diff options
1390 files changed, 27317 insertions, 23387 deletions
diff --git a/.gitignore b/.gitignore index cc5c822e69..9096ff228a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ local.properties .idea .gradletasknamecache project.properties +platform/android/java/lib/.cxx/ platform/android/java/libs/* platform/android/java/app/libs/* diff --git a/.travis.yml b/.travis.yml index 8b58e12563..14ee95e77e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -129,9 +129,6 @@ matrix: before_install: - eval "${MATRIX_EVAL}" - - if [ "$STATIC_CHECKS" = "yes" ]; then - unset SCONS_CACHE; - fi install: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then @@ -150,6 +147,10 @@ install: ./emsdk/emsdk install latest; ./emsdk/emsdk activate latest; fi + - if [ "$STATIC_CHECKS" = "yes" ]; then + unset SCONS_CACHE; + pip3 install --user black pygments; + fi before_script: - if [ "$PLATFORM" = "android" ]; then @@ -160,6 +161,7 @@ before_script: script: - if [ "$STATIC_CHECKS" = "yes" ]; then sh ./misc/travis/clang-format.sh && + sh ./misc/travis/black-format.sh && doc/tools/makerst.py --dry-run doc/classes modules; else scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS && diff --git a/SConstruct b/SConstruct index ed4b3c6242..8fc333a8fa 100644 --- a/SConstruct +++ b/SConstruct @@ -26,48 +26,48 @@ platform_exporters = [] platform_apis = [] for x in sorted(glob.glob("platform/*")): - if (not os.path.isdir(x) or not os.path.exists(x + "/detect.py")): + if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"): continue tmppath = "./" + x sys.path.insert(0, tmppath) import detect - if (os.path.exists(x + "/export/export.cpp")): + if os.path.exists(x + "/export/export.cpp"): platform_exporters.append(x[9:]) - if (os.path.exists(x + "/api/api.cpp")): + if os.path.exists(x + "/api/api.cpp"): platform_apis.append(x[9:]) - if (detect.is_active()): + if detect.is_active(): active_platforms.append(detect.get_name()) active_platform_ids.append(x) - if (detect.can_build()): + if detect.can_build(): x = x.replace("platform/", "") # rest of world x = x.replace("platform\\", "") # win32 platform_list += [x] platform_opts[x] = detect.get_opts() platform_flags[x] = detect.get_flags() sys.path.remove(tmppath) - sys.modules.pop('detect') + sys.modules.pop("detect") module_list = methods.detect_modules() methods.save_active_platforms(active_platforms, active_platform_ids) -custom_tools = ['default'] +custom_tools = ["default"] platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", False)) if os.name == "nt" and (platform_arg == "android" or ARGUMENTS.get("use_mingw", False)): - custom_tools = ['mingw'] -elif platform_arg == 'javascript': + custom_tools = ["mingw"] +elif platform_arg == "javascript": # Use generic POSIX build toolchain for Emscripten. - custom_tools = ['cc', 'c++', 'ar', 'link', 'textfile', 'zip'] + custom_tools = ["cc", "c++", "ar", "link", "textfile", "zip"] env_base = Environment(tools=custom_tools) -if 'TERM' in os.environ: - env_base['ENV']['TERM'] = os.environ['TERM'] -env_base.AppendENVPath('PATH', os.getenv('PATH')) -env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) +if "TERM" in os.environ: + env_base["ENV"]["TERM"] = os.environ["TERM"] +env_base.AppendENVPath("PATH", os.getenv("PATH")) +env_base.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) env_base.disabled_modules = [] env_base.use_ptrcall = False env_base.module_version_string = "" @@ -94,7 +94,7 @@ env_base.SConsignFile(".sconsign{0}.dblite".format(pickle.HIGHEST_PROTOCOL)) # Build options -customs = ['custom.py'] +customs = ["custom.py"] profile = ARGUMENTS.get("profile", False) if profile: @@ -106,62 +106,62 @@ if profile: opts = Variables(customs, ARGUMENTS) # Target build options -opts.Add('arch', "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", '') -opts.Add(EnumVariable('bits', "Target platform bits", 'default', ('default', '32', '64'))) -opts.Add('p', "Platform (alias for 'platform')", '') -opts.Add('platform', "Target platform (%s)" % ('|'.join(platform_list), ), '') -opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release_debug', 'release'))) -opts.Add(EnumVariable('optimize', "Optimization type", 'speed', ('speed', 'size'))) +opts.Add("arch", "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", "") +opts.Add(EnumVariable("bits", "Target platform bits", "default", ("default", "32", "64"))) +opts.Add("p", "Platform (alias for 'platform')", "") +opts.Add("platform", "Target platform (%s)" % ("|".join(platform_list),), "") +opts.Add(EnumVariable("target", "Compilation target", "debug", ("debug", "release_debug", "release"))) +opts.Add(EnumVariable("optimize", "Optimization type", "speed", ("speed", "size"))) -opts.Add(BoolVariable('tools', "Build the tools (a.k.a. the Godot editor)", True)) -opts.Add(BoolVariable('use_lto', 'Use link-time optimization', False)) -opts.Add(BoolVariable('use_precise_math_checks', 'Math checks use very precise epsilon (useful to debug the engine)', False)) +opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Godot editor)", True)) +opts.Add(BoolVariable("use_lto", "Use link-time optimization", False)) +opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) # Components -opts.Add(BoolVariable('deprecated', "Enable deprecated features", True)) -opts.Add(BoolVariable('minizip', "Enable ZIP archive support using minizip", True)) -opts.Add(BoolVariable('xaudio2', "Enable the XAudio2 audio driver", False)) +opts.Add(BoolVariable("deprecated", "Enable deprecated features", True)) +opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True)) +opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver", False)) # Advanced options -opts.Add(BoolVariable('verbose', "Enable verbose output for the compilation", False)) -opts.Add(BoolVariable('progress', "Show a progress indicator during compilation", True)) -opts.Add(EnumVariable('warnings', "Set the level of warnings emitted during compilation", 'all', ('extra', 'all', 'moderate', 'no'))) -opts.Add(BoolVariable('werror', "Treat compiler warnings as errors. Depends on the level of warnings set with 'warnings'", False)) -opts.Add(BoolVariable('dev', "If yes, alias for verbose=yes warnings=extra werror=yes", False)) -opts.Add('extra_suffix', "Custom extra suffix added to the base filename of all generated binary files", '') -opts.Add(BoolVariable('vsproj', "Generate a Visual Studio solution", False)) -opts.Add(EnumVariable('macports_clang', "Build using Clang from MacPorts", 'no', ('no', '5.0', 'devel'))) -opts.Add(BoolVariable('disable_3d', "Disable 3D nodes for a smaller executable", False)) -opts.Add(BoolVariable('disable_advanced_gui', "Disable advanced GUI nodes and behaviors", False)) -opts.Add(BoolVariable('no_editor_splash', "Don't use the custom splash screen for the editor", False)) -opts.Add('system_certs_path', "Use this path as SSL certificates default for editor (for package maintainers)", '') +opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False)) +opts.Add(BoolVariable("progress", "Show a progress indicator during compilation", True)) +opts.Add(EnumVariable("warnings", "Level of compilation warnings", "all", ("extra", "all", "moderate", "no"))) +opts.Add(BoolVariable("werror", "Treat compiler warnings as errors", True)) +opts.Add(BoolVariable("dev", "If yes, alias for verbose=yes warnings=extra werror=yes", False)) +opts.Add("extra_suffix", "Custom extra suffix added to the base filename of all generated binary files", "") +opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False)) +opts.Add(EnumVariable("macports_clang", "Build using Clang from MacPorts", "no", ("no", "5.0", "devel"))) +opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False)) +opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False)) +opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", False)) +opts.Add("system_certs_path", "Use this path as SSL certificates default for editor (for package maintainers)", "") # Thirdparty libraries -#opts.Add(BoolVariable('builtin_assimp', "Use the built-in Assimp library", True)) -opts.Add(BoolVariable('builtin_bullet', "Use the built-in Bullet library", True)) -opts.Add(BoolVariable('builtin_certs', "Bundle default SSL certificates to be used if you don't specify an override in the project settings", True)) -opts.Add(BoolVariable('builtin_enet', "Use the built-in ENet library", True)) -opts.Add(BoolVariable('builtin_freetype', "Use the built-in FreeType library", True)) -opts.Add(BoolVariable('builtin_glslang', "Use the built-in glslang library", True)) -opts.Add(BoolVariable('builtin_libogg', "Use the built-in libogg library", True)) -opts.Add(BoolVariable('builtin_libpng', "Use the built-in libpng library", True)) -opts.Add(BoolVariable('builtin_libtheora', "Use the built-in libtheora library", True)) -opts.Add(BoolVariable('builtin_libvorbis', "Use the built-in libvorbis library", True)) -opts.Add(BoolVariable('builtin_libvpx', "Use the built-in libvpx library", True)) -opts.Add(BoolVariable('builtin_libwebp', "Use the built-in libwebp library", True)) -opts.Add(BoolVariable('builtin_wslay', "Use the built-in wslay library", True)) -opts.Add(BoolVariable('builtin_mbedtls', "Use the built-in mbedTLS library", True)) -opts.Add(BoolVariable('builtin_miniupnpc', "Use the built-in miniupnpc library", True)) -opts.Add(BoolVariable('builtin_opus', "Use the built-in Opus library", True)) -opts.Add(BoolVariable('builtin_pcre2', "Use the built-in PCRE2 library", True)) -opts.Add(BoolVariable('builtin_pcre2_with_jit', "Use JIT compiler for the built-in PCRE2 library", True)) -opts.Add(BoolVariable('builtin_recast', "Use the built-in Recast library", True)) -opts.Add(BoolVariable('builtin_rvo2', "Use the built-in RVO2 library", True)) -opts.Add(BoolVariable('builtin_squish', "Use the built-in squish library", True)) -opts.Add(BoolVariable('builtin_vulkan', "Use the built-in Vulkan loader library and headers", True)) -opts.Add(BoolVariable('builtin_xatlas', "Use the built-in xatlas library", True)) -opts.Add(BoolVariable('builtin_zlib', "Use the built-in zlib library", True)) -opts.Add(BoolVariable('builtin_zstd', "Use the built-in Zstd library", True)) +# opts.Add(BoolVariable('builtin_assimp', "Use the built-in Assimp library", True)) +opts.Add(BoolVariable("builtin_bullet", "Use the built-in Bullet library", True)) +opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundles", True)) +opts.Add(BoolVariable("builtin_enet", "Use the built-in ENet library", True)) +opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True)) +opts.Add(BoolVariable("builtin_glslang", "Use the built-in glslang library", True)) +opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True)) +opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True)) +opts.Add(BoolVariable("builtin_libtheora", "Use the built-in libtheora library", True)) +opts.Add(BoolVariable("builtin_libvorbis", "Use the built-in libvorbis library", True)) +opts.Add(BoolVariable("builtin_libvpx", "Use the built-in libvpx library", True)) +opts.Add(BoolVariable("builtin_libwebp", "Use the built-in libwebp library", True)) +opts.Add(BoolVariable("builtin_wslay", "Use the built-in wslay library", True)) +opts.Add(BoolVariable("builtin_mbedtls", "Use the built-in mbedTLS library", True)) +opts.Add(BoolVariable("builtin_miniupnpc", "Use the built-in miniupnpc library", True)) +opts.Add(BoolVariable("builtin_opus", "Use the built-in Opus library", True)) +opts.Add(BoolVariable("builtin_pcre2", "Use the built-in PCRE2 library", True)) +opts.Add(BoolVariable("builtin_pcre2_with_jit", "Use JIT compiler for the built-in PCRE2 library", True)) +opts.Add(BoolVariable("builtin_recast", "Use the built-in Recast library", True)) +opts.Add(BoolVariable("builtin_rvo2", "Use the built-in RVO2 library", True)) +opts.Add(BoolVariable("builtin_squish", "Use the built-in squish library", True)) +opts.Add(BoolVariable("builtin_vulkan", "Use the built-in Vulkan loader library and headers", True)) +opts.Add(BoolVariable("builtin_xatlas", "Use the built-in xatlas library", True)) +opts.Add(BoolVariable("builtin_zlib", "Use the built-in zlib library", True)) +opts.Add(BoolVariable("builtin_zstd", "Use the built-in Zstd library", True)) # Compilation environment setup opts.Add("CXX", "C++ compiler") @@ -184,63 +184,64 @@ for x in module_list: tmppath = "./modules/" + x sys.path.insert(0, tmppath) import config + enabled_attr = getattr(config, "is_enabled", None) - if (callable(enabled_attr) and not config.is_enabled()): + if callable(enabled_attr) and not config.is_enabled(): module_enabled = False sys.path.remove(tmppath) - sys.modules.pop('config') - opts.Add(BoolVariable('module_' + x + '_enabled', "Enable module '%s'" % (x, ), module_enabled)) + sys.modules.pop("config") + opts.Add(BoolVariable("module_" + x + "_enabled", "Enable module '%s'" % (x,), module_enabled)) opts.Update(env_base) # update environment Help(opts.GenerateHelpText(env_base)) # generate help # add default include paths -env_base.Prepend(CPPPATH=['#']) +env_base.Prepend(CPPPATH=["#"]) # configure ENV for platform env_base.platform_exporters = platform_exporters env_base.platform_apis = platform_apis -if (env_base["use_precise_math_checks"]): - env_base.Append(CPPDEFINES=['PRECISE_MATH_CHECKS']) +if env_base["use_precise_math_checks"]: + env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"]) -if (env_base['target'] == 'debug'): - env_base.Append(CPPDEFINES=['DEBUG_MEMORY_ALLOC','DISABLE_FORCED_INLINE']) +if env_base["target"] == "debug": + env_base.Append(CPPDEFINES=["DEBUG_MEMORY_ALLOC", "DISABLE_FORCED_INLINE"]) # The two options below speed up incremental builds, but reduce the certainty that all files # will properly be rebuilt. As such, we only enable them for debug (dev) builds, not release. # To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed. # http://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792 - env_base.Decider('MD5-timestamp') + env_base.Decider("MD5-timestamp") # Use cached implicit dependencies by default. Can be overridden by specifying `--implicit-deps-changed` in the command line. # http://scons.org/doc/production/HTML/scons-user/ch06s04.html - env_base.SetOption('implicit_cache', 1) + env_base.SetOption("implicit_cache", 1) -if (env_base['no_editor_splash']): - env_base.Append(CPPDEFINES=['NO_EDITOR_SPLASH']) +if env_base["no_editor_splash"]: + env_base.Append(CPPDEFINES=["NO_EDITOR_SPLASH"]) -if not env_base['deprecated']: - env_base.Append(CPPDEFINES=['DISABLE_DEPRECATED']) +if not env_base["deprecated"]: + env_base.Append(CPPDEFINES=["DISABLE_DEPRECATED"]) env_base.platforms = {} selected_platform = "" -if env_base['platform'] != "": - selected_platform = env_base['platform'] -elif env_base['p'] != "": - selected_platform = env_base['p'] +if env_base["platform"] != "": + selected_platform = env_base["platform"] +elif env_base["p"] != "": + selected_platform = env_base["p"] env_base["platform"] = selected_platform else: # Missing `platform` argument, try to detect platform automatically - if sys.platform.startswith('linux'): - selected_platform = 'linuxbsd' - elif sys.platform == 'darwin': - selected_platform = 'osx' - elif sys.platform == 'win32': - selected_platform = 'windows' + if sys.platform.startswith("linux"): + selected_platform = "linuxbsd" + elif sys.platform == "darwin": + selected_platform = "osx" + elif sys.platform == "win32": + selected_platform = "windows" else: print("Could not detect platform automatically. Supported platforms:") for x in platform_list: @@ -251,21 +252,30 @@ else: print("Automatically detected platform: " + selected_platform) env_base["platform"] = selected_platform +if selected_platform in ["linux", "bsd", "x11"]: + if selected_platform == "x11": + # Deprecated alias kept for compatibility. + print('Platform "x11" has been renamed to "linuxbsd" in Godot 4.0. Building for platform "linuxbsd".') + # Alias for convenience. + selected_platform = "linuxbsd" + env_base["platform"] = selected_platform + if selected_platform in platform_list: tmppath = "./platform/" + selected_platform sys.path.insert(0, tmppath) import detect + if "create" in dir(detect): env = detect.create(env_base) else: env = env_base.Clone() - if env['dev']: - env['verbose'] = True - env['warnings'] = "extra" - env['werror'] = True + if env["dev"]: + env["verbose"] = True + env["warnings"] = "extra" + env["werror"] = True - if env['vsproj']: + if env["vsproj"]: env.vs_incs = [] env.vs_srcs = [] @@ -278,7 +288,7 @@ if selected_platform in platform_list: pieces = fname.split(".") if len(pieces) > 0: basename = pieces[0] - basename = basename.replace('\\\\', '/') + basename = basename.replace("\\\\", "/") if os.path.isfile(basename + ".h"): env.vs_incs = env.vs_incs + [basename + ".h"] elif os.path.isfile(basename + ".hpp"): @@ -287,28 +297,29 @@ if selected_platform in platform_list: env.vs_srcs = env.vs_srcs + [basename + ".c"] elif os.path.isfile(basename + ".cpp"): env.vs_srcs = env.vs_srcs + [basename + ".cpp"] + env.AddToVSProject = AddToVSProject env.extra_suffix = "" - if env["extra_suffix"] != '': - env.extra_suffix += '.' + env["extra_suffix"] + if env["extra_suffix"] != "": + env.extra_suffix += "." + env["extra_suffix"] # Environment flags - CCFLAGS = env.get('CCFLAGS', '') - env['CCFLAGS'] = '' + CCFLAGS = env.get("CCFLAGS", "") + env["CCFLAGS"] = "" env.Append(CCFLAGS=str(CCFLAGS).split()) - CFLAGS = env.get('CFLAGS', '') - env['CFLAGS'] = '' + CFLAGS = env.get("CFLAGS", "") + env["CFLAGS"] = "" env.Append(CFLAGS=str(CFLAGS).split()) - CXXFLAGS = env.get('CXXFLAGS', '') - env['CXXFLAGS'] = '' + CXXFLAGS = env.get("CXXFLAGS", "") + env["CXXFLAGS"] = "" env.Append(CXXFLAGS=str(CXXFLAGS).split()) - LINKFLAGS = env.get('LINKFLAGS', '') - env['LINKFLAGS'] = '' + LINKFLAGS = env.get("LINKFLAGS", "") + env["LINKFLAGS"] = "" env.Append(LINKFLAGS=str(LINKFLAGS).split()) # Platform specific flags @@ -327,12 +338,12 @@ if selected_platform in platform_list: if not env.msvc: # Specifying GNU extensions support explicitly, which are supported by # both GCC and Clang. Both currently default to gnu11 and gnu++14. - env.Prepend(CFLAGS=['-std=gnu11']) - env.Prepend(CXXFLAGS=['-std=gnu++17']) + env.Prepend(CFLAGS=["-std=gnu11"]) + env.Prepend(CXXFLAGS=["-std=gnu++17"]) else: # MSVC doesn't have clear C standard support, /std only covers C++. # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features. - env.Prepend(CCFLAGS=['/std:c++17']) + env.Prepend(CCFLAGS=["/std:c++17"]) # Enforce our minimal compiler version requirements cc_version = methods.get_compiler_version(env) or [-1, -1] @@ -343,16 +354,20 @@ if selected_platform in platform_list: # GCC 8 before 8.4 has a regression in the support of guaranteed copy elision # which causes a build failure: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521 if cc_version_major == 8 and cc_version_minor < 4: - print("Detected GCC 8 version < 8.4, which is not supported due to a " - "regression in its C++17 guaranteed copy elision support. Use a " - "newer GCC version, or Clang 6 or later by passing \"use_llvm=yes\" " - "to the SCons command line.") + print( + "Detected GCC 8 version < 8.4, which is not supported due to a " + "regression in its C++17 guaranteed copy elision support. Use a " + 'newer GCC version, or Clang 6 or later by passing "use_llvm=yes" ' + "to the SCons command line." + ) sys.exit(255) elif cc_version_major < 7: - print("Detected GCC version older than 7, which does not fully support " - "C++17. Supported versions are GCC 7, 9 and later. Use a newer GCC " - "version, or Clang 6 or later by passing \"use_llvm=yes\" to the " - "SCons command line.") + print( + "Detected GCC version older than 7, which does not fully support " + "C++17. Supported versions are GCC 7, 9 and later. Use a newer GCC " + 'version, or Clang 6 or later by passing "use_llvm=yes" to the ' + "SCons command line." + ) sys.exit(255) elif methods.using_clang(env): # Apple LLVM versions differ from upstream LLVM version \o/, compare @@ -360,87 +375,100 @@ if selected_platform in platform_list: if env["platform"] == "osx" or env["platform"] == "iphone": vanilla = methods.is_vanilla_clang(env) if vanilla and cc_version_major < 6: - print("Detected Clang version older than 6, which does not fully support " - "C++17. Supported versions are Clang 6 and later.") + print( + "Detected Clang version older than 6, which does not fully support " + "C++17. Supported versions are Clang 6 and later." + ) sys.exit(255) elif not vanilla and cc_version_major < 10: - print("Detected Apple Clang version older than 10, which does not fully " - "support C++17. Supported versions are Apple Clang 10 and later.") + print( + "Detected Apple Clang version older than 10, which does not fully " + "support C++17. Supported versions are Apple Clang 10 and later." + ) sys.exit(255) elif cc_version_major < 6: - print("Detected Clang version older than 6, which does not fully support " - "C++17. Supported versions are Clang 6 and later.") + print( + "Detected Clang version older than 6, which does not fully support " + "C++17. Supported versions are Clang 6 and later." + ) sys.exit(255) # Configure compiler warnings if env.msvc: # 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'): - env.Append(CCFLAGS=['/W3'] + disable_nonessential_warnings) - elif (env["warnings"] == 'moderate'): - env.Append(CCFLAGS=['/W2'] + disable_nonessential_warnings) - else: # 'no' - env.Append(CCFLAGS=['/w']) + disable_nonessential_warnings = ["/wd4267", "/wd4244", "/wd4305", "/wd4018", "/wd4800"] + if env["warnings"] == "extra": + env.Append(CCFLAGS=["/Wall"]) # Implies /W4 + elif env["warnings"] == "all": + env.Append(CCFLAGS=["/W3"] + disable_nonessential_warnings) + elif env["warnings"] == "moderate": + env.Append(CCFLAGS=["/W2"] + disable_nonessential_warnings) + else: # 'no' + env.Append(CCFLAGS=["/w"]) # Set exception handling model to avoid warnings caused by Windows system headers. - env.Append(CCFLAGS=['/EHsc']) - if (env["werror"]): - env.Append(CCFLAGS=['/WX']) + env.Append(CCFLAGS=["/EHsc"]) + if env["werror"]: + env.Append(CCFLAGS=["/WX"]) # Force to use Unicode encoding - env.Append(MSVC_FLAGS=['/utf8']) - else: # Rest of the world + env.Append(MSVC_FLAGS=["/utf8"]) + else: # Rest of the world shadow_local_warning = [] - all_plus_warnings = ['-Wwrite-strings'] + all_plus_warnings = ["-Wwrite-strings"] if methods.using_gcc(env): if cc_version_major >= 7: - shadow_local_warning = ['-Wshadow-local'] + shadow_local_warning = ["-Wshadow-local"] - if (env["warnings"] == 'extra'): - env.Append(CCFLAGS=['-Wall', '-Wextra', '-Wno-unused-parameter'] - + all_plus_warnings + shadow_local_warning) - env.Append(CXXFLAGS=['-Wctor-dtor-privacy', '-Wnon-virtual-dtor']) + if env["warnings"] == "extra": + env.Append(CCFLAGS=["-Wall", "-Wextra", "-Wno-unused-parameter"] + all_plus_warnings + shadow_local_warning) + env.Append(CXXFLAGS=["-Wctor-dtor-privacy", "-Wnon-virtual-dtor"]) if methods.using_gcc(env): - env.Append(CCFLAGS=['-Walloc-zero', - '-Wduplicated-branches', '-Wduplicated-cond', - '-Wstringop-overflow=4', '-Wlogical-op']) + env.Append( + CCFLAGS=[ + "-Walloc-zero", + "-Wduplicated-branches", + "-Wduplicated-cond", + "-Wstringop-overflow=4", + "-Wlogical-op", + ] + ) # -Wnoexcept was removed temporarily due to GH-36325. - env.Append(CXXFLAGS=['-Wplacement-new=1']) + env.Append(CXXFLAGS=["-Wplacement-new=1"]) if cc_version_major >= 9: - env.Append(CCFLAGS=['-Wattribute-alias=2']) + env.Append(CCFLAGS=["-Wattribute-alias=2"]) if methods.using_clang(env): - env.Append(CCFLAGS=['-Wimplicit-fallthrough']) - elif (env["warnings"] == 'all'): - env.Append(CCFLAGS=['-Wall'] + shadow_local_warning) - elif (env["warnings"] == 'moderate'): - env.Append(CCFLAGS=['-Wall', '-Wno-unused'] + shadow_local_warning) - else: # 'no' - env.Append(CCFLAGS=['-w']) - if (env["werror"]): - env.Append(CCFLAGS=['-Werror']) + env.Append(CCFLAGS=["-Wimplicit-fallthrough"]) + elif env["warnings"] == "all": + env.Append(CCFLAGS=["-Wall"] + shadow_local_warning) + elif env["warnings"] == "moderate": + env.Append(CCFLAGS=["-Wall", "-Wno-unused"] + shadow_local_warning) + else: # 'no' + env.Append(CCFLAGS=["-w"]) + if env["werror"]: + env.Append(CCFLAGS=["-Werror"]) # FIXME: Temporary workaround after the Vulkan merge, remove once warnings are fixed. if methods.using_gcc(env): - env.Append(CXXFLAGS=['-Wno-error=cpp']) + env.Append(CXXFLAGS=["-Wno-error=cpp"]) + if cc_version_major == 7: # Bogus warning fixed in 8+. + env.Append(CCFLAGS=["-Wno-error=strict-overflow"]) else: - env.Append(CXXFLAGS=['-Wno-error=#warnings']) - else: # always enable those errors - env.Append(CCFLAGS=['-Werror=return-type']) + env.Append(CXXFLAGS=["-Wno-error=#warnings"]) + else: # always enable those errors + env.Append(CCFLAGS=["-Werror=return-type"]) - if (hasattr(detect, 'get_program_suffix')): + if hasattr(detect, "get_program_suffix"): suffix = "." + detect.get_program_suffix() else: suffix = "." + selected_platform - if (env["target"] == "release"): + if env["target"] == "release": if env["tools"]: print("Tools can only be built with targets 'debug' and 'release_debug'.") sys.exit(255) suffix += ".opt" - env.Append(CPPDEFINES=['NDEBUG']) + env.Append(CPPDEFINES=["NDEBUG"]) - elif (env["target"] == "release_debug"): + elif env["target"] == "release_debug": if env["tools"]: suffix += ".opt.tools" else: @@ -453,27 +481,28 @@ if selected_platform in platform_list: if env["arch"] != "": suffix += "." + env["arch"] - elif (env["bits"] == "32"): + elif env["bits"] == "32": suffix += ".32" - elif (env["bits"] == "64"): + elif env["bits"] == "64": suffix += ".64" suffix += env.extra_suffix sys.path.remove(tmppath) - sys.modules.pop('detect') + sys.modules.pop("detect") env.module_list = [] env.module_icons_paths = [] env.doc_class_path = {} for x in sorted(module_list): - if not env['module_' + x + '_enabled']: + if not env["module_" + x + "_enabled"]: continue tmppath = "./modules/" + x sys.path.insert(0, tmppath) env.current_module = x import config + if config.can_build(env, selected_platform): config.configure(env) env.module_list.append(x) @@ -495,7 +524,7 @@ if selected_platform in platform_list: env.module_icons_paths.append("modules/" + x + "/" + "icons") sys.path.remove(tmppath) - sys.modules.pop('config') + sys.modules.pop("config") methods.update_version(env.module_version_string) @@ -514,45 +543,66 @@ if selected_platform in platform_list: env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"] env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"] - if (env.use_ptrcall): - env.Append(CPPDEFINES=['PTRCALL_ENABLED']) - if env['tools']: - env.Append(CPPDEFINES=['TOOLS_ENABLED']) - if env['disable_3d']: - if env['tools']: - print("Build option 'disable_3d=yes' cannot be used with 'tools=yes' (editor), only with 'tools=no' (export template).") + if env.use_ptrcall: + env.Append(CPPDEFINES=["PTRCALL_ENABLED"]) + if env["tools"]: + env.Append(CPPDEFINES=["TOOLS_ENABLED"]) + if env["disable_3d"]: + if env["tools"]: + print( + "Build option 'disable_3d=yes' cannot be used with 'tools=yes' (editor), " + "only with 'tools=no' (export template)." + ) sys.exit(255) else: - env.Append(CPPDEFINES=['_3D_DISABLED']) - if env['disable_advanced_gui']: - if env['tools']: - print("Build option 'disable_advanced_gui=yes' cannot be used with 'tools=yes' (editor), only with 'tools=no' (export template).") + env.Append(CPPDEFINES=["_3D_DISABLED"]) + if env["disable_advanced_gui"]: + if env["tools"]: + print( + "Build option 'disable_advanced_gui=yes' cannot be used with 'tools=yes' (editor), " + "only with 'tools=no' (export template)." + ) sys.exit(255) else: - env.Append(CPPDEFINES=['ADVANCED_GUI_DISABLED']) - if env['minizip']: - env.Append(CPPDEFINES=['MINIZIP_ENABLED']) + env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"]) + if env["minizip"]: + env.Append(CPPDEFINES=["MINIZIP_ENABLED"]) - editor_module_list = ['regex'] + editor_module_list = ["regex"] for x in editor_module_list: - if not env['module_' + x + '_enabled']: - if env['tools']: - print("Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), only with 'tools=no' (export template).") + if not env["module_" + x + "_enabled"]: + if env["tools"]: + print( + "Build option 'module_" + x + "_enabled=no' cannot be used with 'tools=yes' (editor), " + "only with 'tools=no' (export template)." + ) sys.exit(255) - if not env['verbose']: + if not env["verbose"]: methods.no_verbose(sys, env) - if (not env["platform"] == "server"): - env.Append(BUILDERS = { 'GLES2_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles2_headers), suffix='glsl.gen.h', src_suffix='.glsl')}) - env.Append(BUILDERS = { 'RD_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_rd_headers), suffix='glsl.gen.h', src_suffix='.glsl')}) + if not env["platform"] == "server": + env.Append( + BUILDERS={ + "GLES2_GLSL": env.Builder( + action=run_in_subprocess(gles_builders.build_gles2_headers), suffix="glsl.gen.h", src_suffix=".glsl" + ) + } + ) + env.Append( + BUILDERS={ + "RD_GLSL": env.Builder( + action=run_in_subprocess(gles_builders.build_rd_headers), suffix="glsl.gen.h", src_suffix=".glsl" + ) + } + ) scons_cache_path = os.environ.get("SCONS_CACHE") if scons_cache_path != None: CacheDir(scons_cache_path) print("Scons cache enabled... (path: '" + scons_cache_path + "')") - Export('env') + Export("env") # build subdirs, the build order is dependent on link order. @@ -569,16 +619,16 @@ if selected_platform in platform_list: SConscript("platform/" + selected_platform + "/SCsub") # build selected platform # Microsoft Visual Studio Project Generation - if env['vsproj']: - env['CPPPATH'] = [Dir(path) for path in env['CPPPATH']] + if env["vsproj"]: + env["CPPPATH"] = [Dir(path) for path in env["CPPPATH"]] methods.generate_vs_project(env, GetOption("num_jobs")) methods.generate_cpp_hint_file("cpp.hint") # Check for the existence of headers conf = Configure(env) - if ("check_c_headers" in env): + if "check_c_headers" in env: for header in env["check_c_headers"]: - if (conf.CheckCHeader(header[0])): + if conf.CheckCHeader(header[0]): env.AppendUnique(CPPDEFINES=[header[1]]) elif selected_platform != "": @@ -600,26 +650,30 @@ elif selected_platform != "": sys.exit(255) # The following only makes sense when the env is defined, and assumes it is -if 'env' in locals(): +if "env" in locals(): screen = sys.stdout # Progress reporting is not available in non-TTY environments since it # messes with the output (for example, when writing to a file) - show_progress = (env['progress'] and sys.stdout.isatty()) + show_progress = env["progress"] and sys.stdout.isatty() node_count = 0 node_count_max = 0 node_count_interval = 1 - node_count_fname = str(env.Dir('#')) + '/.scons_node_count' + node_count_fname = str(env.Dir("#")) + "/.scons_node_count" import time, math class cache_progress: # The default is 1 GB cache and 12 hours half life - def __init__(self, path = None, limit = 1073741824, half_life = 43200): + def __init__(self, path=None, limit=1073741824, half_life=43200): self.path = path self.limit = limit self.exponent_scale = math.log(2) / half_life - if env['verbose'] and path != None: - screen.write('Current cache limit is ' + self.convert_size(limit) + ' (used: ' + self.convert_size(self.get_size(path)) + ')\n') + if env["verbose"] and path != None: + screen.write( + "Current cache limit is {} (used: {})\n".format( + self.convert_size(limit), self.convert_size(self.get_size(path)) + ) + ) self.delete(self.file_list()) def __call__(self, node, *args, **kw): @@ -627,22 +681,22 @@ if 'env' in locals(): if show_progress: # Print the progress percentage node_count += node_count_interval - if (node_count_max > 0 and node_count <= node_count_max): - screen.write('\r[%3d%%] ' % (node_count * 100 / node_count_max)) + if node_count_max > 0 and node_count <= node_count_max: + screen.write("\r[%3d%%] " % (node_count * 100 / node_count_max)) screen.flush() - elif (node_count_max > 0 and node_count > node_count_max): - screen.write('\r[100%] ') + elif node_count_max > 0 and node_count > node_count_max: + screen.write("\r[100%] ") screen.flush() else: - screen.write('\r[Initial build] ') + screen.write("\r[Initial build] ") screen.flush() def delete(self, files): if len(files) == 0: return - if env['verbose']: + if env["verbose"]: # Utter something - screen.write('\rPurging %d %s from cache...\n' % (len(files), len(files) > 1 and 'files' or 'file')) + screen.write("\rPurging %d %s from cache...\n" % (len(files), len(files) > 1 and "files" or "file")) [os.remove(f) for f in files] def file_list(self): @@ -651,7 +705,7 @@ if 'env' in locals(): return [] # Gather a list of (filename, (size, atime)) within the # cache directory - file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, '*', '*'))] + file_stat = [(x, os.stat(x)[6:8]) for x in glob.glob(os.path.join(self.path, "*", "*"))] if file_stat == []: # Nothing to do return [] @@ -666,7 +720,7 @@ if 'env' in locals(): # Search for the first entry where the storage limit is # reached sum, mark = 0, None - for i,x in enumerate(file_stat): + for i, x in enumerate(file_stat): sum += x[1] if sum > self.limit: mark = i @@ -685,7 +739,7 @@ if 'env' in locals(): s = round(size_bytes / p, 2) return "%s %s" % (int(s) if i == 0 else s, size_name[i]) - def get_size(self, start_path = '.'): + def get_size(self, start_path="."): total_size = 0 for dirpath, dirnames, filenames in os.walk(start_path): for f in filenames: @@ -695,8 +749,8 @@ if 'env' in locals(): def progress_finish(target, source, env): global node_count, progressor - with open(node_count_fname, 'w') as f: - f.write('%d\n' % node_count) + with open(node_count_fname, "w") as f: + f.write("%d\n" % node_count) progressor.delete(progressor.file_list()) try: @@ -710,7 +764,7 @@ if 'env' in locals(): # cache directory to a size not larger than cache_limit. cache_limit = float(os.getenv("SCONS_CACHE_LIMIT", 1024)) * 1024 * 1024 progressor = cache_progress(cache_directory, cache_limit) - Progress(progressor, interval = node_count_interval) + Progress(progressor, interval=node_count_interval) - progress_finish_command = Command('progress_finish', [], progress_finish) + progress_finish_command = Command("progress_finish", [], progress_finish) AlwaysBuild(progress_finish_command) diff --git a/core/SCsub b/core/SCsub index ca003ce931..0ab4f11d87 100644 --- a/core/SCsub +++ b/core/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") import core_builders import make_binders @@ -11,31 +11,32 @@ env.core_sources = [] # Generate AES256 script encryption key import os + txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" -if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): +if "SCRIPT_AES256_ENCRYPTION_KEY" in os.environ: e = os.environ["SCRIPT_AES256_ENCRYPTION_KEY"] txt = "" ec_valid = True - if (len(e) != 64): + if len(e) != 64: ec_valid = False else: for i in range(len(e) >> 1): - if (i > 0): + if i > 0: txt += "," - txts = "0x" + e[i * 2:i * 2 + 2] + txts = "0x" + e[i * 2 : i * 2 + 2] try: int(txts, 16) except: ec_valid = False txt += txts - if (not ec_valid): + if not ec_valid: txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" print("Invalid AES256 encryption key, not 64 bits hex: " + e) # NOTE: It is safe to generate this file here, since this is still executed serially with open("script_encryption_key.gen.cpp", "w") as f: - f.write("#include \"core/project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") + f.write('#include "core/project_settings.h"\nuint8_t script_encryption_key[32]={' + txt + "};\n") # Add required thirdparty code. @@ -49,7 +50,6 @@ thirdparty_misc_sources = [ # C sources "fastlz.c", "smaz.c", - # C++ sources "hq2x.cpp", "pcg.cpp", @@ -60,30 +60,30 @@ thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_mis env_thirdparty.add_source_files(env.core_sources, thirdparty_misc_sources) # Zlib library, can be unbundled -if env['builtin_zlib']: - thirdparty_zlib_dir = "#thirdparty/zlib/" - thirdparty_zlib_sources = [ - "adler32.c", - "compress.c", - "crc32.c", - "deflate.c", - "infback.c", - "inffast.c", - "inflate.c", - "inftrees.c", - "trees.c", - "uncompr.c", - "zutil.c", - ] - thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources] - - env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir]) - # Needs to be available in main env too - env.Prepend(CPPPATH=[thirdparty_zlib_dir]) - if (env['target'] == 'debug'): - env_thirdparty.Append(CPPDEFINES=['ZLIB_DEBUG']) - - env_thirdparty.add_source_files(env.core_sources, thirdparty_zlib_sources) +if env["builtin_zlib"]: + thirdparty_zlib_dir = "#thirdparty/zlib/" + thirdparty_zlib_sources = [ + "adler32.c", + "compress.c", + "crc32.c", + "deflate.c", + "infback.c", + "inffast.c", + "inflate.c", + "inftrees.c", + "trees.c", + "uncompr.c", + "zutil.c", + ] + thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources] + + env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir]) + # Needs to be available in main env too + env.Prepend(CPPPATH=[thirdparty_zlib_dir]) + if env["target"] == "debug": + env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"]) + + env_thirdparty.add_source_files(env.core_sources, thirdparty_zlib_sources) # Minizip library, could be unbundled in theory # However, our version has some custom modifications, so it won't compile with the system one @@ -99,7 +99,7 @@ env_thirdparty.add_source_files(env.core_sources, thirdparty_minizip_sources) # Zstd library, can be unbundled in theory # though we currently use some private symbols # https://github.com/godotengine/godot/issues/17374 -if env['builtin_zstd']: +if env["builtin_zstd"]: thirdparty_zstd_dir = "#thirdparty/zstd/" thirdparty_zstd_sources = [ "common/debug.c", @@ -142,32 +142,45 @@ if env['builtin_zstd']: env.add_source_files(env.core_sources, "*.cpp") # Certificates -env.Depends("#core/io/certs_compressed.gen.h", ["#thirdparty/certs/ca-certificates.crt", env.Value(env['builtin_certs']), env.Value(env['system_certs_path'])]) -env.CommandNoCache("#core/io/certs_compressed.gen.h", "#thirdparty/certs/ca-certificates.crt", run_in_subprocess(core_builders.make_certs_header)) +env.Depends( + "#core/io/certs_compressed.gen.h", + ["#thirdparty/certs/ca-certificates.crt", env.Value(env["builtin_certs"]), env.Value(env["system_certs_path"])], +) +env.CommandNoCache( + "#core/io/certs_compressed.gen.h", + "#thirdparty/certs/ca-certificates.crt", + run_in_subprocess(core_builders.make_certs_header), +) # Make binders -env.CommandNoCache(['method_bind.gen.inc', 'method_bind_ext.gen.inc', 'method_bind_free_func.gen.inc'], 'make_binders.py', run_in_subprocess(make_binders.run)) +env.CommandNoCache( + ["method_bind.gen.inc", "method_bind_ext.gen.inc", "method_bind_free_func.gen.inc"], + "make_binders.py", + run_in_subprocess(make_binders.run), +) # Authors -env.Depends('#core/authors.gen.h', "../AUTHORS.md") -env.CommandNoCache('#core/authors.gen.h', "../AUTHORS.md", run_in_subprocess(core_builders.make_authors_header)) +env.Depends("#core/authors.gen.h", "../AUTHORS.md") +env.CommandNoCache("#core/authors.gen.h", "../AUTHORS.md", run_in_subprocess(core_builders.make_authors_header)) # Donors -env.Depends('#core/donors.gen.h', "../DONORS.md") -env.CommandNoCache('#core/donors.gen.h', "../DONORS.md", run_in_subprocess(core_builders.make_donors_header)) +env.Depends("#core/donors.gen.h", "../DONORS.md") +env.CommandNoCache("#core/donors.gen.h", "../DONORS.md", run_in_subprocess(core_builders.make_donors_header)) # License -env.Depends('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"]) -env.CommandNoCache('#core/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], run_in_subprocess(core_builders.make_license_header)) +env.Depends("#core/license.gen.h", ["../COPYRIGHT.txt", "../LICENSE.txt"]) +env.CommandNoCache( + "#core/license.gen.h", ["../COPYRIGHT.txt", "../LICENSE.txt"], run_in_subprocess(core_builders.make_license_header) +) # Chain load SCsubs -SConscript('os/SCsub') -SConscript('math/SCsub') -SConscript('crypto/SCsub') -SConscript('io/SCsub') -SConscript('debugger/SCsub') -SConscript('input/SCsub') -SConscript('bind/SCsub') +SConscript("os/SCsub") +SConscript("math/SCsub") +SConscript("crypto/SCsub") +SConscript("io/SCsub") +SConscript("debugger/SCsub") +SConscript("input/SCsub") +SConscript("bind/SCsub") # Build it all as a library diff --git a/core/array.cpp b/core/array.cpp index 7eb15ea934..d65bddae61 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -67,7 +67,7 @@ void Array::_unref() const { if (_p->refcount.unref()) { memdelete(_p); } - _p = NULL; + _p = nullptr; } Variant &Array::operator[](int p_idx) { @@ -467,7 +467,7 @@ const void *Array::id() const { Array::Array(const Array &p_from) { - _p = NULL; + _p = nullptr; _ref(p_from); } diff --git a/core/bind/SCsub b/core/bind/SCsub index 1c5f954470..19a6549225 100644 --- a/core/bind/SCsub +++ b/core/bind/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.core_sources, "*.cpp") diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0236523200..e8955c05df 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -62,7 +62,7 @@ static const unsigned int MONTH_DAYS_TABLE[2][12] = { { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; -_ResourceLoader *_ResourceLoader::singleton = NULL; +_ResourceLoader *_ResourceLoader::singleton = nullptr; Error _ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads) { @@ -173,7 +173,7 @@ Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) return ret; } -_ResourceSaver *_ResourceSaver::singleton = NULL; +_ResourceSaver *_ResourceSaver::singleton = nullptr; void _ResourceSaver::_bind_methods() { @@ -778,7 +778,7 @@ Vector<String> _OS::get_granted_permissions() const { String _OS::get_unique_id() const { return OS::get_singleton()->get_unique_id(); } -_OS *_OS::singleton = NULL; +_OS *_OS::singleton = nullptr; void _OS::_bind_methods() { @@ -916,7 +916,7 @@ _OS::_OS() { ///////////////////// GEOMETRY -_Geometry *_Geometry::singleton = NULL; +_Geometry *_Geometry::singleton = nullptr; _Geometry *_Geometry::get_singleton() { @@ -1363,11 +1363,11 @@ void _File::close() { if (f) memdelete(f); - f = NULL; + f = nullptr; } bool _File::is_open() const { - return f != NULL; + return f != nullptr; } String _File::get_path() const { @@ -1630,7 +1630,7 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) { ERR_FAIL_COND_MSG(!f, "File must be opened before use."); int len; - Error err = encode_variant(p_var, NULL, len, p_full_objects); + Error err = encode_variant(p_var, nullptr, len, p_full_objects); ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant."); Vector<uint8_t> buff; @@ -1654,7 +1654,7 @@ Variant _File::get_var(bool p_allow_objects) const { const uint8_t *r = buff.ptr(); Variant v; - Error err = decode_variant(v, &r[0], len, NULL, p_allow_objects); + Error err = decode_variant(v, &r[0], len, nullptr, p_allow_objects); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to encode Variant."); return v; @@ -1733,7 +1733,7 @@ void _File::_bind_methods() { _File::_File() { - f = NULL; + f = nullptr; eswap = false; } @@ -1934,7 +1934,7 @@ _Directory::~_Directory() { memdelete(d); } -_Marshalls *_Marshalls::singleton = NULL; +_Marshalls *_Marshalls::singleton = nullptr; _Marshalls *_Marshalls::get_singleton() { return singleton; @@ -1943,7 +1943,7 @@ _Marshalls *_Marshalls::get_singleton() { String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects) { int len; - Error err = encode_variant(p_var, NULL, len, p_full_objects); + Error err = encode_variant(p_var, nullptr, len, p_full_objects); ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant."); Vector<uint8_t> buff; @@ -1972,7 +1972,7 @@ Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects) ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, Variant()); Variant v; - Error err = decode_variant(v, &w[0], len, NULL, p_allow_objects); + Error err = decode_variant(v, &w[0], len, nullptr, p_allow_objects); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant."); return v; @@ -2151,7 +2151,7 @@ Error _Thread::start(Object *p_instance, const StringName &p_method, const Varia if (!thread) { active = false; target_method = StringName(); - target_instance = NULL; + target_instance = nullptr; userdata = Variant(); return ERR_CANT_CREATE; } @@ -2179,11 +2179,11 @@ Variant _Thread::wait_to_finish() { Variant r = ret; active = false; target_method = StringName(); - target_instance = NULL; + target_instance = nullptr; userdata = Variant(); if (thread) memdelete(thread); - thread = NULL; + thread = nullptr; return r; } @@ -2202,8 +2202,8 @@ void _Thread::_bind_methods() { _Thread::_Thread() { active = false; - thread = NULL; - target_instance = NULL; + thread = nullptr; + target_instance = nullptr; } _Thread::~_Thread() { @@ -2581,7 +2581,7 @@ void _Engine::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix"); } -_Engine *_Engine::singleton = NULL; +_Engine *_Engine::singleton = nullptr; _Engine::_Engine() { singleton = this; @@ -2657,7 +2657,7 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) { return result; } -_JSON *_JSON::singleton = NULL; +_JSON *_JSON::singleton = nullptr; _JSON::_JSON() { singleton = this; diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 510d87844d..d5f44cdc44 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -502,7 +502,7 @@ public: String base64_to_utf8(const String &p_str); _Marshalls() { singleton = this; } - ~_Marshalls() { singleton = NULL; } + ~_Marshalls() { singleton = nullptr; } }; class _Mutex : public Reference { diff --git a/core/callable.cpp b/core/callable.cpp index 2bb9ab167b..6a5dc151e5 100644 --- a/core/callable.cpp +++ b/core/callable.cpp @@ -79,7 +79,7 @@ StringName Callable::get_method() const { } CallableCustom *Callable::get_custom() const { - ERR_FAIL_COND_V_MSG(!is_custom(), NULL, + ERR_FAIL_COND_V_MSG(!is_custom(), nullptr, vformat("Can't get custom on non-CallableCustom \"%s\".", operator String())); return custom; } diff --git a/core/class_db.cpp b/core/class_db.cpp index 50c924bdd2..691b5a20fd 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -261,8 +261,9 @@ HashMap<StringName, StringName> ClassDB::compat_classes; ClassDB::ClassInfo::ClassInfo() { api = API_NONE; - creation_func = NULL; - inherits_ptr = NULL; + class_ptr = nullptr; + creation_func = nullptr; + inherits_ptr = nullptr; disabled = false; exposed = false; } @@ -289,7 +290,7 @@ void ClassDB::get_class_list(List<StringName> *p_classes) { OBJTYPE_RLOCK; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = classes.next(k))) { @@ -303,7 +304,7 @@ void ClassDB::get_inheriters_from_class(const StringName &p_class, List<StringNa OBJTYPE_RLOCK; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = classes.next(k))) { @@ -316,7 +317,7 @@ void ClassDB::get_direct_inheriters_from_class(const StringName &p_class, List<S OBJTYPE_RLOCK; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = classes.next(k))) { @@ -376,7 +377,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { List<StringName> names; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = classes.next(k))) { @@ -398,7 +399,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->method_map.next(k))) { @@ -445,7 +446,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->constant_map.next(k))) { @@ -465,7 +466,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->signal_map.next(k))) { @@ -488,7 +489,7 @@ uint64_t ClassDB::get_api_hash(APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->property_setget.next(k))) { @@ -548,14 +549,14 @@ Object *ClassDB::instance(const StringName &p_class) { ti = classes.getptr(compat_classes[p_class]); } } - ERR_FAIL_COND_V_MSG(!ti, NULL, "Cannot get class '" + String(p_class) + "'."); - ERR_FAIL_COND_V_MSG(ti->disabled, NULL, "Class '" + String(p_class) + "' is disabled."); - ERR_FAIL_COND_V(!ti->creation_func, NULL); + ERR_FAIL_COND_V_MSG(!ti, nullptr, "Cannot get class '" + String(p_class) + "'."); + ERR_FAIL_COND_V_MSG(ti->disabled, nullptr, "Class '" + String(p_class) + "' is disabled."); + ERR_FAIL_COND_V(!ti->creation_func, nullptr); } #ifdef TOOLS_ENABLED if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { ERR_PRINT("Class '" + String(p_class) + "' can only be instantiated by editor."); - return NULL; + return nullptr; } #endif return ti->creation_func(); @@ -571,7 +572,7 @@ bool ClassDB::can_instance(const StringName &p_class) { return false; } #endif - return (!ti->disabled && ti->creation_func != NULL); + return (!ti->disabled && ti->creation_func != nullptr); } void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherits) { @@ -594,7 +595,7 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit ti.inherits_ptr = &classes[ti.inherits]; } else { - ti.inherits_ptr = NULL; + ti.inherits_ptr = nullptr; } } @@ -652,7 +653,7 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b #else - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = type->method_map.next(K))) { @@ -684,7 +685,7 @@ MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { return *method; type = type->inherits_ptr; } - return NULL; + return nullptr; } void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant) { @@ -736,7 +737,7 @@ void ClassDB::get_integer_constant_list(const StringName &p_class, List<String> for (List<StringName>::Element *E = type->constant_order.front(); E; E = E->next()) p_constants->push_back(E->get()); #else - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = type->constant_map.next(K))) { p_constants->push_back(*K); @@ -783,7 +784,7 @@ StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const S while (type) { - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = type->enum_map.next(k))) { List<StringName> &constants_list = type->enum_map.get(*k); @@ -809,7 +810,7 @@ void ClassDB::get_enum_list(const StringName &p_class, List<StringName> *p_enums while (type) { - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = type->enum_map.next(k))) { p_enums->push_back(*k); } @@ -875,7 +876,7 @@ void ClassDB::get_signal_list(StringName p_class, List<MethodInfo> *p_signals, b while (check) { - const StringName *S = NULL; + const StringName *S = nullptr; while ((S = check->signal_map.next(S))) { p_signals->push_back(check->signal_map[*S]); @@ -937,7 +938,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons ERR_FAIL_COND(!type); - MethodBind *mb_set = NULL; + MethodBind *mb_set = nullptr; if (p_setter) { mb_set = get_method(p_class, p_setter); #ifdef DEBUG_METHODS_ENABLED @@ -949,7 +950,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons #endif } - MethodBind *mb_get = NULL; + MethodBind *mb_get = nullptr; if (p_getter) { mb_get = get_method(p_class, p_getter); @@ -1086,9 +1087,9 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia Callable::CallError ce; if (psg->_getptr) { - r_value = psg->_getptr->call(p_object, NULL, 0, ce); + r_value = psg->_getptr->call(p_object, nullptr, 0, ce); } else { - r_value = p_object->call(psg->getter, NULL, 0, ce); + r_value = p_object->call(psg->getter, nullptr, 0, ce); } } return true; @@ -1245,33 +1246,33 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const c #endif OBJTYPE_WLOCK; - ERR_FAIL_COND_V(!p_bind, NULL); + ERR_FAIL_COND_V(!p_bind, nullptr); p_bind->set_name(mdname); String instance_type = p_bind->get_instance_class(); #ifdef DEBUG_ENABLED - ERR_FAIL_COND_V_MSG(has_method(instance_type, mdname), NULL, "Class " + String(instance_type) + " already has a method " + String(mdname) + "."); + ERR_FAIL_COND_V_MSG(has_method(instance_type, mdname), nullptr, "Class " + String(instance_type) + " already has a method " + String(mdname) + "."); #endif ClassInfo *type = classes.getptr(instance_type); if (!type) { memdelete(p_bind); - ERR_FAIL_V_MSG(NULL, "Couldn't bind method '" + mdname + "' for instance '" + instance_type + "'."); + ERR_FAIL_V_MSG(nullptr, "Couldn't bind method '" + mdname + "' for instance '" + instance_type + "'."); } if (type->method_map.has(mdname)) { memdelete(p_bind); // overloading not supported - ERR_FAIL_V_MSG(NULL, "Method already bound '" + instance_type + "::" + mdname + "'."); + ERR_FAIL_V_MSG(nullptr, "Method already bound '" + instance_type + "::" + mdname + "'."); } #ifdef DEBUG_METHODS_ENABLED if (method_name.args.size() > p_bind->get_argument_count()) { memdelete(p_bind); - ERR_FAIL_V_MSG(NULL, "Method definition provides more arguments than the method actually has '" + instance_type + "::" + mdname + "'."); + ERR_FAIL_V_MSG(nullptr, "Method definition provides more arguments than the method actually has '" + instance_type + "::" + mdname + "'."); } p_bind->set_argument_names(method_name.args); @@ -1382,7 +1383,7 @@ void ClassDB::add_resource_base_extension(const StringName &p_extension, const S void ClassDB::get_resource_base_extensions(List<String> *p_extensions) { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = resource_base_extensions.next(K))) { @@ -1392,7 +1393,7 @@ void ClassDB::get_resource_base_extensions(List<String> *p_extensions) { void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p_extensions) { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = resource_base_extensions.next(K))) { StringName cmp = resource_base_extensions[*K]; @@ -1412,7 +1413,7 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con default_values[p_class] = HashMap<StringName, Variant>(); } - Object *c = NULL; + Object *c = nullptr; bool cleanup_c = false; if (Engine::get_singleton()->has_singleton(p_class)) { @@ -1446,20 +1447,20 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con } if (!default_values.has(p_class)) { - if (r_valid != NULL) *r_valid = false; + if (r_valid != nullptr) *r_valid = false; return Variant(); } if (!default_values[p_class].has(p_property)) { - if (r_valid != NULL) *r_valid = false; + if (r_valid != nullptr) *r_valid = false; return Variant(); } - if (r_valid != NULL) *r_valid = true; + if (r_valid != nullptr) *r_valid = true; return default_values[p_class][p_property]; } -RWLock *ClassDB::lock = NULL; +RWLock *ClassDB::lock = nullptr; void ClassDB::init() { @@ -1476,13 +1477,13 @@ void ClassDB::cleanup() { //OBJTYPE_LOCK; hah not here - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = classes.next(k))) { ClassInfo &ti = classes[*k]; - const StringName *m = NULL; + const StringName *m = nullptr; while ((m = ti.method_map.next(m))) { memdelete(ti.method_map[*m]); diff --git a/core/class_db.h b/core/class_db.h index 35bbe6b6f5..1cbff34ea1 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -234,7 +234,7 @@ public: MethodBind *bind = create_method_bind(p_method); - return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, NULL, 0); //use static function, much smaller binary usage + return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, nullptr, 0); //use static function, much smaller binary usage } template <class N, class M> @@ -315,7 +315,7 @@ public: GLOBAL_LOCK_FUNCTION; MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant); - ERR_FAIL_COND_V(!bind, NULL); + ERR_FAIL_COND_V(!bind, nullptr); bind->set_name(p_name); bind->set_default_arguments(p_default_args); @@ -325,13 +325,13 @@ public: ClassInfo *type = classes.getptr(instance_type); if (!type) { memdelete(bind); - ERR_FAIL_COND_V(!type, NULL); + ERR_FAIL_COND_V(!type, nullptr); } if (type->method_map.has(p_name)) { memdelete(bind); // overloading not supported - ERR_FAIL_V_MSG(NULL, "Method already bound: " + instance_type + "::" + p_name + "."); + ERR_FAIL_V_MSG(nullptr, "Method already bound: " + instance_type + "::" + p_name + "."); } type->method_map[p_name] = bind; #ifdef DEBUG_METHODS_ENABLED @@ -351,12 +351,12 @@ public: static void add_property_group(StringName p_class, const String &p_name, const String &p_prefix = ""); static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1); static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default); - static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = NULL); - static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL); + static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = nullptr); + static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = nullptr); static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value); static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false); - static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); - static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); + static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = nullptr); + static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = nullptr); static StringName get_property_setter(StringName p_class, const StringName &p_property); static StringName get_property_getter(StringName p_class, const StringName &p_property); @@ -371,13 +371,13 @@ public: static void bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant); static void get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance = false); - static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = NULL); + static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = nullptr); static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false); static void get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance = false); static void get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance = false); - static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid = NULL); + static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid = nullptr); static StringName get_category(const StringName &p_node); diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index 85e8a847a0..3ce769c72c 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -113,7 +113,7 @@ CommandQueueMT::CommandQueueMT(bool p_sync) { if (p_sync) sync = memnew(Semaphore); else - sync = NULL; + sync = nullptr; } CommandQueueMT::~CommandQueueMT() { diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index cc08ae7004..558453bdf5 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -360,7 +360,7 @@ class CommandQueueMT { if (dealloc_one()) { goto tryagain; } - return NULL; + return nullptr; } } else { // ahead of dealloc_ptr, check that there is room @@ -374,11 +374,11 @@ class CommandQueueMT { if (dealloc_one()) { goto tryagain; } - return NULL; + return nullptr; } // if this happens, it's a bug - ERR_FAIL_COND_V((COMMAND_MEM_SIZE - write_ptr) < 8, NULL); + ERR_FAIL_COND_V((COMMAND_MEM_SIZE - write_ptr) < 8, nullptr); // zero means, wrap to beginning uint32_t *p = (uint32_t *)&command_mem[write_ptr]; @@ -406,7 +406,7 @@ class CommandQueueMT { lock(); T *ret; - while ((ret = allocate<T>()) == NULL) { + while ((ret = allocate<T>()) == nullptr) { unlock(); // sleep a little until fetch happened and some room is made diff --git a/core/core_builders.py b/core/core_builders.py index a06b61cb9b..d03874608e 100644 --- a/core/core_builders.py +++ b/core/core_builders.py @@ -11,15 +11,15 @@ def escape_string(s): 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)) + rev_result.append("\\%03o" % low) + rev_result.append("\\%03o" % c) + return "".join(reversed(rev_result)) - result = '' + result = "" if isinstance(s, str): - s = s.encode('utf-8') + s = s.encode("utf-8") for c in s: - if not(32 <= c < 127) or c in (ord('\\'), ord('"')): + if not (32 <= c < 127) or c in (ord("\\"), ord('"')): result += charcode_to_c_escapes(c) else: result += chr(c) @@ -34,6 +34,7 @@ def make_certs_header(target, source, env): buf = f.read() decomp_size = len(buf) import zlib + buf = zlib.compress(buf) g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") @@ -41,9 +42,9 @@ def make_certs_header(target, source, env): 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'] - g.write("#define _SYSTEM_CERTS_PATH \"%s\"\n" % str(path)) - if env['builtin_certs']: + path = env["system_certs_path"] + g.write('#define _SYSTEM_CERTS_PATH "%s"\n' % str(path)) + if env["builtin_certs"]: # Defined here and not in env so changing it does not trigger a full rebuild. g.write("#define BUILTIN_CERTS_ENABLED\n") g.write("static const int _certs_compressed_size = " + str(len(buf)) + ";\n") @@ -59,8 +60,18 @@ def make_certs_header(target, source, env): def make_authors_header(target, source, env): - sections = ["Project Founders", "Lead Developer", "Project Manager", "Developers"] - sections_id = ["AUTHORS_FOUNDERS", "AUTHORS_LEAD_DEVELOPERS", "AUTHORS_PROJECT_MANAGERS", "AUTHORS_DEVELOPERS"] + sections = [ + "Project Founders", + "Lead Developer", + "Project Manager", + "Developers", + ] + sections_id = [ + "AUTHORS_FOUNDERS", + "AUTHORS_LEAD_DEVELOPERS", + "AUTHORS_PROJECT_MANAGERS", + "AUTHORS_DEVELOPERS", + ] src = source[0] dst = target[0] @@ -80,7 +91,7 @@ def make_authors_header(target, source, env): for line in f: if reading: if line.startswith(" "): - g.write("\t\"" + escape_string(line.strip()) + "\",\n") + g.write('\t"' + escape_string(line.strip()) + '",\n') continue if line.startswith("## "): if reading: @@ -103,10 +114,22 @@ def make_authors_header(target, source, env): def make_donors_header(target, source, env): - sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors", - "Gold donors", "Silver donors", "Bronze donors"] - sections_id = ["DONORS_SPONSOR_PLAT", "DONORS_SPONSOR_GOLD", "DONORS_SPONSOR_MINI", - "DONORS_GOLD", "DONORS_SILVER", "DONORS_BRONZE"] + sections = [ + "Platinum sponsors", + "Gold sponsors", + "Mini sponsors", + "Gold donors", + "Silver donors", + "Bronze donors", + ] + sections_id = [ + "DONORS_SPONSOR_PLAT", + "DONORS_SPONSOR_GOLD", + "DONORS_SPONSOR_MINI", + "DONORS_GOLD", + "DONORS_SILVER", + "DONORS_BRONZE", + ] src = source[0] dst = target[0] @@ -126,7 +149,7 @@ def make_donors_header(target, source, env): for line in f: if reading >= 0: if line.startswith(" "): - g.write("\t\"" + escape_string(line.strip()) + "\",\n") + g.write('\t"' + escape_string(line.strip()) + '",\n') continue if line.startswith("## "): if reading: @@ -169,8 +192,8 @@ def make_license_header(target, source, env): return line def next_tag(self): - if not ':' in self.current: - return ('', []) + if not ":" in self.current: + return ("", []) tag, line = self.current.split(":", 1) lines = [line.strip()] while self.next_line() and self.current.startswith(" "): @@ -178,6 +201,7 @@ def make_license_header(target, source, env): return (tag, lines) from collections import OrderedDict + projects = OrderedDict() license_list = [] @@ -218,26 +242,30 @@ def make_license_header(target, source, env): 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\"") + f.write('\n\t\t"' + escaped_string + '\\n"') f.write(";\n\n") - f.write("struct ComponentCopyrightPart {\n" - "\tconst char *license;\n" - "\tconst char *const *files;\n" - "\tconst char *const *copyright_statements;\n" - "\tint file_count;\n" - "\tint copyright_count;\n" - "};\n\n") - - f.write("struct ComponentCopyright {\n" - "\tconst char *name;\n" - "\tconst ComponentCopyrightPart *parts;\n" - "\tint part_count;\n" - "};\n\n") + f.write( + "struct ComponentCopyrightPart {\n" + "\tconst char *license;\n" + "\tconst char *const *files;\n" + "\tconst char *const *copyright_statements;\n" + "\tint file_count;\n" + "\tint copyright_count;\n" + "};\n\n" + ) + + f.write( + "struct ComponentCopyright {\n" + "\tconst char *name;\n" + "\tconst ComponentCopyrightPart *parts;\n" + "\tint part_count;\n" + "};\n\n" + ) f.write("const char *const COPYRIGHT_INFO_DATA[] = {\n") for line in data_list: - f.write("\t\"" + escape_string(line) + "\",\n") + f.write('\t"' + escape_string(line) + '",\n') f.write("};\n\n") f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n") @@ -246,11 +274,21 @@ def make_license_header(target, source, env): 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]) + "\", " - + "©RIGHT_INFO_DATA[" + str(part["file_index"]) + "], " - + "©RIGHT_INFO_DATA[" + str(part["copyright_index"]) + "], " - + str(len(part["Files"])) + ", " - + str(len(part["Copyright"])) + " },\n") + f.write( + '\t{ "' + + escape_string(part["License"][0]) + + '", ' + + "©RIGHT_INFO_DATA[" + + str(part["file_index"]) + + "], " + + "©RIGHT_INFO_DATA[" + + str(part["copyright_index"]) + + "], " + + str(len(part["Files"])) + + ", " + + str(len(part["Copyright"])) + + " },\n" + ) part_index += 1 f.write("};\n\n") @@ -258,30 +296,37 @@ def make_license_header(target, source, env): f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n") 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") + f.write( + '\t{ "' + + escape_string(project_name) + + '", ' + + "©RIGHT_PROJECT_PARTS[" + + str(part_indexes[project_name]) + + "], " + + str(len(project)) + + " },\n" + ) f.write("};\n\n") f.write("const int LICENSE_COUNT = " + str(len(license_list)) + ";\n") f.write("const char *const LICENSE_NAMES[] = {\n") for l in license_list: - f.write("\t\"" + escape_string(l[0]) + "\",\n") + f.write('\t"' + escape_string(l[0]) + '",\n') f.write("};\n\n") f.write("const char *const LICENSE_BODIES[] = {\n\n") for l in license_list: for line in l[1:]: if line == ".": - f.write("\t\"\\n\"\n") + f.write('\t"\\n"\n') else: - f.write("\t\"" + escape_string(line) + "\\n\"\n") - f.write("\t\"\",\n\n") + f.write('\t"' + escape_string(line) + '\\n"\n') + f.write('\t"",\n\n') f.write("};\n\n") f.write("#endif // LICENSE_GEN_H\n") -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index 253d5f1acb..1d3b333efc 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -30,7 +30,7 @@ #include "core_string_names.h" -CoreStringNames *CoreStringNames::singleton = NULL; +CoreStringNames *CoreStringNames::singleton = nullptr; CoreStringNames::CoreStringNames() : _free(StaticCString::create("free")), diff --git a/core/core_string_names.h b/core/core_string_names.h index dce0244631..2ade44f4e0 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -41,7 +41,7 @@ class CoreStringNames { static void create() { singleton = memnew(CoreStringNames); } static void free() { memdelete(singleton); - singleton = NULL; + singleton = nullptr; } CoreStringNames(); diff --git a/core/cowdata.h b/core/cowdata.h index 5de78be6d7..975a572906 100644 --- a/core/cowdata.h +++ b/core/cowdata.h @@ -61,7 +61,7 @@ private: _FORCE_INLINE_ uint32_t *_get_refcount() const { if (!_ptr) - return NULL; + return nullptr; return reinterpret_cast<uint32_t *>(_ptr) - 2; } @@ -69,7 +69,7 @@ private: _FORCE_INLINE_ uint32_t *_get_size() const { if (!_ptr) - return NULL; + return nullptr; return reinterpret_cast<uint32_t *>(_ptr) - 1; } @@ -77,7 +77,7 @@ private: _FORCE_INLINE_ T *_get_data() const { if (!_ptr) - return NULL; + return nullptr; return reinterpret_cast<T *>(_ptr); } @@ -253,37 +253,42 @@ Error CowData<T>::resize(int p_size) { ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER); - if (p_size == size()) + int current_size = size(); + + if (p_size == current_size) return OK; if (p_size == 0) { // wants to clean up _unref(_ptr); - _ptr = NULL; + _ptr = nullptr; return OK; } // possibly changing size, copy on write _copy_on_write(); + size_t current_alloc_size = _get_alloc_size(current_size); size_t alloc_size; ERR_FAIL_COND_V(!_get_alloc_size_checked(p_size, &alloc_size), ERR_OUT_OF_MEMORY); - if (p_size > size()) { + if (p_size > current_size) { - if (size() == 0) { - // alloc from scratch - uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true); - ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY); - *(ptr - 1) = 0; //size, currently none - *(ptr - 2) = 1; //refcount + if (alloc_size != current_alloc_size) { + if (current_size == 0) { + // alloc from scratch + uint32_t *ptr = (uint32_t *)Memory::alloc_static(alloc_size, true); + ERR_FAIL_COND_V(!ptr, ERR_OUT_OF_MEMORY); + *(ptr - 1) = 0; //size, currently none + *(ptr - 2) = 1; //refcount - _ptr = (T *)ptr; + _ptr = (T *)ptr; - } else { - void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true); - ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY); - _ptr = (T *)(_ptrnew); + } else { + void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true); + ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY); + _ptr = (T *)(_ptrnew); + } } // construct the newly created elements @@ -298,7 +303,7 @@ Error CowData<T>::resize(int p_size) { *_get_size() = p_size; - } else if (p_size < size()) { + } else if (p_size < current_size) { if (!__has_trivial_destructor(T)) { // deinitialize no longer needed elements @@ -308,10 +313,12 @@ Error CowData<T>::resize(int p_size) { } } - void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true); - ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY); + if (alloc_size != current_alloc_size) { + void *_ptrnew = (T *)Memory::realloc_static(_ptr, alloc_size, true); + ERR_FAIL_COND_V(!_ptrnew, ERR_OUT_OF_MEMORY); - _ptr = (T *)(_ptrnew); + _ptr = (T *)(_ptrnew); + } *_get_size() = p_size; } @@ -349,7 +356,7 @@ void CowData<T>::_ref(const CowData &p_from) { return; // self assign, do nothing. _unref(_ptr); - _ptr = NULL; + _ptr = nullptr; if (!p_from._ptr) return; //nothing to do @@ -362,7 +369,7 @@ void CowData<T>::_ref(const CowData &p_from) { template <class T> CowData<T>::CowData() { - _ptr = NULL; + _ptr = nullptr; } template <class T> diff --git a/core/crypto/SCsub b/core/crypto/SCsub index 0a3f05d87a..da4a9c9381 100644 --- a/core/crypto/SCsub +++ b/core/crypto/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env_crypto = env.Clone() @@ -22,7 +22,9 @@ if not has_module: env_thirdparty = env_crypto.Clone() env_thirdparty.disable_warnings() # Custom config file - env_thirdparty.Append(CPPDEFINES=[('MBEDTLS_CONFIG_FILE', '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')]) + env_thirdparty.Append( + CPPDEFINES=[("MBEDTLS_CONFIG_FILE", '\\"thirdparty/mbedtls/include/godot_core_mbedtls_config.h\\"')] + ) thirdparty_mbedtls_dir = "#thirdparty/mbedtls/library/" thirdparty_mbedtls_sources = [ "aes.c", @@ -30,7 +32,7 @@ if not has_module: "md5.c", "sha1.c", "sha256.c", - "godot_core_mbedtls_platform.c" + "godot_core_mbedtls_platform.c", ] thirdparty_mbedtls_sources = [thirdparty_mbedtls_dir + file for file in thirdparty_mbedtls_sources] env_thirdparty.add_source_files(env.core_sources, thirdparty_mbedtls_sources) diff --git a/core/crypto/crypto.cpp b/core/crypto/crypto.cpp index 793bf719b7..ab8548e3ba 100644 --- a/core/crypto/crypto.cpp +++ b/core/crypto/crypto.cpp @@ -36,11 +36,11 @@ /// Resources -CryptoKey *(*CryptoKey::_create)() = NULL; +CryptoKey *(*CryptoKey::_create)() = nullptr; CryptoKey *CryptoKey::create() { if (_create) return _create(); - return NULL; + return nullptr; } void CryptoKey::_bind_methods() { @@ -48,11 +48,11 @@ void CryptoKey::_bind_methods() { ClassDB::bind_method(D_METHOD("load", "path"), &CryptoKey::load); } -X509Certificate *(*X509Certificate::_create)() = NULL; +X509Certificate *(*X509Certificate::_create)() = nullptr; X509Certificate *X509Certificate::create() { if (_create) return _create(); - return NULL; + return nullptr; } void X509Certificate::_bind_methods() { @@ -62,8 +62,8 @@ void X509Certificate::_bind_methods() { /// Crypto -void (*Crypto::_load_default_certificates)(String p_path) = NULL; -Crypto *(*Crypto::_create)() = NULL; +void (*Crypto::_load_default_certificates)(String p_path) = nullptr; +Crypto *(*Crypto::_create)() = nullptr; Crypto *Crypto::create() { if (_create) return _create(); @@ -87,11 +87,11 @@ PackedByteArray Crypto::generate_random_bytes(int p_bytes) { } Ref<CryptoKey> Crypto::generate_rsa(int p_bytes) { - ERR_FAIL_V_MSG(NULL, "generate_rsa is not available when mbedtls module is disabled."); + ERR_FAIL_V_MSG(nullptr, "generate_rsa is not available when mbedtls module is disabled."); } Ref<X509Certificate> Crypto::generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) { - ERR_FAIL_V_MSG(NULL, "generate_self_signed_certificate is not available when mbedtls module is disabled."); + ERR_FAIL_V_MSG(nullptr, "generate_self_signed_certificate is not available when mbedtls module is disabled."); } Crypto::Crypto() { @@ -113,7 +113,7 @@ RES ResourceFormatLoaderCrypto::load(const String &p_path, const String &p_origi key->load(p_path); return key; } - return NULL; + return nullptr; } void ResourceFormatLoaderCrypto::get_recognized_extensions(List<String> *p_extensions) const { diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h index 3279c0620f..e515367de5 100644 --- a/core/crypto/crypto.h +++ b/core/crypto/crypto.h @@ -87,7 +87,7 @@ class ResourceFormatLoaderCrypto : public ResourceFormatLoader { GDCLASS(ResourceFormatLoaderCrypto, ResourceFormatLoader); public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp index a4d8a93c8a..af43bc9bad 100644 --- a/core/crypto/hashing_context.cpp +++ b/core/crypto/hashing_context.cpp @@ -33,9 +33,9 @@ #include "core/crypto/crypto_core.h" Error HashingContext::start(HashType p_type) { - ERR_FAIL_COND_V(ctx != NULL, ERR_ALREADY_IN_USE); + ERR_FAIL_COND_V(ctx != nullptr, ERR_ALREADY_IN_USE); _create_ctx(p_type); - ERR_FAIL_COND_V(ctx == NULL, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(ctx == nullptr, ERR_UNAVAILABLE); switch (type) { case HASH_MD5: return ((CryptoCore::MD5Context *)ctx)->start(); @@ -48,7 +48,7 @@ Error HashingContext::start(HashType p_type) { } Error HashingContext::update(PackedByteArray p_chunk) { - ERR_FAIL_COND_V(ctx == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(ctx == nullptr, ERR_UNCONFIGURED); size_t len = p_chunk.size(); ERR_FAIL_COND_V(len == 0, FAILED); const uint8_t *r = p_chunk.ptr(); @@ -64,7 +64,7 @@ Error HashingContext::update(PackedByteArray p_chunk) { } PackedByteArray HashingContext::finish() { - ERR_FAIL_COND_V(ctx == NULL, PackedByteArray()); + ERR_FAIL_COND_V(ctx == nullptr, PackedByteArray()); PackedByteArray out; Error err = FAILED; switch (type) { @@ -99,7 +99,7 @@ void HashingContext::_create_ctx(HashType p_type) { ctx = memnew(CryptoCore::SHA256Context); break; default: - ctx = NULL; + ctx = nullptr; } } @@ -116,7 +116,7 @@ void HashingContext::_delete_ctx() { memdelete((CryptoCore::SHA256Context *)ctx); break; } - ctx = NULL; + ctx = nullptr; } void HashingContext::_bind_methods() { @@ -129,10 +129,10 @@ void HashingContext::_bind_methods() { } HashingContext::HashingContext() { - ctx = NULL; + ctx = nullptr; } HashingContext::~HashingContext() { - if (ctx != NULL) + if (ctx != nullptr) _delete_ctx(); } diff --git a/core/debugger/SCsub b/core/debugger/SCsub index 1c5f954470..19a6549225 100644 --- a/core/debugger/SCsub +++ b/core/debugger/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.core_sources, "*.cpp") diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp index eb3a19506a..410c55129d 100644 --- a/core/debugger/debugger_marshalls.cpp +++ b/core/debugger/debugger_marshalls.cpp @@ -227,7 +227,7 @@ Array DebuggerMarshalls::ScriptStackVariable::serialize(int max_size) { } int len = 0; - Error err = encode_variant(var, NULL, len, true); + Error err = encode_variant(var, nullptr, len, true); if (err != OK) ERR_PRINT("Failed to encode variant."); @@ -317,7 +317,7 @@ bool DebuggerMarshalls::VisualProfilerFrame::deserialize(const Array &p_arr) { CHECK_SIZE(p_arr, size, "VisualProfilerFrame"); int idx = 2; areas.resize(size / 3); - VS::FrameProfileArea *w = areas.ptrw(); + RS::FrameProfileArea *w = areas.ptrw(); for (int i = 0; i < size / 3; i++) { w[i].name = p_arr[idx]; w[i].cpu_msec = p_arr[idx + 1]; diff --git a/core/debugger/debugger_marshalls.h b/core/debugger/debugger_marshalls.h index 4c15adc555..04229c0afc 100644 --- a/core/debugger/debugger_marshalls.h +++ b/core/debugger/debugger_marshalls.h @@ -32,7 +32,7 @@ #define DEBUGGER_MARSHARLLS_H #include "core/script_language.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" struct DebuggerMarshalls { @@ -165,7 +165,7 @@ struct DebuggerMarshalls { // Visual Profiler struct VisualProfilerFrame { uint64_t frame_number; - Vector<VS::FrameProfileArea> areas; + Vector<RS::FrameProfileArea> areas; Array serialize(); bool deserialize(const Array &p_arr); diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index c64d886800..bfe38d0f4a 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -35,8 +35,8 @@ #include "core/debugger/script_debugger.h" #include "core/os/os.h" -EngineDebugger *EngineDebugger::singleton = NULL; -ScriptDebugger *EngineDebugger::script_debugger = NULL; +EngineDebugger *EngineDebugger::singleton = nullptr; +ScriptDebugger *EngineDebugger::script_debugger = nullptr; Map<StringName, EngineDebugger::Profiler> EngineDebugger::profilers; Map<StringName, EngineDebugger::Capture> EngineDebugger::captures; @@ -173,7 +173,7 @@ void EngineDebugger::deinitialize() { singleton->poll_events(false); memdelete(singleton); - singleton = NULL; + singleton = nullptr; profilers.clear(); captures.clear(); } @@ -181,6 +181,6 @@ void EngineDebugger::deinitialize() { EngineDebugger::~EngineDebugger() { if (script_debugger) memdelete(script_debugger); - script_debugger = NULL; - singleton = NULL; + script_debugger = nullptr; + singleton = nullptr; } diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h index 9e01aeba18..7b6b77ca9b 100644 --- a/core/debugger/engine_debugger.h +++ b/core/debugger/engine_debugger.h @@ -50,10 +50,10 @@ public: class Profiler { friend class EngineDebugger; - ProfilingToggle toggle = NULL; - ProfilingAdd add = NULL; - ProfilingTick tick = NULL; - void *data = NULL; + ProfilingToggle toggle = nullptr; + ProfilingAdd add = nullptr; + ProfilingTick tick = nullptr; + void *data = nullptr; bool active = false; public: @@ -69,8 +69,8 @@ public: class Capture { friend class EngineDebugger; - CaptureFunc capture = NULL; - void *data = NULL; + CaptureFunc capture = nullptr; + void *data = nullptr; public: Capture() {} @@ -97,7 +97,7 @@ protected: public: _FORCE_INLINE_ static EngineDebugger *get_singleton() { return singleton; } - _FORCE_INLINE_ static bool is_active() { return singleton != NULL && script_debugger != NULL; } + _FORCE_INLINE_ static bool is_active() { return singleton != nullptr && script_debugger != nullptr; } _FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; }; diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index 01e30fb621..6d88ceb2c1 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -402,7 +402,7 @@ LocalDebugger::LocalDebugger() { [](void *p_user, bool p_enable, const Array &p_opts) { ((ScriptsProfiler *)p_user)->toggle(p_enable, p_opts); }, - NULL, + nullptr, [](void *p_user, float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time) { ((ScriptsProfiler *)p_user)->tick(p_frame_time, p_idle_time, p_physics_time, p_physics_frame_time); }); diff --git a/core/debugger/local_debugger.h b/core/debugger/local_debugger.h index e299df0546..2c4302f4da 100644 --- a/core/debugger/local_debugger.h +++ b/core/debugger/local_debugger.h @@ -40,7 +40,7 @@ class LocalDebugger : public EngineDebugger { private: struct ScriptsProfiler; - ScriptsProfiler *scripts_profiler = NULL; + ScriptsProfiler *scripts_profiler = nullptr; String target_function; Map<String, String> options; diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index b9db8ab1b0..c2996e552f 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -354,18 +354,18 @@ struct RemoteDebugger::VisualProfiler { Map<StringName, ServerInfo> server_data; void toggle(bool p_enable, const Array &p_opts) { - VS::get_singleton()->set_frame_profiling_enabled(p_enable); + RS::get_singleton()->set_frame_profiling_enabled(p_enable); } void add(const Array &p_data) {} void tick(float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time) { - Vector<VS::FrameProfileArea> profile_areas = VS::get_singleton()->get_frame_profile(); + Vector<RS::FrameProfileArea> profile_areas = RS::get_singleton()->get_frame_profile(); DebuggerMarshalls::VisualProfilerFrame frame; if (!profile_areas.size()) return; - frame.frame_number = VS::get_singleton()->get_frame_profile_frame(); + frame.frame_number = RS::get_singleton()->get_frame_profile_frame(); frame.areas.append_array(profile_areas); EngineDebugger::get_singleton()->send_message("visual:profile_frame", frame.serialize()); } @@ -373,7 +373,7 @@ struct RemoteDebugger::VisualProfiler { struct RemoteDebugger::PerformanceProfiler { - Object *performance = NULL; + Object *performance = nullptr; int last_perf_time = 0; void toggle(bool p_enable, const Array &p_opts) {} @@ -404,10 +404,10 @@ void RemoteDebugger::_send_resource_usage() { DebuggerMarshalls::ResourceUsage usage; - List<VS::TextureInfo> tinfo; - VS::get_singleton()->texture_debug_usage(&tinfo); + List<RS::TextureInfo> tinfo; + RS::get_singleton()->texture_debug_usage(&tinfo); - for (List<VS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) { + for (List<RS::TextureInfo>::Element *E = tinfo.front(); E; E = E->next()) { DebuggerMarshalls::ResourceInfo info; info.path = E->get().path; @@ -771,9 +771,9 @@ void RemoteDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { // This is for the camera override to stay live even when the game is paused from the editor loop_time_sec = (OS::get_singleton()->get_ticks_usec() - loop_begin_usec) / 1000000.0f; - VisualServer::get_singleton()->sync(); - if (VisualServer::get_singleton()->has_changed()) { - VisualServer::get_singleton()->draw(true, loop_time_sec * Engine::get_singleton()->get_time_scale()); + RenderingServer::get_singleton()->sync(); + if (RenderingServer::get_singleton()->has_changed()) { + RenderingServer::get_singleton()->draw(true, loop_time_sec * Engine::get_singleton()->get_time_scale()); } } @@ -867,7 +867,7 @@ RemoteDebugger *RemoteDebugger::create_for_uri(const String &p_uri) { Ref<RemoteDebuggerPeer> peer = RemoteDebuggerPeer::create_from_uri(p_uri); if (peer.is_valid()) return memnew(RemoteDebugger(peer)); - return NULL; + return nullptr; } RemoteDebugger::RemoteDebugger(Ref<RemoteDebuggerPeer> p_peer) { diff --git a/core/debugger/remote_debugger.h b/core/debugger/remote_debugger.h index 83789c67f9..f805eec631 100644 --- a/core/debugger/remote_debugger.h +++ b/core/debugger/remote_debugger.h @@ -50,10 +50,10 @@ private: struct VisualProfiler; struct PerformanceProfiler; - NetworkProfiler *network_profiler = NULL; - ServersProfiler *servers_profiler = NULL; - VisualProfiler *visual_profiler = NULL; - PerformanceProfiler *performance_profiler = NULL; + NetworkProfiler *network_profiler = nullptr; + ServersProfiler *servers_profiler = nullptr; + VisualProfiler *visual_profiler = nullptr; + PerformanceProfiler *performance_profiler = nullptr; Ref<RemoteDebuggerPeer> peer; diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp index 42c2c8e309..ed04431177 100644 --- a/core/debugger/remote_debugger_peer.cpp +++ b/core/debugger/remote_debugger_peer.cpp @@ -68,7 +68,7 @@ void RemoteDebuggerPeerTCP::close() { running = false; Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } tcp_client->disconnect_from_host(); out_buf.resize(0); @@ -106,7 +106,7 @@ void RemoteDebuggerPeerTCP::_write_out() { out_queue.pop_front(); mutex.unlock(); int size = 0; - Error err = encode_variant(var, NULL, size); + Error err = encode_variant(var, nullptr, size); ERR_CONTINUE(err != OK || size > out_buf.size() - 4); // 4 bytes separator. encode_uint32(size, buf); encode_variant(var, buf + 4, size); diff --git a/core/debugger/remote_debugger_peer.h b/core/debugger/remote_debugger_peer.h index 6fc3214a51..e4b838f145 100644 --- a/core/debugger/remote_debugger_peer.h +++ b/core/debugger/remote_debugger_peer.h @@ -58,7 +58,7 @@ class RemoteDebuggerPeerTCP : public RemoteDebuggerPeer { private: Ref<StreamPeerTCP> tcp_client; Mutex mutex; - Thread *thread = NULL; + Thread *thread = nullptr; List<Array> in_queue; List<Array> out_queue; int out_left = 0; diff --git a/core/debugger/script_debugger.h b/core/debugger/script_debugger.h index a60b57c637..e5066273d2 100644 --- a/core/debugger/script_debugger.h +++ b/core/debugger/script_debugger.h @@ -47,7 +47,7 @@ class ScriptDebugger { Map<int, Set<StringName>> breakpoints; - ScriptLanguage *break_lang = NULL; + ScriptLanguage *break_lang = nullptr; Vector<StackInfo> error_stack_info; public: diff --git a/core/dictionary.cpp b/core/dictionary.cpp index cdb518228b..bc3b792bd5 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -90,7 +90,7 @@ const Variant *Dictionary::getptr(const Variant &p_key) const { OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::ConstElement E = ((const OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator> *)&_p->variant_map)->find(p_key); if (!E) - return NULL; + return nullptr; return &E.get(); } @@ -99,7 +99,7 @@ Variant *Dictionary::getptr(const Variant &p_key) { OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.find(p_key); if (!E) - return NULL; + return nullptr; return &E.get(); } @@ -186,7 +186,7 @@ void Dictionary::_unref() const { if (_p->refcount.unref()) { memdelete(_p); } - _p = NULL; + _p = nullptr; } uint32_t Dictionary::hash() const { @@ -236,17 +236,17 @@ Array Dictionary::values() const { const Variant *Dictionary::next(const Variant *p_key) const { - if (p_key == NULL) { + if (p_key == nullptr) { // caller wants to get the first element if (_p->variant_map.front()) return &_p->variant_map.front().key(); - return NULL; + return nullptr; } OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.find(*p_key); if (E && E.next()) return &E.next().key(); - return NULL; + return nullptr; } Dictionary Dictionary::duplicate(bool p_deep) const { @@ -270,7 +270,7 @@ const void *Dictionary::id() const { } Dictionary::Dictionary(const Dictionary &p_from) { - _p = NULL; + _p = nullptr; _ref(p_from); } diff --git a/core/dictionary.h b/core/dictionary.h index 0ce817f3d4..c6cbacc144 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -75,7 +75,7 @@ public: uint32_t hash() const; void operator=(const Dictionary &p_dictionary); - const Variant *next(const Variant *p_key = NULL) const; + const Variant *next(const Variant *p_key = nullptr) const; Array keys() const; Array values() const; diff --git a/core/engine.cpp b/core/engine.cpp index 85ad175f38..36987eab31 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -114,7 +114,7 @@ Dictionary Engine::get_version_info() const { static Array array_from_info(const char *const *info_list) { Array arr; - for (int i = 0; info_list[i] != NULL; i++) { + for (int i = 0; info_list[i] != nullptr; i++) { arr.push_back(info_list[i]); } return arr; @@ -193,7 +193,7 @@ void Engine::add_singleton(const Singleton &p_singleton) { Object *Engine::get_singleton_object(const String &p_name) const { const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name); - ERR_FAIL_COND_V_MSG(!E, NULL, "Failed to retrieve non-existent singleton '" + p_name + "'."); + ERR_FAIL_COND_V_MSG(!E, nullptr, "Failed to retrieve non-existent singleton '" + p_name + "'."); return E->get(); }; @@ -208,7 +208,7 @@ void Engine::get_singletons(List<Singleton> *p_singletons) { p_singletons->push_back(E->get()); } -Engine *Engine::singleton = NULL; +Engine *Engine::singleton = nullptr; Engine *Engine::get_singleton() { return singleton; diff --git a/core/engine.h b/core/engine.h index cfe3a918fc..4cfdeffa82 100644 --- a/core/engine.h +++ b/core/engine.h @@ -42,7 +42,7 @@ public: struct Singleton { StringName name; Object *ptr; - Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) : + Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr) : name(p_name), ptr(p_ptr) { } diff --git a/core/error_macros.cpp b/core/error_macros.cpp index f6da990562..5de070844a 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -34,7 +34,7 @@ #include "core/ustring.h" #include "os/os.h" -static ErrorHandlerList *error_handler_list = NULL; +static ErrorHandlerList *error_handler_list = nullptr; void add_error_handler(ErrorHandlerList *p_handler) { @@ -48,7 +48,7 @@ void remove_error_handler(ErrorHandlerList *p_handler) { _global_lock(); - ErrorHandlerList *prev = NULL; + ErrorHandlerList *prev = nullptr; ErrorHandlerList *l = error_handler_list; while (l) { diff --git a/core/hash_map.h b/core/hash_map.h index e40b00a67a..f27a86cc02 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -197,14 +197,14 @@ private: e = e->next; } - return NULL; + return nullptr; } Element *create_element(const TKey &p_key) { /* if element doesn't exist, create it */ Element *e = memnew(Element); - ERR_FAIL_COND_V_MSG(!e, NULL, "Out of memory."); + ERR_FAIL_COND_V_MSG(!e, nullptr, "Out of memory."); uint32_t hash = Hasher::hash(p_key); uint32_t index = hash & ((1 << hash_table_power) - 1); e->next = hash_table[index]; @@ -234,7 +234,7 @@ private: for (int i = 0; i < (1 << p_t.hash_table_power); i++) { - hash_table[i] = NULL; + hash_table[i] = nullptr; const Element *e = p_t.hash_table[i]; @@ -260,7 +260,7 @@ public: Element *set(const Pair &p_pair) { - Element *e = NULL; + Element *e = nullptr; if (!hash_table) make_hash_table(); // if no table, make one else @@ -272,7 +272,7 @@ public: e = create_element(p_pair.key); if (!e) - return NULL; + return nullptr; check_hash_table(); // perform mantenience routine } @@ -282,12 +282,12 @@ public: bool has(const TKey &p_key) const { - return getptr(p_key) != NULL; + return getptr(p_key) != nullptr; } /** * Get a key from data, return a const reference. - * WARNING: this doesn't check errors, use either getptr and check NULL, or check + * WARNING: this doesn't check errors, use either getptr and check nullptr, or check * first with has(key) */ @@ -306,38 +306,38 @@ public: } /** - * Same as get, except it can return NULL when item was not found. + * Same as get, except it can return nullptr when item was not found. * This is mainly used for speed purposes. */ _FORCE_INLINE_ TData *getptr(const TKey &p_key) { if (unlikely(!hash_table)) - return NULL; + return nullptr; Element *e = const_cast<Element *>(get_element(p_key)); if (e) return &e->pair.data; - return NULL; + return nullptr; } _FORCE_INLINE_ const TData *getptr(const TKey &p_key) const { if (unlikely(!hash_table)) - return NULL; + return nullptr; const Element *e = const_cast<Element *>(get_element(p_key)); if (e) return &e->pair.data; - return NULL; + return nullptr; } /** - * Same as get, except it can return NULL when item was not found. + * Same as get, except it can return nullptr when item was not found. * This version is custom, will take a hash and a custom key (that should support operator==() */ @@ -345,7 +345,7 @@ public: _FORCE_INLINE_ TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) { if (unlikely(!hash_table)) - return NULL; + return nullptr; uint32_t hash = p_custom_hash; uint32_t index = hash & ((1 << hash_table_power) - 1); @@ -364,14 +364,14 @@ public: e = e->next; } - return NULL; + return nullptr; } template <class C> _FORCE_INLINE_ const TData *custom_getptr(C p_custom_key, uint32_t p_custom_hash) const { if (unlikely(!hash_table)) - return NULL; + return nullptr; uint32_t hash = p_custom_hash; uint32_t index = hash & ((1 << hash_table_power) - 1); @@ -390,7 +390,7 @@ public: e = e->next; } - return NULL; + return nullptr; } /** @@ -406,7 +406,7 @@ public: uint32_t index = hash & ((1 << hash_table_power) - 1); Element *e = hash_table[index]; - Element *p = NULL; + Element *p = nullptr; while (e) { /* checking hash first avoids comparing key, which may take longer */ @@ -443,7 +443,7 @@ public: } inline TData &operator[](const TKey &p_key) { //assignment - Element *e = NULL; + Element *e = nullptr; if (!hash_table) make_hash_table(); // if no table, make one else @@ -462,12 +462,12 @@ public: /** * Get the next key to p_key, and the first key if p_key is null. - * Returns a pointer to the next key if found, NULL otherwise. + * Returns a pointer to the next key if found, nullptr otherwise. * Adding/Removing elements while iterating will, of course, have unexpected results, don't do it. * * Example: * - * const TKey *k=NULL; + * const TKey *k=nullptr; * * while( (k=table.next(k)) ) { * @@ -478,7 +478,7 @@ public: const TKey *next(const TKey *p_key) const { if (unlikely(!hash_table)) - return NULL; + return nullptr; if (!p_key) { /* get the first key */ @@ -492,7 +492,7 @@ public: } else { /* get the next key */ const Element *e = get_element(*p_key); - ERR_FAIL_COND_V_MSG(!e, NULL, "Invalid key supplied."); + ERR_FAIL_COND_V_MSG(!e, nullptr, "Invalid key supplied."); if (e->next) { /* if there is a "next" in the list, return that */ return &e->next->pair.key; @@ -511,7 +511,7 @@ public: /* nothing found, was at end */ } - return NULL; /* nothing found */ + return nullptr; /* nothing found */ } inline unsigned int size() const { @@ -552,7 +552,7 @@ public: } HashMap() { - hash_table = NULL; + hash_table = nullptr; elements = 0; hash_table_power = 0; } @@ -586,7 +586,7 @@ public: HashMap(const HashMap &p_table) { - hash_table = NULL; + hash_table = nullptr; elements = 0; hash_table_power = 0; diff --git a/core/image.cpp b/core/image.cpp index d691c4f442..2097f27b01 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -84,10 +84,10 @@ const char *Image::format_names[Image::FORMAT_MAX] = { }; -SavePNGFunc Image::save_png_func = NULL; -SaveEXRFunc Image::save_exr_func = NULL; +SavePNGFunc Image::save_png_func = nullptr; +SaveEXRFunc Image::save_exr_func = nullptr; -SavePNGBufferFunc Image::save_png_buffer_func = NULL; +SavePNGBufferFunc Image::save_png_buffer_func = nullptr; void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel) { @@ -2099,14 +2099,14 @@ Error Image::load(const String &p_path) { Error Image::save_png(const String &p_path) const { - if (save_png_func == NULL) + if (save_png_func == nullptr) return ERR_UNAVAILABLE; return save_png_func(p_path, Ref<Image>((Image *)this)); } Vector<uint8_t> Image::save_png_to_buffer() const { - if (save_png_buffer_func == NULL) { + if (save_png_buffer_func == nullptr) { return Vector<uint8_t>(); } @@ -2115,7 +2115,7 @@ Vector<uint8_t> Image::save_png_to_buffer() const { Error Image::save_exr(const String &p_path, bool p_grayscale) const { - if (save_exr_func == NULL) + if (save_exr_func == nullptr) return ERR_UNAVAILABLE; return save_exr_func(p_path, Ref<Image>((Image *)this), p_grayscale); @@ -2533,28 +2533,28 @@ void Image::fill(const Color &c) { } } -ImageMemLoadFunc Image::_png_mem_loader_func = NULL; -ImageMemLoadFunc Image::_jpg_mem_loader_func = NULL; -ImageMemLoadFunc Image::_webp_mem_loader_func = NULL; +ImageMemLoadFunc Image::_png_mem_loader_func = nullptr; +ImageMemLoadFunc Image::_jpg_mem_loader_func = nullptr; +ImageMemLoadFunc Image::_webp_mem_loader_func = nullptr; -void (*Image::_image_compress_bc_func)(Image *, float, Image::UsedChannels) = NULL; -void (*Image::_image_compress_bptc_func)(Image *, float, Image::UsedChannels) = NULL; -void (*Image::_image_compress_pvrtc2_func)(Image *) = NULL; -void (*Image::_image_compress_pvrtc4_func)(Image *) = NULL; -void (*Image::_image_compress_etc1_func)(Image *, float) = NULL; -void (*Image::_image_compress_etc2_func)(Image *, float, Image::UsedChannels) = NULL; -void (*Image::_image_decompress_pvrtc)(Image *) = NULL; -void (*Image::_image_decompress_bc)(Image *) = NULL; -void (*Image::_image_decompress_bptc)(Image *) = NULL; -void (*Image::_image_decompress_etc1)(Image *) = NULL; -void (*Image::_image_decompress_etc2)(Image *) = NULL; +void (*Image::_image_compress_bc_func)(Image *, float, Image::UsedChannels) = nullptr; +void (*Image::_image_compress_bptc_func)(Image *, float, Image::UsedChannels) = nullptr; +void (*Image::_image_compress_pvrtc2_func)(Image *) = nullptr; +void (*Image::_image_compress_pvrtc4_func)(Image *) = nullptr; +void (*Image::_image_compress_etc1_func)(Image *, float) = nullptr; +void (*Image::_image_compress_etc2_func)(Image *, float, Image::UsedChannels) = nullptr; +void (*Image::_image_decompress_pvrtc)(Image *) = nullptr; +void (*Image::_image_decompress_bc)(Image *) = nullptr; +void (*Image::_image_decompress_bptc)(Image *) = nullptr; +void (*Image::_image_decompress_etc1)(Image *) = nullptr; +void (*Image::_image_decompress_etc2)(Image *) = nullptr; -Vector<uint8_t> (*Image::lossy_packer)(const Ref<Image> &, float) = NULL; -Ref<Image> (*Image::lossy_unpacker)(const Vector<uint8_t> &) = NULL; -Vector<uint8_t> (*Image::lossless_packer)(const Ref<Image> &) = NULL; -Ref<Image> (*Image::lossless_unpacker)(const Vector<uint8_t> &) = NULL; -Vector<uint8_t> (*Image::basis_universal_packer)(const Ref<Image> &, Image::UsedChannels) = NULL; -Ref<Image> (*Image::basis_universal_unpacker)(const Vector<uint8_t> &) = NULL; +Vector<uint8_t> (*Image::lossy_packer)(const Ref<Image> &, float) = nullptr; +Ref<Image> (*Image::lossy_unpacker)(const Vector<uint8_t> &) = nullptr; +Vector<uint8_t> (*Image::lossless_packer)(const Ref<Image> &) = nullptr; +Ref<Image> (*Image::lossless_unpacker)(const Vector<uint8_t> &) = nullptr; +Vector<uint8_t> (*Image::basis_universal_packer)(const Ref<Image> &, Image::UsedChannels) = nullptr; +Ref<Image> (*Image::basis_universal_unpacker)(const Vector<uint8_t> &) = nullptr; void Image::_set_data(const Dictionary &p_data) { @@ -2945,7 +2945,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("detect_used_channels", "source"), &Image::detect_used_channels, DEFVAL(COMPRESS_SOURCE_GENERIC)); ClassDB::bind_method(D_METHOD("compress", "mode", "source", "lossy_quality"), &Image::compress, DEFVAL(COMPRESS_SOURCE_GENERIC), DEFVAL(0.7)); - ClassDB::bind_method(D_METHOD("compress_from_channels", "mode", "channels", "lossy_quality"), &Image::compress, DEFVAL(0.7)); + ClassDB::bind_method(D_METHOD("compress_from_channels", "mode", "channels", "lossy_quality"), &Image::compress_from_channels, DEFVAL(0.7)); ClassDB::bind_method(D_METHOD("decompress"), &Image::decompress); ClassDB::bind_method(D_METHOD("is_compressed"), &Image::is_compressed); diff --git a/core/image.h b/core/image.h index 9453f41334..5bd73fa677 100644 --- a/core/image.h +++ b/core/image.h @@ -187,7 +187,7 @@ private: _FORCE_INLINE_ void _get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_width, int &r_height) const; //get where the mipmap begins in data - static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1, int *r_mm_width = NULL, int *r_mm_height = NULL); + static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1, int *r_mm_width = nullptr, int *r_mm_height = nullptr); bool _can_modify(Format p_format) const; _FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel); diff --git a/core/input/SCsub b/core/input/SCsub index f1660932e5..d46e52a347 100644 --- a/core/input/SCsub +++ b/core/input/SCsub @@ -1,20 +1,28 @@ #!/usr/bin/env python -Import('env') +Import("env") from platform_methods import run_in_subprocess import input_builders # Order matters here. Higher index controller database files write on top of lower index database files. -controller_databases = ["#core/input/gamecontrollerdb_204.txt", "#core/input/gamecontrollerdb_205.txt", "#core/input/gamecontrollerdb.txt", "#core/input/godotcontrollerdb.txt"] +controller_databases = [ + "#core/input/gamecontrollerdb_204.txt", + "#core/input/gamecontrollerdb_205.txt", + "#core/input/gamecontrollerdb.txt", + "#core/input/godotcontrollerdb.txt", +] env.Depends("#core/input/default_controller_mappings.gen.cpp", controller_databases) -env.CommandNoCache("#core/input/default_controller_mappings.gen.cpp", controller_databases, run_in_subprocess(input_builders.make_default_controller_mappings)) +env.CommandNoCache( + "#core/input/default_controller_mappings.gen.cpp", + controller_databases, + run_in_subprocess(input_builders.make_default_controller_mappings), +) env.add_source_files(env.core_sources, "*.cpp") # Don't warn about duplicate entry here, we need it registered manually for first build, # even if later builds will pick it up twice due to above *.cpp globbing. env.add_source_files(env.core_sources, "#core/input/default_controller_mappings.gen.cpp", warn_duplicates=False) - diff --git a/core/input/input_builders.py b/core/input/input_builders.py index ca142c0c80..53b90f2073 100644 --- a/core/input/input_builders.py +++ b/core/input/input_builders.py @@ -12,8 +12,8 @@ def make_default_controller_mappings(target, source, env): g = open(dst, "w") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#include \"core/typedefs.h\"\n") - g.write("#include \"core/input/default_controller_mappings.h\"\n") + g.write('#include "core/typedefs.h"\n') + g.write('#include "core/input/default_controller_mappings.h"\n') # ensure mappings have a consistent order platform_mappings = OrderedDict() @@ -37,11 +37,19 @@ def make_default_controller_mappings(target, source, env): line_parts = line.split(",") guid = line_parts[0] if guid in platform_mappings[current_platform]: - g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid])) + g.write( + "// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format( + src_path, current_platform, platform_mappings[current_platform][guid] + ) + ) valid_mapping = True for input_map in line_parts[2:]: if "+" in input_map or "-" in input_map or "~" in input_map: - g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line)) + g.write( + "// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format( + src_path, current_platform, line + ) + ) valid_mapping = False break if valid_mapping: @@ -62,12 +70,12 @@ def make_default_controller_mappings(target, source, env): variable = platform_variables[platform] g.write("{}\n".format(variable)) for mapping in mappings.values(): - g.write("\t\"{}\",\n".format(mapping)) + g.write('\t"{}",\n'.format(mapping)) g.write("#endif\n") - g.write("\tNULL\n};\n") + g.write("\tnullptr\n};\n") g.close() -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 088d185b8d..80219331c0 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -366,10 +366,10 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed match = get_keycode() == key->get_keycode() && (!key->is_pressed() || (code & event_code) == code); } if (match) { - if (p_pressed != NULL) + if (p_pressed != nullptr) *p_pressed = key->is_pressed(); - if (p_strength != NULL) - *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; + if (p_strength != nullptr) + *p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f; } return match; } @@ -541,10 +541,10 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p bool match = mb->button_index == button_index; if (match) { - if (p_pressed != NULL) + if (p_pressed != nullptr) *p_pressed = mb->is_pressed(); - if (p_strength != NULL) - *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; + if (p_strength != nullptr) + *p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f; } return match; @@ -815,9 +815,9 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool * if (match) { bool same_direction = (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0); bool pressed = same_direction ? Math::abs(jm->get_axis_value()) >= p_deadzone : false; - if (p_pressed != NULL) + if (p_pressed != nullptr) *p_pressed = pressed; - if (p_strength != NULL) { + if (p_strength != nullptr) { if (pressed) { if (p_deadzone == 1.0f) { *p_strength = 1.0f; @@ -892,10 +892,10 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool * bool match = button_index == jb->button_index; if (match) { - if (p_pressed != NULL) + if (p_pressed != nullptr) *p_pressed = jb->is_pressed(); - if (p_strength != NULL) - *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; + if (p_strength != nullptr) + *p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f; } return match; @@ -1140,10 +1140,10 @@ bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pres bool match = action == act->action; if (match) { - if (p_pressed != NULL) + if (p_pressed != nullptr) *p_pressed = act->pressed; - if (p_strength != NULL) - *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; + if (p_strength != nullptr) + *p_strength = (p_pressed != nullptr && *p_pressed) ? 1.0f : 0.0f; } return match; } diff --git a/core/input/input_filter.cpp b/core/input/input_filter.cpp index 088f7effd6..2e8442a905 100644 --- a/core/input/input_filter.cpp +++ b/core/input/input_filter.cpp @@ -39,7 +39,7 @@ #include "editor/editor_settings.h" #endif -InputFilter *InputFilter::singleton = NULL; +InputFilter *InputFilter::singleton = nullptr; void (*InputFilter::set_mouse_mode_func)(InputFilter::MouseMode) = nullptr; InputFilter::MouseMode (*InputFilter::get_mouse_mode_func)() = nullptr; @@ -1028,9 +1028,9 @@ void InputFilter::_axis_event(int p_device, int p_axis, float p_value) { InputFilter::JoyEvent InputFilter::_find_to_event(String p_to) { // string names of the SDL buttons in the same order as input_event.h godot buttons - static const char *buttons[] = { "a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", NULL }; + static const char *buttons[] = { "a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", nullptr }; - static const char *axis[] = { "leftx", "lefty", "rightx", "righty", NULL }; + static const char *axis[] = { "leftx", "lefty", "rightx", "righty", nullptr }; JoyEvent ret; ret.type = -1; diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 8f18c082d6..6b6acf062d 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -33,7 +33,7 @@ #include "core/os/keyboard.h" #include "core/project_settings.h" -InputMap *InputMap::singleton = NULL; +InputMap *InputMap::singleton = nullptr; int InputMap::ALL_DEVICES = -1; @@ -116,7 +116,7 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re } } - return NULL; + return nullptr; } bool InputMap::has_action(const StringName &p_action) const { @@ -144,7 +144,7 @@ void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) { ERR_FAIL_COND_V_MSG(!input_map.has(p_action), false, "Request for nonexistent InputMap action '" + String(p_action) + "'."); - return (_find_event(input_map[p_action], p_event) != NULL); + return (_find_event(input_map[p_action], p_event) != nullptr); } void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) { @@ -181,7 +181,7 @@ const List<Ref<InputEvent>> *InputMap::get_action_list(const StringName &p_actio const Map<StringName, Action>::Element *E = input_map.find(p_action); if (!E) - return NULL; + return nullptr; return &E->get().inputs; } @@ -196,20 +196,20 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str Ref<InputEventAction> input_event_action = p_event; if (input_event_action.is_valid()) { - if (p_pressed != NULL) + if (p_pressed != nullptr) *p_pressed = input_event_action->is_pressed(); - if (p_strength != NULL) - *p_strength = (p_pressed != NULL && *p_pressed) ? input_event_action->get_strength() : 0.0f; + if (p_strength != nullptr) + *p_strength = (p_pressed != nullptr && *p_pressed) ? input_event_action->get_strength() : 0.0f; return input_event_action->get_action() == p_action; } bool pressed; float strength; List<Ref<InputEvent>>::Element *event = _find_event(E->get(), p_event, &pressed, &strength); - if (event != NULL) { - if (p_pressed != NULL) + if (event != nullptr) { + if (p_pressed != nullptr) *p_pressed = pressed; - if (p_strength != NULL) + if (p_strength != nullptr) *p_strength = strength; return true; } else { diff --git a/core/input/input_map.h b/core/input/input_map.h index de6f57b0bf..e03bc5fd4f 100644 --- a/core/input/input_map.h +++ b/core/input/input_map.h @@ -55,7 +55,7 @@ private: mutable Map<StringName, Action> input_map; - List<Ref<InputEvent>>::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed = NULL, float *p_strength = NULL) const; + List<Ref<InputEvent>>::Element *_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool *p_pressed = nullptr, float *p_strength = nullptr) const; Array _get_action_list(const StringName &p_action); Array _get_actions(); @@ -79,7 +79,7 @@ public: const List<Ref<InputEvent>> *get_action_list(const StringName &p_action); bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const; - bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed = NULL, float *p_strength = NULL) const; + bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed = nullptr, float *p_strength = nullptr) const; const Map<StringName, Action> &get_action_map() const; void load_from_globals(); diff --git a/core/io/SCsub b/core/io/SCsub index 1c5f954470..19a6549225 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.core_sources, "*.cpp") diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 351e2941e8..73230e3a3c 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -290,7 +290,7 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream) next_tag.fields.clear(); next_tag.name = String(); - Error err = VariantParser::parse_tag_assign_eof(p_stream, lines, error_text, next_tag, assign, value, NULL, true); + Error err = VariantParser::parse_tag_assign_eof(p_stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { return OK; } else if (err != OK) { diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp index 07e6abb1c9..5bda06e5b9 100644 --- a/core/io/dtls_server.cpp +++ b/core/io/dtls_server.cpp @@ -32,7 +32,7 @@ #include "core/os/file_access.h" #include "core/project_settings.h" -DTLSServer *(*DTLSServer::_create)() = NULL; +DTLSServer *(*DTLSServer::_create)() = nullptr; bool DTLSServer::available = false; DTLSServer *DTLSServer::create() { diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 17cc6ce58f..c76142d22d 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -64,7 +64,7 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) { cmode = (Compression::Mode)f->get_32(); block_size = f->get_32(); if (block_size == 0) { - f = NULL; // Let the caller to handle the FileAccess object if failed to open as compressed file. + f = nullptr; // Let the caller to handle the FileAccess object if failed to open as compressed file. ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Can't open compressed file '" + p_base->get_path() + "' with block size 0, it is corrupted."); } read_total = f->get_32(); @@ -109,7 +109,7 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) { if (err != OK) { //not openable - f = NULL; + f = nullptr; return err; } @@ -131,7 +131,7 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) { rmagic[4] = 0; if (magic != rmagic || open_after_magic(f) != OK) { memdelete(f); - f = NULL; + f = nullptr; return ERR_FILE_UNRECOGNIZED; } } @@ -187,12 +187,12 @@ void FileAccessCompressed::close() { } memdelete(f); - f = NULL; + f = nullptr; } bool FileAccessCompressed::is_open() const { - return f != NULL; + return f != nullptr; } void FileAccessCompressed::seek(size_t p_position) { @@ -392,20 +392,20 @@ Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t FileAccessCompressed::FileAccessCompressed() : cmode(Compression::MODE_ZSTD), writing(false), - write_ptr(0), + write_ptr(nullptr), write_buffer_size(0), write_max(0), block_size(0), read_eof(false), at_end(false), - read_ptr(NULL), + read_ptr(nullptr), read_block(0), read_block_count(0), read_block_size(0), read_pos(0), read_total(0), magic("GCMP"), - f(NULL) { + f(nullptr) { } FileAccessCompressed::~FileAccessCompressed() { diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 20b6fc81dc..a5b3807789 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -41,7 +41,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) { - ERR_FAIL_COND_V_MSG(file != NULL, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open."); + ERR_FAIL_COND_V_MSG(file != nullptr, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open."); ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER); pos = 0; @@ -159,7 +159,7 @@ void FileAccessEncrypted::close() { file->store_buffer(compressed.ptr(), compressed.size()); file->close(); memdelete(file); - file = NULL; + file = nullptr; data.clear(); } else { @@ -167,13 +167,13 @@ void FileAccessEncrypted::close() { file->close(); memdelete(file); data.clear(); - file = NULL; + file = nullptr; } } bool FileAccessEncrypted::is_open() const { - return file != NULL; + return file != nullptr; } String FileAccessEncrypted::get_path() const { @@ -319,7 +319,7 @@ Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t FileAccessEncrypted::FileAccessEncrypted() { - file = NULL; + file = nullptr; pos = 0; eofed = false; mode = MODE_MAX; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 9e707678c0..a2379ce88f 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -35,7 +35,7 @@ #include "core/os/dir_access.h" #include "core/project_settings.h" -static Map<String, Vector<uint8_t>> *files = NULL; +static Map<String, Vector<uint8_t>> *files = nullptr; void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) { @@ -71,7 +71,7 @@ bool FileAccessMemory::file_exists(const String &p_name) { String name = fix_path(p_name); //name = DirAccess::normalize_path(name); - return files && (files->find(name) != NULL); + return files && (files->find(name) != nullptr); } Error FileAccessMemory::open_custom(const uint8_t *p_data, int p_len) { @@ -101,12 +101,12 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) { void FileAccessMemory::close() { - data = NULL; + data = nullptr; } bool FileAccessMemory::is_open() const { - return data != NULL; + return data != nullptr; } void FileAccessMemory::seek(size_t p_position) { @@ -196,5 +196,5 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, int p_length) { FileAccessMemory::FileAccessMemory() { - data = NULL; + data = nullptr; } diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 370dd8f982..a3f307393f 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -114,7 +114,7 @@ void FileAccessNetworkClient::_thread_func() { int response = get_32(); DEBUG_PRINT("GET RESPONSE: " + itos(response)); - FileAccessNetwork *fa = NULL; + FileAccessNetwork *fa = nullptr; if (response != FileAccessNetwork::RESPONSE_DATA) { if (!accesses.has(id)) { @@ -219,11 +219,11 @@ Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const S return OK; } -FileAccessNetworkClient *FileAccessNetworkClient::singleton = NULL; +FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr; FileAccessNetworkClient::FileAccessNetworkClient() { - thread = NULL; + thread = nullptr; quit = false; singleton = this; last_id = 0; @@ -295,7 +295,7 @@ Error FileAccessNetwork::_open(const String &p_path, int p_mode_flags) { pos = 0; eof_flag = false; last_page = -1; - last_page_buff = NULL; + last_page_buff = nullptr; //buffers.clear(); nc->unlock_mutex(); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 055ce816ad..0a7dee9444 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -98,18 +98,18 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o void PackedData::add_pack_source(PackSource *p_source) { - if (p_source != NULL) { + if (p_source != nullptr) { sources.push_back(p_source); } }; -PackedData *PackedData::singleton = NULL; +PackedData *PackedData::singleton = nullptr; PackedData::PackedData() { singleton = this; root = memnew(PackedDir); - root->parent = NULL; + root->parent = nullptr; disabled = false; add_pack_source(memnew(PackedSourcePCK)); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index e1f35aabdd..8df6826ac9 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -185,9 +185,9 @@ FileAccess *PackedData::try_open_path(const String &p_path) { PathMD5 pmd5(p_path.md5_buffer()); Map<PathMD5, PackedFile>::Element *E = files.find(pmd5); if (!E) - return NULL; //not found + return nullptr; //not found if (E->get().offset == 0) - return NULL; //was erased + return nullptr; //was erased return E->get().src->get_file(p_path, &E->get()); } diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 680450ba43..57de66afaf 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -35,20 +35,20 @@ #include "core/os/copymem.h" #include "core/os/file_access.h" -ZipArchive *ZipArchive::instance = NULL; +ZipArchive *ZipArchive::instance = nullptr; extern "C" { static void *godot_open(void *data, const char *p_fname, int mode) { if (mode & ZLIB_FILEFUNC_MODE_WRITE) { - return NULL; + return nullptr; } FileAccess *f = (FileAccess *)data; f->open(p_fname, FileAccess::READ); - return f->is_open() ? data : NULL; + return f->is_open() ? data : nullptr; } static uLong godot_read(void *data, void *fdata, void *buf, uLong size) { @@ -126,11 +126,11 @@ void ZipArchive::close_handle(unzFile p_file) const { unzFile ZipArchive::get_file_handle(String p_file) const { - ERR_FAIL_COND_V_MSG(!file_exists(p_file), NULL, "File '" + p_file + " doesn't exist."); + ERR_FAIL_COND_V_MSG(!file_exists(p_file), nullptr, "File '" + p_file + " doesn't exist."); File file = files[p_file]; FileAccess *f = FileAccess::open(packages[file.package].filename, FileAccess::READ); - ERR_FAIL_COND_V_MSG(!f, NULL, "Cannot open file '" + packages[file.package].filename + "'."); + ERR_FAIL_COND_V_MSG(!f, nullptr, "Cannot open file '" + packages[file.package].filename + "'."); zlib_filefunc_def io; zeromem(&io, sizeof(io)); @@ -149,12 +149,12 @@ unzFile ZipArchive::get_file_handle(String p_file) const { io.free_mem = godot_free; unzFile pkg = unzOpen2(packages[file.package].filename.utf8().get_data(), &io); - ERR_FAIL_COND_V(!pkg, NULL); + ERR_FAIL_COND_V(!pkg, nullptr); int unz_err = unzGoToFilePos(pkg, &file.file_pos); if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) { unzClose(pkg); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } return pkg; @@ -199,7 +199,7 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) { char filename_inzip[256]; unz_file_info64 file_info; - err = unzGetCurrentFileInfo64(zfile, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0); + err = unzGetCurrentFileInfo64(zfile, &file_info, filename_inzip, sizeof(filename_inzip), nullptr, 0, nullptr, 0); ERR_CONTINUE(err != UNZ_OK); File f; @@ -233,7 +233,7 @@ FileAccess *ZipArchive::get_file(const String &p_path, PackedData::PackedFile *p ZipArchive *ZipArchive::get_singleton() { - if (instance == NULL) { + if (instance == nullptr) { instance = memnew(ZipArchive); } @@ -268,7 +268,7 @@ Error FileAccessZip::_open(const String &p_path, int p_mode_flags) { zfile = arch->get_file_handle(p_path); ERR_FAIL_COND_V(!zfile, FAILED); - int err = unzGetCurrentFileInfo64(zfile, &file_info, NULL, 0, NULL, 0, NULL, 0); + int err = unzGetCurrentFileInfo64(zfile, &file_info, nullptr, 0, nullptr, 0, nullptr, 0); ERR_FAIL_COND_V(err != UNZ_OK, FAILED); return OK; @@ -282,12 +282,12 @@ void FileAccessZip::close() { ZipArchive *arch = ZipArchive::get_singleton(); ERR_FAIL_COND(!arch); arch->close_handle(zfile); - zfile = NULL; + zfile = nullptr; } bool FileAccessZip::is_open() const { - return zfile != NULL; + return zfile != nullptr; } void FileAccessZip::seek(size_t p_position) { @@ -370,7 +370,7 @@ bool FileAccessZip::file_exists(const String &p_name) { } FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) : - zfile(NULL) { + zfile(nullptr) { _open(p_path, FileAccess::READ); } diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 99ac5bcdd9..2770adbd36 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -100,7 +100,7 @@ ImageFormatLoader *ImageLoader::recognize(const String &p_extension) { return loader[i]; } - return NULL; + return nullptr; } Vector<ImageFormatLoader *> ImageLoader::loader; diff --git a/core/io/image_loader.h b/core/io/image_loader.h index 29352e9cd4..18b4df98f7 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -59,7 +59,7 @@ class ImageLoader { protected: public: - static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false, float p_scale = 1.0); + static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = nullptr, bool p_force_linear = false, float p_scale = 1.0); static void get_recognized_extensions(List<String> *p_extensions); static ImageFormatLoader *recognize(const String &p_extension); @@ -73,7 +73,7 @@ public: class ResourceFormatLoaderImage : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 2143b84d15..5de7fb7186 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -280,19 +280,19 @@ void IP::_bind_methods() { BIND_ENUM_CONSTANT(TYPE_ANY); } -IP *IP::singleton = NULL; +IP *IP::singleton = nullptr; IP *IP::get_singleton() { return singleton; } -IP *(*IP::_create)() = NULL; +IP *(*IP::_create)() = nullptr; IP *IP::create() { - ERR_FAIL_COND_V_MSG(singleton, NULL, "IP singleton already exist."); - ERR_FAIL_COND_V(!_create, NULL); + ERR_FAIL_COND_V_MSG(singleton, nullptr, "IP singleton already exist."); + ERR_FAIL_COND_V(!_create, nullptr); return _create(); } @@ -307,7 +307,7 @@ IP::IP() { resolver->thread = Thread::create(_IP_ResolverPrivate::_thread_function, resolver); #else - resolver->thread = NULL; + resolver->thread = nullptr; #endif } diff --git a/core/io/logger.cpp b/core/io/logger.cpp index 4d732332d5..48aebeda3d 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -108,7 +108,7 @@ Logger::~Logger() {} void RotatedFileLogger::close_file() { if (file) { memdelete(file); - file = NULL; + file = nullptr; } } @@ -182,7 +182,7 @@ void RotatedFileLogger::rotate_file() { RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) : base_path(p_base_path.simplify_path()), max_files(p_max_files > 0 ? p_max_files : 1), - file(NULL) { + file(nullptr) { rotate_file(); } diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index fbcaa582b7..81bc45b2f7 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -439,7 +439,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int (*r_len) += 8; if (val.is_null()) { - r_variant = (Object *)NULL; + r_variant = (Object *)nullptr; } else { Ref<EncodedObjectAsID> obj_as_id; obj_as_id.instance(); @@ -457,7 +457,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int return err; if (str == String()) { - r_variant = (Object *)NULL; + r_variant = (Object *)nullptr; } else { Object *obj = ClassDB::instance(str); @@ -917,7 +917,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo // Test for potential wrong values sent by the debugger when it breaks. Object *obj = p_variant.get_validated_object(); if (!obj) { - // Object is invalid, send a NULL instead. + // Object is invalid, send a nullptr instead. if (buf) { encode_uint32(Variant::NIL, buf); } diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 7d95bc4f86..d029ed238c 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -199,7 +199,7 @@ public: EncodedObjectAsID(); }; -Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = false); +Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, 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 // MARSHALLS_H diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index c29df07624..3bec52416e 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -207,7 +207,7 @@ int get_packet_len(uint32_t p_node_target, int p_packet_len) { void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { - ERR_FAIL_COND_MSG(root_node == NULL, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it."); + ERR_FAIL_COND_MSG(root_node == nullptr, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it."); ERR_FAIL_COND_MSG(p_packet_len < 1, "Invalid packet received. Size too small."); #ifdef DEBUG_ENABLED @@ -285,7 +285,7 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_ } Node *node = _process_get_node(p_from, p_packet, node_target, p_packet_len); - ERR_FAIL_COND_MSG(node == NULL, "Invalid packet received. Requested node was not found."); + ERR_FAIL_COND_MSG(node == nullptr, "Invalid packet received. Requested node was not found."); uint16_t name_id = 0; switch (name_id_compression) { @@ -321,14 +321,14 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uint32_t p_node_target, int p_packet_len) { - Node *node = NULL; + Node *node = nullptr; if (p_node_target & 0x80000000) { // Use full path (not cached yet). int ofs = p_node_target & 0x7FFFFFFF; - ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, NULL, "Invalid packet received. Size smaller than declared."); + ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, nullptr, "Invalid packet received. Size smaller than declared."); String paths; paths.parse_utf8((const char *)&p_packet[ofs], p_packet_len - ofs); @@ -344,10 +344,10 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uin int id = p_node_target; Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from); - ERR_FAIL_COND_V_MSG(!E, NULL, "Invalid packet received. Requests invalid peer cache."); + ERR_FAIL_COND_V_MSG(!E, nullptr, "Invalid packet received. Requests invalid peer cache."); Map<int, PathGetCache::NodeInfo>::Element *F = E->get().nodes.find(id); - ERR_FAIL_COND_V_MSG(!F, NULL, "Invalid packet received. Unabled to find requested cached node."); + ERR_FAIL_COND_V_MSG(!F, nullptr, "Invalid packet received. Unabled to find requested cached node."); PathGetCache::NodeInfo *ni = &F->get(); // Do proper caching later. @@ -456,7 +456,7 @@ void MultiplayerAPI::_process_rset(Node *p_node, const uint16_t p_rpc_property_i #endif Variant value; - Error err = _decode_and_decompress_variant(value, &p_packet[p_offset], p_packet_len - p_offset, NULL); + Error err = _decode_and_decompress_variant(value, &p_packet[p_offset], p_packet_len - p_offset, nullptr); ERR_FAIL_COND_MSG(err != OK, "Invalid packet received. Unable to decode RSET value."); @@ -491,7 +491,7 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, } Node *node = root_node->get_node(path); - ERR_FAIL_COND(node == NULL); + ERR_FAIL_COND(node == nullptr); const bool valid_rpc_checksum = node->get_rpc_md5() == methods_md5; if (valid_rpc_checksum == false) { ERR_PRINT("The rpc node checksum failed. Make sure to have the same methods on both nodes. Node path: " + path); @@ -504,7 +504,7 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, // Encode path to send ack. CharString pname = String(path).utf8(); - int len = encode_cstring(pname.get_data(), NULL); + int len = encode_cstring(pname.get_data(), nullptr); Vector<uint8_t> packet; @@ -572,7 +572,7 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC // Encode function name. const CharString path = String(p_path).utf8(); - const int path_len = encode_cstring(path.get_data(), NULL); + const int path_len = encode_cstring(path.get_data(), nullptr); // Extract MD5 from rpc methods list. const String methods_md5 = p_node->get_rpc_md5(); @@ -862,7 +862,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p // Set argument. int len(0); - Error err = _encode_and_compress_variant(*p_arg[0], NULL, len); + Error err = _encode_and_compress_variant(*p_arg[0], nullptr, len); ERR_FAIL_COND_MSG(err != OK, "Unable to encode RSET value. THIS IS LIKELY A BUG IN THE ENGINE!"); MAKE_ROOM(ofs + len); _encode_and_compress_variant(*p_arg[0], &(packet_cache.write[ofs]), len); @@ -907,7 +907,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p ofs += 1; for (int i = 0; i < p_argcount; i++) { int len(0); - Error err = _encode_and_compress_variant(*p_arg[i], NULL, len); + Error err = _encode_and_compress_variant(*p_arg[i], nullptr, len); ERR_FAIL_COND_MSG(err != OK, "Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!"); MAKE_ROOM(ofs + len); _encode_and_compress_variant(*p_arg[i], &(packet_cache.write[ofs]), len); @@ -943,7 +943,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p // Append path at the end, since we will need it for some packets. CharString pname = String(from_path).utf8(); - int path_len = encode_cstring(pname.get_data(), NULL); + int path_len = encode_cstring(pname.get_data(), nullptr); MAKE_ROOM(ofs + path_len); encode_cstring(pname.get_data(), &(packet_cache.write[ofs])); @@ -1262,7 +1262,7 @@ void MultiplayerAPI::_bind_methods() { MultiplayerAPI::MultiplayerAPI() : allow_object_decoding(false) { rpc_sender_id = 0; - root_node = NULL; + root_node = nullptr; clear(); } diff --git a/core/io/net_socket.cpp b/core/io/net_socket.cpp index 23edbc7d64..838c674cec 100644 --- a/core/io/net_socket.cpp +++ b/core/io/net_socket.cpp @@ -30,7 +30,7 @@ #include "net_socket.h" -NetSocket *(*NetSocket::_create)() = NULL; +NetSocket *(*NetSocket::_create)() = nullptr; NetSocket *NetSocket::create() { @@ -38,5 +38,5 @@ NetSocket *NetSocket::create() { return _create(); ERR_PRINT("Unable to create network socket, platform not supported"); - return NULL; + return nullptr; } diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 2f5c493c2c..38abb5c0d6 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -90,13 +90,13 @@ Error PacketPeer::get_var(Variant &r_variant, bool p_allow_objects) { if (err) return err; - return decode_variant(r_variant, buffer, buffer_size, NULL, p_allow_objects); + return decode_variant(r_variant, buffer, buffer_size, nullptr, p_allow_objects); } Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) { int len; - Error err = encode_variant(p_packet, NULL, len, p_full_objects); // compute len first + Error err = encode_variant(p_packet, nullptr, len, p_full_objects); // compute len first if (err) return err; diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp index 01218a6881..6da115eed2 100644 --- a/core/io/packet_peer_dtls.cpp +++ b/core/io/packet_peer_dtls.cpp @@ -32,7 +32,7 @@ #include "core/os/file_access.h" #include "core/project_settings.h" -PacketPeerDTLS *(*PacketPeerDTLS::_create)() = NULL; +PacketPeerDTLS *(*PacketPeerDTLS::_create)() = nullptr; bool PacketPeerDTLS::available = false; PacketPeerDTLS *PacketPeerDTLS::create() { diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 11e537c10b..5c4b3379ee 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -63,7 +63,7 @@ void PCKPacker::_bind_methods() { Error PCKPacker::pck_start(const String &p_file, int p_alignment) { - if (file != NULL) { + if (file != nullptr) { memdelete(file); } @@ -182,12 +182,12 @@ Error PCKPacker::flush(bool p_verbose) { PCKPacker::PCKPacker() { - file = NULL; + file = nullptr; }; PCKPacker::~PCKPacker() { - if (file != NULL) { + if (file != nullptr) { memdelete(file); }; - file = NULL; + file = nullptr; }; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index efd452191a..a640565ecf 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1009,7 +1009,7 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) { ResourceLoaderBinary::ResourceLoaderBinary() : translation_remapped(false), ver_format(0), - f(NULL), + f(nullptr), importmd_ofs(0), error(OK) { @@ -1107,7 +1107,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons FileAccess *f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_path + "'."); - FileAccess *fw = NULL; //=FileAccess::open(p_path+".depren"); + FileAccess *fw = nullptr; //=FileAccess::open(p_path+".depren"); String local_path = p_path.get_base_dir(); @@ -2095,7 +2095,7 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const RES &p_resource, p_extensions->push_back("res"); } -ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = NULL; +ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = nullptr; ResourceFormatSaverBinary::ResourceFormatSaverBinary() { diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 0ffa2c3626..da67e1e648 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -101,7 +101,7 @@ public: class ResourceFormatLoaderBinary : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index 452514a588..ceb73cab77 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -69,7 +69,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { memdelete(f); return OK; @@ -274,7 +274,7 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { memdelete(f); return; @@ -434,7 +434,7 @@ String ResourceFormatImporter::get_import_settings_hash() const { return hash.md5_text(); } -ResourceFormatImporter *ResourceFormatImporter::singleton = NULL; +ResourceFormatImporter *ResourceFormatImporter::singleton = nullptr; ResourceFormatImporter::ResourceFormatImporter() { singleton = this; diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index 369efbe83c..dbac80599a 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -45,7 +45,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { Variant metadata; }; - Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = NULL) const; + Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = nullptr) const; static ResourceFormatImporter *singleton; @@ -58,7 +58,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { public: static ResourceFormatImporter *get_singleton() { return singleton; } - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; @@ -123,7 +123,7 @@ public: virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const = 0; virtual String get_option_group_file() const { return String(); } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL) = 0; + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0; virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) { return ERR_UNAVAILABLE; } virtual bool are_import_settings_valid(const String &p_path) const { return true; } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index b150df5f40..05a41013c2 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -936,7 +936,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { break; } else if (err != OK) { @@ -1048,7 +1048,7 @@ void ResourceLoader::set_load_callback(ResourceLoadedCallback p_callback) { _loaded_callback = p_callback; } -ResourceLoadedCallback ResourceLoader::_loaded_callback = NULL; +ResourceLoadedCallback ResourceLoader::_loaded_callback = nullptr; Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(String path) { for (int i = 0; i < loader_count; ++i) { @@ -1075,7 +1075,7 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) { Object *obj = ClassDB::instance(ibt); - ERR_FAIL_COND_V_MSG(obj == NULL, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); ResourceFormatLoader *crl = Object::cast_to<ResourceFormatLoader>(obj); crl->set_script(s); @@ -1140,11 +1140,11 @@ void ResourceLoader::finalize() { memdelete(thread_load_semaphore); } -ResourceLoadErrorNotify ResourceLoader::err_notify = NULL; -void *ResourceLoader::err_notify_ud = NULL; +ResourceLoadErrorNotify ResourceLoader::err_notify = nullptr; +void *ResourceLoader::err_notify_ud = nullptr; -DependencyErrorNotify ResourceLoader::dep_err_notify = NULL; -void *ResourceLoader::dep_err_notify_ud = NULL; +DependencyErrorNotify ResourceLoader::dep_err_notify = nullptr; +void *ResourceLoader::dep_err_notify_ud = nullptr; bool ResourceLoader::abort_on_missing_resource = true; bool ResourceLoader::timestamp_on_load = false; @@ -1162,4 +1162,4 @@ SelfList<Resource>::List ResourceLoader::remapped_list; HashMap<String, Vector<String>> ResourceLoader::translation_remaps; HashMap<String, String> ResourceLoader::path_remaps; -ResourceLoaderImport ResourceLoader::import = NULL; +ResourceLoaderImport ResourceLoader::import = nullptr; diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index a97b72e7df..be4adf9091 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -43,7 +43,7 @@ protected: static void _bind_methods(); public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual bool exists(const String &p_path) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; @@ -93,7 +93,7 @@ private: static HashMap<String, Vector<String>> translation_remaps; static HashMap<String, String> path_remaps; - static String _path_remap(const String &p_path, bool *r_translation_remapped = NULL); + static String _path_remap(const String &p_path, bool *r_translation_remapped = nullptr); friend class Resource; static SelfList<Resource>::List remapped_list; @@ -140,9 +140,9 @@ private: public: static Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, const String &p_source_resource = String()); static ThreadLoadStatus load_threaded_get_status(const String &p_path, float *r_progress = nullptr); - static RES load_threaded_get(const String &p_path, Error *r_error = NULL); + static RES load_threaded_get(const String &p_path, Error *r_error = nullptr); - static RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false, Error *r_error = NULL); + static RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false, Error *r_error = nullptr); static bool exists(const String &p_path, const String &p_type_hint = ""); static void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions); diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 80d2c5e471..09128adb50 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -38,7 +38,7 @@ Ref<ResourceFormatSaver> ResourceSaver::saver[MAX_SAVERS]; int ResourceSaver::saver_count = 0; bool ResourceSaver::timestamp_on_save = false; -ResourceSavedCallback ResourceSaver::save_callback = 0; +ResourceSavedCallback ResourceSaver::save_callback = nullptr; Error ResourceFormatSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { @@ -218,7 +218,7 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) { Object *obj = ClassDB::instance(ibt); - ERR_FAIL_COND_V_MSG(obj == NULL, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); ResourceFormatSaver *crl = Object::cast_to<ResourceFormatSaver>(obj); crl->set_script(s); diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 3c695c18fc..b28b17aa95 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -224,7 +224,7 @@ void StreamPeer::put_var(const Variant &p_variant, bool p_full_objects) { int len = 0; Vector<uint8_t> buf; - encode_variant(p_variant, NULL, len, p_full_objects); + encode_variant(p_variant, nullptr, len, p_full_objects); buf.resize(len); put_32(len); encode_variant(p_variant, buf.ptrw(), len, p_full_objects); @@ -368,7 +368,7 @@ Variant StreamPeer::get_var(bool p_allow_objects) { ERR_FAIL_COND_V(err != OK, Variant()); Variant ret; - err = decode_variant(ret, var.ptr(), len, NULL, p_allow_objects); + err = decode_variant(ret, var.ptr(), len, nullptr, p_allow_objects); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant."); return ret; diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp index 03ca726619..d98935f77c 100644 --- a/core/io/stream_peer_ssl.cpp +++ b/core/io/stream_peer_ssl.cpp @@ -32,13 +32,13 @@ #include "core/engine.h" -StreamPeerSSL *(*StreamPeerSSL::_create)() = NULL; +StreamPeerSSL *(*StreamPeerSSL::_create)() = nullptr; StreamPeerSSL *StreamPeerSSL::create() { if (_create) return _create(); - return NULL; + return nullptr; } bool StreamPeerSSL::available = false; diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index d280729e94..9d3117b630 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -37,8 +37,8 @@ class TranslationLoaderPO : public ResourceFormatLoader { public: - static RES load_translation(FileAccess *f, Error *r_error = NULL); - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + static RES load_translation(FileAccess *f, Error *r_error = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index bd450dd84f..9613ad3f10 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -165,7 +165,7 @@ bool XMLParser::_parse_cdata() { return true; char *cDataBegin = P; - char *cDataEnd = 0; + char *cDataEnd = nullptr; // find end of CDATA while (*P && !cDataEnd) { @@ -529,9 +529,9 @@ void XMLParser::close() { if (data) memdelete_arr(data); - data = NULL; + data = nullptr; length = 0; - P = NULL; + P = nullptr; node_empty = false; node_type = NODE_NONE; node_offset = 0; @@ -544,7 +544,7 @@ int XMLParser::get_current_line() const { XMLParser::XMLParser() { - data = NULL; + data = nullptr; close(); special_characters.push_back("&"); special_characters.push_back("<lt;"); diff --git a/core/io/zip_io.cpp b/core/io/zip_io.cpp index 40e902d874..3a2a207d22 100644 --- a/core/io/zip_io.cpp +++ b/core/io/zip_io.cpp @@ -47,7 +47,7 @@ void *zipio_open(void *data, const char *p_fname, int mode) { } if (!f) - return NULL; + return nullptr; return data; } @@ -98,7 +98,7 @@ int zipio_close(voidpf opaque, voidpf stream) { if (f) { f->close(); memdelete(f); - f = NULL; + f = nullptr; } return 0; } diff --git a/core/list.h b/core/list.h index d441c0230d..be2dccd876 100644 --- a/core/list.h +++ b/core/list.h @@ -142,7 +142,7 @@ public: _FORCE_INLINE_ Element() { next_ptr = 0; prev_ptr = 0; - data = NULL; + data = nullptr; }; }; @@ -220,8 +220,8 @@ public: if (!_data) { _data = memnew_allocator(_Data, A); - _data->first = NULL; - _data->last = NULL; + _data->first = nullptr; + _data->last = nullptr; _data->size_cache = 0; } @@ -261,8 +261,8 @@ public: if (!_data) { _data = memnew_allocator(_Data, A); - _data->first = NULL; - _data->last = NULL; + _data->first = nullptr; + _data->last = nullptr; _data->size_cache = 0; } @@ -357,7 +357,7 @@ public: it = it->next(); }; - return NULL; + return nullptr; }; /** @@ -370,7 +370,7 @@ public: if (_data->size_cache == 0) { memdelete_allocator<_Data, A>(_data); - _data = NULL; + _data = nullptr; } return ret; @@ -498,7 +498,7 @@ public: _data->last->next_ptr = p_I; p_I->prev_ptr = _data->last; - p_I->next_ptr = NULL; + p_I->next_ptr = nullptr; _data->last = p_I; } @@ -535,7 +535,7 @@ public: _data->first->prev_ptr = p_I; p_I->next_ptr = _data->first; - p_I->prev_ptr = NULL; + p_I->prev_ptr = nullptr; _data->first = p_I; } @@ -595,7 +595,7 @@ public: if (from != current) { - current->prev_ptr = NULL; + current->prev_ptr = nullptr; current->next_ptr = from; Element *find = from; @@ -618,8 +618,8 @@ public: to = current; } else { - current->prev_ptr = NULL; - current->next_ptr = NULL; + current->prev_ptr = nullptr; + current->next_ptr = nullptr; } current = next; @@ -661,12 +661,12 @@ public: sort.sort(aux_buffer, s); _data->first = aux_buffer[0]; - aux_buffer[0]->prev_ptr = NULL; + aux_buffer[0]->prev_ptr = nullptr; aux_buffer[0]->next_ptr = aux_buffer[1]; _data->last = aux_buffer[s - 1]; aux_buffer[s - 1]->prev_ptr = aux_buffer[s - 2]; - aux_buffer[s - 1]->next_ptr = NULL; + aux_buffer[s - 1]->next_ptr = nullptr; for (int i = 1; i < s - 1; i++) { @@ -686,7 +686,7 @@ public: */ List(const List &p_list) { - _data = NULL; + _data = nullptr; const Element *it = p_list.front(); while (it) { @@ -696,7 +696,7 @@ public: } List() { - _data = NULL; + _data = nullptr; }; ~List() { clear(); diff --git a/core/make_binders.py b/core/make_binders.py index c42b91fbe5..94bee95bfb 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -280,58 +280,57 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (*p_method)($ifconst con """ - def make_version(template, nargs, argmax, const, ret): intext = template from_pos = 0 outtext = "" - while(True): + while True: to_pos = intext.find("$", from_pos) - if (to_pos == -1): + if to_pos == -1: outtext += intext[from_pos:] break else: outtext += intext[from_pos:to_pos] end = intext.find("$", to_pos + 1) - if (end == -1): + if end == -1: break # ignore - macro = intext[to_pos + 1:end] + macro = intext[to_pos + 1 : end] cmd = "" data = "" - if (macro.find(" ") != -1): - cmd = macro[0:macro.find(" ")] - data = macro[macro.find(" ") + 1:] + if macro.find(" ") != -1: + cmd = macro[0 : macro.find(" ")] + data = macro[macro.find(" ") + 1 :] else: cmd = macro - if (cmd == "argc"): + if cmd == "argc": outtext += str(nargs) - if (cmd == "ifret" and ret): + if cmd == "ifret" and ret: outtext += data - if (cmd == "ifargs" and nargs): + if cmd == "ifargs" and nargs: outtext += data - if (cmd == "ifretargs" and nargs and ret): + if cmd == "ifretargs" and nargs and ret: outtext += data - if (cmd == "ifconst" and const): + if cmd == "ifconst" and const: outtext += data - elif (cmd == "ifnoconst" and not const): + elif cmd == "ifnoconst" and not const: outtext += data - elif (cmd == "ifnoret" and not ret): + elif cmd == "ifnoret" and not ret: outtext += data - elif (cmd == "iftempl" and (nargs > 0 or ret)): + elif cmd == "iftempl" and (nargs > 0 or ret): outtext += data - elif (cmd == "arg,"): + elif cmd == "arg,": for i in range(1, nargs + 1): - if (i > 1): + if i > 1: outtext += ", " outtext += data.replace("@", str(i)) - elif (cmd == "arg"): + elif cmd == "arg": for i in range(1, nargs + 1): outtext += data.replace("@", str(i)) - elif (cmd == "noarg"): + elif cmd == "noarg": for i in range(nargs + 1, argmax + 1): outtext += data.replace("@", str(i)) @@ -348,7 +347,9 @@ def run(target, source, env): text_ext = "" text_free_func = "#ifndef METHOD_BIND_FREE_FUNC_H\n#define METHOD_BIND_FREE_FUNC_H\n" text_free_func += "\n//including this header file allows method binding to use free functions\n" - text_free_func += "//note that the free function must have a pointer to an instance of the class as its first parameter\n" + text_free_func += ( + "//note that the free function must have a pointer to an instance of the class as its first parameter\n" + ) for i in range(0, versions + 1): @@ -361,7 +362,7 @@ def run(target, source, env): t += make_version(template_typed, i, versions, True, False) t += make_version(template, i, versions, True, True) t += make_version(template_typed, i, versions, True, True) - if (i >= versions_ext): + if i >= versions_ext: text_ext += t else: text += t @@ -383,6 +384,7 @@ def run(target, source, env): f.write(text_free_func) -if __name__ == '__main__': +if __name__ == "__main__": from platform_methods import subprocess_main + subprocess_main(globals()) diff --git a/core/map.h b/core/map.h index 010c47b0fb..6b9dff51de 100644 --- a/core/map.h +++ b/core/map.h @@ -95,11 +95,11 @@ public: }; Element() { color = RED; - right = NULL; - left = NULL; - parent = NULL; - _next = NULL; - _prev = NULL; + right = nullptr; + left = nullptr; + parent = nullptr; + _next = nullptr; + _prev = nullptr; }; }; @@ -118,7 +118,7 @@ private: #else _nil = (Element *)&_GlobalNilClass::_nil; #endif - _root = NULL; + _root = nullptr; size_cache = 0; } @@ -133,7 +133,7 @@ private: if (_root) { memdelete_allocator<Element, A>(_root); - _root = NULL; + _root = nullptr; } } @@ -205,7 +205,7 @@ private: } if (node->parent == _data._root) - return NULL; // No successor, as p_node = last node + return nullptr; // No successor, as p_node = last node return node->parent; } } @@ -227,7 +227,7 @@ private: } if (node == _data._root) - return NULL; // No predecessor, as p_node = first node + return nullptr; // No predecessor, as p_node = first node return node->parent; } } @@ -246,13 +246,13 @@ private: return node; // found } - return NULL; + return nullptr; } Element *_find_closest(const K &p_key) const { Element *node = _data._root->left; - Element *prev = NULL; + Element *prev = nullptr; C less; while (node != _data._nil) { @@ -266,8 +266,8 @@ private: return node; // found } - if (prev == NULL) - return NULL; // tree empty + if (prev == nullptr) + return nullptr; // tree empty if (less(p_key, prev->_key)) prev = prev->_prev; @@ -519,7 +519,7 @@ public: const Element *find(const K &p_key) const { if (!_data._root) - return NULL; + return nullptr; const Element *res = _find(p_key); return res; @@ -528,7 +528,7 @@ public: Element *find(const K &p_key) { if (!_data._root) - return NULL; + return nullptr; Element *res = _find(p_key); return res; @@ -537,7 +537,7 @@ public: const Element *find_closest(const K &p_key) const { if (!_data._root) - return NULL; + return nullptr; const Element *res = _find_closest(p_key); return res; @@ -546,7 +546,7 @@ public: Element *find_closest(const K &p_key) { if (!_data._root) - return NULL; + return nullptr; Element *res = _find_closest(p_key); return res; @@ -554,7 +554,7 @@ public: bool has(const K &p_key) const { - return find(p_key) != NULL; + return find(p_key) != nullptr; } Element *insert(const K &p_key, const V &p_value) { @@ -612,11 +612,11 @@ public: Element *front() const { if (!_data._root) - return NULL; + return nullptr; Element *e = _data._root->left; if (e == _data._nil) - return NULL; + return nullptr; while (e->left != _data._nil) e = e->left; @@ -627,11 +627,11 @@ public: Element *back() const { if (!_data._root) - return NULL; + return nullptr; Element *e = _data._root->left; if (e == _data._nil) - return NULL; + return nullptr; while (e->right != _data._nil) e = e->right; diff --git a/core/math/SCsub b/core/math/SCsub index be438fcfbe..c8fdac207e 100644 --- a/core/math/SCsub +++ b/core/math/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env_math = env.Clone() diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index bfff12ac45..3e3e6c50a7 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -66,7 +66,7 @@ void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) { pt->id = p_id; pt->pos = p_pos; pt->weight_scale = p_weight_scale; - pt->prev_point = NULL; + pt->prev_point = nullptr; pt->open_pass = 0; pt->closed_pass = 0; pt->enabled = true; @@ -167,7 +167,7 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) { if (bidirectional) s.direction = Segment::BIDIRECTIONAL; Set<Segment>::Element *element = segments.find(s); - if (element != NULL) { + if (element != nullptr) { s.direction |= element->get().direction; if (s.direction == Segment::BIDIRECTIONAL) { // Both are neighbours of each other now @@ -194,7 +194,7 @@ void AStar::disconnect_points(int p_id, int p_with_id, bool bidirectional) { int remove_direction = bidirectional ? (int)Segment::BIDIRECTIONAL : s.direction; Set<Segment>::Element *element = segments.find(s); - if (element != NULL) { + if (element != nullptr) { // s is the new segment // Erase the directions to be removed s.direction = (element->get().direction & ~remove_direction); @@ -255,7 +255,7 @@ bool AStar::are_points_connected(int p_id, int p_with_id, bool bidirectional) co Segment s(p_id, p_with_id); const Set<Segment>::Element *element = segments.find(s); - return element != NULL && + return element != nullptr && (bidirectional || (element->get().direction & s.direction) == s.direction); } diff --git a/core/math/aabb.h b/core/math/aabb.h index d9d50c7139..eca74e6755 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -72,8 +72,8 @@ public: AABB merge(const AABB &p_with) const; void merge_with(const AABB &p_aabb); ///merge with another AABB AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs - bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const; - bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const; + bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const; + bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = nullptr, Vector3 *r_normal = nullptr) const; _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const; _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_planes, int p_plane_count) const; diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 04fda9d09a..859b9be8c5 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -760,7 +760,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant PackedByteArray barr; bool full_objects = *p_inputs[1]; int len; - Error err = encode_variant(*p_inputs[0], NULL, len, full_objects); + Error err = encode_variant(*p_inputs[0], nullptr, len, full_objects); if (err) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; @@ -791,7 +791,7 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant Variant ret; { const uint8_t *r = varr.ptr(); - Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects); + Error err = decode_variant(ret, r, varr.size(), nullptr, allow_objects); if (err != OK) { r_error_str = RTR("Not enough bytes for decoding bytes, or invalid format."); r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; @@ -1298,12 +1298,12 @@ Expression::ENode *Expression::_parse_expression() { while (true) { //keep appending stuff to expression - ENode *expr = NULL; + ENode *expr = nullptr; Token tk; _get_token(tk); if (error_set) - return NULL; + return nullptr; switch (tk.type) { case TK_CURLY_BRACKET_OPEN: { @@ -1321,18 +1321,18 @@ Expression::ENode *Expression::_parse_expression() { //parse an expression ENode *subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; dn->dict.push_back(subexpr); _get_token(tk); if (tk.type != TK_COLON) { _set_error("Expected ':'"); - return NULL; + return nullptr; } subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; dn->dict.push_back(subexpr); @@ -1365,7 +1365,7 @@ Expression::ENode *Expression::_parse_expression() { //parse an expression ENode *subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; an->array.push_back(subexpr); cofs = str_ofs; @@ -1385,11 +1385,11 @@ Expression::ENode *Expression::_parse_expression() { //a suexpression ENode *e = _parse_expression(); if (error_set) - return NULL; + return nullptr; _get_token(tk); if (tk.type != TK_PARENTHESIS_CLOSE) { _set_error("Expected ')'"); - return NULL; + return nullptr; } expr = e; @@ -1419,7 +1419,7 @@ Expression::ENode *Expression::_parse_expression() { //parse an expression ENode *subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; func_call->arguments.push_back(subexpr); @@ -1484,7 +1484,7 @@ Expression::ENode *Expression::_parse_expression() { _get_token(tk); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '('"); - return NULL; + return nullptr; } ConstructorNode *constructor = alloc_node<ConstructorNode>(); @@ -1501,7 +1501,7 @@ Expression::ENode *Expression::_parse_expression() { //parse an expression ENode *subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; constructor->arguments.push_back(subexpr); @@ -1525,7 +1525,7 @@ Expression::ENode *Expression::_parse_expression() { _get_token(tk); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '('"); - return NULL; + return nullptr; } BuiltinFuncNode *bifunc = alloc_node<BuiltinFuncNode>(); @@ -1542,7 +1542,7 @@ Expression::ENode *Expression::_parse_expression() { //parse an expression ENode *subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; bifunc->arguments.push_back(subexpr); @@ -1584,7 +1584,7 @@ Expression::ENode *Expression::_parse_expression() { default: { _set_error("Expected expression."); - return NULL; + return nullptr; } break; } @@ -1594,7 +1594,7 @@ Expression::ENode *Expression::_parse_expression() { int cofs2 = str_ofs; _get_token(tk); if (error_set) - return NULL; + return nullptr; bool done = false; @@ -1607,14 +1607,14 @@ Expression::ENode *Expression::_parse_expression() { ENode *what = _parse_expression(); if (!what) - return NULL; + return nullptr; index->index = what; _get_token(tk); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']' at end of index."); - return NULL; + return nullptr; } expr = index; @@ -1624,7 +1624,7 @@ Expression::ENode *Expression::_parse_expression() { _get_token(tk); if (tk.type != TK_IDENTIFIER) { _set_error("Expected identifier after '.'"); - return NULL; + return nullptr; } StringName identifier = tk.value; @@ -1648,7 +1648,7 @@ Expression::ENode *Expression::_parse_expression() { //parse an expression ENode *subexpr = _parse_expression(); if (!subexpr) - return NULL; + return nullptr; func_call->arguments.push_back(subexpr); @@ -1698,7 +1698,7 @@ Expression::ENode *Expression::_parse_expression() { int cofs = str_ofs; _get_token(tk); if (error_set) - return NULL; + return nullptr; Variant::Operator op = Variant::OP_MAX; @@ -1805,7 +1805,7 @@ Expression::ENode *Expression::_parse_expression() { default: { _set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op)); - return NULL; + return nullptr; } } @@ -1822,7 +1822,7 @@ Expression::ENode *Expression::_parse_expression() { if (next_op == -1) { _set_error("Yet another parser bug...."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } // OK! create operator.. @@ -1835,7 +1835,7 @@ Expression::ENode *Expression::_parse_expression() { if (expr_pos == expression.size()) { //can happen.. _set_error("Unexpected end of expression..."); - return NULL; + return nullptr; } } @@ -1845,7 +1845,7 @@ Expression::ENode *Expression::_parse_expression() { OperatorNode *op = alloc_node<OperatorNode>(); op->op = expression[i].op; op->nodes[0] = expression[i + 1].node; - op->nodes[1] = NULL; + op->nodes[1] = nullptr; expression.write[i].is_op = false; expression.write[i].node = op; expression.remove(i + 1); @@ -1855,7 +1855,7 @@ Expression::ENode *Expression::_parse_expression() { if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } OperatorNode *op = alloc_node<OperatorNode>(); @@ -1864,7 +1864,7 @@ Expression::ENode *Expression::_parse_expression() { if (expression[next_op - 1].is_op) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (expression[next_op + 1].is_op) { @@ -1874,7 +1874,7 @@ Expression::ENode *Expression::_parse_expression() { // due to how precedence works, unaries will always disappear first _set_error("Unexpected two consecutive operators."); - return NULL; + return nullptr; } op->nodes[0] = expression[next_op - 1].node; //expression goes as left @@ -1897,8 +1897,8 @@ bool Expression::_compile_expression() { if (nodes) { memdelete(nodes); - nodes = NULL; - root = NULL; + nodes = nullptr; + root = nullptr; } error_str = String(); @@ -1908,11 +1908,11 @@ bool Expression::_compile_expression() { root = _parse_expression(); if (error_set) { - root = NULL; + root = nullptr; if (nodes) { memdelete(nodes); } - nodes = NULL; + nodes = nullptr; return true; } @@ -2151,8 +2151,8 @@ Error Expression::parse(const String &p_expression, const Vector<String> &p_inpu if (nodes) { memdelete(nodes); - nodes = NULL; - root = NULL; + nodes = nullptr; + root = nullptr; } error_str = String(); @@ -2164,11 +2164,11 @@ Error Expression::parse(const String &p_expression, const Vector<String> &p_inpu root = _parse_expression(); if (error_set) { - root = NULL; + root = nullptr; if (nodes) { memdelete(nodes); } - nodes = NULL; + nodes = nullptr; return ERR_INVALID_PARAMETER; } @@ -2212,9 +2212,11 @@ Expression::Expression() : output_type(Variant::NIL), sequenced(false), error_set(true), - root(NULL), - nodes(NULL), + root(nullptr), + nodes(nullptr), execution_error(false) { + str_ofs = 0; + expression_dirty = false; } Expression::~Expression() { diff --git a/core/math/expression.h b/core/math/expression.h index bbf946bb0a..78de225ebf 100644 --- a/core/math/expression.h +++ b/core/math/expression.h @@ -219,7 +219,7 @@ private: Type type; - ENode() { next = NULL; } + ENode() { next = nullptr; } virtual ~ENode() { if (next) { memdelete(next); @@ -352,7 +352,7 @@ protected: public: Error parse(const String &p_expression, const Vector<String> &p_input_names = Vector<String>()); - Variant execute(Array p_inputs, Object *p_base = NULL, bool p_show_error = true); + Variant execute(Array p_inputs, Object *p_base = nullptr, bool p_show_error = true); bool has_execute_failed() const; String get_error_text() const; diff --git a/core/math/geometry.h b/core/math/geometry.h index becbcdbf0f..e47d18b056 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -891,7 +891,7 @@ public: for (int i = 0; i < c; i++) { const Vector2 &v1 = p[i]; const Vector2 &v2 = p[(i + 1) % c]; - if (segment_intersects_segment_2d(v1, v2, p_point, further_away, NULL)) { + if (segment_intersects_segment_2d(v1, v2, p_point, further_away, nullptr)) { intersections++; } } @@ -902,7 +902,7 @@ public: static Vector<Vector<Face3>> separate_objects(Vector<Face3> p_array); // Create a "wrap" that encloses the given geometry. - static Vector<Face3> wrap_geometry(Vector<Face3> p_array, real_t *p_error = NULL); + static Vector<Face3> wrap_geometry(Vector<Face3> p_array, real_t *p_error = nullptr); struct MeshData { diff --git a/core/math/octree.h b/core/math/octree.h index b47c052b68..5225fbecb4 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -119,9 +119,9 @@ private: children_count = 0; parent_index = -1; last_pass = 0; - parent = NULL; + parent = nullptr; for (int i = 0; i < 8; i++) - children[i] = NULL; + children[i] = nullptr; } ~Octant() { @@ -171,7 +171,7 @@ private: octree = 0; pairable_mask = 0; pairable_type = 0; - common_parent = NULL; + common_parent = nullptr; } }; @@ -308,19 +308,19 @@ private: while (root && root->children_count < 2 && !root->elements.size() && !(use_pairs && root->pairable_elements.size())) { - Octant *new_root = NULL; + Octant *new_root = nullptr; if (root->children_count == 1) { for (int i = 0; i < 8; i++) { if (root->children[i]) { new_root = root->children[i]; - root->children[i] = NULL; + root->children[i] = nullptr; break; } } ERR_FAIL_COND(!new_root); - new_root->parent = NULL; + new_root->parent = nullptr; new_root->parent_index = -1; } @@ -332,7 +332,7 @@ private: void _insert_element(Element *p_element, Octant *p_octant); void _ensure_valid_root(const AABB &p_aabb); - bool _remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit = NULL); + bool _remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit = nullptr); void _remove_element(Element *p_element); void _pair_element(Element *p_element, Octant *p_octant); void _unpair_element(Element *p_element, Octant *p_octant); @@ -377,10 +377,10 @@ public: int get_subindex(OctreeElementID p_id) const; int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF); - int cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); - int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); + int cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = nullptr, uint32_t p_mask = 0xFFFFFFFF); + int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = nullptr, uint32_t p_mask = 0xFFFFFFFF); - int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); + int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = nullptr, uint32_t p_mask = 0xFFFFFFFF); void set_pair_callback(PairCallback p_callback, void *p_userdata); void set_unpair_callback(UnpairCallback p_callback, void *p_userdata); @@ -396,7 +396,7 @@ public: template <class T, bool use_pairs, class AL> T *Octree<T, use_pairs, AL>::get(OctreeElementID p_id) const { const typename ElementMap::Element *E = element_map.find(p_id); - ERR_FAIL_COND_V(!E, NULL); + ERR_FAIL_COND_V(!E, nullptr); return E->get().userdata; } @@ -442,7 +442,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct p_element->octant_owners.push_back(owner); - if (p_element->common_parent == NULL) { + if (p_element->common_parent == nullptr) { p_element->common_parent = p_octant; p_element->container_aabb = p_octant->aabb; } else { @@ -463,7 +463,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct } else { /* not big enough, send it to subitems */ int splits = 0; - bool candidate = p_element->common_parent == NULL; + bool candidate = p_element->common_parent == nullptr; for (int i = 0; i < 8; i++) { @@ -552,7 +552,7 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) { root = memnew_allocator(Octant, AL); - root->parent = NULL; + root->parent = nullptr; root->parent_index = -1; root->aabb = base; @@ -634,11 +634,11 @@ bool Octree<T, use_pairs, AL>::_remove_element_from_octant(Element *p_element, O if (p_octant == root) { // won't have a parent, just erase - root = NULL; + root = nullptr; } else { ERR_FAIL_INDEX_V(p_octant->parent_index, 8, octant_removed); - parent->children[p_octant->parent_index] = NULL; + parent->children[p_octant->parent_index] = nullptr; parent->children_count--; } @@ -852,12 +852,12 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) { if (old_has_surf) { _remove_element(&e); // removing - e.common_parent = NULL; + e.common_parent = nullptr; e.aabb = AABB(); _optimize(); } else { _ensure_valid_root(p_aabb); // inserting - e.common_parent = NULL; + e.common_parent = nullptr; e.aabb = p_aabb; _insert_element(&e, root); if (use_pairs) @@ -884,7 +884,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) { combined.merge_with(p_aabb); _ensure_valid_root(combined); - ERR_FAIL_COND(e.octant_owners.front() == NULL); + ERR_FAIL_COND(e.octant_owners.front() == nullptr); /* FIND COMMON PARENT */ @@ -902,7 +902,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) { //prepare for reinsert e.octant_owners.clear(); - e.common_parent = NULL; + e.common_parent = nullptr; e.aabb = p_aabb; _insert_element(&e, common_parent); // reinsert from this point @@ -971,7 +971,7 @@ void Octree<T, use_pairs, AL>::set_pairable(OctreeElementID p_id, bool p_pairabl e.pairable = p_pairable; e.pairable_type = p_pairable_type; e.pairable_mask = p_pairable_mask; - e.common_parent = NULL; + e.common_parent = nullptr; if (!e.aabb.has_no_surface()) { _ensure_valid_root(e.aabb); @@ -1364,15 +1364,15 @@ Octree<T, use_pairs, AL>::Octree(real_t p_unit_size) { last_element_id = 1; pass = 1; unit_size = p_unit_size; - root = NULL; + root = nullptr; octant_count = 0; pair_count = 0; - pair_callback = NULL; - unpair_callback = NULL; - pair_callback_userdata = NULL; - unpair_callback_userdata = NULL; + pair_callback = nullptr; + unpair_callback = nullptr; + pair_callback_userdata = nullptr; + unpair_callback_userdata = nullptr; } #endif // OCTREE_H diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 63dd18091f..7fbb26c377 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -399,7 +399,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me ERR_CONTINUE(!F); List<Geometry::MeshData::Face>::Element *O = F->get().left == E ? F->get().right : F->get().left; ERR_CONTINUE(O == E); - ERR_CONTINUE(O == NULL); + ERR_CONTINUE(O == nullptr); if (O->get().plane.is_equal_approx(f.plane)) { //merge and delete edge and contiguous face, while repointing edges (uuugh!) @@ -440,10 +440,10 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me // remove all edge connections to this face for (Map<Edge, RetFaceConnect>::Element *G = ret_edges.front(); G; G = G->next()) { if (G->get().left == O) - G->get().left = NULL; + G->get().left = nullptr; if (G->get().right == O) - G->get().right = NULL; + G->get().right = nullptr; } ret_edges.erase(F); //remove the edge diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index aea9ffad8b..173f919a73 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -77,15 +77,15 @@ private: struct FaceConnect { List<Face>::Element *left, *right; FaceConnect() { - left = NULL; - right = NULL; + left = nullptr; + right = nullptr; } }; struct RetFaceConnect { List<Geometry::MeshData::Face>::Element *left, *right; RetFaceConnect() { - left = NULL; - right = NULL; + left = nullptr; + right = nullptr; } }; diff --git a/core/math/rect2.h b/core/math/rect2.h index 3b9660e2f0..30dbfdbbe5 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -105,7 +105,7 @@ struct Rect2 { bool intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const; - bool intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos = NULL, Point2 *r_normal = NULL) const; + bool intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos = nullptr, Point2 *r_normal = nullptr) const; inline bool encloses(const Rect2 &p_rect) const { diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 26f5b23416..652c424492 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -34,7 +34,7 @@ #include "core/project_settings.h" #include "core/script_language.h" -MessageQueue *MessageQueue::singleton = NULL; +MessageQueue *MessageQueue::singleton = nullptr; MessageQueue *MessageQueue::get_singleton() { @@ -174,7 +174,7 @@ void MessageQueue::statistics() { Object *target = message->callable.get_object(); - if (target != NULL) { + if (target != nullptr) { switch (message->type & FLAG_MASK) { @@ -240,7 +240,7 @@ int MessageQueue::get_max_buffer_usage() const { void MessageQueue::_call_function(const Callable &p_callable, const Variant *p_args, int p_argcount, bool p_show_error) { - const Variant **argptrs = NULL; + const Variant **argptrs = nullptr; if (p_argcount) { argptrs = (const Variant **)alloca(sizeof(Variant *) * p_argcount); for (int i = 0; i < p_argcount; i++) { @@ -291,7 +291,7 @@ void MessageQueue::flush() { Object *target = message->callable.get_object(); - if (target != NULL) { + if (target != nullptr) { switch (message->type & FLAG_MASK) { case TYPE_CALL: { @@ -343,7 +343,7 @@ bool MessageQueue::is_flushing() const { MessageQueue::MessageQueue() { - ERR_FAIL_COND_MSG(singleton != NULL, "A MessageQueue singleton already exists."); + ERR_FAIL_COND_MSG(singleton != nullptr, "A MessageQueue singleton already exists."); singleton = this; flushing = false; @@ -375,6 +375,6 @@ MessageQueue::~MessageQueue() { read_pos += sizeof(Variant) * message->args; } - singleton = NULL; + singleton = nullptr; memdelete_arr(buffer); } diff --git a/core/method_bind.cpp b/core/method_bind.cpp index 2c9d0cee2f..c513de9ca0 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -108,7 +108,7 @@ MethodBind::MethodBind() { argument_count = 0; default_argument_count = 0; #ifdef DEBUG_METHODS_ENABLED - argument_types = NULL; + argument_types = nullptr; #endif _const = false; _returns = false; diff --git a/core/method_bind.h b/core/method_bind.h index a1ab4e58fc..588b472b62 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -382,7 +382,7 @@ public: virtual bool is_vararg() const { return true; } MethodBindVarArg() { - call_method = NULL; + call_method = nullptr; _set_returns(true); } }; diff --git a/core/node_path.cpp b/core/node_path.cpp index e844cd7c27..83233622a0 100644 --- a/core/node_path.cpp +++ b/core/node_path.cpp @@ -99,7 +99,7 @@ void NodePath::unref() { memdelete(data); } - data = NULL; + data = nullptr; } bool NodePath::operator==(const NodePath &p_path) const { @@ -189,7 +189,7 @@ NodePath::operator String() const { NodePath::NodePath(const NodePath &p_path) { - data = NULL; + data = nullptr; if (p_path.data && p_path.data->refcount.ref()) { @@ -287,7 +287,7 @@ NodePath NodePath::get_as_property_path() const { NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) { - data = NULL; + data = nullptr; if (p_path.size() == 0) return; @@ -302,7 +302,7 @@ NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) { NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p_subpath, bool p_absolute) { - data = NULL; + data = nullptr; if (p_path.size() == 0 && p_subpath.size() == 0) return; @@ -349,7 +349,7 @@ NodePath NodePath::simplified() const { NodePath::NodePath(const String &p_path) { - data = NULL; + data = nullptr; if (p_path.length() == 0) return; @@ -442,7 +442,7 @@ bool NodePath::is_empty() const { } NodePath::NodePath() { - data = NULL; + data = nullptr; } NodePath::~NodePath() { diff --git a/core/oa_hash_map.h b/core/oa_hash_map.h index 447b0db0eb..71e3ba9068 100644 --- a/core/oa_hash_map.h +++ b/core/oa_hash_map.h @@ -224,7 +224,7 @@ public: /** * returns true if the value was found, false otherwise. * - * if r_data is not NULL then the value will be written to the object + * if r_data is not nullptr then the value will be written to the object * it points to. */ bool lookup(const TKey &p_key, TValue &r_data) const { @@ -243,7 +243,7 @@ public: /** * returns true if the value was found, false otherwise. * - * if r_data is not NULL then the value will be written to the object + * if r_data is not nullptr then the value will be written to the object * it points to. */ TValue *lookup_ptr(const TKey &p_key) const { @@ -253,7 +253,7 @@ public: if (exists) { return &values[pos]; } - return NULL; + return nullptr; } _FORCE_INLINE_ bool has(const TKey &p_key) const { @@ -325,8 +325,8 @@ public: Iterator it; it.valid = false; it.pos = p_iter.pos; - it.key = NULL; - it.value = NULL; + it.key = nullptr; + it.value = nullptr; for (uint32_t i = it.pos; i < capacity; i++) { it.pos = i + 1; diff --git a/core/object.cpp b/core/object.cpp index 188c0ee5c2..b0e6f2bdae 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -368,7 +368,7 @@ bool Object::_predelete() { _predelete_ok = 1; notification(NOTIFICATION_PREDELETE, true); if (_predelete_ok) { - _class_ptr = NULL; //must restore so destructors can access class ptr correctly + _class_ptr = nullptr; //must restore so destructors can access class ptr correctly } return _predelete_ok; } @@ -781,7 +781,7 @@ bool Object::has_method(const StringName &p_method) const { MethodBind *method = ClassDB::get_method(get_class_name(), p_method); - return method != NULL; + return method != nullptr; } Variant Object::getvar(const Variant &p_key, bool *r_valid) const { @@ -797,7 +797,7 @@ void Object::setvar(const Variant &p_key, const Variant &p_value, bool *r_valid) } Variant Object::callv(const StringName &p_method, const Array &p_args) { - const Variant **argptrs = NULL; + const Variant **argptrs = nullptr; if (p_args.size() > 0) { argptrs = (const Variant **)alloca(sizeof(Variant *) * p_args.size()); @@ -955,7 +955,7 @@ void Object::set_script_and_instance(const Variant &p_script, ScriptInstance *p_ //this function is not meant to be used in any of these ways ERR_FAIL_COND(p_script.is_null()); ERR_FAIL_COND(!p_instance); - ERR_FAIL_COND(script_instance != NULL || !script.is_null()); + ERR_FAIL_COND(script_instance != nullptr || !script.is_null()); script = p_script; script_instance = p_instance; @@ -968,7 +968,7 @@ void Object::set_script(const Variant &p_script) { if (script_instance) { memdelete(script_instance); - script_instance = NULL; + script_instance = nullptr; } script = p_script; @@ -1119,7 +1119,7 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Callable::C StringName signal = *p_args[0]; - const Variant **args = NULL; + const Variant **args = nullptr; int argc = p_argcount - 1; if (argc) { @@ -1354,7 +1354,7 @@ void Object::get_signal_list(List<MethodInfo> *p_signals) const { ClassDB::get_signal_list(get_class_name(), p_signals); //find maybe usersignals? - const StringName *S = NULL; + const StringName *S = nullptr; while ((S = signal_map.next(S))) { @@ -1367,7 +1367,7 @@ void Object::get_signal_list(List<MethodInfo> *p_signals) const { void Object::get_all_signal_connections(List<Connection> *p_connections) const { - const StringName *S = NULL; + const StringName *S = nullptr; while ((S = signal_map.next(S))) { @@ -1393,7 +1393,7 @@ void Object::get_signal_connection_list(const StringName &p_signal, List<Connect int Object::get_persistent_signal_connection_count() const { int count = 0; - const StringName *S = NULL; + const StringName *S = nullptr; while ((S = signal_map.next(S))) { @@ -1505,7 +1505,7 @@ bool Object::is_connected(const StringName &p_signal, const Callable &p_callable return s->slot_map.has(target); //const Map<Signal::Target,Signal::Slot>::Element *E = s->slot_map.find(target); - //return (E!=NULL); + //return (E!=nullptr ); } void Object::disconnect_compat(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method) { @@ -1840,7 +1840,7 @@ Variant::Type Object::get_static_property_type_indexed(const Vector<StringName> } Callable::CallError ce; - Variant check = Variant::construct(t, NULL, 0, ce); + Variant check = Variant::construct(t, nullptr, 0, ce); for (int i = 1; i < p_path.size(); i++) { if (check.get_type() == Variant::OBJECT || check.get_type() == Variant::DICTIONARY || check.get_type() == Variant::ARRAY) { @@ -1889,7 +1889,7 @@ uint32_t Object::get_edited_version() const { void *Object::get_script_instance_binding(int p_script_language_index) { #ifdef DEBUG_ENABLED - ERR_FAIL_INDEX_V(p_script_language_index, MAX_SCRIPT_INSTANCE_BINDINGS, NULL); + ERR_FAIL_INDEX_V(p_script_language_index, MAX_SCRIPT_INSTANCE_BINDINGS, nullptr); #endif //it's up to the script language to make this thread safe, if the function is called twice due to threads being out of syncro @@ -1910,19 +1910,19 @@ void *Object::get_script_instance_binding(int p_script_language_index) { bool Object::has_script_instance_binding(int p_script_language_index) { - return _script_instance_bindings[p_script_language_index] != NULL; + return _script_instance_bindings[p_script_language_index] != nullptr; } void Object::set_script_instance_binding(int p_script_language_index, void *p_data) { #ifdef DEBUG_ENABLED - CRASH_COND(_script_instance_bindings[p_script_language_index] != NULL); + CRASH_COND(_script_instance_bindings[p_script_language_index] != nullptr); #endif _script_instance_bindings[p_script_language_index] = p_data; } void Object::_construct_object(bool p_reference) { type_is_reference = p_reference; - _class_ptr = NULL; + _class_ptr = nullptr; _block_signals = false; _predelete_ok = 0; _instance_id = ObjectDB::add_instance(this); @@ -1931,7 +1931,7 @@ void Object::_construct_object(bool p_reference) { _emitting = false; instance_binding_count = 0; memset(_script_instance_bindings, 0, sizeof(void *) * MAX_SCRIPT_INSTANCE_BINDINGS); - script_instance = NULL; + script_instance = nullptr; #ifdef TOOLS_ENABLED _edited = false; @@ -1955,16 +1955,16 @@ Object::~Object() { if (script_instance) memdelete(script_instance); - script_instance = NULL; + script_instance = nullptr; - const StringName *S = NULL; + const StringName *S = nullptr; if (_emitting) { //@todo this may need to actually reach the debugger prioritarily somehow because it may crash before ERR_PRINT("Object " + to_string() + " was freed or unreferenced while a signal is being emitted from it. Try connecting to the signal using 'CONNECT_DEFERRED' flag, or use queue_free() to free the object (if this object is a Node) to avoid this error and potential crashes."); } - while ((S = signal_map.next(NULL))) { + while ((S = signal_map.next(nullptr))) { SignalData *s = &signal_map[*S]; diff --git a/core/object.h b/core/object.h index 0826686fb3..40032de271 100644 --- a/core/object.h +++ b/core/object.h @@ -242,7 +242,7 @@ struct MethodInfo { //if ( is_type(T::get_class_static()) ) //return static_cast<T*>(this); ////else -//return NULL; +//return nullptr; /* the following is an incomprehensible blob of hacks and workarounds to compensate for many of the fallencies in C++. As a plus, this macro pretty much alone defines the object model. @@ -591,11 +591,11 @@ public: return dynamic_cast<T *>(p_object); #else if (!p_object) - return NULL; + return nullptr; if (p_object->is_class_ptr(T::get_class_ptr_static())) return static_cast<T *>(p_object); else - return NULL; + return nullptr; #endif } @@ -605,11 +605,11 @@ public: return dynamic_cast<const T *>(p_object); #else if (!p_object) - return NULL; + return nullptr; if (p_object->is_class_ptr(T::get_class_ptr_static())) return static_cast<const T *>(p_object); else - return NULL; + return nullptr; #endif } @@ -644,10 +644,10 @@ public: //void set(const String& p_name, const Variant& p_value); //Variant get(const String& p_name) const; - void set(const StringName &p_name, const Variant &p_value, bool *r_valid = NULL); - Variant get(const StringName &p_name, bool *r_valid = NULL) const; - void set_indexed(const Vector<StringName> &p_names, const Variant &p_value, bool *r_valid = NULL); - Variant get_indexed(const Vector<StringName> &p_names, bool *r_valid = NULL) const; + void set(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr); + Variant get(const StringName &p_name, bool *r_valid = nullptr) const; + void set_indexed(const Vector<StringName> &p_names, const Variant &p_value, bool *r_valid = nullptr); + Variant get_indexed(const Vector<StringName> &p_names, bool *r_valid = nullptr) const; void get_property_list(List<PropertyInfo> *p_list, bool p_reversed = false) const; @@ -664,8 +664,8 @@ public: String to_string(); //used mainly by script, get and set all INCLUDING string - virtual Variant getvar(const Variant &p_key, bool *r_valid = NULL) const; - virtual void setvar(const Variant &p_key, const Variant &p_value, bool *r_valid = NULL); + virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const; + virtual void setvar(const Variant &p_key, const Variant &p_value, bool *r_valid = nullptr); /* SCRIPT */ @@ -715,8 +715,8 @@ public: void set_block_signals(bool p_block); bool is_blocking_signals() const; - Variant::Type get_static_property_type(const StringName &p_property, bool *r_valid = NULL) const; - Variant::Type get_static_property_type_indexed(const Vector<StringName> &p_path, bool *r_valid = NULL) const; + Variant::Type get_static_property_type(const StringName &p_property, bool *r_valid = nullptr) const; + Variant::Type get_static_property_type_indexed(const Vector<StringName> &p_path, bool *r_valid = nullptr) const; virtual void get_translatable_strings(List<String> *p_strings) const; diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h index 055e3e607e..05debd529f 100644 --- a/core/ordered_hash_map.h +++ b/core/ordered_hash_map.h @@ -70,9 +70,9 @@ public: public: _FORCE_INLINE_ Element() : - list_element(NULL), - prev_element(NULL), - next_element(NULL) { + list_element(nullptr), + prev_element(nullptr), + next_element(nullptr) { } Element next() const { @@ -104,7 +104,7 @@ public: } operator bool() const { - return (list_element != NULL); + return (list_element != nullptr); } const K &key() const { @@ -144,7 +144,7 @@ public: public: _FORCE_INLINE_ ConstElement() : - list_element(NULL) { + list_element(nullptr) { } ConstElement(const ConstElement &other) : @@ -157,11 +157,11 @@ public: } ConstElement next() const { - return ConstElement(list_element ? list_element->next() : NULL); + return ConstElement(list_element ? list_element->next() : nullptr); } ConstElement prev() const { - return ConstElement(list_element ? list_element->prev() : NULL); + return ConstElement(list_element ? list_element->prev() : nullptr); } _FORCE_INLINE_ bool operator==(const ConstElement &p_other) const { @@ -172,7 +172,7 @@ public: } operator bool() const { - return (list_element != NULL); + return (list_element != nullptr); } const K &key() const { @@ -196,7 +196,7 @@ public: if (list_element) { return ConstElement(*list_element); } - return ConstElement(NULL); + return ConstElement(nullptr); } Element find(const K &p_key) { @@ -204,7 +204,7 @@ public: if (list_element) { return Element(*list_element); } - return Element(NULL); + return Element(nullptr); } Element insert(const K &p_key, const V &p_value) { @@ -213,7 +213,7 @@ public: (*list_element)->get().second = p_value; return Element(*list_element); } - typename InternalList::Element *new_element = list.push_back(Pair<const K *, V>(NULL, p_value)); + typename InternalList::Element *new_element = list.push_back(Pair<const K *, V>(nullptr, p_value)); typename InternalMap::Element *e = map.set(p_key, new_element); new_element->get().first = &e->key(); @@ -223,7 +223,7 @@ public: void erase(Element &p_element) { map.erase(p_element.key()); list.erase(p_element.list_element); - p_element.list_element = NULL; + p_element.list_element = nullptr; } bool erase(const K &p_key) { diff --git a/core/os/SCsub b/core/os/SCsub index 1c5f954470..19a6549225 100644 --- a/core/os/SCsub +++ b/core/os/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.core_sources, "*.cpp") diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 642c86be2f..94c8cd5d73 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -226,11 +226,11 @@ String DirAccess::fix_path(String p_path) const { return p_path; } -DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { 0, 0, 0 }; +DirAccess::CreateFunc DirAccess::create_func[ACCESS_MAX] = { nullptr, nullptr, nullptr }; DirAccess *DirAccess::create_for_path(const String &p_path) { - DirAccess *da = NULL; + DirAccess *da = nullptr; if (p_path.begins_with("res://")) { da = create(ACCESS_RESOURCES); @@ -249,13 +249,13 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) { DirAccess *da = create_for_path(p_path); - ERR_FAIL_COND_V_MSG(!da, NULL, "Cannot create DirAccess for path '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(!da, nullptr, "Cannot create DirAccess for path '" + p_path + "'."); Error err = da->change_dir(p_path); if (r_error) *r_error = err; if (err != OK) { memdelete(da); - return NULL; + return nullptr; } return da; @@ -263,7 +263,7 @@ DirAccess *DirAccess::open(const String &p_path, Error *r_error) { DirAccess *DirAccess::create(AccessType p_access) { - DirAccess *da = create_func[p_access] ? create_func[p_access]() : NULL; + DirAccess *da = create_func[p_access] ? create_func[p_access]() : nullptr; if (da) { da->_access_type = p_access; } diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 059f7aad2f..60eb553968 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -128,7 +128,7 @@ public: create_func[p_access] = _create_builtin<T>; } - static DirAccess *open(const String &p_path, Error *r_error = NULL); + static DirAccess *open(const String &p_path, Error *r_error = nullptr); DirAccess(); virtual ~DirAccess(); @@ -141,7 +141,7 @@ struct DirAccessRef { return f; } - operator bool() const { return f != NULL; } + operator bool() const { return f != nullptr; } DirAccess *f; DirAccessRef(DirAccess *fa) { f = fa; } ~DirAccessRef() { diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 30cfaa7617..3922f031b7 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -36,15 +36,15 @@ #include "core/os/os.h" #include "core/project_settings.h" -FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX] = { 0, 0 }; +FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX] = { nullptr, nullptr }; -FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = NULL; +FileAccess::FileCloseFailNotify FileAccess::close_fail_notify = nullptr; bool FileAccess::backup_save = false; FileAccess *FileAccess::create(AccessType p_access) { - ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, 0); + ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, nullptr); FileAccess *ret = create_func[p_access](); ret->_set_access_type(p_access); @@ -70,7 +70,7 @@ void FileAccess::_set_access_type(AccessType p_access) { FileAccess *FileAccess::create_for_path(const String &p_path) { - FileAccess *ret = NULL; + FileAccess *ret = nullptr; if (p_path.begins_with("res://")) { ret = create(ACCESS_RESOURCES); @@ -95,7 +95,7 @@ FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_er //try packed data first - FileAccess *ret = NULL; + FileAccess *ret = nullptr; if (!(p_mode_flags & WRITE) && PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled()) { ret = PackedData::get_singleton()->try_open_path(p_path); if (ret) { @@ -113,7 +113,7 @@ FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_er if (err != OK) { memdelete(ret); - ret = NULL; + ret = nullptr; } return ret; diff --git a/core/os/file_access.h b/core/os/file_access.h index 4a82637ecc..010cc74a87 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -153,7 +153,7 @@ public: static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. static FileAccess *create_for_path(const String &p_path); - static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = NULL); /// Create a file access (for the current platform) this is the only portable way of accessing files. + static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files. static CreateFunc get_create_func(AccessType p_access); static bool exists(const String &p_name); ///< return true if a file exists static uint64_t get_modified_time(const String &p_file); @@ -167,8 +167,8 @@ public: static String get_sha256(const String &p_file); static String get_multiple_md5(const Vector<String> &p_file); - static Vector<uint8_t> get_file_as_array(const String &p_path, Error *r_error = NULL); - static String get_file_as_string(const String &p_path, Error *r_error = NULL); + static Vector<uint8_t> get_file_as_array(const String &p_path, Error *r_error = nullptr); + static String get_file_as_string(const String &p_path, Error *r_error = nullptr); template <class T> static void make_default(AccessType p_access) { @@ -187,7 +187,7 @@ struct FileAccessRef { return f; } - operator bool() const { return f != NULL; } + operator bool() const { return f != nullptr; } FileAccess *f; operator FileAccess *() { return f; } FileAccessRef(FileAccess *fa) { f = fa; } diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 7141423c77..c65d3fefc2 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -288,7 +288,7 @@ static const _KeyCodeText _keycodes[] = { {KEY_DIVISION ,"Division"}, {KEY_YDIAERESIS ,"Ydiaeresis"}, - {0 ,0} + {0 ,nullptr} /* clang-format on */ }; diff --git a/core/os/memory.cpp b/core/os/memory.cpp index 39d3fce910..d921c10ad4 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -81,7 +81,7 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { void *mem = malloc(p_bytes + (prepad ? PAD_ALIGN : 0)); - ERR_FAIL_COND_V(!mem, NULL); + ERR_FAIL_COND_V(!mem, nullptr); atomic_increment(&alloc_count); @@ -103,7 +103,7 @@ void *Memory::alloc_static(size_t p_bytes, bool p_pad_align) { void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { - if (p_memory == NULL) { + if (p_memory == nullptr) { return alloc_static(p_bytes, p_pad_align); } @@ -130,12 +130,12 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { if (p_bytes == 0) { free(mem); - return NULL; + return nullptr; } else { *s = p_bytes; mem = (uint8_t *)realloc(mem, p_bytes + PAD_ALIGN); - ERR_FAIL_COND_V(!mem, NULL); + ERR_FAIL_COND_V(!mem, nullptr); s = (uint64_t *)mem; @@ -147,7 +147,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { mem = (uint8_t *)realloc(mem, p_bytes); - ERR_FAIL_COND_V(mem == NULL && p_bytes > 0, NULL); + ERR_FAIL_COND_V(mem == nullptr && p_bytes > 0, nullptr); return mem; } @@ -155,7 +155,7 @@ void *Memory::realloc_static(void *p_memory, size_t p_bytes, bool p_pad_align) { void Memory::free_static(void *p_ptr, bool p_pad_align) { - ERR_FAIL_COND(p_ptr == NULL); + ERR_FAIL_COND(p_ptr == nullptr); uint8_t *mem = (uint8_t *)p_ptr; diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp index c23ade3088..985f6f38e5 100644 --- a/core/os/midi_driver.cpp +++ b/core/os/midi_driver.cpp @@ -34,7 +34,7 @@ #include "core/os/os.h" uint8_t MIDIDriver::last_received_message = 0x00; -MIDIDriver *MIDIDriver::singleton = NULL; +MIDIDriver *MIDIDriver::singleton = nullptr; MIDIDriver *MIDIDriver::get_singleton() { return singleton; diff --git a/core/os/os.cpp b/core/os/os.cpp index 66ab3bbd8c..0636810e4b 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -40,7 +40,7 @@ #include <stdarg.h> -OS *OS::singleton = NULL; +OS *OS::singleton = nullptr; OS *OS::get_singleton() { @@ -184,7 +184,7 @@ void OS::dump_memory_to_file(const char *p_file) { //Memory::dump_static_mem_to_file(p_file); } -static FileAccess *_OSPRF = NULL; +static FileAccess *_OSPRF = nullptr; static void _OS_printres(Object *p_obj) { @@ -207,7 +207,7 @@ void OS::print_all_resources(String p_to_file) { Error err; _OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err); if (err != OK) { - _OSPRF = NULL; + _OSPRF = nullptr; ERR_FAIL_MSG("Can't print all resources to file: " + String(p_to_file) + "."); } } @@ -218,13 +218,13 @@ void OS::print_all_resources(String p_to_file) { if (_OSPRF) memdelete(_OSPRF); - _OSPRF = NULL; + _OSPRF = nullptr; } } void OS::print_resources_in_use(bool p_short) { - ResourceCache::dump(NULL, p_short); + ResourceCache::dump(nullptr, p_short); } void OS::dump_resources_to_file(const char *p_file) { @@ -523,9 +523,9 @@ OS::OS() { _allow_layered = false; _stack_bottom = (void *)(&stack_bottom); - _logger = NULL; + _logger = nullptr; - has_server_feature_callback = NULL; + has_server_feature_callback = nullptr; Vector<Logger *> loggers; loggers.push_back(memnew(StdLogger)); @@ -534,5 +534,5 @@ OS::OS() { OS::~OS() { memdelete(_logger); - singleton = NULL; + singleton = nullptr; } diff --git a/core/os/os.h b/core/os/os.h index a31b1c1f4b..714a10bf76 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -130,7 +130,7 @@ public: virtual int get_low_processor_usage_mode_sleep_usec() const; virtual String get_executable_path() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL) = 0; + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr) = 0; virtual Error kill(const ProcessID &p_pid) = 0; virtual int get_process_id() const; virtual void vibrate_handheld(int p_duration_ms = 500); diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp index 75683962af..1dd2c3bccb 100644 --- a/core/os/rw_lock.cpp +++ b/core/os/rw_lock.cpp @@ -34,11 +34,11 @@ #include <stddef.h> -RWLock *(*RWLock::create_func)() = 0; +RWLock *(*RWLock::create_func)() = nullptr; RWLock *RWLock::create() { - ERR_FAIL_COND_V(!create_func, 0); + ERR_FAIL_COND_V(!create_func, nullptr); return create_func(); } diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 7f6148057d..294b52f00c 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -30,10 +30,10 @@ #include "thread.h" -Thread *(*Thread::create_func)(ThreadCreateCallback, void *, const Settings &) = NULL; -Thread::ID (*Thread::get_thread_id_func)() = NULL; -void (*Thread::wait_to_finish_func)(Thread *) = NULL; -Error (*Thread::set_name_func)(const String &) = NULL; +Thread *(*Thread::create_func)(ThreadCreateCallback, void *, const Settings &) = nullptr; +Thread::ID (*Thread::get_thread_id_func)() = nullptr; +void (*Thread::wait_to_finish_func)(Thread *) = nullptr; +Error (*Thread::set_name_func)(const String &) = nullptr; Thread::ID Thread::_main_thread_id = 0; @@ -50,7 +50,7 @@ Thread *Thread::create(ThreadCreateCallback p_callback, void *p_user, const Sett return create_func(p_callback, p_user, p_settings); } - return NULL; + return nullptr; } void Thread::wait_to_finish(Thread *p_thread) { diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index b82a366ef2..04deba2c14 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -114,7 +114,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b } else { Variant v; - Error rerr = decode_variant(v, p_buf + p_ofs, datalen - p_ofs, NULL, false); + Error rerr = decode_variant(v, p_buf + p_ofs, datalen - p_ofs, nullptr, false); if (rerr != OK) { @@ -254,7 +254,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd uint32_t pos = tmpdata.size(); int len; - encode_variant(p_data, NULL, len, false); + encode_variant(p_data, nullptr, len, false); tmpdata.resize(tmpdata.size() + len); encode_variant(p_data, &tmpdata.write[pos], len, false); return pos; diff --git a/core/packed_data_container.h b/core/packed_data_container.h index 852fdcd0d3..0f08a1cb7b 100644 --- a/core/packed_data_container.h +++ b/core/packed_data_container.h @@ -73,7 +73,7 @@ protected: static void _bind_methods(); public: - virtual Variant getvar(const Variant &p_key, bool *r_valid = NULL) const; + virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const; Error pack(const Variant &p_data); int size() const; @@ -98,7 +98,7 @@ public: bool _is_dictionary() const; int size() const; - virtual Variant getvar(const Variant &p_key, bool *r_valid = NULL) const; + virtual Variant getvar(const Variant &p_key, bool *r_valid = nullptr) const; PackedDataContainerRef(); }; diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index 5a83c3eeb4..b74540395c 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -250,9 +250,9 @@ PoolAllocator::Entry *PoolAllocator::get_entry(ID p_mem) { unsigned int check = p_mem & CHECK_MASK; int entry = p_mem >> CHECK_BITS; - ERR_FAIL_INDEX_V(entry, entry_max, NULL); - ERR_FAIL_COND_V(entry_array[entry].check != check, NULL); - ERR_FAIL_COND_V(entry_array[entry].len == 0, NULL); + ERR_FAIL_INDEX_V(entry, entry_max, nullptr); + ERR_FAIL_COND_V(entry_array[entry].check != check, nullptr); + ERR_FAIL_COND_V(entry_array[entry].len == 0, nullptr); return &entry_array[entry]; } @@ -261,9 +261,9 @@ const PoolAllocator::Entry *PoolAllocator::get_entry(ID p_mem) const { unsigned int check = p_mem & CHECK_MASK; int entry = p_mem >> CHECK_BITS; - ERR_FAIL_INDEX_V(entry, entry_max, NULL); - ERR_FAIL_COND_V(entry_array[entry].check != check, NULL); - ERR_FAIL_COND_V(entry_array[entry].len == 0, NULL); + ERR_FAIL_INDEX_V(entry, entry_max, nullptr); + ERR_FAIL_COND_V(entry_array[entry].check != check, nullptr); + ERR_FAIL_COND_V(entry_array[entry].len == 0, nullptr); return &entry_array[entry]; } @@ -461,7 +461,7 @@ const void *PoolAllocator::get(ID p_mem) const { if (!needs_locking) { const Entry *e = get_entry(p_mem); - ERR_FAIL_COND_V(!e, NULL); + ERR_FAIL_COND_V(!e, nullptr); return &pool[e->pos]; } @@ -471,20 +471,20 @@ const void *PoolAllocator::get(ID p_mem) const { if (!e) { mt_unlock(); - ERR_FAIL_COND_V(!e, NULL); + ERR_FAIL_COND_V(!e, nullptr); } if (e->lock == 0) { mt_unlock(); ERR_PRINT("e->lock == 0"); - return NULL; + return nullptr; } if ((int)e->pos >= pool_size) { mt_unlock(); ERR_PRINT("e->pos<0 || e->pos>=pool_size"); - return NULL; + return nullptr; } const void *ptr = &pool[e->pos]; @@ -498,7 +498,7 @@ void *PoolAllocator::get(ID p_mem) { if (!needs_locking) { Entry *e = get_entry(p_mem); - ERR_FAIL_COND_V(!e, NULL); + ERR_FAIL_COND_V(!e, nullptr); return &pool[e->pos]; } @@ -508,21 +508,21 @@ void *PoolAllocator::get(ID p_mem) { if (!e) { mt_unlock(); - ERR_FAIL_COND_V(!e, NULL); + ERR_FAIL_COND_V(!e, nullptr); } if (e->lock == 0) { //assert(0); mt_unlock(); ERR_PRINT("e->lock == 0"); - return NULL; + return nullptr; } if ((int)e->pos >= pool_size) { mt_unlock(); ERR_PRINT("e->pos<0 || e->pos>=pool_size"); - return NULL; + return nullptr; } void *ptr = &pool[e->pos]; @@ -606,7 +606,7 @@ PoolAllocator::PoolAllocator(void *p_mem, int p_size, int p_align, bool p_needs_ create_pool(p_mem, p_size, p_max_entries); needs_locking = p_needs_locking; align = p_align; - mem_ptr = NULL; + mem_ptr = nullptr; } PoolAllocator::PoolAllocator(int p_align, int p_size, bool p_needs_locking, int p_max_entries) { diff --git a/core/print_string.cpp b/core/print_string.cpp index 551b149334..8eb1d9e86a 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -34,7 +34,7 @@ #include <stdio.h> -static PrintHandlerList *print_handler_list = NULL; +static PrintHandlerList *print_handler_list = nullptr; bool _print_line_enabled = true; bool _print_error_enabled = true; @@ -50,7 +50,7 @@ void remove_print_handler(PrintHandlerList *p_handler) { _global_lock(); - PrintHandlerList *prev = NULL; + PrintHandlerList *prev = nullptr; PrintHandlerList *l = print_handler_list; while (l) { @@ -69,7 +69,7 @@ void remove_print_handler(PrintHandlerList *p_handler) { //OS::get_singleton()->print("print handler list is %p\n",print_handler_list); _global_unlock(); - ERR_FAIL_COND(l == NULL); + ERR_FAIL_COND(l == nullptr); } void print_line(String p_string) { diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 36fb016448..63b52661b4 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -43,7 +43,7 @@ #include <zlib.h> -ProjectSettings *ProjectSettings::singleton = NULL; +ProjectSettings *ProjectSettings::singleton = nullptr; ProjectSettings *ProjectSettings::get_singleton() { @@ -532,7 +532,7 @@ Error ProjectSettings::_load_settings_binary(const String &p_path) { d.resize(vlen); f->get_buffer(d.ptrw(), vlen); Variant value; - err = decode_variant(value, d.ptr(), d.size(), NULL, true); + err = decode_variant(value, d.ptr(), d.size(), nullptr, true); ERR_CONTINUE_MSG(err != OK, "Error decoding property: " + key + "."); set(key, value); } @@ -571,7 +571,7 @@ Error ProjectSettings::_load_settings_text(const String &p_path) { next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { memdelete(f); // If we're loading a project.godot from source code, we can operate some @@ -679,7 +679,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str file->store_string(key); int len; - err = encode_variant(p_custom_features, NULL, len, false); + err = encode_variant(p_custom_features, nullptr, len, false); if (err != OK) { memdelete(file); ERR_FAIL_V(err); @@ -717,7 +717,7 @@ Error ProjectSettings::_save_settings_binary(const String &p_file, const Map<Str file->store_string(key); int len; - err = encode_variant(value, NULL, len, true); + err = encode_variant(value, nullptr, len, true); if (err != OK) memdelete(file); ERR_FAIL_COND_V_MSG(err != OK, ERR_INVALID_DATA, "Error when trying to encode Variant."); @@ -1220,5 +1220,5 @@ ProjectSettings::ProjectSettings() { ProjectSettings::~ProjectSettings() { - singleton = NULL; + singleton = nullptr; } diff --git a/core/reference.h b/core/reference.h index 6898bfec3b..30a93d82a6 100644 --- a/core/reference.h +++ b/core/reference.h @@ -152,7 +152,7 @@ public: Ref r; r.reference = Object::cast_to<T>(refb); ref(r); - r.reference = NULL; + r.reference = nullptr; } void operator=(const Variant &p_variant) { @@ -190,14 +190,14 @@ public: Ref(const Ref &p_from) { - reference = NULL; + reference = nullptr; ref(p_from); } template <class T_Other> Ref(const Ref<T_Other> &p_from) { - reference = NULL; + reference = nullptr; Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr())); if (!refb) { unref(); @@ -206,12 +206,12 @@ public: Ref r; r.reference = Object::cast_to<T>(refb); ref(r); - r.reference = NULL; + r.reference = nullptr; } Ref(T *p_reference) { - reference = NULL; + reference = nullptr; if (p_reference) ref_pointer(p_reference); } @@ -233,8 +233,8 @@ public: } } - inline bool is_valid() const { return reference != NULL; } - inline bool is_null() const { return reference == NULL; } + inline bool is_valid() const { return reference != nullptr; } + inline bool is_null() const { return reference == nullptr; } void unref() { //TODO this should be moved to mutexes, since this engine does not really @@ -245,7 +245,7 @@ public: memdelete(reference); } - reference = NULL; + reference = nullptr; } void instance() { @@ -254,7 +254,7 @@ public: Ref() { - reference = NULL; + reference = nullptr; } ~Ref() { diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 7145d64629..905f43d61b 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -78,17 +78,17 @@ static Ref<TranslationLoaderPO> resource_format_po; static Ref<ResourceFormatSaverCrypto> resource_format_saver_crypto; static Ref<ResourceFormatLoaderCrypto> resource_format_loader_crypto; -static _ResourceLoader *_resource_loader = NULL; -static _ResourceSaver *_resource_saver = NULL; -static _OS *_os = NULL; -static _Engine *_engine = NULL; -static _ClassDB *_classdb = NULL; -static _Marshalls *_marshalls = NULL; -static _JSON *_json = NULL; +static _ResourceLoader *_resource_loader = nullptr; +static _ResourceSaver *_resource_saver = nullptr; +static _OS *_os = nullptr; +static _Engine *_engine = nullptr; +static _ClassDB *_classdb = nullptr; +static _Marshalls *_marshalls = nullptr; +static _JSON *_json = nullptr; -static IP *ip = NULL; +static IP *ip = nullptr; -static _Geometry *_geometry = NULL; +static _Geometry *_geometry = nullptr; extern Mutex _global_mutex; @@ -138,6 +138,7 @@ void register_core_types() { ClassDB::register_virtual_class<InputEvent>(); ClassDB::register_virtual_class<InputEventWithModifiers>(); + ClassDB::register_virtual_class<InputEventFromWindow>(); ClassDB::register_class<InputEventKey>(); ClassDB::register_virtual_class<InputEventMouse>(); ClassDB::register_class<InputEventMouseButton>(); diff --git a/core/resource.cpp b/core/resource.cpp index e329a1574f..d1883d8043 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -328,7 +328,7 @@ Node *Resource::get_local_scene() const { return _get_local_scene_func(); } - return NULL; + return nullptr; } void Resource::setup_local_to_scene() { @@ -337,7 +337,7 @@ void Resource::setup_local_to_scene() { get_script_instance()->call("_setup_local_to_scene"); } -Node *(*Resource::_get_local_scene_func)() = NULL; +Node *(*Resource::_get_local_scene_func)() = nullptr; void Resource::set_as_translation_remapped(bool p_remapped) { @@ -438,7 +438,7 @@ Resource::Resource() : subindex = 0; local_to_scene = false; - local_scene = NULL; + local_scene = nullptr; } Resource::~Resource() { @@ -458,9 +458,9 @@ HashMap<String, Resource *> ResourceCache::resources; HashMap<String, HashMap<String, int>> ResourceCache::resource_path_cache; #endif -RWLock *ResourceCache::lock = NULL; +RWLock *ResourceCache::lock = nullptr; #ifdef TOOLS_ENABLED -RWLock *ResourceCache::path_cache_lock = NULL; +RWLock *ResourceCache::path_cache_lock = nullptr; #endif void ResourceCache::setup() { @@ -482,7 +482,7 @@ void ResourceCache::clear() { void ResourceCache::reload_externals() { /* - const String *K=NULL; + const String *K=nullptr; while ((K=resources.next(K))) { resources[*K]->reload_external_data(); } @@ -506,7 +506,7 @@ Resource *ResourceCache::get(const String &p_path) { lock->read_unlock(); if (!res) { - return NULL; + return nullptr; } return *res; @@ -515,7 +515,7 @@ Resource *ResourceCache::get(const String &p_path) { void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) { lock->read_lock(); - const String *K = NULL; + const String *K = nullptr; while ((K = resources.next(K))) { Resource *r = resources[*K]; @@ -539,13 +539,13 @@ void ResourceCache::dump(const char *p_file, bool p_short) { Map<String, int> type_count; - FileAccess *f = NULL; + FileAccess *f = nullptr; if (p_file) { f = FileAccess::open(p_file, FileAccess::WRITE); ERR_FAIL_COND_MSG(!f, "Cannot create file at path '" + String(p_file) + "'."); } - const String *K = NULL; + const String *K = nullptr; while ((K = resources.next(K))) { Resource *r = resources[*K]; diff --git a/core/resource.h b/core/resource.h index 9f83848c04..3b7812c870 100644 --- a/core/resource.h +++ b/core/resource.h @@ -162,7 +162,7 @@ public: static void reload_externals(); static bool has(const String &p_path); static Resource *get(const String &p_path); - static void dump(const char *p_file = NULL, bool p_short = false); + static void dump(const char *p_file = nullptr, bool p_short = false); static void get_cached_resources(List<Ref<Resource>> *p_resources); static int get_cached_resource_count(); }; diff --git a/core/rid_owner.h b/core/rid_owner.h index 5c8c48a4cb..946b2e396c 100644 --- a/core/rid_owner.h +++ b/core/rid_owner.h @@ -142,7 +142,7 @@ public: if (THREAD_SAFE) { spin_lock.unlock(); } - return NULL; + return nullptr; } uint32_t idx_chunk = idx / elements_in_chunk; @@ -153,7 +153,7 @@ public: if (THREAD_SAFE) { spin_lock.unlock(); } - return NULL; + return nullptr; } T *ptr = &chunks[idx_chunk][idx_element]; @@ -236,7 +236,7 @@ public: } _FORCE_INLINE_ T *get_ptr_by_index(uint32_t p_index) { - ERR_FAIL_INDEX_V(p_index, alloc_count, NULL); + ERR_FAIL_INDEX_V(p_index, alloc_count, nullptr); if (THREAD_SAFE) { spin_lock.lock(); } @@ -283,14 +283,14 @@ public: } RID_Alloc(uint32_t p_target_chunk_byte_size = 4096) { - chunks = NULL; - free_list_chunks = NULL; - validator_chunks = NULL; + chunks = nullptr; + free_list_chunks = nullptr; + validator_chunks = nullptr; elements_in_chunk = sizeof(T) > p_target_chunk_byte_size ? 1 : (p_target_chunk_byte_size / sizeof(T)); max_alloc = 0; alloc_count = 0; - description = NULL; + description = nullptr; } ~RID_Alloc() { @@ -340,7 +340,7 @@ public: _FORCE_INLINE_ T *getornull(const RID &p_rid) { T **ptr = alloc.getornull(p_rid); if (unlikely(!ptr)) { - return NULL; + return nullptr; } return *ptr; } diff --git a/core/script_language.cpp b/core/script_language.cpp index c664563909..82cac6bc9a 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -42,7 +42,7 @@ int ScriptServer::_language_count = 0; bool ScriptServer::scripting_enabled = true; bool ScriptServer::reload_scripts_on_save = false; bool ScriptServer::languages_finished = false; -ScriptEditRequestFunction ScriptServer::edit_request_func = NULL; +ScriptEditRequestFunction ScriptServer::edit_request_func = nullptr; void Script::_notification(int p_what) { @@ -136,7 +136,7 @@ bool ScriptServer::is_scripting_enabled() { ScriptLanguage *ScriptServer::get_language(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, _language_count, NULL); + ERR_FAIL_INDEX_V(p_idx, _language_count, nullptr); return _languages[p_idx]; } @@ -256,7 +256,7 @@ StringName ScriptServer::get_global_class_native_base(const String &p_class) { return base; } void ScriptServer::get_global_class_list(List<StringName> *r_global_classes) { - const StringName *K = NULL; + const StringName *K = nullptr; List<StringName> classes; while ((K = global_classes.next(K))) { classes.push_back(*K); @@ -350,7 +350,7 @@ void ScriptInstance::call_multilevel(const StringName &p_method, VARIANT_ARG_DEC ScriptInstance::~ScriptInstance() { } -ScriptCodeCompletionCache *ScriptCodeCompletionCache::singleton = NULL; +ScriptCodeCompletionCache *ScriptCodeCompletionCache::singleton = nullptr; ScriptCodeCompletionCache::ScriptCodeCompletionCache() { singleton = this; } diff --git a/core/script_language.h b/core/script_language.h index 6219a423d0..2d86c5166d 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -137,7 +137,7 @@ public: virtual StringName get_instance_base_type() const = 0; // this may not work in all scripts, will return empty if so virtual ScriptInstance *instance_create(Object *p_this) = 0; - virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) { return NULL; } + virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) { return nullptr; } virtual bool instance_has(const Object *p_this) const = 0; virtual bool has_source_code() const = 0; @@ -189,9 +189,9 @@ public: virtual bool set(const StringName &p_name, const Variant &p_value) = 0; virtual bool get(const StringName &p_name, Variant &r_ret) const = 0; virtual void get_property_list(List<PropertyInfo> *p_properties) const = 0; - virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const = 0; + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const = 0; - virtual Object *get_owner() { return NULL; } + virtual Object *get_owner() { return nullptr; } virtual void get_property_state(List<Pair<StringName, Variant>> &state); virtual void get_method_list(List<MethodInfo> *p_list) const = 0; @@ -306,7 +306,7 @@ public: virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const = 0; virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {} virtual bool is_using_templates() { return false; } - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const = 0; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const = 0; virtual String validate_path(const String &p_path) const { return ""; } virtual Script *create_script() const = 0; virtual bool has_named_classes() const = 0; @@ -363,7 +363,7 @@ public: virtual String debug_get_stack_level_source(int p_level) const = 0; virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0; virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0; - virtual ScriptInstance *debug_get_stack_level_instance(int p_level) { return NULL; } + virtual ScriptInstance *debug_get_stack_level_instance(int p_level) { return nullptr; } virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0; virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) = 0; @@ -390,7 +390,7 @@ public: virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) = 0; virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) = 0; - virtual void *alloc_instance_binding_data(Object *p_object) { return NULL; } //optional, not used by all languages + virtual void *alloc_instance_binding_data(Object *p_object) { return nullptr; } //optional, not used by all languages virtual void free_instance_binding_data(void *p_data) {} //optional, not used by all languages virtual void refcount_incremented_instance_binding(Object *p_object) {} //optional, not used by all languages virtual bool refcount_decremented_instance_binding(Object *p_object) { return true; } //return true if it can die //optional, not used by all languages @@ -398,7 +398,7 @@ public: virtual void frame(); virtual bool handles_global_class_type(const String &p_type) const { return false; } - virtual String get_global_class_name(const String &p_path, String *r_base_type = NULL, String *r_icon_path = NULL) const { return String(); } + virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const { return String(); } virtual ~ScriptLanguage() {} }; @@ -418,7 +418,7 @@ public: virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; - virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const; + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const; virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName &p_method) const; @@ -441,8 +441,8 @@ public: virtual bool is_placeholder() const { return true; } - virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid = NULL); - virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid = NULL); + virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid = nullptr); + virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid = nullptr); virtual Vector<ScriptNetData> get_rpc_methods() const { return Vector<ScriptNetData>(); } virtual uint16_t get_rpc_method_id(const StringName &p_method) const; diff --git a/core/self_list.h b/core/self_list.h index 1cd7bb44d8..19d2783208 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -49,7 +49,7 @@ public: p_elem->_root = this; p_elem->_next = _first; - p_elem->_prev = NULL; + p_elem->_prev = nullptr; if (_first) { _first->_prev = p_elem; @@ -66,7 +66,7 @@ public: ERR_FAIL_COND(p_elem->_root); p_elem->_root = this; - p_elem->_next = NULL; + p_elem->_next = nullptr; p_elem->_prev = _last; if (_last) { @@ -98,18 +98,18 @@ public: _last = p_elem->_prev; } - p_elem->_next = NULL; - p_elem->_prev = NULL; - p_elem->_root = NULL; + p_elem->_next = nullptr; + p_elem->_prev = nullptr; + p_elem->_root = nullptr; } _FORCE_INLINE_ SelfList<T> *first() { return _first; } _FORCE_INLINE_ const SelfList<T> *first() const { return _first; } _FORCE_INLINE_ List() { - _first = NULL; - _last = NULL; + _first = nullptr; + _last = nullptr; } - _FORCE_INLINE_ ~List() { ERR_FAIL_COND(_first != NULL); } + _FORCE_INLINE_ ~List() { ERR_FAIL_COND(_first != nullptr); } }; private: @@ -129,9 +129,9 @@ public: _FORCE_INLINE_ SelfList(T *p_self) { _self = p_self; - _next = NULL; - _prev = NULL; - _root = NULL; + _next = nullptr; + _prev = nullptr; + _root = nullptr; } _FORCE_INLINE_ ~SelfList() { diff --git a/core/set.h b/core/set.h index 5ddfb87b74..c17ee15350 100644 --- a/core/set.h +++ b/core/set.h @@ -82,11 +82,11 @@ public: }; Element() { color = RED; - right = NULL; - left = NULL; - parent = NULL; - _next = NULL; - _prev = NULL; + right = nullptr; + left = nullptr; + parent = nullptr; + _next = nullptr; + _prev = nullptr; }; }; @@ -105,7 +105,7 @@ private: #else _nil = (Element *)&_GlobalNilClass::_nil; #endif - _root = NULL; + _root = nullptr; size_cache = 0; } @@ -120,7 +120,7 @@ private: if (_root) { memdelete_allocator<Element, A>(_root); - _root = NULL; + _root = nullptr; } } @@ -192,7 +192,7 @@ private: } if (node->parent == _data._root) - return NULL; // No successor, as p_node = last node + return nullptr; // No successor, as p_node = last node return node->parent; } } @@ -214,7 +214,7 @@ private: } if (node == _data._root) - return NULL; // No predecessor, as p_node = first node. + return nullptr; // No predecessor, as p_node = first node. return node->parent; } } @@ -233,13 +233,13 @@ private: return node; // found } - return NULL; + return nullptr; } Element *_lower_bound(const T &p_value) const { Element *node = _data._root->left; - Element *prev = NULL; + Element *prev = nullptr; C less; while (node != _data._nil) { @@ -253,8 +253,8 @@ private: return node; // found } - if (prev == NULL) - return NULL; // tree empty + if (prev == nullptr) + return nullptr; // tree empty if (less(prev->value, p_value)) prev = prev->_next; @@ -504,7 +504,7 @@ public: const Element *find(const T &p_value) const { if (!_data._root) - return NULL; + return nullptr; const Element *res = _find(p_value); return res; @@ -513,7 +513,7 @@ public: Element *find(const T &p_value) { if (!_data._root) - return NULL; + return nullptr; Element *res = _find(p_value); return res; @@ -526,7 +526,7 @@ public: bool has(const T &p_value) const { - return find(p_value) != NULL; + return find(p_value) != nullptr; } Element *insert(const T &p_value) { @@ -564,11 +564,11 @@ public: Element *front() const { if (!_data._root) - return NULL; + return nullptr; Element *e = _data._root->left; if (e == _data._nil) - return NULL; + return nullptr; while (e->left != _data._nil) e = e->left; @@ -579,11 +579,11 @@ public: Element *back() const { if (!_data._root) - return NULL; + return nullptr; Element *e = _data._root->left; if (e == _data._nil) - return NULL; + return nullptr; while (e->right != _data._nil) e = e->right; diff --git a/core/string_name.cpp b/core/string_name.cpp index 4ec9af008e..9cbac97a7c 100644 --- a/core/string_name.cpp +++ b/core/string_name.cpp @@ -54,7 +54,7 @@ void StringName::setup() { ERR_FAIL_COND(configured); for (int i = 0; i < STRING_TABLE_LEN; i++) { - _table[i] = NULL; + _table[i] = nullptr; } configured = true; } @@ -110,7 +110,7 @@ void StringName::unref() { memdelete(_data); } - _data = NULL; + _data = nullptr; } bool StringName::operator==(const String &p_name) const { @@ -160,7 +160,7 @@ void StringName::operator=(const StringName &p_name) { StringName::StringName(const StringName &p_name) { - _data = NULL; + _data = nullptr; ERR_FAIL_COND(!configured); @@ -171,7 +171,7 @@ StringName::StringName(const StringName &p_name) { StringName::StringName(const char *p_name) { - _data = NULL; + _data = nullptr; ERR_FAIL_COND(!configured); @@ -206,9 +206,9 @@ StringName::StringName(const char *p_name) { _data->refcount.init(); _data->hash = hash; _data->idx = idx; - _data->cname = NULL; + _data->cname = nullptr; _data->next = _table[idx]; - _data->prev = NULL; + _data->prev = nullptr; if (_table[idx]) _table[idx]->prev = _data; _table[idx] = _data; @@ -216,7 +216,7 @@ StringName::StringName(const char *p_name) { StringName::StringName(const StaticCString &p_static_string) { - _data = NULL; + _data = nullptr; ERR_FAIL_COND(!configured); @@ -252,7 +252,7 @@ StringName::StringName(const StaticCString &p_static_string) { _data->idx = idx; _data->cname = p_static_string.ptr; _data->next = _table[idx]; - _data->prev = NULL; + _data->prev = nullptr; if (_table[idx]) _table[idx]->prev = _data; _table[idx] = _data; @@ -260,7 +260,7 @@ StringName::StringName(const StaticCString &p_static_string) { StringName::StringName(const String &p_name) { - _data = NULL; + _data = nullptr; ERR_FAIL_COND(!configured); @@ -293,9 +293,9 @@ StringName::StringName(const String &p_name) { _data->refcount.init(); _data->hash = hash; _data->idx = idx; - _data->cname = NULL; + _data->cname = nullptr; _data->next = _table[idx]; - _data->prev = NULL; + _data->prev = nullptr; if (_table[idx]) _table[idx]->prev = _data; _table[idx] = _data; @@ -390,7 +390,7 @@ StringName StringName::search(const String &p_name) { StringName::StringName() { - _data = NULL; + _data = nullptr; } StringName::~StringName() { diff --git a/core/string_name.h b/core/string_name.h index e68ab8bfa3..aec87b8e66 100644 --- a/core/string_name.h +++ b/core/string_name.h @@ -61,8 +61,8 @@ class StringName { _Data *prev; _Data *next; _Data() { - cname = NULL; - next = prev = NULL; + cname = nullptr; + next = prev = nullptr; idx = 0; hash = 0; } diff --git a/core/translation.cpp b/core/translation.cpp index df3661e5d0..3f45bb17c9 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -407,7 +407,7 @@ static const char *locale_list[] = { "zh_SG", // Chinese (Singapore) "zh_TW", // Chinese (Taiwan) "zu_ZA", // Zulu (South Africa) - 0 + nullptr }; static const char *locale_names[] = { @@ -775,7 +775,7 @@ static const char *locale_names[] = { "Chinese (Singapore)", "Chinese (Taiwan)", "Zulu (South Africa)", - 0 + nullptr }; // Windows has some weird locale identifiers which do not honor the ISO 639-1 @@ -789,7 +789,7 @@ static const char *locale_renames[][2] = { { "in", "id" }, // Indonesian { "iw", "he" }, // Hebrew { "no", "nb" }, // Norwegian BokmÃ¥l - { NULL, NULL } + { nullptr, nullptr } }; /////////////////////////////////////////////// @@ -929,7 +929,7 @@ String TranslationServer::standardize_locale(const String &p_locale) { // Handles known non-ISO locale names used e.g. on Windows int idx = 0; - while (locale_renames[idx][0] != NULL) { + while (locale_renames[idx][0] != nullptr) { if (locale_renames[idx][0] == univ_locale) { univ_locale = locale_renames[idx][1]; break; @@ -1141,7 +1141,7 @@ StringName TranslationServer::translate(const StringName &p_message) const { return res; } -TranslationServer *TranslationServer::singleton = NULL; +TranslationServer *TranslationServer::singleton = nullptr; bool TranslationServer::_load_translations(const String &p_from) { diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 02f460c93d..8bd5a4915d 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -108,7 +108,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) { void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -128,7 +128,7 @@ void UndoRedo::add_do_method(Object *p_object, const StringName &p_method, VARIA void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -151,7 +151,7 @@ void UndoRedo::add_undo_method(Object *p_object, const StringName &p_method, VAR } void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, const Variant &p_value) { - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -166,7 +166,7 @@ void UndoRedo::add_do_property(Object *p_object, const StringName &p_property, c } void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property, const Variant &p_value) { - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -186,7 +186,7 @@ void UndoRedo::add_undo_property(Object *p_object, const StringName &p_property, } void UndoRedo::add_do_reference(Object *p_object) { - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; @@ -199,7 +199,7 @@ void UndoRedo::add_do_reference(Object *p_object) { } void UndoRedo::add_undo_reference(Object *p_object) { - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); @@ -417,13 +417,13 @@ UndoRedo::UndoRedo() { current_action = -1; merge_mode = MERGE_DISABLE; merging = false; - callback = NULL; - callback_ud = NULL; + callback = nullptr; + callback_ud = nullptr; - method_callbck_ud = NULL; - prop_callback_ud = NULL; - method_callback = NULL; - property_callback = NULL; + method_callbck_ud = nullptr; + prop_callback_ud = nullptr; + method_callback = nullptr; + property_callback = nullptr; } UndoRedo::~UndoRedo() { diff --git a/core/ustring.cpp b/core/ustring.cpp index 8027ae29b5..e56f177103 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -205,7 +205,7 @@ void String::copy_from(const CharType *p_cstr, const int p_clip_to) { } // assumes the following have already been validated: -// p_char != NULL +// p_char != nullptr // p_length > 0 // p_length <= p_char strlen void String::copy_from_unchecked(const CharType *p_char, const int p_length) { @@ -1640,7 +1640,7 @@ CharString String::utf8() const { /* String::String(CharType p_char) { - shared=NULL; + shared=nullptr; copy_from(p_char); } */ @@ -1913,7 +1913,7 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point * necessary unless F is present. The "E" may * actually be an "e". E and X may both be * omitted (but not just one). */ - C **endPtr = NULL) /* If non-NULL, store terminating Cacter's + C **endPtr = nullptr) /* If non-nullptr, store terminating Cacter's * address here. */ { @@ -2101,7 +2101,7 @@ static double built_in_strtod(const C *string, /* A decimal ASCII floating-point } done: - if (endPtr != NULL) { + if (endPtr != nullptr) { *endPtr = (C *)p; } @@ -2202,7 +2202,7 @@ double String::to_double() const { return 0; #ifndef NO_USE_STDLIB return built_in_strtod<CharType>(c_str()); -//return wcstod(c_str(),NULL); DOES NOT WORK ON ANDROID :( +//return wcstod(c_str(),nullptr ); DOES NOT WORK ON ANDROID :( #else return built_in_strtod<CharType>(c_str()); #endif @@ -3449,7 +3449,7 @@ String String::http_unescape() const { CharType ord2 = ord_at(i + 2); if ((ord2 >= '0' && ord2 <= '9') || (ord2 >= 'A' && ord2 <= 'Z')) { char bytes[3] = { (char)ord1, (char)ord2, 0 }; - res += (char)strtol(bytes, NULL, 16); + res += (char)strtol(bytes, nullptr, 16); i += 2; } } else { @@ -3633,7 +3633,7 @@ String String::xml_unescape() const { String str; int l = length(); - int len = _xml_unescape(c_str(), l, NULL); + int len = _xml_unescape(c_str(), l, nullptr); if (len == 0) return String(); str.resize(len + 1); diff --git a/core/ustring.h b/core/ustring.h index 33320a0a49..ee7e3b1e16 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -117,7 +117,7 @@ struct StrRange { const CharType *c_str; int len; - StrRange(const CharType *p_c_str = NULL, int p_len = 0) { + StrRange(const CharType *p_c_str = nullptr, int p_len = 0) { c_str = p_c_str; len = p_len; } @@ -206,7 +206,7 @@ public: int findn(const String &p_str, int p_from = 0) const; ///< return <0 if failed, case insensitive int rfind(const String &p_str, int p_from = -1) const; ///< return <0 if failed int rfindn(const String &p_str, int p_from = -1) const; ///< return <0 if failed, case insensitive - int findmk(const Vector<String> &p_keys, int p_from = 0, int *r_key = NULL) const; ///< return <0 if failed + int findmk(const Vector<String> &p_keys, int p_from = 0, int *r_key = nullptr) const; ///< return <0 if failed bool match(const String &p_wildcard) const; bool matchn(const String &p_wildcard) const; bool begins_with(const String &p_string) const; @@ -253,7 +253,7 @@ public: int64_t to_int64() const; static int to_int(const char *p_str, int p_len = -1); static double to_double(const char *p_str); - static double to_double(const CharType *p_str, const CharType **r_end = NULL); + static double to_double(const CharType *p_str, const CharType **r_end = nullptr); static int64_t to_int(const CharType *p_str, int p_len = -1); String capitalize() const; String camelcase_to_underscore(bool lowercase = true) const; diff --git a/core/variant.cpp b/core/variant.cpp index d12a15ec9d..b3611536b8 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -233,8 +233,8 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) { return (p_type_to == OBJECT); }; - const Type *valid_types = NULL; - const Type *invalid_types = NULL; + const Type *valid_types = nullptr; + const Type *invalid_types = nullptr; switch (p_type_to) { case BOOL: { @@ -570,7 +570,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type return (p_type_to == OBJECT); }; - const Type *valid_types = NULL; + const Type *valid_types = nullptr; switch (p_type_to) { case BOOL: { @@ -1020,7 +1020,7 @@ bool Variant::is_zero() const { } break; case OBJECT: { - return _get_obj().obj == NULL; + return _get_obj().obj == nullptr; } break; case CALLABLE: { @@ -1479,7 +1479,7 @@ void Variant::clear() { memdelete(reference); } } - _get_obj().obj = NULL; + _get_obj().obj = nullptr; _get_obj().id = ObjectID(); } break; case _RID: { @@ -1864,7 +1864,7 @@ String Variant::stringify(List<const void *> &stack) const { stack.push_back(d.id()); - //const String *K=NULL; + //const String *K=nullptr; String str("{"); List<Variant> keys; d.get_key_list(&keys); @@ -2227,7 +2227,7 @@ Variant::operator RID() const { }; #endif Callable::CallError ce; - Variant ret = _get_obj().obj->call(CoreStringNames::get_singleton()->get_rid, NULL, 0, ce); + Variant ret = _get_obj().obj->call(CoreStringNames::get_singleton()->get_rid, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK && ret.get_type() == Variant::_RID) { return ret; } @@ -2242,7 +2242,7 @@ Variant::operator Object *() const { if (type == OBJECT) return _get_obj().obj; else - return NULL; + return nullptr; } Object *Variant::get_validated_object_with_check(bool &r_previously_freed) const { @@ -2252,7 +2252,7 @@ Object *Variant::get_validated_object_with_check(bool &r_previously_freed) const return instance; } else { r_previously_freed = false; - return NULL; + return nullptr; } } @@ -2260,7 +2260,7 @@ Object *Variant::get_validated_object() const { if (type == OBJECT) return ObjectDB::get_instance(_get_obj().id); else - return NULL; + return nullptr; } Variant::operator Node *() const { @@ -2268,14 +2268,14 @@ Variant::operator Node *() const { if (type == OBJECT) return Object::cast_to<Node>(_get_obj().obj); else - return NULL; + return nullptr; } Variant::operator Control *() const { if (type == OBJECT) return Object::cast_to<Control>(_get_obj().obj); else - return NULL; + return nullptr; } Variant::operator Dictionary() const { diff --git a/core/variant.h b/core/variant.h index d38130e3a3..a832f7ccf8 100644 --- a/core/variant.h +++ b/core/variant.h @@ -435,16 +435,16 @@ public: bool has_method(const StringName &p_method) const; static Vector<Variant::Type> get_method_argument_types(Variant::Type p_type, const StringName &p_method); static Vector<Variant> get_method_default_arguments(Variant::Type p_type, const StringName &p_method); - static Variant::Type get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return = NULL); + static Variant::Type get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return = nullptr); static Vector<StringName> get_method_argument_names(Variant::Type p_type, const StringName &p_method); static bool is_method_const(Variant::Type p_type, const StringName &p_method); - void set_named(const StringName &p_index, const Variant &p_value, bool *r_valid = NULL); - Variant get_named(const StringName &p_index, bool *r_valid = NULL) const; + void set_named(const StringName &p_index, const Variant &p_value, bool *r_valid = nullptr); + Variant get_named(const StringName &p_index, bool *r_valid = nullptr) const; - void set(const Variant &p_index, const Variant &p_value, bool *r_valid = NULL); - Variant get(const Variant &p_index, bool *r_valid = NULL) const; - bool in(const Variant &p_index, bool *r_valid = NULL) const; + void set(const Variant &p_index, const Variant &p_value, bool *r_valid = nullptr); + Variant get(const Variant &p_index, bool *r_valid = nullptr) const; + bool in(const Variant &p_index, bool *r_valid = nullptr) const; bool iter_init(Variant &r_iter, bool &r_valid) const; bool iter_next(Variant &r_iter, bool &r_valid) const; @@ -467,13 +467,13 @@ public: static void get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list); static void get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants); static bool has_constant(Variant::Type p_type, const StringName &p_value); - static Variant get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid = NULL); + static Variant get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid = nullptr); typedef String (*ObjectDeConstruct)(const Variant &p_object, void *ud); typedef void (*ObjectConstruct)(const String &p_text, void *ud, Variant &r_value); String get_construct_string() const; - static void construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct = NULL, void *p_construct_ud = NULL); + static void construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct = nullptr, void *p_construct_ud = nullptr); void operator=(const Variant &p_variant); // only this is enough for all the other types Variant(const Variant &p_variant); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index db7244a221..391c293810 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1191,9 +1191,9 @@ struct _VariantCall { } }; -_VariantCall::TypeFunc *_VariantCall::type_funcs = NULL; -_VariantCall::ConstructFunc *_VariantCall::construct_funcs = NULL; -_VariantCall::ConstantData *_VariantCall::constant_data = NULL; +_VariantCall::TypeFunc *_VariantCall::type_funcs = nullptr; +_VariantCall::ConstructFunc *_VariantCall::construct_funcs = nullptr; +_VariantCall::ConstantData *_VariantCall::constant_data = nullptr; Variant Variant::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { @@ -1310,7 +1310,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case NODE_PATH: return NodePath(); case _RID: return RID(); - case OBJECT: return (Object *)NULL; + case OBJECT: return (Object *)nullptr; case CALLABLE: return Callable(); case SIGNAL: return Signal(); case DICTIONARY: return Dictionary(); @@ -1957,7 +1957,7 @@ void register_variant_methods() { ADDFUNC0NC(DICTIONARY, NIL, Dictionary, clear, varray()); ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray()); ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray()); - ADDFUNC1R(DICTIONARY, BOOL, Dictionary, erase, NIL, "key", varray()); + ADDFUNC1RNC(DICTIONARY, BOOL, Dictionary, erase, NIL, "key", varray()); ADDFUNC0R(DICTIONARY, INT, Dictionary, hash, varray()); ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, keys, varray()); ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, values, varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 88f6ce19a2..f173c88054 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -438,7 +438,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_EQUAL, NIL) { if (p_b.type == NIL) _RETURN(true); if (p_b.type == OBJECT) - _RETURN(p_b._get_obj().obj == NULL); + _RETURN(p_b._get_obj().obj == nullptr); _RETURN(false); } @@ -457,7 +457,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, if (p_b.type == OBJECT) _RETURN((p_a._get_obj().obj == p_b._get_obj().obj)); if (p_b.type == NIL) - _RETURN(p_a._get_obj().obj == NULL); + _RETURN(p_a._get_obj().obj == nullptr); _RETURN_FAIL; } @@ -534,7 +534,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_NOT_EQUAL, NIL) { if (p_b.type == NIL) _RETURN(false); if (p_b.type == OBJECT) - _RETURN(p_b._get_obj().obj != NULL); + _RETURN(p_b._get_obj().obj != nullptr); _RETURN(true); } @@ -554,7 +554,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, if (p_b.type == OBJECT) _RETURN((p_a._get_obj().obj != p_b._get_obj().obj)); if (p_b.type == NIL) - _RETURN(p_a._get_obj().obj != NULL); + _RETURN(p_a._get_obj().obj != nullptr); _RETURN_FAIL; } @@ -3527,7 +3527,7 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { if (dic->empty()) return false; - const Variant *next = dic->next(NULL); + const Variant *next = dic->next(nullptr); r_iter = *next; return true; diff --git a/core/variant_parser.h b/core/variant_parser.h index d50842145c..63ed51bcc9 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -58,7 +58,7 @@ public: virtual bool is_utf8() const; virtual bool is_eof() const; - StreamFile() { f = NULL; } + StreamFile() { f = nullptr; } }; struct StreamString : public Stream { @@ -130,17 +130,17 @@ private: template <class T> static Error _parse_construct(Stream *p_stream, Vector<T> &r_construct, int &line, String &r_err_str); static Error _parse_enginecfg(Stream *p_stream, Vector<String> &strings, int &line, String &r_err_str); - static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL); - static Error _parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL); - static Error _parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = NULL, bool p_simple_tag = false); + static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); + static Error _parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); + static Error _parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = nullptr, bool p_simple_tag = false); public: - static Error parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = NULL, bool p_simple_tag = false); - static Error parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser = NULL, bool p_simple_tag = false); + static Error parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser = nullptr, bool p_simple_tag = false); + static Error parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser = nullptr, bool p_simple_tag = false); - static Error parse_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = NULL); + static Error parse_value(Token &token, Variant &value, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser = nullptr); static Error get_token(Stream *p_stream, Token &r_token, int &line, String &r_err_str); - static Error parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser = NULL); + static Error parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser = nullptr); }; class VariantWriter { @@ -149,7 +149,7 @@ public: typedef String (*EncodeResourceFunc)(void *ud, const RES &p_resource); static Error write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud); - static Error write_to_string(const Variant &p_variant, String &r_string, EncodeResourceFunc p_encode_res_func = NULL, void *p_encode_res_ud = NULL); + static Error write_to_string(const Variant &p_variant, String &r_string, EncodeResourceFunc p_encode_res_func = nullptr, void *p_encode_res_ud = nullptr); }; #endif // VARIANT_PARSER_H diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 74c364bad5..8c6821eaac 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -36,8 +36,8 @@ <member name="IP" type="IP" setter="" getter=""> The [IP] singleton. </member> - <member name="Input" type="Input" setter="" getter=""> - The [Input] singleton. + <member name="Input" type="InputFilter" setter="" getter=""> + The [InputFilter] singleton. </member> <member name="InputMap" type="InputMap" setter="" getter=""> The [InputMap] singleton. @@ -56,14 +56,14 @@ <member name="Marshalls" type="Marshalls" setter="" getter=""> The [Marshalls] singleton. </member> - <member name="Navigation2DServer" type="Navigation2DServer" setter="" getter=""> - The [Navigation2DServer] singleton. - </member> <member name="NavigationMeshGenerator" type="NavigationMeshGenerator" setter="" getter=""> The [NavigationMeshGenerator] singleton. </member> - <member name="NavigationServer" type="NavigationServer" setter="" getter=""> - The [NavigationServer] singleton. + <member name="NavigationServer2D" type="NavigationServer2D" setter="" getter=""> + The [NavigationServer2D] singleton. + </member> + <member name="NavigationServer3D" type="NavigationServer3D" setter="" getter=""> + The [NavigationServer2D] singleton. </member> <member name="OS" type="OS" setter="" getter=""> The [OS] singleton. @@ -71,15 +71,18 @@ <member name="Performance" type="Performance" setter="" getter=""> The [Performance] singleton. </member> - <member name="Physics2DServer" type="Physics2DServer" setter="" getter=""> - The [Physics2DServer] singleton. + <member name="PhysicsServer2D" type="PhysicsServer2D" setter="" getter=""> + The [PhysicsServer2D] singleton. </member> - <member name="PhysicsServer" type="PhysicsServer" setter="" getter=""> - The [PhysicsServer] singleton. + <member name="PhysicsServer3D" type="PhysicsServer3D" setter="" getter=""> + The [PhysicsServer3D] singleton. </member> <member name="ProjectSettings" type="ProjectSettings" setter="" getter=""> The [ProjectSettings] singleton. </member> + <member name="RenderingServer" type="RenderingServer" setter="" getter=""> + The [RenderingServer] singleton. + </member> <member name="ResourceLoader" type="ResourceLoader" setter="" getter=""> The [ResourceLoader] singleton. </member> @@ -92,9 +95,6 @@ <member name="VisualScriptEditor" type="VisualScriptEditor" setter="" getter=""> The [VisualScriptEditor] singleton. </member> - <member name="VisualServer" type="VisualServer" setter="" getter=""> - The [VisualServer] singleton. - </member> </members> <constants> <constant name="MARGIN_LEFT" value="0" enum="Margin"> diff --git a/doc/classes/ARVRAnchor.xml b/doc/classes/ARVRAnchor.xml index 87181f572d..82575ce7cb 100644 --- a/doc/classes/ARVRAnchor.xml +++ b/doc/classes/ARVRAnchor.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRAnchor" inherits="Spatial" version="4.0"> +<class name="ARVRAnchor" inherits="Node3D" version="4.0"> <brief_description> An anchor point in AR space. </brief_description> diff --git a/doc/classes/ARVRCamera.xml b/doc/classes/ARVRCamera.xml index a571d26c83..c97d5cf1d8 100644 --- a/doc/classes/ARVRCamera.xml +++ b/doc/classes/ARVRCamera.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRCamera" inherits="Camera" version="4.0"> +<class name="ARVRCamera" inherits="Camera3D" version="4.0"> <brief_description> A camera node with a few overrules for AR/VR applied, such as location tracking. </brief_description> diff --git a/doc/classes/ARVRController.xml b/doc/classes/ARVRController.xml index ebae25feb7..572b47ce6d 100644 --- a/doc/classes/ARVRController.xml +++ b/doc/classes/ARVRController.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRController" inherits="Spatial" version="4.0"> +<class name="ARVRController" inherits="Node3D" version="4.0"> <brief_description> A spatial node representing a spatially-tracked controller. </brief_description> diff --git a/doc/classes/ARVROrigin.xml b/doc/classes/ARVROrigin.xml index 9a386fd154..a88a89c927 100644 --- a/doc/classes/ARVROrigin.xml +++ b/doc/classes/ARVROrigin.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVROrigin" inherits="Spatial" version="4.0"> +<class name="ARVROrigin" inherits="Node3D" version="4.0"> <brief_description> The origin point in AR/VR. </brief_description> diff --git a/doc/classes/ARVRServer.xml b/doc/classes/ARVRServer.xml index 6db7121858..d8d069c048 100644 --- a/doc/classes/ARVRServer.xml +++ b/doc/classes/ARVRServer.xml @@ -69,7 +69,7 @@ <return type="int"> </return> <description> - Returns the absolute timestamp (in μs) of the last [ARVRServer] commit of the AR/VR eyes to [VisualServer]. The value comes from an internal call to [method OS.get_ticks_usec]. + Returns the absolute timestamp (in μs) of the last [ARVRServer] commit of the AR/VR eyes to [RenderingServer]. The value comes from an internal call to [method OS.get_ticks_usec]. </description> </method> <method name="get_last_frame_usec"> diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index 01540383dc..99b566e74f 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AcceptDialog" inherits="WindowDialog" version="4.0"> +<class name="AcceptDialog" inherits="Window" version="4.0"> <brief_description> Base dialog for user notification. </brief_description> @@ -67,9 +67,16 @@ <member name="dialog_text" type="String" setter="set_text" getter="get_text" default=""""> The text displayed by the dialog. </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Alert!"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Alert!"" /> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" override="true" default="true" /> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" override="true" default="false" /> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" override="true" default="true" /> </members> <signals> + <signal name="cancelled"> + <description> + </description> + </signal> <signal name="confirmed"> <description> Emitted when the dialog is accepted, i.e. the OK button is pressed. diff --git a/doc/classes/AnimatedSprite.xml b/doc/classes/AnimatedSprite2D.xml index b5c1d38ff9..8d0534ccd2 100644 --- a/doc/classes/AnimatedSprite.xml +++ b/doc/classes/AnimatedSprite2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AnimatedSprite" inherits="Node2D" version="4.0"> +<class name="AnimatedSprite2D" inherits="Node2D" version="4.0"> <brief_description> Sprite node that can use multiple textures for animation. </brief_description> @@ -61,7 +61,7 @@ If [code]true[/code], the [member animation] is currently playing. </member> <member name="shininess" type="float" setter="set_shininess" getter="get_shininess" default="1.0"> - Strength of the specular light effect of this [AnimatedSprite]. + Strength of the specular light effect of this [AnimatedSprite2D]. </member> <member name="specular_color" type="Color" setter="set_specular_color" getter="get_specular_color" default="Color( 1, 1, 1, 1 )"> The color of the specular light effect. diff --git a/doc/classes/AnimatedTexture.xml b/doc/classes/AnimatedTexture.xml index b851c76e59..80b910aaa7 100644 --- a/doc/classes/AnimatedTexture.xml +++ b/doc/classes/AnimatedTexture.xml @@ -4,7 +4,7 @@ Proxy texture for simple frame-based animations. </brief_description> <description> - [AnimatedTexture] is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike [AnimationPlayer] or [AnimatedSprite], it isn't a [Node], but has the advantage of being usable anywhere a [Texture2D] resource can be used, e.g. in a [TileSet]. + [AnimatedTexture] is a resource format for frame-based animations, where multiple textures can be chained automatically with a predefined delay for each frame. Unlike [AnimationPlayer] or [AnimatedSprite2D], it isn't a [Node], but has the advantage of being usable anywhere a [Texture2D] resource can be used, e.g. in a [TileSet]. The playback of the animation is controlled by the [member fps] property as well as each frame's optional delay (see [method set_frame_delay]). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame. [AnimatedTexture] currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one. Also, it doesn't support [AtlasTexture]. Each frame needs to be separate image. </description> @@ -71,7 +71,7 @@ </members> <constants> <constant name="MAX_FRAMES" value="256"> - The maximum number of frames supported by [AnimatedTexture]. If you need more frames in your animation, use [AnimationPlayer] or [AnimatedSprite]. + The maximum number of frames supported by [AnimatedTexture]. If you need more frames in your animation, use [AnimationPlayer] or [AnimatedSprite2D]. </constant> </constants> </class> diff --git a/doc/classes/Area.xml b/doc/classes/Area3D.xml index b273a7a9d9..1adfc878e2 100644 --- a/doc/classes/Area.xml +++ b/doc/classes/Area3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Area" inherits="CollisionObject" version="4.0"> +<class name="Area3D" inherits="CollisionObject3D" version="4.0"> <brief_description> General-purpose area node for detection and 3D physics influence. </brief_description> <description> - 3D area that detects [CollisionObject] nodes overlapping, entering, or exiting. Can also alter or override local physics parameters (gravity, damping). + 3D area that detects [CollisionObject3D] nodes overlapping, entering, or exiting. Can also alter or override local physics parameters (gravity, damping). </description> <tutorials> </tutorials> @@ -31,14 +31,14 @@ <return type="Array"> </return> <description> - Returns a list of intersecting [Area]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. + Returns a list of intersecting [Area3D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. </description> </method> <method name="get_overlapping_bodies" qualifiers="const"> <return type="Array"> </return> <description> - Returns a list of intersecting [PhysicsBody]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. + Returns a list of intersecting [PhysicsBody3D]s. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead. </description> </method> <method name="overlaps_area" qualifiers="const"> @@ -47,7 +47,7 @@ <argument index="0" name="area" type="Node"> </argument> <description> - If [code]true[/code], the given area overlaps the Area. + If [code]true[/code], the given area overlaps the Area3D. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. </description> </method> @@ -57,9 +57,9 @@ <argument index="0" name="body" type="Node"> </argument> <description> - If [code]true[/code], the given physics body overlaps the Area. + If [code]true[/code], the given physics body overlaps the Area3D. [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. - The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). + The [code]body[/code] argument can either be a [PhysicsBody3D] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </method> <method name="set_collision_layer_bit"> @@ -70,7 +70,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> - Set/clear individual bits on the layer mask. This simplifies editing this [Area]'s layers. + Set/clear individual bits on the layer mask. This simplifies editing this [Area3D]'s layers. </description> </method> <method name="set_collision_mask_bit"> @@ -81,7 +81,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> - Set/clear individual bits on the collision mask. This simplifies editing which [Area] layers this [Area] scans. + Set/clear individual bits on the collision mask. This simplifies editing which [Area3D] layers this [Area3D] scans. </description> </method> </methods> @@ -137,20 +137,20 @@ <member name="reverb_bus_uniformity" type="float" setter="set_reverb_uniformity" getter="get_reverb_uniformity" default="0.0"> The degree to which this area's reverb is a uniform effect. Ranges from [code]0[/code] to [code]1[/code] with [code]0.1[/code] precision. </member> - <member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" enum="Area.SpaceOverride" default="0"> + <member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" enum="Area3D.SpaceOverride" default="0"> Override mode for gravity and damping calculations within this area. See [enum SpaceOverride] for possible values. </member> </members> <signals> <signal name="area_entered"> - <argument index="0" name="area" type="Area"> + <argument index="0" name="area" type="Area3D"> </argument> <description> Emitted when another area enters. </description> </signal> <signal name="area_exited"> - <argument index="0" name="area" type="Area"> + <argument index="0" name="area" type="Area3D"> </argument> <description> Emitted when another area exits. @@ -159,7 +159,7 @@ <signal name="area_shape_entered"> <argument index="0" name="area_id" type="int"> </argument> - <argument index="1" name="area" type="Area"> + <argument index="1" name="area" type="Area3D"> </argument> <argument index="2" name="area_shape" type="int"> </argument> @@ -172,7 +172,7 @@ <signal name="area_shape_exited"> <argument index="0" name="area_id" type="int"> </argument> - <argument index="1" name="area" type="Area"> + <argument index="1" name="area" type="Area3D"> </argument> <argument index="2" name="area_shape" type="int"> </argument> @@ -187,7 +187,7 @@ </argument> <description> Emitted when a physics body enters. - The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). + The [code]body[/code] argument can either be a [PhysicsBody3D] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_exited"> @@ -195,7 +195,7 @@ </argument> <description> Emitted when a physics body exits. - The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). + The [code]body[/code] argument can either be a [PhysicsBody3D] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_shape_entered"> @@ -209,7 +209,7 @@ </argument> <description> Emitted when a physics body enters, reporting which shapes overlapped. - The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). + The [code]body[/code] argument can either be a [PhysicsBody3D] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_shape_exited"> @@ -223,7 +223,7 @@ </argument> <description> Emitted when a physics body exits, reporting which shapes were overlapping. - The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). + The [code]body[/code] argument can either be a [PhysicsBody3D] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> </signals> diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index 47abd2e996..9e742ea581 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -18,10 +18,10 @@ arrays[ArrayMesh.ARRAY_VERTEX] = vertices # Create the Mesh. arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays) - var m = MeshInstance.new() + var m = MeshInstance3D.new() m.mesh = arr_mesh [/codeblock] - The [MeshInstance] is ready to be added to the [SceneTree] to be shown. + The [MeshInstance3D] is ready to be added to the [SceneTree] to be shown. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/content/procedural_geometry/arraymesh.html</link> diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml index 4ec8dba2c6..3eeb524e9c 100644 --- a/doc/classes/AudioStreamPlayer3D.xml +++ b/doc/classes/AudioStreamPlayer3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamPlayer3D" inherits="Spatial" version="4.0"> +<class name="AudioStreamPlayer3D" inherits="Node3D" version="4.0"> <brief_description> Plays 3D sound in 3D space. </brief_description> diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 380e739f46..bffaf91e1d 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -634,8 +634,8 @@ The object's X axis will always face the camera. </constant> <constant name="BILLBOARD_PARTICLES" value="3" enum="BillboardMode"> - Used for particle systems when assigned to [Particles] and [CPUParticles] nodes. Enables [code]particles_anim_*[/code] properties. - The [member ParticlesMaterial.anim_speed] or [member CPUParticles.anim_speed] should also be set to a positive value for the animation to play. + Used for particle systems when assigned to [GPUParticles3D] and [CPUParticles3D] nodes. Enables [code]particles_anim_*[/code] properties. + The [member ParticlesMaterial.anim_speed] or [member CPUParticles3D.anim_speed] should also be set to a positive value for the animation to play. </constant> <constant name="TEXTURE_CHANNEL_RED" value="0" enum="TextureChannel"> Used to read from the red channel of a texture. diff --git a/doc/classes/BoneAttachment.xml b/doc/classes/BoneAttachment3D.xml index d15322254b..ab1e5b17d9 100644 --- a/doc/classes/BoneAttachment.xml +++ b/doc/classes/BoneAttachment3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BoneAttachment" inherits="Spatial" version="4.0"> +<class name="BoneAttachment3D" inherits="Node3D" version="4.0"> <brief_description> A node that will attach to a bone. </brief_description> <description> - This node must be the child of a [Skeleton] node. You can then select a bone for this node to attach to. The BoneAttachment node will copy the transform of the selected bone. + This node must be the child of a [Skeleton3D] node. You can then select a bone for this node to attach to. The BoneAttachment3D node will copy the transform of the selected bone. </description> <tutorials> </tutorials> diff --git a/doc/classes/BoxShape.xml b/doc/classes/BoxShape3D.xml index 3a5f05ef79..fd08da148d 100644 --- a/doc/classes/BoxShape.xml +++ b/doc/classes/BoxShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BoxShape" inherits="Shape" version="4.0"> +<class name="BoxShape3D" inherits="Shape3D" version="4.0"> <brief_description> Box shape resource. </brief_description> <description> - 3D box shape that can be a child of a [PhysicsBody] or [Area]. + 3D box shape that can be a child of a [PhysicsBody3D] or [Area3D]. </description> <tutorials> </tutorials> diff --git a/doc/classes/CPUParticles2D.xml b/doc/classes/CPUParticles2D.xml index 799ba32075..c2b821699d 100644 --- a/doc/classes/CPUParticles2D.xml +++ b/doc/classes/CPUParticles2D.xml @@ -5,7 +5,7 @@ </brief_description> <description> CPU-based 2D particle node used to create a variety of particle systems and effects. - See also [Particles2D], which provides the same functionality with hardware acceleration, but may not run on older devices. + See also [GPUParticles2D], which provides the same functionality with hardware acceleration, but may not run on older devices. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/2d/particle_systems_2d.html</link> @@ -17,7 +17,7 @@ <argument index="0" name="particles" type="Node"> </argument> <description> - Sets this node's properties to match a given [Particles2D] node with an assigned [ParticlesMaterial]. + Sets this node's properties to match a given [GPUParticles2D] node with an assigned [ParticlesMaterial]. </description> </method> <method name="get_param" qualifiers="const"> diff --git a/doc/classes/CPUParticles.xml b/doc/classes/CPUParticles3D.xml index 6a6525e99a..07da066bd9 100644 --- a/doc/classes/CPUParticles.xml +++ b/doc/classes/CPUParticles3D.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CPUParticles" inherits="GeometryInstance" version="4.0"> +<class name="CPUParticles3D" inherits="GeometryInstance3D" version="4.0"> <brief_description> CPU-based 3D particle emitter. </brief_description> <description> CPU-based 3D particle node used to create a variety of particle systems and effects. - See also [Particles], which provides the same functionality with hardware acceleration, but may not run on older devices. + See also [GPUParticles3D], which provides the same functionality with hardware acceleration, but may not run on older devices. </description> <tutorials> </tutorials> @@ -16,13 +16,13 @@ <argument index="0" name="particles" type="Node"> </argument> <description> - Sets this node's properties to match a given [Particles] node with an assigned [ParticlesMaterial]. + Sets this node's properties to match a given [GPUParticles3D] node with an assigned [ParticlesMaterial]. </description> </method> <method name="get_param" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="CPUParticles.Parameter"> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> </argument> <description> Returns the base value of the parameter specified by [enum Parameter]. @@ -31,7 +31,7 @@ <method name="get_param_curve" qualifiers="const"> <return type="Curve"> </return> - <argument index="0" name="param" type="int" enum="CPUParticles.Parameter"> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> </argument> <description> Returns the [Curve] of the parameter specified by [enum Parameter]. @@ -40,7 +40,7 @@ <method name="get_param_randomness" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="CPUParticles.Parameter"> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> </argument> <description> Returns the randomness factor of the parameter specified by [enum Parameter]. @@ -49,7 +49,7 @@ <method name="get_particle_flag" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="flag" type="int" enum="CPUParticles.Flags"> + <argument index="0" name="flag" type="int" enum="CPUParticles3D.Flags"> </argument> <description> Returns the enabled state of the given flag (see [enum Flags] for options). @@ -65,7 +65,7 @@ <method name="set_param"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="CPUParticles.Parameter"> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> </argument> <argument index="1" name="value" type="float"> </argument> @@ -76,7 +76,7 @@ <method name="set_param_curve"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="CPUParticles.Parameter"> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> </argument> <argument index="1" name="curve" type="Curve"> </argument> @@ -87,7 +87,7 @@ <method name="set_param_randomness"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="CPUParticles.Parameter"> + <argument index="0" name="param" type="int" enum="CPUParticles3D.Parameter"> </argument> <argument index="1" name="randomness" type="float"> </argument> @@ -98,7 +98,7 @@ <method name="set_particle_flag"> <return type="void"> </return> - <argument index="0" name="flag" type="int" enum="CPUParticles.Flags"> + <argument index="0" name="flag" type="int" enum="CPUParticles3D.Flags"> </argument> <argument index="1" name="enable" type="bool"> </argument> @@ -165,7 +165,7 @@ <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3( 1, 0, 0 )"> Unit vector specifying the particles' emission direction. </member> - <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles.DrawOrder" default="0"> + <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles3D.DrawOrder" default="0"> Particle draw order. Uses [enum DrawOrder] values. </member> <member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents"> @@ -180,7 +180,7 @@ <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array( )"> Sets the initial positions to spawn particles when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="CPUParticles.EmissionShape" default="0"> + <member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="CPUParticles3D.EmissionShape" default="0"> Particles will be emitted inside this region. See [enum EmissionShape] for possible values. </member> <member name="emission_sphere_radius" type="float" setter="set_emission_sphere_radius" getter="get_emission_sphere_radius"> diff --git a/doc/classes/Camera.xml b/doc/classes/Camera3D.xml index 6097721cbd..bfba23c7ee 100644 --- a/doc/classes/Camera.xml +++ b/doc/classes/Camera3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Camera" inherits="Spatial" version="4.0"> +<class name="Camera3D" inherits="Node3D" version="4.0"> <brief_description> Camera node, displays from a point of view. </brief_description> <description> - Camera is a special node that displays what is visible from its current location. Cameras register themselves in the nearest [Viewport] node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the camera will register in the global viewport. In other words, a camera just provides 3D display capabilities to a [Viewport], and, without one, a scene registered in that [Viewport] (or higher viewports) can't be displayed. + [Camera3D] is a special node that displays what is visible from its current location. Cameras register themselves in the nearest [Viewport] node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the camera will register in the global viewport. In other words, a camera just provides 3D display capabilities to a [Viewport], and, without one, a scene registered in that [Viewport] (or higher viewports) can't be displayed. </description> <tutorials> </tutorials> @@ -22,14 +22,14 @@ <return type="RID"> </return> <description> - Returns the camera's RID from the [VisualServer]. + Returns the camera's RID from the [RenderingServer]. </description> </method> <method name="get_camera_transform" qualifiers="const"> <return type="Transform"> </return> <description> - Gets the camera transform. Subclassed cameras such as [InterpolatedCamera] may provide different transforms than the [Node] transform. + Gets the camera transform. Subclassed cameras such as [ClippedCamera3D] may provide different transforms than the [Node] transform. </description> </method> <method name="get_cull_mask_bit" qualifiers="const"> @@ -172,7 +172,7 @@ <member name="current" type="bool" setter="set_current" getter="is_current" default="false"> If [code]true[/code], the ancestor [Viewport] is currently using this camera. </member> - <member name="doppler_tracking" type="int" setter="set_doppler_tracking" getter="get_doppler_tracking" enum="Camera.DopplerTracking" default="0"> + <member name="doppler_tracking" type="int" setter="set_doppler_tracking" getter="get_doppler_tracking" enum="Camera3D.DopplerTracking" default="0"> If not [constant DOPPLER_TRACKING_DISABLED], this camera will simulate the [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] for objects changed in particular [code]_process[/code] methods. See [enum DopplerTracking] for possible values. </member> <member name="effects" type="CameraEffects" setter="set_effects" getter="get_effects"> @@ -192,13 +192,13 @@ <member name="h_offset" type="float" setter="set_h_offset" getter="get_h_offset" default="0.0"> The horizontal (X) offset of the camera viewport. </member> - <member name="keep_aspect" type="int" setter="set_keep_aspect_mode" getter="get_keep_aspect_mode" enum="Camera.KeepAspect" default="1"> + <member name="keep_aspect" type="int" setter="set_keep_aspect_mode" getter="get_keep_aspect_mode" enum="Camera3D.KeepAspect" default="1"> The axis to lock during [member fov]/[member size] adjustments. Can be either [constant KEEP_WIDTH] or [constant KEEP_HEIGHT]. </member> <member name="near" type="float" setter="set_znear" getter="get_znear" default="0.05"> The distance to the near culling boundary for this camera relative to its local Z axis. </member> - <member name="projection" type="int" setter="set_projection" getter="get_projection" enum="Camera.Projection" default="0"> + <member name="projection" type="int" setter="set_projection" getter="get_projection" enum="Camera3D.Projection" default="0"> The camera's projection mode. In [constant PROJECTION_PERSPECTIVE] mode, objects' Z distance from the camera's local space scales their perceived size. </member> <member name="size" type="float" setter="set_size" getter="get_size" default="1.0"> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index 73ba8b392f..f2ce2a6fb9 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -426,7 +426,7 @@ <return type="RID"> </return> <description> - Returns the canvas item RID used by [VisualServer] for this item. + Returns the canvas item RID used by [RenderingServer] for this item. </description> </method> <method name="get_canvas_transform" qualifiers="const"> diff --git a/doc/classes/CanvasItemMaterial.xml b/doc/classes/CanvasItemMaterial.xml index ffe2272260..c2d44c1d17 100644 --- a/doc/classes/CanvasItemMaterial.xml +++ b/doc/classes/CanvasItemMaterial.xml @@ -18,7 +18,7 @@ The manner in which material reacts to lighting. </member> <member name="particles_anim_h_frames" type="int" setter="set_particles_anim_h_frames" getter="get_particles_anim_h_frames"> - The number of columns in the spritesheet assigned as [Texture2D] for a [Particles2D] or [CPUParticles2D]. + The number of columns in the spritesheet assigned as [Texture2D] for a [GPUParticles2D] or [CPUParticles2D]. [b]Note:[/b] This property is only used and visible in the editor if [member particles_animation] is [code]true[/code]. </member> <member name="particles_anim_loop" type="bool" setter="set_particles_anim_loop" getter="get_particles_anim_loop"> @@ -26,11 +26,11 @@ [b]Note:[/b] This property is only used and visible in the editor if [member particles_animation] is [code]true[/code]. </member> <member name="particles_anim_v_frames" type="int" setter="set_particles_anim_v_frames" getter="get_particles_anim_v_frames"> - The number of rows in the spritesheet assigned as [Texture2D] for a [Particles2D] or [CPUParticles2D]. + The number of rows in the spritesheet assigned as [Texture2D] for a [GPUParticles2D] or [CPUParticles2D]. [b]Note:[/b] This property is only used and visible in the editor if [member particles_animation] is [code]true[/code]. </member> <member name="particles_animation" type="bool" setter="set_particles_animation" getter="get_particles_animation" default="false"> - If [code]true[/code], enable spritesheet-based animation features when assigned to [Particles2D] and [CPUParticles2D] nodes. The [member ParticlesMaterial.anim_speed] or [member CPUParticles2D.anim_speed] should also be set to a positive value for the animation to play. + If [code]true[/code], enable spritesheet-based animation features when assigned to [GPUParticles2D] and [CPUParticles2D] nodes. The [member ParticlesMaterial.anim_speed] or [member CPUParticles2D.anim_speed] should also be set to a positive value for the animation to play. This property (and other [code]particles_anim_*[/code] properties that depend on it) has no effect on other types of nodes. </member> </members> diff --git a/doc/classes/CapsuleShape.xml b/doc/classes/CapsuleShape3D.xml index c83e832281..f56d94dc63 100644 --- a/doc/classes/CapsuleShape.xml +++ b/doc/classes/CapsuleShape3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CapsuleShape" inherits="Shape" version="4.0"> +<class name="CapsuleShape3D" inherits="Shape3D" version="4.0"> <brief_description> Capsule shape for collisions. </brief_description> diff --git a/doc/classes/ClippedCamera.xml b/doc/classes/ClippedCamera3D.xml index 4cdc098c2f..58ecec828d 100644 --- a/doc/classes/ClippedCamera.xml +++ b/doc/classes/ClippedCamera3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ClippedCamera" inherits="Camera" version="4.0"> +<class name="ClippedCamera3D" inherits="Camera3D" version="4.0"> <brief_description> - A [Camera] that includes collision. + A [Camera3D] that includes collision. </brief_description> <description> - This node extends [Camera] to add collisions with [Area] and/or [PhysicsBody] nodes. The camera cannot move through colliding objects. + This node extends [Camera3D] to add collisions with [Area3D] and/or [PhysicsBody3D] nodes. The camera cannot move through colliding objects. </description> <tutorials> </tutorials> @@ -84,10 +84,10 @@ </methods> <members> <member name="clip_to_areas" type="bool" setter="set_clip_to_areas" getter="is_clip_to_areas_enabled" default="false"> - If [code]true[/code], the camera stops on contact with [Area]s. + If [code]true[/code], the camera stops on contact with [Area3D]s. </member> <member name="clip_to_bodies" type="bool" setter="set_clip_to_bodies" getter="is_clip_to_bodies_enabled" default="true"> - If [code]true[/code], the camera stops on contact with [PhysicsBody]s. + If [code]true[/code], the camera stops on contact with [PhysicsBody3D]s. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The camera's collision mask. Only objects in at least one collision layer matching the mask will be detected. @@ -95,7 +95,7 @@ <member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0"> The camera's collision margin. The camera can't get closer than this distance to a colliding object. </member> - <member name="process_mode" type="int" setter="set_process_mode" getter="get_process_mode" enum="ClippedCamera.ProcessMode" default="0"> + <member name="process_mode" type="int" setter="set_process_mode" getter="get_process_mode" enum="ClippedCamera3D.ProcessMode" default="0"> The camera's process callback. See [enum ProcessMode]. </member> </members> diff --git a/doc/classes/CollisionObject.xml b/doc/classes/CollisionObject3D.xml index 34758d71b2..f8e897653d 100644 --- a/doc/classes/CollisionObject.xml +++ b/doc/classes/CollisionObject3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionObject" inherits="Spatial" version="4.0"> +<class name="CollisionObject3D" inherits="Node3D" version="4.0"> <brief_description> Base node for collision objects. </brief_description> <description> - CollisionObject is the base class for physics objects. It can hold any number of collision [Shape]s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods. + CollisionObject3D is the base class for physics objects. It can hold any number of collision [Shape3D]s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject3D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the [code]shape_owner_*[/code] methods. </description> <tutorials> </tutorials> @@ -23,7 +23,7 @@ <argument index="4" name="shape_idx" type="int"> </argument> <description> - Accepts unhandled [InputEvent]s. [code]click_position[/code] is the clicked location in world space and [code]click_normal[/code] is the normal vector extending from the clicked surface of the [Shape] at [code]shape_idx[/code]. Connect to the [code]input_event[/code] signal to easily pick up these events. + Accepts unhandled [InputEvent]s. [code]click_position[/code] is the clicked location in world space and [code]click_normal[/code] is the normal vector extending from the clicked surface of the [Shape3D] at [code]shape_idx[/code]. Connect to the [code]input_event[/code] signal to easily pick up these events. </description> </method> <method name="create_shape_owner"> @@ -81,10 +81,10 @@ </return> <argument index="0" name="owner_id" type="int"> </argument> - <argument index="1" name="shape" type="Shape"> + <argument index="1" name="shape" type="Shape3D"> </argument> <description> - Adds a [Shape] to the shape owner. + Adds a [Shape3D] to the shape owner. </description> </method> <method name="shape_owner_clear_shapes"> @@ -106,14 +106,14 @@ </description> </method> <method name="shape_owner_get_shape" qualifiers="const"> - <return type="Shape"> + <return type="Shape3D"> </return> <argument index="0" name="owner_id" type="int"> </argument> <argument index="1" name="shape_id" type="int"> </argument> <description> - Returns the [Shape] with the given id from the given shape owner. + Returns the [Shape3D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_shape_count" qualifiers="const"> @@ -133,7 +133,7 @@ <argument index="1" name="shape_id" type="int"> </argument> <description> - Returns the child index of the [Shape] with the given id from the given shape owner. + Returns the child index of the [Shape3D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_transform" qualifiers="const"> @@ -181,10 +181,10 @@ </methods> <members> <member name="input_capture_on_drag" type="bool" setter="set_capture_input_on_drag" getter="get_capture_input_on_drag" default="false"> - If [code]true[/code], the [CollisionObject] will continue to receive input events as the mouse is dragged across its shapes. + If [code]true[/code], the [CollisionObject3D] will continue to receive input events as the mouse is dragged across its shapes. </member> <member name="input_ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable" default="true"> - If [code]true[/code], the [CollisionObject]'s shapes will respond to [RayCast]s. + If [code]true[/code], the [CollisionObject3D]'s shapes will respond to [RayCast3D]s. </member> </members> <signals> diff --git a/doc/classes/CollisionPolygon.xml b/doc/classes/CollisionPolygon3D.xml index 8aceec17a8..dd3c57d1d0 100644 --- a/doc/classes/CollisionPolygon.xml +++ b/doc/classes/CollisionPolygon3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionPolygon" inherits="Spatial" version="4.0"> +<class name="CollisionPolygon3D" inherits="Node3D" version="4.0"> <brief_description> Editor-only class for defining a collision polygon in 3D space. </brief_description> <description> - Allows editing a collision polygon's vertices on a selected plane. Can also set a depth perpendicular to that plane. This class is only available in the editor. It will not appear in the scene tree at run-time. Creates a [Shape] for gameplay. Properties modified during gameplay will have no effect. + Allows editing a collision polygon's vertices on a selected plane. Can also set a depth perpendicular to that plane. This class is only available in the editor. It will not appear in the scene tree at run-time. Creates a [Shape3D] for gameplay. Properties modified during gameplay will have no effect. </description> <tutorials> </tutorials> diff --git a/doc/classes/CollisionShape.xml b/doc/classes/CollisionShape3D.xml index 7787bf957d..76515a65a7 100644 --- a/doc/classes/CollisionShape.xml +++ b/doc/classes/CollisionShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionShape" inherits="Spatial" version="4.0"> +<class name="CollisionShape3D" inherits="Node3D" version="4.0"> <brief_description> Node that represents collision shape data in 3D space. </brief_description> <description> - Editor facility for creating and editing collision shapes in 3D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area] to give it a detection shape, or add it to a [PhysicsBody] to create a solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method CollisionObject.shape_owner_get_shape] to get the actual shape. + Editor facility for creating and editing collision shapes in 3D space. You can use this node to represent all sorts of collision shapes, for example, add this to an [Area3D] to give it a detection shape, or add it to a [PhysicsBody3D] to create a solid object. [b]IMPORTANT[/b]: this is an Editor-only helper to create shapes, use [method CollisionObject3D.shape_owner_get_shape] to get the actual shape. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html</link> @@ -14,7 +14,7 @@ <return type="void"> </return> <description> - Sets the collision shape's shape to the addition of all its convexed [MeshInstance] siblings geometry. + Sets the collision shape's shape to the addition of all its convexed [MeshInstance3D] siblings geometry. </description> </method> <method name="resource_changed"> @@ -31,7 +31,7 @@ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false"> A disabled collision shape has no effect in the world. </member> - <member name="shape" type="Shape" setter="set_shape" getter="get_shape"> + <member name="shape" type="Shape3D" setter="set_shape" getter="get_shape"> The actual shape owned by this collision shape. </member> </members> diff --git a/doc/classes/ConcavePolygonShape.xml b/doc/classes/ConcavePolygonShape3D.xml index 47f2276c63..20402d350a 100644 --- a/doc/classes/ConcavePolygonShape.xml +++ b/doc/classes/ConcavePolygonShape3D.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConcavePolygonShape" inherits="Shape" version="4.0"> +<class name="ConcavePolygonShape3D" inherits="Shape3D" version="4.0"> <brief_description> Concave polygon shape. </brief_description> <description> - Concave polygon shape resource, which can be set into a [PhysicsBody] or area. This shape is created by feeding a list of triangles. - Note: when used for collision, [ConcavePolygonShape] is intended to work with static [PhysicsBody] nodes like [StaticBody] and will not work with [KinematicBody] or [RigidBody] with a mode other than Static. + Concave polygon shape resource, which can be set into a [PhysicsBody3D] or area. This shape is created by feeding a list of triangles. + Note: when used for collision, [ConcavePolygonShape3D] is intended to work with static [PhysicsBody3D] nodes like [StaticBody3D] and will not work with [KinematicBody3D] or [RigidBody3D] with a mode other than Static. </description> <tutorials> </tutorials> diff --git a/doc/classes/ConeTwistJoint.xml b/doc/classes/ConeTwistJoint3D.xml index 8682391a73..e86e95bec3 100644 --- a/doc/classes/ConeTwistJoint.xml +++ b/doc/classes/ConeTwistJoint3D.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConeTwistJoint" inherits="Joint" version="4.0"> +<class name="ConeTwistJoint3D" inherits="Joint3D" version="4.0"> <brief_description> A twist joint between two 3D bodies. </brief_description> <description> - The joint can rotate the bodies across an axis defined by the local x-axes of the [Joint]. - The twist axis is initiated as the X axis of the [Joint]. - Once the Bodies swing, the twist axis is calculated as the middle of the x-axes of the Joint in the local space of the two Bodies. + The joint can rotate the bodies across an axis defined by the local x-axes of the [Joint3D]. + The twist axis is initiated as the X axis of the [Joint3D]. + Once the Bodies swing, the twist axis is calculated as the middle of the x-axes of the Joint3D in the local space of the two Bodies. </description> <tutorials> </tutorials> @@ -14,7 +14,7 @@ <method name="get_param" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="ConeTwistJoint.Param"> + <argument index="0" name="param" type="int" enum="ConeTwistJoint3D.Param"> </argument> <description> </description> @@ -22,7 +22,7 @@ <method name="set_param"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="ConeTwistJoint.Param"> + <argument index="0" name="param" type="int" enum="ConeTwistJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> @@ -44,7 +44,7 @@ <member name="swing_span" type="float" setter="_set_swing_span" getter="_get_swing_span" default="45.0"> Swing is rotation from side to side, around the axis perpendicular to the twist axis. The swing span defines, how much rotation will not get corrected along the swing axis. - Could be defined as looseness in the [ConeTwistJoint]. + Could be defined as looseness in the [ConeTwistJoint3D]. If below 0.05, this behavior is locked. </member> <member name="twist_span" type="float" setter="_set_twist_span" getter="_get_twist_span" default="180.0"> @@ -56,7 +56,7 @@ <constant name="PARAM_SWING_SPAN" value="0" enum="Param"> Swing is rotation from side to side, around the axis perpendicular to the twist axis. The swing span defines, how much rotation will not get corrected along the swing axis. - Could be defined as looseness in the [ConeTwistJoint]. + Could be defined as looseness in the [ConeTwistJoint3D]. If below 0.05, this behavior is locked. </constant> <constant name="PARAM_TWIST_SPAN" value="1" enum="Param"> diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml index a16326d55a..522d484131 100644 --- a/doc/classes/ConfigFile.xml +++ b/doc/classes/ConfigFile.xml @@ -8,7 +8,7 @@ [codeblock] [section] some_key=42 - string_example="Hello World!" + string_example="Hello World3D!" a_vector=Vector3( 1, 0, 2 ) [/codeblock] The stored data can be saved to or parsed from a file, though ConfigFile objects can also be used directly without accessing the filesystem. diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index 801d9508dd..6d5871508b 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -22,8 +22,9 @@ </method> </methods> <members> - <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" override="true" default="Vector2( 200, 70 )" /> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Please Confirm..."" /> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i( 200, 70 )" /> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i( 200, 100 )" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Please Confirm..."" /> </members> <constants> </constants> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 89db5baf8a..85a75fda37 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -7,10 +7,12 @@ Base class for all UI-related nodes. [Control] features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change. For more information on Godot's UI system, anchors, margins, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from [Control] and [Container] nodes. [b]User Interface nodes and input[/b] - Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [method MainLoop._input_event]. Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. + Godot sends input events to the scene's root node first, by calling [method Node._input]. [method Node._input] forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls [code]MainLoop._input_event[/code]. + [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring. + Call [method accept_event] so no other node receives the event. Once you accepted an input, it becomes handled so [method Node._unhandled_input] will not process it. Only one [Control] node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call [method grab_focus]. [Control] nodes lose focus when another node grabs it, or if you hide the node in focus. Sets [member mouse_filter] to [constant MOUSE_FILTER_IGNORE] to tell a [Control] node to ignore mouse or touch events. You'll need it if you place an icon on top of a button. - [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_*_override[/code] methods, like [method add_font_override]. You can override the theme with the inspector. + [Theme] resources change the Control's appearance. If you change the [Theme] on a [Control] node, it affects all of its children. To override some of the theme's parameters, call one of the [code]add_theme_*_override[/code] methods, like [method add_theme_font_override]. You can override the theme with the inspector. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/gui/index.html</link> @@ -87,7 +89,7 @@ Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to [method Node._unhandled_input] or [method Node._unhandled_key_input]. </description> </method> - <method name="add_color_override"> + <method name="add_theme_color_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -98,7 +100,7 @@ Overrides the [Color] with given [code]name[/code] in the [member theme] resource the control uses. If the [code]color[/code] is empty or invalid, the override is cleared and the color from assigned [Theme] is used. </description> </method> - <method name="add_constant_override"> + <method name="add_theme_constant_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -109,7 +111,7 @@ Overrides an integer constant with given [code]name[/code] in the [member theme] resource the control uses. If the [code]constant[/code] is empty or invalid, the override is cleared and the constant from assigned [Theme] is used. </description> </method> - <method name="add_font_override"> + <method name="add_theme_font_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -120,7 +122,7 @@ Overrides the font with given [code]name[/code] in the [member theme] resource the control uses. If [code]font[/code] is empty or invalid, the override is cleared and the font from assigned [Theme] is used. </description> </method> - <method name="add_icon_override"> + <method name="add_theme_icon_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -131,7 +133,7 @@ Overrides the icon with given [code]name[/code] in the [member theme] resource the control uses. If [code]icon[/code] is empty or invalid, the override is cleared and the icon from assigned [Theme] is used. </description> </method> - <method name="add_shader_override"> + <method name="add_theme_shader_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -142,7 +144,7 @@ Overrides the [Shader] with given [code]name[/code] in the [member theme] resource the control uses. If [code]shader[/code] is empty or invalid, the override is cleared and the shader from assigned [Theme] is used. </description> </method> - <method name="add_stylebox_override"> + <method name="add_theme_stylebox_override"> <return type="void"> </return> <argument index="0" name="name" type="StringName"> @@ -217,21 +219,6 @@ Returns [member margin_left] and [member margin_top]. See also [member rect_position]. </description> </method> - <method name="get_color" qualifiers="const"> - <return type="Color"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - [codeblock] - func _ready(): - modulate = get_color("font_color", "Button") #get the color defined for button fonts - [/codeblock] - </description> - </method> <method name="get_combined_minimum_size" qualifiers="const"> <return type="Vector2"> </return> @@ -239,17 +226,6 @@ Returns combined minimum size from [member rect_min_size] and [method get_minimum_size]. </description> </method> - <method name="get_constant" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - </description> - </method> <method name="get_cursor_shape" qualifiers="const"> <return type="int" enum="Control.CursorShape"> </return> @@ -298,17 +274,6 @@ Returns the control that has the keyboard focus or [code]null[/code] if none. </description> </method> - <method name="get_font" qualifiers="const"> - <return type="Font"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - </description> - </method> <method name="get_global_rect" qualifiers="const"> <return type="Rect2"> </return> @@ -316,17 +281,6 @@ Returns the position and size of the control relative to the top-left corner of the screen. See [member rect_position] and [member rect_size]. </description> </method> - <method name="get_icon" qualifiers="const"> - <return type="Texture2D"> - </return> - <argument index="0" name="name" type="StringName"> - </argument> - <argument index="1" name="type" type="StringName" default=""""> - </argument> - <description> - Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. - </description> - </method> <method name="get_margin" qualifiers="const"> <return type="float"> </return> @@ -371,7 +325,55 @@ Returns the rotation (in radians). </description> </method> - <method name="get_stylebox" qualifiers="const"> + <method name="get_theme_color" qualifiers="const"> + <return type="Color"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns a color from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + [codeblock] + func _ready(): + modulate = get_theme_color("font_color", "Button") #get the color defined for button fonts + [/codeblock] + </description> + </method> + <method name="get_theme_constant" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns a constant from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + </description> + </method> + <method name="get_theme_font" qualifiers="const"> + <return type="Font"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns a font from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + </description> + </method> + <method name="get_theme_icon" qualifiers="const"> + <return type="Texture2D"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + Returns an icon from assigned [Theme] with given [code]name[/code] and associated with [Control] of given [code]type[/code]. + </description> + </method> + <method name="get_theme_stylebox" qualifiers="const"> <return type="StyleBox"> </return> <argument index="0" name="name" type="StringName"> @@ -409,7 +411,25 @@ Steal the focus from another control and become the focused control (see [member focus_mode]). </description> </method> - <method name="has_color" qualifiers="const"> + <method name="has_focus" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns [code]true[/code] if this is the current focused control. See [member focus_mode]. + </description> + </method> + <method name="has_point" qualifiers="virtual"> + <return type="bool"> + </return> + <argument index="0" name="point" type="Vector2"> + </argument> + <description> + Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control. + If not overridden, default behavior is checking if the point is within control's Rect. + [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code]. + </description> + </method> + <method name="has_theme_color" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -420,7 +440,7 @@ Returns [code]true[/code] if [Color] with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_color_override" qualifiers="const"> + <method name="has_theme_color_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -429,7 +449,7 @@ Returns [code]true[/code] if [Color] with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_constant" qualifiers="const"> + <method name="has_theme_constant" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -440,7 +460,7 @@ Returns [code]true[/code] if constant with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_constant_override" qualifiers="const"> + <method name="has_theme_constant_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -449,14 +469,7 @@ Returns [code]true[/code] if constant with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_focus" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if this is the current focused control. See [member focus_mode]. - </description> - </method> - <method name="has_font" qualifiers="const"> + <method name="has_theme_font" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -467,7 +480,7 @@ Returns [code]true[/code] if font with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_font_override" qualifiers="const"> + <method name="has_theme_font_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -476,7 +489,7 @@ Returns [code]true[/code] if font with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_icon" qualifiers="const"> + <method name="has_theme_icon" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -487,7 +500,7 @@ Returns [code]true[/code] if icon with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_icon_override" qualifiers="const"> + <method name="has_theme_icon_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -496,18 +509,7 @@ Returns [code]true[/code] if icon with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_point" qualifiers="virtual"> - <return type="bool"> - </return> - <argument index="0" name="point" type="Vector2"> - </argument> - <description> - Virtual method to be implemented by the user. Returns whether the given [code]point[/code] is inside this control. - If not overridden, default behavior is checking if the point is within control's Rect. - [b]Note:[/b] If you want to check if a point is inside the control, you can use [code]get_rect().has_point(point)[/code]. - </description> - </method> - <method name="has_shader_override" qualifiers="const"> + <method name="has_theme_shader_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -516,7 +518,7 @@ Returns [code]true[/code] if [Shader] with given [code]name[/code] has a valid override in this [Control] node. </description> </method> - <method name="has_stylebox" qualifiers="const"> + <method name="has_theme_stylebox" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -527,7 +529,7 @@ Returns [code]true[/code] if [StyleBox] with given [code]name[/code] and associated with [Control] of given [code]type[/code] exists in assigned [Theme]. </description> </method> - <method name="has_stylebox_override" qualifiers="const"> + <method name="has_theme_stylebox_override" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="name" type="StringName"> @@ -757,16 +759,6 @@ If [code]keep_margins[/code] is [code]true[/code], control's anchors will be updated instead of margins. </description> </method> - <method name="show_modal"> - <return type="void"> - </return> - <argument index="0" name="exclusive" type="bool" default="false"> - </argument> - <description> - Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus. - If [code]exclusive[/code] is [code]true[/code], other controls will not receive input and clicking outside this control will not close it. - </description> - </method> <method name="warp_mouse"> <return type="void"> </return> @@ -905,11 +897,6 @@ Emitted when the node's minimum size changes. </description> </signal> - <signal name="modal_closed"> - <description> - Emitted when a modal [Control] is closed. See [method show_modal]. - </description> - </signal> <signal name="mouse_entered"> <description> Emitted when the mouse enters the control's [code]Rect[/code] area, provided its [member mouse_filter] lets the event reach it. @@ -930,6 +917,10 @@ Emitted when one of the size flags changes. See [member size_flags_horizontal] and [member size_flags_vertical]. </description> </signal> + <signal name="theme_changed"> + <description> + </description> + </signal> </signals> <constants> <constant name="FOCUS_NONE" value="0" enum="FocusMode"> @@ -957,10 +948,7 @@ Sent when the node loses focus. </constant> <constant name="NOTIFICATION_THEME_CHANGED" value="45"> - Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_*_override[/code] methods. - </constant> - <constant name="NOTIFICATION_MODAL_CLOSE" value="46"> - Sent when an open modal dialog closes. See [method show_modal]. + Sent when the node's [member theme] changes, right before Godot redraws the control. Happens when you call one of the [code]add_theme_*_override[/code] methods. </constant> <constant name="NOTIFICATION_SCROLL_BEGIN" value="47"> Sent when this node is inside a [ScrollContainer] which has begun being scrolled. diff --git a/doc/classes/ConvexPolygonShape.xml b/doc/classes/ConvexPolygonShape3D.xml index 077bb57a03..c036f80e2d 100644 --- a/doc/classes/ConvexPolygonShape.xml +++ b/doc/classes/ConvexPolygonShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConvexPolygonShape" inherits="Shape" version="4.0"> +<class name="ConvexPolygonShape3D" inherits="Shape3D" version="4.0"> <brief_description> Convex polygon shape for 3D physics. </brief_description> <description> - Convex polygon shape resource, which can be added to a [PhysicsBody] or area. + Convex polygon shape resource, which can be added to a [PhysicsBody3D] or area. </description> <tutorials> </tutorials> diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index 5024cdefbd..fe454d90cc 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -4,7 +4,7 @@ Describes a Bézier curve in 3D space. </brief_description> <description> - This class describes a Bézier curve in 3D space. It is mainly used to give a shape to a [Path], but can be manually sampled for other purposes. + This class describes a Bézier curve in 3D space. It is mainly used to give a shape to a [Path3D], but can be manually sampled for other purposes. It keeps a cache of precalculated points along the curve, to speed up further calculations. </description> <tutorials> @@ -223,7 +223,7 @@ </argument> <description> Sets the tilt angle in radians for the point [code]idx[/code]. If the index is out of bounds, the function sends an error to the console. - The tilt controls the rotation along the look-at axis an object traveling the path would have. In the case of a curve controlling a [PathFollow], this tilt is an offset over the natural tilt the [PathFollow] calculates. + The tilt controls the rotation along the look-at axis an object traveling the path would have. In the case of a curve controlling a [PathFollow3D], this tilt is an offset over the natural tilt the [PathFollow3D] calculates. </description> </method> <method name="tessellate" qualifiers="const"> @@ -246,7 +246,7 @@ The distance in meters between two adjacent cached points. Changing it forces the cache to be recomputed the next time the [method get_baked_points] or [method get_baked_length] function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care. </member> <member name="up_vector_enabled" type="bool" setter="set_up_vector_enabled" getter="is_up_vector_enabled" default="true"> - If [code]true[/code], the curve will bake up vectors used for orientation. This is used when [member PathFollow.rotation_mode] is set to [constant PathFollow.ROTATION_ORIENTED]. Changing it forces the cache to be recomputed. + If [code]true[/code], the curve will bake up vectors used for orientation. This is used when [member PathFollow3D.rotation_mode] is set to [constant PathFollow3D.ROTATION_ORIENTED]. Changing it forces the cache to be recomputed. </member> </members> <constants> diff --git a/doc/classes/CylinderShape.xml b/doc/classes/CylinderShape3D.xml index 54adbd3b04..eb12568e71 100644 --- a/doc/classes/CylinderShape.xml +++ b/doc/classes/CylinderShape3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CylinderShape" inherits="Shape" version="4.0"> +<class name="CylinderShape3D" inherits="Shape3D" version="4.0"> <brief_description> Cylinder shape for collisions. </brief_description> diff --git a/doc/classes/DirectionalLight.xml b/doc/classes/DirectionalLight3D.xml index a3ef830d5d..a5d476f5c8 100644 --- a/doc/classes/DirectionalLight.xml +++ b/doc/classes/DirectionalLight3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="DirectionalLight" inherits="Light" version="4.0"> +<class name="DirectionalLight3D" inherits="Light3D" version="4.0"> <brief_description> Directional light from a distance, as from the Sun. </brief_description> <description> - A directional light is a type of [Light] node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene to model sunlight or moonlight. The worldspace location of the DirectionalLight transform (origin) is ignored. Only the basis is used to determine light direction. + A directional light is a type of [Light3D] node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene to model sunlight or moonlight. The worldspace location of the DirectionalLight3D transform (origin) is ignored. Only the basis is used to determine light direction. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/lights_and_shadows.html</link> @@ -18,7 +18,7 @@ <member name="directional_shadow_blend_splits" type="bool" setter="set_blend_splits" getter="is_blend_splits_enabled" default="false"> If [code]true[/code], shadow detail is sacrificed in exchange for smoother transitions between splits. </member> - <member name="directional_shadow_depth_range" type="int" setter="set_shadow_depth_range" getter="get_shadow_depth_range" enum="DirectionalLight.ShadowDepthRange" default="0"> + <member name="directional_shadow_depth_range" type="int" setter="set_shadow_depth_range" getter="get_shadow_depth_range" enum="DirectionalLight3D.ShadowDepthRange" default="0"> Optimizes shadow rendering for detail versus movement. See [enum ShadowDepthRange]. </member> <member name="directional_shadow_fade_start" type="float" setter="set_param" getter="get_param" default="0.8"> @@ -26,7 +26,7 @@ <member name="directional_shadow_max_distance" type="float" setter="set_param" getter="get_param" default="100.0"> The maximum distance for shadow splits. </member> - <member name="directional_shadow_mode" type="int" setter="set_shadow_mode" getter="get_shadow_mode" enum="DirectionalLight.ShadowMode" default="2"> + <member name="directional_shadow_mode" type="int" setter="set_shadow_mode" getter="get_shadow_mode" enum="DirectionalLight3D.ShadowMode" default="2"> The light's shadow rendering algorithm. See [enum ShadowMode]. </member> <member name="directional_shadow_normal_bias" type="float" setter="set_param" getter="get_param" default="0.8"> diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml new file mode 100644 index 0000000000..90828089f9 --- /dev/null +++ b/doc/classes/DisplayServer.xml @@ -0,0 +1,1049 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="DisplayServer" inherits="Object" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="alert"> + <return type="void"> + </return> + <argument index="0" name="text" type="String"> + </argument> + <argument index="1" name="title" type="String" default=""Alert!""> + </argument> + <description> + </description> + </method> + <method name="clipboard_get" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="clipboard_set"> + <return type="void"> + </return> + <argument index="0" name="clipboard" type="String"> + </argument> + <description> + </description> + </method> + <method name="console_set_visible"> + <return type="void"> + </return> + <argument index="0" name="console_visible" type="bool"> + </argument> + <description> + </description> + </method> + <method name="create_sub_window"> + <return type="int"> + </return> + <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode"> + </argument> + <argument index="1" name="rect" type="int"> + </argument> + <argument index="2" name="arg2" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="cursor_get_shape" qualifiers="const"> + <return type="int" enum="DisplayServer.CursorShape"> + </return> + <description> + </description> + </method> + <method name="cursor_set_custom_image"> + <return type="void"> + </return> + <argument index="0" name="cursor" type="Resource"> + </argument> + <argument index="1" name="shape" type="int" enum="DisplayServer.CursorShape" default="0"> + </argument> + <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="cursor_set_shape"> + <return type="void"> + </return> + <argument index="0" name="shape" type="int" enum="DisplayServer.CursorShape"> + </argument> + <description> + </description> + </method> + <method name="delete_sub_window"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="dialog_input_text"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="title" type="String"> + </argument> + <argument index="1" name="description" type="String"> + </argument> + <argument index="2" name="existing_text" type="String"> + </argument> + <argument index="3" name="callback" type="Callable"> + </argument> + <description> + </description> + </method> + <method name="dialog_show"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="title" type="String"> + </argument> + <argument index="1" name="description" type="String"> + </argument> + <argument index="2" name="buttons" type="PackedStringArray"> + </argument> + <argument index="3" name="callback" type="Callable"> + </argument> + <description> + </description> + </method> + <method name="enable_for_stealing_focus"> + <return type="void"> + </return> + <argument index="0" name="process_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="force_process_and_drop_events"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="get_latin_keyboard_variant" qualifiers="const"> + <return type="int" enum="DisplayServer.LatinKeyboardVariant"> + </return> + <description> + </description> + </method> + <method name="get_name" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="get_screen_count" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="get_swap_ok_cancel"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="get_window_at_screen_position" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <description> + </description> + </method> + <method name="get_window_list" qualifiers="const"> + <return type="PackedInt32Array"> + </return> + <description> + </description> + </method> + <method name="global_menu_add_check_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="label" type="String"> + </argument> + <argument index="2" name="callback" type="Callable"> + </argument> + <argument index="3" name="tag" type="Variant" default="null"> + </argument> + <description> + </description> + </method> + <method name="global_menu_add_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="label" type="String"> + </argument> + <argument index="2" name="callback" type="Callable"> + </argument> + <argument index="3" name="tag" type="Variant" default="null"> + </argument> + <description> + </description> + </method> + <method name="global_menu_add_separator"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_add_submenu_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="label" type="String"> + </argument> + <argument index="2" name="submenu" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_clear"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_callback"> + <return type="Callable"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_submenu"> + <return type="String"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_tag"> + <return type="Variant"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_get_item_text"> + <return type="String"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_is_item_checkable" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_is_item_checked" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_remove_item"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_callback"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="callback" type="Callable"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_checkable"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="checkable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_checked"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="checked" type="bool"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_submenu"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="submenu" type="String"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_tag"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="tag" type="Variant"> + </argument> + <description> + </description> + </method> + <method name="global_menu_set_item_text"> + <return type="void"> + </return> + <argument index="0" name="menu_root" type="String"> + </argument> + <argument index="1" name="idx" type="int"> + </argument> + <argument index="2" name="text" type="String"> + </argument> + <description> + </description> + </method> + <method name="has_feature" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="feature" type="int" enum="DisplayServer.Feature"> + </argument> + <description> + </description> + </method> + <method name="ime_get_selection" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="ime_get_text" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="is_console_visible" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="mouse_get_absolute_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="mouse_get_button_state" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="mouse_get_mode" qualifiers="const"> + <return type="int" enum="DisplayServer.MouseMode"> + </return> + <description> + </description> + </method> + <method name="mouse_get_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="mouse_set_mode"> + <return type="void"> + </return> + <argument index="0" name="mouse_mode" type="int" enum="DisplayServer.MouseMode"> + </argument> + <description> + </description> + </method> + <method name="mouse_warp_to_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <description> + </description> + </method> + <method name="native_video_is_playing" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="native_video_pause"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="native_video_play"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="path" type="String"> + </argument> + <argument index="1" name="volume" type="float"> + </argument> + <argument index="2" name="audio_track" type="String"> + </argument> + <argument index="3" name="subtitle_track" type="String"> + </argument> + <argument index="4" name="arg4" type="int"> + </argument> + <description> + </description> + </method> + <method name="native_video_stop"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="native_video_unpause"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="process_events"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="screen_get_dpi" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_orientation" qualifiers="const"> + <return type="int" enum="DisplayServer.ScreenOrientation"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_scale" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_get_usable_rect" qualifiers="const"> + <return type="Rect2i"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_is_kept_on" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="screen_is_touchscreen" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="screen_set_keep_on"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="screen_set_orientation"> + <return type="void"> + </return> + <argument index="0" name="orientation" type="int" enum="DisplayServer.ScreenOrientation"> + </argument> + <argument index="1" name="screen" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="set_icon"> + <return type="void"> + </return> + <argument index="0" name="image" type="Image"> + </argument> + <description> + </description> + </method> + <method name="set_native_icon"> + <return type="void"> + </return> + <argument index="0" name="filename" type="String"> + </argument> + <description> + </description> + </method> + <method name="virtual_keyboard_get_height" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="virtual_keyboard_hide"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="virtual_keyboard_show"> + <return type="void"> + </return> + <argument index="0" name="existing_text" type="String"> + </argument> + <argument index="1" name="position" type="Rect2" default="Rect2i( 0, 0, 0, 0 )"> + </argument> + <argument index="2" name="max_length" type="int" default="-1"> + </argument> + <description> + </description> + </method> + <method name="vsync_is_enabled" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="vsync_is_using_via_compositor" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="vsync_set_enabled"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + <method name="vsync_set_use_via_compositor"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + <method name="window_attach_instance_id"> + <return type="void"> + </return> + <argument index="0" name="instance_id" type="int"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_can_draw" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_attached_instance_id" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_current_screen" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_flag" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_max_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_min_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_mode" qualifiers="const"> + <return type="int" enum="DisplayServer.WindowMode"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_position" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_real_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_get_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_move_to_foreground"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_request_attention"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_current_screen"> + <return type="void"> + </return> + <argument index="0" name="screen" type="int"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_drop_files_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_flag"> + <return type="void"> + </return> + <argument index="0" name="flag" type="int" enum="DisplayServer.WindowFlags"> + </argument> + <argument index="1" name="enabled" type="bool"> + </argument> + <argument index="2" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_ime_active"> + <return type="void"> + </return> + <argument index="0" name="active" type="bool"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_ime_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_input_event_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_input_text_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_max_size"> + <return type="void"> + </return> + <argument index="0" name="max_size" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_min_size"> + <return type="void"> + </return> + <argument index="0" name="min_size" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_mode"> + <return type="void"> + </return> + <argument index="0" name="mode" type="int" enum="DisplayServer.WindowMode"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_rect_changed_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_size"> + <return type="void"> + </return> + <argument index="0" name="size" type="Vector2i"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_title"> + <return type="void"> + </return> + <argument index="0" name="title" type="String"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + <method name="window_set_transient"> + <return type="void"> + </return> + <argument index="0" name="window_id" type="int"> + </argument> + <argument index="1" name="parent_window_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="window_set_window_event_callback"> + <return type="void"> + </return> + <argument index="0" name="callback" type="Callable"> + </argument> + <argument index="1" name="window_id" type="int" default="0"> + </argument> + <description> + </description> + </method> + </methods> + <constants> + <constant name="FEATURE_GLOBAL_MENU" value="0" enum="Feature"> + </constant> + <constant name="FEATURE_SUBWINDOWS" value="1" enum="Feature"> + </constant> + <constant name="FEATURE_TOUCHSCREEN" value="2" enum="Feature"> + </constant> + <constant name="FEATURE_MOUSE" value="3" enum="Feature"> + </constant> + <constant name="FEATURE_MOUSE_WARP" value="4" enum="Feature"> + </constant> + <constant name="FEATURE_CLIPBOARD" value="5" enum="Feature"> + </constant> + <constant name="FEATURE_VIRTUAL_KEYBOARD" value="6" enum="Feature"> + </constant> + <constant name="FEATURE_CURSOR_SHAPE" value="7" enum="Feature"> + </constant> + <constant name="FEATURE_CUSTOM_CURSOR_SHAPE" value="8" enum="Feature"> + </constant> + <constant name="FEATURE_NATIVE_VIDEO" value="9" enum="Feature"> + </constant> + <constant name="FEATURE_NATIVE_DIALOG" value="10" enum="Feature"> + </constant> + <constant name="FEATURE_CONSOLE_WINDOW" value="11" enum="Feature"> + </constant> + <constant name="FEATURE_IME" value="12" enum="Feature"> + </constant> + <constant name="FEATURE_WINDOW_TRANSPARENCY" value="13" enum="Feature"> + </constant> + <constant name="FEATURE_HIDPI" value="14" enum="Feature"> + </constant> + <constant name="FEATURE_ICON" value="15" enum="Feature"> + </constant> + <constant name="FEATURE_NATIVE_ICON" value="16" enum="Feature"> + </constant> + <constant name="FEATURE_ORIENTATION" value="17" enum="Feature"> + </constant> + <constant name="FEATURE_SWAP_BUFFERS" value="18" enum="Feature"> + </constant> + <constant name="MOUSE_MODE_VISIBLE" value="0" enum="MouseMode"> + </constant> + <constant name="MOUSE_MODE_HIDDEN" value="1" enum="MouseMode"> + </constant> + <constant name="MOUSE_MODE_CAPTURED" value="2" enum="MouseMode"> + </constant> + <constant name="MOUSE_MODE_CONFINED" value="3" enum="MouseMode"> + </constant> + <constant name="SCREEN_OF_MAIN_WINDOW" value="-1"> + </constant> + <constant name="MAIN_WINDOW_ID" value="0"> + </constant> + <constant name="INVALID_WINDOW_ID" value="-1"> + </constant> + <constant name="SCREEN_LANDSCAPE" value="0" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_PORTRAIT" value="1" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_REVERSE_LANDSCAPE" value="2" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_REVERSE_PORTRAIT" value="3" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_SENSOR_LANDSCAPE" value="4" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_SENSOR_PORTRAIT" value="5" enum="ScreenOrientation"> + </constant> + <constant name="SCREEN_SENSOR" value="6" enum="ScreenOrientation"> + </constant> + <constant name="CURSOR_ARROW" value="0" enum="CursorShape"> + </constant> + <constant name="CURSOR_IBEAM" value="1" enum="CursorShape"> + </constant> + <constant name="CURSOR_POINTING_HAND" value="2" enum="CursorShape"> + </constant> + <constant name="CURSOR_CROSS" value="3" enum="CursorShape"> + </constant> + <constant name="CURSOR_WAIT" value="4" enum="CursorShape"> + </constant> + <constant name="CURSOR_BUSY" value="5" enum="CursorShape"> + </constant> + <constant name="CURSOR_DRAG" value="6" enum="CursorShape"> + </constant> + <constant name="CURSOR_CAN_DROP" value="7" enum="CursorShape"> + </constant> + <constant name="CURSOR_FORBIDDEN" value="8" enum="CursorShape"> + </constant> + <constant name="CURSOR_VSIZE" value="9" enum="CursorShape"> + </constant> + <constant name="CURSOR_HSIZE" value="10" enum="CursorShape"> + </constant> + <constant name="CURSOR_BDIAGSIZE" value="11" enum="CursorShape"> + </constant> + <constant name="CURSOR_FDIAGSIZE" value="12" enum="CursorShape"> + </constant> + <constant name="CURSOR_MOVE" value="13" enum="CursorShape"> + </constant> + <constant name="CURSOR_VSPLIT" value="14" enum="CursorShape"> + </constant> + <constant name="CURSOR_HSPLIT" value="15" enum="CursorShape"> + </constant> + <constant name="CURSOR_HELP" value="16" enum="CursorShape"> + </constant> + <constant name="CURSOR_MAX" value="17" enum="CursorShape"> + </constant> + <constant name="WINDOW_MODE_WINDOWED" value="0" enum="WindowMode"> + </constant> + <constant name="WINDOW_MODE_MINIMIZED" value="1" enum="WindowMode"> + </constant> + <constant name="WINDOW_MODE_MAXIMIZED" value="2" enum="WindowMode"> + </constant> + <constant name="WINDOW_MODE_FULLSCREEN" value="3" enum="WindowMode"> + </constant> + <constant name="WINDOW_FLAG_RESIZE_DISABLED" value="0" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_BORDERLESS" value="1" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_ALWAYS_ON_TOP" value="2" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_TRANSPARENT" value="3" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_NO_FOCUS" value="4" enum="WindowFlags"> + </constant> + <constant name="WINDOW_FLAG_MAX" value="5" enum="WindowFlags"> + </constant> + <constant name="LATIN_KEYBOARD_QWERTY" value="0" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_QWERTZ" value="1" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_AZERTY" value="2" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_QZERTY" value="3" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_DVORAK" value="4" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_NEO" value="5" enum="LatinKeyboardVariant"> + </constant> + <constant name="LATIN_KEYBOARD_COLEMAK" value="6" enum="LatinKeyboardVariant"> + </constant> + <constant name="WINDOW_EVENT_MOUSE_ENTER" value="0" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_MOUSE_EXIT" value="1" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_FOCUS_IN" value="2" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_FOCUS_OUT" value="3" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_CLOSE_REQUEST" value="4" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_GO_BACK_REQUEST" value="5" enum="WindowEvent"> + </constant> + <constant name="WINDOW_EVENT_DPI_CHANGE" value="6" enum="WindowEvent"> + </constant> + </constants> +</class> diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml index 8fac3e950d..8cfd3b63d6 100644 --- a/doc/classes/EditorExportPlugin.xml +++ b/doc/classes/EditorExportPlugin.xml @@ -94,6 +94,14 @@ <description> </description> </method> + <method name="add_ios_project_static_lib"> + <return type="void"> + </return> + <argument index="0" name="path" type="String"> + </argument> + <description> + </description> + </method> <method name="add_shared_object"> <return type="void"> </return> diff --git a/doc/classes/EditorFeatureProfile.xml b/doc/classes/EditorFeatureProfile.xml index 75b906d6d2..53db8dd293 100644 --- a/doc/classes/EditorFeatureProfile.xml +++ b/doc/classes/EditorFeatureProfile.xml @@ -5,7 +5,7 @@ </brief_description> <description> An editor feature profile can be used to disable specific features of the Godot editor. When disabled, the features won't appear in the editor, which makes the editor less cluttered. This is useful in education settings to reduce confusion or when working in a team. For example, artists and level designers could use a feature profile that disables the script editor to avoid accidentally making changes to files they aren't supposed to edit. - To manage editor feature profiles visually, use [b]Editor > Manage Feature Profiles...[/b] at the top of the editor window. + To manage editor feature profiles visually, use [b]Editor > Manage Feature Profiles...[/b] at the top of the editor window. </description> <tutorials> </tutorials> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index 3e6bbd682d..084459e518 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -60,14 +60,13 @@ <member name="display_mode" type="int" setter="set_display_mode" getter="get_display_mode" enum="EditorFileDialog.DisplayMode" default="0"> The view format in which the [EditorFileDialog] displays resources to the user. </member> - <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="EditorFileDialog.Mode" default="4"> - The purpose of the [EditorFileDialog], which defines the allowed behaviors. + <member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="EditorFileDialog.FileMode" default="4"> + The dialog's open or save mode, which affects the selection behavior. See [enum FileMode] </member> - <member name="resizable" type="bool" setter="set_resizable" getter="get_resizable" override="true" default="true" /> <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false"> If [code]true[/code], hidden files and directories will be visible in the [EditorFileDialog]. </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> @@ -93,19 +92,19 @@ </signal> </signals> <constants> - <constant name="MODE_OPEN_FILE" value="0" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILE" value="0" enum="FileMode"> The [EditorFileDialog] can select only one file. Accepting the window will open the file. </constant> - <constant name="MODE_OPEN_FILES" value="1" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILES" value="1" enum="FileMode"> The [EditorFileDialog] can select multiple files. Accepting the window will open all files. </constant> - <constant name="MODE_OPEN_DIR" value="2" enum="Mode"> + <constant name="FILE_MODE_OPEN_DIR" value="2" enum="FileMode"> The [EditorFileDialog] can select only one directory. Accepting the window will open the directory. </constant> - <constant name="MODE_OPEN_ANY" value="3" enum="Mode"> + <constant name="FILE_MODE_OPEN_ANY" value="3" enum="FileMode"> The [EditorFileDialog] can select a file or directory. Accepting the window will open it. </constant> - <constant name="MODE_SAVE_FILE" value="4" enum="Mode"> + <constant name="FILE_MODE_SAVE_FILE" value="4" enum="FileMode"> The [EditorFileDialog] can select only one file. Accepting the window will save the file. </constant> <constant name="ACCESS_RESOURCES" value="0" enum="Access"> diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorNode3DGizmo.xml index b8c4daab07..6d695ddeea 100644 --- a/doc/classes/EditorSpatialGizmo.xml +++ b/doc/classes/EditorNode3DGizmo.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorSpatialGizmo" inherits="SpatialGizmo" version="4.0"> +<class name="EditorNode3DGizmo" inherits="Node3DGizmo" version="4.0"> <brief_description> - Custom gizmo for editing Spatial objects. + Custom gizmo for editing Node3D objects. </brief_description> <description> - Custom gizmo that is used for providing custom visualization and editing (handles) for 3D Spatial objects. See [EditorSpatialGizmoPlugin] for more information. + Custom gizmo that is used for providing custom visualization and editing (handles) for Node3D objects. See [EditorNode3DGizmoPlugin] for more information. </description> <tutorials> </tutorials> @@ -124,17 +124,17 @@ </description> </method> <method name="get_plugin" qualifiers="const"> - <return type="EditorSpatialGizmoPlugin"> + <return type="EditorNode3DGizmoPlugin"> </return> <description> - Returns the [EditorSpatialGizmoPlugin] that owns this gizmo. It's useful to retrieve materials using [method EditorSpatialGizmoPlugin.get_material]. + Returns the [EditorNode3DGizmoPlugin] that owns this gizmo. It's useful to retrieve materials using [method EditorNode3DGizmoPlugin.get_material]. </description> </method> <method name="get_spatial_node" qualifiers="const"> - <return type="Spatial"> + <return type="Node3D"> </return> <description> - Returns the Spatial node associated with this gizmo. + Returns the Node3D node associated with this gizmo. </description> </method> <method name="is_handle_highlighted" qualifiers="virtual"> @@ -150,7 +150,7 @@ <return type="void"> </return> <description> - This function is called when the Spatial this gizmo refers to changes (the [method Spatial.update_gizmo] is called). + This function is called when the Node3D this gizmo refers to changes (the [method Node3D.update_gizmo] is called). </description> </method> <method name="set_handle" qualifiers="virtual"> @@ -158,13 +158,13 @@ </return> <argument index="0" name="index" type="int"> </argument> - <argument index="1" name="camera" type="Camera"> + <argument index="1" name="camera" type="Camera3D"> </argument> <argument index="2" name="point" type="Vector2"> </argument> <description> This function is used when the user drags a gizmo handle (previously added with [method add_handles]) in screen coordinates. - The [Camera] is also provided so screen coordinates can be converted to raycasts. + The [Camera3D] is also provided so screen coordinates can be converted to raycasts. </description> </method> <method name="set_hidden"> diff --git a/doc/classes/EditorSpatialGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index b1a4a25a5f..ca75b47fbf 100644 --- a/doc/classes/EditorSpatialGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorSpatialGizmoPlugin" inherits="Resource" version="4.0"> +<class name="EditorNode3DGizmoPlugin" inherits="Resource" version="4.0"> <brief_description> - Used by the editor to define Spatial gizmo types. + Used by the editor to define Node3D gizmo types. </brief_description> <description> - EditorSpatialGizmoPlugin allows you to define a new type of Gizmo. There are two main ways to do so: extending [EditorSpatialGizmoPlugin] for the simpler gizmos, or creating a new [EditorSpatialGizmo] type. See the tutorial in the documentation for more info. + EditorNode3DGizmoPlugin allows you to define a new type of Gizmo. There are two main ways to do so: extending [EditorNode3DGizmoPlugin] for the simpler gizmos, or creating a new [EditorNode3DGizmo] type. See the tutorial in the documentation for more info. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/plugins/editor/spatial_gizmos.html</link> @@ -31,7 +31,7 @@ <method name="commit_handle" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="gizmo" type="EditorSpatialGizmo"> + <argument index="0" name="gizmo" type="EditorNode3DGizmo"> </argument> <argument index="1" name="index" type="int"> </argument> @@ -44,12 +44,12 @@ </description> </method> <method name="create_gizmo" qualifiers="virtual"> - <return type="EditorSpatialGizmo"> + <return type="EditorNode3DGizmo"> </return> - <argument index="0" name="spatial" type="Spatial"> + <argument index="0" name="spatial" type="Node3D"> </argument> <description> - Override this method to return a custom [EditorSpatialGizmo] for the spatial nodes of your choice, return [code]null[/code] for the rest of nodes. See also [method has_gizmo]. + Override this method to return a custom [EditorNode3DGizmo] for the spatial nodes of your choice, return [code]null[/code] for the rest of nodes. See also [method has_gizmo]. </description> </method> <method name="create_handle_material"> @@ -60,7 +60,7 @@ <argument index="1" name="billboard" type="bool" default="false"> </argument> <description> - Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorSpatialGizmo.add_handles]. Should not be overridden. + Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_handles]. Should not be overridden. </description> </method> <method name="create_icon_material"> @@ -75,7 +75,7 @@ <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> <description> - Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorSpatialGizmo.add_unscaled_billboard]. Should not be overridden. + Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_unscaled_billboard]. Should not be overridden. </description> </method> <method name="create_material"> @@ -92,13 +92,13 @@ <argument index="4" name="use_vertex_color" type="bool" default="false"> </argument> <description> - Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorSpatialGizmo.add_mesh] and [method EditorSpatialGizmo.add_lines]. Should not be overridden. + Creates an unshaded material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_mesh] and [method EditorNode3DGizmo.add_lines]. Should not be overridden. </description> </method> <method name="get_handle_name" qualifiers="virtual"> <return type="String"> </return> - <argument index="0" name="gizmo" type="EditorSpatialGizmo"> + <argument index="0" name="gizmo" type="EditorNode3DGizmo"> </argument> <argument index="1" name="index" type="int"> </argument> @@ -109,7 +109,7 @@ <method name="get_handle_value" qualifiers="virtual"> <return type="Variant"> </return> - <argument index="0" name="gizmo" type="EditorSpatialGizmo"> + <argument index="0" name="gizmo" type="EditorNode3DGizmo"> </argument> <argument index="1" name="index" type="int"> </argument> @@ -122,10 +122,10 @@ </return> <argument index="0" name="name" type="String"> </argument> - <argument index="1" name="gizmo" type="EditorSpatialGizmo"> + <argument index="1" name="gizmo" type="EditorNode3DGizmo"> </argument> <description> - Gets material from the internal list of materials. If an [EditorSpatialGizmo] is provided, it will try to get the corresponding variant (selected and/or editable). + Gets material from the internal list of materials. If an [EditorNode3DGizmo] is provided, it will try to get the corresponding variant (selected and/or editable). </description> </method> <method name="get_name" qualifiers="virtual"> @@ -144,16 +144,16 @@ <method name="has_gizmo" qualifiers="virtual"> <return type="bool"> </return> - <argument index="0" name="spatial" type="Spatial"> + <argument index="0" name="spatial" type="Node3D"> </argument> <description> - Override this method to define which Spatial nodes have a gizmo from this plugin. Whenever a [Spatial] node is added to a scene this method is called, if it returns [code]true[/code] the node gets a generic [EditorSpatialGizmo] assigned and is added to this plugin's list of active gizmos. + Override this method to define which Node3D nodes have a gizmo from this plugin. Whenever a [Node3D] node is added to a scene this method is called, if it returns [code]true[/code] the node gets a generic [EditorNode3DGizmo] assigned and is added to this plugin's list of active gizmos. </description> </method> <method name="is_handle_highlighted" qualifiers="virtual"> <return type="bool"> </return> - <argument index="0" name="gizmo" type="EditorSpatialGizmo"> + <argument index="0" name="gizmo" type="EditorNode3DGizmo"> </argument> <argument index="1" name="index" type="int"> </argument> @@ -165,13 +165,13 @@ <return type="bool"> </return> <description> - Override this method to define whether Spatial with this gizmo should be selecteble even when the gizmo is hidden. + Override this method to define whether Node3D with this gizmo should be selecteble even when the gizmo is hidden. </description> </method> <method name="redraw" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="gizmo" type="EditorSpatialGizmo"> + <argument index="0" name="gizmo" type="EditorNode3DGizmo"> </argument> <description> Callback to redraw the provided gizmo. Called for this plugin's active gizmos. @@ -180,11 +180,11 @@ <method name="set_handle" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="gizmo" type="EditorSpatialGizmo"> + <argument index="0" name="gizmo" type="EditorNode3DGizmo"> </argument> <argument index="1" name="index" type="int"> </argument> - <argument index="2" name="camera" type="Camera"> + <argument index="2" name="camera" type="Camera3D"> </argument> <argument index="3" name="point" type="Vector2"> </argument> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 587fd51f1e..19583fca28 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -71,7 +71,7 @@ </argument> <description> Adds a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed. - When given node or resource is selected, the base type will be instanced (e.g. "Spatial", "Control", "Resource"), then the script will be loaded and set to this object. + When given node or resource is selected, the base type will be instanced (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object. You can use the virtual method [method handles] to check if your custom object is being edited by checking the script or using the [code]is[/code] keyword. During run-time, this will be a simple object with a script so this function does not need to be called then. </description> @@ -111,7 +111,7 @@ <method name="add_spatial_gizmo_plugin"> <return type="void"> </return> - <argument index="0" name="plugin" type="EditorSpatialGizmoPlugin"> + <argument index="0" name="plugin" type="EditorNode3DGizmoPlugin"> </argument> <description> </description> @@ -229,7 +229,7 @@ <method name="forward_spatial_gui_input" qualifiers="virtual"> <return type="bool"> </return> - <argument index="0" name="camera" type="Camera"> + <argument index="0" name="camera" type="Camera3D"> </argument> <argument index="1" name="event" type="InputEvent"> </argument> @@ -450,7 +450,7 @@ <method name="remove_spatial_gizmo_plugin"> <return type="void"> </return> - <argument index="0" name="plugin" type="EditorSpatialGizmoPlugin"> + <argument index="0" name="plugin" type="EditorNode3DGizmoPlugin"> </argument> <description> </description> diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index f5c04b3947..6f55bfc229 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -108,7 +108,7 @@ If [code]true[/code], the depth fog effect is enabled. When enabled, fog will appear in the distance (relative to the camera). </member> <member name="fog_depth_end" type="float" setter="set_fog_depth_end" getter="get_fog_depth_end" default="100.0"> - The fog's depth end distance from the camera. If this value is set to 0, it will be equal to the current camera's [member Camera.far] value. + The fog's depth end distance from the camera. If this value is set to 0, it will be equal to the current camera's [member Camera3D.far] value. </member> <member name="fog_enabled" type="bool" setter="set_fog_enabled" getter="is_fog_enabled" default="false"> If [code]true[/code], fog effects are enabled. [member fog_height_enabled] and/or [member fog_depth_enabled] must be set to [code]true[/code] to actually display fog. @@ -126,7 +126,7 @@ The Y coordinate where the height fog will be the least intense. If this value is greater than [member fog_height_max], fog will be displayed from top to bottom. Otherwise, it will be displayed from bottom to top. </member> <member name="fog_sun_amount" type="float" setter="set_fog_sun_amount" getter="get_fog_sun_amount" default="0.0"> - The intensity of the depth fog color transition when looking towards the sun. The sun's direction is determined automatically using the DirectionalLight node in the scene. + The intensity of the depth fog color transition when looking towards the sun. The sun's direction is determined automatically using the DirectionalLight3D node in the scene. </member> <member name="fog_sun_color" type="Color" setter="set_fog_sun_color" getter="get_fog_sun_color" default="Color( 1, 0.9, 0.7, 1 )"> The depth fog's [Color] when looking towards the sun. @@ -137,10 +137,6 @@ <member name="fog_transmit_enabled" type="bool" setter="set_fog_transmit_enabled" getter="is_fog_transmit_enabled" default="false"> Enables fog's light transmission effect. If [code]true[/code], light will be more visible in the fog to simulate light scattering as in real life. </member> - <member name="glow_bicubic_upscale" type="bool" setter="set_glow_bicubic_upscale" getter="is_glow_bicubic_upscale_enabled" default="false"> - Smooths out the blockiness created by sampling higher levels, at the cost of performance. - [b]Note:[/b] When using the GLES2 renderer, this is only available if the GPU supports the [code]GL_EXT_gpu_shader4[/code] extension. - </member> <member name="glow_blend_mode" type="int" setter="set_glow_blend_mode" getter="get_glow_blend_mode" enum="Environment.GlowBlendMode" default="2"> The glow blending mode. </member> @@ -212,9 +208,6 @@ <member name="ss_reflections_max_steps" type="int" setter="set_ssr_max_steps" getter="get_ssr_max_steps" default="64"> The maximum number of steps for screen-space reflections. Higher values are slower. </member> - <member name="ss_reflections_roughness" type="bool" setter="set_ssr_rough" getter="is_ssr_rough" default="true"> - If [code]true[/code], screen-space reflections will take the material roughness into account. - </member> <member name="ssao_ao_channel_affect" type="float" setter="set_ssao_ao_channel_affect" getter="get_ssao_ao_channel_affect" default="0.0"> The screen-space ambient occlusion intensity on materials that have an AO texture defined. Values higher than [code]0[/code] will make the SSAO effect visible in areas darkened by AO textures. </member> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 78fcec33ea..99563ee367 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -68,19 +68,19 @@ The currently selected file path of the file dialog. </member> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> + <member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="FileDialog.FileMode" default="4"> + The dialog's open or save mode, which affects the selection behavior. See [enum FileMode]. + </member> <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray( )"> The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code]. </member> - <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="FileDialog.Mode" default="4"> - The dialog's open or save mode, which affects the selection behavior. See enum [code]Mode[/code] constants. - </member> <member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true"> - If [code]true[/code], changing the [code]Mode[/code] property will set the window title accordingly (e.g. setting mode to [constant MODE_OPEN_FILE] will change the window title to "Open a File"). + If [code]true[/code], changing the [code]Mode[/code] property will set the window title accordingly (e.g. setting mode to [constant FILE_MODE_OPEN_FILE] will change the window title to "Open a File"). </member> <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false"> If [code]true[/code], the dialog will show hidden files. </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> @@ -106,19 +106,19 @@ </signal> </signals> <constants> - <constant name="MODE_OPEN_FILE" value="0" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILE" value="0" enum="FileMode"> The dialog allows selecting one, and only one file. </constant> - <constant name="MODE_OPEN_FILES" value="1" enum="Mode"> + <constant name="FILE_MODE_OPEN_FILES" value="1" enum="FileMode"> The dialog allows selecting multiple files. </constant> - <constant name="MODE_OPEN_DIR" value="2" enum="Mode"> + <constant name="FILE_MODE_OPEN_DIR" value="2" enum="FileMode"> The dialog only allows selecting a directory, disallowing the selection of any file. </constant> - <constant name="MODE_OPEN_ANY" value="3" enum="Mode"> + <constant name="FILE_MODE_OPEN_ANY" value="3" enum="FileMode"> The dialog allows selecting one file or directory. </constant> - <constant name="MODE_SAVE_FILE" value="4" enum="Mode"> + <constant name="FILE_MODE_SAVE_FILE" value="4" enum="FileMode"> The dialog will warn when a file exists. </constant> <constant name="ACCESS_RESOURCES" value="0" enum="Access"> diff --git a/doc/classes/GIProbe.xml b/doc/classes/GIProbe.xml index 322143ea9e..df50244c77 100644 --- a/doc/classes/GIProbe.xml +++ b/doc/classes/GIProbe.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GIProbe" inherits="VisualInstance" version="4.0"> +<class name="GIProbe" inherits="VisualInstance3D" version="4.0"> <brief_description> Real-time global illumination (GI) probe. </brief_description> @@ -19,7 +19,7 @@ <argument index="1" name="create_visual_debug" type="bool" default="false"> </argument> <description> - Bakes the effect from all [GeometryInstance]s marked with [member GeometryInstance.use_in_baked_light] and [Light]s marked with either [constant Light.BAKE_INDIRECT] or [constant Light.BAKE_ALL]. If [code]create_visual_debug[/code] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [GIProbe]'s data and debug any issues that may be occurring. + Bakes the effect from all [GeometryInstance3D]s marked with [member GeometryInstance3D.use_in_baked_light] and [Light3D]s marked with either [constant Light3D.BAKE_INDIRECT] or [constant Light3D.BAKE_ALL]. If [code]create_visual_debug[/code] is [code]true[/code], after baking the light, this will generate a [MultiMesh] that has a cube representing each solid cell with each cube colored to the cell's albedo color. This can be used to visualize the [GIProbe]'s data and debug any issues that may be occurring. </description> </method> <method name="debug_bake"> diff --git a/doc/classes/Particles2D.xml b/doc/classes/GPUParticles2D.xml index 50fc3680bc..64a2522f2f 100644 --- a/doc/classes/Particles2D.xml +++ b/doc/classes/GPUParticles2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Particles2D" inherits="Node2D" version="4.0"> +<class name="GPUParticles2D" inherits="Node2D" version="4.0"> <brief_description> 2D particle emitter. </brief_description> <description> - 2D particle node used to create a variety of particle systems and effects. [Particles2D] features an emitter that generates some number of particles at a given rate. + 2D particle node used to create a variety of particle systems and effects. [GPUParticles2D] features an emitter that generates some number of particles at a given rate. Use the [code]process_material[/code] property to add a [ParticlesMaterial] to configure particle appearance and behavior. Alternatively, you can add a [ShaderMaterial] which will be applied to all particles. </description> <tutorials> @@ -30,7 +30,7 @@ <member name="amount" type="int" setter="set_amount" getter="get_amount" default="8"> Number of particles emitted in one emission cycle. </member> - <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="Particles2D.DrawOrder" default="0"> + <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="GPUParticles2D.DrawOrder" default="0"> Particle draw order. Uses [enum DrawOrder] values. </member> <member name="emitting" type="bool" setter="set_emitting" getter="is_emitting" default="false"> diff --git a/doc/classes/Particles.xml b/doc/classes/GPUParticles3D.xml index 74651ddd2f..add8f28bf8 100644 --- a/doc/classes/Particles.xml +++ b/doc/classes/GPUParticles3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Particles" inherits="GeometryInstance" version="4.0"> +<class name="GPUParticles3D" inherits="GeometryInstance3D" version="4.0"> <brief_description> 3D particle emitter. </brief_description> <description> - 3D particle node used to create a variety of particle systems and effects. [Particles] features an emitter that generates some number of particles at a given rate. + 3D particle node used to create a variety of particle systems and effects. [GPUParticles3D] features an emitter that generates some number of particles at a given rate. Use the [code]process_material[/code] property to add a [ParticlesMaterial] to configure particle appearance and behavior. Alternatively, you can add a [ShaderMaterial] which will be applied to all particles. </description> <tutorials> @@ -50,7 +50,7 @@ <member name="amount" type="int" setter="set_amount" getter="get_amount" default="8"> Number of particles to emit. </member> - <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="Particles.DrawOrder" default="0"> + <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="GPUParticles3D.DrawOrder" default="0"> Particle draw order. Uses [enum DrawOrder] values. </member> <member name="draw_pass_1" type="Mesh" setter="set_draw_pass_mesh" getter="get_draw_pass_mesh"> diff --git a/doc/classes/Generic6DOFJoint.xml b/doc/classes/Generic6DOFJoint3D.xml index 29ebf9f5d6..fae567dc58 100644 --- a/doc/classes/Generic6DOFJoint.xml +++ b/doc/classes/Generic6DOFJoint3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Generic6DOFJoint" inherits="Joint" version="4.0"> +<class name="Generic6DOFJoint3D" inherits="Joint3D" version="4.0"> <brief_description> The generic 6-degrees-of-freedom joint can implement a variety of joint types by locking certain axes' rotation or translation. </brief_description> @@ -12,7 +12,7 @@ <method name="get_flag_x" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint.Flag"> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> </argument> <description> </description> @@ -20,7 +20,7 @@ <method name="get_flag_y" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint.Flag"> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> </argument> <description> </description> @@ -28,7 +28,7 @@ <method name="get_flag_z" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint.Flag"> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> </argument> <description> </description> @@ -36,7 +36,7 @@ <method name="get_param_x" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint.Param"> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> </argument> <description> </description> @@ -44,7 +44,7 @@ <method name="get_param_y" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint.Param"> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> </argument> <description> </description> @@ -52,7 +52,7 @@ <method name="get_param_z" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint.Param"> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> </argument> <description> </description> @@ -60,7 +60,7 @@ <method name="set_flag_x"> <return type="void"> </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint.Flag"> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> </argument> <argument index="1" name="value" type="bool"> </argument> @@ -70,7 +70,7 @@ <method name="set_flag_y"> <return type="void"> </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint.Flag"> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> </argument> <argument index="1" name="value" type="bool"> </argument> @@ -80,7 +80,7 @@ <method name="set_flag_z"> <return type="void"> </return> - <argument index="0" name="flag" type="int" enum="Generic6DOFJoint.Flag"> + <argument index="0" name="flag" type="int" enum="Generic6DOFJoint3D.Flag"> </argument> <argument index="1" name="value" type="bool"> </argument> @@ -90,7 +90,7 @@ <method name="set_param_x"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint.Param"> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> @@ -100,7 +100,7 @@ <method name="set_param_y"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint.Param"> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> @@ -110,7 +110,7 @@ <method name="set_param_z"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="Generic6DOFJoint.Param"> + <argument index="0" name="param" type="int" enum="Generic6DOFJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> diff --git a/doc/classes/GeometryInstance.xml b/doc/classes/GeometryInstance3D.xml index 8259462531..7df5f0ea50 100644 --- a/doc/classes/GeometryInstance.xml +++ b/doc/classes/GeometryInstance3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GeometryInstance" inherits="VisualInstance" version="4.0"> +<class name="GeometryInstance3D" inherits="VisualInstance3D" version="4.0"> <brief_description> Base node for geometry-based visual instances. </brief_description> @@ -12,10 +12,10 @@ <method name="get_flag" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="flag" type="int" enum="GeometryInstance.Flags"> + <argument index="0" name="flag" type="int" enum="GeometryInstance3D.Flags"> </argument> <description> - Returns the [enum GeometryInstance.Flags] that have been set for this object. + Returns the [enum GeometryInstance3D.Flags] that have been set for this object. </description> </method> <method name="set_custom_aabb"> @@ -30,36 +30,36 @@ <method name="set_flag"> <return type="void"> </return> - <argument index="0" name="flag" type="int" enum="GeometryInstance.Flags"> + <argument index="0" name="flag" type="int" enum="GeometryInstance3D.Flags"> </argument> <argument index="1" name="value" type="bool"> </argument> <description> - Sets the [enum GeometryInstance.Flags] specified. See [enum GeometryInstance.Flags] for options. + Sets the [enum GeometryInstance3D.Flags] specified. See [enum GeometryInstance3D.Flags] for options. </description> </method> </methods> <members> - <member name="cast_shadow" type="int" setter="set_cast_shadows_setting" getter="get_cast_shadows_setting" enum="GeometryInstance.ShadowCastingSetting" default="1"> + <member name="cast_shadow" type="int" setter="set_cast_shadows_setting" getter="get_cast_shadows_setting" enum="GeometryInstance3D.ShadowCastingSetting" default="1"> The selected shadow casting flag. See [enum ShadowCastingSetting] for possible values. </member> <member name="extra_cull_margin" type="float" setter="set_extra_cull_margin" getter="get_extra_cull_margin" default="0.0"> - The extra distance added to the GeometryInstance's bounding box ([AABB]) to increase its cull box. + The extra distance added to the GeometryInstance3D's bounding box ([AABB]) to increase its cull box. </member> <member name="lod_max_distance" type="float" setter="set_lod_max_distance" getter="get_lod_max_distance" default="0.0"> - The GeometryInstance's max LOD distance. + The GeometryInstance3D's max LOD distance. [b]Note:[/b] This property currently has no effect. </member> <member name="lod_max_hysteresis" type="float" setter="set_lod_max_hysteresis" getter="get_lod_max_hysteresis" default="0.0"> - The GeometryInstance's max LOD margin. + The GeometryInstance3D's max LOD margin. [b]Note:[/b] This property currently has no effect. </member> <member name="lod_min_distance" type="float" setter="set_lod_min_distance" getter="get_lod_min_distance" default="0.0"> - The GeometryInstance's min LOD distance. + The GeometryInstance3D's min LOD distance. [b]Note:[/b] This property currently has no effect. </member> <member name="lod_min_hysteresis" type="float" setter="set_lod_min_hysteresis" getter="get_lod_min_hysteresis" default="0.0"> - The GeometryInstance's min LOD margin. + The GeometryInstance3D's min LOD margin. [b]Note:[/b] This property currently has no effect. </member> <member name="material_override" type="Material" setter="set_material_override" getter="get_material_override"> @@ -69,7 +69,7 @@ <member name="use_dynamic_gi" type="bool" setter="set_flag" getter="get_flag" default="false"> </member> <member name="use_in_baked_light" type="bool" setter="set_flag" getter="get_flag" default="false"> - If [code]true[/code], this GeometryInstance will be used when baking lights using a [GIProbe]. + If [code]true[/code], this GeometryInstance3D will be used when baking lights using a [GIProbe]. </member> </members> <constants> @@ -77,11 +77,11 @@ Will not cast any shadows. </constant> <constant name="SHADOW_CASTING_SETTING_ON" value="1" enum="ShadowCastingSetting"> - Will cast shadows from all visible faces in the GeometryInstance. + Will cast shadows from all visible faces in the GeometryInstance3D. Will take culling into account, so faces not being rendered will not be taken into account when shadow casting. </constant> <constant name="SHADOW_CASTING_SETTING_DOUBLE_SIDED" value="2" enum="ShadowCastingSetting"> - Will cast shadows from all visible faces in the GeometryInstance. + Will cast shadows from all visible faces in the GeometryInstance3D. Will not take culling into account, so all faces will be taken into account when shadow casting. </constant> <constant name="SHADOW_CASTING_SETTING_SHADOWS_ONLY" value="3" enum="ShadowCastingSetting"> @@ -89,12 +89,12 @@ In other words, the actual mesh will not be visible, only the shadows casted from the mesh will be. </constant> <constant name="FLAG_USE_BAKED_LIGHT" value="0" enum="Flags"> - Will allow the GeometryInstance to be used when baking lights using a [GIProbe]. + Will allow the GeometryInstance3D to be used when baking lights using a [GIProbe]. </constant> <constant name="FLAG_USE_DYNAMIC_GI" value="1" enum="Flags"> </constant> <constant name="FLAG_DRAW_NEXT_FRAME_IF_VISIBLE" value="2" enum="Flags"> - Unused in this class, exposed for consistency with [enum VisualServer.InstanceFlags]. + Unused in this class, exposed for consistency with [enum RenderingServer.InstanceFlags]. </constant> <constant name="FLAG_MAX" value="3" enum="Flags"> Represents the size of the [enum Flags] enum. diff --git a/doc/classes/HeightMapShape.xml b/doc/classes/HeightMapShape3D.xml index 029f3642d2..6d230bdab8 100644 --- a/doc/classes/HeightMapShape.xml +++ b/doc/classes/HeightMapShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HeightMapShape" inherits="Shape" version="4.0"> +<class name="HeightMapShape3D" inherits="Shape3D" version="4.0"> <brief_description> Height map shape for 3D physics (Bullet only). </brief_description> <description> - Height map shape resource, which can be added to a [PhysicsBody] or [Area]. + Height map shape resource, which can be added to a [PhysicsBody3D] or [Area3D]. </description> <tutorials> </tutorials> diff --git a/doc/classes/HingeJoint.xml b/doc/classes/HingeJoint3D.xml index 0d1b6ff0e0..2d4480cb20 100644 --- a/doc/classes/HingeJoint.xml +++ b/doc/classes/HingeJoint3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HingeJoint" inherits="Joint" version="4.0"> +<class name="HingeJoint3D" inherits="Joint3D" version="4.0"> <brief_description> A hinge between two 3D bodies. </brief_description> <description> - A HingeJoint normally uses the Z axis of body A as the hinge axis, another axis can be specified when adding it manually though. + A HingeJoint3D normally uses the Z axis of body A as the hinge axis, another axis can be specified when adding it manually though. </description> <tutorials> </tutorials> @@ -12,7 +12,7 @@ <method name="get_flag" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="flag" type="int" enum="HingeJoint.Flag"> + <argument index="0" name="flag" type="int" enum="HingeJoint3D.Flag"> </argument> <description> Returns the value of the specified flag. @@ -21,7 +21,7 @@ <method name="get_param" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="HingeJoint.Param"> + <argument index="0" name="param" type="int" enum="HingeJoint3D.Param"> </argument> <description> Returns the value of the specified parameter. @@ -30,7 +30,7 @@ <method name="set_flag"> <return type="void"> </return> - <argument index="0" name="flag" type="int" enum="HingeJoint.Flag"> + <argument index="0" name="flag" type="int" enum="HingeJoint3D.Flag"> </argument> <argument index="1" name="enabled" type="bool"> </argument> @@ -41,7 +41,7 @@ <method name="set_param"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="HingeJoint.Param"> + <argument index="0" name="param" type="int" enum="HingeJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 8bd2213194..f541b0ae66 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -99,7 +99,7 @@ </return> <argument index="0" name="mode" type="int" enum="Image.CompressMode"> </argument> - <argument index="1" name="channels" type="int" enum="Image.CompressSource"> + <argument index="1" name="channels" type="int" enum="Image.UsedChannels"> </argument> <argument index="2" name="lossy_quality" type="float" default="0.7"> </argument> diff --git a/doc/classes/ImmediateGeometry.xml b/doc/classes/ImmediateGeometry3D.xml index 710e929d1a..1c0831c922 100644 --- a/doc/classes/ImmediateGeometry.xml +++ b/doc/classes/ImmediateGeometry3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ImmediateGeometry" inherits="GeometryInstance" version="4.0"> +<class name="ImmediateGeometry3D" inherits="GeometryInstance3D" version="4.0"> <brief_description> Draws simple geometry from code. </brief_description> diff --git a/doc/classes/InputDefault.xml b/doc/classes/InputDefault.xml deleted file mode 100644 index ea4d08c628..0000000000 --- a/doc/classes/InputDefault.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="InputDefault" inherits="Input" version="4.0"> - <brief_description> - Default implementation of the [Input] class. - </brief_description> - <description> - Default implementation of the [Input] class, used internally by the editor and games for default input management. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <constants> - </constants> -</class> diff --git a/doc/classes/InputEventFromWindow.xml b/doc/classes/InputEventFromWindow.xml new file mode 100644 index 0000000000..7cd5b7d179 --- /dev/null +++ b/doc/classes/InputEventFromWindow.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="InputEventFromWindow" inherits="InputEvent" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <members> + <member name="window_id" type="int" setter="set_window_id" getter="get_window_id" default="0"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/InputEventKey.xml b/doc/classes/InputEventKey.xml index c8d0769b90..34afa90553 100644 --- a/doc/classes/InputEventKey.xml +++ b/doc/classes/InputEventKey.xml @@ -43,7 +43,7 @@ If [code]true[/code], the key's state is pressed. If [code]false[/code], the key's state is released. </member> <member name="unicode" type="int" setter="set_unicode" getter="get_unicode" default="0"> - The key Unicode identifier (when relevant). Unicode identifiers for the composite characters and complex scripts may not be available unless IME input mode is active. See [method OS.set_ime_active] for more information. + The key Unicode identifier (when relevant). Unicode identifiers for the composite characters and complex scripts may not be available unless IME input mode is active. See [method Window.set_ime_active] for more information. </member> </members> <constants> diff --git a/doc/classes/InputEventScreenDrag.xml b/doc/classes/InputEventScreenDrag.xml index d7e0c2454c..a315e4ddfb 100644 --- a/doc/classes/InputEventScreenDrag.xml +++ b/doc/classes/InputEventScreenDrag.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventScreenDrag" inherits="InputEvent" version="4.0"> +<class name="InputEventScreenDrag" inherits="InputEventFromWindow" version="4.0"> <brief_description> Input event type for screen drag events. Only available on mobile devices. </brief_description> diff --git a/doc/classes/InputEventScreenTouch.xml b/doc/classes/InputEventScreenTouch.xml index 4a5cd36423..16a3cf8353 100644 --- a/doc/classes/InputEventScreenTouch.xml +++ b/doc/classes/InputEventScreenTouch.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventScreenTouch" inherits="InputEvent" version="4.0"> +<class name="InputEventScreenTouch" inherits="InputEventFromWindow" version="4.0"> <brief_description> Input event type for screen touch events. (only available on mobile devices) diff --git a/doc/classes/InputEventWithModifiers.xml b/doc/classes/InputEventWithModifiers.xml index 63465ad28c..34faf18e24 100644 --- a/doc/classes/InputEventWithModifiers.xml +++ b/doc/classes/InputEventWithModifiers.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventWithModifiers" inherits="InputEvent" version="4.0"> +<class name="InputEventWithModifiers" inherits="InputEventFromWindow" version="4.0"> <brief_description> Base class for keys events with modifiers. </brief_description> diff --git a/doc/classes/Input.xml b/doc/classes/InputFilter.xml index 0f212e7498..54184ae8a3 100644 --- a/doc/classes/Input.xml +++ b/doc/classes/InputFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Input" inherits="Object" version="4.0"> +<class name="InputFilter" inherits="Object" version="4.0"> <brief_description> A singleton that deals with inputs. </brief_description> @@ -68,7 +68,7 @@ </description> </method> <method name="get_current_cursor_shape" qualifiers="const"> - <return type="int" enum="Input.CursorShape"> + <return type="int" enum="InputFilter.CursorShape"> </return> <description> Returns the currently assigned cursor shape (see [enum CursorShape]). @@ -193,7 +193,7 @@ </description> </method> <method name="get_mouse_mode" qualifiers="const"> - <return type="int" enum="Input.MouseMode"> + <return type="int" enum="InputFilter.MouseMode"> </return> <description> Returns the mouse mode. See the constants for more information. @@ -277,7 +277,7 @@ <argument index="3" name="guid" type="String"> </argument> <description> - Notifies the [Input] singleton that a connection has changed, to update the state for the [code]device[/code] index. + Notifies the [InputFilter] singleton that a connection has changed, to update the state for the [code]device[/code] index. This is used internally and should not have to be called from user scripts. See [signal joy_connection_changed] for the signal emitted when this is triggered internally. </description> </method> @@ -293,7 +293,7 @@ var a = InputEventAction.new() a.action = "ui_cancel" a.pressed = true - Input.parse_input_event(a) + InputFilter.parse_input_event(a) [/codeblock] </description> </method> @@ -311,7 +311,7 @@ </return> <argument index="0" name="image" type="Resource"> </argument> - <argument index="1" name="shape" type="int" enum="Input.CursorShape" default="0"> + <argument index="1" name="shape" type="int" enum="InputFilter.CursorShape" default="0"> </argument> <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )"> </argument> @@ -326,7 +326,7 @@ <method name="set_default_cursor_shape"> <return type="void"> </return> - <argument index="0" name="shape" type="int" enum="Input.CursorShape" default="0"> + <argument index="0" name="shape" type="int" enum="InputFilter.CursorShape" default="0"> </argument> <description> Sets the default cursor shape to be used in the viewport instead of [constant CURSOR_ARROW]. @@ -337,7 +337,7 @@ <method name="set_mouse_mode"> <return type="void"> </return> - <argument index="0" name="mode" type="int" enum="Input.MouseMode"> + <argument index="0" name="mode" type="int" enum="InputFilter.MouseMode"> </argument> <description> Sets the mouse mode. See the constants for more information. diff --git a/doc/classes/InterpolatedCamera.xml b/doc/classes/InterpolatedCamera.xml deleted file mode 100644 index 66df7e9531..0000000000 --- a/doc/classes/InterpolatedCamera.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="InterpolatedCamera" inherits="Camera" version="4.0"> - <brief_description> - Camera which moves toward another node. - </brief_description> - <description> - InterpolatedCamera is a [Camera] which smoothly moves to match a target node's position and rotation. - If it is not [member enabled] or does not have a valid target set, InterpolatedCamera acts like a normal Camera. - </description> - <tutorials> - </tutorials> - <methods> - <method name="set_target"> - <return type="void"> - </return> - <argument index="0" name="target" type="Object"> - </argument> - <description> - Sets the node to move toward and orient with. - </description> - </method> - </methods> - <members> - <member name="enabled" type="bool" setter="set_interpolation_enabled" getter="is_interpolation_enabled" default="false"> - If [code]true[/code], and a target is set, the camera will move automatically. - </member> - <member name="speed" type="float" setter="set_speed" getter="get_speed" default="1.0"> - How quickly the camera moves toward its target. Higher values will result in tighter camera motion. - </member> - <member name="target" type="NodePath" setter="set_target_path" getter="get_target_path" default="NodePath("")"> - The target's [NodePath]. - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/Joint.xml b/doc/classes/Joint3D.xml index 34da997292..15bef960f6 100644 --- a/doc/classes/Joint.xml +++ b/doc/classes/Joint3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Joint" inherits="Spatial" version="4.0"> +<class name="Joint3D" inherits="Node3D" version="4.0"> <brief_description> Base class for all 3D joints. </brief_description> diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody3D.xml index 4ccbc679bf..5f9b36f97d 100644 --- a/doc/classes/KinematicBody.xml +++ b/doc/classes/KinematicBody3D.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="KinematicBody" inherits="PhysicsBody" version="4.0"> +<class name="KinematicBody3D" inherits="PhysicsBody3D" version="4.0"> <brief_description> Kinematic body 3D node. </brief_description> <description> Kinematic bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all; to other types of bodies, such as a character or a rigid body, these are the same as a static body. However, they have two main uses: [b]Simulated motion:[/b] When these bodies are moved manually, either from code or from an [AnimationPlayer] (with [member AnimationPlayer.playback_process_mode] set to "physics"), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc). - [b]Kinematic characters:[/b] KinematicBody also has an API for moving objects (the [method move_and_collide] and [method move_and_slide] methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics. + [b]Kinematic characters:[/b] KinematicBody3D also has an API for moving objects (the [method move_and_collide] and [method move_and_slide] methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/kinematic_character_2d.html</link> @@ -15,7 +15,7 @@ <method name="get_axis_lock" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="axis" type="int" enum="PhysicsServer.BodyAxis"> + <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> </argument> <description> Returns [code]true[/code] if the specified [code]axis[/code] is locked. See also [member move_lock_x], [member move_lock_y] and [member move_lock_z]. @@ -36,12 +36,12 @@ </description> </method> <method name="get_slide_collision"> - <return type="KinematicCollision"> + <return type="KinematicCollision3D"> </return> <argument index="0" name="slide_idx" type="int"> </argument> <description> - Returns a [KinematicCollision], which contains information about a collision that occurred during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1). + Returns a [KinematicCollision3D], which contains information about a collision that occurred during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1). </description> </method> <method name="get_slide_count" qualifiers="const"> @@ -73,7 +73,7 @@ </description> </method> <method name="move_and_collide"> - <return type="KinematicCollision"> + <return type="KinematicCollision3D"> </return> <argument index="0" name="rel_vec" type="Vector3"> </argument> @@ -84,7 +84,7 @@ <argument index="3" name="test_only" type="bool" default="false"> </argument> <description> - Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision], which contains information about the collision. + Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision3D], which contains information about the collision. If [code]test_only[/code] is [code]true[/code], the body does not move but the would-be collision information is given. </description> </method> @@ -104,14 +104,14 @@ <argument index="5" name="infinite_inertia" type="bool" default="true"> </argument> <description> - Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [KinematicBody] or [RigidBody], it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes. + Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [KinematicBody3D] or [RigidBody3D], it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes. This method should be used in [method Node._physics_process] (or in a method called by [method Node._physics_process]), as it uses the physics step's [code]delta[/code] value automatically in calculations. Otherwise, the simulation will run at an incorrect speed. [code]linear_velocity[/code] is the velocity vector (typically meters per second). Unlike in [method move_and_collide], you should [i]not[/i] multiply it by [code]delta[/code] — the physics engine handles applying the velocity. [code]up_direction[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector3(0, 0, 0)[/code], everything is considered a wall. If [code]stop_on_slope[/code] is [code]true[/code], body will not slide on slopes if you include gravity in [code]linear_velocity[/code]. If the body collides, it will change direction a maximum of [code]max_slides[/code] times before it stops. [code]floor_max_angle[/code] is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees. - If [code]infinite_inertia[/code] is [code]true[/code], body will be able to push [RigidBody] nodes, but it won't also detect any collisions with them. If [code]false[/code], it will interact with [RigidBody] nodes like with [StaticBody]. + If [code]infinite_inertia[/code] is [code]true[/code], body will be able to push [RigidBody3D] nodes, but it won't also detect any collisions with them. If [code]false[/code], it will interact with [RigidBody3D] nodes like with [StaticBody3D]. Returns the [code]linear_velocity[/code] vector, rotated and/or scaled if a slide collision occurred. To get detailed information about collisions that occurred, use [method get_slide_collision]. </description> </method> @@ -140,7 +140,7 @@ <method name="set_axis_lock"> <return type="void"> </return> - <argument index="0" name="axis" type="int" enum="PhysicsServer.BodyAxis"> + <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> </argument> <argument index="1" name="lock" type="bool"> </argument> diff --git a/doc/classes/KinematicCollision.xml b/doc/classes/KinematicCollision3D.xml index 858a1e69c0..f3248a9ca1 100644 --- a/doc/classes/KinematicCollision.xml +++ b/doc/classes/KinematicCollision3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="KinematicCollision" inherits="Reference" version="4.0"> +<class name="KinematicCollision3D" inherits="Reference" version="4.0"> <brief_description> - Collision data for [KinematicBody] collisions. + Collision data for [KinematicBody3D] collisions. </brief_description> <description> - Contains collision data for [KinematicBody] collisions. When a [KinematicBody] is moved using [method KinematicBody.move_and_collide], it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision object is returned. + Contains collision data for [KinematicBody3D] collisions. When a [KinematicBody3D] is moved using [method KinematicBody3D.move_and_collide], it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision3D object is returned. This object contains information about the collision, including the colliding object, the remaining motion, and the collision position. This information can be used to calculate a collision response. </description> <tutorials> @@ -25,7 +25,7 @@ The colliding body's shape. </member> <member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" default="0"> - The colliding shape's index. See [CollisionObject]. + The colliding shape's index. See [CollisionObject3D]. </member> <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" default="Vector3( 0, 0, 0 )"> The colliding object's velocity. diff --git a/doc/classes/Light.xml b/doc/classes/Light3D.xml index a2867a50d2..4e48a24951 100644 --- a/doc/classes/Light.xml +++ b/doc/classes/Light3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Light" inherits="VisualInstance" version="4.0"> +<class name="Light3D" inherits="VisualInstance3D" version="4.0"> <brief_description> Provides a base class for different kinds of light nodes. </brief_description> <description> - Light is the abstract base class for light nodes, so it shouldn't be used directly (it can't be instanced). Other types of light nodes inherit from it. Light contains the common variables and parameters used for lighting. + Light3D is the abstract base class for light nodes, so it shouldn't be used directly (it can't be instanced). Other types of light nodes inherit from it. Light3D contains the common variables and parameters used for lighting. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/lights_and_shadows.html</link> @@ -13,21 +13,21 @@ <method name="get_param" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="Light.Param"> + <argument index="0" name="param" type="int" enum="Light3D.Param"> </argument> <description> - Returns the value of the specified [enum Light.Param] parameter. + Returns the value of the specified [enum Light3D.Param] parameter. </description> </method> <method name="set_param"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="Light.Param"> + <argument index="0" name="param" type="int" enum="Light3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> <description> - Sets the value of the specified [enum Light.Param] parameter. + Sets the value of the specified [enum Light3D.Param] parameter. </description> </method> </methods> @@ -35,7 +35,7 @@ <member name="editor_only" type="bool" setter="set_editor_only" getter="is_editor_only" default="false"> If [code]true[/code], the light only appears in the editor and will not be visible at runtime. </member> - <member name="light_bake_mode" type="int" setter="set_bake_mode" getter="get_bake_mode" enum="Light.BakeMode" default="1"> + <member name="light_bake_mode" type="int" setter="set_bake_mode" getter="get_bake_mode" enum="Light3D.BakeMode" default="1"> The light's bake mode. See [enum BakeMode]. </member> <member name="light_color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> @@ -69,7 +69,7 @@ If [code]true[/code], the light will cast shadows. </member> <member name="shadow_reverse_cull_face" type="bool" setter="set_shadow_reverse_cull_face" getter="get_shadow_reverse_cull_face" default="false"> - If [code]true[/code], reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows with [constant GeometryInstance.SHADOW_CASTING_SETTING_DOUBLE_SIDED]. + If [code]true[/code], reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows with [constant GeometryInstance3D.SHADOW_CASTING_SETTING_DOUBLE_SIDED]. </member> </members> <constants> @@ -83,42 +83,42 @@ Constant for accessing [member light_specular]. </constant> <constant name="PARAM_RANGE" value="3" enum="Param"> - Constant for accessing [member OmniLight.omni_range] or [member SpotLight.spot_range]. + Constant for accessing [member OmniLight3D.omni_range] or [member SpotLight3D.spot_range]. </constant> <constant name="PARAM_ATTENUATION" value="4" enum="Param"> - Constant for accessing [member OmniLight.omni_attenuation] or [member SpotLight.spot_attenuation]. + Constant for accessing [member OmniLight3D.omni_attenuation] or [member SpotLight3D.spot_attenuation]. </constant> <constant name="PARAM_SPOT_ANGLE" value="5" enum="Param"> - Constant for accessing [member SpotLight.spot_angle]. + Constant for accessing [member SpotLight3D.spot_angle]. </constant> <constant name="PARAM_SPOT_ATTENUATION" value="6" enum="Param"> - Constant for accessing [member SpotLight.spot_angle_attenuation]. + Constant for accessing [member SpotLight3D.spot_angle_attenuation]. </constant> <constant name="PARAM_CONTACT_SHADOW_SIZE" value="7" enum="Param"> Constant for accessing [member shadow_contact]. </constant> <constant name="PARAM_SHADOW_MAX_DISTANCE" value="8" enum="Param"> - Constant for accessing [member DirectionalLight.directional_shadow_max_distance]. + Constant for accessing [member DirectionalLight3D.directional_shadow_max_distance]. </constant> <constant name="PARAM_SHADOW_SPLIT_1_OFFSET" value="9" enum="Param"> - Constant for accessing [member DirectionalLight.directional_shadow_split_1]. + Constant for accessing [member DirectionalLight3D.directional_shadow_split_1]. </constant> <constant name="PARAM_SHADOW_SPLIT_2_OFFSET" value="10" enum="Param"> - Constant for accessing [member DirectionalLight.directional_shadow_split_2]. + Constant for accessing [member DirectionalLight3D.directional_shadow_split_2]. </constant> <constant name="PARAM_SHADOW_SPLIT_3_OFFSET" value="11" enum="Param"> - Constant for accessing [member DirectionalLight.directional_shadow_split_3]. + Constant for accessing [member DirectionalLight3D.directional_shadow_split_3]. </constant> <constant name="PARAM_SHADOW_FADE_START" value="12" enum="Param"> </constant> <constant name="PARAM_SHADOW_NORMAL_BIAS" value="13" enum="Param"> - Constant for accessing [member DirectionalLight.directional_shadow_normal_bias]. + Constant for accessing [member DirectionalLight3D.directional_shadow_normal_bias]. </constant> <constant name="PARAM_SHADOW_BIAS" value="14" enum="Param"> Constant for accessing [member shadow_bias]. </constant> <constant name="PARAM_SHADOW_BIAS_SPLIT_SCALE" value="15" enum="Param"> - Constant for accessing [member DirectionalLight.directional_shadow_bias_split_scale]. + Constant for accessing [member DirectionalLight3D.directional_shadow_bias_split_scale]. </constant> <constant name="PARAM_MAX" value="16" enum="Param"> Represents the size of the [enum Param] enum. diff --git a/doc/classes/Listener.xml b/doc/classes/Listener3D.xml index 72bbfa29d4..998ea757ff 100644 --- a/doc/classes/Listener.xml +++ b/doc/classes/Listener3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Listener" inherits="Spatial" version="4.0"> +<class name="Listener3D" inherits="Node3D" version="4.0"> <brief_description> Overrides the location sounds are heard from. </brief_description> <description> - Once added to the scene tree and enabled using [method make_current], this node will override the location sounds are heard from. This can be used to listen from a location different from the [Camera]. + Once added to the scene tree and enabled using [method make_current], this node will override the location sounds are heard from. This can be used to listen from a location different from the [Camera3D]. [b]Note:[/b] There is no 2D equivalent for this node yet. </description> <tutorials> @@ -29,7 +29,7 @@ </return> <description> Returns [code]true[/code] if the listener was made current using [method make_current], [code]false[/code] otherwise. - [b]Note:[/b] There may be more than one Listener marked as "current" in the scene tree, but only the one that was made current last will be used. + [b]Note:[/b] There may be more than one Listener3D marked as "current" in the scene tree, but only the one that was made current last will be used. </description> </method> <method name="make_current"> diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml index af71c30936..7bb478fce2 100644 --- a/doc/classes/MainLoop.xml +++ b/doc/classes/MainLoop.xml @@ -7,6 +7,7 @@ [MainLoop] is the abstract base class for a Godot project's game loop. It is inherited by [SceneTree], which is the default game loop implementation used in Godot projects, though it is also possible to write and use one's own [MainLoop] subclass instead of the scene tree. Upon the application start, a [MainLoop] implementation must be provided to the OS; otherwise, the application will exit. This happens automatically (and a [SceneTree] is created) unless a main [Script] is provided from the command line (with e.g. [code]godot -s my_loop.gd[/code], which should then be a [MainLoop] implementation. Here is an example script implementing a simple [MainLoop]: + [b]FIXME:[/b] No longer valid after DisplayServer split and Input refactoring. [codeblock] extends MainLoop @@ -43,17 +44,6 @@ <tutorials> </tutorials> <methods> - <method name="_drop_files" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="files" type="PackedStringArray"> - </argument> - <argument index="1" name="from_screen" type="int"> - </argument> - <description> - Called when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated. - </description> - </method> <method name="_finalize" qualifiers="virtual"> <return type="void"> </return> @@ -61,17 +51,6 @@ Called before the program exits. </description> </method> - <method name="_global_menu_action" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="id" type="Variant"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> - <description> - Called when the user performs an action in the system global menu (e.g. the Mac OS menu bar). - </description> - </method> <method name="_idle" qualifiers="virtual"> <return type="bool"> </return> @@ -89,24 +68,6 @@ Called once during initialization. </description> </method> - <method name="_input_event" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <description> - Called whenever an [InputEvent] is received by the main loop. - </description> - </method> - <method name="_input_text" qualifiers="virtual"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <description> - Deprecated callback, does not do anything. Use [method _input_event] to parse text input. Will be removed in Godot 4.0. - </description> - </method> <method name="_iteration" qualifiers="virtual"> <return type="bool"> </return> @@ -140,24 +101,6 @@ Should not be called manually, override [method _initialize] instead. Will be removed in Godot 4.0. </description> </method> - <method name="input_event"> - <return type="void"> - </return> - <argument index="0" name="event" type="InputEvent"> - </argument> - <description> - Should not be called manually, override [method _input_event] instead. Will be removed in Godot 4.0. - </description> - </method> - <method name="input_text"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <description> - Should not be called manually, override [method _input_text] instead. Will be removed in Godot 4.0. - </description> - </method> <method name="iteration"> <return type="bool"> </return> @@ -180,58 +123,30 @@ </signal> </signals> <constants> - <constant name="NOTIFICATION_WM_MOUSE_ENTER" value="1002"> - Notification received from the OS when the mouse enters the game window. - Implemented on desktop and web platforms. - </constant> - <constant name="NOTIFICATION_WM_MOUSE_EXIT" value="1003"> - Notification received from the OS when the mouse leaves the game window. - Implemented on desktop and web platforms. - </constant> - <constant name="NOTIFICATION_WM_FOCUS_IN" value="1004"> - Notification received from the OS when the game window is focused. - Implemented on all platforms. - </constant> - <constant name="NOTIFICATION_WM_FOCUS_OUT" value="1005"> - Notification received from the OS when the game window is unfocused. - Implemented on all platforms. - </constant> - <constant name="NOTIFICATION_WM_QUIT_REQUEST" value="1006"> - Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4). - Implemented on desktop platforms. - </constant> - <constant name="NOTIFICATION_WM_GO_BACK_REQUEST" value="1007"> - Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android). - Specific to the Android platform. - </constant> - <constant name="NOTIFICATION_WM_UNFOCUS_REQUEST" value="1008"> - Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus). - No supported platforms currently send this notification. - </constant> - <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="1009"> + <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="2009"> Notification received from the OS when the application is exceeding its allocated memory. Specific to the iOS platform. </constant> - <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="1010"> + <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="2010"> Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like [method Object.tr]. </constant> - <constant name="NOTIFICATION_WM_ABOUT" value="1011"> + <constant name="NOTIFICATION_WM_ABOUT" value="2011"> Notification received from the OS when a request for "About" information is sent. Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_CRASH" value="1012"> + <constant name="NOTIFICATION_CRASH" value="2012"> Notification received from Godot's crash handler when the engine is about to crash. Implemented on desktop platforms if the crash handler is enabled. </constant> - <constant name="NOTIFICATION_OS_IME_UPDATE" value="1013"> + <constant name="NOTIFICATION_OS_IME_UPDATE" value="2013"> Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string). Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_APP_RESUMED" value="1014"> + <constant name="NOTIFICATION_APP_RESUMED" value="2014"> Notification received from the OS when the app is resumed. Specific to the Android platform. </constant> - <constant name="NOTIFICATION_APP_PAUSED" value="1015"> + <constant name="NOTIFICATION_APP_PAUSED" value="2015"> Notification received from the OS when the app is paused. Specific to the Android platform. </constant> diff --git a/doc/classes/Material.xml b/doc/classes/Material.xml index a0c1979646..a37c8127f0 100644 --- a/doc/classes/Material.xml +++ b/doc/classes/Material.xml @@ -4,7 +4,7 @@ Abstract base [Resource] for coloring and shading geometry. </brief_description> <description> - Material is a base [Resource] used for coloring and shading geometry. All materials inherit from it and almost all [VisualInstance] derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here. + Material is a base [Resource] used for coloring and shading geometry. All materials inherit from it and almost all [VisualInstance3D] derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here. </description> <tutorials> </tutorials> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 6ec9d60df4..316315f777 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -38,9 +38,9 @@ <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> </members> <signals> - <signal name="about_to_show"> + <signal name="about_to_popup"> <description> - Emitted when [PopupMenu] of this MenuButton is about to show. + Emitted when the [PopupMenu] of this MenuButton is about to show. </description> </signal> </signals> diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index dc7ffc8934..6958c815a6 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -10,10 +10,10 @@ </tutorials> <methods> <method name="create_convex_shape" qualifiers="const"> - <return type="Shape"> + <return type="Shape3D"> </return> <description> - Calculate a [ConvexPolygonShape] from the mesh. + Calculate a [ConvexPolygonShape3D] from the mesh. </description> </method> <method name="create_outline" qualifiers="const"> @@ -27,10 +27,10 @@ </description> </method> <method name="create_trimesh_shape" qualifiers="const"> - <return type="Shape"> + <return type="Shape3D"> </return> <description> - Calculate a [ConcavePolygonShape] from the mesh. + Calculate a [ConcavePolygonShape3D] from the mesh. </description> </method> <method name="generate_triangle_mesh" qualifiers="const"> diff --git a/doc/classes/MeshInstance.xml b/doc/classes/MeshInstance.xml deleted file mode 100644 index 6123dfa37a..0000000000 --- a/doc/classes/MeshInstance.xml +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="MeshInstance" inherits="GeometryInstance" version="4.0"> - <brief_description> - Node that instances meshes into a scenario. - </brief_description> - <description> - MeshInstance is a node that takes a [Mesh] resource and adds it to the current scenario by creating an instance of it. This is the class most often used to get 3D geometry rendered and can be used to instance a single [Mesh] in many places. This allows to reuse geometry and save on resources. When a [Mesh] has to be instanced more than thousands of times at close proximity, consider using a [MultiMesh] in a [MultiMeshInstance] instead. - </description> - <tutorials> - </tutorials> - <methods> - <method name="create_convex_collision"> - <return type="void"> - </return> - <description> - This helper creates a [StaticBody] child node with a [ConvexPolygonShape] collision shape calculated from the mesh geometry. It's mainly used for testing. - </description> - </method> - <method name="create_debug_tangents"> - <return type="void"> - </return> - <description> - This helper creates a [MeshInstance] child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing. - </description> - </method> - <method name="create_trimesh_collision"> - <return type="void"> - </return> - <description> - This helper creates a [StaticBody] child node with a [ConcavePolygonShape] collision shape calculated from the mesh geometry. It's mainly used for testing. - </description> - </method> - <method name="get_surface_material" qualifiers="const"> - <return type="Material"> - </return> - <argument index="0" name="surface" type="int"> - </argument> - <description> - Returns the [Material] for a surface of the [Mesh] resource. - </description> - </method> - <method name="get_surface_material_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the number of surface materials. - </description> - </method> - <method name="set_surface_material"> - <return type="void"> - </return> - <argument index="0" name="surface" type="int"> - </argument> - <argument index="1" name="material" type="Material"> - </argument> - <description> - Sets the [Material] for a surface of the [Mesh] resource. - </description> - </method> - </methods> - <members> - <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> - The [Mesh] resource for the instance. - </member> - <member name="skeleton" type="NodePath" setter="set_skeleton_path" getter="get_skeleton_path" default="NodePath("..")"> - [NodePath] to the [Skeleton] associated with the instance. - </member> - <member name="skin" type="Skin" setter="set_skin" getter="get_skin"> - Sets the skin to be used by this instance. - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/MeshInstance2D.xml b/doc/classes/MeshInstance2D.xml index 2781dd4626..0cfc8deb0a 100644 --- a/doc/classes/MeshInstance2D.xml +++ b/doc/classes/MeshInstance2D.xml @@ -4,7 +4,7 @@ Node used for displaying a [Mesh] in 2D. </brief_description> <description> - Node used for displaying a [Mesh] in 2D. Can be constructed from an existing [Sprite] via a tool in the editor toolbar. Select "Sprite" then "Convert to Mesh2D", select settings in popup and press "Create Mesh2D". + Node used for displaying a [Mesh] in 2D. Can be constructed from an existing [Sprite2D] via a tool in the editor toolbar. Select "Sprite2D" then "Convert to Mesh2D", select settings in popup and press "Create Mesh2D". </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/2d/2d_meshes.html</link> diff --git a/doc/classes/MeshInstance3D.xml b/doc/classes/MeshInstance3D.xml new file mode 100644 index 0000000000..c569da2df1 --- /dev/null +++ b/doc/classes/MeshInstance3D.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="MeshInstance3D" inherits="GeometryInstance3D" version="4.0"> + <brief_description> + Node that instances meshes into a scenario. + </brief_description> + <description> + MeshInstance3D is a node that takes a [Mesh] resource and adds it to the current scenario by creating an instance of it. This is the class most often used render 3D geometry and can be used to instance a single [Mesh] in many places. This allows reuse of geometry which can save on resources. When a [Mesh] has to be instanced more than thousands of times at close proximity, consider using a [MultiMesh] in a [MultiMeshInstance3D] instead. + </description> + <tutorials> + </tutorials> + <methods> + <method name="create_convex_collision"> + <return type="void"> + </return> + <description> + This helper creates a [StaticBody3D] child node with a [ConvexPolygonShape3D] collision shape calculated from the mesh geometry. It's mainly used for testing. + </description> + </method> + <method name="create_debug_tangents"> + <return type="void"> + </return> + <description> + This helper creates a [MeshInstance3D] child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing. + </description> + </method> + <method name="create_trimesh_collision"> + <return type="void"> + </return> + <description> + This helper creates a [StaticBody3D] child node with a [ConcavePolygonShape3D] collision shape calculated from the mesh geometry. It's mainly used for testing. + </description> + </method> + <method name="get_active_material" qualifiers="const"> + <return type="Material"> + </return> + <argument index="0" name="surface" type="int"> + </argument> + <description> + Returns the [Material] that will be used by the [Mesh] when drawing. This can return the [member GeometryInstance3D.material_override], the surface override [Material] defined in this [MeshInstance3D], or the surface [Material] defined in the [Mesh]. For example, if [member GeometryInstance3D.material_override] is used, all surfaces will return the override material. + </description> + </method> + <method name="get_surface_material" qualifiers="const"> + <return type="Material"> + </return> + <argument index="0" name="surface" type="int"> + </argument> + <description> + Returns the override [Material] for the specified surface of the [Mesh] resource. + </description> + </method> + <method name="get_surface_material_count" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the number of surface materials. + </description> + </method> + <method name="set_surface_material"> + <return type="void"> + </return> + <argument index="0" name="surface" type="int"> + </argument> + <argument index="1" name="material" type="Material"> + </argument> + <description> + Sets the override [Material] for the specified surface of the [Mesh] resource. This material is associated with this [MeshInstance3D] rather than with the [Mesh] resource. + </description> + </method> + </methods> + <members> + <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> + The [Mesh] resource for the instance. + </member> + <member name="skeleton" type="NodePath" setter="set_skeleton_path" getter="get_skeleton_path" default="NodePath("..")"> + [NodePath] to the [Skeleton3D] associated with the instance. + </member> + <member name="skin" type="Skin" setter="set_skin" getter="get_skin"> + Sets the skin to be used by this instance. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/MeshLibrary.xml b/doc/classes/MeshLibrary.xml index a96f6d7231..ccf6172017 100644 --- a/doc/classes/MeshLibrary.xml +++ b/doc/classes/MeshLibrary.xml @@ -94,7 +94,7 @@ </argument> <description> Returns an item's collision shapes. - The array consists of each [Shape] followed by its [Transform]. + The array consists of each [Shape3D] followed by its [Transform]. </description> </method> <method name="get_last_unused_item_id" qualifiers="const"> @@ -178,7 +178,7 @@ </argument> <description> Sets an item's collision shapes. - The array should consist of [Shape] objects, each followed by a [Transform] that will be applied to it. For shapes that should not have a transform, use [constant Transform.IDENTITY]. + The array should consist of [Shape3D] objects, each followed by a [Transform] that will be applied to it. For shapes that should not have a transform, use [constant Transform.IDENTITY]. </description> </method> </methods> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 2a1d270990..0f56ab4b95 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -4,7 +4,7 @@ Provides high-performance mesh instancing. </brief_description> <description> - MultiMesh provides low-level mesh instancing. Drawing thousands of [MeshInstance] nodes can be slow, since each object is submitted to the GPU then drawn individually. + MultiMesh provides low-level mesh instancing. Drawing thousands of [MeshInstance3D] nodes can be slow, since each object is submitted to the GPU then drawn individually. MultiMesh is much faster as it can draw thousands of instances with a single draw call, resulting in less API overhead. As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object). Since instances may have any behavior, the AABB used for visibility must be provided by the user. diff --git a/doc/classes/MultiMeshInstance2D.xml b/doc/classes/MultiMeshInstance2D.xml index 2fe5447a27..07f21514ef 100644 --- a/doc/classes/MultiMeshInstance2D.xml +++ b/doc/classes/MultiMeshInstance2D.xml @@ -5,7 +5,7 @@ </brief_description> <description> [MultiMeshInstance2D] is a specialized node to instance a [MultiMesh] resource in 2D. - Usage is the same as [MultiMeshInstance]. + Usage is the same as [MultiMeshInstance3D]. </description> <tutorials> </tutorials> diff --git a/doc/classes/MultiMeshInstance.xml b/doc/classes/MultiMeshInstance3D.xml index 6cbc0a8e04..cab17c952e 100644 --- a/doc/classes/MultiMeshInstance.xml +++ b/doc/classes/MultiMeshInstance3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MultiMeshInstance" inherits="GeometryInstance" version="4.0"> +<class name="MultiMeshInstance3D" inherits="GeometryInstance3D" version="4.0"> <brief_description> Node that instances a [MultiMesh]. </brief_description> <description> - [MultiMeshInstance] is a specialized node to instance [GeometryInstance]s based on a [MultiMesh] resource. + [MultiMeshInstance3D] is a specialized node to instance [GeometryInstance3D]s based on a [MultiMesh] resource. This is useful to optimize the rendering of a high amount of instances of a given mesh (for example trees in a forest or grass strands). </description> <tutorials> @@ -16,7 +16,7 @@ </methods> <members> <member name="multimesh" type="MultiMesh" setter="set_multimesh" getter="get_multimesh"> - The [MultiMesh] resource that will be used and shared among all instances of the [MultiMeshInstance]. + The [MultiMesh] resource that will be used and shared among all instances of the [MultiMeshInstance3D]. </member> </members> <constants> diff --git a/doc/classes/Navigation.xml b/doc/classes/Navigation3D.xml index 93170bca4a..807f0ad309 100644 --- a/doc/classes/Navigation.xml +++ b/doc/classes/Navigation3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Navigation" inherits="Spatial" version="4.0"> +<class name="Navigation3D" inherits="Node3D" version="4.0"> <brief_description> Mesh-based navigation and pathfinding node. </brief_description> <description> - Provides navigation and pathfinding within a collection of [NavigationMesh]es. These will be automatically collected from child [NavigationRegion] nodes. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on. + Provides navigation and pathfinding within a collection of [NavigationMesh]es. These will be automatically collected from child [NavigationRegion3D] nodes. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on. </description> <tutorials> </tutorials> diff --git a/doc/classes/NavigationAgent.xml b/doc/classes/NavigationAgent3D.xml index c6c9abec13..f9df1d390b 100644 --- a/doc/classes/NavigationAgent.xml +++ b/doc/classes/NavigationAgent3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationAgent" inherits="Node" version="4.0"> +<class name="NavigationAgent3D" inherits="Node" version="4.0"> <brief_description> 3D Agent used in navigation for collision avoidance. </brief_description> <description> - 3D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. This can be done by having the agent as a child of a [Navigation] node, or using [method set_navigation]. [NavigationAgent] is physics safe. + 3D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. This can be done by having the agent as a child of a [Navigation3D] node, or using [method set_navigation]. [NavigationAgent3D] is physics safe. </description> <tutorials> </tutorials> @@ -41,7 +41,7 @@ <return type="Node"> </return> <description> - Returns the [Navigation] node that the agent is using for its navigation system. + Returns the [Navigation3D] node that the agent is using for its navigation system. </description> </method> <method name="get_next_location"> @@ -85,7 +85,7 @@ <argument index="0" name="navigation" type="Node"> </argument> <description> - Sets the [Navigation] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation] node. + Sets the [Navigation3D] node used by the agent. Useful when you don't want to make the agent a child of a [Navigation3D] node. </description> </method> <method name="set_target_location"> diff --git a/doc/classes/NavigationObstacle2D.xml b/doc/classes/NavigationObstacle2D.xml index 4d12b985e0..ddd96975f1 100644 --- a/doc/classes/NavigationObstacle2D.xml +++ b/doc/classes/NavigationObstacle2D.xml @@ -4,7 +4,7 @@ 2D Obstacle used in navigation for collision avoidance. </brief_description> <description> - 2D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation2D] node, or using [method set_navigation]. [NavigationObstacle] is physics safe. + 2D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation2D] node, or using [method set_navigation]. [NavigationObstacle2D] is physics safe. </description> <tutorials> </tutorials> diff --git a/doc/classes/NavigationObstacle.xml b/doc/classes/NavigationObstacle3D.xml index 31cf01793a..e01a40ed73 100644 --- a/doc/classes/NavigationObstacle.xml +++ b/doc/classes/NavigationObstacle3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationObstacle" inherits="Node" version="4.0"> +<class name="NavigationObstacle3D" inherits="Node" version="4.0"> <brief_description> 3D Obstacle used in navigation for collision avoidance. </brief_description> <description> - 3D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation] node, or using [method set_navigation]. [NavigationObstacle] is physics safe. + 3D Obstacle used in navigation for collision avoidance. The obstacle needs navigation data to work correctly. This can be done by having the obstacle as a child of a [Navigation3D] node, or using [method set_navigation]. [NavigationObstacle3D] is physics safe. </description> <tutorials> </tutorials> @@ -13,7 +13,7 @@ <return type="Node"> </return> <description> - Returns the [Navigation] node that the obstacle is using for its navigation system. + Returns the [Navigation3D] node that the obstacle is using for its navigation system. </description> </method> <method name="set_navigation"> @@ -22,7 +22,7 @@ <argument index="0" name="navigation" type="Node"> </argument> <description> - Sets the [Navigation] node used by the obstacle. Useful when you don't want to make the obstacle a child of a [Navigation] node. + Sets the [Navigation3D] node used by the obstacle. Useful when you don't want to make the obstacle a child of a [Navigation3D] node. </description> </method> </methods> diff --git a/doc/classes/NavigationRegion.xml b/doc/classes/NavigationRegion3D.xml index a32ded2878..b70bfb6596 100644 --- a/doc/classes/NavigationRegion.xml +++ b/doc/classes/NavigationRegion3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationRegion" inherits="Spatial" version="4.0"> +<class name="NavigationRegion3D" inherits="Node3D" version="4.0"> <brief_description> A region of the navigation map. </brief_description> <description> - A region of the navigation map. It tells the [Navigation] node what can be navigated and what cannot, based on the [NavigationMesh] resource. This should be a child of a [Navigation] node (even not a direct child). + A region of the navigation map. It tells the [Navigation3D] node what can be navigated and what cannot, based on the [NavigationMesh] resource. This should be a child of a [Navigation3D] node (even not a direct child). </description> <tutorials> </tutorials> @@ -19,7 +19,7 @@ </methods> <members> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true"> - Determines if the [NavigationRegion] is enabled or disabled. + Determines if the [NavigationRegion3D] is enabled or disabled. </member> <member name="navmesh" type="NavigationMesh" setter="set_navigation_mesh" getter="get_navigation_mesh"> The [NavigationMesh] resource to use. diff --git a/doc/classes/Navigation2DServer.xml b/doc/classes/NavigationServer2D.xml index 110844c492..1b9099336c 100644 --- a/doc/classes/Navigation2DServer.xml +++ b/doc/classes/NavigationServer2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Navigation2DServer" inherits="Object" version="4.0"> +<class name="NavigationServer2D" inherits="Object" version="4.0"> <brief_description> Server interface for low-level 2D navigation access </brief_description> <description> - Navigation2DServer is the server responsible for all 2D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. + NavigationServer2D is the server responsible for all 2D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. </description> <tutorials> </tutorials> diff --git a/doc/classes/NavigationServer.xml b/doc/classes/NavigationServer3D.xml index 1b534b8458..1f621c3c81 100644 --- a/doc/classes/NavigationServer.xml +++ b/doc/classes/NavigationServer3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationServer" inherits="Object" version="4.0"> +<class name="NavigationServer3D" inherits="Object" version="4.0"> <brief_description> Server interface for low-level 3D navigation access </brief_description> <description> - NavigationServer is the server responsible for all 3D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. + NavigationServer3D is the server responsible for all 3D navigation. It creates the agents, maps, and regions for navigation to work as expected. This keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying. </description> <tutorials> </tutorials> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 717130728d..d7bff83575 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -53,7 +53,7 @@ <description> Called when there is an input event. The input event propagates up through the node tree until a node consumes it. It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_input]. - To consume the input event and stop it propagating further to other nodes, [method SceneTree.set_input_as_handled] can be called. + To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called. For gameplay input, [method _unhandled_input] and [method _unhandled_key_input] are usually a better fit as they allow the GUI to intercept the events first. </description> </method> @@ -97,7 +97,7 @@ <description> Called when an [InputEvent] hasn't been consumed by [method _input] or any GUI. The input event propagates up through the node tree until a node consumes it. It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_input]. - To consume the input event and stop it propagating further to other nodes, [method SceneTree.set_input_as_handled] can be called. + To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called. For gameplay input, this and [method _unhandled_key_input] are usually a better fit than [method _input] as they allow the GUI to intercept the events first. </description> </method> @@ -109,7 +109,7 @@ <description> Called when an [InputEventKey] hasn't been consumed by [method _input] or any GUI. The input event propagates up through the node tree until a node consumes it. It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with [method set_process_unhandled_key_input]. - To consume the input event and stop it propagating further to other nodes, [method SceneTree.set_input_as_handled] can be called. + To consume the input event and stop it propagating further to other nodes, [method Viewport.set_input_as_handled] can be called. For gameplay input, this and [method _unhandled_input] are usually a better fit than [method _input] as they allow the GUI to intercept the events first. </description> </method> @@ -938,42 +938,40 @@ Notification received from the OS when the game window is unfocused. Implemented on all platforms. </constant> - <constant name="NOTIFICATION_WM_QUIT_REQUEST" value="1006"> - Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4). + <constant name="NOTIFICATION_WM_CLOSE_REQUEST" value="1006"> + Notification received from the OS when a close request is sent (e.g. closing the window with a "Close" button or Alt+F4). Implemented on desktop platforms. </constant> <constant name="NOTIFICATION_WM_GO_BACK_REQUEST" value="1007"> Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android). Specific to the Android platform. </constant> - <constant name="NOTIFICATION_WM_UNFOCUS_REQUEST" value="1008"> - Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus). - No supported platforms currently send this notification. + <constant name="NOTIFICATION_WM_SIZE_CHANGED" value="1008"> </constant> - <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="1009"> + <constant name="NOTIFICATION_OS_MEMORY_WARNING" value="2009"> Notification received from the OS when the application is exceeding its allocated memory. Specific to the iOS platform. </constant> - <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="1010"> + <constant name="NOTIFICATION_TRANSLATION_CHANGED" value="2010"> Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like [method Object.tr]. </constant> - <constant name="NOTIFICATION_WM_ABOUT" value="1011"> + <constant name="NOTIFICATION_WM_ABOUT" value="2011"> Notification received from the OS when a request for "About" information is sent. Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_CRASH" value="1012"> + <constant name="NOTIFICATION_CRASH" value="2012"> Notification received from Godot's crash handler when the engine is about to crash. Implemented on desktop platforms if the crash handler is enabled. </constant> - <constant name="NOTIFICATION_OS_IME_UPDATE" value="1013"> + <constant name="NOTIFICATION_OS_IME_UPDATE" value="2013"> Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string). Specific to the macOS platform. </constant> - <constant name="NOTIFICATION_APP_RESUMED" value="1014"> + <constant name="NOTIFICATION_APP_RESUMED" value="2014"> Notification received from the OS when the app is resumed. Specific to the Android platform. </constant> - <constant name="NOTIFICATION_APP_PAUSED" value="1015"> + <constant name="NOTIFICATION_APP_PAUSED" value="2015"> Notification received from the OS when the app is paused. Specific to the Android platform. </constant> diff --git a/doc/classes/Spatial.xml b/doc/classes/Node3D.xml index d057db8519..ef24f638fb 100644 --- a/doc/classes/Spatial.xml +++ b/doc/classes/Node3D.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Spatial" inherits="Node" version="4.0"> +<class name="Node3D" inherits="Node" version="4.0"> <brief_description> Most basic 3D game object, parent of all 3D-related nodes. </brief_description> <description> - Most basic 3D game object, with a 3D [Transform] and visibility settings. All other 3D game objects inherit from Spatial. Use [Spatial] as a parent node to move, scale, rotate and show/hide children in a 3D project. - Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless the [Spatial] object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the [Spatial]'s transform. The word local below refers to this coordinate system. The coordinate system that is attached to the [Spatial] object itself is referred to as object-local coordinate system. + Most basic 3D game object, with a 3D [Transform] and visibility settings. All other 3D game objects inherit from Node3D. Use [Node3D] as a parent node to move, scale, rotate and show/hide children in a 3D project. + Affine operations (rotate, scale, translate) happen in parent's local coordinate system, unless the [Node3D] object is set as top-level. Affine operations in this coordinate system correspond to direct affine operations on the [Node3D]'s transform. The word local below refers to this coordinate system. The coordinate system that is attached to the [Node3D] object itself is referred to as object-local coordinate system. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/introduction_to_3d.html</link> @@ -19,17 +19,17 @@ </description> </method> <method name="get_parent_spatial" qualifiers="const"> - <return type="Spatial"> + <return type="Node3D"> </return> <description> - Returns the parent [Spatial], or an empty [Object] if no parent exists or parent is not of type [Spatial]. + Returns the parent [Node3D], or an empty [Object] if no parent exists or parent is not of type [Node3D]. </description> </method> <method name="get_world" qualifiers="const"> - <return type="World"> + <return type="World3D"> </return> <description> - Returns the current [World] resource this [Spatial] node is registered to. + Returns the current [World3D] resource this [Node3D] node is registered to. </description> </method> <method name="global_rotate"> @@ -72,7 +72,7 @@ <return type="bool"> </return> <description> - Returns whether node notifies about its local transformation changes. [Spatial] will not propagate this by default. + Returns whether node notifies about its local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="is_scale_disabled" qualifiers="const"> @@ -93,7 +93,7 @@ <return type="bool"> </return> <description> - Returns whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default. + Returns whether the node notifies about its global and local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="is_visible_in_tree" qualifiers="const"> @@ -234,7 +234,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> - Sets whether the node notifies about its local transformation changes. [Spatial] will not propagate this by default. + Sets whether the node notifies about its local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="set_notify_transform"> @@ -243,7 +243,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> - Sets whether the node notifies about its global and local transformation changes. [Spatial] will not propagate this by default. + Sets whether the node notifies about its global and local transformation changes. [Node3D] will not propagate this by default. </description> </method> <method name="show"> @@ -294,16 +294,16 @@ <return type="void"> </return> <description> - Updates the [SpatialGizmo] of this node. + Updates the [Node3DGizmo] of this node. </description> </method> </methods> <members> - <member name="gizmo" type="SpatialGizmo" setter="set_gizmo" getter="get_gizmo"> - The [SpatialGizmo] for this node. Used for example in [EditorSpatialGizmo] as custom visualization and editing handles in Editor. + <member name="gizmo" type="Node3DGizmo" setter="set_gizmo" getter="get_gizmo"> + The [Node3DGizmo] for this node. Used for example in [EditorNode3DGizmo] as custom visualization and editing handles in Editor. </member> <member name="global_transform" type="Transform" setter="set_global_transform" getter="get_global_transform"> - World space (global) [Transform] of this node. + World3D space (global) [Transform] of this node. </member> <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation"> Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle). @@ -334,17 +334,17 @@ </signals> <constants> <constant name="NOTIFICATION_TRANSFORM_CHANGED" value="2000"> - Spatial nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform. + Node3D nodes receives this notification when their global transform changes. This means that either the current or a parent node changed its transform. In order for [constant NOTIFICATION_TRANSFORM_CHANGED] to work, users first need to ask for it, with [method set_notify_transform]. </constant> <constant name="NOTIFICATION_ENTER_WORLD" value="41"> - Spatial nodes receives this notification when they are registered to new [World] resource. + Node3D nodes receives this notification when they are registered to new [World3D] resource. </constant> <constant name="NOTIFICATION_EXIT_WORLD" value="42"> - Spatial nodes receives this notification when they are unregistered from current [World] resource. + Node3D nodes receives this notification when they are unregistered from current [World3D] resource. </constant> <constant name="NOTIFICATION_VISIBILITY_CHANGED" value="43"> - Spatial nodes receives this notification when their visibility changes. + Node3D nodes receives this notification when their visibility changes. </constant> </constants> </class> diff --git a/doc/classes/SpatialGizmo.xml b/doc/classes/Node3DGizmo.xml index 5260eaa8a3..55080614fc 100644 --- a/doc/classes/SpatialGizmo.xml +++ b/doc/classes/Node3DGizmo.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpatialGizmo" inherits="Reference" version="4.0"> +<class name="Node3DGizmo" inherits="Reference" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/NodePath.xml b/doc/classes/NodePath.xml index e8ab3e536e..dc7fd1be3f 100644 --- a/doc/classes/NodePath.xml +++ b/doc/classes/NodePath.xml @@ -4,7 +4,7 @@ Pre-parsed scene tree path. </brief_description> <description> - A pre-parsed relative or absolute path in a scene tree, for use with [method Node.get_node] and similar functions. It can reference a node, a resource within a node, or a property of a node or resource. For instance, [code]"Path2D/PathFollow2D/Sprite:texture:size"[/code] would refer to the [code]size[/code] property of the [code]texture[/code] resource on the node named [code]"Sprite"[/code] which is a child of the other named nodes in the path. + A pre-parsed relative or absolute path in a scene tree, for use with [method Node.get_node] and similar functions. It can reference a node, a resource within a node, or a property of a node or resource. For instance, [code]"Path2D/PathFollow2D/Sprite2D:texture:size"[/code] would refer to the [code]size[/code] property of the [code]texture[/code] resource on the node named [code]"Sprite2D"[/code] which is a child of the other named nodes in the path. You will usually just pass a string to [method Node.get_node] and it will be automatically converted, but you may occasionally want to parse a path ahead of time with [NodePath] or the literal syntax [code]@"path"[/code]. Exporting a [NodePath] variable will give you a node selection widget in the properties panel of the editor, which can often be useful. A [NodePath] is composed of a list of slash-separated node names (like a filesystem path) and an optional colon-separated list of "subnames" which can be resources or properties. Some examples of NodePaths include the following: @@ -30,20 +30,20 @@ <argument index="0" name="from" type="String"> </argument> <description> - Creates a NodePath from a string, e.g. [code]"Path2D/PathFollow2D/Sprite:texture:size"[/code]. A path is absolute if it starts with a slash. Absolute paths are only valid in the global scene tree, not within individual scenes. In a relative path, [code]"."[/code] and [code]".."[/code] indicate the current node and its parent. + Creates a NodePath from a string, e.g. [code]"Path2D/PathFollow2D/Sprite2D:texture:size"[/code]. A path is absolute if it starts with a slash. Absolute paths are only valid in the global scene tree, not within individual scenes. In a relative path, [code]"."[/code] and [code]".."[/code] indicate the current node and its parent. The "subnames" optionally included after the path to the target node can point to resources or properties, and can also be nested. Examples of valid NodePaths (assuming that those nodes exist and have the referenced resources or properties): [codeblock] - # Points to the Sprite node - "Path2D/PathFollow2D/Sprite" - # Points to the Sprite node and its "texture" resource. - # get_node() would retrieve "Sprite", while get_node_and_resource() - # would retrieve both the Sprite node and the "texture" resource. - "Path2D/PathFollow2D/Sprite:texture" - # Points to the Sprite node and its "position" property. - "Path2D/PathFollow2D/Sprite:position" - # Points to the Sprite node and the "x" component of its "position" property. - "Path2D/PathFollow2D/Sprite:position:x" + # Points to the Sprite2D node + "Path2D/PathFollow2D/Sprite2D" + # Points to the Sprite2D node and its "texture" resource. + # get_node() would retrieve "Sprite2D", while get_node_and_resource() + # would retrieve both the Sprite2D node and the "texture" resource. + "Path2D/PathFollow2D/Sprite2D:texture" + # Points to the Sprite2D node and its "position" property. + "Path2D/PathFollow2D/Sprite2D:position" + # Points to the Sprite2D node and the "x" component of its "position" property. + "Path2D/PathFollow2D/Sprite2D:position:x" # Absolute path (from "root") "/root/Level/Path2D" [/codeblock] @@ -69,7 +69,7 @@ <description> Returns all subnames concatenated with a colon character ([code]:[/code]) as separator, i.e. the right side of the first colon in a node path. [codeblock] - var nodepath = NodePath("Path2D/PathFollow2D/Sprite:texture:load_path") + var nodepath = NodePath("Path2D/PathFollow2D/Sprite2D:texture:load_path") print(nodepath.get_concatenated_subnames()) # texture:load_path [/codeblock] </description> @@ -82,7 +82,7 @@ <description> Gets the node name indicated by [code]idx[/code] (0 to [method get_name_count]). [codeblock] - var node_path = NodePath("Path2D/PathFollow2D/Sprite") + var node_path = NodePath("Path2D/PathFollow2D/Sprite2D") print(node_path.get_name(0)) # Path2D print(node_path.get_name(1)) # PathFollow2D print(node_path.get_name(2)) # Sprite @@ -94,7 +94,7 @@ </return> <description> Gets the number of node names which make up the path. Subnames (see [method get_subname_count]) are not included. - For example, [code]"Path2D/PathFollow2D/Sprite"[/code] has 3 names. + For example, [code]"Path2D/PathFollow2D/Sprite2D"[/code] has 3 names. </description> </method> <method name="get_subname"> @@ -105,7 +105,7 @@ <description> Gets the resource or property name indicated by [code]idx[/code] (0 to [method get_subname_count]). [codeblock] - var node_path = NodePath("Path2D/PathFollow2D/Sprite:texture:load_path") + var node_path = NodePath("Path2D/PathFollow2D/Sprite2D:texture:load_path") print(node_path.get_subname(0)) # texture print(node_path.get_subname(1)) # load_path [/codeblock] @@ -116,7 +116,7 @@ </return> <description> Gets the number of resource or property names ("subnames") in the path. Each subname is listed after a colon character ([code]:[/code]) in the node path. - For example, [code]"Path2D/PathFollow2D/Sprite:texture:load_path"[/code] has 2 subnames. + For example, [code]"Path2D/PathFollow2D/Sprite2D:texture:load_path"[/code] has 2 subnames. </description> </method> <method name="is_absolute"> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index d43c395433..db79ee7765 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -9,24 +9,6 @@ <tutorials> </tutorials> <methods> - <method name="alert"> - <return type="void"> - </return> - <argument index="0" name="text" type="String"> - </argument> - <argument index="1" name="title" type="String" default=""Alert!""> - </argument> - <description> - Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed. - </description> - </method> - <method name="can_draw" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the host OS allows drawing. - </description> - </method> <method name="can_use_threads" qualifiers="const"> <return type="bool"> </return> @@ -34,13 +16,6 @@ Returns [code]true[/code] if the current host platform is using multiple threads. </description> </method> - <method name="center_window"> - <return type="void"> - </return> - <description> - Centers the window on the screen if in windowed mode. - </description> - </method> <method name="close_midi_inputs"> <return type="void"> </return> @@ -133,22 +108,6 @@ Returns the keycode of the given string (e.g. "Escape"). </description> </method> - <method name="get_audio_driver_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the total number of available audio drivers. - </description> - </method> - <method name="get_audio_driver_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="driver" type="int"> - </argument> - <description> - Returns the audio driver name for the given index. - </description> - </method> <method name="get_cmdline_args"> <return type="PackedStringArray"> </return> @@ -165,13 +124,6 @@ [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> - <method name="get_current_video_driver" qualifiers="const"> - <return type="int" enum="OS.VideoDriver"> - </return> - <description> - Returns the currently used video driver, using one of the values from [enum VideoDriver]. - </description> - </method> <method name="get_date" qualifiers="const"> <return type="Dictionary"> </return> @@ -224,24 +176,6 @@ [b]Note:[/b] This method is implemented on Android. </description> </method> - <method name="get_ime_selection" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the IME cursor position (the currently-edited portion of the string) relative to the characters in the composition string. - [constant MainLoop.NOTIFICATION_OS_IME_UPDATE] is sent to the application to notify it of changes to the IME cursor position. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="get_ime_text" qualifiers="const"> - <return type="String"> - </return> - <description> - Returns the IME intermediate composition string. - [constant MainLoop.NOTIFICATION_OS_IME_UPDATE] is sent to the application to notify it of changes to the IME composition string. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> <method name="get_keycode_string" qualifiers="const"> <return type="String"> </return> @@ -252,15 +186,6 @@ See also [member InputEventKey.keycode] and [method InputEventKey.get_keycode_with_modifiers]. </description> </method> - <method name="get_latin_keyboard_variant" qualifiers="const"> - <return type="String"> - </return> - <description> - Returns the current latin keyboard variant as a String. - Possible return values are: [code]"QWERTY"[/code], [code]"AZERTY"[/code], [code]"QZERTY"[/code], [code]"DVORAK"[/code], [code]"NEO"[/code], [code]"COLEMAK"[/code] or [code]"ERROR"[/code]. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. Returns [code]"QWERTY"[/code] on unsupported platforms. - </description> - </method> <method name="get_locale" qualifiers="const"> <return type="String"> </return> @@ -298,57 +223,6 @@ Returns the number of threads available on the host machine. </description> </method> - <method name="get_real_window_size" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the window size including decorations like window borders. - </description> - </method> - <method name="get_screen_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the number of displays attached to the host machine. - </description> - </method> - <method name="get_screen_dpi" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> - <description> - Returns the dots per inch density of the specified screen. If [code]screen[/code] is [/code]-1[/code] (the default value), the current screen will be used. - On Android devices, the actual screen densities are grouped into six generalized densities: - [codeblock] - ldpi - 120 dpi - mdpi - 160 dpi - hdpi - 240 dpi - xhdpi - 320 dpi - xxhdpi - 480 dpi - xxxhdpi - 640 dpi - [/codeblock] - [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows. Returns [code]72[/code] on unsupported platforms. - </description> - </method> - <method name="get_screen_position" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> - <description> - Returns the position of the specified screen by index. If [code]screen[/code] is [/code]-1[/code] (the default value), the current screen will be used. - </description> - </method> - <method name="get_screen_size" qualifiers="const"> - <return type="Vector2"> - </return> - <argument index="0" name="screen" type="int" default="-1"> - </argument> - <description> - Returns the dimensions in pixels of the specified screen. If [code]screen[/code] is [/code]-1[/code] (the default value), the current screen will be used. - </description> - </method> <method name="get_splash_tick_msec" qualifiers="const"> <return type="int"> </return> @@ -461,84 +335,6 @@ If the project name is empty, [code]user://[/code] falls back to [code]res://[/code]. </description> </method> - <method name="get_video_driver_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the number of video drivers supported on the current platform. - </description> - </method> - <method name="get_video_driver_name" qualifiers="const"> - <return type="String"> - </return> - <argument index="0" name="driver" type="int" enum="OS.VideoDriver"> - </argument> - <description> - Returns the name of the video driver matching the given [code]driver[/code] index. This index is a value from [enum VideoDriver], and you can use [method get_current_video_driver] to get the current backend's index. - </description> - </method> - <method name="get_virtual_keyboard_height"> - <return type="int"> - </return> - <description> - Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden. - </description> - </method> - <method name="get_window_safe_area" qualifiers="const"> - <return type="Rect2"> - </return> - <description> - Returns unobscured area of the window where interactive controls should be rendered. - </description> - </method> - <method name="global_menu_add_item"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <argument index="1" name="label" type="String"> - </argument> - <argument index="2" name="id" type="Variant"> - </argument> - <argument index="3" name="meta" type="Variant"> - </argument> - <description> - Add a new item with text "label" to global menu. Use "_dock" menu to add item to the macOS dock icon menu. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="global_menu_add_separator"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <description> - Add a separator between items. Separators also occupy an index. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="global_menu_clear"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <description> - Clear the global menu, in effect removing all items. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> - <method name="global_menu_remove_item"> - <return type="void"> - </return> - <argument index="0" name="menu" type="String"> - </argument> - <argument index="1" name="idx" type="int"> - </argument> - <description> - Removes the item at index "idx" from the global menu. Note that the indexes of items after the removed item are going to be shifted by one. - [b]Note:[/b] This method is implemented on macOS. - </description> - </method> <method name="has_environment" qualifiers="const"> <return type="bool"> </return> @@ -558,27 +354,6 @@ [b]Note:[/b] Tag names are case-sensitive. </description> </method> - <method name="has_touchscreen_ui_hint" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the device has a touchscreen or emulates one. - </description> - </method> - <method name="has_virtual_keyboard" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the platform has a virtual keyboard, [code]false[/code] otherwise. - </description> - </method> - <method name="hide_virtual_keyboard"> - <return type="void"> - </return> - <description> - Hides the virtual keyboard if it is shown, does nothing otherwise. - </description> - </method> <method name="is_debug_build" qualifiers="const"> <return type="bool"> </return> @@ -597,13 +372,6 @@ Returns [code]true[/code] if the input keycode corresponds to a Unicode character. </description> </method> - <method name="is_ok_left_and_cancel_right" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the [b]OK[/b] button should appear on the left and [b]Cancel[/b] on the right. - </description> - </method> <method name="is_stdout_verbose" qualifiers="const"> <return type="bool"> </return> @@ -618,21 +386,6 @@ If [code]true[/code], the [code]user://[/code] file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable. </description> </method> - <method name="is_window_always_on_top" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the window should always be on top of other windows. - </description> - </method> - <method name="is_window_focused" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the window is currently focused. - [b]Note:[/b] Only implemented on desktop platforms. On other platforms, it will always return [code]true[/code]. - </description> - </method> <method name="kill"> <return type="int" enum="Error"> </return> @@ -644,62 +397,6 @@ [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows. </description> </method> - <method name="move_window_to_foreground"> - <return type="void"> - </return> - <description> - Moves the window to the front. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="native_video_is_playing"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if native video is playing. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> - <method name="native_video_pause"> - <return type="void"> - </return> - <description> - Pauses native video playback. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> - <method name="native_video_play"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <argument index="1" name="volume" type="float"> - </argument> - <argument index="2" name="audio_track" type="String"> - </argument> - <argument index="3" name="subtitle_track" type="String"> - </argument> - <description> - Plays native video from the specified path, at the given volume and with audio and subtitle tracks. - [b]Note:[/b] This method is 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"> - <return type="void"> - </return> - <description> - Stops native video playback. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> - <method name="native_video_unpause"> - <return type="void"> - </return> - <description> - Resumes native video playback. - [b]Note:[/b] This method is implemented on Android and iOS. - </description> - </method> <method name="open_midi_inputs"> <return type="void"> </return> @@ -742,14 +439,6 @@ Shows all resources currently used by the game. </description> </method> - <method name="request_attention"> - <return type="void"> - </return> - <description> - Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> <method name="request_permission"> <return type="bool"> </return> @@ -767,51 +456,6 @@ [b]Note:[/b] This method is implemented on Android. </description> </method> - <method name="set_icon"> - <return type="void"> - </return> - <argument index="0" name="icon" type="Image"> - </argument> - <description> - Sets the game's icon using an [Image] resource. - The same image is used for window caption, taskbar/dock and window selection dialog. Image is scaled as needed. - [b]Note:[/b] This method is implemented on HTML5, Linux, macOS and Windows. - </description> - </method> - <method name="set_ime_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> - <description> - Sets whether IME input mode should be enabled. - If active IME handles key events before the application and creates an composition string and suggestion list. - Application can retrieve the composition status by using [method get_ime_selection] and [method get_ime_text] functions. - Completed composition string is committed when input is finished. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="set_ime_position"> - <return type="void"> - </return> - <argument index="0" name="position" type="Vector2"> - </argument> - <description> - Sets position of IME suggestion list popup (in window coordinates). - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="set_native_icon"> - <return type="void"> - </return> - <argument index="0" name="filename" type="String"> - </argument> - <description> - Sets the game's icon using a multi-size platform-specific icon file ([code]*.ico[/code] on Windows and [code]*.icns[/code] on macOS). - Appropriate size sub-icons are used for window caption, taskbar/dock and window selection dialog. - [b]Note:[/b] This method is implemented on macOS and Windows. - </description> - </method> <method name="set_thread_name"> <return type="int" enum="Error"> </return> @@ -830,27 +474,6 @@ Enables backup saves if [code]enabled[/code] is [code]true[/code]. </description> </method> - <method name="set_window_always_on_top"> - <return type="void"> - </return> - <argument index="0" name="enabled" type="bool"> - </argument> - <description> - Sets whether the window should always be on top. - [b]Note:[/b] This method is implemented on Linux, macOS and Windows. - </description> - </method> - <method name="set_window_title"> - <return type="void"> - </return> - <argument index="0" name="title" type="String"> - </argument> - <description> - Sets the window title to the specified string. - [b]Note:[/b] This should be used sporadically. Don't set this every frame, as that will negatively affect performance on some window managers. - [b]Note:[/b] This method is implemented on HTML5, Linux, macOS and Windows. - </description> - </method> <method name="shell_open"> <return type="int" enum="Error"> </return> @@ -864,82 +487,18 @@ [b]Note:[/b] This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows. </description> </method> - <method name="show_virtual_keyboard"> - <return type="void"> - </return> - <argument index="0" name="existing_text" type="String" default=""""> - </argument> - <description> - Shows the virtual keyboard if the platform has one. The [code]existing_text[/code] parameter is useful for implementing your own LineEdit, as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions). - [b]Note:[/b] This method is implemented on Android, iOS and UWP. - </description> - </method> </methods> <members> - <member name="clipboard" type="String" setter="set_clipboard" getter="get_clipboard" default=""""> - The clipboard from the host OS. Might be unavailable on some platforms. - </member> - <member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen" default="0"> - The current screen index (starting from 0). - </member> <member name="exit_code" type="int" setter="set_exit_code" getter="get_exit_code" default="0"> The exit code passed to the OS when the main loop exits. By convention, an exit code of [code]0[/code] indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive). [b]Note:[/b] This value will be ignored if using [method SceneTree.quit] with an [code]exit_code[/code] argument passed. </member> - <member name="keep_screen_on" type="bool" setter="set_keep_screen_on" getter="is_keep_screen_on" default="true"> - If [code]true[/code], the engine tries to keep the screen on while the game is running. Useful on mobile. - </member> <member name="low_processor_usage_mode" type="bool" setter="set_low_processor_usage_mode" getter="is_in_low_processor_usage_mode" default="false"> If [code]true[/code], the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile. </member> <member name="low_processor_usage_mode_sleep_usec" type="int" setter="set_low_processor_usage_mode_sleep_usec" getter="get_low_processor_usage_mode_sleep_usec" default="6900"> The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage. </member> - <member name="max_window_size" type="Vector2" setter="set_max_window_size" getter="get_max_window_size" default="Vector2( 0, 0 )"> - The maximum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to [code](0, 0)[/code] to reset to the system default value. - </member> - <member name="min_window_size" type="Vector2" setter="set_min_window_size" getter="get_min_window_size" default="Vector2( 0, 0 )"> - The minimum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to [code](0, 0)[/code] to reset to the system default value. - </member> - <member name="screen_orientation" type="int" setter="set_screen_orientation" getter="get_screen_orientation" enum="_OS.ScreenOrientation" default="0"> - The current screen orientation. - </member> - <member name="vsync_enabled" type="bool" setter="set_use_vsync" getter="is_vsync_enabled" default="true"> - If [code]true[/code], vertical synchronization (Vsync) is enabled. - </member> - <member name="vsync_via_compositor" type="bool" setter="set_vsync_via_compositor" getter="is_vsync_via_compositor_enabled" default="false"> - If [code]true[/code] and [code]vsync_enabled[/code] is true, the operating system's window compositor will be used for vsync when the compositor is enabled and the game is in windowed mode. - [b]Note:[/b] This option is experimental and meant to alleviate stutter experienced by some users. However, some users have experienced a Vsync framerate halving (e.g. from 60 FPS to 30 FPS) when using it. - [b]Note:[/b] This property is only implemented on Windows. - </member> - <member name="window_borderless" type="bool" setter="set_borderless_window" getter="get_borderless_window" default="false"> - If [code]true[/code], removes the window frame. - [b]Note:[/b] Setting [code]window_borderless[/code] to [code]false[/code] disables per-pixel transparency. - </member> - <member name="window_fullscreen" type="bool" setter="set_window_fullscreen" getter="is_window_fullscreen" default="false"> - If [code]true[/code], the window is fullscreen. - </member> - <member name="window_maximized" type="bool" setter="set_window_maximized" getter="is_window_maximized" default="false"> - If [code]true[/code], the window is maximized. - </member> - <member name="window_minimized" type="bool" setter="set_window_minimized" getter="is_window_minimized" default="false"> - If [code]true[/code], the window is minimized. - </member> - <member name="window_per_pixel_transparency_enabled" type="bool" setter="set_window_per_pixel_transparency_enabled" getter="get_window_per_pixel_transparency_enabled" default="false"> - If [code]true[/code], the window background is transparent and window frame is removed. - Use [code]get_tree().get_root().set_transparent_background(true)[/code] to disable main viewport background rendering. - [b]Note:[/b] This property has no effect if [b]Project > Project Settings > Display > Window > Per-pixel transparency > Allowed[/b] setting is disabled. - [b]Note:[/b] This property is implemented on HTML5, Linux, macOS and Windows. - </member> - <member name="window_position" type="Vector2" setter="set_window_position" getter="get_window_position" default="Vector2( 0, 0 )"> - The window position relative to the screen, the origin is the top left corner, +Y axis goes to the bottom and +X axis goes to the right. - </member> - <member name="window_resizable" type="bool" setter="set_window_resizable" getter="is_window_resizable" default="true"> - If [code]true[/code], the window is resizable by the user. - </member> - <member name="window_size" type="Vector2" setter="set_window_size" getter="get_window_size" default="Vector2( 0, 0 )"> - The size of the window (without counting window manager decorations). - </member> </members> <constants> <constant name="VIDEO_DRIVER_GLES2" value="0" enum="VideoDriver"> @@ -1005,27 +564,6 @@ <constant name="MONTH_DECEMBER" value="12" enum="Month"> December. </constant> - <constant name="SCREEN_ORIENTATION_LANDSCAPE" value="0" enum="ScreenOrientation"> - Landscape screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_PORTRAIT" value="1" enum="ScreenOrientation"> - Portrait screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_REVERSE_LANDSCAPE" value="2" enum="ScreenOrientation"> - Reverse landscape screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_REVERSE_PORTRAIT" value="3" enum="ScreenOrientation"> - Reverse portrait screen orientation. - </constant> - <constant name="SCREEN_ORIENTATION_SENSOR_LANDSCAPE" value="4" enum="ScreenOrientation"> - Uses landscape or reverse landscape based on the hardware sensor. - </constant> - <constant name="SCREEN_ORIENTATION_SENSOR_PORTRAIT" value="5" enum="ScreenOrientation"> - Uses portrait or reverse portrait based on the hardware sensor. - </constant> - <constant name="SCREEN_ORIENTATION_SENSOR" value="6" enum="ScreenOrientation"> - Uses most suitable orientation based on the hardware sensor. - </constant> <constant name="SYSTEM_DIR_DESKTOP" value="0" enum="SystemDir"> Desktop directory path. </constant> diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index 33f5fc0f35..35e87d1a2a 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -314,7 +314,7 @@ <method name="has_signal" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="signal" type="String"> + <argument index="0" name="signal" type="StringName"> </argument> <description> Returns [code]true[/code] if the given [code]signal[/code] exists. diff --git a/doc/classes/OmniLight.xml b/doc/classes/OmniLight3D.xml index dc57efd3f9..0bbc987156 100644 --- a/doc/classes/OmniLight.xml +++ b/doc/classes/OmniLight3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="OmniLight" inherits="Light" version="4.0"> +<class name="OmniLight3D" inherits="Light3D" version="4.0"> <brief_description> Omnidirectional light, such as a light bulb or a candle. </brief_description> <description> - An Omnidirectional light is a type of [Light] that emits light in all directions. The light is attenuated by distance and this attenuation can be configured by changing its energy, radius, and attenuation parameters. + An Omnidirectional light is a type of [Light3D] that emits light in all directions. The light is attenuated by distance and this attenuation can be configured by changing its energy, radius, and attenuation parameters. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/lights_and_shadows.html</link> @@ -18,7 +18,7 @@ <member name="omni_range" type="float" setter="set_param" getter="get_param" default="5.0"> The light's radius. </member> - <member name="omni_shadow_mode" type="int" setter="set_shadow_mode" getter="get_shadow_mode" enum="OmniLight.ShadowMode" default="1"> + <member name="omni_shadow_mode" type="int" setter="set_shadow_mode" getter="get_shadow_mode" enum="OmniLight3D.ShadowMode" default="1"> See [enum ShadowMode]. </member> </members> diff --git a/doc/classes/Panel.xml b/doc/classes/Panel.xml index a3f6a0be8f..7285bc9e2e 100644 --- a/doc/classes/Panel.xml +++ b/doc/classes/Panel.xml @@ -10,11 +10,21 @@ </tutorials> <methods> </methods> + <members> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Panel.Mode" default="0"> + </member> + </members> <constants> + <constant name="MODE_BACKGROUND" value="0" enum="Mode"> + </constant> + <constant name="MODE_FOREGROUND" value="1" enum="Mode"> + </constant> </constants> <theme_items> <theme_item name="panel" type="StyleBox"> The style of this [Panel]. </theme_item> + <theme_item name="panel_fg" type="StyleBox"> + </theme_item> </theme_items> </class> diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml index 1e90214e47..d04ac5bdce 100644 --- a/doc/classes/ParticlesMaterial.xml +++ b/doc/classes/ParticlesMaterial.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="ParticlesMaterial" inherits="Material" version="4.0"> <brief_description> - Particle properties for [Particles] and [Particles2D] nodes. + Particle properties for [GPUParticles3D] and [GPUParticles2D] nodes. </brief_description> <description> - ParticlesMaterial defines particle properties and behavior. It is used in the [code]process_material[/code] of [Particles] and [Particles2D] emitter nodes. + ParticlesMaterial defines particle properties and behavior. It is used in the [code]process_material[/code] of [GPUParticles3D] and [GPUParticles2D] emitter nodes. Some of this material's properties are applied to each particle when emitted, while others can have a [CurveTexture] applied to vary values over the lifetime of the particle. When a randomness ratio is applied to a property it is used to scale that property by a random amount. The random ratio is used to interpolate between [code]1.0[/code] and a random number less than one, the result is multiplied by the property to obtain the randomized property. For example a random ratio of [code]0.4[/code] would scale the original property between [code]0.4-1.0[/code] of its original value. </description> @@ -132,7 +132,7 @@ Animation speed randomness ratio. </member> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> - Each particle's initial color. If the [Particles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. + Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. </member> <member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp"> Each particle's color will vary along this [GradientTexture]. diff --git a/doc/classes/Path.xml b/doc/classes/Path3D.xml index 801e86ff9e..b97e7efd5d 100644 --- a/doc/classes/Path.xml +++ b/doc/classes/Path3D.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Path" inherits="Spatial" version="4.0"> +<class name="Path3D" inherits="Node3D" version="4.0"> <brief_description> - Contains a [Curve3D] path for [PathFollow] nodes to follow. + Contains a [Curve3D] path for [PathFollow3D] nodes to follow. </brief_description> <description> - Can have [PathFollow] child nodes moving along the [Curve3D]. See [PathFollow] for more information on the usage. - Note that the path is considered as relative to the moved nodes (children of [PathFollow]). As such, the curve should usually start with a zero vector [code](0, 0, 0)[/code]. + Can have [PathFollow3D] child nodes moving along the [Curve3D]. See [PathFollow3D] for more information on the usage. + Note that the path is considered as relative to the moved nodes (children of [PathFollow3D]). As such, the curve should usually start with a zero vector [code](0, 0, 0)[/code]. </description> <tutorials> </tutorials> diff --git a/doc/classes/PathFollow.xml b/doc/classes/PathFollow3D.xml index 85ca5b787f..f405bdedfc 100644 --- a/doc/classes/PathFollow.xml +++ b/doc/classes/PathFollow3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PathFollow" inherits="Spatial" version="4.0"> +<class name="PathFollow3D" inherits="Node3D" version="4.0"> <brief_description> - Point sampler for a [Path]. + Point sampler for a [Path3D]. </brief_description> <description> - This node takes its parent [Path], and returns the coordinates of a point within it, given a distance from the first vertex. + This node takes its parent [Path3D], and returns the coordinates of a point within it, given a distance from the first vertex. It is useful for making other nodes follow a path, without coding the movement pattern. For that, the nodes must be children of this node. The descendant nodes will then move accordingly when setting an offset in this node. </description> <tutorials> @@ -14,7 +14,7 @@ <members> <member name="cubic_interp" type="bool" setter="set_cubic_interpolation" getter="get_cubic_interpolation" default="true"> If [code]true[/code], the position between two cached points is interpolated cubically, and linearly otherwise. - The points along the [Curve3D] of the [Path] are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough. + The points along the [Curve3D] of the [Path3D] are precomputed before use, for faster calculations. The point at the requested offset is then calculated interpolating between two adjacent cached points. This may present a problem if the curve makes sharp turns, as the cached points may not follow the curve closely enough. There are two answers to this problem: either increase the number of cached points and increase memory consumption, or make a cubic interpolation between two points at the cost of (slightly) slower calculations. </member> <member name="h_offset" type="float" setter="set_h_offset" getter="get_h_offset" default="0.0"> @@ -26,7 +26,7 @@ <member name="offset" type="float" setter="set_offset" getter="get_offset" default="0.0"> The distance from the first vertex, measured in 3D units along the path. This sets this node's position to a point within the path. </member> - <member name="rotation_mode" type="int" setter="set_rotation_mode" getter="get_rotation_mode" enum="PathFollow.RotationMode" default="3"> + <member name="rotation_mode" type="int" setter="set_rotation_mode" getter="get_rotation_mode" enum="PathFollow3D.RotationMode" default="3"> Allows or forbids rotation on one or more axes, depending on the [enum RotationMode] constants being used. </member> <member name="unit_offset" type="float" setter="set_unit_offset" getter="get_unit_offset" default="0.0"> @@ -38,19 +38,19 @@ </members> <constants> <constant name="ROTATION_NONE" value="0" enum="RotationMode"> - Forbids the PathFollow to rotate. + Forbids the PathFollow3D to rotate. </constant> <constant name="ROTATION_Y" value="1" enum="RotationMode"> - Allows the PathFollow to rotate in the Y axis only. + Allows the PathFollow3D to rotate in the Y axis only. </constant> <constant name="ROTATION_XY" value="2" enum="RotationMode"> - Allows the PathFollow to rotate in both the X, and Y axes. + Allows the PathFollow3D to rotate in both the X, and Y axes. </constant> <constant name="ROTATION_XYZ" value="3" enum="RotationMode"> - Allows the PathFollow to rotate in any axis. + Allows the PathFollow3D to rotate in any axis. </constant> <constant name="ROTATION_ORIENTED" value="4" enum="RotationMode"> - Uses the up vector information in a [Curve3D] to enforce orientation. This rotation mode requires the [Path]'s [member Curve3D.up_vector_enabled] property to be set to [code]true[/code]. + Uses the up vector information in a [Curve3D] to enforce orientation. This rotation mode requires the [Path3D]'s [member Curve3D.up_vector_enabled] property to be set to [code]true[/code]. </constant> </constants> </class> diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml index 378b165644..2a0c153267 100644 --- a/doc/classes/Performance.xml +++ b/doc/classes/Performance.xml @@ -95,7 +95,7 @@ Number of islands in the 2D physics engine. </constant> <constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="23" enum="Monitor"> - Number of active [RigidBody] and [VehicleBody] nodes in the game. + Number of active [RigidBody3D] and [VehicleBody3D] nodes in the game. </constant> <constant name="PHYSICS_3D_COLLISION_PAIRS" value="24" enum="Monitor"> Number of collision pairs in the 3D physics engine. diff --git a/doc/classes/PhysicalBone.xml b/doc/classes/PhysicalBone3D.xml index bb31f03c18..d45c72ee87 100644 --- a/doc/classes/PhysicalBone.xml +++ b/doc/classes/PhysicalBone3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicalBone" inherits="PhysicsBody" version="4.0"> +<class name="PhysicalBone3D" inherits="PhysicsBody3D" version="4.0"> <brief_description> </brief_description> <description> @@ -55,7 +55,7 @@ </member> <member name="joint_offset" type="Transform" setter="set_joint_offset" getter="get_joint_offset" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> </member> - <member name="joint_type" type="int" setter="set_joint_type" getter="get_joint_type" enum="PhysicalBone.JointType" default="0"> + <member name="joint_type" type="int" setter="set_joint_type" getter="get_joint_type" enum="PhysicalBone3D.JointType" default="0"> </member> <member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0"> </member> diff --git a/doc/classes/PhysicalSkyMaterial.xml b/doc/classes/PhysicalSkyMaterial.xml index 705c063257..89b43158dc 100644 --- a/doc/classes/PhysicalSkyMaterial.xml +++ b/doc/classes/PhysicalSkyMaterial.xml @@ -5,7 +5,7 @@ </brief_description> <description> The [PhysicalSkyMaterial] uses the Preetham analytic daylight model to draw a sky based on physical properties. This results in a substantially more realistic sky than the [ProceduralSkyMaterial], but it is slightly slower and less flexible. - The [PhysicalSkyMaterial] only supports one sun. The color, energy, and direction of the sun are taken from the first [DirectionalLight] in the scene tree. + The [PhysicalSkyMaterial] only supports one sun. The color, energy, and direction of the sun are taken from the first [DirectionalLight3D] in the scene tree. As it is based on a daylight model, the sky fades to black as the sunset ends. If you want a full day/night cycle, you will have to add a night sky by converting this to a [ShaderMaterial] and adding a night sky directly into the resulting shader. </description> <tutorials> diff --git a/doc/classes/Physics2DDirectBodyStateSW.xml b/doc/classes/Physics2DDirectBodyStateSW.xml deleted file mode 100644 index 11f1140ca8..0000000000 --- a/doc/classes/Physics2DDirectBodyStateSW.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DDirectBodyStateSW" inherits="Physics2DDirectBodyState" version="4.0"> - <brief_description> - Software implementation of [Physics2DDirectBodyState]. - </brief_description> - <description> - Software implementation of [Physics2DDirectBodyState]. This object exposes no new methods or properties and should not be used, as [Physics2DDirectBodyState] selects the best implementation available. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <constants> - </constants> -</class> diff --git a/doc/classes/PhysicsBody.xml b/doc/classes/PhysicsBody3D.xml index c0927a5b53..f0ba2a7f5f 100644 --- a/doc/classes/PhysicsBody.xml +++ b/doc/classes/PhysicsBody3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsBody" inherits="CollisionObject" version="4.0"> +<class name="PhysicsBody3D" inherits="CollisionObject3D" version="4.0"> <brief_description> Base class for all objects affected by physics in 3D space. </brief_description> <description> - PhysicsBody is an abstract base class for implementing a physics body. All *Body types inherit from it. + PhysicsBody3D is an abstract base class for implementing a physics body. All *Body types inherit from it. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html</link> diff --git a/doc/classes/Physics2DDirectBodyState.xml b/doc/classes/PhysicsDirectBodyState2D.xml index d9d402ac9a..46205fecd1 100644 --- a/doc/classes/Physics2DDirectBodyState.xml +++ b/doc/classes/PhysicsDirectBodyState2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DDirectBodyState" inherits="Object" version="4.0"> +<class name="PhysicsDirectBodyState2D" inherits="Object" version="4.0"> <brief_description> - Direct access object to a physics body in the [Physics2DServer]. + Direct access object to a physics body in the [PhysicsServer2D]. </brief_description> <description> - Provides direct access to a physics body in the [Physics2DServer], allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See [method RigidBody2D._integrate_forces]. + Provides direct access to a physics body in the [PhysicsServer2D], allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See [method RigidBody2D._integrate_forces]. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html</link> @@ -119,7 +119,7 @@ <argument index="0" name="contact_idx" type="int"> </argument> <description> - Returns the collided shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + Returns the collided shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method PhysicsServer2D.shape_set_data]. </description> </method> <method name="get_contact_collider_velocity_at_position" qualifiers="const"> @@ -167,7 +167,7 @@ </description> </method> <method name="get_space_state"> - <return type="Physics2DDirectSpaceState"> + <return type="PhysicsDirectSpaceState2D"> </return> <description> Returns the current state of the space, useful for queries. diff --git a/doc/classes/PhysicsDirectBodyState2DSW.xml b/doc/classes/PhysicsDirectBodyState2DSW.xml new file mode 100644 index 0000000000..94fc4213b7 --- /dev/null +++ b/doc/classes/PhysicsDirectBodyState2DSW.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="PhysicsDirectBodyState2DSW" inherits="PhysicsDirectBodyState2D" version="4.0"> + <brief_description> + Software implementation of [PhysicsDirectBodyState2D]. + </brief_description> + <description> + Software implementation of [PhysicsDirectBodyState2D]. This object exposes no new methods or properties and should not be used, as [PhysicsDirectBodyState2D] selects the best implementation available. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/PhysicsDirectBodyState.xml b/doc/classes/PhysicsDirectBodyState3D.xml index 24cf4961be..1ee520fe5f 100644 --- a/doc/classes/PhysicsDirectBodyState.xml +++ b/doc/classes/PhysicsDirectBodyState3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsDirectBodyState" inherits="Object" version="4.0"> +<class name="PhysicsDirectBodyState3D" inherits="Object" version="4.0"> <brief_description> - Direct access object to a physics body in the [PhysicsServer]. + Direct access object to a physics body in the [PhysicsServer3D]. </brief_description> <description> - Provides direct access to a physics body in the [PhysicsServer], allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See [method RigidBody._integrate_forces]. + Provides direct access to a physics body in the [PhysicsServer3D], allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See [method RigidBody3D._integrate_forces]. </description> <tutorials> </tutorials> @@ -128,7 +128,7 @@ </return> <description> Returns the number of contacts this body has with other bodies. - [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody.contact_monitor]. + [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody3D.contact_monitor]. </description> </method> <method name="get_contact_impulse" qualifiers="const"> @@ -168,7 +168,7 @@ </description> </method> <method name="get_space_state"> - <return type="PhysicsDirectSpaceState"> + <return type="PhysicsDirectSpaceState3D"> </return> <description> Returns the current state of the space, useful for queries. diff --git a/doc/classes/Physics2DDirectSpaceState.xml b/doc/classes/PhysicsDirectSpaceState2D.xml index 662a823d84..d85d7794dd 100644 --- a/doc/classes/Physics2DDirectSpaceState.xml +++ b/doc/classes/PhysicsDirectSpaceState2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DDirectSpaceState" inherits="Object" version="4.0"> +<class name="PhysicsDirectSpaceState2D" inherits="Object" version="4.0"> <brief_description> - Direct access object to a space in the [Physics2DServer]. + Direct access object to a space in the [PhysicsServer2D]. </brief_description> <description> - Direct access object to a space in the [Physics2DServer]. It's used mainly to do queries against objects and areas residing in a given space. + Direct access object to a space in the [PhysicsServer2D]. It's used mainly to do queries against objects and areas residing in a given space. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html</link> @@ -13,35 +13,35 @@ <method name="cast_motion"> <return type="Array"> </return> - <argument index="0" name="shape" type="Physics2DShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> </argument> <description> Checks how far the shape can travel toward a point. If the shape can not move, the array will be empty. - [b]Note:[/b] Both the shape and the motion are supplied through a [Physics2DShapeQueryParameters] object. The method will return an array with two floats between 0 and 1, both representing a fraction of [code]motion[/code]. The first is how far the shape can move without triggering a collision, and the second is the point at which a collision will occur. If no collision is detected, the returned array will be [code][1, 1][/code]. + [b]Note:[/b] Both the shape and the motion are supplied through a [PhysicsShapeQueryParameters2D] object. The method will return an array with two floats between 0 and 1, both representing a fraction of [code]motion[/code]. The first is how far the shape can move without triggering a collision, and the second is the point at which a collision will occur. If no collision is detected, the returned array will be [code][1, 1][/code]. </description> </method> <method name="collide_shape"> <return type="Array"> </return> - <argument index="0" name="shape" type="Physics2DShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> </argument> <argument index="1" name="max_results" type="int" default="32"> </argument> <description> - Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. + Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. </description> </method> <method name="get_rest_info"> <return type="Dictionary"> </return> - <argument index="0" name="shape" type="Physics2DShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> </argument> <description> - Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. If it collides with more than one shape, the nearest one is selected. If the shape did not intersect anything, then an empty dictionary is returned instead. + Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space. If it collides with more than one shape, the nearest one is selected. If the shape did not intersect anything, then an empty dictionary is returned instead. [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object. The returned object is a dictionary containing the following fields: [code]collider_id[/code]: The colliding object's ID. [code]linear_velocity[/code]: The colliding object's velocity [Vector2]. If the object is an [Area2D], the result is [code](0, 0)[/code]. - [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method PhysicsServer2D.shape_set_data]. [code]normal[/code]: The object's surface normal at the intersection point. [code]point[/code]: The intersection point. [code]rid[/code]: The intersecting object's [RID]. @@ -67,10 +67,10 @@ Checks whether a point is inside any shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields: [code]collider[/code]: The colliding object. [code]collider_id[/code]: The colliding object's ID. - [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method PhysicsServer2D.shape_set_data]. [code]rid[/code]: The intersecting object's [RID]. [code]shape[/code]: The shape index of the colliding shape. - Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody]s or [Area]s, respectively. + Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody2D]s or [Area2D]s, respectively. </description> </method> <method name="intersect_point_on_canvas"> @@ -112,28 +112,28 @@ Intersects a ray in a given space. The returned object is a dictionary with the following fields: [code]collider[/code]: The colliding object. [code]collider_id[/code]: The colliding object's ID. - [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method PhysicsServer2D.shape_set_data]. [code]normal[/code]: The object's surface normal at the intersection point. [code]position[/code]: The intersection point. [code]rid[/code]: The intersecting object's [RID]. [code]shape[/code]: The shape index of the colliding shape. If the ray did not intersect anything, then an empty dictionary is returned instead. - Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody]s or [Area]s, respectively. + Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody2D]s or [Area2D]s, respectively. </description> </method> <method name="intersect_shape"> <return type="Array"> </return> - <argument index="0" name="shape" type="Physics2DShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters2D"> </argument> <argument index="1" name="max_results" type="int" default="32"> </argument> <description> - Checks the intersections of a shape, given through a [Physics2DShapeQueryParameters] object, against the space. + Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space. [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object. The intersected shapes are returned in an array containing dictionaries with the following fields: [code]collider[/code]: The colliding object. [code]collider_id[/code]: The colliding object's ID. - [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method Physics2DServer.shape_set_data]. + [code]metadata[/code]: The intersecting shape's metadata. This metadata is different from [method Object.get_meta], and is set with [method PhysicsServer2D.shape_set_data]. [code]rid[/code]: The intersecting object's [RID]. [code]shape[/code]: The shape index of the colliding shape. The number of intersections can be limited with the [code]max_results[/code] parameter, to reduce the processing time. diff --git a/doc/classes/PhysicsDirectSpaceState.xml b/doc/classes/PhysicsDirectSpaceState3D.xml index a6172805e9..09ee93732d 100644 --- a/doc/classes/PhysicsDirectSpaceState.xml +++ b/doc/classes/PhysicsDirectSpaceState3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsDirectSpaceState" inherits="Object" version="4.0"> +<class name="PhysicsDirectSpaceState3D" inherits="Object" version="4.0"> <brief_description> - Direct access object to a space in the [PhysicsServer]. + Direct access object to a space in the [PhysicsServer3D]. </brief_description> <description> - Direct access object to a space in the [PhysicsServer]. It's used mainly to do queries against objects and areas residing in a given space. + Direct access object to a space in the [PhysicsServer3D]. It's used mainly to do queries against objects and areas residing in a given space. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html</link> @@ -13,7 +13,7 @@ <method name="cast_motion"> <return type="Array"> </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> </argument> <argument index="1" name="motion" type="Vector3"> </argument> @@ -25,23 +25,23 @@ <method name="collide_shape"> <return type="Array"> </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> </argument> <argument index="1" name="max_results" type="int" default="32"> </argument> <description> - Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. + Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space. The resulting array contains a list of points where the shape intersects another. Like with [method intersect_shape], the number of returned results can be limited to save processing time. </description> </method> <method name="get_rest_info"> <return type="Dictionary"> </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> </argument> <description> - Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters] object, against the space. If it collides with more than one shape, the nearest one is selected. The returned object is a dictionary containing the following fields: + Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space. If it collides with more than one shape, the nearest one is selected. The returned object is a dictionary containing the following fields: [code]collider_id[/code]: The colliding object's ID. - [code]linear_velocity[/code]: The colliding object's velocity [Vector3]. If the object is an [Area], the result is [code](0, 0, 0)[/code]. + [code]linear_velocity[/code]: The colliding object's velocity [Vector3]. If the object is an [Area3D], the result is [code](0, 0, 0)[/code]. [code]normal[/code]: The object's surface normal at the intersection point. [code]point[/code]: The intersection point. [code]rid[/code]: The intersecting object's [RID]. @@ -73,18 +73,18 @@ [code]rid[/code]: The intersecting object's [RID]. [code]shape[/code]: The shape index of the colliding shape. If the ray did not intersect anything, then an empty dictionary is returned instead. - Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody]s or [Area]s, respectively. + Additionally, the method can take an [code]exclude[/code] array of objects or [RID]s that are to be excluded from collisions, a [code]collision_mask[/code] bitmask representing the physics layers to check in, or booleans to determine if the ray should collide with [PhysicsBody3D]s or [Area3D]s, respectively. </description> </method> <method name="intersect_shape"> <return type="Array"> </return> - <argument index="0" name="shape" type="PhysicsShapeQueryParameters"> + <argument index="0" name="shape" type="PhysicsShapeQueryParameters3D"> </argument> <argument index="1" name="max_results" type="int" default="32"> </argument> <description> - Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters] object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields: + Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space. The intersected shapes are returned in an array containing dictionaries with the following fields: [code]collider[/code]: The colliding object. [code]collider_id[/code]: The colliding object's ID. [code]rid[/code]: The intersecting object's [RID]. diff --git a/doc/classes/PhysicsMaterial.xml b/doc/classes/PhysicsMaterial.xml index 84e7f2b275..6410626496 100644 --- a/doc/classes/PhysicsMaterial.xml +++ b/doc/classes/PhysicsMaterial.xml @@ -4,7 +4,7 @@ A material for physics properties. </brief_description> <description> - Provides a means of modifying the collision properties of a [PhysicsBody]. + Provides a means of modifying the collision properties of a [PhysicsBody3D]. </description> <tutorials> </tutorials> diff --git a/doc/classes/Physics2DServer.xml b/doc/classes/PhysicsServer2D.xml index 45215253be..9da739e57a 100644 --- a/doc/classes/Physics2DServer.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DServer" inherits="Object" version="4.0"> +<class name="PhysicsServer2D" inherits="Object" version="4.0"> <brief_description> Server interface for low-level 2D physics access. </brief_description> <description> - Physics2DServer is the server responsible for all 2D physics. It can create many kinds of physics objects, but does not insert them on the node tree. + PhysicsServer2D is the server responsible for all 2D physics. It can create many kinds of physics objects, but does not insert them on the node tree. </description> <tutorials> </tutorials> @@ -83,7 +83,7 @@ </return> <argument index="0" name="area" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.AreaParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter"> </argument> <description> Returns an area parameter value. See [enum AreaParameter] for a list of available parameters. @@ -130,7 +130,7 @@ </description> </method> <method name="area_get_space_override_mode" qualifiers="const"> - <return type="int" enum="Physics2DServer.AreaSpaceOverrideMode"> + <return type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode"> </return> <argument index="0" name="area" type="RID"> </argument> @@ -225,7 +225,7 @@ </return> <argument index="0" name="area" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.AreaParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter"> </argument> <argument index="2" name="value" type="Variant"> </argument> @@ -288,7 +288,7 @@ </return> <argument index="0" name="area" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="Physics2DServer.AreaSpaceOverrideMode"> + <argument index="1" name="mode" type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode"> </argument> <description> Sets the space override mode for the area. See [enum AreaSpaceOverrideMode] for a list of available modes. @@ -461,7 +461,7 @@ </description> </method> <method name="body_get_continuous_collision_detection_mode" qualifiers="const"> - <return type="int" enum="Physics2DServer.CCDMode"> + <return type="int" enum="PhysicsServer2D.CCDMode"> </return> <argument index="0" name="body" type="RID"> </argument> @@ -470,12 +470,12 @@ </description> </method> <method name="body_get_direct_state"> - <return type="Physics2DDirectBodyState"> + <return type="PhysicsDirectBodyState2D"> </return> <argument index="0" name="body" type="RID"> </argument> <description> - Returns the [Physics2DDirectBodyState] of the body. + Returns the [PhysicsDirectBodyState2D] of the body. </description> </method> <method name="body_get_max_contacts_reported" qualifiers="const"> @@ -488,7 +488,7 @@ </description> </method> <method name="body_get_mode" qualifiers="const"> - <return type="int" enum="Physics2DServer.BodyMode"> + <return type="int" enum="PhysicsServer2D.BodyMode"> </return> <argument index="0" name="body" type="RID"> </argument> @@ -510,7 +510,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.BodyParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter"> </argument> <description> Returns the value of a body parameter. See [enum BodyParameter] for a list of available parameters. @@ -572,7 +572,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="state" type="int" enum="Physics2DServer.BodyState"> + <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState"> </argument> <description> Returns a body state. @@ -647,7 +647,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="Physics2DServer.CCDMode"> + <argument index="1" name="mode" type="int" enum="PhysicsServer2D.CCDMode"> </argument> <description> Sets the continuous collision detection mode using one of the [enum CCDMode] constants. @@ -685,7 +685,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="Physics2DServer.BodyMode"> + <argument index="1" name="mode" type="int" enum="PhysicsServer2D.BodyMode"> </argument> <description> Sets the body mode using one of the [enum BodyMode] constants. @@ -707,7 +707,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.BodyParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -798,7 +798,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="state" type="int" enum="Physics2DServer.BodyState"> + <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState"> </argument> <argument index="2" name="value" type="Variant"> </argument> @@ -819,10 +819,10 @@ </argument> <argument index="4" name="margin" type="float" default="0.08"> </argument> - <argument index="5" name="result" type="Physics2DTestMotionResult" default="null"> + <argument index="5" name="result" type="PhysicsTestMotionResult2D" default="null"> </argument> <description> - Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [Physics2DTestMotionResult] can be passed to return additional information in. + Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [PhysicsTestMotionResult2D] can be passed to return additional information in. </description> </method> <method name="capsule_shape_create"> @@ -869,7 +869,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.DampedStringParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedStringParam"> </argument> <description> Returns the value of a damped spring joint parameter. @@ -880,7 +880,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.DampedStringParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedStringParam"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -894,13 +894,13 @@ <argument index="0" name="rid" type="RID"> </argument> <description> - Destroys any of the objects created by Physics2DServer. If the [RID] passed is not one of the objects that can be created by Physics2DServer, an error will be sent to the console. + Destroys any of the objects created by PhysicsServer2D. If the [RID] passed is not one of the objects that can be created by PhysicsServer2D, an error will be sent to the console. </description> </method> <method name="get_process_info"> <return type="int"> </return> - <argument index="0" name="process_info" type="int" enum="Physics2DServer.ProcessInfo"> + <argument index="0" name="process_info" type="int" enum="PhysicsServer2D.ProcessInfo"> </argument> <description> Returns information about the current state of the 2D physics engine. See [enum ProcessInfo] for a list of available states. @@ -928,14 +928,14 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.JointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam"> </argument> <description> Returns the value of a joint parameter. </description> </method> <method name="joint_get_type" qualifiers="const"> - <return type="int" enum="Physics2DServer.JointType"> + <return type="int" enum="PhysicsServer2D.JointType"> </return> <argument index="0" name="joint" type="RID"> </argument> @@ -948,7 +948,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.JointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -1012,7 +1012,7 @@ </description> </method> <method name="shape_get_type" qualifiers="const"> - <return type="int" enum="Physics2DServer.ShapeType"> + <return type="int" enum="PhysicsServer2D.ShapeType"> </return> <argument index="0" name="shape" type="RID"> </argument> @@ -1039,12 +1039,12 @@ </description> </method> <method name="space_get_direct_state"> - <return type="Physics2DDirectSpaceState"> + <return type="PhysicsDirectSpaceState2D"> </return> <argument index="0" name="space" type="RID"> </argument> <description> - Returns the state of a space, a [Physics2DDirectSpaceState]. This object can be used to make collision/intersection queries. + Returns the state of a space, a [PhysicsDirectSpaceState2D]. This object can be used to make collision/intersection queries. </description> </method> <method name="space_get_param" qualifiers="const"> @@ -1052,7 +1052,7 @@ </return> <argument index="0" name="space" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.SpaceParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter"> </argument> <description> Returns the value of a space parameter. @@ -1083,7 +1083,7 @@ </return> <argument index="0" name="space" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="Physics2DServer.SpaceParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter"> </argument> <argument index="2" name="value" type="float"> </argument> diff --git a/doc/classes/Physics2DServerSW.xml b/doc/classes/PhysicsServer2DSW.xml index 1e4531ed66..dac5e360f0 100644 --- a/doc/classes/Physics2DServerSW.xml +++ b/doc/classes/PhysicsServer2DSW.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DServerSW" inherits="Physics2DServer" version="4.0"> +<class name="PhysicsServer2DSW" inherits="PhysicsServer2D" version="4.0"> <brief_description> - Software implementation of [Physics2DServer]. + Software implementation of [PhysicsServer2D]. </brief_description> <description> - This class exposes no new methods or properties and should not be used, as [Physics2DServer] automatically selects the best implementation available. + This class exposes no new methods or properties and should not be used, as [PhysicsServer2D] automatically selects the best implementation available. </description> <tutorials> </tutorials> diff --git a/doc/classes/PhysicsServer.xml b/doc/classes/PhysicsServer3D.xml index 1b9ce80a1b..e9e1552c92 100644 --- a/doc/classes/PhysicsServer.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsServer" inherits="Object" version="4.0"> +<class name="PhysicsServer3D" inherits="Object" version="4.0"> <brief_description> Server interface for low-level physics access. </brief_description> <description> - PhysicsServer is the server responsible for all 3D physics. It can create many kinds of physics objects, but does not insert them on the node tree. + PhysicsServer3D is the server responsible for all 3D physics. It can create many kinds of physics objects, but does not insert them on the node tree. </description> <tutorials> </tutorials> @@ -48,7 +48,7 @@ <return type="RID"> </return> <description> - Creates an [Area]. + Creates an [Area3D]. </description> </method> <method name="area_get_object_instance_id" qualifiers="const"> @@ -65,7 +65,7 @@ </return> <argument index="0" name="area" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.AreaParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.AreaParameter"> </argument> <description> Returns an area parameter value. A list of available parameters is on the [enum AreaParameter] constants. @@ -112,7 +112,7 @@ </description> </method> <method name="area_get_space_override_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer.AreaSpaceOverrideMode"> + <return type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode"> </return> <argument index="0" name="area" type="RID"> </argument> @@ -216,7 +216,7 @@ </return> <argument index="0" name="area" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.AreaParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.AreaParameter"> </argument> <argument index="2" name="value" type="Variant"> </argument> @@ -289,7 +289,7 @@ </return> <argument index="0" name="area" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer.AreaSpaceOverrideMode"> + <argument index="1" name="mode" type="int" enum="PhysicsServer3D.AreaSpaceOverrideMode"> </argument> <description> Sets the space override mode for the area. The modes are described in the [enum AreaSpaceOverrideMode] constants. @@ -421,7 +421,7 @@ <method name="body_create"> <return type="RID"> </return> - <argument index="0" name="mode" type="int" enum="PhysicsServer.BodyMode" default="2"> + <argument index="0" name="mode" type="int" enum="PhysicsServer3D.BodyMode" default="2"> </argument> <argument index="1" name="init_sleeping" type="bool" default="false"> </argument> @@ -449,12 +449,12 @@ </description> </method> <method name="body_get_direct_state"> - <return type="PhysicsDirectBodyState"> + <return type="PhysicsDirectBodyState3D"> </return> <argument index="0" name="body" type="RID"> </argument> <description> - Returns the [PhysicsDirectBodyState] of the body. + Returns the [PhysicsDirectBodyState3D] of the body. </description> </method> <method name="body_get_kinematic_safe_margin" qualifiers="const"> @@ -475,7 +475,7 @@ </description> </method> <method name="body_get_mode" qualifiers="const"> - <return type="int" enum="PhysicsServer.BodyMode"> + <return type="int" enum="PhysicsServer3D.BodyMode"> </return> <argument index="0" name="body" type="RID"> </argument> @@ -497,7 +497,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.BodyParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.BodyParameter"> </argument> <description> Returns the value of a body parameter. A list of available parameters is on the [enum BodyParameter] constants. @@ -548,7 +548,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="state" type="int" enum="PhysicsServer.BodyState"> + <argument index="1" name="state" type="int" enum="PhysicsServer3D.BodyState"> </argument> <description> Returns a body state. @@ -559,7 +559,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="axis" type="int" enum="PhysicsServer.BodyAxis"> + <argument index="1" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> </argument> <description> </description> @@ -619,7 +619,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="axis" type="int" enum="PhysicsServer.BodyAxis"> + <argument index="1" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> </argument> <argument index="2" name="lock" type="bool"> </argument> @@ -712,7 +712,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="PhysicsServer.BodyMode"> + <argument index="1" name="mode" type="int" enum="PhysicsServer3D.BodyMode"> </argument> <description> Sets the body mode, from one of the [enum BodyMode] constants. @@ -734,7 +734,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.BodyParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.BodyParameter"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -807,7 +807,7 @@ </return> <argument index="0" name="body" type="RID"> </argument> - <argument index="1" name="state" type="int" enum="PhysicsServer.BodyState"> + <argument index="1" name="state" type="int" enum="PhysicsServer3D.BodyState"> </argument> <argument index="2" name="value" type="Variant"> </argument> @@ -820,7 +820,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.ConeTwistJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.ConeTwistJointParam"> </argument> <description> Gets a cone_twist_joint parameter (see [enum ConeTwistJointParam] constants). @@ -831,7 +831,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.ConeTwistJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.ConeTwistJointParam"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -845,7 +845,7 @@ <argument index="0" name="rid" type="RID"> </argument> <description> - Destroys any of the objects created by PhysicsServer. If the [RID] passed is not one of the objects that can be created by PhysicsServer, an error will be sent to the console. + Destroys any of the objects created by PhysicsServer3D. If the [RID] passed is not one of the objects that can be created by PhysicsServer3D, an error will be sent to the console. </description> </method> <method name="generic_6dof_joint_get_flag"> @@ -855,7 +855,7 @@ </argument> <argument index="1" name="axis" type="int" enum="Vector3.Axis"> </argument> - <argument index="2" name="flag" type="int" enum="PhysicsServer.G6DOFJointAxisFlag"> + <argument index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag"> </argument> <description> Gets a generic_6_DOF_joint flag (see [enum G6DOFJointAxisFlag] constants). @@ -868,7 +868,7 @@ </argument> <argument index="1" name="axis" type="int" enum="Vector3.Axis"> </argument> - <argument index="2" name="param" type="int" enum="PhysicsServer.G6DOFJointAxisParam"> + <argument index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam"> </argument> <description> Gets a generic_6_DOF_joint parameter (see [enum G6DOFJointAxisParam] constants). @@ -881,7 +881,7 @@ </argument> <argument index="1" name="axis" type="int" enum="Vector3.Axis"> </argument> - <argument index="2" name="flag" type="int" enum="PhysicsServer.G6DOFJointAxisFlag"> + <argument index="2" name="flag" type="int" enum="PhysicsServer3D.G6DOFJointAxisFlag"> </argument> <argument index="3" name="enable" type="bool"> </argument> @@ -896,7 +896,7 @@ </argument> <argument index="1" name="axis" type="int" enum="Vector3.Axis"> </argument> - <argument index="2" name="param" type="int" enum="PhysicsServer.G6DOFJointAxisParam"> + <argument index="2" name="param" type="int" enum="PhysicsServer3D.G6DOFJointAxisParam"> </argument> <argument index="3" name="value" type="float"> </argument> @@ -907,7 +907,7 @@ <method name="get_process_info"> <return type="int"> </return> - <argument index="0" name="process_info" type="int" enum="PhysicsServer.ProcessInfo"> + <argument index="0" name="process_info" type="int" enum="PhysicsServer3D.ProcessInfo"> </argument> <description> Returns an Info defined by the [enum ProcessInfo] input given. @@ -918,7 +918,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="flag" type="int" enum="PhysicsServer.HingeJointFlag"> + <argument index="1" name="flag" type="int" enum="PhysicsServer3D.HingeJointFlag"> </argument> <description> Gets a hinge_joint flag (see [enum HingeJointFlag] constants). @@ -929,7 +929,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.HingeJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.HingeJointParam"> </argument> <description> Gets a hinge_joint parameter (see [enum HingeJointParam]). @@ -940,7 +940,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="flag" type="int" enum="PhysicsServer.HingeJointFlag"> + <argument index="1" name="flag" type="int" enum="PhysicsServer3D.HingeJointFlag"> </argument> <argument index="2" name="enabled" type="bool"> </argument> @@ -953,7 +953,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.HingeJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.HingeJointParam"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -973,7 +973,7 @@ <argument index="3" name="local_ref_B" type="Transform"> </argument> <description> - Creates a [ConeTwistJoint]. + Creates a [ConeTwistJoint3D]. </description> </method> <method name="joint_create_generic_6dof"> @@ -988,7 +988,7 @@ <argument index="3" name="local_ref_B" type="Transform"> </argument> <description> - Creates a [Generic6DOFJoint]. + Creates a [Generic6DOFJoint3D]. </description> </method> <method name="joint_create_hinge"> @@ -1003,7 +1003,7 @@ <argument index="3" name="hinge_B" type="Transform"> </argument> <description> - Creates a [HingeJoint]. + Creates a [HingeJoint3D]. </description> </method> <method name="joint_create_pin"> @@ -1018,7 +1018,7 @@ <argument index="3" name="local_B" type="Vector3"> </argument> <description> - Creates a [PinJoint]. + Creates a [PinJoint3D]. </description> </method> <method name="joint_create_slider"> @@ -1033,7 +1033,7 @@ <argument index="3" name="local_ref_B" type="Transform"> </argument> <description> - Creates a [SliderJoint]. + Creates a [SliderJoint3D]. </description> </method> <method name="joint_get_solver_priority" qualifiers="const"> @@ -1042,16 +1042,16 @@ <argument index="0" name="joint" type="RID"> </argument> <description> - Gets the priority value of the Joint. + Gets the priority value of the Joint3D. </description> </method> <method name="joint_get_type" qualifiers="const"> - <return type="int" enum="PhysicsServer.JointType"> + <return type="int" enum="PhysicsServer3D.JointType"> </return> <argument index="0" name="joint" type="RID"> </argument> <description> - Returns the type of the Joint. + Returns the type of the Joint3D. </description> </method> <method name="joint_set_solver_priority"> @@ -1062,7 +1062,7 @@ <argument index="1" name="priority" type="int"> </argument> <description> - Sets the priority value of the Joint. + Sets the priority value of the Joint3D. </description> </method> <method name="pin_joint_get_local_a" qualifiers="const"> @@ -1088,7 +1088,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.PinJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.PinJointParam"> </argument> <description> Gets a pin_joint parameter (see [enum PinJointParam] constants). @@ -1121,7 +1121,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.PinJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.PinJointParam"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -1141,7 +1141,7 @@ <method name="shape_create"> <return type="RID"> </return> - <argument index="0" name="type" type="int" enum="PhysicsServer.ShapeType"> + <argument index="0" name="type" type="int" enum="PhysicsServer3D.ShapeType"> </argument> <description> Creates a shape of a type from [enum ShapeType]. Does not assign it to a body or an area. To do so, you must use [method area_set_shape] or [method body_set_shape]. @@ -1157,7 +1157,7 @@ </description> </method> <method name="shape_get_type" qualifiers="const"> - <return type="int" enum="PhysicsServer.ShapeType"> + <return type="int" enum="PhysicsServer3D.ShapeType"> </return> <argument index="0" name="shape" type="RID"> </argument> @@ -1181,7 +1181,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.SliderJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SliderJointParam"> </argument> <description> Gets a slider_joint parameter (see [enum SliderJointParam] constants). @@ -1192,7 +1192,7 @@ </return> <argument index="0" name="joint" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.SliderJointParam"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SliderJointParam"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -1208,12 +1208,12 @@ </description> </method> <method name="space_get_direct_state"> - <return type="PhysicsDirectSpaceState"> + <return type="PhysicsDirectSpaceState3D"> </return> <argument index="0" name="space" type="RID"> </argument> <description> - Returns the state of a space, a [PhysicsDirectSpaceState]. This object can be used to make collision/intersection queries. + Returns the state of a space, a [PhysicsDirectSpaceState3D]. This object can be used to make collision/intersection queries. </description> </method> <method name="space_get_param" qualifiers="const"> @@ -1221,7 +1221,7 @@ </return> <argument index="0" name="space" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.SpaceParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SpaceParameter"> </argument> <description> Returns the value of a space parameter. @@ -1252,7 +1252,7 @@ </return> <argument index="0" name="space" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="PhysicsServer.SpaceParameter"> + <argument index="1" name="param" type="int" enum="PhysicsServer3D.SpaceParameter"> </argument> <argument index="2" name="value" type="float"> </argument> @@ -1263,19 +1263,19 @@ </methods> <constants> <constant name="JOINT_PIN" value="0" enum="JointType"> - The [Joint] is a [PinJoint]. + The [Joint3D] is a [PinJoint3D]. </constant> <constant name="JOINT_HINGE" value="1" enum="JointType"> - The [Joint] is a [HingeJoint]. + The [Joint3D] is a [HingeJoint3D]. </constant> <constant name="JOINT_SLIDER" value="2" enum="JointType"> - The [Joint] is a [SliderJoint]. + The [Joint3D] is a [SliderJoint3D]. </constant> <constant name="JOINT_CONE_TWIST" value="3" enum="JointType"> - The [Joint] is a [ConeTwistJoint]. + The [Joint3D] is a [ConeTwistJoint3D]. </constant> <constant name="JOINT_6DOF" value="4" enum="JointType"> - The [Joint] is a [Generic6DOFJoint]. + The [Joint3D] is a [Generic6DOFJoint3D]. </constant> <constant name="PIN_JOINT_BIAS" value="0" enum="PinJointParam"> The strength with which the pinned objects try to stay in positional relation to each other. @@ -1286,7 +1286,7 @@ The higher, the stronger. </constant> <constant name="PIN_JOINT_IMPULSE_CLAMP" value="2" enum="PinJointParam"> - If above 0, this value is the maximum value for an impulse that this Joint puts on its ends. + If above 0, this value is the maximum value for an impulse that this Joint3D puts on its ends. </constant> <constant name="HINGE_JOINT_BIAS" value="0" enum="HingeJointParam"> The speed with which the two bodies get pulled together when they move in different directions. @@ -1389,7 +1389,7 @@ <constant name="CONE_TWIST_JOINT_SWING_SPAN" value="0" enum="ConeTwistJointParam"> Swing is rotation from side to side, around the axis perpendicular to the twist axis. The swing span defines, how much rotation will not get corrected along the swing axis. - Could be defined as looseness in the [ConeTwistJoint]. + Could be defined as looseness in the [ConeTwistJoint3D]. If below 0.05, this behavior is locked. </constant> <constant name="CONE_TWIST_JOINT_TWIST_SPAN" value="1" enum="ConeTwistJointParam"> @@ -1401,7 +1401,7 @@ The higher, the faster. </constant> <constant name="CONE_TWIST_JOINT_SOFTNESS" value="3" enum="ConeTwistJointParam"> - The ease with which the Joint twists, if it's too low, it takes more force to twist the joint. + The ease with which the Joint3D twists, if it's too low, it takes more force to twist the joint. </constant> <constant name="CONE_TWIST_JOINT_RELAXATION" value="4" enum="ConeTwistJointParam"> Defines, how fast the swing- and twist-speed-difference on both sides gets synced. @@ -1467,31 +1467,31 @@ If [code]set[/code] there is a linear motor on this axis that targets a specific velocity. </constant> <constant name="SHAPE_PLANE" value="0" enum="ShapeType"> - The [Shape] is a [WorldMarginShape]. + The [Shape3D] is a [WorldMarginShape3D]. </constant> <constant name="SHAPE_RAY" value="1" enum="ShapeType"> - The [Shape] is a [RayShape]. + The [Shape3D] is a [RayShape3D]. </constant> <constant name="SHAPE_SPHERE" value="2" enum="ShapeType"> - The [Shape] is a [SphereShape]. + The [Shape3D] is a [SphereShape3D]. </constant> <constant name="SHAPE_BOX" value="3" enum="ShapeType"> - The [Shape] is a [BoxShape]. + The [Shape3D] is a [BoxShape3D]. </constant> <constant name="SHAPE_CAPSULE" value="4" enum="ShapeType"> - The [Shape] is a [CapsuleShape]. + The [Shape3D] is a [CapsuleShape3D]. </constant> <constant name="SHAPE_CYLINDER" value="5" enum="ShapeType"> - The [Shape] is a [CylinderShape]. + The [Shape3D] is a [CylinderShape3D]. </constant> <constant name="SHAPE_CONVEX_POLYGON" value="6" enum="ShapeType"> - The [Shape] is a [ConvexPolygonShape]. + The [Shape3D] is a [ConvexPolygonShape3D]. </constant> <constant name="SHAPE_CONCAVE_POLYGON" value="7" enum="ShapeType"> - The [Shape] is a [ConcavePolygonShape]. + The [Shape3D] is a [ConcavePolygonShape3D]. </constant> <constant name="SHAPE_HEIGHTMAP" value="8" enum="ShapeType"> - The [Shape] is a [HeightMapShape]. + The [Shape3D] is a [HeightMapShape3D]. </constant> <constant name="SHAPE_CUSTOM" value="9" enum="ShapeType"> This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. diff --git a/doc/classes/Physics2DShapeQueryParameters.xml b/doc/classes/PhysicsShapeQueryParameters2D.xml index 392ccbd10a..9a162dabbb 100644 --- a/doc/classes/Physics2DShapeQueryParameters.xml +++ b/doc/classes/PhysicsShapeQueryParameters2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DShapeQueryParameters" inherits="Reference" version="4.0"> +<class name="PhysicsShapeQueryParameters2D" inherits="Reference" version="4.0"> <brief_description> Parameters to be sent to a 2D shape physics query. </brief_description> <description> - This class contains the shape and other parameters for 2D intersection/collision queries. See also [Physics2DShapeQueryResult]. + This class contains the shape and other parameters for 2D intersection/collision queries. See also [PhysicsShapeQueryResult2D]. </description> <tutorials> </tutorials> diff --git a/doc/classes/PhysicsShapeQueryParameters.xml b/doc/classes/PhysicsShapeQueryParameters3D.xml index 829a1d1bf0..6606cfbc59 100644 --- a/doc/classes/PhysicsShapeQueryParameters.xml +++ b/doc/classes/PhysicsShapeQueryParameters3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsShapeQueryParameters" inherits="Reference" version="4.0"> +<class name="PhysicsShapeQueryParameters3D" inherits="Reference" version="4.0"> <brief_description> Parameters to be sent to a 3D shape physics query. </brief_description> <description> - This class contains the shape and other parameters for 3D intersection/collision queries. See also [PhysicsShapeQueryResult]. + This class contains the shape and other parameters for 3D intersection/collision queries. See also [PhysicsShapeQueryResult3D]. </description> <tutorials> </tutorials> @@ -15,16 +15,16 @@ <argument index="0" name="shape" type="Resource"> </argument> <description> - Sets the [Shape] that will be used for collision/intersection queries. + Sets the [Shape3D] that will be used for collision/intersection queries. </description> </method> </methods> <members> <member name="collide_with_areas" type="bool" setter="set_collide_with_areas" getter="is_collide_with_areas_enabled" default="false"> - If [code]true[/code], the query will take [Area]s into account. + If [code]true[/code], the query will take [Area3D]s into account. </member> <member name="collide_with_bodies" type="bool" setter="set_collide_with_bodies" getter="is_collide_with_bodies_enabled" default="true"> - If [code]true[/code], the query will take [PhysicsBody]s into account. + If [code]true[/code], the query will take [PhysicsBody3D]s into account. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="2147483647"> The physics layer(s) the query will take into account (as a bitmask). diff --git a/doc/classes/Physics2DShapeQueryResult.xml b/doc/classes/PhysicsShapeQueryResult2D.xml index 359a716bee..227683cc33 100644 --- a/doc/classes/Physics2DShapeQueryResult.xml +++ b/doc/classes/PhysicsShapeQueryResult2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DShapeQueryResult" inherits="Reference" version="4.0"> +<class name="PhysicsShapeQueryResult2D" inherits="Reference" version="4.0"> <brief_description> - Result of a 2D shape query in [Physics2DServer]. + Result of a 2D shape query in [PhysicsServer2D]. </brief_description> <description> - The result of a 2D shape query in [Physics2DServer]. See also [Physics2DShapeQueryParameters]. + The result of a 2D shape query in [PhysicsServer2D]. See also [PhysicsShapeQueryParameters2D]. </description> <tutorials> </tutorials> @@ -40,7 +40,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> - Returns the child index of the object's [Shape] that intersected with the shape at index [code]idx[/code]. + Returns the child index of the object's [Shape2D] that intersected with the shape at index [code]idx[/code]. </description> </method> <method name="get_result_rid" qualifiers="const"> diff --git a/doc/classes/PhysicsShapeQueryResult.xml b/doc/classes/PhysicsShapeQueryResult3D.xml index ea6dc2c39e..4555c4e242 100644 --- a/doc/classes/PhysicsShapeQueryResult.xml +++ b/doc/classes/PhysicsShapeQueryResult3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsShapeQueryResult" inherits="Reference" version="4.0"> +<class name="PhysicsShapeQueryResult3D" inherits="Reference" version="4.0"> <brief_description> - Result of a 3D shape query in [PhysicsServer]. + Result of a 3D shape query in [PhysicsServer3D]. </brief_description> <description> - The result of a 3D shape query in [PhysicsServer]. See also [PhysicsShapeQueryParameters]. + The result of a 3D shape query in [PhysicsServer3D]. See also [PhysicsShapeQueryParameters3D]. </description> <tutorials> </tutorials> @@ -40,7 +40,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> - Returns the child index of the object's [Shape] that intersected with the shape at index [code]idx[/code]. + Returns the child index of the object's [Shape3D] that intersected with the shape at index [code]idx[/code]. </description> </method> <method name="get_result_rid" qualifiers="const"> diff --git a/doc/classes/Physics2DTestMotionResult.xml b/doc/classes/PhysicsTestMotionResult2D.xml index 9e8c03580f..301cff2885 100644 --- a/doc/classes/Physics2DTestMotionResult.xml +++ b/doc/classes/PhysicsTestMotionResult2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DTestMotionResult" inherits="Reference" version="4.0"> +<class name="PhysicsTestMotionResult2D" inherits="Reference" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PinJoint2D.xml b/doc/classes/PinJoint2D.xml index 020babdf40..42155a7f25 100644 --- a/doc/classes/PinJoint2D.xml +++ b/doc/classes/PinJoint2D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="PinJoint2D" inherits="Joint2D" version="4.0"> <brief_description> - Pin Joint for 2D shapes. + Pin joint for 2D shapes. </brief_description> <description> - Pin Joint for 2D rigid bodies. It pins two bodies (rigid or static) together. + Pin joint for 2D rigid bodies. It pins two bodies (rigid or static) together. </description> <tutorials> </tutorials> diff --git a/doc/classes/PinJoint.xml b/doc/classes/PinJoint3D.xml index 78cab4805e..0af1e60839 100644 --- a/doc/classes/PinJoint.xml +++ b/doc/classes/PinJoint3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PinJoint" inherits="Joint" version="4.0"> +<class name="PinJoint3D" inherits="Joint3D" version="4.0"> <brief_description> Pin joint for 3D shapes. </brief_description> @@ -12,7 +12,7 @@ <method name="get_param" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="PinJoint.Param"> + <argument index="0" name="param" type="int" enum="PinJoint3D.Param"> </argument> <description> Returns the value of the specified parameter. @@ -21,7 +21,7 @@ <method name="set_param"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="PinJoint.Param"> + <argument index="0" name="param" type="int" enum="PinJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> @@ -38,7 +38,7 @@ The force with which the pinned objects stay in velocity relation to each other. The higher, the stronger. </member> <member name="params/impulse_clamp" type="float" setter="set_param" getter="get_param" default="0.0"> - If above 0, this value is the maximum value for an impulse that this Joint produces. + If above 0, this value is the maximum value for an impulse that this Joint3D produces. </member> </members> <constants> @@ -49,7 +49,7 @@ The force with which the pinned objects stay in velocity relation to each other. The higher, the stronger. </constant> <constant name="PARAM_IMPULSE_CLAMP" value="2" enum="Param"> - If above 0, this value is the maximum value for an impulse that this Joint produces. + If above 0, this value is the maximum value for an impulse that this Joint3D produces. </constant> </constants> </class> diff --git a/doc/classes/Popup.xml b/doc/classes/Popup.xml index 483e262f60..6f77f3371d 100644 --- a/doc/classes/Popup.xml +++ b/doc/classes/Popup.xml @@ -1,81 +1,23 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Popup" inherits="Control" version="4.0"> +<class name="Popup" inherits="Window" version="4.0"> <brief_description> Base container control for popups and dialogs. </brief_description> <description> - Popup is a base [Control] used to show dialogs and popups. It's a subwindow and modal by default (see [Control]) and has helpers for custom popup behavior. All popup methods ensure correct placement within the viewport. + Popup is a base [Control] used to show dialogs and popups. It's a subwindow and modal by default (see [Control]) and has helpers for custom popup behavior. </description> <tutorials> </tutorials> <methods> - <method name="popup"> - <return type="void"> - </return> - <argument index="0" name="bounds" type="Rect2" default="Rect2( 0, 0, 0, 0 )"> - </argument> - <description> - Popup (show the control in modal form). - </description> - </method> - <method name="popup_centered"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to its current canvas transform, at the current size, or at a size determined by [code]size[/code]. - </description> - </method> - <method name="popup_centered_clamped"> - <return type="void"> - </return> - <argument index="0" name="size" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <argument index="1" name="fallback_ratio" type="float" default="0.75"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, clamping the size to [code]size[/code], then ensuring the popup is no larger than the viewport size multiplied by [code]fallback_ratio[/code]. - </description> - </method> - <method name="popup_centered_minsize"> - <return type="void"> - </return> - <argument index="0" name="minsize" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, ensuring the size is never smaller than [code]minsize[/code]. - </description> - </method> - <method name="popup_centered_ratio"> - <return type="void"> - </return> - <argument index="0" name="ratio" type="float" default="0.75"> - </argument> - <description> - Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, scaled at a ratio of size of the screen. - </description> - </method> - <method name="set_as_minsize"> - <return type="void"> - </return> - <description> - Shrink popup to keep to the minimum size of content. - </description> - </method> </methods> <members> - <member name="popup_exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false"> - If [code]true[/code], the popup will not be hidden when a click event occurs outside of it, or when it receives the [code]ui_cancel[/code] action event. - </member> + <member name="borderless" type="bool" setter="set_flag" getter="get_flag" override="true" default="true" /> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" override="true" default="true" /> + <member name="unresizable" type="bool" setter="set_flag" getter="get_flag" override="true" default="true" /> <member name="visible" type="bool" setter="set_visible" getter="is_visible" override="true" default="false" /> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" override="true" default="true" /> </members> <signals> - <signal name="about_to_show"> - <description> - Emitted when a popup is about to be shown. This is often used in [PopupMenu] to clear the list of options then create a new one according to the current context. - </description> - </signal> <signal name="popup_hide"> <description> Emitted when a popup is hidden. @@ -83,11 +25,5 @@ </signal> </signals> <constants> - <constant name="NOTIFICATION_POST_POPUP" value="80"> - Notification sent right after the popup is shown. - </constant> - <constant name="NOTIFICATION_POPUP_HIDE" value="81"> - Notification sent right after the popup is hidden. - </constant> </constants> </class> diff --git a/doc/classes/PopupDialog.xml b/doc/classes/PopupDialog.xml deleted file mode 100644 index a8fd9c1b7d..0000000000 --- a/doc/classes/PopupDialog.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="PopupDialog" inherits="Popup" version="4.0"> - <brief_description> - Base class for popup dialogs. - </brief_description> - <description> - PopupDialog is a base class for popup dialogs, along with [WindowDialog]. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <constants> - </constants> - <theme_items> - <theme_item name="panel" type="StyleBox"> - Sets a custom [StyleBox] for the panel of the [PopupDialog]. - </theme_item> - </theme_items> -</class> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 8dda33f624..569da5c58b 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -330,13 +330,6 @@ Returns the tooltip associated with the specified index index [code]idx[/code]. </description> </method> - <method name="is_hide_on_window_lose_focus" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the popup will be hidden when the window loses focus or not. - </description> - </method> <method name="is_item_checkable" qualifiers="const"> <return type="bool"> </return> @@ -404,15 +397,6 @@ [b]Note:[/b] The indices of items after the removed item will be shifted by one. </description> </method> - <method name="set_hide_on_window_lose_focus"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> - <description> - Hides the [PopupMenu] when the window loses focus. - </description> - </method> <method name="set_item_accelerator"> <return type="void"> </return> @@ -604,7 +588,6 @@ <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="false"> If [code]true[/code], allows to navigate [PopupMenu] with letter keys. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection" default="true"> If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected. </member> diff --git a/doc/classes/PopupPanel.xml b/doc/classes/PopupPanel.xml index 2e62d09f8f..72045c5559 100644 --- a/doc/classes/PopupPanel.xml +++ b/doc/classes/PopupPanel.xml @@ -4,7 +4,7 @@ Class for displaying popups with a panel background. </brief_description> <description> - Class for displaying popups with a panel background. In some cases it might be simpler to use than [Popup], since it provides a configurable background. If you are making windows, better check [WindowDialog]. + Class for displaying popups with a panel background. In some cases it might be simpler to use than [Popup], since it provides a configurable background. If you are making windows, better check [Window]. </description> <tutorials> </tutorials> diff --git a/doc/classes/Position3D.xml b/doc/classes/Position3D.xml index 6dce8a91c6..ca61a57483 100644 --- a/doc/classes/Position3D.xml +++ b/doc/classes/Position3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Position3D" inherits="Spatial" version="4.0"> +<class name="Position3D" inherits="Node3D" version="4.0"> <brief_description> Generic 3D position hint for editing. </brief_description> <description> - Generic 3D position hint for editing. It's just like a plain [Spatial], but it displays as a cross in the 3D editor at all times. + Generic 3D position hint for editing. It's just like a plain [Node3D], but it displays as a cross in the 3D editor at all times. </description> <tutorials> </tutorials> diff --git a/doc/classes/ProceduralSkyMaterial.xml b/doc/classes/ProceduralSkyMaterial.xml index dec0cbc120..70e82d248c 100644 --- a/doc/classes/ProceduralSkyMaterial.xml +++ b/doc/classes/ProceduralSkyMaterial.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="ProceduralSkyMaterial" inherits="Material" version="4.0"> <brief_description> - A [Material] used with [Sky] to generate a background based on user input parameters. + A [Material] used with [Sky] to generate a background based on user input parameters. </brief_description> <description> ProceduralSkyMaterial provides a way to create an effective background quickly by defining procedural parameters for the sun, the sky and the ground. The sky and ground are very similar, they are defined by a color at the horizon, another color, and finally an easing curve to interpolate between these two colors. Similarly, the sun is described by a position in the sky, a color, and an easing curve. However, the sun also defines a minimum and maximum angle, these two values define at what distance the easing curve begins and ends from the sun, and thus end up defining the size of the sun in the sky. The [ProceduralSkyMaterial] uses a lightweight shader to draw the sky and is thus suited for real time updates. When you do not need a quick sky that is not realistic, this is a good option. - The [ProceduralSkyMaterial] supports up to 4 suns. Each sun takes its color, energy, and direction from the corresponding [DirectionalLight] in the scene. + The [ProceduralSkyMaterial] supports up to 4 suns. Each sun takes its color, energy, and direction from the corresponding [DirectionalLight3D] in the scene. </description> <tutorials> </tutorials> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 79d5ffa2e7..6de82e602b 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -202,7 +202,7 @@ Icon used for the project, set when project loads. Exporters will also use this icon when possible. </member> <member name="application/config/macos_native_icon" type="String" setter="" getter="" default=""""> - Icon set in [code].icns[/code] format used on macOS to set the game's icon. This is done automatically on start by calling [method OS.set_native_icon]. + Icon set in [code].icns[/code] format used on macOS to set the game's icon. This is done automatically on start by calling [method DisplayServer.set_native_icon]. </member> <member name="application/config/name" type="String" setter="" getter="" default=""""> The project's name. It is used both by the Project Manager and by exporters. The project name can be translated by translating its value in localization files. @@ -215,7 +215,7 @@ If [code]true[/code], the project will save user data to its own user directory (see [member application/config/custom_user_dir_name]). This setting is only effective on desktop platforms. A name must be set in the [member application/config/custom_user_dir_name] setting for this to take effect. If [code]false[/code], the project will save user data to [code](OS user data directory)/Godot/app_userdata/(project name)[/code]. </member> <member name="application/config/windows_native_icon" type="String" setter="" getter="" default=""""> - Icon set in [code].ico[/code] format used on Windows to set the game's icon. This is done automatically on start by calling [method OS.set_native_icon]. + Icon set in [code].ico[/code] format used on Windows to set the game's icon. This is done automatically on start by calling [method DisplayServer.set_native_icon]. </member> <member name="application/run/disable_stderr" type="bool" setter="" getter="" default="false"> If [code]true[/code], disables printing to standard error in an exported build. @@ -426,12 +426,6 @@ <member name="display/window/ios/hide_home_indicator" type="bool" setter="" getter="" default="true"> If [code]true[/code], the home indicator is hidden automatically. This only affects iOS devices without a physical home button. </member> - <member name="display/window/per_pixel_transparency/allowed" type="bool" setter="" getter="" default="false"> - If [code]true[/code], allows per-pixel transparency in a desktop window. This affects performance, so leave it on [code]false[/code] unless you need it. - </member> - <member name="display/window/per_pixel_transparency/enabled" type="bool" setter="" getter="" default="false"> - Sets the window background to transparent when it starts. - </member> <member name="display/window/size/always_on_top" type="bool" setter="" getter="" default="false"> Force the window to be always on top. </member> @@ -898,7 +892,7 @@ [b]Note:[/b] This property is only read when the project starts. To change the default gravity at runtime, use the following code sample: [codeblock] # Set the default gravity strength to 98. - Physics2DServer.area_set_param(get_viewport().find_world_2d().get_space(), Physics2DServer.AREA_PARAM_GRAVITY, 98) + PhysicsServer2D.area_set_param(get_viewport().find_world_2d().get_space(), PhysicsServer2D.AREA_PARAM_GRAVITY, 98) [/codeblock] </member> <member name="physics/2d/default_gravity_vector" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )"> @@ -906,7 +900,7 @@ [b]Note:[/b] This property is only read when the project starts. To change the default gravity vector at runtime, use the following code sample: [codeblock] # Set the default gravity direction to `Vector2(0, 1)`. - Physics2DServer.area_set_param(get_viewport().find_world_2d().get_space(), Physics2DServer.AREA_PARAM_GRAVITY_VECTOR, Vector2(0, 1)) + PhysicsServer2D.area_set_param(get_viewport().find_world_2d().get_space(), PhysicsServer2D.AREA_PARAM_GRAVITY_VECTOR, Vector2(0, 1)) [/codeblock] </member> <member name="physics/2d/default_linear_damp" type="float" setter="" getter="" default="0.1"> @@ -920,20 +914,20 @@ "DEFAULT" and "GodotPhysics" are the same, as there is currently no alternative 2D physics server implemented. </member> <member name="physics/2d/sleep_threshold_angular" type="float" setter="" getter="" default="0.139626"> - Threshold angular velocity under which a 2D physics body will be considered inactive. See [constant Physics2DServer.SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD]. + Threshold angular velocity under which a 2D physics body will be considered inactive. See [constant PhysicsServer2D.SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD]. </member> <member name="physics/2d/sleep_threshold_linear" type="float" setter="" getter="" default="2.0"> - Threshold linear velocity under which a 2D physics body will be considered inactive. See [constant Physics2DServer.SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD]. + Threshold linear velocity under which a 2D physics body will be considered inactive. See [constant PhysicsServer2D.SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD]. </member> <member name="physics/2d/thread_model" type="int" setter="" getter="" default="1"> Sets whether physics is run on the main thread or a separate one. Running the server on a thread increases performance, but restricts API access to only physics process. [b]Warning:[/b] As of Godot 3.2, there are mixed reports about the use of a Multi-Threaded thread model for physics. Be sure to assess whether it does give you extra performance and no regressions when using it. </member> <member name="physics/2d/time_before_sleep" type="float" setter="" getter="" default="0.5"> - Time (in seconds) of inactivity before which a 2D physics body will put to sleep. See [constant Physics2DServer.SPACE_PARAM_BODY_TIME_TO_SLEEP]. + Time (in seconds) of inactivity before which a 2D physics body will put to sleep. See [constant PhysicsServer2D.SPACE_PARAM_BODY_TIME_TO_SLEEP]. </member> <member name="physics/3d/active_soft_world" type="bool" setter="" getter="" default="true"> - Sets whether the 3D physics world will be created with support for [SoftBody] physics. Only applies to the Bullet physics engine. + Sets whether the 3D physics world will be created with support for [SoftBody3D] physics. Only applies to the Bullet physics engine. </member> <member name="physics/3d/default_angular_damp" type="float" setter="" getter="" default="0.1"> The default angular damp in 3D. @@ -943,7 +937,7 @@ [b]Note:[/b] This property is only read when the project starts. To change the default gravity at runtime, use the following code sample: [codeblock] # Set the default gravity strength to 9.8. - PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 9.8) + PhysicsServer3D.area_set_param(get_viewport().find_world().get_space(), PhysicsServer3D.AREA_PARAM_GRAVITY, 9.8) [/codeblock] </member> <member name="physics/3d/default_gravity_vector" type="Vector3" setter="" getter="" default="Vector3( 0, -1, 0 )"> @@ -951,7 +945,7 @@ [b]Note:[/b] This property is only read when the project starts. To change the default gravity vector at runtime, use the following code sample: [codeblock] # Set the default gravity direction to `Vector3(0, -1, 0)`. - PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY_VECTOR, Vector3(0, -1, 0)) + PhysicsServer3D.area_set_param(get_viewport().find_world().get_space(), PhysicsServer3D.AREA_PARAM_GRAVITY_VECTOR, Vector3(0, -1, 0)) [/codeblock] </member> <member name="physics/3d/default_linear_damp" type="float" setter="" getter="" default="0.1"> @@ -973,7 +967,7 @@ [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.physics_jitter_fix] instead. </member> <member name="rendering/environment/default_clear_color" type="Color" setter="" getter="" default="Color( 0.3, 0.3, 0.3, 1 )"> - Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method VisualServer.set_default_clear_color]. + Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method RenderingServer.set_default_clear_color]. </member> <member name="rendering/environment/default_environment" type="String" setter="" getter="" default=""""> [Environment] that will be used as a fallback environment in case a scene does not specify its own environment. The default environment is loaded in at scene load time regardless of whether you have set an environment or not. If you do not rely on the fallback environment, it is best to delete [code]default_env.tres[/code], or to specify a different default environment here. @@ -1002,7 +996,9 @@ </member> <member name="rendering/quality/driver/driver_name" type="String" setter="" getter="" default=""Vulkan""> The video driver to use ("GLES2" or "Vulkan"). - [b]Note:[/b] The backend in use can be overridden at runtime via the [code]--video-driver[/code] command line argument. In such cases, this property is not updated, so use [method OS.get_current_video_driver] to query it at run-time. + [b]Note:[/b] The backend in use can be overridden at runtime via the [code]--rendering-driver[/code] command line argument. + [b]FIXME:[/b] No longer valid after DisplayServer split: + In such cases, this property is not updated, so use [code]OS.get_current_video_driver[/code] to query it at run-time. </member> <member name="rendering/quality/filters/depth_of_field_bokeh_quality" type="int" setter="" getter="" default="2"> </member> @@ -1027,6 +1023,10 @@ </member> <member name="rendering/quality/gi_probes/quality" type="int" setter="" getter="" default="1"> </member> + <member name="rendering/quality/glow/upscale_mode" type="int" setter="" getter="" default="1"> + </member> + <member name="rendering/quality/glow/upscale_mode.mobile" type="int" setter="" getter="" default="0"> + </member> <member name="rendering/quality/intended_usage/framebuffer_allocation" type="int" setter="" getter="" default="2"> Strategy used for framebuffer allocation. The simpler it is, the less resources it uses (but the less features it supports). If set to "2D Without Sampling" or "3D Without Effects", sample buffers will not be allocated. This means [code]SCREEN_TEXTURE[/code] and [code]DEPTH_TEXTURE[/code] will not be available in shaders and post-processing effects will not be available in the [Environment]. </member> @@ -1060,6 +1060,8 @@ <member name="rendering/quality/reflections/texture_array_reflections.mobile" type="bool" setter="" getter="" default="false"> Lower-end override for [member rendering/quality/reflections/texture_array_reflections] on mobile devices, due to performance concerns or driver support. </member> + <member name="rendering/quality/screen_space_reflection/roughness_quality" type="int" setter="" getter="" default="1"> + </member> <member name="rendering/quality/shading/force_blinn_over_ggx" type="bool" setter="" getter="" default="false"> If [code]true[/code], uses faster but lower-quality Blinn model to generate blurred reflections instead of the GGX model. </member> diff --git a/doc/classes/ProximityGroup.xml b/doc/classes/ProximityGroup3D.xml index dee1a3daf0..1714c1ec8d 100644 --- a/doc/classes/ProximityGroup.xml +++ b/doc/classes/ProximityGroup3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ProximityGroup" inherits="Spatial" version="4.0"> +<class name="ProximityGroup3D" inherits="Node3D" version="4.0"> <brief_description> General-purpose proximity detection node. </brief_description> @@ -21,7 +21,7 @@ </method> </methods> <members> - <member name="dispatch_mode" type="int" setter="set_dispatch_mode" getter="get_dispatch_mode" enum="ProximityGroup.DispatchMode" default="0"> + <member name="dispatch_mode" type="int" setter="set_dispatch_mode" getter="get_dispatch_mode" enum="ProximityGroup3D.DispatchMode" default="0"> </member> <member name="grid_radius" type="Vector3" setter="set_grid_radius" getter="get_grid_radius" default="Vector3( 1, 1, 1 )"> </member> diff --git a/doc/classes/RID.xml b/doc/classes/RID.xml index 77c608fccb..644c427120 100644 --- a/doc/classes/RID.xml +++ b/doc/classes/RID.xml @@ -4,7 +4,7 @@ Handle for a [Resource]'s unique ID. </brief_description> <description> - The RID type is used to access the unique integer ID of a resource. They are opaque, which means they do not grant access to the associated resource by themselves. They are used by and with the low-level Server classes such as [VisualServer]. + The RID type is used to access the unique integer ID of a resource. They are opaque, which means they do not grant access to the associated resource by themselves. They are used by and with the low-level Server classes such as [RenderingServer]. </description> <tutorials> </tutorials> diff --git a/doc/classes/RayCast.xml b/doc/classes/RayCast3D.xml index 65f632ba74..08c6d6f40c 100644 --- a/doc/classes/RayCast.xml +++ b/doc/classes/RayCast3D.xml @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RayCast" inherits="Spatial" version="4.0"> +<class name="RayCast3D" inherits="Node3D" version="4.0"> <brief_description> Query the closest object intersecting a ray. </brief_description> <description> A RayCast represents a line from its origin to its destination position, [code]cast_to[/code]. It is used to query the 3D space in order to find the closest object along the path of the ray. - RayCast can ignore some objects by adding them to the exception list via [code]add_exception[/code] or by setting proper filtering with collision layers and masks. - RayCast can be configured to report collisions with [Area]s ([member collide_with_areas]) and/or [PhysicsBody]s ([member collide_with_bodies]). + RayCast3D can ignore some objects by adding them to the exception list via [code]add_exception[/code] or by setting proper filtering with collision layers and masks. + RayCast3D can be configured to report collisions with [Area3D]s ([member collide_with_areas]) and/or [PhysicsBody3D]s ([member collide_with_bodies]). Only enabled raycasts will be able to query the space and report collisions. - RayCast calculates intersection every physics frame (see [Node]), and the result is cached so it can be used later until the next frame. If multiple queries are required between physics frames (or during the same frame), use [method force_raycast_update] after adjusting the raycast. + RayCast3D calculates intersection every physics frame (see [Node]), and the result is cached so it can be used later until the next frame. If multiple queries are required between physics frames (or during the same frame), use [method force_raycast_update] after adjusting the raycast. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html</link> @@ -130,10 +130,10 @@ The ray's destination point, relative to the RayCast's [code]position[/code]. </member> <member name="collide_with_areas" type="bool" setter="set_collide_with_areas" getter="is_collide_with_areas_enabled" default="false"> - If [code]true[/code], collision with [Area]s will be reported. + If [code]true[/code], collision with [Area3D]s will be reported. </member> <member name="collide_with_bodies" type="bool" setter="set_collide_with_bodies" getter="is_collide_with_bodies_enabled" default="true"> - If [code]true[/code], collision with [PhysicsBody]s will be reported. + If [code]true[/code], collision with [PhysicsBody3D]s will be reported. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. @@ -142,7 +142,7 @@ If [code]true[/code], collisions will be reported. </member> <member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true"> - If [code]true[/code], collisions will be ignored for this RayCast's immediate parent. + If [code]true[/code], collisions will be ignored for this RayCast3D's immediate parent. </member> </members> <constants> diff --git a/doc/classes/RayShape.xml b/doc/classes/RayShape3D.xml index 87a642f779..9839044c30 100644 --- a/doc/classes/RayShape.xml +++ b/doc/classes/RayShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RayShape" inherits="Shape" version="4.0"> +<class name="RayShape3D" inherits="Shape3D" version="4.0"> <brief_description> Ray shape for 3D collisions. </brief_description> <description> - Ray shape for 3D collisions, which can be set into a [PhysicsBody] or [Area]. A ray is not really a collision body; instead, it tries to separate itself from whatever is touching its far endpoint. It's often useful for characters. + Ray shape for 3D collisions, which can be set into a [PhysicsBody3D] or [Area3D]. A ray is not really a collision body; instead, it tries to separate itself from whatever is touching its far endpoint. It's often useful for characters. </description> <tutorials> </tutorials> diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml index e138af6841..84f87c3e71 100644 --- a/doc/classes/ReflectionProbe.xml +++ b/doc/classes/ReflectionProbe.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ReflectionProbe" inherits="VisualInstance" version="4.0"> +<class name="ReflectionProbe" inherits="VisualInstance3D" version="4.0"> <brief_description> Captures its surroundings to create reflections. </brief_description> @@ -17,7 +17,7 @@ If [code]true[/code], enables box projection. This makes reflections look more correct in rectangle-shaped rooms by offsetting the reflection center depending on the camera's location. </member> <member name="cull_mask" type="int" setter="set_cull_mask" getter="get_cull_mask" default="1048575"> - Sets the cull mask which determines what objects are drawn by this probe. Every [VisualInstance] with a layer included in this cull mask will be rendered by the probe. It is best to only include large objects which are likely to take up a lot of space in the reflection in order to save on rendering cost. + Sets the cull mask which determines what objects are drawn by this probe. Every [VisualInstance3D] with a layer included in this cull mask will be rendered by the probe. It is best to only include large objects which are likely to take up a lot of space in the reflection in order to save on rendering cost. </member> <member name="enable_shadows" type="bool" setter="set_enable_shadows" getter="are_shadows_enabled" default="false"> If [code]true[/code], computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the [constant UPDATE_ALWAYS] [member update_mode]. diff --git a/doc/classes/RemoteTransform.xml b/doc/classes/RemoteTransform3D.xml index feb6ac1841..bd3da2aea9 100644 --- a/doc/classes/RemoteTransform.xml +++ b/doc/classes/RemoteTransform3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RemoteTransform" inherits="Spatial" version="4.0"> +<class name="RemoteTransform3D" inherits="Node3D" version="4.0"> <brief_description> - RemoteTransform pushes its own [Transform] to another [Spatial] derived Node in the scene. + RemoteTransform3D pushes its own [Transform] to another [Node3D] derived Node in the scene. </brief_description> <description> - RemoteTransform pushes its own [Transform] to another [Spatial] derived Node (called the remote node) in the scene. + RemoteTransform3D pushes its own [Transform] to another [Node3D] derived Node (called the remote node) in the scene. It can be set to update another Node's position, rotation and/or scale. It can use either global or local coordinates. </description> <tutorials> @@ -14,13 +14,13 @@ <return type="void"> </return> <description> - [RemoteTransform] caches the remote node. It may not notice if the remote node disappears; [method force_update_cache] forces it to update the cache again. + [RemoteTransform3D] caches the remote node. It may not notice if the remote node disappears; [method force_update_cache] forces it to update the cache again. </description> </method> </methods> <members> <member name="remote_path" type="NodePath" setter="set_remote_node" getter="get_remote_node" default="NodePath("")"> - The [NodePath] to the remote node, relative to the RemoteTransform's position in the scene. + The [NodePath] to the remote node, relative to the RemoteTransform3D's position in the scene. </member> <member name="update_position" type="bool" setter="set_update_position" getter="get_update_position" default="true"> If [code]true[/code], the remote node's position is updated. diff --git a/doc/classes/VisualServer.xml b/doc/classes/RenderingServer.xml index 00e0b7cdc9..d2d13fe406 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/RenderingServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualServer" inherits="Object" version="4.0"> +<class name="RenderingServer" inherits="Object" version="4.0"> <brief_description> Server for anything visible. </brief_description> @@ -9,7 +9,7 @@ The visual server can be used to bypass the scene system entirely. Resources are created using the [code]*_create[/code] functions. All objects are drawn to a viewport. You can use the [Viewport] attached to the [SceneTree] or you can create one yourself with [method viewport_create]. When using a custom scenario or canvas, the scenario or canvas needs to be attached to the viewport using [method viewport_set_scenario] or [method viewport_attach_canvas]. - In 3D, all visual objects must be associated with a scenario. The scenario is a visual representation of the world. If accessing the visual server from a running game, the scenario can be accessed from the scene tree from any [Spatial] node with [method Spatial.get_world]. Otherwise, a scenario can be created with [method scenario_create]. + In 3D, all visual objects must be associated with a scenario. The scenario is a visual representation of the world. If accessing the visual server from a running game, the scenario can be accessed from the scene tree from any [Node3D] node with [method Node3D.get_world]. Otherwise, a scenario can be created with [method scenario_create]. Similarly in 2D, a canvas is needed to draw all canvas items. In 3D, all visible objects are comprised of a resource and an instance. A resource can be a mesh, a particle system, a light, or any other 3D object. In order to be visible resources must be attached to an instance using [method instance_set_base]. The instance must also be attached to the scenario using [method instance_set_scenario] in order to be visible. In 2D, all visible objects are some form of canvas item. In order to be visible, a canvas item needs to be the child of a canvas attached to a viewport, or it needs to be the child of another canvas item that is eventually attached to the canvas. @@ -52,8 +52,8 @@ <return type="RID"> </return> <description> - Creates a camera and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]camera_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a camera and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]camera_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="camera_set_cull_mask"> @@ -64,7 +64,7 @@ <argument index="1" name="layers" type="int"> </argument> <description> - Sets the cull mask associated with this camera. The cull mask describes which 3D layers are rendered by this camera. Equivalent to [member Camera.cull_mask]. + Sets the cull mask associated with this camera. The cull mask describes which 3D layers are rendered by this camera. Equivalent to [member Camera3D.cull_mask]. </description> </method> <method name="camera_set_environment"> @@ -75,7 +75,7 @@ <argument index="1" name="env" type="RID"> </argument> <description> - Sets the environment used by this camera. Equivalent to [member Camera.environment]. + Sets the environment used by this camera. Equivalent to [member Camera3D.environment]. </description> </method> <method name="camera_set_frustum"> @@ -144,15 +144,15 @@ <argument index="1" name="enable" type="bool"> </argument> <description> - If [code]true[/code], preserves the horizontal aspect ratio which is equivalent to [constant Camera.KEEP_WIDTH]. If [code]false[/code], preserves the vertical aspect ratio which is equivalent to [constant Camera.KEEP_HEIGHT]. + If [code]true[/code], preserves the horizontal aspect ratio which is equivalent to [constant Camera3D.KEEP_WIDTH]. If [code]false[/code], preserves the vertical aspect ratio which is equivalent to [constant Camera3D.KEEP_HEIGHT]. </description> </method> <method name="canvas_create"> <return type="RID"> </return> <description> - Creates a canvas and returns the assigned [RID]. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a canvas and returns the assigned [RID]. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_item_clear"> @@ -247,8 +247,8 @@ <return type="RID"> </return> <description> - Creates a canvas light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a canvas light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_light_occluder_attach_to_canvas"> @@ -266,8 +266,8 @@ <return type="RID"> </return> <description> - Creates a light occluder and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_ocluder_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a light occluder and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_light_ocluder_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_light_occluder_set_enabled"> @@ -398,7 +398,7 @@ </return> <argument index="0" name="light" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="VisualServer.CanvasLightMode"> + <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasLightMode"> </argument> <description> The mode of the light, see [enum CanvasLightMode] constants. @@ -453,7 +453,7 @@ </return> <argument index="0" name="light" type="RID"> </argument> - <argument index="1" name="filter" type="int" enum="VisualServer.CanvasLightShadowFilter"> + <argument index="1" name="filter" type="int" enum="RenderingServer.CanvasLightShadowFilter"> </argument> <description> Sets the canvas light's shadow's filter, see [enum CanvasLightShadowFilter] constants. @@ -520,8 +520,8 @@ <return type="RID"> </return> <description> - Creates a new light occluder polygon and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_occluder_polygon_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a new light occluder polygon and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]canvas_occluder_polygon_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="canvas_occluder_polygon_set_cull_mode"> @@ -529,7 +529,7 @@ </return> <argument index="0" name="occluder_polygon" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="VisualServer.CanvasOccluderPolygonCullMode"> + <argument index="1" name="mode" type="int" enum="RenderingServer.CanvasOccluderPolygonCullMode"> </argument> <description> Sets an occluder polygons cull mode. See [enum CanvasOccluderPolygonCullMode] constants. @@ -587,8 +587,8 @@ <return type="RID"> </return> <description> - Creates a directional light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a directional light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this directional light to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -596,8 +596,8 @@ <return type="RID"> </return> <description> - Creates an environment and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]environment_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates an environment and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]environment_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="environment_set_adjustment"> @@ -626,13 +626,13 @@ </argument> <argument index="1" name="color" type="Color"> </argument> - <argument index="2" name="ambient" type="int" enum="VisualServer.EnvironmentAmbientSource" default="0"> + <argument index="2" name="ambient" type="int" enum="RenderingServer.EnvironmentAmbientSource" default="0"> </argument> <argument index="3" name="energy" type="float" default="1.0"> </argument> <argument index="4" name="sky_contibution" type="float" default="0.0"> </argument> - <argument index="5" name="reflection_source" type="int" enum="VisualServer.EnvironmentReflectionSource" default="0"> + <argument index="5" name="reflection_source" type="int" enum="RenderingServer.EnvironmentReflectionSource" default="0"> </argument> <argument index="6" name="ao_color" type="Color" default="Color( 0, 0, 0, 1 )"> </argument> @@ -644,7 +644,7 @@ </return> <argument index="0" name="env" type="RID"> </argument> - <argument index="1" name="bg" type="int" enum="VisualServer.EnvironmentBG"> + <argument index="1" name="bg" type="int" enum="RenderingServer.EnvironmentBG"> </argument> <description> Sets the [i]BGMode[/i] of the environment. Equivalent to [member Environment.background_mode]. @@ -755,7 +755,7 @@ </argument> <argument index="6" name="bloom_threshold" type="float"> </argument> - <argument index="7" name="blend_mode" type="int" enum="VisualServer.EnvironmentGlowBlendMode"> + <argument index="7" name="blend_mode" type="int" enum="RenderingServer.EnvironmentGlowBlendMode"> </argument> <argument index="8" name="hdr_bleed_threshold" type="float"> </argument> @@ -763,8 +763,6 @@ </argument> <argument index="10" name="hdr_luminance_cap" type="float"> </argument> - <argument index="11" name="bicubic_upscale" type="bool"> - </argument> <description> </description> </method> @@ -818,7 +816,7 @@ </argument> <argument index="6" name="ao_channel_affect" type="float"> </argument> - <argument index="7" name="blur" type="int" enum="VisualServer.EnvironmentSSAOBlur"> + <argument index="7" name="blur" type="int" enum="RenderingServer.EnvironmentSSAOBlur"> </argument> <argument index="8" name="bilateral_sharpness" type="float"> </argument> @@ -840,8 +838,6 @@ </argument> <argument index="5" name="depth_tolerance" type="float"> </argument> - <argument index="6" name="roughness" type="bool"> - </argument> <description> Sets the variables to be used with the "screen space reflections" post-process effect. See [Environment] for more details. </description> @@ -851,7 +847,7 @@ </return> <argument index="0" name="env" type="RID"> </argument> - <argument index="1" name="tone_mapper" type="int" enum="VisualServer.EnvironmentToneMapper"> + <argument index="1" name="tone_mapper" type="int" enum="RenderingServer.EnvironmentToneMapper"> </argument> <argument index="2" name="exposure" type="float"> </argument> @@ -902,13 +898,13 @@ <argument index="0" name="rid" type="RID"> </argument> <description> - Tries to free an object in the VisualServer. + Tries to free an object in the RenderingServer. </description> </method> <method name="get_render_info"> <return type="int"> </return> - <argument index="0" name="info" type="int" enum="VisualServer.RenderInfo"> + <argument index="0" name="info" type="int" enum="RenderingServer.RenderInfo"> </argument> <description> Returns a certain information, see [enum RenderInfo] for options. @@ -955,13 +951,13 @@ <return type="bool"> </return> <description> - Returns [code]true[/code] if changes have been made to the VisualServer's data. [method force_draw] is usually called if this happens. + Returns [code]true[/code] if changes have been made to the RenderingServer's data. [method force_draw] is usually called if this happens. </description> </method> <method name="has_feature" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="feature" type="int" enum="VisualServer.Features"> + <argument index="0" name="feature" type="int" enum="RenderingServer.Features"> </argument> <description> Not yet implemented. Always returns [code]false[/code]. @@ -981,12 +977,12 @@ </return> <argument index="0" name="immediate" type="RID"> </argument> - <argument index="1" name="primitive" type="int" enum="VisualServer.PrimitiveType"> + <argument index="1" name="primitive" type="int" enum="RenderingServer.PrimitiveType"> </argument> <argument index="2" name="texture" type="RID"> </argument> <description> - Sets up [ImmediateGeometry] internals to prepare for drawing. Equivalent to [method ImmediateGeometry.begin]. + Sets up [ImmediateGeometry3D] internals to prepare for drawing. Equivalent to [method ImmediateGeometry3D.begin]. </description> </method> <method name="immediate_clear"> @@ -995,7 +991,7 @@ <argument index="0" name="immediate" type="RID"> </argument> <description> - Clears everything that was set up between [method immediate_begin] and [method immediate_end]. Equivalent to [method ImmediateGeometry.clear]. + Clears everything that was set up between [method immediate_begin] and [method immediate_end]. Equivalent to [method ImmediateGeometry3D.clear]. </description> </method> <method name="immediate_color"> @@ -1006,15 +1002,15 @@ <argument index="1" name="color" type="Color"> </argument> <description> - Sets the color to be used with next vertex. Equivalent to [method ImmediateGeometry.set_color]. + Sets the color to be used with next vertex. Equivalent to [method ImmediateGeometry3D.set_color]. </description> </method> <method name="immediate_create"> <return type="RID"> </return> <description> - Creates an immediate geometry and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]immediate_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates an immediate geometry and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]immediate_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this immediate geometry to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -1024,7 +1020,7 @@ <argument index="0" name="immediate" type="RID"> </argument> <description> - Ends drawing the [ImmediateGeometry] and displays it. Equivalent to [method ImmediateGeometry.end]. + Ends drawing the [ImmediateGeometry3D] and displays it. Equivalent to [method ImmediateGeometry3D.end]. </description> </method> <method name="immediate_get_material" qualifiers="const"> @@ -1033,7 +1029,7 @@ <argument index="0" name="immediate" type="RID"> </argument> <description> - Returns the material assigned to the [ImmediateGeometry]. + Returns the material assigned to the [ImmediateGeometry3D]. </description> </method> <method name="immediate_normal"> @@ -1044,7 +1040,7 @@ <argument index="1" name="normal" type="Vector3"> </argument> <description> - Sets the normal to be used with next vertex. Equivalent to [method ImmediateGeometry.set_normal]. + Sets the normal to be used with next vertex. Equivalent to [method ImmediateGeometry3D.set_normal]. </description> </method> <method name="immediate_set_material"> @@ -1055,7 +1051,7 @@ <argument index="1" name="material" type="RID"> </argument> <description> - Sets the material to be used to draw the [ImmediateGeometry]. + Sets the material to be used to draw the [ImmediateGeometry3D]. </description> </method> <method name="immediate_tangent"> @@ -1066,7 +1062,7 @@ <argument index="1" name="tangent" type="Plane"> </argument> <description> - Sets the tangent to be used with next vertex. Equivalent to [method ImmediateGeometry.set_tangent]. + Sets the tangent to be used with next vertex. Equivalent to [method ImmediateGeometry3D.set_tangent]. </description> </method> <method name="immediate_uv"> @@ -1077,7 +1073,7 @@ <argument index="1" name="tex_uv" type="Vector2"> </argument> <description> - Sets the UV to be used with next vertex. Equivalent to [method ImmediateGeometry.set_uv]. + Sets the UV to be used with next vertex. Equivalent to [method ImmediateGeometry3D.set_uv]. </description> </method> <method name="immediate_uv2"> @@ -1088,7 +1084,7 @@ <argument index="1" name="tex_uv" type="Vector2"> </argument> <description> - Sets the UV2 to be used with next vertex. Equivalent to [method ImmediateGeometry.set_uv2]. + Sets the UV2 to be used with next vertex. Equivalent to [method ImmediateGeometry3D.set_uv2]. </description> </method> <method name="immediate_vertex"> @@ -1099,7 +1095,7 @@ <argument index="1" name="vertex" type="Vector3"> </argument> <description> - Adds the next vertex using the information provided in advance. Equivalent to [method ImmediateGeometry.add_vertex]. + Adds the next vertex using the information provided in advance. Equivalent to [method ImmediateGeometry3D.add_vertex]. </description> </method> <method name="immediate_vertex_2d"> @@ -1110,7 +1106,7 @@ <argument index="1" name="vertex" type="Vector2"> </argument> <description> - Adds the next vertex using the information provided in advance. This is a helper class that calls [method immediate_vertex] under the hood. Equivalent to [method ImmediateGeometry.add_vertex]. + Adds the next vertex using the information provided in advance. This is a helper class that calls [method immediate_vertex] under the hood. Equivalent to [method ImmediateGeometry3D.add_vertex]. </description> </method> <method name="init"> @@ -1146,8 +1142,8 @@ <return type="RID"> </return> <description> - Creates a visual instance and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a visual instance and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. An instance is a way of placing a 3D object in the scenario. Objects like particles, meshes, and reflection probes need to be associated with an instance to be visible in the scenario using [method instance_set_base]. </description> </method> @@ -1159,8 +1155,8 @@ <argument index="1" name="scenario" type="RID"> </argument> <description> - Creates a visual instance, adds it to the VisualServer, and sets both base and scenario. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a visual instance, adds it to the RenderingServer, and sets both base and scenario. It can be accessed with the RID that is returned. This RID will be used in all [code]instance_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="instance_geometry_set_as_instance_lod"> @@ -1179,10 +1175,10 @@ </return> <argument index="0" name="instance" type="RID"> </argument> - <argument index="1" name="shadow_casting_setting" type="int" enum="VisualServer.ShadowCastingSetting"> + <argument index="1" name="shadow_casting_setting" type="int" enum="RenderingServer.ShadowCastingSetting"> </argument> <description> - Sets the shadow casting setting to one of [enum ShadowCastingSetting]. Equivalent to [member GeometryInstance.cast_shadow]. + Sets the shadow casting setting to one of [enum ShadowCastingSetting]. Equivalent to [member GeometryInstance3D.cast_shadow]. </description> </method> <method name="instance_geometry_set_draw_range"> @@ -1207,7 +1203,7 @@ </return> <argument index="0" name="instance" type="RID"> </argument> - <argument index="1" name="flag" type="int" enum="VisualServer.InstanceFlags"> + <argument index="1" name="flag" type="int" enum="RenderingServer.InstanceFlags"> </argument> <argument index="2" name="enabled" type="bool"> </argument> @@ -1223,7 +1219,7 @@ <argument index="1" name="material" type="RID"> </argument> <description> - Sets a material that will override the material for all surfaces on the mesh associated with this instance. Equivalent to [member GeometryInstance.material_override]. + Sets a material that will override the material for all surfaces on the mesh associated with this instance. Equivalent to [member GeometryInstance3D.material_override]. </description> </method> <method name="instance_set_base"> @@ -1234,7 +1230,7 @@ <argument index="1" name="base" type="RID"> </argument> <description> - Sets the base of the instance. A base can be any of the 3D objects that are created in the VisualServer that can be displayed. For example, any of the light types, mesh, multimesh, immediate geometry, particle system, reflection probe, lightmap capture, and the GI probe are all types that can be set as the base of an instance in order to be displayed in the scenario. + Sets the base of the instance. A base can be any of the 3D objects that are created in the RenderingServer that can be displayed. For example, any of the light types, mesh, multimesh, immediate geometry, particle system, reflection probe, lightmap capture, and the GI probe are all types that can be set as the base of an instance in order to be displayed in the scenario. </description> </method> <method name="instance_set_blend_shape_weight"> @@ -1258,7 +1254,7 @@ <argument index="1" name="aabb" type="AABB"> </argument> <description> - Sets a custom AABB to use when culling objects from the view frustum. Equivalent to [method GeometryInstance.set_custom_aabb]. + Sets a custom AABB to use when culling objects from the view frustum. Equivalent to [method GeometryInstance3D.set_custom_aabb]. </description> </method> <method name="instance_set_exterior"> @@ -1280,7 +1276,7 @@ <argument index="1" name="margin" type="float"> </argument> <description> - Sets a margin to increase the size of the AABB when culling objects from the view frustum. This allows you avoid culling objects that fall outside the view frustum. Equivalent to [member GeometryInstance.extra_cull_margin]. + Sets a margin to increase the size of the AABB when culling objects from the view frustum. This allows you avoid culling objects that fall outside the view frustum. Equivalent to [member GeometryInstance3D.extra_cull_margin]. </description> </method> <method name="instance_set_layer_mask"> @@ -1291,7 +1287,7 @@ <argument index="1" name="mask" type="int"> </argument> <description> - Sets the render layers that this instance will be drawn to. Equivalent to [member VisualInstance.layers]. + Sets the render layers that this instance will be drawn to. Equivalent to [member VisualInstance3D.layers]. </description> </method> <method name="instance_set_scenario"> @@ -1315,7 +1311,7 @@ <argument index="2" name="material" type="RID"> </argument> <description> - Sets the material of a specific surface. Equivalent to [method MeshInstance.set_surface_material]. + Sets the material of a specific surface. Equivalent to [method MeshInstance3D.set_surface_material]. </description> </method> <method name="instance_set_transform"> @@ -1326,7 +1322,7 @@ <argument index="1" name="transform" type="Transform"> </argument> <description> - Sets the world space transform of the instance. Equivalent to [member Spatial.transform]. + Sets the world space transform of the instance. Equivalent to [member Node3D.transform]. </description> </method> <method name="instance_set_use_lightmap"> @@ -1350,7 +1346,7 @@ <argument index="1" name="visible" type="bool"> </argument> <description> - Sets whether an instance is drawn or not. Equivalent to [member Spatial.visible]. + Sets whether an instance is drawn or not. Equivalent to [member Node3D.visible]. </description> </method> <method name="instances_cull_aabb" qualifiers="const"> @@ -1361,7 +1357,7 @@ <argument index="1" name="scenario" type="RID"> </argument> <description> - Returns an array of object IDs intersecting with the provided AABB. Only visual 3D nodes are considered, such as [MeshInstance] or [DirectionalLight]. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World] you want to query. This forces an update for all resources queued to update. + Returns an array of object IDs intersecting with the provided AABB. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update. [b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision. </description> </method> @@ -1373,7 +1369,7 @@ <argument index="1" name="scenario" type="RID"> </argument> <description> - Returns an array of object IDs intersecting with the provided convex shape. Only visual 3D nodes are considered, such as [MeshInstance] or [DirectionalLight]. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World] you want to query. This forces an update for all resources queued to update. + Returns an array of object IDs intersecting with the provided convex shape. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update. [b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision. </description> </method> @@ -1387,7 +1383,7 @@ <argument index="2" name="scenario" type="RID"> </argument> <description> - Returns an array of object IDs intersecting with the provided 3D ray. Only visual 3D nodes are considered, such as [MeshInstance] or [DirectionalLight]. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World] you want to query. This forces an update for all resources queued to update. + Returns an array of object IDs intersecting with the provided 3D ray. Only visual 3D nodes are considered, such as [MeshInstance3D] or [DirectionalLight3D]. Use [method @GDScript.instance_from_id] to obtain the actual nodes. A scenario RID must be provided, which is available in the [World3D] you want to query. This forces an update for all resources queued to update. [b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision. </description> </method> @@ -1399,7 +1395,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> - If [code]true[/code], this directional light will blend between shadow map splits resulting in a smoother transition between them. Equivalent to [member DirectionalLight.directional_shadow_blend_splits]. + If [code]true[/code], this directional light will blend between shadow map splits resulting in a smoother transition between them. Equivalent to [member DirectionalLight3D.directional_shadow_blend_splits]. </description> </method> <method name="light_directional_set_shadow_depth_range_mode"> @@ -1407,10 +1403,10 @@ </return> <argument index="0" name="light" type="RID"> </argument> - <argument index="1" name="range_mode" type="int" enum="VisualServer.LightDirectionalShadowDepthRangeMode"> + <argument index="1" name="range_mode" type="int" enum="RenderingServer.LightDirectionalShadowDepthRangeMode"> </argument> <description> - Sets the shadow depth range mode for this directional light. Equivalent to [member DirectionalLight.directional_shadow_depth_range]. See [enum LightDirectionalShadowDepthRangeMode] for options. + Sets the shadow depth range mode for this directional light. Equivalent to [member DirectionalLight3D.directional_shadow_depth_range]. See [enum LightDirectionalShadowDepthRangeMode] for options. </description> </method> <method name="light_directional_set_shadow_mode"> @@ -1418,10 +1414,10 @@ </return> <argument index="0" name="light" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="VisualServer.LightDirectionalShadowMode"> + <argument index="1" name="mode" type="int" enum="RenderingServer.LightDirectionalShadowMode"> </argument> <description> - Sets the shadow mode for this directional light. Equivalent to [member DirectionalLight.directional_shadow_mode]. See [enum LightDirectionalShadowMode] for options. + Sets the shadow mode for this directional light. Equivalent to [member DirectionalLight3D.directional_shadow_mode]. See [enum LightDirectionalShadowMode] for options. </description> </method> <method name="light_omni_set_shadow_mode"> @@ -1429,10 +1425,10 @@ </return> <argument index="0" name="light" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="VisualServer.LightOmniShadowMode"> + <argument index="1" name="mode" type="int" enum="RenderingServer.LightOmniShadowMode"> </argument> <description> - Sets whether to use a dual paraboloid or a cubemap for the shadow map. Dual paraboloid is faster but may suffer from artifacts. Equivalent to [member OmniLight.omni_shadow_mode]. + Sets whether to use a dual paraboloid or a cubemap for the shadow map. Dual paraboloid is faster but may suffer from artifacts. Equivalent to [member OmniLight3D.omni_shadow_mode]. </description> </method> <method name="light_set_color"> @@ -1443,7 +1439,7 @@ <argument index="1" name="color" type="Color"> </argument> <description> - Sets the color of the light. Equivalent to [member Light.light_color]. + Sets the color of the light. Equivalent to [member Light3D.light_color]. </description> </method> <method name="light_set_cull_mask"> @@ -1454,7 +1450,7 @@ <argument index="1" name="mask" type="int"> </argument> <description> - Sets the cull mask for this Light. Lights only affect objects in the selected layers. Equivalent to [member Light.light_cull_mask]. + Sets the cull mask for this Light3D. Lights only affect objects in the selected layers. Equivalent to [member Light3D.light_cull_mask]. </description> </method> <method name="light_set_negative"> @@ -1465,7 +1461,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> - If [code]true[/code], light will subtract light instead of adding light. Equivalent to [member Light.light_negative]. + If [code]true[/code], light will subtract light instead of adding light. Equivalent to [member Light3D.light_negative]. </description> </method> <method name="light_set_param"> @@ -1473,12 +1469,12 @@ </return> <argument index="0" name="light" type="RID"> </argument> - <argument index="1" name="param" type="int" enum="VisualServer.LightParam"> + <argument index="1" name="param" type="int" enum="RenderingServer.LightParam"> </argument> <argument index="2" name="value" type="float"> </argument> <description> - Sets the specified light parameter. See [enum LightParam] for options. Equivalent to [method Light.set_param]. + Sets the specified light parameter. See [enum LightParam] for options. Equivalent to [method Light3D.set_param]. </description> </method> <method name="light_set_projector"> @@ -1500,7 +1496,7 @@ <argument index="1" name="enabled" type="bool"> </argument> <description> - If [code]true[/code], reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double sided shadows with [method instance_geometry_set_cast_shadows_setting]. Equivalent to [member Light.shadow_reverse_cull_face]. + If [code]true[/code], reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double sided shadows with [method instance_geometry_set_cast_shadows_setting]. Equivalent to [member Light3D.shadow_reverse_cull_face]. </description> </method> <method name="light_set_shadow"> @@ -1511,7 +1507,7 @@ <argument index="1" name="enabled" type="bool"> </argument> <description> - If [code]true[/code], light will cast shadows. Equivalent to [member Light.shadow_enabled]. + If [code]true[/code], light will cast shadows. Equivalent to [member Light3D.shadow_enabled]. </description> </method> <method name="light_set_shadow_color"> @@ -1522,7 +1518,7 @@ <argument index="1" name="color" type="Color"> </argument> <description> - Sets the color of the shadow cast by the light. Equivalent to [member Light.shadow_color]. + Sets the color of the shadow cast by the light. Equivalent to [member Light3D.shadow_color]. </description> </method> <method name="light_set_use_gi"> @@ -1540,8 +1536,8 @@ <return type="RID"> </return> <description> - Creates a lightmap capture and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]lightmap_capture_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a lightmap capture and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]lightmap_capture_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this lightmap capture to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -1662,8 +1658,8 @@ <return type="RID"> </return> <description> - Creates an empty material and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]material_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates an empty material and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]material_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="material_get_param" qualifiers="const"> @@ -1728,7 +1724,7 @@ </return> <argument index="0" name="mesh" type="RID"> </argument> - <argument index="1" name="primitive" type="int" enum="VisualServer.PrimitiveType"> + <argument index="1" name="primitive" type="int" enum="RenderingServer.PrimitiveType"> </argument> <argument index="2" name="arrays" type="Array"> </argument> @@ -1756,8 +1752,8 @@ <return type="RID"> </return> <description> - Creates a new mesh and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]mesh_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a new mesh and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]mesh_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this mesh to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -1771,7 +1767,7 @@ </description> </method> <method name="mesh_get_blend_shape_mode" qualifiers="const"> - <return type="int" enum="VisualServer.BlendShapeMode"> + <return type="int" enum="RenderingServer.BlendShapeMode"> </return> <argument index="0" name="mesh" type="RID"> </argument> @@ -1802,7 +1798,7 @@ </return> <argument index="0" name="mesh" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="VisualServer.BlendShapeMode"> + <argument index="1" name="mode" type="int" enum="RenderingServer.BlendShapeMode"> </argument> <description> Sets a mesh's blend shape mode. @@ -1915,7 +1911,7 @@ </argument> <argument index="1" name="instances" type="int"> </argument> - <argument index="2" name="transform_format" type="int" enum="VisualServer.MultimeshTransformFormat"> + <argument index="2" name="transform_format" type="int" enum="RenderingServer.MultimeshTransformFormat"> </argument> <argument index="3" name="color_format" type="bool" default="false"> </argument> @@ -1928,8 +1924,8 @@ <return type="RID"> </return> <description> - Creates a new multimesh on the VisualServer and returns an [RID] handle. This RID will be used in all [code]multimesh_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a new multimesh on the RenderingServer and returns an [RID] handle. This RID will be used in all [code]multimesh_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this multimesh to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -2109,8 +2105,8 @@ <return type="RID"> </return> <description> - Creates a new omni light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a new omni light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this omni light to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -2118,8 +2114,8 @@ <return type="RID"> </return> <description> - Creates a particle system and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]particles_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a particle system and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]particles_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach these particles to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -2129,7 +2125,7 @@ <argument index="0" name="particles" type="RID"> </argument> <description> - Calculates and returns the axis-aligned bounding box that contains all the particles. Equivalent to [method Particles.capture_aabb]. + Calculates and returns the axis-aligned bounding box that contains all the particles. Equivalent to [method GPUParticles3D.capture_aabb]. </description> </method> <method name="particles_get_emitting"> @@ -2165,7 +2161,7 @@ <argument index="0" name="particles" type="RID"> </argument> <description> - Reset the particles on the next update. Equivalent to [method Particles.restart]. + Reset the particles on the next update. Equivalent to [method GPUParticles3D.restart]. </description> </method> <method name="particles_set_amount"> @@ -2176,7 +2172,7 @@ <argument index="1" name="amount" type="int"> </argument> <description> - Sets the number of particles to be drawn and allocates the memory for them. Equivalent to [member Particles.amount]. + Sets the number of particles to be drawn and allocates the memory for them. Equivalent to [member GPUParticles3D.amount]. </description> </method> <method name="particles_set_custom_aabb"> @@ -2187,7 +2183,7 @@ <argument index="1" name="aabb" type="AABB"> </argument> <description> - Sets a custom axis-aligned bounding box for the particle system. Equivalent to [member Particles.visibility_aabb]. + Sets a custom axis-aligned bounding box for the particle system. Equivalent to [member GPUParticles3D.visibility_aabb]. </description> </method> <method name="particles_set_draw_order"> @@ -2195,10 +2191,10 @@ </return> <argument index="0" name="particles" type="RID"> </argument> - <argument index="1" name="order" type="int" enum="VisualServer.ParticlesDrawOrder"> + <argument index="1" name="order" type="int" enum="RenderingServer.ParticlesDrawOrder"> </argument> <description> - Sets the draw order of the particles to one of the named enums from [enum ParticlesDrawOrder]. See [enum ParticlesDrawOrder] for options. Equivalent to [member Particles.draw_order]. + Sets the draw order of the particles to one of the named enums from [enum ParticlesDrawOrder]. See [enum ParticlesDrawOrder] for options. Equivalent to [member GPUParticles3D.draw_order]. </description> </method> <method name="particles_set_draw_pass_mesh"> @@ -2211,7 +2207,7 @@ <argument index="2" name="mesh" type="RID"> </argument> <description> - Sets the mesh to be used for the specified draw pass. Equivalent to [member Particles.draw_pass_1], [member Particles.draw_pass_2], [member Particles.draw_pass_3], and [member Particles.draw_pass_4]. + Sets the mesh to be used for the specified draw pass. Equivalent to [member GPUParticles3D.draw_pass_1], [member GPUParticles3D.draw_pass_2], [member GPUParticles3D.draw_pass_3], and [member GPUParticles3D.draw_pass_4]. </description> </method> <method name="particles_set_draw_passes"> @@ -2222,7 +2218,7 @@ <argument index="1" name="count" type="int"> </argument> <description> - Sets the number of draw passes to use. Equivalent to [member Particles.draw_passes]. + Sets the number of draw passes to use. Equivalent to [member GPUParticles3D.draw_passes]. </description> </method> <method name="particles_set_emission_transform"> @@ -2244,7 +2240,7 @@ <argument index="1" name="emitting" type="bool"> </argument> <description> - If [code]true[/code], particles will emit over time. Setting to false does not reset the particles, but only stops their emission. Equivalent to [member Particles.emitting]. + If [code]true[/code], particles will emit over time. Setting to false does not reset the particles, but only stops their emission. Equivalent to [member GPUParticles3D.emitting]. </description> </method> <method name="particles_set_explosiveness_ratio"> @@ -2255,7 +2251,7 @@ <argument index="1" name="ratio" type="float"> </argument> <description> - Sets the explosiveness ratio. Equivalent to [member Particles.explosiveness]. + Sets the explosiveness ratio. Equivalent to [member GPUParticles3D.explosiveness]. </description> </method> <method name="particles_set_fixed_fps"> @@ -2266,7 +2262,7 @@ <argument index="1" name="fps" type="int"> </argument> <description> - Sets the frame rate that the particle system rendering will be fixed to. Equivalent to [member Particles.fixed_fps]. + Sets the frame rate that the particle system rendering will be fixed to. Equivalent to [member GPUParticles3D.fixed_fps]. </description> </method> <method name="particles_set_fractional_delta"> @@ -2277,7 +2273,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> - If [code]true[/code], uses fractional delta which smooths the movement of the particles. Equivalent to [member Particles.fract_delta]. + If [code]true[/code], uses fractional delta which smooths the movement of the particles. Equivalent to [member GPUParticles3D.fract_delta]. </description> </method> <method name="particles_set_lifetime"> @@ -2288,7 +2284,7 @@ <argument index="1" name="lifetime" type="float"> </argument> <description> - Sets the lifetime of each particle in the system. Equivalent to [member Particles.lifetime]. + Sets the lifetime of each particle in the system. Equivalent to [member GPUParticles3D.lifetime]. </description> </method> <method name="particles_set_one_shot"> @@ -2299,7 +2295,7 @@ <argument index="1" name="one_shot" type="bool"> </argument> <description> - If [code]true[/code], particles will emit once and then stop. Equivalent to [member Particles.one_shot]. + If [code]true[/code], particles will emit once and then stop. Equivalent to [member GPUParticles3D.one_shot]. </description> </method> <method name="particles_set_pre_process_time"> @@ -2310,7 +2306,7 @@ <argument index="1" name="time" type="float"> </argument> <description> - Sets the preprocess time for the particles animation. This lets you delay starting an animation until after the particles have begun emitting. Equivalent to [member Particles.preprocess]. + Sets the preprocess time for the particles animation. This lets you delay starting an animation until after the particles have begun emitting. Equivalent to [member GPUParticles3D.preprocess]. </description> </method> <method name="particles_set_process_material"> @@ -2321,7 +2317,7 @@ <argument index="1" name="material" type="RID"> </argument> <description> - Sets the material for processing the particles. Note: this is not the material used to draw the materials. Equivalent to [member Particles.process_material]. + Sets the material for processing the particles. Note: this is not the material used to draw the materials. Equivalent to [member GPUParticles3D.process_material]. </description> </method> <method name="particles_set_randomness_ratio"> @@ -2332,7 +2328,7 @@ <argument index="1" name="ratio" type="float"> </argument> <description> - Sets the emission randomness ratio. This randomizes the emission of particles within their phase. Equivalent to [member Particles.randomness]. + Sets the emission randomness ratio. This randomizes the emission of particles within their phase. Equivalent to [member GPUParticles3D.randomness]. </description> </method> <method name="particles_set_speed_scale"> @@ -2343,7 +2339,7 @@ <argument index="1" name="scale" type="float"> </argument> <description> - Sets the speed scale of the particle system. Equivalent to [member Particles.speed_scale]. + Sets the speed scale of the particle system. Equivalent to [member GPUParticles3D.speed_scale]. </description> </method> <method name="particles_set_use_local_coordinates"> @@ -2354,15 +2350,15 @@ <argument index="1" name="enable" type="bool"> </argument> <description> - If [code]true[/code], particles use local coordinates. If [code]false[/code] they use global coordinates. Equivalent to [member Particles.local_coords]. + If [code]true[/code], particles use local coordinates. If [code]false[/code] they use global coordinates. Equivalent to [member GPUParticles3D.local_coords]. </description> </method> <method name="reflection_probe_create"> <return type="RID"> </return> <description> - Creates a reflection probe and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]reflection_probe_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a reflection probe and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]reflection_probe_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this reflection probe to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -2492,7 +2488,7 @@ </return> <argument index="0" name="probe" type="RID"> </argument> - <argument index="1" name="mode" type="int" enum="VisualServer.ReflectionProbeUpdateMode"> + <argument index="1" name="mode" type="int" enum="RenderingServer.ReflectionProbeUpdateMode"> </argument> <description> Sets how often the reflection probe updates. Can either be once or every frame. See [enum ReflectionProbeUpdateMode] for options. @@ -2516,8 +2512,8 @@ <return type="RID"> </return> <description> - Creates a scenario and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]scenario_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a scenario and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]scenario_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. The scenario is the 3D world that all the visual instances exist in. </description> </method> @@ -2526,7 +2522,7 @@ </return> <argument index="0" name="scenario" type="RID"> </argument> - <argument index="1" name="debug_mode" type="int" enum="VisualServer.ScenarioDebugMode"> + <argument index="1" name="debug_mode" type="int" enum="RenderingServer.ScenarioDebugMode"> </argument> <description> Sets the [enum ScenarioDebugMode] for this scenario. See [enum ScenarioDebugMode] for options. @@ -2591,8 +2587,8 @@ <return type="RID"> </return> <description> - Creates an empty shader and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]shader_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates an empty shader and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]shader_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="shader_get_code" qualifiers="const"> @@ -2723,8 +2719,8 @@ <return type="RID"> </return> <description> - Creates a skeleton and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]skeleton_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a skeleton and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]skeleton_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="skeleton_get_bone_count" qualifiers="const"> @@ -2740,8 +2736,8 @@ <return type="RID"> </return> <description> - Creates an empty sky and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]sky_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates an empty sky and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]sky_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="sky_set_material"> @@ -2759,8 +2755,8 @@ <return type="RID"> </return> <description> - Creates a spot light and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. + Creates a spot light and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID can be used in most [code]light_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. To place in a scene, attach this spot light to an instance using [method instance_set_base] using the returned RID. </description> </method> @@ -2812,7 +2808,7 @@ <argument index="2" name="screen" type="int" default="0"> </argument> <description> - Copies viewport to a region of the screen specified by [code]rect[/code]. If [member Viewport.render_direct_to_screen] is [code]true[/code], then viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. + Copies the viewport to a region of the screen specified by [code]rect[/code]. If [method viewport_set_render_direct_to_screen] is [code]true[/code], then the viewport does not use a framebuffer and the contents of the viewport are rendered directly to screen. However, note that the root viewport is drawn last, therefore it will draw over the screen. Accordingly, you must set the root viewport to an area that does not cover the area that you have attached this viewport to. For example, you can set the root viewport to not render at all with the following code: [codeblock] func _ready(): @@ -2826,17 +2822,8 @@ <return type="RID"> </return> <description> - Creates an empty viewport and adds it to the VisualServer. It can be accessed with the RID that is returned. This RID will be used in all [code]viewport_*[/code] VisualServer functions. - Once finished with your RID, you will want to free the RID using the VisualServer's [method free_rid] static method. - </description> - </method> - <method name="viewport_detach"> - <return type="void"> - </return> - <argument index="0" name="viewport" type="RID"> - </argument> - <description> - Detaches the viewport from the screen. + Creates an empty viewport and adds it to the RenderingServer. It can be accessed with the RID that is returned. This RID will be used in all [code]viewport_*[/code] RenderingServer functions. + Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method. </description> </method> <method name="viewport_get_render_info"> @@ -2844,7 +2831,7 @@ </return> <argument index="0" name="viewport" type="RID"> </argument> - <argument index="1" name="info" type="int" enum="VisualServer.ViewportRenderInfo"> + <argument index="1" name="info" type="int" enum="RenderingServer.ViewportRenderInfo"> </argument> <description> Returns a viewport's render information. For options, see the [enum ViewportRenderInfo] constants. @@ -2915,7 +2902,7 @@ </return> <argument index="0" name="viewport" type="RID"> </argument> - <argument index="1" name="clear_mode" type="int" enum="VisualServer.ViewportClearMode"> + <argument index="1" name="clear_mode" type="int" enum="RenderingServer.ViewportClearMode"> </argument> <description> Sets the clear mode of a viewport. See [enum ViewportClearMode] for options. @@ -2926,7 +2913,7 @@ </return> <argument index="0" name="viewport" type="RID"> </argument> - <argument index="1" name="draw" type="int" enum="VisualServer.ViewportDebugDraw"> + <argument index="1" name="draw" type="int" enum="RenderingServer.ViewportDebugDraw"> </argument> <description> Sets the debug draw mode of a viewport. See [enum ViewportDebugDraw] for options. @@ -2981,7 +2968,7 @@ </return> <argument index="0" name="viewport" type="RID"> </argument> - <argument index="1" name="msaa" type="int" enum="VisualServer.ViewportMSAA"> + <argument index="1" name="msaa" type="int" enum="RenderingServer.ViewportMSAA"> </argument> <description> Sets the anti-aliasing mode. See [enum ViewportMSAA] for options. @@ -3074,7 +3061,7 @@ </return> <argument index="0" name="viewport" type="RID"> </argument> - <argument index="1" name="update_mode" type="int" enum="VisualServer.ViewportUpdateMode"> + <argument index="1" name="update_mode" type="int" enum="RenderingServer.ViewportUpdateMode"> </argument> <description> Sets when the viewport should be updated. See [enum ViewportUpdateMode] constants for options. @@ -3095,12 +3082,12 @@ <signals> <signal name="frame_post_draw"> <description> - Emitted at the end of the frame, after the VisualServer has finished updating all the Viewports. + Emitted at the end of the frame, after the RenderingServer has finished updating all the Viewports. </description> </signal> <signal name="frame_pre_draw"> <description> - Emitted at the beginning of the frame, before the VisualServer updates all the Viewports. + Emitted at the beginning of the frame, before the RenderingServer updates all the Viewports. </description> </signal> </signals> @@ -3378,7 +3365,9 @@ <constant name="VIEWPORT_UPDATE_WHEN_VISIBLE" value="2" enum="ViewportUpdateMode"> Update the viewport whenever it is visible. </constant> - <constant name="VIEWPORT_UPDATE_ALWAYS" value="3" enum="ViewportUpdateMode"> + <constant name="VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE" value="3" enum="ViewportUpdateMode"> + </constant> + <constant name="VIEWPORT_UPDATE_ALWAYS" value="4" enum="ViewportUpdateMode"> Always update the viewport. </constant> <constant name="VIEWPORT_CLEAR_ALWAYS" value="0" enum="ViewportClearMode"> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 79c4205f59..e746d7fc96 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -16,7 +16,7 @@ <method name="_integrate_forces" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="state" type="Physics2DDirectBodyState"> + <argument index="0" name="state" type="PhysicsDirectBodyState2D"> </argument> <description> Allows you to read and safely modify the simulation state for the object. Use this instead of [method Node._physics_process] if you need to directly change the body's [code]position[/code] or other physics properties. By default, it works in addition to the usual physics behavior, but [member custom_integrator] allows you to disable the default behavior and write custom force integration for a body. @@ -106,10 +106,10 @@ </argument> <argument index="2" name="margin" type="float" default="0.08"> </argument> - <argument index="3" name="result" type="Physics2DTestMotionResult" default="null"> + <argument index="3" name="result" type="PhysicsTestMotionResult2D" default="null"> </argument> <description> - Returns [code]true[/code] if a collision would result from moving in the given vector. [code]margin[/code] increases the size of the shapes involved in the collision detection, and [code]result[/code] is an object of type [Physics2DTestMotionResult], which contains additional information about the collision (should there be one). + Returns [code]true[/code] if a collision would result from moving in the given vector. [code]margin[/code] increases the size of the shapes involved in the collision detection, and [code]result[/code] is an object of type [PhysicsTestMotionResult2D], which contains additional information about the collision (should there be one). </description> </method> </methods> diff --git a/doc/classes/RigidBody.xml b/doc/classes/RigidBody3D.xml index e2b7813361..829589f650 100644 --- a/doc/classes/RigidBody.xml +++ b/doc/classes/RigidBody3D.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RigidBody" inherits="PhysicsBody" version="4.0"> +<class name="RigidBody3D" inherits="PhysicsBody3D" version="4.0"> <brief_description> Physics Body whose position is determined through physics simulation in 3D space. </brief_description> <description> - This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc. - A RigidBody has 4 behavior [member mode]s: Rigid, Static, Character, and Kinematic. - [b]Note:[/b] Don't change a RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state. + This is the node that implements full 3D physics. This means that you do not control a RigidBody3D directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc. + A RigidBody3D has 4 behavior [member mode]s: Rigid, Static, Character, and Kinematic. + [b]Note:[/b] Don't change a RigidBody3D's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state. If you need to override the default physics behavior, you can write a custom force integration function. See [member custom_integrator]. </description> <tutorials> @@ -16,7 +16,7 @@ <method name="_integrate_forces" qualifiers="virtual"> <return type="void"> </return> - <argument index="0" name="state" type="PhysicsDirectBodyState"> + <argument index="0" name="state" type="PhysicsDirectBodyState3D"> </argument> <description> Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the [member custom_integrator] property allows you to disable the default behavior and do fully custom force integration for a body. @@ -85,7 +85,7 @@ <method name="get_axis_lock" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="axis" type="int" enum="PhysicsServer.BodyAxis"> + <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> </argument> <description> Returns [code]true[/code] if the specified linear or rotational axis is locked. @@ -102,7 +102,7 @@ <method name="set_axis_lock"> <return type="void"> </return> - <argument index="0" name="axis" type="int" enum="PhysicsServer.BodyAxis"> + <argument index="0" name="axis" type="int" enum="PhysicsServer3D.BodyAxis"> </argument> <argument index="1" name="lock" type="bool"> </argument> @@ -122,10 +122,10 @@ </methods> <members> <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="-1.0"> - Damps RigidBody's rotational forces. + Damps RigidBody3D's rotational forces. </member> <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3( 0, 0, 0 )"> - RigidBody's rotational velocity. + RigidBody3D's rotational velocity. </member> <member name="axis_lock_angular_x" type="bool" setter="set_axis_lock" getter="get_axis_lock" default="false"> Lock the body's rotation in the X axis. @@ -146,10 +146,10 @@ Lock the body's movement in the Z axis. </member> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> - 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. + If [code]true[/code], the RigidBody3D 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" default="false"> - If [code]true[/code], the RigidBody will emit signals when it collides with another RigidBody. + If [code]true[/code], the RigidBody3D will emit signals when it collides with another RigidBody3D. </member> <member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported" default="0"> 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. @@ -162,7 +162,7 @@ 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="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0"> - This is multiplied by the global 3D gravity setting found in [b]Project > Project Settings > Physics > 3d[/b] to produce RigidBody's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. + This is multiplied by the global 3D gravity setting found in [b]Project > Project Settings > Physics > 3d[/b] to produce RigidBody3D's gravity. For example, 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" default="-1.0"> The body's linear damp. Cannot be less than -1.0. If this value is different from -1.0, any linear damp derived from the world or areas will be overridden. @@ -173,7 +173,7 @@ <member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0"> The body's mass. </member> - <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody.Mode" default="0"> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody3D.Mode" default="0"> The body mode. See [enum Mode] for possible values. </member> <member name="physics_material_override" type="PhysicsMaterial" setter="set_physics_material_override" getter="get_physics_material_override"> @@ -241,13 +241,13 @@ 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. + Static mode. The body behaves like a [StaticBody3D], and can only move by user code. </constant> <constant name="MODE_CHARACTER" value="2" enum="Mode"> Character body mode. This behaves like a rigid body, but can not rotate. </constant> <constant name="MODE_KINEMATIC" value="3" enum="Mode"> - Kinematic body mode. The body behaves like a [KinematicBody], and can only move by user code. + Kinematic body mode. The body behaves like a [KinematicBody3D], and can only move by user code. </constant> </constants> </class> diff --git a/doc/classes/RootMotionView.xml b/doc/classes/RootMotionView.xml index 654e42a3c6..be8d8d0078 100644 --- a/doc/classes/RootMotionView.xml +++ b/doc/classes/RootMotionView.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RootMotionView" inherits="VisualInstance" version="4.0"> +<class name="RootMotionView" inherits="VisualInstance3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index e6778013cf..00ca5c6e9f 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -135,13 +135,6 @@ Returns [code]true[/code] if there is a [member network_peer] set. </description> </method> - <method name="is_input_handled"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if the most recent [InputEvent] was marked as handled with [method set_input_as_handled]. - </description> - </method> <method name="is_network_server" qualifiers="const"> <return type="bool"> </return> @@ -237,13 +230,6 @@ Sets the given [code]property[/code] to [code]value[/code] on all members of the given group, respecting the given [enum GroupCallFlags]. </description> </method> - <method name="set_input_as_handled"> - <return type="void"> - </return> - <description> - Marks the most recent [InputEvent] as handled. - </description> - </method> <method name="set_quit_on_go_back"> <return type="void"> </return> @@ -251,22 +237,7 @@ </argument> <description> If [code]true[/code], the application quits automatically on going back (e.g. on Android). Enabled by default. - To handle 'Go Back' button when this option is disabled, use [constant MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST]. - </description> - </method> - <method name="set_screen_stretch"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="SceneTree.StretchMode"> - </argument> - <argument index="1" name="aspect" type="int" enum="SceneTree.StretchAspect"> - </argument> - <argument index="2" name="minsize" type="Vector2"> - </argument> - <argument index="3" name="shrink" type="float" default="1"> - </argument> - <description> - Configures screen stretching to the given [enum StretchMode], [enum StretchAspect], minimum size and [code]shrink[/code] ratio. + To handle 'Go Back' button when this option is disabled, use [constant DisplayServer.WINDOW_EVENT_GO_BACK_REQUEST]. </description> </method> </methods> @@ -301,11 +272,8 @@ <member name="refuse_new_network_connections" type="bool" setter="set_refuse_new_network_connections" getter="is_refusing_new_network_connections" default="false"> If [code]true[/code], the [SceneTree]'s [member network_peer] refuses new incoming connections. </member> - <member name="root" type="Viewport" setter="" getter="get_root"> - The [SceneTree]'s root [Viewport]. - </member> - <member name="use_font_oversampling" type="bool" setter="set_use_font_oversampling" getter="is_using_font_oversampling" default="false"> - If [code]true[/code], font oversampling is used. + <member name="root" type="Window" setter="" getter="get_root"> + The [SceneTree]'s root [Window]. </member> </members> <signals> @@ -328,15 +296,6 @@ Emitted when files are dragged from the OS file manager and dropped in the game window. The arguments are a list of file paths and the identifier of the screen where the drag originated. </description> </signal> - <signal name="global_menu_action"> - <argument index="0" name="id" type="Variant"> - </argument> - <argument index="1" name="meta" type="Variant"> - </argument> - <description> - Emitted whenever global menu item is clicked. - </description> - </signal> <signal name="idle_frame"> <description> Emitted immediately before [method Node._process] is called on every node in the [SceneTree]. @@ -389,11 +348,6 @@ Emitted immediately before [method Node._physics_process] is called on every node in the [SceneTree]. </description> </signal> - <signal name="screen_resized"> - <description> - Emitted when the screen resolution (fullscreen) or window size (windowed) changes. - </description> - </signal> <signal name="server_disconnected"> <description> Emitted whenever this [SceneTree]'s [member network_peer] disconnected from server. Only emitted on clients. @@ -418,29 +372,5 @@ <constant name="GROUP_CALL_UNIQUE" value="4" enum="GroupCallFlags"> Call a group only once even if the call is executed many times. </constant> - <constant name="STRETCH_MODE_DISABLED" value="0" enum="StretchMode"> - No stretching. - </constant> - <constant name="STRETCH_MODE_2D" value="1" enum="StretchMode"> - Render stretching in higher resolution (interpolated). - </constant> - <constant name="STRETCH_MODE_VIEWPORT" value="2" enum="StretchMode"> - Keep the specified display resolution. No interpolation. Content may appear pixelated. - </constant> - <constant name="STRETCH_ASPECT_IGNORE" value="0" enum="StretchAspect"> - Fill the window with the content stretched to cover excessive space. Content may appear stretched. - </constant> - <constant name="STRETCH_ASPECT_KEEP" value="1" enum="StretchAspect"> - Retain the same aspect ratio by padding with black bars on either axis. This prevents distortion. - </constant> - <constant name="STRETCH_ASPECT_KEEP_WIDTH" value="2" enum="StretchAspect"> - Expand vertically. Left/right black bars may appear if the window is too wide. - </constant> - <constant name="STRETCH_ASPECT_KEEP_HEIGHT" value="3" enum="StretchAspect"> - Expand horizontally. Top/bottom black bars may appear if the window is too tall. - </constant> - <constant name="STRETCH_ASPECT_EXPAND" value="4" enum="StretchAspect"> - Expand in both directions, retaining the same aspect ratio. This prevents distortion while avoiding black bars. - </constant> </constants> </class> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml index 9f16a6ed46..aa60ecb12b 100644 --- a/doc/classes/ScriptCreateDialog.xml +++ b/doc/classes/ScriptCreateDialog.xml @@ -4,7 +4,7 @@ The Editor's popup dialog for creating new [Script] files. </brief_description> <description> - The [ScriptCreateDialog] creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling one of the [method Popup.popup] methods. + The [ScriptCreateDialog] creates script files according to a given template for a given scripting language. The standard use is to configure its fields prior to calling one of the [method Window.popup] methods. [codeblock] func _ready(): dialog.config("Node", "res://new_node.gd") # For in-engine types @@ -33,10 +33,7 @@ </methods> <members> <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> - <member name="margin_bottom" type="float" setter="set_margin" getter="get_margin" override="true" default="232.0" /> - <member name="margin_right" type="float" setter="set_margin" getter="get_margin" override="true" default="361.0" /> - <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" override="true" default="Vector2( 361, 232 )" /> - <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Attach Node Script"" /> + <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Attach Node Script"" /> </members> <signals> <signal name="script_created"> diff --git a/doc/classes/Shape.xml b/doc/classes/Shape3D.xml index d70d2c09b3..1af6550dc5 100644 --- a/doc/classes/Shape.xml +++ b/doc/classes/Shape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Shape" inherits="Resource" version="4.0"> +<class name="Shape3D" inherits="Resource" version="4.0"> <brief_description> Base class for all 3D shape resources. </brief_description> <description> - Base class for all 3D shape resources. Nodes that inherit from this can be used as shapes for a [PhysicsBody] or [Area] objects. + Base class for all 3D shape resources. Nodes that inherit from this can be used as shapes for a [PhysicsBody3D] or [Area3D] objects. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html</link> diff --git a/doc/classes/Skeleton.xml b/doc/classes/Skeleton3D.xml index eaab4063b8..08404fb467 100644 --- a/doc/classes/Skeleton.xml +++ b/doc/classes/Skeleton3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Skeleton" inherits="Spatial" version="4.0"> +<class name="Skeleton3D" inherits="Node3D" version="4.0"> <brief_description> Skeleton for characters and animated objects. </brief_description> <description> - Skeleton provides a hierarchical interface for managing bones, including pose, rest and animation (see [Animation]). It can also use ragdoll physics. + Skeleton3D provides a hierarchical interface for managing bones, including pose, rest and animation (see [Animation]). It can also use ragdoll physics. The overall transform of a bone with respect to the skeleton is determined by the following hierarchical order: rest pose, custom pose and pose. Note that "global pose" below refers to the overall transform of the bone with respect to skeleton, so it not the actual global/world transform of the bone. </description> @@ -38,6 +38,12 @@ Clear all the bones in this skeleton. </description> </method> + <method name="clear_bones_global_pose_override"> + <return type="void"> + </return> + <description> + </description> + </method> <method name="find_bone" qualifiers="const"> <return type="int"> </return> diff --git a/doc/classes/SkeletonIK.xml b/doc/classes/SkeletonIK3D.xml index 1db78314d2..de83847403 100644 --- a/doc/classes/SkeletonIK.xml +++ b/doc/classes/SkeletonIK3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SkeletonIK" inherits="Node" version="4.0"> +<class name="SkeletonIK3D" inherits="Node" version="4.0"> <brief_description> </brief_description> <description> @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="get_parent_skeleton" qualifiers="const"> - <return type="Skeleton"> + <return type="Skeleton3D"> </return> <description> </description> diff --git a/doc/classes/SliderJoint.xml b/doc/classes/SliderJoint3D.xml index dc0cf96eb4..efd6353e3c 100644 --- a/doc/classes/SliderJoint.xml +++ b/doc/classes/SliderJoint3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SliderJoint" inherits="Joint" version="4.0"> +<class name="SliderJoint3D" inherits="Joint3D" version="4.0"> <brief_description> Piston kind of slider between two bodies in 3D. </brief_description> @@ -12,7 +12,7 @@ <method name="get_param" qualifiers="const"> <return type="float"> </return> - <argument index="0" name="param" type="int" enum="SliderJoint.Param"> + <argument index="0" name="param" type="int" enum="SliderJoint3D.Param"> </argument> <description> </description> @@ -20,7 +20,7 @@ <method name="set_param"> <return type="void"> </return> - <argument index="0" name="param" type="int" enum="SliderJoint.Param"> + <argument index="0" name="param" type="int" enum="SliderJoint3D.Param"> </argument> <argument index="1" name="value" type="float"> </argument> diff --git a/doc/classes/SoftBody.xml b/doc/classes/SoftBody3D.xml index 46a00fbd67..24d6609900 100644 --- a/doc/classes/SoftBody.xml +++ b/doc/classes/SoftBody3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SoftBody" inherits="MeshInstance" version="4.0"> +<class name="SoftBody3D" inherits="MeshInstance3D" version="4.0"> <brief_description> A soft mesh physics body. </brief_description> @@ -80,12 +80,12 @@ <member name="areaAngular_stiffness" type="float" setter="set_areaAngular_stiffness" getter="get_areaAngular_stiffness" default="0.5"> </member> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> - The physics layers this SoftBody is in. + The physics layers this SoftBody3D is in. Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. </member> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> - The physics layers this SoftBody scans for collisions. + The physics layers this SoftBody3D scans for collisions. </member> <member name="damping_coefficient" type="float" setter="set_damping_coefficient" getter="get_damping_coefficient" default="0.01"> </member> @@ -94,20 +94,20 @@ <member name="linear_stiffness" type="float" setter="set_linear_stiffness" getter="get_linear_stiffness" default="0.5"> </member> <member name="parent_collision_ignore" type="NodePath" setter="set_parent_collision_ignore" getter="get_parent_collision_ignore" default="NodePath("")"> - [NodePath] to a [CollisionObject] this SoftBody should avoid clipping. + [NodePath] to a [CollisionObject3D] this SoftBody3D should avoid clipping. </member> <member name="pose_matching_coefficient" type="float" setter="set_pose_matching_coefficient" getter="get_pose_matching_coefficient" default="0.0"> </member> <member name="pressure_coefficient" type="float" setter="set_pressure_coefficient" getter="get_pressure_coefficient" default="0.0"> </member> <member name="ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable" default="true"> - If [code]true[/code], the [SoftBody] will respond to [RayCast]s. + If [code]true[/code], the [SoftBody3D] will respond to [RayCast3D]s. </member> <member name="simulation_precision" type="int" setter="set_simulation_precision" getter="get_simulation_precision" default="5"> Increasing this value will improve the resulting simulation, but can affect performance. Use with care. </member> <member name="total_mass" type="float" setter="set_total_mass" getter="get_total_mass" default="1.0"> - The SoftBody's mass. + The SoftBody3D's mass. </member> <member name="volume_stiffness" type="float" setter="set_volume_stiffness" getter="get_volume_stiffness" default="0.5"> </member> diff --git a/doc/classes/SphereShape.xml b/doc/classes/SphereShape3D.xml index 75dab58c38..1eaf890639 100644 --- a/doc/classes/SphereShape.xml +++ b/doc/classes/SphereShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SphereShape" inherits="Shape" version="4.0"> +<class name="SphereShape3D" inherits="Shape3D" version="4.0"> <brief_description> Sphere shape for 3D collisions. </brief_description> <description> - Sphere shape for 3D collisions, which can be set into a [PhysicsBody] or [Area]. This shape is useful for modeling sphere-like 3D objects. + Sphere shape for 3D collisions, which can be set into a [PhysicsBody3D] or [Area3D]. This shape is useful for modeling sphere-like 3D objects. </description> <tutorials> </tutorials> diff --git a/doc/classes/SpotLight.xml b/doc/classes/SpotLight3D.xml index 351d4f8aff..f094818c21 100644 --- a/doc/classes/SpotLight.xml +++ b/doc/classes/SpotLight3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpotLight" inherits="Light" version="4.0"> +<class name="SpotLight3D" inherits="Light3D" version="4.0"> <brief_description> A spotlight, such as a reflector spotlight or a lantern. </brief_description> <description> - A Spotlight is a type of [Light] node that emits lights in a specific direction, in the shape of a cone. The light is attenuated through the distance. This attenuation can be configured by changing the energy, radius and attenuation parameters of [Light]. + A Spotlight is a type of [Light3D] node that emits lights in a specific direction, in the shape of a cone. The light is attenuated through the distance. This attenuation can be configured by changing the energy, radius and attenuation parameters of [Light3D]. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/lights_and_shadows.html</link> diff --git a/doc/classes/SpringArm.xml b/doc/classes/SpringArm3D.xml index 780ed5077d..8305494c2b 100644 --- a/doc/classes/SpringArm.xml +++ b/doc/classes/SpringArm3D.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpringArm" inherits="Spatial" version="4.0"> +<class name="SpringArm3D" inherits="Node3D" version="4.0"> <brief_description> A helper node, mostly used in 3rd person cameras. </brief_description> <description> - The SpringArm node is a node that casts a ray (or collision shape) along its z axis and moves all its direct children to the collision point, minus a margin. + The SpringArm3D node is a node that casts a ray (or collision shape) along its z axis and moves all its direct children to the collision point, minus a margin. The most common use case for this is to make a 3rd person camera that reacts to collisions in the environment. - The SpringArm will either cast a ray, or if a shape is given, it will cast the shape in the direction of its z axis. - If you use the SpringArm as a camera controller for your player, you might need to exclude the player's collider from the SpringArm's collision check. + The SpringArm3D will either cast a ray, or if a shape is given, it will cast the shape in the direction of its z axis. + If you use the SpringArm3D as a camera controller for your player, you might need to exclude the player's collider from the SpringArm3D's collision check. </description> <tutorials> </tutorials> @@ -18,14 +18,14 @@ <argument index="0" name="RID" type="RID"> </argument> <description> - Adds the [PhysicsBody] object with the given [RID] to the list of [PhysicsBody] objects excluded from the collision check. + Adds the [PhysicsBody3D] object with the given [RID] to the list of [PhysicsBody3D] objects excluded from the collision check. </description> </method> <method name="clear_excluded_objects"> <return type="void"> </return> <description> - Clears the list of [PhysicsBody] objects excluded from the collision check. + Clears the list of [PhysicsBody3D] objects excluded from the collision check. </description> </method> <method name="get_hit_length"> @@ -41,7 +41,7 @@ <argument index="0" name="RID" type="RID"> </argument> <description> - Removes the given [RID] from the list of [PhysicsBody] objects excluded from the collision check. + Removes the given [RID] from the list of [PhysicsBody3D] objects excluded from the collision check. </description> </method> </methods> @@ -50,17 +50,17 @@ The layers against which the collision check shall be done. </member> <member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.01"> - When the collision check is made, a candidate length for the SpringArm is given. - The margin is then subtracted to this length and the translation is applied to the child objects of the SpringArm. - This margin is useful for when the SpringArm has a [Camera] as a child node: without the margin, the [Camera] would be placed on the exact point of collision, while with the margin the [Camera] would be placed close to the point of collision. + When the collision check is made, a candidate length for the SpringArm3D is given. + The margin is then subtracted to this length and the translation is applied to the child objects of the SpringArm3D. + This margin is useful for when the SpringArm3D has a [Camera3D] as a child node: without the margin, the [Camera3D] would be placed on the exact point of collision, while with the margin the [Camera3D] would be placed close to the point of collision. </member> - <member name="shape" type="Shape" setter="set_shape" getter="get_shape"> - The [Shape] to use for the SpringArm. - When the shape is set, the SpringArm will cast the [Shape] on its z axis instead of performing a ray cast. + <member name="shape" type="Shape3D" setter="set_shape" getter="get_shape"> + The [Shape3D] to use for the SpringArm3D. + When the shape is set, the SpringArm3D will cast the [Shape3D] on its z axis instead of performing a ray cast. </member> <member name="spring_length" type="float" setter="set_length" getter="get_length" default="1.0"> - The maximum extent of the SpringArm. This is used as a length for both the ray and the shape cast used internally to calculate the desired position of the SpringArm's child nodes. - To know more about how to perform a shape cast or a ray cast, please consult the [PhysicsDirectSpaceState] documentation. + The maximum extent of the SpringArm3D. This is used as a length for both the ray and the shape cast used internally to calculate the desired position of the SpringArm3D's child nodes. + To know more about how to perform a shape cast or a ray cast, please consult the [PhysicsDirectSpaceState3D] documentation. </member> </members> <constants> diff --git a/doc/classes/Sprite.xml b/doc/classes/Sprite2D.xml index 6c21881535..950fda4e20 100644 --- a/doc/classes/Sprite.xml +++ b/doc/classes/Sprite2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Sprite" inherits="Node2D" version="4.0"> +<class name="Sprite2D" inherits="Node2D" version="4.0"> <brief_description> General-purpose sprite node. </brief_description> @@ -13,7 +13,7 @@ <return type="Rect2"> </return> <description> - Returns a [Rect2] representing the Sprite's boundary in local coordinates. Can be used to detect if the Sprite was clicked. Example: + Returns a [Rect2] representing the Sprite2D's boundary in local coordinates. Can be used to detect if the Sprite2D was clicked. Example: [codeblock] func _input(event): if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT: @@ -53,7 +53,7 @@ The number of columns in the sprite sheet. </member> <member name="normal_map" type="Texture2D" setter="set_normal_map" getter="get_normal_map"> - The normal map gives depth to the Sprite. + The normal map gives depth to the Sprite2D. </member> <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> The texture's drawing offset. @@ -68,7 +68,7 @@ The region of the atlas texture to display. [member region_enabled] must be [code]true[/code]. </member> <member name="shininess" type="float" setter="set_shininess" getter="get_shininess" default="1.0"> - Strength of the specular light effect of this [Sprite]. + Strength of the specular light effect of this [Sprite2D]. </member> <member name="specular_color" type="Color" setter="set_specular_color" getter="get_specular_color" default="Color( 1, 1, 1, 1 )"> The color of the specular light effect. diff --git a/doc/classes/Sprite3D.xml b/doc/classes/Sprite3D.xml index 63958eeb7b..f59d5130c9 100644 --- a/doc/classes/Sprite3D.xml +++ b/doc/classes/Sprite3D.xml @@ -5,7 +5,7 @@ </brief_description> <description> A node that displays a 2D texture in a 3D environment. The texture displayed can be a region from a larger atlas texture, or a frame from a sprite sheet animation. - [b]Note:[/b] There are [url=https://github.com/godotengine/godot/issues/20855]known performance issues[/url] when using [Sprite3D]. Consider using a [MeshInstance] with a [QuadMesh] as the mesh instead. You can still have billboarding by enabling billboard properties in the QuadMesh's [StandardMaterial3D]. + [b]Note:[/b] There are [url=https://github.com/godotengine/godot/issues/20855]known performance issues[/url] when using [Sprite3D]. Consider using a [MeshInstance3D] with a [QuadMesh] as the mesh instead. You can still have billboarding by enabling billboard properties in the QuadMesh's [StandardMaterial3D]. </description> <tutorials> </tutorials> diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index 563a17e8f6..479dc5f94c 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpriteBase3D" inherits="GeometryInstance" version="4.0"> +<class name="SpriteBase3D" inherits="GeometryInstance3D" version="4.0"> <brief_description> 2D sprite node in 3D environment. </brief_description> @@ -76,7 +76,7 @@ The size of one pixel's width on the sprite to scale it in 3D. </member> <member name="shaded" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false"> - If [code]true[/code], the [Light] in the [Environment] has effects on the sprite. + If [code]true[/code], the [Light3D] in the [Environment] has effects on the sprite. </member> <member name="transparent" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="true"> If [code]true[/code], the texture's transparency and the opacity are used to make those parts of the sprite invisible. diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index 9facdde681..6e1e1688f4 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="SpriteFrames" inherits="Resource" version="4.0"> <brief_description> - Sprite frame library for AnimatedSprite. + Sprite frame library for AnimatedSprite2D. </brief_description> <description> - Sprite frame library for [AnimatedSprite]. Contains frames and animation data for playback. + Sprite frame library for [AnimatedSprite2D]. Contains frames and animation data for playback. </description> <tutorials> </tutorials> diff --git a/doc/classes/StaticBody.xml b/doc/classes/StaticBody3D.xml index 280b95d182..c896efc314 100644 --- a/doc/classes/StaticBody.xml +++ b/doc/classes/StaticBody3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StaticBody" inherits="PhysicsBody" version="4.0"> +<class name="StaticBody3D" inherits="PhysicsBody3D" version="4.0"> <brief_description> Static body for 3D physics. </brief_description> <description> - Static body for 3D physics. A static body is a simple body that is not intended to move. In contrast to [RigidBody], they don't consume any CPU resources as long as they don't move. + Static body for 3D physics. A static body is a simple body that is not intended to move. In contrast to [RigidBody3D], they don't consume any CPU resources as long as they don't move. Additionally, a constant linear or angular velocity can be set for the static body, so even if it doesn't move, it affects other bodies as if it was moving (this is useful for simulating conveyor belts or conveyor wheels). </description> <tutorials> diff --git a/doc/classes/SubViewport.xml b/doc/classes/SubViewport.xml new file mode 100644 index 0000000000..561e5d1a15 --- /dev/null +++ b/doc/classes/SubViewport.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SubViewport" inherits="Viewport" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="set_size"> + <return type="void"> + </return> + <argument index="0" name="size" type="Vector2i"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="arvr" type="bool" setter="set_use_arvr" getter="is_using_arvr" default="false"> + </member> + <member name="render_target_clear_mode" type="int" setter="set_clear_mode" getter="get_clear_mode" enum="SubViewport.ClearMode" default="0"> + </member> + <member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="SubViewport.UpdateMode" default="2"> + </member> + </members> + <constants> + <constant name="UPDATE_DISABLED" value="0" enum="UpdateMode"> + </constant> + <constant name="UPDATE_ONCE" value="1" enum="UpdateMode"> + </constant> + <constant name="UPDATE_WHEN_VISIBLE" value="2" enum="UpdateMode"> + </constant> + <constant name="UPDATE_WHEN_PARENT_VISIBLE" value="3" enum="UpdateMode"> + </constant> + <constant name="UPDATE_ALWAYS" value="4" enum="UpdateMode"> + </constant> + <constant name="CLEAR_MODE_ALWAYS" value="0" enum="ClearMode"> + </constant> + <constant name="CLEAR_MODE_NEVER" value="1" enum="ClearMode"> + </constant> + <constant name="CLEAR_MODE_ONLY_NEXT_FRAME" value="2" enum="ClearMode"> + </constant> + </constants> +</class> diff --git a/doc/classes/SubViewportContainer.xml b/doc/classes/SubViewportContainer.xml new file mode 100644 index 0000000000..e6a0bd4866 --- /dev/null +++ b/doc/classes/SubViewportContainer.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SubViewportContainer" inherits="Container" version="4.0"> + <brief_description> + Control for holding [SubViewport]s. + </brief_description> + <description> + A [Container] node that holds a [SubViewport], automatically setting its size. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <members> + <member name="stretch" type="bool" setter="set_stretch" getter="is_stretch_enabled" default="false"> + If [code]true[/code], the sub-viewport will be scaled to the control's size. + </member> + <member name="stretch_shrink" type="int" setter="set_stretch_shrink" getter="get_stretch_shrink" default="1"> + Divides the sub-viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering. + For example, a 1280×720 sub-viewport with [member stretch_shrink] set to [code]2[/code] will be rendered at 640×360 while occupying the same size in the container. + [b]Note:[/b] [member stretch] must be [code]true[/code] for this property to work. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/Texture2D.xml b/doc/classes/Texture2D.xml index 63cdb0d90a..ffe806cef7 100644 --- a/doc/classes/Texture2D.xml +++ b/doc/classes/Texture2D.xml @@ -4,7 +4,7 @@ Texture for 2D and 3D. </brief_description> <description> - A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D [Sprite] or GUI [Control]. + A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D [Sprite2D] or GUI [Control]. Textures are often created by loading them from a file. See [method @GDScript.load]. [Texture2D] is a base for other resources. It cannot be used directly. </description> @@ -28,12 +28,12 @@ </argument> <argument index="6" name="specular_color_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> - <argument index="7" name="texture_filter" type="int" enum="VisualServer.CanvasItemTextureFilter" default="0"> + <argument index="7" name="texture_filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" default="0"> </argument> - <argument index="8" name="texture_repeat" type="int" enum="VisualServer.CanvasItemTextureRepeat" default="0"> + <argument index="8" name="texture_repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" default="0"> </argument> <description> - Draws the texture using a [CanvasItem] with the [VisualServer] API at the specified [code]position[/code]. + Draws the texture using a [CanvasItem] with the [RenderingServer] API at the specified [code]position[/code]. </description> </method> <method name="draw_rect" qualifiers="const"> @@ -55,12 +55,12 @@ </argument> <argument index="7" name="specular_color_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> - <argument index="8" name="texture_filter" type="int" enum="VisualServer.CanvasItemTextureFilter" default="0"> + <argument index="8" name="texture_filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" default="0"> </argument> - <argument index="9" name="texture_repeat" type="int" enum="VisualServer.CanvasItemTextureRepeat" default="0"> + <argument index="9" name="texture_repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" default="0"> </argument> <description> - Draws the texture using a [CanvasItem] with the [VisualServer] API. + Draws the texture using a [CanvasItem] with the [RenderingServer] API. </description> </method> <method name="draw_rect_region" qualifiers="const"> @@ -82,14 +82,14 @@ </argument> <argument index="7" name="specular_color_shininess" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> - <argument index="8" name="texture_filter" type="int" enum="VisualServer.CanvasItemTextureFilter" default="0"> + <argument index="8" name="texture_filter" type="int" enum="RenderingServer.CanvasItemTextureFilter" default="0"> </argument> - <argument index="9" name="texture_repeat" type="int" enum="VisualServer.CanvasItemTextureRepeat" default="0"> + <argument index="9" name="texture_repeat" type="int" enum="RenderingServer.CanvasItemTextureRepeat" default="0"> </argument> <argument index="10" name="clip_uv" type="bool" default="true"> </argument> <description> - Draws a part of the texture using a [CanvasItem] with the [VisualServer] API. + Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API. </description> </method> <method name="get_data" qualifiers="const"> diff --git a/doc/classes/Thread.xml b/doc/classes/Thread.xml index 3bb5797df5..4d6e89fa6f 100644 --- a/doc/classes/Thread.xml +++ b/doc/classes/Thread.xml @@ -36,7 +36,7 @@ <argument index="3" name="priority" type="int" enum="Thread.Priority" default="1"> </argument> <description> - Starts a new [Thread] that runs [code]method[/code] on object [code]instance[/code] with [code]userdata[/code] passed as an argument. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum. + Starts a new [Thread] that runs [code]method[/code] on object [code]instance[/code] with [code]userdata[/code] passed as an argument. Even if no userdata is passed, [code]method[/code] must accept one argument and it will be null. The [code]priority[/code] of the [Thread] can be changed by passing a value from the [enum Priority] enum. Returns [constant OK] on success, or [constant ERR_CANT_CREATE] on failure. </description> </method> diff --git a/doc/classes/VehicleBody.xml b/doc/classes/VehicleBody3D.xml index 74879419a1..b8b85ff605 100644 --- a/doc/classes/VehicleBody.xml +++ b/doc/classes/VehicleBody3D.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VehicleBody" inherits="RigidBody" version="4.0"> +<class name="VehicleBody3D" inherits="RigidBody3D" version="4.0"> <brief_description> Physics body that simulates the behavior of a car. </brief_description> <description> - This node implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. You will need to add a [CollisionShape] for the main body of your vehicle and add [VehicleWheel] nodes for the wheels. You should also add a [MeshInstance] to this node for the 3D model of your car but this model should not include meshes for the wheels. You should control the vehicle by using the [member brake], [member engine_force], and [member steering] properties and not change the position or orientation of this node directly. - [b]Note:[/b] The origin point of your VehicleBody will determine the center of gravity of your vehicle so it is better to keep this low and move the [CollisionShape] and [MeshInstance] upwards. + This node implements all the physics logic needed to simulate a car. It is based on the raycast vehicle system commonly found in physics engines. You will need to add a [CollisionShape3D] for the main body of your vehicle and add [VehicleWheel3D] nodes for the wheels. You should also add a [MeshInstance3D] to this node for the 3D model of your car but this model should not include meshes for the wheels. You should control the vehicle by using the [member brake], [member engine_force], and [member steering] properties and not change the position or orientation of this node directly. + [b]Note:[/b] The origin point of your VehicleBody3D will determine the center of gravity of your vehicle so it is better to keep this low and move the [CollisionShape3D] and [MeshInstance3D] upwards. </description> <tutorials> </tutorials> @@ -13,16 +13,16 @@ </methods> <members> <member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0"> - Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. + Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody3D.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. </member> <member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0"> - Accelerates the vehicle by applying an engine force. The vehicle is only speed up if the wheels that have [member VehicleWheel.use_as_traction] set to [code]true[/code] and are in contact with a surface. The [member RigidBody.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. + Accelerates the vehicle by applying an engine force. The vehicle is only speed up if the wheels that have [member VehicleWheel3D.use_as_traction] set to [code]true[/code] and are in contact with a surface. The [member RigidBody3D.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. [b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. A negative value will result in the vehicle reversing. </member> <member name="mass" type="float" setter="set_mass" getter="get_mass" override="true" default="40.0" /> <member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0"> - The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have [member VehicleWheel.use_as_steering] set to [code]true[/code] will automatically be rotated. + The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have [member VehicleWheel3D.use_as_steering] set to [code]true[/code] will automatically be rotated. </member> <member name="weight" type="float" setter="set_weight" getter="get_weight" override="true" default="392.0" /> </members> diff --git a/doc/classes/VehicleWheel.xml b/doc/classes/VehicleWheel3D.xml index 1a6a226fd1..c71d797eff 100644 --- a/doc/classes/VehicleWheel.xml +++ b/doc/classes/VehicleWheel3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VehicleWheel" inherits="Spatial" version="4.0"> +<class name="VehicleWheel3D" inherits="Node3D" version="4.0"> <brief_description> Physics object that simulates the behavior of a wheel. </brief_description> <description> - This node needs to be used as a child node of [VehicleBody] and simulates the behavior of one of its wheels. This node also acts as a collider to detect if the wheel is touching a surface. + This node needs to be used as a child node of [VehicleBody3D] and simulates the behavior of one of its wheels. This node also acts as a collider to detect if the wheel is touching a surface. </description> <tutorials> </tutorials> @@ -33,7 +33,7 @@ </methods> <members> <member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0"> - Slows down the wheel by applying a braking force. The wheel is only slowed down if it is in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. + Slows down the wheel by applying a braking force. The wheel is only slowed down if it is in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody3D.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. </member> <member name="damping_compression" type="float" setter="set_damping_compression" getter="get_damping_compression" default="0.83"> The damping applied to the spring when the spring is being compressed. This value should be between 0.0 (no damping) and 1.0. A value of 0.0 means the car will keep bouncing as the spring keeps its energy. A good value for this is around 0.3 for a normal car, 0.5 for a race car. @@ -42,7 +42,7 @@ The damping applied to the spring when relaxing. This value should be between 0.0 (no damping) and 1.0. This value should always be slightly higher than the [member damping_compression] property. For a [member damping_compression] value of 0.3, try a relaxation value of 0.5. </member> <member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0"> - Accelerates the wheel by applying an engine force. The wheel is only speed up if it is in contact with a surface. The [member RigidBody.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. + Accelerates the wheel by applying an engine force. The wheel is only speed up if it is in contact with a surface. The [member RigidBody3D.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. [b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. A negative value will result in the wheel reversing. </member> @@ -50,7 +50,7 @@ The steering angle for the wheel. Setting this to a non-zero value will result in the vehicle turning when it's moving. </member> <member name="suspension_max_force" type="float" setter="set_suspension_max_force" getter="get_suspension_max_force" default="6000.0"> - The maximum force the spring can resist. This value should be higher than a quarter of the [member RigidBody.mass] of the [VehicleBody] or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number. + The maximum force the spring can resist. This value should be higher than a quarter of the [member RigidBody3D.mass] of the [VehicleBody3D] or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number. </member> <member name="suspension_stiffness" type="float" setter="set_suspension_stiffness" getter="get_suspension_stiffness" default="5.88"> This value defines the stiffness of the suspension. Use a value lower than 50 for an off-road car, a value between 50 and 100 for a race car and try something around 200 for something like a Formula 1 car. @@ -59,10 +59,10 @@ This is the distance the suspension can travel. As Godot units are equivalent to meters, keep this setting relatively low. Try a value between 0.1 and 0.3 depending on the type of car. </member> <member name="use_as_steering" type="bool" setter="set_use_as_steering" getter="is_used_as_steering" default="false"> - If [code]true[/code], this wheel will be turned when the car steers. This value is used in conjunction with [member VehicleBody.steering] and ignored if you are using the per-wheel [member steering] value instead. + If [code]true[/code], this wheel will be turned when the car steers. This value is used in conjunction with [member VehicleBody3D.steering] and ignored if you are using the per-wheel [member steering] value instead. </member> <member name="use_as_traction" type="bool" setter="set_use_as_traction" getter="is_used_as_traction" default="false"> - If [code]true[/code], this wheel transfers engine force to the ground to propel the vehicle forward. This value is used in conjunction with [member VehicleBody.engine_force] and ignored if you are using the per-wheel [member engine_force] value instead. + If [code]true[/code], this wheel transfers engine force to the ground to propel the vehicle forward. This value is used in conjunction with [member VehicleBody3D.engine_force] and ignored if you are using the per-wheel [member engine_force] value instead. </member> <member name="wheel_friction_slip" type="float" setter="set_friction_slip" getter="get_friction_slip" default="10.5"> This determines how much grip this wheel has. It is combined with the friction setting of the surface the wheel is in contact with. 0.0 means no grip, 1.0 is normal grip. For a drift car setup, try setting the grip of the rear wheels slightly lower than the front wheels, or use a lower value to simulate tire wear. diff --git a/doc/classes/SpatialVelocityTracker.xml b/doc/classes/VelocityTracker3D.xml index 7a4e0c054a..98f7533c76 100644 --- a/doc/classes/SpatialVelocityTracker.xml +++ b/doc/classes/VelocityTracker3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpatialVelocityTracker" inherits="Reference" version="4.0"> +<class name="VelocityTracker3D" inherits="Reference" version="4.0"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 0632be28e1..5826822c6e 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -4,9 +4,9 @@ Creates a sub-view into the screen. </brief_description> <description> - A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera 3D nodes will render on it too. + A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera3D 3D nodes will render on it too. Optionally, a viewport can have its own 2D or 3D world, so they don't share what they draw with other viewports. - If a viewport is a child of a [ViewportContainer], it will automatically take up its size, otherwise it must be set manually. + If a viewport is a child of a [SubViewportContainer], it will automatically take up its size, otherwise it must be set manually. Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it. Also, viewports can be assigned to different screens in case the devices have multiple screens. Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw. @@ -17,7 +17,7 @@ </tutorials> <methods> <method name="find_world" qualifiers="const"> - <return type="World"> + <return type="World3D"> </return> <description> Returns the 3D world of the viewport, or if none the world of the parent viewport. @@ -31,7 +31,7 @@ </description> </method> <method name="get_camera" qualifiers="const"> - <return type="Camera"> + <return type="Camera3D"> </return> <description> Returns the active 3D camera. @@ -44,13 +44,6 @@ Returns the total transform of the viewport. </description> </method> - <method name="get_modal_stack_top" qualifiers="const"> - <return type="Control"> - </return> - <description> - Returns the topmost modal in the stack. - </description> - </method> <method name="get_mouse_position" qualifiers="const"> <return type="Vector2"> </return> @@ -76,13 +69,6 @@ Returns the [enum ShadowAtlasQuadrantSubdiv] of the specified quadrant. </description> </method> - <method name="get_size_override" qualifiers="const"> - <return type="Vector2"> - </return> - <description> - Returns the size override set with [method set_size_override]. - </description> - </method> <method name="get_texture" qualifiers="const"> <return type="ViewportTexture"> </return> @@ -99,7 +85,7 @@ <return type="RID"> </return> <description> - Returns the viewport's RID from the [VisualServer]. + Returns the viewport's RID from the [RenderingServer]. </description> </method> <method name="get_visible_rect" qualifiers="const"> @@ -116,13 +102,6 @@ Returns the drag data from the GUI, that was previously returned by [method Control.get_drag_data]. </description> </method> - <method name="gui_has_modal_stack" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns [code]true[/code] if there are visible modals on-screen. - </description> - </method> <method name="gui_is_dragging" qualifiers="const"> <return type="bool"> </return> @@ -133,31 +112,31 @@ <method name="input"> <return type="void"> </return> - <argument index="0" name="local_event" type="InputEvent"> + <argument index="0" name="event" type="InputEvent"> + </argument> + <argument index="1" name="in_local_coords" type="bool" default="false"> </argument> <description> </description> </method> - <method name="is_input_handled" qualifiers="const"> - <return type="bool"> + <method name="input_text"> + <return type="void"> </return> + <argument index="0" name="text" type="String"> + </argument> <description> </description> </method> - <method name="is_size_override_enabled" qualifiers="const"> + <method name="is_embedding_subwindows" qualifiers="const"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the size override is enabled. See [method set_size_override]. </description> </method> - <method name="set_attach_to_screen_rect"> - <return type="void"> + <method name="is_input_handled" qualifiers="const"> + <return type="bool"> </return> - <argument index="0" name="rect" type="Rect2"> - </argument> <description> - Attaches this [Viewport] to the root [Viewport] with the specified rectangle. This bypasses the need for another node to display this [Viewport] but makes you responsible for updating the position of this [Viewport] manually. </description> </method> <method name="set_input_as_handled"> @@ -178,23 +157,12 @@ Sets the number of subdivisions to use in the specified quadrant. A higher number of subdivisions allows you to have more shadows in the scene at once, but reduces the quality of the shadows. A good practice is to have quadrants with a varying number of subdivisions and to have as few subdivisions as possible. </description> </method> - <method name="set_size_override"> - <return type="void"> - </return> - <argument index="0" name="enable" type="bool"> - </argument> - <argument index="1" name="size" type="Vector2" default="Vector2( -1, -1 )"> - </argument> - <argument index="2" name="margin" type="Vector2" default="Vector2( 0, 0 )"> - </argument> - <description> - Sets the size override of the viewport. If the [code]enable[/code] parameter is [code]true[/code] the override is used, otherwise it uses the default size. If the size parameter is [code](-1, -1)[/code], it won't update the size. - </description> - </method> <method name="unhandled_input"> <return type="void"> </return> - <argument index="0" name="local_event" type="InputEvent"> + <argument index="0" name="event" type="InputEvent"> + </argument> + <argument index="1" name="in_local_coords" type="bool" default="false"> </argument> <description> </description> @@ -217,9 +185,6 @@ </method> </methods> <members> - <member name="arvr" type="bool" setter="set_use_arvr" getter="use_arvr" default="false"> - If [code]true[/code], the viewport will be used in AR/VR process. - </member> <member name="audio_listener_enable_2d" type="bool" setter="set_as_audio_listener_2d" getter="is_audio_listener_2d" default="false"> If [code]true[/code], the viewport will process 2D audio streams. </member> @@ -242,6 +207,8 @@ <member name="gui_disable_input" type="bool" setter="set_disable_input" getter="is_input_disabled" default="false"> If [code]true[/code], the viewport will not receive input event. </member> + <member name="gui_embed_subwindows" type="bool" setter="set_embed_subwindows_hint" getter="get_embed_subwindows_hint" default="false"> + </member> <member name="gui_snap_controls_to_pixels" type="bool" setter="set_snap_controls_to_pixels" getter="is_snap_controls_to_pixels_enabled" default="true"> If [code]true[/code], the GUI controls on the viewport will lay pixel perfectly. </member> @@ -251,20 +218,11 @@ The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 4 is best unless targeting very high-end systems. </member> <member name="own_world" type="bool" setter="set_use_own_world" getter="is_using_own_world" default="false"> - If [code]true[/code], the viewport will use [World] defined in [code]world[/code] property. + If [code]true[/code], the viewport will use [World3D] defined in [code]world[/code] property. </member> <member name="physics_object_picking" type="bool" setter="set_physics_object_picking" getter="get_physics_object_picking" default="false"> If [code]true[/code], the objects rendered by viewport become subjects of mouse picking process. </member> - <member name="render_direct_to_screen" type="bool" setter="set_use_render_direct_to_screen" getter="is_using_render_direct_to_screen" default="false"> - If [code]true[/code], renders the Viewport directly to the screen instead of to the root viewport. Only available in GLES2. This is a low-level optimization and should not be used in most cases. If used, reading from the Viewport or from [code]SCREEN_TEXTURE[/code] becomes unavailable. For more information see [method VisualServer.viewport_set_render_direct_to_screen]. - </member> - <member name="render_target_clear_mode" type="int" setter="set_clear_mode" getter="get_clear_mode" enum="Viewport.ClearMode" default="0"> - The clear mode when viewport used as a render target. - </member> - <member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="Viewport.UpdateMode" default="2"> - The update mode when viewport used as a render target. - </member> <member name="shadow_atlas_quad_0" type="int" setter="set_shadow_atlas_quadrant_subdiv" getter="get_shadow_atlas_quadrant_subdiv" enum="Viewport.ShadowAtlasQuadrantSubdiv" default="2"> The subdivision amount of the first quadrant on the shadow atlas. </member> @@ -281,17 +239,11 @@ The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2. [b]Note:[/b] If this is set to 0, shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually. </member> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 0, 0 )"> - The width and height of viewport. - </member> - <member name="size_override_stretch" type="bool" setter="set_size_override_stretch" getter="is_size_override_stretch_enabled" default="false"> - If [code]true[/code], the size override affects stretch as well. - </member> <member name="transparent_bg" type="bool" setter="set_transparent_background" getter="has_transparent_background" default="false"> If [code]true[/code], the viewport should render its background as transparent. </member> - <member name="world" type="World" setter="set_world" getter="get_world"> - The custom [World] which can be used as 3D environment source. + <member name="world" type="World3D" setter="set_world" getter="get_world"> + The custom [World3D] which can be used as 3D environment source. </member> <member name="world_2d" type="World2D" setter="set_world_2d" getter="get_world_2d"> The custom [World2D] which can be used as 2D environment source. @@ -307,23 +259,11 @@ </signal> <signal name="size_changed"> <description> - Emitted when the size of the viewport is changed, whether by [method set_size_override], resize of window, or some other means. + Emitted when the size of the viewport is changed, whether by resizing of window, or some other means. </description> </signal> </signals> <constants> - <constant name="UPDATE_DISABLED" value="0" enum="UpdateMode"> - Do not update the render target. - </constant> - <constant name="UPDATE_ONCE" value="1" enum="UpdateMode"> - Update the render target once, then switch to [constant UPDATE_DISABLED]. - </constant> - <constant name="UPDATE_WHEN_VISIBLE" value="2" enum="UpdateMode"> - Update the render target only when it is visible. This is the default value. - </constant> - <constant name="UPDATE_ALWAYS" value="3" enum="UpdateMode"> - Always update the render target. - </constant> <constant name="SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED" value="0" enum="ShadowAtlasQuadrantSubdiv"> This quadrant will not be used. </constant> @@ -410,15 +350,6 @@ <constant name="MSAA_16X" value="4" enum="MSAA"> Use 16x Multisample Antialiasing. Likely unsupported on medium and low-end hardware. </constant> - <constant name="CLEAR_MODE_ALWAYS" value="0" enum="ClearMode"> - Always clear the render target before drawing. - </constant> - <constant name="CLEAR_MODE_NEVER" value="1" enum="ClearMode"> - Never clear the render target. - </constant> - <constant name="CLEAR_MODE_ONLY_NEXT_FRAME" value="2" enum="ClearMode"> - Clear the render target next frame, then switch to [constant CLEAR_MODE_NEVER]. - </constant> <constant name="DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST" value="0" enum="DefaultCanvasItemTextureFilter"> </constant> <constant name="DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR" value="1" enum="DefaultCanvasItemTextureFilter"> diff --git a/doc/classes/ViewportContainer.xml b/doc/classes/ViewportContainer.xml deleted file mode 100644 index d2fbb85305..0000000000 --- a/doc/classes/ViewportContainer.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="ViewportContainer" inherits="Container" version="4.0"> - <brief_description> - Control for holding [Viewport]s. - </brief_description> - <description> - A [Container] node that holds a [Viewport], automatically setting its size. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <members> - <member name="stretch" type="bool" setter="set_stretch" getter="is_stretch_enabled" default="false"> - If [code]true[/code], the viewport will be scaled to the control's size. - </member> - <member name="stretch_shrink" type="int" setter="set_stretch_shrink" getter="get_stretch_shrink" default="1"> - Divides the viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering. - For example, a 1280×720 viewport with [member stretch_shrink] set to [code]2[/code] will be rendered at 640×360 while occupying the same size in the container. - [b]Note:[/b] [member stretch] must be [code]true[/code] for this property to work. - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml index 3f9bf6887a..0bdecafbfa 100644 --- a/doc/classes/VisibilityEnabler2D.xml +++ b/doc/classes/VisibilityEnabler2D.xml @@ -36,13 +36,13 @@ If [code]true[/code], [RigidBody2D] nodes will be paused. </member> <member name="pause_animated_sprites" type="bool" setter="set_enabler" getter="is_enabler_enabled" default="true"> - If [code]true[/code], [AnimatedSprite] nodes will be paused. + If [code]true[/code], [AnimatedSprite2D] nodes will be paused. </member> <member name="pause_animations" type="bool" setter="set_enabler" getter="is_enabler_enabled" default="true"> If [code]true[/code], [AnimationPlayer] nodes will be paused. </member> <member name="pause_particles" type="bool" setter="set_enabler" getter="is_enabler_enabled" default="true"> - If [code]true[/code], [Particles2D] nodes will be paused. + If [code]true[/code], [GPUParticles2D] nodes will be paused. </member> <member name="physics_process_parent" type="bool" setter="set_enabler" getter="is_enabler_enabled" default="false"> If [code]true[/code], the parent's [method Node._physics_process] will be stopped. @@ -59,7 +59,7 @@ This enabler will freeze [RigidBody2D] nodes. </constant> <constant name="ENABLER_PAUSE_PARTICLES" value="2" enum="Enabler"> - This enabler will stop [Particles2D] nodes. + This enabler will stop [GPUParticles2D] nodes. </constant> <constant name="ENABLER_PARENT_PROCESS" value="3" enum="Enabler"> This enabler will stop the parent's _process function. @@ -68,7 +68,7 @@ This enabler will stop the parent's _physics_process function. </constant> <constant name="ENABLER_PAUSE_ANIMATED_SPRITES" value="5" enum="Enabler"> - This enabler will stop [AnimatedSprite] nodes animations. + This enabler will stop [AnimatedSprite2D] nodes animations. </constant> <constant name="ENABLER_MAX" value="6" enum="Enabler"> Represents the size of the [enum Enabler] enum. diff --git a/doc/classes/VisibilityEnabler.xml b/doc/classes/VisibilityEnabler3D.xml index 7ab6c52e6c..9c25c6c7c8 100644 --- a/doc/classes/VisibilityEnabler.xml +++ b/doc/classes/VisibilityEnabler3D.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisibilityEnabler" inherits="VisibilityNotifier" version="4.0"> +<class name="VisibilityEnabler3D" inherits="VisibilityNotifier3D" version="4.0"> <brief_description> Enables certain nodes only when visible. </brief_description> <description> - The VisibilityEnabler will disable [RigidBody] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler itself. - Note that VisibilityEnabler will not affect nodes added after scene initialization. + The VisibilityEnabler3D will disable [RigidBody3D] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler3D itself. + Note that VisibilityEnabler3D will not affect nodes added after scene initialization. </description> <tutorials> </tutorials> @@ -13,7 +13,7 @@ <method name="is_enabler_enabled" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="enabler" type="int" enum="VisibilityEnabler.Enabler"> + <argument index="0" name="enabler" type="int" enum="VisibilityEnabler3D.Enabler"> </argument> <description> Returns whether the enabler identified by given [enum Enabler] constant is active. @@ -22,7 +22,7 @@ <method name="set_enabler"> <return type="void"> </return> - <argument index="0" name="enabler" type="int" enum="VisibilityEnabler.Enabler"> + <argument index="0" name="enabler" type="int" enum="VisibilityEnabler3D.Enabler"> </argument> <argument index="1" name="enabled" type="bool"> </argument> @@ -33,7 +33,7 @@ </methods> <members> <member name="freeze_bodies" type="bool" setter="set_enabler" getter="is_enabler_enabled" default="true"> - If [code]true[/code], [RigidBody] nodes will be paused. + If [code]true[/code], [RigidBody3D] nodes will be paused. </member> <member name="pause_animations" type="bool" setter="set_enabler" getter="is_enabler_enabled" default="true"> If [code]true[/code], [AnimationPlayer] nodes will be paused. @@ -44,7 +44,7 @@ This enabler will pause [AnimationPlayer] nodes. </constant> <constant name="ENABLER_FREEZE_BODIES" value="1" enum="Enabler"> - This enabler will freeze [RigidBody] nodes. + This enabler will freeze [RigidBody3D] nodes. </constant> <constant name="ENABLER_MAX" value="2" enum="Enabler"> Represents the size of the [enum Enabler] enum. diff --git a/doc/classes/VisibilityNotifier.xml b/doc/classes/VisibilityNotifier3D.xml index 6161017884..d8a605c69c 100644 --- a/doc/classes/VisibilityNotifier.xml +++ b/doc/classes/VisibilityNotifier3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisibilityNotifier" inherits="Spatial" version="4.0"> +<class name="VisibilityNotifier3D" inherits="Node3D" version="4.0"> <brief_description> Detects when the node is visible on screen. </brief_description> <description> - The VisibilityNotifier detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a [Camera]'s view. + The VisibilityNotifier3D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a [Camera3D]'s view. </description> <tutorials> </tutorials> @@ -20,32 +20,32 @@ </methods> <members> <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB( -1, -1, -1, 2, 2, 2 )"> - The VisibilityNotifier's bounding box. + The VisibilityNotifier3D's bounding box. </member> </members> <signals> <signal name="camera_entered"> - <argument index="0" name="camera" type="Camera"> + <argument index="0" name="camera" type="Camera3D"> </argument> <description> - Emitted when the VisibilityNotifier enters a [Camera]'s view. + Emitted when the VisibilityNotifier3D enters a [Camera3D]'s view. </description> </signal> <signal name="camera_exited"> - <argument index="0" name="camera" type="Camera"> + <argument index="0" name="camera" type="Camera3D"> </argument> <description> - Emitted when the VisibilityNotifier exits a [Camera]'s view. + Emitted when the VisibilityNotifier3D exits a [Camera3D]'s view. </description> </signal> <signal name="screen_entered"> <description> - Emitted when the VisibilityNotifier enters the screen. + Emitted when the VisibilityNotifier3D enters the screen. </description> </signal> <signal name="screen_exited"> <description> - Emitted when the VisibilityNotifier exits the screen. + Emitted when the VisibilityNotifier3D exits the screen. </description> </signal> </signals> diff --git a/doc/classes/VisualInstance.xml b/doc/classes/VisualInstance3D.xml index 1bbd5cb64d..6451b3f330 100644 --- a/doc/classes/VisualInstance.xml +++ b/doc/classes/VisualInstance3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualInstance" inherits="Spatial" version="4.0"> +<class name="VisualInstance3D" inherits="Node3D" version="4.0"> <brief_description> Parent of all visual 3D nodes. </brief_description> <description> - The [VisualInstance] is used to connect a resource to a visual representation. All visual 3D nodes inherit from the [VisualInstance]. In general, you should not access the [VisualInstance] properties directly as they are accessed and managed by the nodes that inherit from [VisualInstance]. [VisualInstance] is the node representation of the [VisualServer] instance. + The [VisualInstance3D] is used to connect a resource to a visual representation. All visual 3D nodes inherit from the [VisualInstance3D]. In general, you should not access the [VisualInstance3D] properties directly as they are accessed and managed by the nodes that inherit from [VisualInstance3D]. [VisualInstance3D] is the node representation of the [RenderingServer] instance. </description> <tutorials> </tutorials> @@ -13,21 +13,21 @@ <return type="AABB"> </return> <description> - Returns the [AABB] (also known as the bounding box) for this [VisualInstance]. + Returns the [AABB] (also known as the bounding box) for this [VisualInstance3D]. </description> </method> <method name="get_base" qualifiers="const"> <return type="RID"> </return> <description> - Returns the RID of the resource associated with this [VisualInstance]. For example, if the Node is a [MeshInstance], this will return the RID of the associated [Mesh]. + Returns the RID of the resource associated with this [VisualInstance3D]. For example, if the Node is a [MeshInstance3D], this will return the RID of the associated [Mesh]. </description> </method> <method name="get_instance" qualifiers="const"> <return type="RID"> </return> <description> - Returns the RID of this instance. This RID is the same as the RID returned by [method VisualServer.instance_create]. This RID is needed if you want to call [VisualServer] functions directly on this [VisualInstance]. + Returns the RID of this instance. This RID is the same as the RID returned by [method RenderingServer.instance_create]. This RID is needed if you want to call [RenderingServer] functions directly on this [VisualInstance3D]. </description> </method> <method name="get_layer_mask_bit" qualifiers="const"> @@ -43,8 +43,8 @@ <return type="AABB"> </return> <description> - Returns the transformed [AABB] (also known as the bounding box) for this [VisualInstance]. - Transformed in this case means the [AABB] plus the position, rotation, and scale of the [Spatial]'s [Transform]. + Returns the transformed [AABB] (also known as the bounding box) for this [VisualInstance3D]. + Transformed in this case means the [AABB] plus the position, rotation, and scale of the [Node3D]'s [Transform]. </description> </method> <method name="set_base"> @@ -53,7 +53,7 @@ <argument index="0" name="base" type="RID"> </argument> <description> - Sets the resource that is instantiated by this [VisualInstance], which changes how the engine handles the [VisualInstance] under the hood. Equivalent to [method VisualServer.instance_set_base]. + Sets the resource that is instantiated by this [VisualInstance3D], which changes how the engine handles the [VisualInstance3D] under the hood. Equivalent to [method RenderingServer.instance_set_base]. </description> </method> <method name="set_layer_mask_bit"> @@ -70,8 +70,8 @@ </methods> <members> <member name="layers" type="int" setter="set_layer_mask" getter="get_layer_mask" default="1"> - The render layer(s) this [VisualInstance] is drawn on. - This object will only be visible for [Camera]s whose cull mask includes the render object this [VisualInstance] is set to. + The render layer(s) this [VisualInstance3D] is drawn on. + This object will only be visible for [Camera3D]s whose cull mask includes the render object this [VisualInstance3D] is set to. </member> </members> <constants> diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml new file mode 100644 index 0000000000..e1a0f1f22a --- /dev/null +++ b/doc/classes/Window.xml @@ -0,0 +1,419 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="Window" inherits="Viewport" version="4.0"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="can_draw" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="child_controls_changed"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="get_flag" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="flag" type="int" enum="Window.Flags"> + </argument> + <description> + </description> + </method> + <method name="get_real_size" qualifiers="const"> + <return type="Vector2i"> + </return> + <description> + </description> + </method> + <method name="get_theme_color" qualifiers="const"> + <return type="Color"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_constant" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_font" qualifiers="const"> + <return type="Font"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_icon" qualifiers="const"> + <return type="Texture2D"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="get_theme_stylebox" qualifiers="const"> + <return type="StyleBox"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="grab_focus"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="has_focus" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="has_theme_color" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_constant" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_font" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_icon" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="has_theme_stylebox" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="StringName"> + </argument> + <argument index="1" name="type" type="StringName" default=""""> + </argument> + <description> + </description> + </method> + <method name="hide"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="is_embedded" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="is_maximize_allowed" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="is_using_font_oversampling" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="move_to_foreground"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="popup"> + <return type="void"> + </return> + <argument index="0" name="rect" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="popup_centered"> + <return type="void"> + </return> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )"> + </argument> + <description> + </description> + </method> + <method name="popup_centered_clamped"> + <return type="void"> + </return> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )"> + </argument> + <argument index="1" name="fallback_ratio" type="float" default="0.75"> + </argument> + <description> + </description> + </method> + <method name="popup_centered_ratio"> + <return type="void"> + </return> + <argument index="0" name="ratio" type="float" default="0.8"> + </argument> + <description> + </description> + </method> + <method name="popup_on_parent"> + <return type="void"> + </return> + <argument index="0" name="parent_rect" type="Rect2i"> + </argument> + <description> + </description> + </method> + <method name="request_attention"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="set_flag"> + <return type="void"> + </return> + <argument index="0" name="flag" type="int" enum="Window.Flags"> + </argument> + <argument index="1" name="enabled" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_ime_active"> + <return type="void"> + </return> + <argument index="0" name="arg0" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_ime_position"> + <return type="void"> + </return> + <argument index="0" name="arg0" type="Vector2i"> + </argument> + <description> + </description> + </method> + <method name="set_use_font_oversampling"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="show"> + <return type="void"> + </return> + <description> + </description> + </method> + </methods> + <members> + <member name="always_on_top" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="borderless" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="content_scale_aspect" type="int" setter="set_content_scale_aspect" getter="get_content_scale_aspect" enum="Window.ContentScaleAspect" default="0"> + </member> + <member name="content_scale_mode" type="int" setter="set_content_scale_mode" getter="get_content_scale_mode" enum="Window.ContentScaleMode" default="0"> + </member> + <member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i( 0, 0 )"> + </member> + <member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen" default="0"> + </member> + <member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false"> + </member> + <member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i( 0, 0 )"> + </member> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i( 0, 0 )"> + </member> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Window.Mode" default="0"> + </member> + <member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i( 0, 0 )"> + </member> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i( 100, 100 )"> + </member> + <member name="theme" type="Theme" setter="set_theme" getter="get_theme"> + </member> + <member name="title" type="String" setter="set_title" getter="get_title" default=""""> + </member> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" default="false"> + </member> + <member name="transparent" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="unfocusable" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="unresizable" type="bool" setter="set_flag" getter="get_flag" default="false"> + </member> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" default="true"> + </member> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" default="false"> + </member> + </members> + <signals> + <signal name="about_to_popup"> + <description> + </description> + </signal> + <signal name="close_requested"> + <description> + </description> + </signal> + <signal name="files_dropped"> + <argument index="0" name="files" type="PackedStringArray"> + </argument> + <description> + </description> + </signal> + <signal name="focus_entered"> + <description> + </description> + </signal> + <signal name="focus_exited"> + <description> + </description> + </signal> + <signal name="go_back_requested"> + <description> + </description> + </signal> + <signal name="mouse_entered"> + <description> + </description> + </signal> + <signal name="mouse_exited"> + <description> + </description> + </signal> + <signal name="visibility_changed"> + <description> + </description> + </signal> + <signal name="window_input"> + <argument index="0" name="event" type="InputEvent"> + </argument> + <description> + </description> + </signal> + </signals> + <constants> + <constant name="NOTIFICATION_VISIBILITY_CHANGED" value="30"> + </constant> + <constant name="MODE_WINDOWED" value="0" enum="Mode"> + </constant> + <constant name="MODE_MINIMIZED" value="1" enum="Mode"> + </constant> + <constant name="MODE_MAXIMIZED" value="2" enum="Mode"> + </constant> + <constant name="MODE_FULLSCREEN" value="3" enum="Mode"> + </constant> + <constant name="FLAG_RESIZE_DISABLED" value="0" enum="Flags"> + </constant> + <constant name="FLAG_BORDERLESS" value="1" enum="Flags"> + </constant> + <constant name="FLAG_ALWAYS_ON_TOP" value="2" enum="Flags"> + </constant> + <constant name="FLAG_TRANSPARENT" value="3" enum="Flags"> + </constant> + <constant name="FLAG_NO_FOCUS" value="4" enum="Flags"> + </constant> + <constant name="FLAG_MAX" value="5" enum="Flags"> + </constant> + <constant name="CONTENT_SCALE_MODE_DISABLED" value="0" enum="ContentScaleMode"> + </constant> + <constant name="CONTENT_SCALE_MODE_OBJECTS" value="1" enum="ContentScaleMode"> + </constant> + <constant name="CONTENT_SCALE_MODE_PIXELS" value="2" enum="ContentScaleMode"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_IGNORE" value="0" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_KEEP" value="1" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_KEEP_WIDTH" value="2" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_KEEP_HEIGHT" value="3" enum="ContentScaleAspect"> + </constant> + <constant name="CONTENT_SCALE_ASPECT_EXPAND" value="4" enum="ContentScaleAspect"> + </constant> + </constants> + <theme_items> + <theme_item name="close" type="Texture2D"> + </theme_item> + <theme_item name="close_h_ofs" type="int" default="18"> + </theme_item> + <theme_item name="close_highlight" type="Texture2D"> + </theme_item> + <theme_item name="close_v_ofs" type="int" default="18"> + </theme_item> + <theme_item name="panel" type="StyleBox"> + </theme_item> + <theme_item name="resize_margin" type="int" default="4"> + </theme_item> + <theme_item name="scaleborder_size" type="int" default="4"> + </theme_item> + <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )"> + </theme_item> + <theme_item name="title_font" type="Font"> + </theme_item> + <theme_item name="title_height" type="int" default="20"> + </theme_item> + <theme_item name="window_panel" type="StyleBox"> + </theme_item> + </theme_items> +</class> diff --git a/doc/classes/WindowDialog.xml b/doc/classes/WindowDialog.xml deleted file mode 100644 index 8b6bf00508..0000000000 --- a/doc/classes/WindowDialog.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="WindowDialog" inherits="Popup" version="4.0"> - <brief_description> - Base class for window dialogs. - </brief_description> - <description> - Windowdialog is the base class for all window-based dialogs. It's a by-default toplevel [Control] that draws a window decoration and allows motion and resizing. - </description> - <tutorials> - </tutorials> - <methods> - <method name="get_close_button"> - <return type="TextureButton"> - </return> - <description> - Returns the close [TextureButton]. - </description> - </method> - </methods> - <members> - <member name="resizable" type="bool" setter="set_resizable" getter="get_resizable" default="false"> - If [code]true[/code], the user can resize the window. - </member> - <member name="window_title" type="String" setter="set_title" getter="get_title" default=""""> - The text displayed in the window's title bar. - </member> - </members> - <constants> - </constants> - <theme_items> - <theme_item name="close" type="Texture2D"> - The icon for the close button. - </theme_item> - <theme_item name="close_h_ofs" type="int" default="18"> - The horizontal offset of the close button. - </theme_item> - <theme_item name="close_highlight" type="Texture2D"> - The icon used for the close button when it's hovered with the mouse cursor. - </theme_item> - <theme_item name="close_v_ofs" type="int" default="18"> - The vertical offset of the close button. - </theme_item> - <theme_item name="panel" type="StyleBox"> - The style for both the content background of the [WindowDialog] and the title bar. - </theme_item> - <theme_item name="scaleborder_size" type="int" default="4"> - The thickness of the border that can be dragged when scaling the window (if [member resizable] is enabled). - </theme_item> - <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )"> - The color of the title text. - </theme_item> - <theme_item name="title_font" type="Font"> - The font used to draw the title. - </theme_item> - <theme_item name="title_height" type="int" default="20"> - The vertical offset of the title text. - </theme_item> - </theme_items> -</class> diff --git a/doc/classes/World2D.xml b/doc/classes/World2D.xml index 9e2d4cfde3..2d8382b7e3 100644 --- a/doc/classes/World2D.xml +++ b/doc/classes/World2D.xml @@ -13,13 +13,13 @@ </methods> <members> <member name="canvas" type="RID" setter="" getter="get_canvas"> - The [RID] of this world's canvas resource. Used by the [VisualServer] for 2D drawing. + The [RID] of this world's canvas resource. Used by the [RenderingServer] for 2D drawing. </member> - <member name="direct_space_state" type="Physics2DDirectSpaceState" setter="" getter="get_direct_space_state"> + <member name="direct_space_state" type="PhysicsDirectSpaceState2D" setter="" getter="get_direct_space_state"> The state of this world's physics space. This allows arbitrary querying for collision. </member> <member name="space" type="RID" setter="" getter="get_space"> - The [RID] of this world's physics space resource. Used by the [Physics2DServer] for 2D physics, treating it as both a space and an area. + The [RID] of this world's physics space resource. Used by the [PhysicsServer2D] for 2D physics, treating it as both a space and an area. </member> </members> <constants> diff --git a/doc/classes/World.xml b/doc/classes/World3D.xml index 48596c87d0..4224a2a2c3 100644 --- a/doc/classes/World.xml +++ b/doc/classes/World3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="World" inherits="Resource" version="4.0"> +<class name="World3D" inherits="Resource" version="4.0"> <brief_description> Class that has everything pertaining to a world. </brief_description> <description> - Class that has everything pertaining to a world. A physics space, a visual scenario and a sound space. Spatial nodes register their resources into the current world. + Class that has everything pertaining to a world. A physics space, a visual scenario and a sound space. Node3D nodes register their resources into the current world. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/physics/ray-casting.html</link> @@ -14,20 +14,20 @@ <members> <member name="camera_effects" type="CameraEffects" setter="set_camera_effects" getter="get_camera_effects"> </member> - <member name="direct_space_state" type="PhysicsDirectSpaceState" setter="" getter="get_direct_space_state"> - The World's physics direct space state, used for making various queries. Might be used only during [code]_physics_process[/code]. + <member name="direct_space_state" type="PhysicsDirectSpaceState3D" setter="" getter="get_direct_space_state"> + The World3D's physics direct space state, used for making various queries. Might be used only during [code]_physics_process[/code]. </member> <member name="environment" type="Environment" setter="set_environment" getter="get_environment"> - The World's [Environment]. + The World3D's [Environment]. </member> <member name="fallback_environment" type="Environment" setter="set_fallback_environment" getter="get_fallback_environment"> - The World's fallback_environment will be used if the World's [Environment] fails or is missing. + The World3D's fallback_environment will be used if the World3D's [Environment] fails or is missing. </member> <member name="scenario" type="RID" setter="" getter="get_scenario"> - The World's visual scenario. + The World3D's visual scenario. </member> <member name="space" type="RID" setter="" getter="get_space"> - The World's physics space. + The World3D's physics space. </member> </members> <constants> diff --git a/doc/classes/WorldEnvironment.xml b/doc/classes/WorldEnvironment.xml index 73500868a8..92b75621c2 100644 --- a/doc/classes/WorldEnvironment.xml +++ b/doc/classes/WorldEnvironment.xml @@ -5,7 +5,7 @@ </brief_description> <description> The [WorldEnvironment] node is used to configure the default [Environment] for the scene. - The parameters defined in the [WorldEnvironment] can be overridden by an [Environment] node set on the current [Camera]. Additionally, only one [WorldEnvironment] may be instanced in a given scene at a time. + The parameters defined in the [WorldEnvironment] can be overridden by an [Environment] node set on the current [Camera3D]. Additionally, only one [WorldEnvironment] may be instanced in a given scene at a time. The [WorldEnvironment] allows the user to specify default lighting parameters (e.g. ambient lighting), various post-processing effects (e.g. SSAO, DOF, Tonemapping), and how to draw the background (e.g. solid color, skybox). Usually, these are added in order to improve the realism/color balance of the scene. </description> <tutorials> diff --git a/doc/classes/WorldMarginShape.xml b/doc/classes/WorldMarginShape3D.xml index 54f76a066b..a91447056b 100644 --- a/doc/classes/WorldMarginShape.xml +++ b/doc/classes/WorldMarginShape3D.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WorldMarginShape" inherits="Shape" version="4.0"> +<class name="WorldMarginShape3D" inherits="Shape3D" version="4.0"> <brief_description> Infinite plane shape for 3D collisions. </brief_description> <description> - An infinite plane shape for 3D collisions. Note that the [Plane]'s normal matters; anything "below" the plane will collide with it. If the [WorldMarginShape] is used in a [PhysicsBody], it will cause colliding objects placed "below" it to teleport "above" the plane. + An infinite plane shape for 3D collisions. Note that the [Plane]'s normal matters; anything "below" the plane will collide with it. If the [WorldMarginShape3D] is used in a [PhysicsBody3D], it will cause colliding objects placed "below" it to teleport "above" the plane. </description> <tutorials> </tutorials> @@ -12,7 +12,7 @@ </methods> <members> <member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane( 0, 1, 0, 0 )"> - The [Plane] used by the [WorldMarginShape] for collision. + The [Plane] used by the [WorldMarginShape3D] for collision. </member> </members> <constants> diff --git a/doc/tools/doc_merge.py b/doc/tools/doc_merge.py index 496d5dcb74..f6f52f5d66 100755 --- a/doc/tools/doc_merge.py +++ b/doc/tools/doc_merge.py @@ -21,7 +21,7 @@ def write_string(_f, text, newline=True): for t in range(tab): _f.write("\t") _f.write(text) - if (newline): + if newline: _f.write("\n") @@ -30,7 +30,7 @@ def escape(ret): ret = ret.replace("<", ">") ret = ret.replace(">", "<") ret = ret.replace("'", "'") - ret = ret.replace("\"", """) + ret = ret.replace('"', """) return ret @@ -43,25 +43,26 @@ def dec_tab(): global tab tab -= 1 + write_string(f, '<?xml version="1.0" encoding="UTF-8" ?>') write_string(f, '<doc version="' + new_doc.attrib["version"] + '">') def get_tag(node, name): tag = "" - if (name in node.attrib): - tag = ' ' + name + '="' + escape(node.attrib[name]) + '" ' + if name in node.attrib: + tag = " " + name + '="' + escape(node.attrib[name]) + '" ' return tag def find_method_descr(old_class, name): methods = old_class.find("methods") - if(methods != None and len(list(methods)) > 0): + if methods != None and len(list(methods)) > 0: for m in list(methods): - if (m.attrib["name"] == name): + if m.attrib["name"] == name: description = m.find("description") - if (description != None and description.text.strip() != ""): + if description != None and description.text.strip() != "": return description.text return None @@ -70,11 +71,11 @@ def find_method_descr(old_class, name): def find_signal_descr(old_class, name): signals = old_class.find("signals") - if(signals != None and len(list(signals)) > 0): + if signals != None and len(list(signals)) > 0: for m in list(signals): - if (m.attrib["name"] == name): + if m.attrib["name"] == name: description = m.find("description") - if (description != None and description.text.strip() != ""): + if description != None and description.text.strip() != "": return description.text return None @@ -82,13 +83,13 @@ def find_signal_descr(old_class, name): def find_constant_descr(old_class, name): - if (old_class is None): + if old_class is None: return None constants = old_class.find("constants") - if(constants != None and len(list(constants)) > 0): + if constants != None and len(list(constants)) > 0: for m in list(constants): - if (m.attrib["name"] == name): - if (m.text.strip() != ""): + if m.attrib["name"] == name: + if m.text.strip() != "": return m.text return None @@ -96,35 +97,35 @@ def find_constant_descr(old_class, name): def write_class(c): class_name = c.attrib["name"] print("Parsing Class: " + class_name) - if (class_name in old_classes): + if class_name in old_classes: old_class = old_classes[class_name] else: old_class = None category = get_tag(c, "category") inherits = get_tag(c, "inherits") - write_string(f, '<class name="' + class_name + '" ' + category + inherits + '>') + write_string(f, '<class name="' + class_name + '" ' + category + inherits + ">") inc_tab() write_string(f, "<brief_description>") - if (old_class != None): + if old_class != None: old_brief_descr = old_class.find("brief_description") - if (old_brief_descr != None): + if old_brief_descr != None: write_string(f, escape(old_brief_descr.text.strip())) write_string(f, "</brief_description>") write_string(f, "<description>") - if (old_class != None): + if old_class != None: old_descr = old_class.find("description") - if (old_descr != None): + if old_descr != None: write_string(f, escape(old_descr.text.strip())) write_string(f, "</description>") methods = c.find("methods") - if(methods != None and len(list(methods)) > 0): + if methods != None and len(list(methods)) > 0: write_string(f, "<methods>") inc_tab() @@ -132,35 +133,46 @@ def write_class(c): for m in list(methods): qualifiers = get_tag(m, "qualifiers") - write_string(f, '<method name="' + escape(m.attrib["name"]) + '" ' + qualifiers + '>') + write_string(f, '<method name="' + escape(m.attrib["name"]) + '" ' + qualifiers + ">") inc_tab() for a in list(m): - if (a.tag == "return"): + if a.tag == "return": typ = get_tag(a, "type") - write_string(f, '<return' + typ + '>') - write_string(f, '</return>') - elif (a.tag == "argument"): + write_string(f, "<return" + typ + ">") + write_string(f, "</return>") + elif a.tag == "argument": default = get_tag(a, "default") - write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '"' + default + '>') - write_string(f, '</argument>') - - write_string(f, '<description>') - if (old_class != None): + write_string( + f, + '<argument index="' + + a.attrib["index"] + + '" name="' + + escape(a.attrib["name"]) + + '" type="' + + a.attrib["type"] + + '"' + + default + + ">", + ) + write_string(f, "</argument>") + + write_string(f, "<description>") + if old_class != None: old_method_descr = find_method_descr(old_class, m.attrib["name"]) - if (old_method_descr): + if old_method_descr: write_string(f, escape(escape(old_method_descr.strip()))) - write_string(f, '</description>') + write_string(f, "</description>") dec_tab() write_string(f, "</method>") dec_tab() write_string(f, "</methods>") signals = c.find("signals") - if(signals != None and len(list(signals)) > 0): + if signals != None and len(list(signals)) > 0: write_string(f, "<signals>") inc_tab() @@ -171,24 +183,33 @@ def write_class(c): inc_tab() for a in list(m): - if (a.tag == "argument"): - - write_string(f, '<argument index="' + a.attrib["index"] + '" name="' + escape(a.attrib["name"]) + '" type="' + a.attrib["type"] + '">') - write_string(f, '</argument>') - - write_string(f, '<description>') - if (old_class != None): + if a.tag == "argument": + + write_string( + f, + '<argument index="' + + a.attrib["index"] + + '" name="' + + escape(a.attrib["name"]) + + '" type="' + + a.attrib["type"] + + '">', + ) + write_string(f, "</argument>") + + write_string(f, "<description>") + if old_class != None: old_signal_descr = find_signal_descr(old_class, m.attrib["name"]) - if (old_signal_descr): + if old_signal_descr: write_string(f, escape(old_signal_descr.strip())) - write_string(f, '</description>') + write_string(f, "</description>") dec_tab() write_string(f, "</signal>") dec_tab() write_string(f, "</signals>") constants = c.find("constants") - if(constants != None and len(list(constants)) > 0): + if constants != None and len(list(constants)) > 0: write_string(f, "<constants>") inc_tab() @@ -197,7 +218,7 @@ def write_class(c): write_string(f, '<constant name="' + escape(m.attrib["name"]) + '" value="' + m.attrib["value"] + '">') old_constant_descr = find_constant_descr(old_class, m.attrib["name"]) - if (old_constant_descr): + if old_constant_descr: write_string(f, escape(old_constant_descr.strip())) write_string(f, "</constant>") @@ -207,9 +228,10 @@ def write_class(c): dec_tab() write_string(f, "</class>") + for c in list(old_doc): old_classes[c.attrib["name"]] = c for c in list(new_doc): write_class(c) -write_string(f, '</doc>\n') +write_string(f, "</doc>\n") diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index e6e6d5f606..629b5a032b 100755 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -13,75 +13,74 @@ import xml.etree.ElementTree as ET ################################################################################ flags = { - 'c': platform.platform() != 'Windows', # Disable by default on windows, since we use ANSI escape codes - 'b': False, - 'g': False, - 's': False, - 'u': False, - 'h': False, - 'p': False, - 'o': True, - 'i': False, - 'a': True, - 'e': False, + "c": platform.platform() != "Windows", # Disable by default on windows, since we use ANSI escape codes + "b": False, + "g": False, + "s": False, + "u": False, + "h": False, + "p": False, + "o": True, + "i": False, + "a": True, + "e": False, } flag_descriptions = { - 'c': 'Toggle colors when outputting.', - 'b': 'Toggle showing only not fully described classes.', - 'g': 'Toggle showing only completed classes.', - 's': 'Toggle showing comments about the status.', - 'u': 'Toggle URLs to docs.', - 'h': 'Show help and exit.', - 'p': 'Toggle showing percentage as well as counts.', - 'o': 'Toggle overall column.', - 'i': 'Toggle collapse of class items columns.', - 'a': 'Toggle showing all items.', - 'e': 'Toggle hiding empty items.', + "c": "Toggle colors when outputting.", + "b": "Toggle showing only not fully described classes.", + "g": "Toggle showing only completed classes.", + "s": "Toggle showing comments about the status.", + "u": "Toggle URLs to docs.", + "h": "Show help and exit.", + "p": "Toggle showing percentage as well as counts.", + "o": "Toggle overall column.", + "i": "Toggle collapse of class items columns.", + "a": "Toggle showing all items.", + "e": "Toggle hiding empty items.", } long_flags = { - 'colors': 'c', - 'use-colors': 'c', - - 'bad': 'b', - 'only-bad': 'b', - - 'good': 'g', - 'only-good': 'g', - - 'comments': 's', - 'status': 's', - - 'urls': 'u', - 'gen-url': 'u', - - 'help': 'h', - - 'percent': 'p', - 'use-percentages': 'p', - - 'overall': 'o', - 'use-overall': 'o', - - 'items': 'i', - 'collapse': 'i', - - 'all': 'a', - - 'empty': 'e', + "colors": "c", + "use-colors": "c", + "bad": "b", + "only-bad": "b", + "good": "g", + "only-good": "g", + "comments": "s", + "status": "s", + "urls": "u", + "gen-url": "u", + "help": "h", + "percent": "p", + "use-percentages": "p", + "overall": "o", + "use-overall": "o", + "items": "i", + "collapse": "i", + "all": "a", + "empty": "e", } -table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals', 'theme_items'] -table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals', 'Theme Items'] +table_columns = [ + "name", + "brief_description", + "description", + "methods", + "constants", + "members", + "signals", + "theme_items", +] +table_column_names = ["Name", "Brief Desc.", "Desc.", "Methods", "Constants", "Members", "Signals", "Theme Items"] colors = { - 'name': [36], # cyan - 'part_big_problem': [4, 31], # underline, red - 'part_problem': [31], # red - 'part_mostly_good': [33], # yellow - 'part_good': [32], # green - 'url': [4, 34], # underline, blue - 'section': [1, 4], # bold, underline - 'state_off': [36], # cyan - 'state_on': [1, 35], # bold, magenta/plum - 'bold': [1], # bold + "name": [36], # cyan + "part_big_problem": [4, 31], # underline, red + "part_problem": [31], # red + "part_mostly_good": [33], # yellow + "part_good": [32], # green + "url": [4, 34], # underline, blue + "section": [1, 4], # bold, underline + "state_off": [36], # cyan + "state_on": [1, 35], # bold, magenta/plum + "bold": [1], # bold } overall_progress_description_weigth = 10 @@ -90,6 +89,7 @@ overall_progress_description_weigth = 10 # Utils # ################################################################################ + def validate_tag(elem, tag): if elem.tag != tag: print('Tag mismatch, expected "' + tag + '", got ' + elem.tag) @@ -97,36 +97,38 @@ def validate_tag(elem, tag): def color(color, string): - if flags['c'] and terminal_supports_color(): - color_format = '' + if flags["c"] and terminal_supports_color(): + color_format = "" for code in colors[color]: - color_format += '\033[' + str(code) + 'm' - return color_format + string + '\033[0m' + color_format += "\033[" + str(code) + "m" + return color_format + string + "\033[0m" else: return string -ansi_escape = re.compile(r'\x1b[^m]*m') + +ansi_escape = re.compile(r"\x1b[^m]*m") def nonescape_len(s): - return len(ansi_escape.sub('', s)) + return len(ansi_escape.sub("", s)) + def terminal_supports_color(): p = sys.platform - supported_platform = p != 'Pocket PC' and (p != 'win32' or - 'ANSICON' in os.environ) + supported_platform = p != "Pocket PC" and (p != "win32" or "ANSICON" in os.environ) - is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty() + is_a_tty = hasattr(sys.stdout, "isatty") and sys.stdout.isatty() if not supported_platform or not is_a_tty: return False return True + ################################################################################ # Classes # ################################################################################ -class ClassStatusProgress: +class ClassStatusProgress: def __init__(self, described=0, total=0): self.described = described self.total = total @@ -143,42 +145,41 @@ class ClassStatusProgress: return self.described >= self.total def to_configured_colored_string(self): - if flags['p']: - return self.to_colored_string('{percent}% ({has}/{total})', '{pad_percent}{pad_described}{s}{pad_total}') + if flags["p"]: + return self.to_colored_string("{percent}% ({has}/{total})", "{pad_percent}{pad_described}{s}{pad_total}") else: return self.to_colored_string() - def to_colored_string(self, format='{has}/{total}', pad_format='{pad_described}{s}{pad_total}'): + def to_colored_string(self, format="{has}/{total}", pad_format="{pad_described}{s}{pad_total}"): ratio = float(self.described) / float(self.total) if self.total != 0 else 1 percent = int(round(100 * ratio)) s = format.format(has=str(self.described), total=str(self.total), percent=str(percent)) if self.described >= self.total: - s = color('part_good', s) + s = color("part_good", s) elif self.described >= self.total / 4 * 3: - s = color('part_mostly_good', s) + s = color("part_mostly_good", s) elif self.described > 0: - s = color('part_problem', s) + s = color("part_problem", s) else: - s = color('part_big_problem', s) + s = color("part_big_problem", s) pad_size = max(len(str(self.described)), len(str(self.total))) - pad_described = ''.ljust(pad_size - len(str(self.described))) - pad_percent = ''.ljust(3 - len(str(percent))) - pad_total = ''.ljust(pad_size - len(str(self.total))) + pad_described = "".ljust(pad_size - len(str(self.described))) + pad_percent = "".ljust(3 - len(str(percent))) + pad_total = "".ljust(pad_size - len(str(self.total))) return pad_format.format(pad_described=pad_described, pad_total=pad_total, pad_percent=pad_percent, s=s) class ClassStatus: - - def __init__(self, name=''): + def __init__(self, name=""): self.name = name self.has_brief_description = True self.has_description = True self.progresses = { - 'methods': ClassStatusProgress(), - 'constants': ClassStatusProgress(), - 'members': ClassStatusProgress(), - 'theme_items': ClassStatusProgress(), - 'signals': ClassStatusProgress() + "methods": ClassStatusProgress(), + "constants": ClassStatusProgress(), + "members": ClassStatusProgress(), + "theme_items": ClassStatusProgress(), + "signals": ClassStatusProgress(), } def __add__(self, other): @@ -208,66 +209,70 @@ class ClassStatus: def make_output(self): output = {} - output['name'] = color('name', self.name) + output["name"] = color("name", self.name) - ok_string = color('part_good', 'OK') - missing_string = color('part_big_problem', 'MISSING') + ok_string = color("part_good", "OK") + missing_string = color("part_big_problem", "MISSING") - output['brief_description'] = ok_string if self.has_brief_description else missing_string - output['description'] = ok_string if self.has_description else missing_string + output["brief_description"] = ok_string if self.has_brief_description else missing_string + output["description"] = ok_string if self.has_description else missing_string description_progress = ClassStatusProgress( (self.has_brief_description + self.has_description) * overall_progress_description_weigth, - 2 * overall_progress_description_weigth + 2 * overall_progress_description_weigth, ) items_progress = ClassStatusProgress() - for k in ['methods', 'constants', 'members', 'signals', 'theme_items']: + for k in ["methods", "constants", "members", "signals", "theme_items"]: items_progress += self.progresses[k] output[k] = self.progresses[k].to_configured_colored_string() - output['items'] = items_progress.to_configured_colored_string() + output["items"] = items_progress.to_configured_colored_string() - output['overall'] = (description_progress + items_progress).to_colored_string(color('bold', '{percent}%'), '{pad_percent}{s}') + output["overall"] = (description_progress + items_progress).to_colored_string( + color("bold", "{percent}%"), "{pad_percent}{s}" + ) - if self.name.startswith('Total'): - output['url'] = color('url', 'https://docs.godotengine.org/en/latest/classes/') - if flags['s']: - output['comment'] = color('part_good', 'ALL OK') + if self.name.startswith("Total"): + output["url"] = color("url", "https://docs.godotengine.org/en/latest/classes/") + if flags["s"]: + output["comment"] = color("part_good", "ALL OK") else: - output['url'] = color('url', 'https://docs.godotengine.org/en/latest/classes/class_{name}.html'.format(name=self.name.lower())) + output["url"] = color( + "url", "https://docs.godotengine.org/en/latest/classes/class_{name}.html".format(name=self.name.lower()) + ) - if flags['s'] and not flags['g'] and self.is_ok(): - output['comment'] = color('part_good', 'ALL OK') + if flags["s"] and not flags["g"] and self.is_ok(): + output["comment"] = color("part_good", "ALL OK") return output @staticmethod def generate_for_class(c): status = ClassStatus() - status.name = c.attrib['name'] + status.name = c.attrib["name"] for tag in list(c): - if tag.tag == 'brief_description': + if tag.tag == "brief_description": status.has_brief_description = len(tag.text.strip()) > 0 - elif tag.tag == 'description': + elif tag.tag == "description": status.has_description = len(tag.text.strip()) > 0 - elif tag.tag in ['methods', 'signals']: + elif tag.tag in ["methods", "signals"]: for sub_tag in list(tag): - descr = sub_tag.find('description') + descr = sub_tag.find("description") status.progresses[tag.tag].increment(len(descr.text.strip()) > 0) - elif tag.tag in ['constants', 'members', 'theme_items']: + elif tag.tag in ["constants", "members", "theme_items"]: for sub_tag in list(tag): if not sub_tag.text is None: status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0) - elif tag.tag in ['tutorials']: + elif tag.tag in ["tutorials"]: pass # Ignore those tags for now - elif tag.tag in ['theme_items']: + elif tag.tag in ["theme_items"]: pass # Ignore those tags, since they seem to lack description at all else: @@ -286,63 +291,69 @@ merged_file = "" for arg in sys.argv[1:]: try: - if arg.startswith('--'): + if arg.startswith("--"): flags[long_flags[arg[2:]]] = not flags[long_flags[arg[2:]]] - elif arg.startswith('-'): + elif arg.startswith("-"): for f in arg[1:]: flags[f] = not flags[f] elif os.path.isdir(arg): for f in os.listdir(arg): - if f.endswith('.xml'): - input_file_list.append(os.path.join(arg, f)); + if f.endswith(".xml"): + input_file_list.append(os.path.join(arg, f)) else: input_class_list.append(arg) except KeyError: print("Unknown command line flag: " + arg) sys.exit(1) -if flags['i']: - for r in ['methods', 'constants', 'members', 'signals', 'theme_items']: +if flags["i"]: + for r in ["methods", "constants", "members", "signals", "theme_items"]: index = table_columns.index(r) del table_column_names[index] del table_columns[index] - table_column_names.append('Items') - table_columns.append('items') + table_column_names.append("Items") + table_columns.append("items") -if flags['o'] == (not flags['i']): - table_column_names.append(color('bold', 'Overall')) - table_columns.append('overall') +if flags["o"] == (not flags["i"]): + table_column_names.append(color("bold", "Overall")) + table_columns.append("overall") -if flags['u']: - table_column_names.append('Docs URL') - table_columns.append('url') +if flags["u"]: + table_column_names.append("Docs URL") + table_columns.append("url") ################################################################################ # Help # ################################################################################ -if len(input_file_list) < 1 or flags['h']: - if not flags['h']: - print(color('section', 'Invalid usage') + ': Please specify a classes directory') - print(color('section', 'Usage') + ': doc_status.py [flags] <classes_dir> [class names]') - print('\t< and > signify required parameters, while [ and ] signify optional parameters.') - print(color('section', 'Available flags') + ':') +if len(input_file_list) < 1 or flags["h"]: + if not flags["h"]: + print(color("section", "Invalid usage") + ": Please specify a classes directory") + print(color("section", "Usage") + ": doc_status.py [flags] <classes_dir> [class names]") + print("\t< and > signify required parameters, while [ and ] signify optional parameters.") + print(color("section", "Available flags") + ":") possible_synonym_list = list(long_flags) possible_synonym_list.sort() flag_list = list(flags) flag_list.sort() for flag in flag_list: - synonyms = [color('name', '-' + flag)] + synonyms = [color("name", "-" + flag)] for synonym in possible_synonym_list: if long_flags[synonym] == flag: - synonyms.append(color('name', '--' + synonym)) - - print(('{synonyms} (Currently ' + color('state_' + ('on' if flags[flag] else 'off'), '{value}') + ')\n\t{description}').format( - synonyms=', '.join(synonyms), - value=('on' if flags[flag] else 'off'), - description=flag_descriptions[flag] - )) + synonyms.append(color("name", "--" + synonym)) + + print( + ( + "{synonyms} (Currently " + + color("state_" + ("on" if flags[flag] else "off"), "{value}") + + ")\n\t{description}" + ).format( + synonyms=", ".join(synonyms), + value=("on" if flags[flag] else "off"), + description=flag_descriptions[flag], + ) + ) sys.exit(0) @@ -357,21 +368,21 @@ for file in input_file_list: tree = ET.parse(file) doc = tree.getroot() - if 'version' not in doc.attrib: + if "version" not in doc.attrib: print('Version missing from "doc"') sys.exit(255) - version = doc.attrib['version'] + version = doc.attrib["version"] - if doc.attrib['name'] in class_names: + if doc.attrib["name"] in class_names: continue - class_names.append(doc.attrib['name']) - classes[doc.attrib['name']] = doc + class_names.append(doc.attrib["name"]) + classes[doc.attrib["name"]] = doc class_names.sort() if len(input_class_list) < 1: - input_class_list = ['*'] + input_class_list = ["*"] filtered_classes = set() for pattern in input_class_list: @@ -384,23 +395,23 @@ filtered_classes.sort() ################################################################################ table = [table_column_names] -table_row_chars = '| - ' -table_column_chars = '|' +table_row_chars = "| - " +table_column_chars = "|" -total_status = ClassStatus('Total') +total_status = ClassStatus("Total") for cn in filtered_classes: c = classes[cn] - validate_tag(c, 'class') + validate_tag(c, "class") status = ClassStatus.generate_for_class(c) total_status = total_status + status - if (flags['b'] and status.is_ok()) or (flags['g'] and not status.is_ok()) or (not flags['a']): + if (flags["b"] and status.is_ok()) or (flags["g"] and not status.is_ok()) or (not flags["a"]): continue - if flags['e'] and status.is_empty(): + if flags["e"] and status.is_empty(): continue out = status.make_output() @@ -409,10 +420,10 @@ for cn in filtered_classes: if column in out: row.append(out[column]) else: - row.append('') + row.append("") - if 'comment' in out and out['comment'] != '': - row.append(out['comment']) + if "comment" in out and out["comment"] != "": + row.append(out["comment"]) table.append(row) @@ -421,22 +432,22 @@ for cn in filtered_classes: # Print output table # ################################################################################ -if len(table) == 1 and flags['a']: - print(color('part_big_problem', 'No classes suitable for printing!')) +if len(table) == 1 and flags["a"]: + print(color("part_big_problem", "No classes suitable for printing!")) sys.exit(0) -if len(table) > 2 or not flags['a']: - total_status.name = 'Total = {0}'.format(len(table) - 1) +if len(table) > 2 or not flags["a"]: + total_status.name = "Total = {0}".format(len(table) - 1) out = total_status.make_output() row = [] for column in table_columns: if column in out: row.append(out[column]) else: - row.append('') + row.append("") table.append(row) -if flags['a']: +if flags["a"]: # Duplicate the headers at the bottom of the table so they can be viewed # without having to scroll back to the top. table.append(table_column_names) @@ -451,7 +462,9 @@ for row in table: divider_string = table_row_chars[0] for cell_i in range(len(table[0])): - divider_string += table_row_chars[1] + table_row_chars[2] * (table_column_sizes[cell_i]) + table_row_chars[1] + table_row_chars[0] + divider_string += ( + table_row_chars[1] + table_row_chars[2] * (table_column_sizes[cell_i]) + table_row_chars[1] + table_row_chars[0] + ) print(divider_string) for row_i, row in enumerate(table): @@ -461,7 +474,11 @@ for row_i, row in enumerate(table): if cell_i == 0: row_string += table_row_chars[3] + cell + table_row_chars[3] * (padding_needed - 1) else: - row_string += table_row_chars[3] * int(math.floor(float(padding_needed) / 2)) + cell + table_row_chars[3] * int(math.ceil(float(padding_needed) / 2)) + row_string += ( + table_row_chars[3] * int(math.floor(float(padding_needed) / 2)) + + cell + + table_row_chars[3] * int(math.ceil(float(padding_needed) / 2)) + ) row_string += table_column_chars print(row_string) @@ -474,5 +491,5 @@ for row_i, row in enumerate(table): print(divider_string) -if total_status.is_ok() and not flags['g']: - print('All listed classes are ' + color('part_good', 'OK') + '!') +if total_status.is_ok() and not flags["g"]: + print("All listed classes are " + color("part_good", "OK") + "!") diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index 9012de03b3..9de5eac31d 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -7,10 +7,12 @@ import xml.etree.ElementTree as ET from collections import OrderedDict # Uncomment to do type checks. I have it commented out so it works below Python 3.5 -#from typing import List, Dict, TextIO, Tuple, Iterable, Optional, DefaultDict, Any, Union +# from typing import List, Dict, TextIO, Tuple, Iterable, Optional, DefaultDict, Any, Union # http(s)://docs.godotengine.org/<langcode>/<tag>/path/to/page.html(#fragment-tag) -GODOT_DOCS_PATTERN = re.compile(r'^http(?:s)?://docs\.godotengine\.org/(?:[a-zA-Z0-9.\-_]*)/(?:[a-zA-Z0-9.\-_]*)/(.*)\.html(#.*)?$') +GODOT_DOCS_PATTERN = re.compile( + r"^http(?:s)?://docs\.godotengine\.org/(?:[a-zA-Z0-9.\-_]*)/(?:[a-zA-Z0-9.\-_]*)/(.*)\.html(#.*)?$" +) def print_error(error, state): # type: (str, State) -> None @@ -37,7 +39,9 @@ class TypeName: class PropertyDef: - def __init__(self, name, type_name, setter, getter, text, default_value, overridden): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str], Optional[bool]) -> None + def __init__( + self, name, type_name, setter, getter, text, default_value, overridden + ): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str], Optional[bool]) -> None self.name = name self.type_name = type_name self.setter = setter @@ -46,6 +50,7 @@ class PropertyDef: self.default_value = default_value self.overridden = overridden + class ParameterDef: def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None self.name = name @@ -61,7 +66,9 @@ class SignalDef: class MethodDef: - def __init__(self, name, return_type, parameters, description, qualifiers): # type: (str, TypeName, List[ParameterDef], Optional[str], Optional[str]) -> None + def __init__( + self, name, return_type, parameters, description, qualifiers + ): # type: (str, TypeName, List[ParameterDef], Optional[str], Optional[str]) -> None self.name = name self.return_type = return_type self.parameters = parameters @@ -144,10 +151,12 @@ class State: getter = property.get("getter") or None default_value = property.get("default") or None if default_value is not None: - default_value = '``{}``'.format(default_value) + default_value = "``{}``".format(default_value) overridden = property.get("override") or False - property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value, overridden) + property_def = PropertyDef( + property_name, type_name, setter, getter, property.text, default_value, overridden + ) class_def.properties[property_name] = property_def methods = class_root.find("methods") @@ -246,8 +255,6 @@ class State: if link.text is not None: class_def.tutorials.append(link.text) - - def sort_classes(self): # type: () -> None self.classes = OrderedDict(sorted(self.classes.items(), key=lambda t: t[0])) @@ -273,7 +280,11 @@ def main(): # type: () -> None parser.add_argument("path", nargs="+", help="A path to an XML file or a directory containing XML files to parse.") group = parser.add_mutually_exclusive_group() group.add_argument("--output", "-o", default=".", help="The directory to save output .rst files in.") - group.add_argument("--dry-run", action="store_true", help="If passed, no output will be generated and XML files are only checked for errors.") + group.add_argument( + "--dry-run", + action="store_true", + help="If passed, no output will be generated and XML files are only checked for errors.", + ) args = parser.parse_args() file_list = [] # type: List[str] @@ -283,15 +294,15 @@ def main(): # type: () -> None if path.endswith(os.sep): path = path[:-1] - if os.path.basename(path) == 'modules': + if os.path.basename(path) == "modules": for subdir, dirs, _ in os.walk(path): - if 'doc_classes' in dirs: - doc_dir = os.path.join(subdir, 'doc_classes') - class_file_names = (f for f in os.listdir(doc_dir) if f.endswith('.xml')) + if "doc_classes" in dirs: + doc_dir = os.path.join(subdir, "doc_classes") + class_file_names = (f for f in os.listdir(doc_dir) if f.endswith(".xml")) file_list += (os.path.join(doc_dir, f) for f in class_file_names) elif os.path.isdir(path): - file_list += (os.path.join(path, f) for f in os.listdir(path) if f.endswith('.xml')) + file_list += (os.path.join(path, f) for f in os.listdir(path) if f.endswith(".xml")) elif os.path.isfile(path): if not path.endswith(".xml"): @@ -311,7 +322,7 @@ def main(): # type: () -> None continue doc = tree.getroot() - if 'version' not in doc.attrib: + if "version" not in doc.attrib: print_error("Version missing from 'doc', file: {}".format(cur_file), state) continue @@ -337,13 +348,14 @@ def main(): # type: () -> None if state.errored: exit(1) + def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, State, bool, str) -> None class_name = class_def.name if dry_run: - f = open(os.devnull, "w") + f = open(os.devnull, "w", encoding="utf-8") else: - f = open(os.path.join(output_dir, "class_" + class_name.lower() + '.rst'), 'w', encoding='utf-8') + f = open(os.path.join(output_dir, "class_" + class_name.lower() + ".rst"), "w", encoding="utf-8") # Warn contributors not to edit this file directly f.write(":github_url: hide\n\n") @@ -352,13 +364,13 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write(".. The source is found in doc/classes or modules/<name>/doc_classes.\n\n") f.write(".. _class_" + class_name + ":\n\n") - f.write(make_heading(class_name, '=')) + f.write(make_heading(class_name, "=")) # Inheritance tree # Ascendants if class_def.inherits: inh = class_def.inherits.strip() - f.write('**Inherits:** ') + f.write("**Inherits:** ") first = True while inh in state.classes: if not first: @@ -381,7 +393,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S inherited.append(c.name) if len(inherited): - f.write('**Inherited By:** ') + f.write("**Inherited By:** ") for i, child in enumerate(inherited): if i > 0: f.write(", ") @@ -393,20 +405,20 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write(rstize_text(class_def.brief_description.strip(), state) + "\n\n") # Class description - if class_def.description is not None and class_def.description.strip() != '': - f.write(make_heading('Description', '-')) + if class_def.description is not None and class_def.description.strip() != "": + f.write(make_heading("Description", "-")) f.write(rstize_text(class_def.description.strip(), state) + "\n\n") # Online tutorials if len(class_def.tutorials) > 0: - f.write(make_heading('Tutorials', '-')) + f.write(make_heading("Tutorials", "-")) for t in class_def.tutorials: link = t.strip() f.write("- " + make_url(link) + "\n\n") # Properties overview if len(class_def.properties) > 0: - f.write(make_heading('Properties', '-')) + f.write(make_heading("Properties", "-")) ml = [] # type: List[Tuple[str, str, str]] for property_def in class_def.properties.values(): type_rst = property_def.type_name.to_rst(state) @@ -420,7 +432,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S # Methods overview if len(class_def.methods) > 0: - f.write(make_heading('Methods', '-')) + f.write(make_heading("Methods", "-")) ml = [] for method_list in class_def.methods.values(): for m in method_list: @@ -429,7 +441,7 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S # Theme properties if class_def.theme_items is not None and len(class_def.theme_items) > 0: - f.write(make_heading('Theme Properties', '-')) + f.write(make_heading("Theme Properties", "-")) pl = [] for theme_item_list in class_def.theme_items.values(): for theme_item in theme_item_list: @@ -438,30 +450,30 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S # Signals if len(class_def.signals) > 0: - f.write(make_heading('Signals', '-')) + f.write(make_heading("Signals", "-")) index = 0 for signal in class_def.signals.values(): if index != 0: - f.write('----\n\n') + f.write("----\n\n") f.write(".. _class_{}_signal_{}:\n\n".format(class_name, signal.name)) _, signature = make_method_signature(class_def, signal, False, state) f.write("- {}\n\n".format(signature)) - if signal.description is not None and signal.description.strip() != '': - f.write(rstize_text(signal.description.strip(), state) + '\n\n') + if signal.description is not None and signal.description.strip() != "": + f.write(rstize_text(signal.description.strip(), state) + "\n\n") index += 1 # Enums if len(class_def.enums) > 0: - f.write(make_heading('Enumerations', '-')) + f.write(make_heading("Enumerations", "-")) index = 0 for e in class_def.enums.values(): if index != 0: - f.write('----\n\n') + f.write("----\n\n") f.write(".. _enum_{}_{}:\n\n".format(class_name, e.name)) # Sphinx seems to divide the bullet list into individual <ul> tags if we weave the labels into it. @@ -474,16 +486,16 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write("enum **{}**:\n\n".format(e.name)) for value in e.values.values(): f.write("- **{}** = **{}**".format(value.name, value.value)) - if value.text is not None and value.text.strip() != '': - f.write(' --- ' + rstize_text(value.text.strip(), state)) + if value.text is not None and value.text.strip() != "": + f.write(" --- " + rstize_text(value.text.strip(), state)) - f.write('\n\n') + f.write("\n\n") index += 1 # Constants if len(class_def.constants) > 0: - f.write(make_heading('Constants', '-')) + f.write(make_heading("Constants", "-")) # Sphinx seems to divide the bullet list into individual <ul> tags if we weave the labels into it. # As such I'll put them all above the list. Won't be perfect but better than making the list visually broken. for constant in class_def.constants.values(): @@ -491,14 +503,14 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S for constant in class_def.constants.values(): f.write("- **{}** = **{}**".format(constant.name, constant.value)) - if constant.text is not None and constant.text.strip() != '': - f.write(' --- ' + rstize_text(constant.text.strip(), state)) + if constant.text is not None and constant.text.strip() != "": + f.write(" --- " + rstize_text(constant.text.strip(), state)) - f.write('\n\n') + f.write("\n\n") # Property descriptions if any(not p.overridden for p in class_def.properties.values()) > 0: - f.write(make_heading('Property Descriptions', '-')) + f.write(make_heading("Property Descriptions", "-")) index = 0 for property_def in class_def.properties.values(): @@ -506,36 +518,36 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S continue if index != 0: - f.write('----\n\n') + f.write("----\n\n") f.write(".. _class_{}_property_{}:\n\n".format(class_name, property_def.name)) - f.write('- {} **{}**\n\n'.format(property_def.type_name.to_rst(state), property_def.name)) + f.write("- {} **{}**\n\n".format(property_def.type_name.to_rst(state), property_def.name)) info = [] if property_def.default_value is not None: info.append(("*Default*", property_def.default_value)) if property_def.setter is not None and not property_def.setter.startswith("_"): - info.append(("*Setter*", property_def.setter + '(value)')) + info.append(("*Setter*", property_def.setter + "(value)")) if property_def.getter is not None and not property_def.getter.startswith("_"): - info.append(('*Getter*', property_def.getter + '()')) + info.append(("*Getter*", property_def.getter + "()")) if len(info) > 0: format_table(f, info) - if property_def.text is not None and property_def.text.strip() != '': - f.write(rstize_text(property_def.text.strip(), state) + '\n\n') + if property_def.text is not None and property_def.text.strip() != "": + f.write(rstize_text(property_def.text.strip(), state) + "\n\n") index += 1 # Method descriptions if len(class_def.methods) > 0: - f.write(make_heading('Method Descriptions', '-')) + f.write(make_heading("Method Descriptions", "-")) index = 0 for method_list in class_def.methods.values(): for i, m in enumerate(method_list): if index != 0: - f.write('----\n\n') + f.write("----\n\n") if i == 0: f.write(".. _class_{}_method_{}:\n\n".format(class_name, m.name)) @@ -543,24 +555,24 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S ret_type, signature = make_method_signature(class_def, m, False, state) f.write("- {} {}\n\n".format(ret_type, signature)) - if m.description is not None and m.description.strip() != '': - f.write(rstize_text(m.description.strip(), state) + '\n\n') + if m.description is not None and m.description.strip() != "": + f.write(rstize_text(m.description.strip(), state) + "\n\n") index += 1 def make_class_list(class_list, columns): # type: (List[str], int) -> None # This function is no longer used. - f = open('class_list.rst', 'w', encoding='utf-8') + f = open("class_list.rst", "w", encoding="utf-8") col_max = len(class_list) // columns + 1 - print(('col max is ', col_max)) + print(("col max is ", col_max)) fit_columns = [] # type: List[List[str]] for _ in range(0, columns): fit_columns.append([]) indexers = [] # type List[str] - last_initial = '' + last_initial = "" for idx, name in enumerate(class_list): col = idx // col_max @@ -590,7 +602,7 @@ def make_class_list(class_list, columns): # type: (List[str], int) -> None f.write("\n") for r in range(0, row_max): - s = '+ ' + s = "+ " for c in range(0, columns): if r >= len(fit_columns[c]): continue @@ -598,13 +610,13 @@ def make_class_list(class_list, columns): # type: (List[str], int) -> None classname = fit_columns[c][r] initial = classname[0] if classname in indexers: - s += '**' + initial + '** | ' + s += "**" + initial + "** | " else: - s += ' | ' + s += " | " - s += '[' + classname + '](class_' + classname.lower() + ') | ' + s += "[" + classname + "](class_" + classname.lower() + ") | " - s += '\n' + s += "\n" f.write(s) for n in range(0, columns): @@ -618,29 +630,29 @@ def escape_rst(text, until_pos=-1): # type: (str) -> str # Escape \ character, otherwise it ends up as an escape character in rst pos = 0 while True: - pos = text.find('\\', pos, until_pos) + pos = text.find("\\", pos, until_pos) if pos == -1: break - text = text[:pos] + "\\\\" + text[pos + 1:] + text = text[:pos] + "\\\\" + text[pos + 1 :] pos += 2 # Escape * character to avoid interpreting it as emphasis pos = 0 while True: - pos = text.find('*', pos, until_pos) + pos = text.find("*", pos, until_pos) if pos == -1: break - text = text[:pos] + "\*" + text[pos + 1:] + text = text[:pos] + "\*" + text[pos + 1 :] pos += 2 # Escape _ character at the end of a word to avoid interpreting it as an inline hyperlink pos = 0 while True: - pos = text.find('_', pos, until_pos) + pos = text.find("_", pos, until_pos) if pos == -1: break if not text[pos + 1].isalnum(): # don't escape within a snake_case word - text = text[:pos] + "\_" + text[pos + 1:] + text = text[:pos] + "\_" + text[pos + 1 :] pos += 2 else: pos += 1 @@ -652,16 +664,16 @@ def rstize_text(text, state): # type: (str, State) -> str # Linebreak + tabs in the XML should become two line breaks unless in a "codeblock" pos = 0 while True: - pos = text.find('\n', pos) + pos = text.find("\n", pos) if pos == -1: break pre_text = text[:pos] indent_level = 0 - while text[pos + 1] == '\t': + while text[pos + 1] == "\t": pos += 1 indent_level += 1 - post_text = text[pos + 1:] + post_text = text[pos + 1 :] # Handle codeblocks if post_text.startswith("[codeblock]"): @@ -670,28 +682,33 @@ def rstize_text(text, state): # type: (str, State) -> str print_error("[codeblock] without a closing tag, file: {}".format(state.current_class), state) return "" - code_text = post_text[len("[codeblock]"):end_pos] + code_text = post_text[len("[codeblock]") : end_pos] post_text = post_text[end_pos:] # Remove extraneous tabs code_pos = 0 while True: - code_pos = code_text.find('\n', code_pos) + code_pos = code_text.find("\n", code_pos) if code_pos == -1: break to_skip = 0 - while code_pos + to_skip + 1 < len(code_text) and code_text[code_pos + to_skip + 1] == '\t': + while code_pos + to_skip + 1 < len(code_text) and code_text[code_pos + to_skip + 1] == "\t": to_skip += 1 if to_skip > indent_level: - print_error("Four spaces should be used for indentation within [codeblock], file: {}".format(state.current_class), state) - - if len(code_text[code_pos + to_skip + 1:]) == 0: + print_error( + "Four spaces should be used for indentation within [codeblock], file: {}".format( + state.current_class + ), + state, + ) + + if len(code_text[code_pos + to_skip + 1 :]) == 0: code_text = code_text[:code_pos] + "\n" code_pos += 1 else: - code_text = code_text[:code_pos] + "\n " + code_text[code_pos + to_skip + 1:] + code_text = code_text[:code_pos] + "\n " + code_text[code_pos + to_skip + 1 :] code_pos += 5 - to_skip text = pre_text + "\n[codeblock]" + code_text + post_text @@ -702,7 +719,7 @@ def rstize_text(text, state): # type: (str, State) -> str text = pre_text + "\n\n" + post_text pos += 2 - next_brac_pos = text.find('[') + next_brac_pos = text.find("[") text = escape_rst(text, next_brac_pos) # Handle [tags] @@ -714,54 +731,59 @@ def rstize_text(text, state): # type: (str, State) -> str tag_depth = 0 previous_pos = 0 while True: - pos = text.find('[', pos) + pos = text.find("[", pos) if inside_url and (pos > previous_pos): url_has_name = True if pos == -1: break - endq_pos = text.find(']', pos + 1) + endq_pos = text.find("]", pos + 1) if endq_pos == -1: break pre_text = text[:pos] - post_text = text[endq_pos + 1:] - tag_text = text[pos + 1:endq_pos] + post_text = text[endq_pos + 1 :] + tag_text = text[pos + 1 : endq_pos] escape_post = False if tag_text in state.classes: if tag_text == state.current_class: # We don't want references to the same class - tag_text = '``{}``'.format(tag_text) + tag_text = "``{}``".format(tag_text) else: tag_text = make_type(tag_text, state) escape_post = True else: # command cmd = tag_text - space_pos = tag_text.find(' ') - if cmd == '/codeblock': - tag_text = '' + space_pos = tag_text.find(" ") + if cmd == "/codeblock": + tag_text = "" tag_depth -= 1 inside_code = False # Strip newline if the tag was alone on one - if pre_text[-1] == '\n': + if pre_text[-1] == "\n": pre_text = pre_text[:-1] - elif cmd == '/code': - tag_text = '``' + elif cmd == "/code": + tag_text = "``" tag_depth -= 1 inside_code = False escape_post = True elif inside_code: - tag_text = '[' + tag_text + ']' - elif cmd.find('html') == 0: - param = tag_text[space_pos + 1:] + tag_text = "[" + tag_text + "]" + elif cmd.find("html") == 0: + param = tag_text[space_pos + 1 :] tag_text = param - elif cmd.startswith('method') or cmd.startswith('member') or cmd.startswith('signal') or cmd.startswith('constant'): - param = tag_text[space_pos + 1:] - - if param.find('.') != -1: - ss = param.split('.') + elif ( + cmd.startswith("method") + or cmd.startswith("member") + or cmd.startswith("signal") + or cmd.startswith("constant") + ): + param = tag_text[space_pos + 1 :] + + if param.find(".") != -1: + ss = param.split(".") if len(ss) > 2: print_error("Bad reference: '{}', file: {}".format(param, state.current_class), state) class_param, method_param = ss @@ -794,7 +816,7 @@ def rstize_text(text, state): # type: (str, State) -> str # Search in the current class search_class_defs = [class_def] - if param.find('.') == -1: + if param.find(".") == -1: # Also search in @GlobalScope as a last resort if no class was specified search_class_defs.append(state.classes["@GlobalScope"]) @@ -815,66 +837,71 @@ def rstize_text(text, state): # type: (str, State) -> str ref_type = "_constant" else: - print_error("Unresolved type reference '{}' in method reference '{}', file: {}".format(class_param, param, state.current_class), state) + print_error( + "Unresolved type reference '{}' in method reference '{}', file: {}".format( + class_param, param, state.current_class + ), + state, + ) repl_text = method_param if class_param != state.current_class: repl_text = "{}.{}".format(class_param, method_param) - tag_text = ':ref:`{}<class_{}{}_{}>`'.format(repl_text, class_param, ref_type, method_param) + tag_text = ":ref:`{}<class_{}{}_{}>`".format(repl_text, class_param, ref_type, method_param) escape_post = True - elif cmd.find('image=') == 0: + elif cmd.find("image=") == 0: tag_text = "" # '' - elif cmd.find('url=') == 0: + elif cmd.find("url=") == 0: url_link = cmd[4:] - tag_text = '`' + tag_text = "`" tag_depth += 1 inside_url = True url_has_name = False - elif cmd == '/url': - tag_text = ('' if url_has_name else url_link) + " <" + url_link + ">`_" + elif cmd == "/url": + tag_text = ("" if url_has_name else url_link) + " <" + url_link + ">`_" tag_depth -= 1 escape_post = True inside_url = False url_has_name = False - elif cmd == 'center': + elif cmd == "center": tag_depth += 1 - tag_text = '' - elif cmd == '/center': + tag_text = "" + elif cmd == "/center": tag_depth -= 1 - tag_text = '' - elif cmd == 'codeblock': + tag_text = "" + elif cmd == "codeblock": tag_depth += 1 - tag_text = '\n::\n' + tag_text = "\n::\n" inside_code = True - elif cmd == 'br': + elif cmd == "br": # Make a new paragraph instead of a linebreak, rst is not so linebreak friendly - tag_text = '\n\n' + tag_text = "\n\n" # Strip potential leading spaces - while post_text[0] == ' ': + while post_text[0] == " ": post_text = post_text[1:] - elif cmd == 'i' or cmd == '/i': + elif cmd == "i" or cmd == "/i": if cmd == "/i": tag_depth -= 1 else: tag_depth += 1 - tag_text = '*' - elif cmd == 'b' or cmd == '/b': + tag_text = "*" + elif cmd == "b" or cmd == "/b": if cmd == "/b": tag_depth -= 1 else: tag_depth += 1 - tag_text = '**' - elif cmd == 'u' or cmd == '/u': + tag_text = "**" + elif cmd == "u" or cmd == "/u": if cmd == "/u": tag_depth -= 1 else: tag_depth += 1 - tag_text = '' - elif cmd == 'code': - tag_text = '``' + tag_text = "" + elif cmd == "code": + tag_text = "``" tag_depth += 1 inside_code = True - elif cmd.startswith('enum '): + elif cmd.startswith("enum "): tag_text = make_enum(cmd[5:], state) escape_post = True else: @@ -883,24 +910,24 @@ def rstize_text(text, state): # type: (str, State) -> str # Properly escape things like `[Node]s` if escape_post and post_text and (post_text[0].isalnum() or post_text[0] == "("): # not punctuation, escape - post_text = '\ ' + post_text + post_text = "\ " + post_text - next_brac_pos = post_text.find('[', 0) + next_brac_pos = post_text.find("[", 0) iter_pos = 0 while not inside_code: - iter_pos = post_text.find('*', iter_pos, next_brac_pos) + iter_pos = post_text.find("*", iter_pos, next_brac_pos) if iter_pos == -1: break - post_text = post_text[:iter_pos] + "\*" + post_text[iter_pos + 1:] + post_text = post_text[:iter_pos] + "\*" + post_text[iter_pos + 1 :] iter_pos += 2 iter_pos = 0 while not inside_code: - iter_pos = post_text.find('_', iter_pos, next_brac_pos) + iter_pos = post_text.find("_", iter_pos, next_brac_pos) if iter_pos == -1: break if not post_text[iter_pos + 1].isalnum(): # don't escape within a snake_case word - post_text = post_text[:iter_pos] + "\_" + post_text[iter_pos + 1:] + post_text = post_text[:iter_pos] + "\_" + post_text[iter_pos + 1 :] iter_pos += 2 else: iter_pos += 1 @@ -922,7 +949,7 @@ def format_table(f, data, remove_empty_columns=False): # type: (TextIO, Iterabl column_sizes = [0] * len(data[0]) for row in data: for i, text in enumerate(row): - text_length = len(text or '') + text_length = len(text or "") if text_length > column_sizes[i]: column_sizes[i] = text_length @@ -939,16 +966,16 @@ def format_table(f, data, remove_empty_columns=False): # type: (TextIO, Iterabl for i, text in enumerate(row): if column_sizes[i] == 0 and remove_empty_columns: continue - row_text += " " + (text or '').ljust(column_sizes[i]) + " |" + row_text += " " + (text or "").ljust(column_sizes[i]) + " |" row_text += "\n" f.write(row_text) f.write(sep) - f.write('\n') + f.write("\n") def make_type(t, state): # type: (str, State) -> str if t in state.classes: - return ':ref:`{0}<class_{0}>`'.format(t) + return ":ref:`{0}<class_{0}>`".format(t) print_error("Unresolved type '{}', file: {}".format(t, state.current_class), state) return t @@ -957,7 +984,7 @@ def make_enum(t, state): # type: (str, State) -> str p = t.find(".") if p >= 0: c = t[0:p] - e = t[p + 1:] + e = t[p + 1 :] # Variant enums live in GlobalScope but still use periods. if c == "Variant": c = "@GlobalScope" @@ -969,7 +996,7 @@ def make_enum(t, state): # type: (str, State) -> str c = "@GlobalScope" if not c in state.classes and c.startswith("_"): - c = c[1:] # Remove the underscore prefix + c = c[1:] # Remove the underscore prefix if c in state.classes and e in state.classes[c].enums: return ":ref:`{0}<enum_{1}_{0}>`".format(e, c) @@ -981,7 +1008,9 @@ def make_enum(t, state): # type: (str, State) -> str return t -def make_method_signature(class_def, method_def, make_ref, state): # type: (ClassDef, Union[MethodDef, SignalDef], bool, State) -> Tuple[str, str] +def make_method_signature( + class_def, method_def, make_ref, state +): # type: (ClassDef, Union[MethodDef, SignalDef], bool, State) -> Tuple[str, str] ret_type = " " ref_type = "signal" @@ -996,34 +1025,34 @@ def make_method_signature(class_def, method_def, make_ref, state): # type: (Cla else: out += "**{}** ".format(method_def.name) - out += '**(**' + out += "**(**" for i, arg in enumerate(method_def.parameters): if i > 0: - out += ', ' + out += ", " else: - out += ' ' + out += " " out += "{} {}".format(arg.type_name.to_rst(state), arg.name) if arg.default_value is not None: - out += '=' + arg.default_value + out += "=" + arg.default_value - if isinstance(method_def, MethodDef) and method_def.qualifiers is not None and 'vararg' in method_def.qualifiers: + if isinstance(method_def, MethodDef) and method_def.qualifiers is not None and "vararg" in method_def.qualifiers: if len(method_def.parameters) > 0: - out += ', ...' + out += ", ..." else: - out += ' ...' + out += " ..." - out += ' **)**' + out += " **)**" if isinstance(method_def, MethodDef) and method_def.qualifiers is not None: - out += ' ' + method_def.qualifiers + out += " " + method_def.qualifiers return ret_type, out def make_heading(title, underline): # type: (str, str) -> str - return title + '\n' + (underline * len(title)) + "\n\n" + return title + "\n" + (underline * len(title)) + "\n\n" def make_url(link): # type: (str) -> str @@ -1047,5 +1076,5 @@ def make_url(link): # type: (str) -> str return "`" + link + " <" + link + ">`_" -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/doc/translations/extract.py b/doc/translations/extract.py index cd06e13dda..a65f942b92 100644 --- a/doc/translations/extract.py +++ b/doc/translations/extract.py @@ -7,7 +7,7 @@ import shutil from collections import OrderedDict EXTRACT_TAGS = ["description", "brief_description", "member", "constant", "theme_item", "link"] -HEADER = '''\ +HEADER = """\ # LANGUAGE translation of the Godot Engine class reference. # Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. # Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). @@ -24,7 +24,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\\n" "Content-Transfer-Encoding: 8-bit\\n" -''' +""" # Some strings used by makerst.py are normally part of the editor translations, # so we need to include them manually here for the online docs. BASE_STRINGS = [ @@ -42,7 +42,8 @@ BASE_STRINGS = [ ## <xml-line-number-hack from="https://stackoverflow.com/a/36430270/10846399"> import sys -sys.modules['_elementtree'] = None + +sys.modules["_elementtree"] = None import xml.etree.ElementTree as ET ## override the parser to get the line number @@ -62,8 +63,11 @@ class LineNumberingParser(ET.XMLParser): element._end_column_number = self.parser.CurrentColumnNumber element._end_byte_index = self.parser.CurrentByteIndex return element + + ## </xml-line-number-hack> + class Desc: def __init__(self, line_no, msg, desc_list=None): ## line_no : the line number where the desc is @@ -73,6 +77,7 @@ class Desc: self.msg = msg self.desc_list = desc_list + class DescList: def __init__(self, doc, path): ## doc : root xml element of the document @@ -82,29 +87,32 @@ class DescList: self.path = path self.list = [] + def print_error(error): print("ERROR: {}".format(error)) + ## build classes with xml elements recursively def _collect_classes_dir(path, classes): if not os.path.isdir(path): print_error("Invalid directory path: {}".format(path)) exit(1) - for _dir in map(lambda dir : os.path.join(path, dir), os.listdir(path)): + for _dir in map(lambda dir: os.path.join(path, dir), os.listdir(path)): if os.path.isdir(_dir): _collect_classes_dir(_dir, classes) elif os.path.isfile(_dir): if not _dir.endswith(".xml"): - #print("Got non-.xml file '{}', skipping.".format(path)) + # print("Got non-.xml file '{}', skipping.".format(path)) continue _collect_classes_file(_dir, classes) + ## opens a file and parse xml add to classes def _collect_classes_file(path, classes): if not os.path.isfile(path) or not path.endswith(".xml"): print_error("Invalid xml file path: {}".format(path)) exit(1) - print('Collecting file: {}'.format(os.path.basename(path))) + print("Collecting file: {}".format(os.path.basename(path))) try: tree = ET.parse(path, parser=LineNumberingParser()) @@ -114,8 +122,8 @@ def _collect_classes_file(path, classes): doc = tree.getroot() - if 'name' in doc.attrib: - if 'version' not in doc.attrib: + if "name" in doc.attrib: + if "version" not in doc.attrib: print_error("Version missing from 'doc', file: {}".format(path)) name = doc.attrib["name"] @@ -124,7 +132,7 @@ def _collect_classes_file(path, classes): exit(1) classes[name] = DescList(doc, path) else: - print_error('Unknown XML file {}, skipping'.format(path)) + print_error("Unknown XML file {}, skipping".format(path)) ## regions are list of tuples with size 3 (start_index, end_index, indent) @@ -132,56 +140,64 @@ def _collect_classes_file(path, classes): ## if i inside the region returns the indent, else returns -1 def _get_xml_indent(i, regions): for region in regions: - if region[0] < i < region[1] : + if region[0] < i < region[1]: return region[2] return -1 + ## find and build all regions of codeblock which we need later -def _make_codeblock_regions(desc, path=''): +def _make_codeblock_regions(desc, path=""): code_block_end = False code_block_index = 0 code_block_regions = [] while not code_block_end: code_block_index = desc.find("[codeblock]", code_block_index) - if code_block_index < 0: break - xml_indent=0 - while True : + if code_block_index < 0: + break + xml_indent = 0 + while True: ## [codeblock] always have a trailing new line and some tabs ## those tabs are belongs to xml indentations not code indent - if desc[code_block_index+len("[codeblock]\n")+xml_indent] == '\t': - xml_indent+=1 - else: break + if desc[code_block_index + len("[codeblock]\n") + xml_indent] == "\t": + xml_indent += 1 + else: + break end_index = desc.find("[/codeblock]", code_block_index) - if end_index < 0 : - print_error('Non terminating codeblock: {}'.format(path)) + if end_index < 0: + print_error("Non terminating codeblock: {}".format(path)) exit(1) - code_block_regions.append( (code_block_index, end_index, xml_indent) ) + code_block_regions.append((code_block_index, end_index, xml_indent)) code_block_index += 1 return code_block_regions + def _strip_and_split_desc(desc, code_block_regions): - desc_strip = '' ## a stripped desc msg + desc_strip = "" ## a stripped desc msg total_indent = 0 ## code indent = total indent - xml indent for i in range(len(desc)): c = desc[i] - if c == '\n' : c = '\\n' - if c == '"': c = '\\"' - if c == '\\': c = '\\\\' ## <element \> is invalid for msgmerge - if c == '\t': + if c == "\n": + c = "\\n" + if c == '"': + c = '\\"' + if c == "\\": + c = "\\\\" ## <element \> is invalid for msgmerge + if c == "\t": xml_indent = _get_xml_indent(i, code_block_regions) if xml_indent >= 0: total_indent += 1 if xml_indent < total_indent: - c = '\\t' + c = "\\t" else: continue else: continue desc_strip += c - if c == '\\n': + if c == "\\n": total_indent = 0 return desc_strip + ## make catalog strings from xml elements def _make_translation_catalog(classes): unique_msgs = OrderedDict() @@ -189,8 +205,9 @@ def _make_translation_catalog(classes): desc_list = classes[class_name] for elem in desc_list.doc.iter(): if elem.tag in EXTRACT_TAGS: - if not elem.text or len(elem.text) == 0 : continue - line_no = elem._start_line_number if elem.text[0]!='\n' else elem._start_line_number+1 + if not elem.text or len(elem.text) == 0: + continue + line_no = elem._start_line_number if elem.text[0] != "\n" else elem._start_line_number + 1 desc_str = elem.text.strip() code_block_regions = _make_codeblock_regions(desc_str, desc_list.path) desc_msg = _strip_and_split_desc(desc_str, code_block_regions) @@ -203,44 +220,48 @@ def _make_translation_catalog(classes): unique_msgs[desc_msg].append(desc_obj) return unique_msgs + ## generate the catalog file def _generate_translation_catalog_file(unique_msgs, output): - with open(output, 'w', encoding='utf8') as f: + with open(output, "w", encoding="utf8") as f: f.write(HEADER) for msg in BASE_STRINGS: - f.write('#: doc/tools/makerst.py\n') + f.write("#: doc/tools/makerst.py\n") f.write('msgid "{}"\n'.format(msg)) f.write('msgstr ""\n\n') for msg in unique_msgs: if len(msg) == 0 or msg in BASE_STRINGS: continue - f.write('#:') + f.write("#:") desc_list = unique_msgs[msg] for desc in desc_list: - path = desc.desc_list.path.replace('\\', '/') - if path.startswith('./'): + path = desc.desc_list.path.replace("\\", "/") + if path.startswith("./"): path = path[2:] - f.write(' {}:{}'.format(path, desc.line_no)) - f.write('\n') + f.write(" {}:{}".format(path, desc.line_no)) + f.write("\n") f.write('msgid "{}"\n'.format(msg)) f.write('msgstr ""\n\n') ## TODO: what if 'nt'? - if (os.name == "posix"): + if os.name == "posix": print("Wrapping template at 79 characters for compatibility with Weblate.") os.system("msgmerge -w79 {0} {0} > {0}.wrap".format(output)) shutil.move("{}.wrap".format(output), output) + def main(): parser = argparse.ArgumentParser() - parser.add_argument("--path", "-p", nargs="+", default=".", help="The directory or directories containing XML files to collect.") + parser.add_argument( + "--path", "-p", nargs="+", default=".", help="The directory or directories containing XML files to collect." + ) parser.add_argument("--output", "-o", default="translation_catalog.pot", help="The path to the output file.") args = parser.parse_args() output = os.path.abspath(args.output) - if not os.path.isdir(os.path.dirname(output)) or not output.endswith('.pot'): + if not os.path.isdir(os.path.dirname(output)) or not output.endswith(".pot"): print_error("Invalid output path: {}".format(output)) exit(1) @@ -252,13 +273,14 @@ def main(): print("\nCurrent working dir: {}".format(path)) - path_classes = OrderedDict() ## dictionary of key=class_name, value=DescList objects + path_classes = OrderedDict() ## dictionary of key=class_name, value=DescList objects _collect_classes_dir(path, path_classes) classes.update(path_classes) - classes = OrderedDict(sorted(classes.items(), key = lambda kv: kv[0].lower())) + classes = OrderedDict(sorted(classes.items(), key=lambda kv: kv[0].lower())) unique_msgs = _make_translation_catalog(classes) _generate_translation_catalog_file(unique_msgs, output) -if __name__ == '__main__': + +if __name__ == "__main__": main() diff --git a/drivers/SCsub b/drivers/SCsub index 41c20d81ad..cc7bcbc640 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -1,41 +1,42 @@ #!/usr/bin/env python -Import('env') +Import("env") env.drivers_sources = [] # OS drivers -SConscript('unix/SCsub') -SConscript('windows/SCsub') +SConscript("unix/SCsub") +SConscript("windows/SCsub") # Sounds drivers -SConscript('alsa/SCsub') -SConscript('coreaudio/SCsub') -SConscript('pulseaudio/SCsub') -if (env["platform"] == "windows"): +SConscript("alsa/SCsub") +SConscript("coreaudio/SCsub") +SConscript("pulseaudio/SCsub") +if env["platform"] == "windows": SConscript("wasapi/SCsub") -if env['xaudio2']: +if env["xaudio2"]: SConscript("xaudio2/SCsub") # Midi drivers -SConscript('alsamidi/SCsub') -SConscript('coremidi/SCsub') -SConscript('winmidi/SCsub') +SConscript("alsamidi/SCsub") +SConscript("coremidi/SCsub") +SConscript("winmidi/SCsub") # Graphics drivers -if (env["platform"] != "server" and env["platform"] != "javascript"): -# SConscript('gles2/SCsub') - SConscript('vulkan/SCsub') - SConscript('gl_context/SCsub') +if env["platform"] != "server" and env["platform"] != "javascript": + # SConscript('gles2/SCsub') + SConscript("vulkan/SCsub") + SConscript("gl_context/SCsub") else: - SConscript('dummy/SCsub') + SConscript("dummy/SCsub") # Core dependencies SConscript("png/SCsub") SConscript("spirv-reflect/SCsub") -if env['vsproj']: +if env["vsproj"]: import os + path = os.getcwd() # Change directory so the path resolves correctly in the function call. os.chdir("..") diff --git a/drivers/alsa/SCsub b/drivers/alsa/SCsub index 28b315ae66..91e1140b75 100644 --- a/drivers/alsa/SCsub +++ b/drivers/alsa/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 400ce31bf7..48e694dd3a 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -60,7 +60,7 @@ Error AudioDriverALSA::init_device() { fprintf(stderr, "ALSA ERR: %s\n", snd_strerror(status)); \ if (pcm_handle) { \ snd_pcm_close(pcm_handle); \ - pcm_handle = NULL; \ + pcm_handle = nullptr; \ } \ ERR_FAIL_COND_V(m_cond, ERR_CANT_OPEN); \ } @@ -98,7 +98,7 @@ Error AudioDriverALSA::init_device() { status = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, 2); CHECK_FAIL(status < 0); - status = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &mix_rate, NULL); + status = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &mix_rate, nullptr); CHECK_FAIL(status < 0); // In ALSA the period size seems to be the one that will determine the actual latency @@ -113,12 +113,12 @@ Error AudioDriverALSA::init_device() { status = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &buffer_size); CHECK_FAIL(status < 0); - status = snd_pcm_hw_params_set_period_size_near(pcm_handle, hwparams, &period_size, NULL); + status = snd_pcm_hw_params_set_period_size_near(pcm_handle, hwparams, &period_size, nullptr); CHECK_FAIL(status < 0); print_verbose("Audio buffer frames: " + itos(period_size) + " calculated latency: " + itos(period_size * 1000 / mix_rate) + "ms"); - status = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &periods, NULL); + status = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &periods, nullptr); CHECK_FAIL(status < 0); status = snd_pcm_hw_params(pcm_handle, hwparams); @@ -262,11 +262,11 @@ Array AudioDriverALSA::get_device_list() { if (snd_device_name_hint(-1, "pcm", &hints) < 0) return list; - for (void **n = hints; *n != NULL; n++) { + for (void **n = hints; *n != nullptr; n++) { char *name = snd_device_name_get_hint(*n, "NAME"); char *desc = snd_device_name_get_hint(*n, "DESC"); - if (name != NULL && !strncmp(name, "plughw", 6)) { + if (name != nullptr && !strncmp(name, "plughw", 6)) { if (desc) { list.push_back(String(name) + ";" + String(desc)); } else { @@ -274,9 +274,9 @@ Array AudioDriverALSA::get_device_list() { } } - if (desc != NULL) + if (desc != nullptr) free(desc); - if (name != NULL) + if (name != nullptr) free(name); } snd_device_name_free_hint(hints); @@ -314,7 +314,7 @@ void AudioDriverALSA::finish_device() { if (pcm_handle) { snd_pcm_close(pcm_handle); - pcm_handle = NULL; + pcm_handle = nullptr; } } @@ -325,15 +325,15 @@ void AudioDriverALSA::finish() { Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } finish_device(); } AudioDriverALSA::AudioDriverALSA() : - thread(NULL), - pcm_handle(NULL), + thread(nullptr), + pcm_handle(nullptr), device_name("Default"), new_device("Default") { } diff --git a/drivers/alsamidi/SCsub b/drivers/alsamidi/SCsub index 4c24925192..4e1b5f2a36 100644 --- a/drivers/alsamidi/SCsub +++ b/drivers/alsamidi/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/alsamidi/midi_driver_alsamidi.cpp b/drivers/alsamidi/midi_driver_alsamidi.cpp index 0cecf1de3e..e3e54ea267 100644 --- a/drivers/alsamidi/midi_driver_alsamidi.cpp +++ b/drivers/alsamidi/midi_driver_alsamidi.cpp @@ -132,18 +132,18 @@ Error MIDIDriverALSAMidi::open() { return ERR_CANT_OPEN; int i = 0; - for (void **n = hints; *n != NULL; n++) { + for (void **n = hints; *n != nullptr; n++) { char *name = snd_device_name_get_hint(*n, "NAME"); - if (name != NULL) { + if (name != nullptr) { snd_rawmidi_t *midi_in; - int ret = snd_rawmidi_open(&midi_in, NULL, name, SND_RAWMIDI_NONBLOCK); + int ret = snd_rawmidi_open(&midi_in, nullptr, name, SND_RAWMIDI_NONBLOCK); if (ret >= 0) { connected_inputs.insert(i++, midi_in); } } - if (name != NULL) + if (name != nullptr) free(name); } snd_device_name_free_hint(hints); @@ -161,7 +161,7 @@ void MIDIDriverALSAMidi::close() { Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } for (int i = 0; i < connected_inputs.size(); i++) { @@ -202,7 +202,7 @@ PackedStringArray MIDIDriverALSAMidi::get_connected_inputs() { MIDIDriverALSAMidi::MIDIDriverALSAMidi() { - thread = NULL; + thread = nullptr; exit_thread = false; } diff --git a/drivers/coreaudio/SCsub b/drivers/coreaudio/SCsub index 4c24925192..4e1b5f2a36 100644 --- a/drivers/coreaudio/SCsub +++ b/drivers/coreaudio/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index 1e95bcf5d9..21c3649445 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -79,8 +79,8 @@ Error AudioDriverCoreAudio::init() { #endif desc.componentManufacturer = kAudioUnitManufacturer_Apple; - AudioComponent comp = AudioComponentFindNext(NULL, &desc); - ERR_FAIL_COND_V(comp == NULL, FAILED); + AudioComponent comp = AudioComponentFindNext(nullptr, &desc); + ERR_FAIL_COND_V(comp == nullptr, FAILED); OSStatus result = AudioComponentInstanceNew(comp, &audio_unit); ERR_FAIL_COND_V(result != noErr, FAILED); @@ -335,7 +335,7 @@ void AudioDriverCoreAudio::finish() { ERR_PRINT("AudioComponentInstanceDispose failed"); } - audio_unit = NULL; + audio_unit = nullptr; unlock(); } } @@ -351,8 +351,8 @@ Error AudioDriverCoreAudio::capture_init() { #endif desc.componentManufacturer = kAudioUnitManufacturer_Apple; - AudioComponent comp = AudioComponentFindNext(NULL, &desc); - ERR_FAIL_COND_V(comp == NULL, FAILED); + AudioComponent comp = AudioComponentFindNext(nullptr, &desc); + ERR_FAIL_COND_V(comp == nullptr, FAILED); OSStatus result = AudioComponentInstanceNew(comp, &input_unit); ERR_FAIL_COND_V(result != noErr, FAILED); @@ -380,7 +380,7 @@ Error AudioDriverCoreAudio::capture_init() { size = sizeof(AudioDeviceID); AudioObjectPropertyAddress property = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; - result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, NULL, &size, &deviceId); + result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId); ERR_FAIL_COND_V(result != noErr, FAILED); result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID)); @@ -469,7 +469,7 @@ void AudioDriverCoreAudio::capture_finish() { ERR_PRINT("AudioComponentInstanceDispose failed"); } - input_unit = NULL; + input_unit = nullptr; unlock(); } } @@ -513,18 +513,18 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) { prop.mElement = kAudioObjectPropertyElementMaster; UInt32 size = 0; - AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, NULL, &size); + AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size); AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size); - AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &size, audioDevices); + AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, nullptr, &size, audioDevices); UInt32 deviceCount = size / sizeof(AudioDeviceID); for (UInt32 i = 0; i < deviceCount; i++) { prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; prop.mSelector = kAudioDevicePropertyStreamConfiguration; - AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, NULL, &size); + AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size); AudioBufferList *bufferList = (AudioBufferList *)malloc(size); - AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, bufferList); + AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList); UInt32 channelCount = 0; for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) @@ -538,7 +538,7 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) { size = sizeof(CFStringRef); prop.mSelector = kAudioObjectPropertyName; - AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, &cfname); + AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, &cfname); CFIndex length = CFStringGetLength(cfname); CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; @@ -569,18 +569,18 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) { prop.mElement = kAudioObjectPropertyElementMaster; UInt32 size = 0; - AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, NULL, &size); + AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size); AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size); - AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &size, audioDevices); + AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, nullptr, &size, audioDevices); UInt32 deviceCount = size / sizeof(AudioDeviceID); for (UInt32 i = 0; i < deviceCount && !found; i++) { prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput; prop.mSelector = kAudioDevicePropertyStreamConfiguration; - AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, NULL, &size); + AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size); AudioBufferList *bufferList = (AudioBufferList *)malloc(size); - AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, bufferList); + AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList); UInt32 channelCount = 0; for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++) @@ -594,7 +594,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) { size = sizeof(CFStringRef); prop.mSelector = kAudioObjectPropertyName; - AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, &cfname); + AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, &cfname); CFIndex length = CFStringGetLength(cfname); CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; @@ -620,7 +620,7 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) { UInt32 elem = capture ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice; AudioObjectPropertyAddress property = { elem, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; - OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, NULL, &size, &deviceId); + OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId); ERR_FAIL_COND(result != noErr); found = true; @@ -677,8 +677,8 @@ String AudioDriverCoreAudio::capture_get_device() { #endif AudioDriverCoreAudio::AudioDriverCoreAudio() : - audio_unit(NULL), - input_unit(NULL), + audio_unit(nullptr), + input_unit(nullptr), active(false), device_name("Default"), capture_device_name("Default"), diff --git a/drivers/coremidi/SCsub b/drivers/coremidi/SCsub index 4c24925192..4e1b5f2a36 100644 --- a/drivers/coremidi/SCsub +++ b/drivers/coremidi/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/coremidi/midi_driver_coremidi.cpp b/drivers/coremidi/midi_driver_coremidi.cpp index d807896e61..2cd322813b 100644 --- a/drivers/coremidi/midi_driver_coremidi.cpp +++ b/drivers/coremidi/midi_driver_coremidi.cpp @@ -47,8 +47,8 @@ void MIDIDriverCoreMidi::read(const MIDIPacketList *packet_list, void *read_proc Error MIDIDriverCoreMidi::open() { - CFStringRef name = CFStringCreateWithCString(NULL, "Godot", kCFStringEncodingASCII); - OSStatus result = MIDIClientCreate(name, NULL, NULL, &client); + CFStringRef name = CFStringCreateWithCString(nullptr, "Godot", kCFStringEncodingASCII); + OSStatus result = MIDIClientCreate(name, nullptr, nullptr, &client); CFRelease(name); if (result != noErr) { ERR_PRINT("MIDIClientCreate failed, code: " + itos(result)); @@ -99,7 +99,7 @@ PackedStringArray MIDIDriverCoreMidi::get_connected_inputs() { for (int i = 0; i < connected_sources.size(); i++) { MIDIEndpointRef source = connected_sources[i]; - CFStringRef ref = NULL; + CFStringRef ref = nullptr; char name[256]; MIDIObjectGetStringProperty(source, kMIDIPropertyDisplayName, &ref); diff --git a/drivers/dummy/SCsub b/drivers/dummy/SCsub index 28b315ae66..91e1140b75 100644 --- a/drivers/dummy/SCsub +++ b/drivers/dummy/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index b446828128..0bcfed2dcf 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -35,8 +35,8 @@ #include "core/rid_owner.h" #include "core/self_list.h" #include "scene/resources/mesh.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" class RasterizerSceneDummy : public RasterizerScene { public: @@ -55,7 +55,7 @@ public: RID sky_create() { return RID(); } void sky_set_radiance_size(RID p_sky, int p_radiance_size) {} - void sky_set_mode(RID p_sky, VS::SkyMode p_samples) {} + void sky_set_mode(RID p_sky, RS::SkyMode p_samples) {} void sky_set_texture(RID p_sky, RID p_panorama) {} void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {} void sky_set_material(RID p_sky, RID p_material) {} @@ -64,28 +64,28 @@ public: RID environment_create() { return RID(); } - void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) {} + void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {} void environment_set_sky(RID p_env, RID p_sky) {} void environment_set_sky_custom_fov(RID p_env, float p_scale) {} void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {} void environment_set_bg_color(RID p_env, const Color &p_color) {} void environment_set_bg_energy(RID p_env, float p_energy) {} void environment_set_canvas_max_layer(RID p_env, int p_max_layer) {} - void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) {} + void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) {} // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) {} #endif - void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) {} + void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {} void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {} void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {} - virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {} - virtual void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) {} + virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) {} + virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) {} - void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {} + void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {} void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {} @@ -94,13 +94,13 @@ public: void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) {} bool is_environment(RID p_env) const { return false; } - VS::EnvironmentBG environment_get_background(RID p_env) const { return VS::ENV_BG_KEEP; } + RS::EnvironmentBG environment_get_background(RID p_env) const { return RS::ENV_BG_KEEP; } int environment_get_canvas_max_layer(RID p_env) const { return 0; } virtual RID camera_effects_create() { return RID(); } - virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) {} - virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) {} + virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {} + virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {} virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {} virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {} @@ -133,10 +133,10 @@ public: void set_scene_pass(uint64_t p_pass) {} virtual void set_time(double p_time, double p_step) {} - void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) {} + void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {} virtual RID render_buffers_create() { return RID(); } - virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) {} + virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) {} virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_curve) {} virtual bool screen_space_roughness_limiter_is_active() const { return false; } @@ -162,7 +162,7 @@ public: struct DummySurface { uint32_t format; - VS::PrimitiveType primitive; + RS::PrimitiveType primitive; Vector<uint8_t> array; int vertex_count; Vector<uint8_t> index_array; @@ -175,14 +175,14 @@ public: struct DummyMesh { Vector<DummySurface> surfaces; int blend_shape_count; - VS::BlendShapeMode blend_shape_mode; + RS::BlendShapeMode blend_shape_mode; }; mutable RID_PtrOwner<DummyTexture> texture_owner; mutable RID_PtrOwner<DummyMesh> mesh_owner; virtual RID texture_2d_create(const Ref<Image> &p_image) { return RID(); } - virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) { return RID(); } + virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) { return RID(); } virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return RID(); } virtual RID texture_proxy_create(RID p_base) { return RID(); } @@ -209,11 +209,11 @@ public: virtual void texture_set_path(RID p_texture, const String &p_path) {} virtual String texture_get_path(RID p_texture) const { return String(); } - virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {} - virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) {} - virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {} + virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {} + virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) {} + virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) {} - virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) {} + virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) {} virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {} virtual Size2 texture_size_with_proxy(RID p_proxy) { return Size2(); } @@ -225,7 +225,7 @@ public: return texture_owner.make_rid(texture); } - void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VisualServer::TextureType p_type = VS::TEXTURE_TYPE_2D, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) { + void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingServer::TextureType p_type = RS::TEXTURE_TYPE_2D, uint32_t p_flags = RS::TEXTURE_FLAGS_DEFAULT) { DummyTexture *t = texture_owner.getornull(p_texture); ERR_FAIL_COND(!t); t->width = p_width; @@ -278,7 +278,7 @@ public: return t->format; } - VisualServer::TextureType texture_get_type(RID p_texture) const { return VS::TEXTURE_TYPE_2D; } + RenderingServer::TextureType texture_get_type(RID p_texture) const { return RS::TEXTURE_TYPE_2D; } uint32_t texture_get_texid(RID p_texture) const { return 0; } uint32_t texture_get_width(RID p_texture) const { return 0; } uint32_t texture_get_height(RID p_texture) const { return 0; } @@ -299,13 +299,13 @@ public: void texture_set_shrink_all_x2_on_set_data(bool p_enable) {} - void texture_debug_usage(List<VS::TextureInfo> *r_info) {} + void texture_debug_usage(List<RS::TextureInfo> *r_info) {} RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const { return RID(); } - void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {} - void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {} - void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) {} + void texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {} + void texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {} + void texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) {} void textures_keep_original(bool p_enable) {} @@ -353,14 +353,14 @@ public: DummyMesh *mesh = memnew(DummyMesh); ERR_FAIL_COND_V(!mesh, RID()); mesh->blend_shape_count = 0; - mesh->blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED; + mesh->blend_shape_mode = RS::BLEND_SHAPE_MODE_NORMALIZED; return mesh_owner.make_rid(mesh); } - void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) {} + void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) {} #if 0 - void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) { + void mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t> > &p_blend_shapes = Vector<Vector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) { DummyMesh *m = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!m); @@ -390,14 +390,14 @@ public: return m->blend_shape_count; } - void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) { + void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) { DummyMesh *m = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!m); m->blend_shape_mode = p_mode; } - VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const { + RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const { DummyMesh *m = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!m, VS::BLEND_SHAPE_MODE_NORMALIZED); + ERR_FAIL_COND_V(!m, RS::BLEND_SHAPE_MODE_NORMALIZED); return m->blend_shape_mode; } @@ -439,9 +439,9 @@ public: return m->surfaces[p_surface].format; } - VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { + RS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { DummyMesh *m = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!m, VS::PRIMITIVE_POINTS); + ERR_FAIL_COND_V(!m, RS::PRIMITIVE_POINTS); return m->surfaces[p_surface].primitive; } @@ -474,7 +474,7 @@ public: } #endif - VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const { return VS::SurfaceData(); } + RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const { return RS::SurfaceData(); } int mesh_get_surface_count(RID p_mesh) const { DummyMesh *m = mesh_owner.getornull(p_mesh); ERR_FAIL_COND_V(!m, 0); @@ -491,7 +491,7 @@ public: virtual RID multimesh_create() { return RID(); } - virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) {} + virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) {} int multimesh_get_instance_count(RID p_multimesh) const { return 0; } void multimesh_set_mesh(RID p_multimesh, RID p_mesh) {} @@ -516,7 +516,7 @@ public: /* IMMEDIATE API */ RID immediate_create() { return RID(); } - void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) {} + void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {} void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {} void immediate_normal(RID p_immediate, const Vector3 &p_normal) {} void immediate_tangent(RID p_immediate, const Plane &p_tangent) {} @@ -543,14 +543,14 @@ public: /* Light API */ - RID light_create(VS::LightType p_type) { return RID(); } + RID light_create(RS::LightType p_type) { return RID(); } - RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); } - RID omni_light_create() { return light_create(VS::LIGHT_OMNI); } - RID spot_light_create() { return light_create(VS::LIGHT_SPOT); } + RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); } + RID omni_light_create() { return light_create(RS::LIGHT_OMNI); } + RID spot_light_create() { return light_create(RS::LIGHT_SPOT); } void light_set_color(RID p_light, const Color &p_color) {} - void light_set_param(RID p_light, VS::LightParam p_param, float p_value) {} + void light_set_param(RID p_light, RS::LightParam p_param, float p_value) {} void light_set_shadow(RID p_light, bool p_enabled) {} void light_set_shadow_color(RID p_light, const Color &p_color) {} void light_set_projector(RID p_light, RID p_texture) {} @@ -559,22 +559,22 @@ public: void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {} void light_set_use_gi(RID p_light, bool p_enabled) {} - void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {} + void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) {} - void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {} + void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) {} void light_directional_set_blend_splits(RID p_light, bool p_enable) {} bool light_directional_get_blend_splits(RID p_light) const { return false; } - void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) {} - VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; } + void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) {} + RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const { return RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; } - VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; } - VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; } + RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) { return RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; } + RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) { return RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; } bool light_has_shadow(RID p_light) const { return false; } - VS::LightType light_get_type(RID p_light) const { return VS::LIGHT_OMNI; } + RS::LightType light_get_type(RID p_light) const { return RS::LIGHT_OMNI; } AABB light_get_aabb(RID p_light) const { return AABB(); } - float light_get_param(RID p_light, VS::LightParam p_param) { return 0.0; } + float light_get_param(RID p_light, RS::LightParam p_param) { return 0.0; } Color light_get_color(RID p_light) { return Color(); } bool light_get_use_gi(RID p_light) { return false; } uint64_t light_get_version(RID p_light) const { return 0; } @@ -583,7 +583,7 @@ public: RID reflection_probe_create() { return RID(); } - void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) {} + void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {} void reflection_probe_set_intensity(RID p_probe, float p_intensity) {} void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {} void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {} @@ -598,7 +598,7 @@ public: void reflection_probe_set_resolution(RID p_probe, int p_resolution) {} AABB reflection_probe_get_aabb(RID p_probe) const { return AABB(); } - VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return VisualServer::REFLECTION_PROBE_UPDATE_ONCE; } + RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; } uint32_t reflection_probe_get_cull_mask(RID p_probe) const { return 0; } Vector3 reflection_probe_get_extents(RID p_probe) const { return Vector3(); } Vector3 reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); } @@ -719,7 +719,7 @@ public: float lightmap_capture_get_energy(RID p_capture) const { return 0.0; } const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const { const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); - ERR_FAIL_COND_V(!capture, NULL); + ERR_FAIL_COND_V(!capture, nullptr); return &capture->octree; } @@ -742,7 +742,7 @@ public: void particles_set_fractional_delta(RID p_particles, bool p_enable) {} void particles_restart(RID p_particles) {} - void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {} + void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {} void particles_set_draw_passes(RID p_particles, int p_count) {} void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {} @@ -776,12 +776,12 @@ public: virtual void render_target_disable_clear_request(RID p_render_target) {} virtual void render_target_do_clear_request(RID p_render_target) {} - VS::InstanceType get_base_type(RID p_rid) const { + RS::InstanceType get_base_type(RID p_rid) const { if (mesh_owner.owns(p_rid)) { - return VS::INSTANCE_MESH; + return RS::INSTANCE_MESH; } - return VS::INSTANCE_NONE; + return RS::INSTANCE_NONE; } bool free(RID p_rid) { @@ -803,9 +803,9 @@ public: void render_info_begin_capture() {} void render_info_end_capture() {} - int get_captured_render_info(VS::RenderInfo p_info) { return 0; } + int get_captured_render_info(RS::RenderInfo p_info) { return 0; } - int get_render_info(VS::RenderInfo p_info) { return 0; } + int get_render_info(RS::RenderInfo p_info) { return 0; } String get_video_adapter_name() const { return String(); } String get_video_adapter_vendor() const { return String(); } @@ -825,7 +825,7 @@ public: class RasterizerCanvasDummy : public RasterizerCanvas { public: - virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { return 0; } + virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { return 0; } virtual void free_texture_binding(TextureBindingID p_binding) {} virtual PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>()) { return 0; } @@ -841,7 +841,7 @@ public: virtual RID occluder_polygon_create() { return RID(); } virtual void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) {} - virtual void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) {} + virtual void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {} void draw_window_margins(int *p_margins, RID *p_margin_textures) {} diff --git a/drivers/dummy/texture_loader_dummy.h b/drivers/dummy/texture_loader_dummy.h index e5ae945706..2a7d01dd78 100644 --- a/drivers/dummy/texture_loader_dummy.h +++ b/drivers/dummy/texture_loader_dummy.h @@ -36,7 +36,7 @@ class ResourceFormatDummyTexture : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/drivers/gl_context/SCsub b/drivers/gl_context/SCsub index d6945ee2eb..ddeec6f4c6 100644 --- a/drivers/gl_context/SCsub +++ b/drivers/gl_context/SCsub @@ -1,8 +1,8 @@ #!/usr/bin/env python -Import('env') +Import("env") -if (env["platform"] in ["haiku", "osx", "windows", "linuxbsd"]): +if env["platform"] in ["haiku", "osx", "windows", "linuxbsd"]: # Thirdparty source files thirdparty_dir = "#thirdparty/glad/" thirdparty_sources = [ @@ -12,8 +12,8 @@ if (env["platform"] in ["haiku", "osx", "windows", "linuxbsd"]): env.Prepend(CPPPATH=[thirdparty_dir]) - env.Append(CPPDEFINES=['GLAD_ENABLED']) - env.Append(CPPDEFINES=['GLES_OVER_GL']) + env.Append(CPPDEFINES=["GLAD_ENABLED"]) + env.Append(CPPDEFINES=["GLES_OVER_GL"]) env_thirdparty = env.Clone() env_thirdparty.disable_warnings() diff --git a/drivers/gles2/SCsub b/drivers/gles2/SCsub index 9923e52c73..987ddcd16e 100644 --- a/drivers/gles2/SCsub +++ b/drivers/gles2/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index 5e8948e9c4..069eeaba6c 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "core/project_settings.h" #include "rasterizer_scene_gles2.h" -#include "servers/visual/visual_server_raster.h" +#include "servers/rendering/rendering_server_raster.h" #ifndef GLES_OVER_GL #define glClearDepth glClearDepthf @@ -85,7 +85,7 @@ void RasterizerCanvasGLES2::_set_uniforms() { state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR, light->color * light->energy); state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS, light->light_shader_pos); state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_HEIGHT, light->height); - state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == VS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0); + state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0); if (state.using_shadow) { RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.getornull(light->shadow_buffer); @@ -152,8 +152,8 @@ void RasterizerCanvasGLES2::canvas_begin() { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex); - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); - glDisableVertexAttribArray(VS::ARRAY_COLOR); + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); + glDisableVertexAttribArray(RS::ARRAY_COLOR); // set up default uniforms @@ -188,7 +188,7 @@ void RasterizerCanvasGLES2::canvas_end() { glBindBuffer(GL_ARRAY_BUFFER, 0); - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { glDisableVertexAttribArray(i); } @@ -208,7 +208,7 @@ void RasterizerCanvasGLES2::canvas_end() { RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) { - RasterizerStorageGLES2::Texture *tex_return = NULL; + RasterizerStorageGLES2::Texture *tex_return = nullptr; if (p_texture.is_valid()) { @@ -216,7 +216,7 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con if (!texture) { state.current_tex = RID(); - state.current_tex_ptr = NULL; + state.current_tex_ptr = nullptr; glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1); glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex); @@ -224,7 +224,7 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con } else { if (texture->redraw_if_visible) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } texture = texture->get_ptr(); @@ -243,7 +243,7 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con } } else { state.current_tex = RID(); - state.current_tex_ptr = NULL; + state.current_tex_ptr = nullptr; glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1); glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex); @@ -266,7 +266,7 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(con } else { if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } normal_map = normal_map->get_ptr(); @@ -293,59 +293,59 @@ void RasterizerCanvasGLES2::_draw_polygon(const int *p_indices, int p_index_coun glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData - glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, nullptr, GL_DYNAMIC_DRAW); #endif uint32_t buffer_ofs = 0; glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), nullptr); buffer_ofs += sizeof(Vector2) * p_vertex_count; if (p_singlecolor) { - glDisableVertexAttribArray(VS::ARRAY_COLOR); + glDisableVertexAttribArray(RS::ARRAY_COLOR); Color m = *p_colors; - glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a); + glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a); } else if (!p_colors) { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + glDisableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } else { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors); - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(Color) * p_vertex_count; } if (p_uvs) { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(Vector2) * p_vertex_count; } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV); } if (p_weights && p_bones) { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(float) * 4 * p_vertex_count, p_weights); - glEnableVertexAttribArray(VS::ARRAY_WEIGHTS); - glVertexAttribPointer(VS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_WEIGHTS); + glVertexAttribPointer(RS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(float) * 4 * p_vertex_count; glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(int) * 4 * p_vertex_count, p_bones); - glEnableVertexAttribArray(VS::ARRAY_BONES); - glVertexAttribPointer(VS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, sizeof(int) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_BONES); + glVertexAttribPointer(RS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, sizeof(int) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(int) * 4 * p_vertex_count; } else { - glDisableVertexAttribArray(VS::ARRAY_WEIGHTS); - glDisableVertexAttribArray(VS::ARRAY_BONES); + glDisableVertexAttribArray(RS::ARRAY_WEIGHTS); + glDisableVertexAttribArray(RS::ARRAY_BONES); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData - glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, nullptr, GL_DYNAMIC_DRAW); #endif if (storage->config.support_32_bits_indices) { //should check for @@ -369,36 +369,36 @@ void RasterizerCanvasGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData - glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, nullptr, GL_DYNAMIC_DRAW); #endif uint32_t buffer_ofs = 0; glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), nullptr); buffer_ofs += sizeof(Vector2) * p_vertex_count; if (p_singlecolor) { - glDisableVertexAttribArray(VS::ARRAY_COLOR); + glDisableVertexAttribArray(RS::ARRAY_COLOR); Color m = *p_colors; - glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a); + glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a); } else if (!p_colors) { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + glDisableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } else { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors); - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(Color) * p_vertex_count; } if (p_uvs) { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV); } glDrawArrays(p_primitive, 0, p_vertex_count); @@ -411,43 +411,43 @@ void RasterizerCanvasGLES2::_draw_generic_indices(GLuint p_primitive, const int glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData - glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, nullptr, GL_DYNAMIC_DRAW); #endif uint32_t buffer_ofs = 0; glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(Vector2) * p_vertex_count, p_vertices); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), nullptr); buffer_ofs += sizeof(Vector2) * p_vertex_count; if (p_singlecolor) { - glDisableVertexAttribArray(VS::ARRAY_COLOR); + glDisableVertexAttribArray(RS::ARRAY_COLOR); Color m = *p_colors; - glVertexAttrib4f(VS::ARRAY_COLOR, m.r, m.g, m.b, m.a); + glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a); } else if (!p_colors) { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + glDisableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } else { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors); - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(Color) * p_vertex_count; } if (p_uvs) { glBufferSubData(GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs)); buffer_ofs += sizeof(Vector2) * p_vertex_count; } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData - glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer_size, nullptr, GL_DYNAMIC_DRAW); #endif if (storage->config.support_32_bits_indices) { //should check for @@ -510,20 +510,20 @@ void RasterizerCanvasGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_v glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); #ifndef GLES_OVER_GL // Orphan the buffer to avoid CPU/GPU sync points caused by glBufferSubData - glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, data.polygon_buffer_size, nullptr, GL_DYNAMIC_DRAW); #endif glBufferSubData(GL_ARRAY_BUFFER, 0, p_points * stride * 4 * sizeof(float), buffer_data); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), nullptr); if (p_colors) { - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float))); - glEnableVertexAttribArray(VS::ARRAY_COLOR); + glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float))); + glEnableVertexAttribArray(RS::ARRAY_COLOR); } if (p_uvs) { - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float))); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float))); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); } glDrawArrays(prim[p_points], 0, p_points); @@ -564,8 +564,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur _bind_canvas_texture(RID(), RID()); - glDisableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttrib4fv(VS::ARRAY_COLOR, line->color.components); + glDisableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttrib4fv(RS::ARRAY_COLOR, line->color.components); state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix); @@ -579,7 +579,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur if (line->antialiased) glEnable(GL_LINE_SMOOTH); #endif - _draw_gui_primitive(2, verts, NULL, NULL); + _draw_gui_primitive(2, verts, nullptr, nullptr); #ifdef GLES_OVER_GL if (line->antialiased) @@ -595,7 +595,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur line->to - t }; - _draw_gui_primitive(4, verts, NULL, NULL); + _draw_gui_primitive(4, verts, nullptr, nullptr); #ifdef GLES_OVER_GL if (line->antialiased) { glEnable(GL_LINE_SMOOTH); @@ -604,7 +604,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur verts[j], verts[(j + 1) % 4], }; - _draw_gui_primitive(2, vertsl, NULL, NULL); + _draw_gui_primitive(2, vertsl, nullptr, nullptr); } glDisable(GL_LINE_SMOOTH); } @@ -616,8 +616,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur Item::CommandRect *r = static_cast<Item::CommandRect *>(command); - glDisableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttrib4fv(VS::ARRAY_COLOR, r->modulate.components); + glDisableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttrib4fv(RS::ARRAY_COLOR, r->modulate.components); bool can_tile = true; if (r->texture.is_valid() && r->flags & CANVAS_RECT_TILE && !storage->config.support_npot_repeat_mipmap) { @@ -696,13 +696,13 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur bool untile = false; - if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & VS::TEXTURE_FLAG_REPEAT)) { + if (can_tile && r->flags & CANVAS_RECT_TILE && !(texture->flags & RS::TEXTURE_FLAG_REPEAT)) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); untile = true; } - _draw_gui_primitive(4, points, NULL, uvs); + _draw_gui_primitive(4, points, nullptr, uvs); if (untile) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -717,7 +717,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur }; state.canvas_shader.set_uniform(CanvasShaderGLES2::COLOR_TEXPIXEL_SIZE, Vector2()); - _draw_gui_primitive(4, points, NULL, uvs); + _draw_gui_primitive(4, points, nullptr, uvs); } } else { @@ -753,7 +753,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur bool untile = false; - if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & VS::TEXTURE_FLAG_REPEAT)) { + if (can_tile && r->flags & CANVAS_RECT_TILE && !(tex->flags & RS::TEXTURE_FLAG_REPEAT)) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); untile = true; @@ -816,8 +816,8 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur state.canvas_shader.use_material((void *)p_material); } - glDisableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttrib4fv(VS::ARRAY_COLOR, np->color.components); + glDisableVertexAttribArray(RS::ARRAY_COLOR); + glVertexAttrib4fv(RS::ARRAY_COLOR, np->color.components); RasterizerStorageGLES2::Texture *tex = _bind_canvas_texture(np->texture, np->normal_map); @@ -968,13 +968,13 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.ninepatch_elements); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), NULL); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), CAST_INT_TO_UCHAR_PTR((sizeof(float) * 2))); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), nullptr); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), CAST_INT_TO_UCHAR_PTR((sizeof(float) * 2))); - glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_BYTE, NULL); + glDrawElements(GL_TRIANGLES, 18 * 3 - (np->draw_center ? 0 : 6), GL_UNSIGNED_BYTE, nullptr); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -1008,7 +1008,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur _bind_canvas_texture(RID(), RID()); - _draw_polygon(indices, num_points * 3, num_points + 1, points, NULL, &circle->color, true); + _draw_polygon(indices, num_points * 3, num_points + 1, points, nullptr, &circle->color, true); } break; case Item::Command::TYPE_POLYGON: { @@ -1072,18 +1072,18 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); } - for (int k = 0; k < VS::ARRAY_MAX - 1; k++) { + for (int k = 0; k < RS::ARRAY_MAX - 1; k++) { if (s->attribs[k].enabled) { glEnableVertexAttribArray(k); glVertexAttribPointer(s->attribs[k].index, s->attribs[k].size, s->attribs[k].type, s->attribs[k].normalized, s->attribs[k].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[k].offset)); } else { glDisableVertexAttribArray(k); switch (k) { - case VS::ARRAY_NORMAL: { - glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); + case RS::ARRAY_NORMAL: { + glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); } break; - case VS::ARRAY_COLOR: { - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + case RS::ARRAY_COLOR: { + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } break; default: { @@ -1099,7 +1099,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } } - for (int j = 1; j < VS::ARRAY_MAX - 1; j++) { + for (int j = 1; j < RS::ARRAY_MAX - 1; j++) { glDisableVertexAttribArray(j); } } @@ -1118,7 +1118,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur if (!mesh_data) break; - state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != VS::MULTIMESH_CUSTOM_DATA_NONE); + state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCING, true); state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, false); @@ -1162,18 +1162,18 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); } - for (int k = 0; k < VS::ARRAY_MAX - 1; k++) { + for (int k = 0; k < RS::ARRAY_MAX - 1; k++) { if (s->attribs[k].enabled) { glEnableVertexAttribArray(k); glVertexAttribPointer(s->attribs[k].index, s->attribs[k].size, s->attribs[k].type, s->attribs[k].normalized, s->attribs[k].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[k].offset)); } else { glDisableVertexAttribArray(k); switch (k) { - case VS::ARRAY_NORMAL: { - glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); + case RS::ARRAY_NORMAL: { + glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); } break; - case VS::ARRAY_COLOR: { - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + case RS::ARRAY_COLOR: { + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } break; default: { @@ -1189,7 +1189,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 0, &buffer[0]); glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 1, &buffer[4]); - if (multi_mesh->transform_format == VS::MULTIMESH_TRANSFORM_3D) { + if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) { glVertexAttrib4fv(INSTANCE_ATTRIB_BASE + 2, &buffer[8]); } else { glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 2, 0.0, 0.0, 1.0, 0.0); @@ -1197,7 +1197,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } if (multi_mesh->color_floats) { - if (multi_mesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multi_mesh->color_format == RS::MULTIMESH_COLOR_8BIT) { uint8_t *color_data = (uint8_t *)(buffer + color_ofs); glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 3, color_data[0] / 255.0, color_data[1] / 255.0, color_data[2] / 255.0, color_data[3] / 255.0); } else { @@ -1208,7 +1208,7 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur } if (multi_mesh->custom_data_floats) { - if (multi_mesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multi_mesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { uint8_t *custom_data = (uint8_t *)(buffer + custom_data_ofs); glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 4, custom_data[0] / 255.0, custom_data[1] / 255.0, custom_data[2] / 255.0, custom_data[3] / 255.0); } else { @@ -1241,13 +1241,13 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur _bind_canvas_texture(RID(), RID()); if (pline->triangles.size()) { - _draw_generic(GL_TRIANGLE_STRIP, pline->triangles.size(), pline->triangles.ptr(), NULL, pline->triangle_colors.ptr(), pline->triangle_colors.size() == 1); + _draw_generic(GL_TRIANGLE_STRIP, pline->triangles.size(), pline->triangles.ptr(), nullptr, pline->triangle_colors.ptr(), pline->triangle_colors.size() == 1); #ifdef GLES_OVER_GL glEnable(GL_LINE_SMOOTH); if (pline->multiline) { //needs to be different } else { - _draw_generic(GL_LINE_LOOP, pline->lines.size(), pline->lines.ptr(), NULL, pline->line_colors.ptr(), pline->line_colors.size() == 1); + _draw_generic(GL_LINE_LOOP, pline->lines.size(), pline->lines.ptr(), nullptr, pline->line_colors.ptr(), pline->line_colors.size() == 1); } glDisable(GL_LINE_SMOOTH); #endif @@ -1265,12 +1265,12 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur while (todo) { int to_draw = MIN(max_per_call, todo); - _draw_generic(GL_LINES, to_draw * 2, &pline->lines.ptr()[offset], NULL, pline->line_colors.size() == 1 ? pline->line_colors.ptr() : &pline->line_colors.ptr()[offset], pline->line_colors.size() == 1); + _draw_generic(GL_LINES, to_draw * 2, &pline->lines.ptr()[offset], nullptr, pline->line_colors.size() == 1 ? pline->line_colors.ptr() : &pline->line_colors.ptr()[offset], pline->line_colors.size() == 1); todo -= to_draw; offset += to_draw * 2; } } else { - _draw_generic(GL_LINES, pline->lines.size(), pline->lines.ptr(), NULL, pline->line_colors.ptr(), pline->line_colors.size() == 1); + _draw_generic(GL_LINES, pline->lines.size(), pline->lines.ptr(), nullptr, pline->line_colors.ptr(), pline->line_colors.size() == 1); } #ifdef GLES_OVER_GL @@ -1301,9 +1301,9 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur if (primitive->colors.size() == 1 && primitive->points.size() > 1) { Color c = primitive->colors[0]; - glVertexAttrib4f(VS::ARRAY_COLOR, c.r, c.g, c.b, c.a); + glVertexAttrib4f(RS::ARRAY_COLOR, c.r, c.g, c.b, c.a); } else if (primitive->colors.empty()) { - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } _draw_gui_primitive(primitive->points.size(), primitive->points.ptr(), primitive->colors.ptr(), primitive->uvs.ptr()); @@ -1402,7 +1402,7 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) { 2, 3, 0 }; - _draw_polygon(indexpos, 6, 4, vertpos, uvpos, NULL, false); + _draw_polygon(indexpos, 6, 4, vertpos, uvpos, nullptr, false); storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_COPY_SECTION, false); storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, false); @@ -1426,16 +1426,16 @@ void RasterizerCanvasGLES2::_copy_texscreen(const Rect2 &p_rect) { void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) { - Item *current_clip = NULL; + Item *current_clip = nullptr; - RasterizerStorageGLES2::Shader *shader_cache = NULL; + RasterizerStorageGLES2::Shader *shader_cache = nullptr; bool rebind_shader = true; bool prev_use_skeleton = false; state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SKELETON, false); state.current_tex = RID(); - state.current_tex_ptr = NULL; + state.current_tex_ptr = nullptr; state.current_normal = RID(); state.canvas_texscreen_used = false; @@ -1475,14 +1475,14 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } } - RasterizerStorageGLES2::Skeleton *skeleton = NULL; + RasterizerStorageGLES2::Skeleton *skeleton = nullptr; { //skeleton handling if (ci->skeleton.is_valid() && storage->skeleton_owner.owns(ci->skeleton)) { skeleton = storage->skeleton_owner.getornull(ci->skeleton); if (!skeleton->use_2d) { - skeleton = NULL; + skeleton = nullptr; } else { state.skeleton_transform = p_base_transform * skeleton->base_transform_2d; state.skeleton_transform_inverse = state.skeleton_transform.affine_inverse(); @@ -1490,7 +1490,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } } - bool use_skeleton = skeleton != NULL; + bool use_skeleton = skeleton != nullptr; if (prev_use_skeleton != use_skeleton) { rebind_shader = true; state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SKELETON, use_skeleton); @@ -1513,13 +1513,13 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons if (material != canvas_last_material || rebind_shader) { - RasterizerStorageGLES2::Shader *shader_ptr = NULL; + RasterizerStorageGLES2::Shader *shader_ptr = nullptr; if (material_ptr) { shader_ptr = material_ptr->shader; - if (shader_ptr && shader_ptr->mode != VS::SHADER_CANVAS_ITEM) { - shader_ptr = NULL; // not a canvas item shader, don't use. + if (shader_ptr && shader_ptr->mode != RS::SHADER_CANVAS_ITEM) { + shader_ptr = nullptr; // not a canvas item shader, don't use. } } @@ -1542,7 +1542,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons if (shader_ptr != shader_cache) { if (shader_ptr->canvas_item.uses_time) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } state.canvas_shader.set_custom_shader(shader_ptr->custom_code_id); @@ -1582,7 +1582,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } if (t->redraw_if_visible) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } t = t->get_ptr(); @@ -1674,7 +1674,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons _set_uniforms(); if (unshaded || (state.uniforms.final_modulate.a > 0.001 && (!shader_cache || shader_cache->canvas_item.light_mode != RasterizerStorageGLES2::Shader::CanvasItem::LIGHT_MODE_LIGHT_ONLY) && !ci->light_masked)) - _canvas_item_render_commands(p_item_list, NULL, reclip, material_ptr); + _canvas_item_render_commands(p_item_list, nullptr, reclip, material_ptr); rebind_shader = true; // hacked in for now. @@ -1682,7 +1682,7 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons Light *light = p_light; bool light_used = false; - VS::CanvasLightMode mode = VS::CANVAS_LIGHT_MODE_ADD; + RS::CanvasLightMode mode = RS::CANVAS_LIGHT_MODE_ADD; state.uniforms.final_modulate = ci->final_modulate; // remove the canvas modulate while (light) { @@ -1697,17 +1697,17 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons switch (mode) { - case VS::CANVAS_LIGHT_MODE_ADD: { + case RS::CANVAS_LIGHT_MODE_ADD: { glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE); } break; - case VS::CANVAS_LIGHT_MODE_SUB: { + case RS::CANVAS_LIGHT_MODE_SUB: { glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); glBlendFunc(GL_SRC_ALPHA, GL_ONE); } break; - case VS::CANVAS_LIGHT_MODE_MIX: - case VS::CANVAS_LIGHT_MODE_MASK: { + case RS::CANVAS_LIGHT_MODE_MIX: + case RS::CANVAS_LIGHT_MODE_MASK: { glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1726,12 +1726,12 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, has_shadow); if (has_shadow) { state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_USE_GRADIENT, light->shadow_gradient_length > 0); - state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_NONE); - state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF3, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF3); - state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF5, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF5); - state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF7, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF7); - state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF9, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF9); - state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF13, light->shadow_filter == VS::CANVAS_LIGHT_FILTER_PCF13); + state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_NEAREST, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_NONE); + state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF3, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF3); + state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF5, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF5); + state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF7, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF7); + state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF9, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF9); + state.canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_FILTER_PCF13, light->shadow_filter == RS::CANVAS_LIGHT_FILTER_PCF13); } state.canvas_shader.bind(); @@ -1753,9 +1753,9 @@ void RasterizerCanvasGLES2::canvas_render_items(Item *p_item_list, int p_z, cons } glActiveTexture(GL_TEXTURE0); - _canvas_item_render_commands(p_item_list, NULL, reclip, material_ptr); //redraw using light + _canvas_item_render_commands(p_item_list, nullptr, reclip, material_ptr); //redraw using light - state.using_light = NULL; + state.using_light = nullptr; } light = light->next_ptr; @@ -1846,7 +1846,7 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons glClearColor(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - VS::CanvasOccluderPolygonCullMode cull = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; + RS::CanvasOccluderPolygonCullMode cull = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; for (int i = 0; i < 4; i++) { @@ -1903,31 +1903,31 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::WORLD_MATRIX, instance->xform_cache); - VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache; + RS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache; - if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED && + if (transformed_cull_cache != RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED && (p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) { transformed_cull_cache = - transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? - VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE : - VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE; + transformed_cull_cache == RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? + RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE : + RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE; } if (cull != transformed_cull_cache) { cull = transformed_cull_cache; switch (cull) { - case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: { + case RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: { glDisable(GL_CULL_FACE); } break; - case VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: { + case RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: { glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); } break; - case VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: { + case RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: { glEnable(GL_CULL_FACE); glCullFace(GL_BACK); @@ -1937,8 +1937,8 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons } glBindBuffer(GL_ARRAY_BUFFER, cc->vertex_id); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cc->index_id); glDrawElements(GL_TRIANGLES, cc->len * 3, GL_UNSIGNED_SHORT, 0); @@ -1979,8 +1979,8 @@ void RasterizerCanvasGLES2::reset_canvas() { void RasterizerCanvasGLES2::_bind_quad_buffer() { glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, nullptr); } void RasterizerCanvasGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) { @@ -2022,7 +2022,7 @@ void RasterizerCanvasGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float // and cleanup glBindBuffer(GL_ARRAY_BUFFER, 0); - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { glDisableVertexAttribArray(i); } } @@ -2117,7 +2117,7 @@ void RasterizerCanvasGLES2::initialize() { poly_size = MAX(poly_size, (2 + 2 + 4) * 4 * sizeof(float)); glGenBuffers(1, &data.polygon_buffer); glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer); - glBufferData(GL_ARRAY_BUFFER, poly_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, poly_size, nullptr, GL_DYNAMIC_DRAW); data.polygon_buffer_size = poly_size; @@ -2128,7 +2128,7 @@ void RasterizerCanvasGLES2::initialize() { index_size *= 1024; // kb glGenBuffers(1, &data.polygon_index_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_size, nullptr, GL_DYNAMIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); data.polygon_index_buffer_size = index_size; @@ -2140,7 +2140,7 @@ void RasterizerCanvasGLES2::initialize() { glGenBuffers(1, &data.ninepatch_vertices); glBindBuffer(GL_ARRAY_BUFFER, data.ninepatch_vertices); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * (16 + 16) * 2, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(float) * (16 + 16) * 2, nullptr, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -2210,7 +2210,7 @@ void RasterizerCanvasGLES2::initialize() { state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false)); - state.using_light = NULL; + state.using_light = nullptr; state.using_transparent_rt = false; state.using_skeleton = false; } diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h index f6ae6a60c0..2d6355e948 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.h +++ b/drivers/gles2/rasterizer_canvas_gles2.h @@ -32,7 +32,7 @@ #define RASTERIZERCANVASGLES2_H #include "rasterizer_storage_gles2.h" -#include "servers/visual/rasterizer.h" +#include "servers/rendering/rasterizer.h" #include "shaders/canvas.glsl.gen.h" #include "shaders/lens_distorted.glsl.gen.h" @@ -116,7 +116,7 @@ public: virtual void canvas_end(); _FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs); - _FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights = NULL, const int *p_bones = NULL); + _FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights = nullptr, const int *p_bones = nullptr); _FORCE_INLINE_ void _draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor); _FORCE_INLINE_ void _draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor); diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index f14c5f9406..37b729d568 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -221,7 +221,7 @@ void RasterizerGLES2::initialize() { if (OS::get_singleton()->is_stdout_verbose()) { if (GLAD_GL_ARB_debug_output) { glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); - glDebugMessageCallbackARB(_gl_debug_print, NULL); + glDebugMessageCallbackARB(_gl_debug_print, nullptr); glEnable(_EXT_DEBUG_OUTPUT); } else { print_line("OpenGL debugging not supported!"); @@ -233,12 +233,12 @@ void RasterizerGLES2::initialize() { #ifdef CAN_DEBUG #ifdef GLES_OVER_GL if (OS::get_singleton()->is_stdout_verbose() && GLAD_GL_ARB_debug_output) { - glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); - glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); - glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); - glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); - glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); - glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE); + glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE); + glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE); + glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE); + glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE); + glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE); + glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE); /* glDebugMessageInsertARB( GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, 1, @@ -256,14 +256,14 @@ void RasterizerGLES2::initialize() { print_line("godot: ENABLING GL DEBUG"); glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); - callback(_gl_debug_print, NULL); + callback(_gl_debug_print, nullptr); glEnable(_EXT_DEBUG_OUTPUT); } } #endif // GLES_OVER_GL #endif // CAN_DEBUG - print_line("OpenGL ES 2.0 Renderer: " + VisualServer::get_singleton()->get_video_adapter_name()); + print_line("OpenGL ES 2.0 Renderer: " + RenderingServer::get_singleton()->get_video_adapter_name()); storage->initialize(); canvas->initialize(); scene->initialize(); @@ -316,7 +316,7 @@ void RasterizerGLES2::set_current_render_target(RID p_render_target) { glViewport(0, 0, rt->width, rt->height); } else { - storage->frame.current_rt = NULL; + storage->frame.current_rt = nullptr; storage->frame.clear_request = false; glViewport(0, 0, DisplayServer::get_singleton()->window_get_size().width, DisplayServer::get_singleton()->window_get_size().height); glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES2::system_fbo); @@ -324,7 +324,7 @@ void RasterizerGLES2::set_current_render_target(RID p_render_target) { } void RasterizerGLES2::restore_render_target(bool p_3d_was_drawn) { - ERR_FAIL_COND(storage->frame.current_rt == NULL); + ERR_FAIL_COND(storage->frame.current_rt == nullptr); RasterizerStorageGLES2::RenderTarget *rt = storage->frame.current_rt; glBindFramebuffer(GL_FRAMEBUFFER, rt->fbo); glViewport(0, 0, rt->width, rt->height); @@ -359,7 +359,7 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c canvas->canvas_begin(); RID texture = storage->texture_create(); - storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_use_filter ? VS::TEXTURE_FLAG_FILTER : 0); + storage->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), RS::TEXTURE_TYPE_2D, p_use_filter ? RS::TEXTURE_FLAG_FILTER : 0); storage->texture_set_data(texture, p_image); Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height()); diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 9a5501f13d..027a634ae8 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -34,7 +34,7 @@ #include "rasterizer_canvas_gles2.h" #include "rasterizer_scene_gles2.h" #include "rasterizer_storage_gles2.h" -#include "servers/visual/rasterizer.h" +#include "servers/rendering/rasterizer.h" class RasterizerGLES2 : public Rasterizer { diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 8872dde9fc..8d4c6e87fa 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -37,7 +37,7 @@ #include "core/vmap.h" #include "rasterizer_canvas_gles2.h" #include "servers/camera/camera_feed.h" -#include "servers/visual/visual_server_raster.h" +#include "servers/rendering/rendering_server_raster.h" #ifndef GLES_OVER_GL #define glClearDepth glClearDepthf @@ -142,7 +142,7 @@ void RasterizerSceneGLES2::shadow_atlas_set_size(RID p_atlas, int p_size) { glGenTextures(1, &shadow_atlas->color); glBindTexture(GL_TEXTURE_2D, shadow_atlas->color); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shadow_atlas->size, shadow_atlas->size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, shadow_atlas->size, shadow_atlas->size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -152,7 +152,7 @@ void RasterizerSceneGLES2::shadow_atlas_set_size(RID p_atlas, int p_size) { //just depth texture glGenTextures(1, &shadow_atlas->depth); glBindTexture(GL_TEXTURE_2D, shadow_atlas->depth); - glTexImage2D(GL_TEXTURE_2D, 0, storage->config.depth_internalformat, shadow_atlas->size, shadow_atlas->size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, storage->config.depth_internalformat, shadow_atlas->size, shadow_atlas->size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -456,10 +456,10 @@ int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance) ERR_FAIL_COND_V(!light_instance, 0); switch (light_instance->light_ptr->directional_shadow_mode) { - case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: + case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: break; //none - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: shadow_size /= 2; break; } @@ -525,7 +525,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_needs_redraw(RID p_instance const ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND_V(!rpi, false); - bool need_redraw = rpi->probe_ptr->resolution != rpi->current_resolution || rpi->dirty || rpi->probe_ptr->update_mode == VS::REFLECTION_PROBE_UPDATE_ALWAYS; + bool need_redraw = rpi->probe_ptr->resolution != rpi->current_resolution || rpi->dirty || rpi->probe_ptr->update_mode == RS::REFLECTION_PROBE_UPDATE_ALWAYS; rpi->dirty = false; return need_redraw; } @@ -566,7 +566,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance // Mobile hardware (PowerVR specially) prefers this approach, // the previous approach with manual lod levels kills the game. for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, size, size, 0, format, type, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, size, size, 0, format, type, nullptr); } glGenerateMipmap(GL_TEXTURE_CUBE_MAP); @@ -575,7 +575,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance for (int i = 0; i < 6; i++) { glBindFramebuffer(GL_FRAMEBUFFER, rpi->fbo[i]); glBindTexture(GL_TEXTURE_2D, rpi->color[i]); - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size, 0, format, type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size, 0, format, type, nullptr); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rpi->color[i], 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rpi->depth); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -610,7 +610,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst glDisable(GL_BLEND); glDepthMask(GL_FALSE); - for (int i = 0; i < VS::ARRAY_MAX - 1; i++) { + for (int i = 0; i < RS::ARRAY_MAX - 1; i++) { glDisableVertexAttribArray(i); } } @@ -646,7 +646,7 @@ bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_inst glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, storage->resources.mipmap_blur_color); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, storage->resources.mipmap_blur_color, 0); glViewport(0, 0, size, size); glActiveTexture(GL_TEXTURE0); @@ -690,7 +690,7 @@ RID RasterizerSceneGLES2::environment_create() { return environment_owner.make_rid(env); } -void RasterizerSceneGLES2::environment_set_background(RID p_env, VS::EnvironmentBG p_bg) { +void RasterizerSceneGLES2::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -755,7 +755,7 @@ void RasterizerSceneGLES2::environment_set_camera_feed_id(RID p_env, int p_camer env->camera_feed_id = p_camera_feed_id; } -void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) { +void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -767,7 +767,7 @@ void RasterizerSceneGLES2::environment_set_dof_blur_far(RID p_env, bool p_enable env->dof_blur_far_quality = p_quality; } -void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality) { +void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -779,7 +779,7 @@ void RasterizerSceneGLES2::environment_set_dof_blur_near(RID p_env, bool p_enabl env->dof_blur_near_quality = p_quality; } -void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) { +void RasterizerSceneGLES2::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -806,12 +806,12 @@ void RasterizerSceneGLES2::environment_set_ssr(RID p_env, bool p_enable, int p_m ERR_FAIL_COND(!env); } -void RasterizerSceneGLES2::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VisualServer::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) { +void RasterizerSceneGLES2::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, RS::EnvironmentSSAOQuality p_quality, RenderingServer::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); } -void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { +void RasterizerSceneGLES2::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); } @@ -866,9 +866,9 @@ bool RasterizerSceneGLES2::is_environment(RID p_env) { return environment_owner.owns(p_env); } -VS::EnvironmentBG RasterizerSceneGLES2::environment_get_background(RID p_env) { +RS::EnvironmentBG RasterizerSceneGLES2::environment_get_background(RID p_env) { const Environment *env = environment_owner.getornull(p_env); - ERR_FAIL_COND_V(!env, VS::ENV_BG_MAX); + ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX); return env->bg_mode; } @@ -914,7 +914,7 @@ void RasterizerSceneGLES2::light_instance_set_shadow_transform(RID p_light_insta LightInstance *light_instance = light_instance_owner.getornull(p_light_instance); ERR_FAIL_COND(!light_instance); - if (light_instance->light_ptr->type != VS::LIGHT_DIRECTIONAL) { + if (light_instance->light_ptr->type != RS::LIGHT_DIRECTIONAL) { p_pass = 0; } @@ -956,7 +956,7 @@ void RasterizerSceneGLES2::gi_probe_instance_set_bounds(RID p_probe, const Vecto void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass) { - RasterizerStorageGLES2::Material *material = NULL; + RasterizerStorageGLES2::Material *material = nullptr; RID material_src; if (p_instance->material_override.is_valid()) { @@ -971,7 +971,7 @@ void RasterizerSceneGLES2::_add_geometry(RasterizerStorageGLES2::Geometry *p_geo material = storage->material_owner.getornull(material_src); if (!material->shader || !material->shader->valid) { - material = NULL; + material = nullptr; } } @@ -1022,7 +1022,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES2::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) { //shader does not use discard and does not write a vertex position, use generic material - if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) { + if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) { p_material = storage->material_owner.getornull(!p_shadow_pass && p_material->shader->spatial.uses_world_coordinates ? default_worldcoord_material_twosided : default_material_twosided); mirror = false; } else { @@ -1048,7 +1048,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G e->use_accum = false; e->light_index = RenderList::MAX_LIGHTS; e->use_accum_ptr = &e->use_accum; - e->instancing = (e->instance->base_type == VS::INSTANCE_MULTIMESH) ? 1 : 0; + e->instancing = (e->instance->base_type == RS::INSTANCE_MULTIMESH) ? 1 : 0; e->front_facing = false; if (e->geometry->last_pass != render_pass) { @@ -1162,7 +1162,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G //directional sort key e->light_type1 = 1; - e->light_type2 = li->light_ptr->type == VisualServer::LIGHT_OMNI ? 0 : 1; + e->light_type2 = li->light_ptr->type == RenderingServer::LIGHT_OMNI ? 0 : 1; e->light_index = li->light_index; copy = true; @@ -1181,7 +1181,7 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G // do not add anything here, as lights are duplicated elements.. if (p_material->shader->spatial.uses_time) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } } @@ -1224,7 +1224,7 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p switch (instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { RasterizerStorageGLES2::Mesh *mesh = storage->mesh_owner.getornull(instance->base); ERR_CONTINUE(!mesh); @@ -1236,12 +1236,12 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p RasterizerStorageGLES2::Surface *surface = mesh->surfaces[j]; - _add_geometry(surface, instance, NULL, material_index, p_depth_pass, p_shadow_pass); + _add_geometry(surface, instance, nullptr, material_index, p_depth_pass, p_shadow_pass); } } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { RasterizerStorageGLES2::MultiMesh *multi_mesh = storage->multimesh_owner.getornull(instance->base); ERR_CONTINUE(!multi_mesh); @@ -1260,11 +1260,11 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p } } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { RasterizerStorageGLES2::Immediate *im = storage->immediate_owner.getornull(instance->base); ERR_CONTINUE(!im); - _add_geometry(im, instance, NULL, -1, p_depth_pass, p_shadow_pass); + _add_geometry(im, instance, nullptr, -1, p_depth_pass, p_shadow_pass); } break; @@ -1426,7 +1426,7 @@ bool RasterizerSceneGLES2::_setup_material(RasterizerStorageGLES2::Material *p_m } if (t->redraw_if_visible) { //must check before proxy because this is often used with proxies - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } t = t->get_ptr(); @@ -1459,7 +1459,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste switch (p_element->instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id); @@ -1468,18 +1468,18 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); } - for (int i = 0; i < VS::ARRAY_MAX - 1; i++) { + for (int i = 0; i < RS::ARRAY_MAX - 1; i++) { if (s->attribs[i].enabled) { glEnableVertexAttribArray(i); glVertexAttribPointer(s->attribs[i].index, s->attribs[i].size, s->attribs[i].type, s->attribs[i].normalized, s->attribs[i].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[i].offset)); } else { glDisableVertexAttribArray(i); switch (i) { - case VS::ARRAY_NORMAL: { - glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); + case RS::ARRAY_NORMAL: { + glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); } break; - case VS::ARRAY_COLOR: { - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + case RS::ARRAY_COLOR: { + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } break; default: { @@ -1502,7 +1502,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste Vector<float> &transform_buffer = storage->resources.skeleton_transform_cpu_buffer; - if (!s->attribs[VS::ARRAY_BONES].enabled || !s->attribs[VS::ARRAY_WEIGHTS].enabled) { + if (!s->attribs[RS::ARRAY_BONES].enabled || !s->attribs[RS::ARRAY_WEIGHTS].enabled) { break; // the whole instance has a skeleton, but this surface is not affected by it. } @@ -1511,10 +1511,10 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste transform_buffer.resize(s->array_len * 12); } - const size_t bones_offset = s->attribs[VS::ARRAY_BONES].offset; - const size_t bones_stride = s->attribs[VS::ARRAY_BONES].stride; - const size_t bone_weight_offset = s->attribs[VS::ARRAY_WEIGHTS].offset; - const size_t bone_weight_stride = s->attribs[VS::ARRAY_WEIGHTS].stride; + const size_t bones_offset = s->attribs[RS::ARRAY_BONES].offset; + const size_t bones_stride = s->attribs[RS::ARRAY_BONES].stride; + const size_t bone_weight_offset = s->attribs[RS::ARRAY_WEIGHTS].offset; + const size_t bone_weight_stride = s->attribs[RS::ARRAY_WEIGHTS].stride; { float *write = transform_buffer.ptrw(); @@ -1530,7 +1530,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste size_t bones[4]; float bone_weight[4]; - if (s->attribs[VS::ARRAY_BONES].type == GL_UNSIGNED_BYTE) { + if (s->attribs[RS::ARRAY_BONES].type == GL_UNSIGNED_BYTE) { // read as byte const uint8_t *bones_ptr = vertex_data + bones_offset + (i * bones_stride); bones[0] = bones_ptr[0]; @@ -1546,7 +1546,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste bones[3] = bones_ptr[3]; } - if (s->attribs[VS::ARRAY_WEIGHTS].type == GL_FLOAT) { + if (s->attribs[RS::ARRAY_WEIGHTS].type == GL_FLOAT) { // read as float const float *weight_ptr = (const float *)(vertex_data + bone_weight_offset + (i * bone_weight_stride)); bone_weight[0] = weight_ptr[0]; @@ -1621,7 +1621,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); glBindBuffer(GL_ARRAY_BUFFER, s->vertex_id); @@ -1630,18 +1630,18 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); } - for (int i = 0; i < VS::ARRAY_MAX - 1; i++) { + for (int i = 0; i < RS::ARRAY_MAX - 1; i++) { if (s->attribs[i].enabled) { glEnableVertexAttribArray(i); glVertexAttribPointer(s->attribs[i].index, s->attribs[i].size, s->attribs[i].type, s->attribs[i].normalized, s->attribs[i].stride, CAST_INT_TO_UCHAR_PTR(s->attribs[i].offset)); } else { glDisableVertexAttribArray(i); switch (i) { - case VS::ARRAY_NORMAL: { - glVertexAttrib4f(VS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); + case RS::ARRAY_NORMAL: { + glVertexAttrib4f(RS::ARRAY_NORMAL, 0.0, 0.0, 1, 1); } break; - case VS::ARRAY_COLOR: { - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + case RS::ARRAY_COLOR: { + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); } break; default: { @@ -1662,7 +1662,7 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { } break; default: { @@ -1674,7 +1674,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { switch (p_element->instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); @@ -1688,22 +1688,22 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { storage->info.render.vertices_count += s->array_len; } /* - if (p_element->instance->skeleton.is_valid() && s->attribs[VS::ARRAY_BONES].enabled && s->attribs[VS::ARRAY_WEIGHTS].enabled) { + if (p_element->instance->skeleton.is_valid() && s->attribs[RS::ARRAY_BONES].enabled && s->attribs[RS::ARRAY_WEIGHTS].enabled) { //clean up after skeleton glBindBuffer(GL_ARRAY_BUFFER, storage->resources.skeleton_transform_buffer); - glDisableVertexAttribArray(VS::ARRAY_MAX + 0); - glDisableVertexAttribArray(VS::ARRAY_MAX + 1); - glDisableVertexAttribArray(VS::ARRAY_MAX + 2); + glDisableVertexAttribArray(RS::ARRAY_MAX + 0); + glDisableVertexAttribArray(RS::ARRAY_MAX + 1); + glDisableVertexAttribArray(RS::ARRAY_MAX + 2); - glVertexAttrib4f(VS::ARRAY_MAX + 0, 1, 0, 0, 0); - glVertexAttrib4f(VS::ARRAY_MAX + 1, 0, 1, 0, 0); - glVertexAttrib4f(VS::ARRAY_MAX + 2, 0, 0, 1, 0); + glVertexAttrib4f(RS::ARRAY_MAX + 0, 1, 0, 0, 0); + glVertexAttrib4f(RS::ARRAY_MAX + 1, 0, 1, 0, 0); + glVertexAttrib4f(RS::ARRAY_MAX + 2, 0, 0, 1, 0); } */ } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { RasterizerStorageGLES2::MultiMesh *multi_mesh = static_cast<RasterizerStorageGLES2::MultiMesh *>(p_element->owner); RasterizerStorageGLES2::Surface *s = static_cast<RasterizerStorageGLES2::Surface *>(p_element->geometry); @@ -1734,7 +1734,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } if (multi_mesh->color_floats) { - if (multi_mesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multi_mesh->color_format == RS::MULTIMESH_COLOR_8BIT) { uint8_t *color_data = (uint8_t *)(buffer + color_ofs); glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 3, color_data[0] / 255.0, color_data[1] / 255.0, color_data[2] / 255.0, color_data[3] / 255.0); } else { @@ -1745,7 +1745,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } if (multi_mesh->custom_data_floats) { - if (multi_mesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multi_mesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { uint8_t *custom_data = (uint8_t *)(buffer + custom_data_ofs); glVertexAttrib4f(INSTANCE_ATTRIB_BASE + 4, custom_data[0] / 255.0, custom_data[1] / 255.0, custom_data[2] / 255.0, custom_data[3] / 255.0); } else { @@ -1764,7 +1764,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { const RasterizerStorageGLES2::Immediate *im = static_cast<const RasterizerStorageGLES2::Immediate *>(p_element->geometry); if (im->building) { @@ -1792,7 +1792,7 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { RasterizerStorageGLES2::Texture *t = storage->texture_owner.getornull(c.texture); if (t->redraw_if_visible) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } t = t->get_ptr(); @@ -1816,53 +1816,53 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } if (!c.normals.empty()) { - glEnableVertexAttribArray(VS::ARRAY_NORMAL); + glEnableVertexAttribArray(RS::ARRAY_NORMAL); glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.normals.ptr()); - glVertexAttribPointer(VS::ARRAY_NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs)); + glVertexAttribPointer(RS::ARRAY_NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs)); buf_ofs += sizeof(Vector3) * vertices; } else { - glDisableVertexAttribArray(VS::ARRAY_NORMAL); + glDisableVertexAttribArray(RS::ARRAY_NORMAL); } if (!c.tangents.empty()) { - glEnableVertexAttribArray(VS::ARRAY_TANGENT); + glEnableVertexAttribArray(RS::ARRAY_TANGENT); glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Plane) * vertices, c.tangents.ptr()); - glVertexAttribPointer(VS::ARRAY_TANGENT, 4, GL_FLOAT, GL_FALSE, sizeof(Plane), CAST_INT_TO_UCHAR_PTR(buf_ofs)); + glVertexAttribPointer(RS::ARRAY_TANGENT, 4, GL_FLOAT, GL_FALSE, sizeof(Plane), CAST_INT_TO_UCHAR_PTR(buf_ofs)); buf_ofs += sizeof(Plane) * vertices; } else { - glDisableVertexAttribArray(VS::ARRAY_TANGENT); + glDisableVertexAttribArray(RS::ARRAY_TANGENT); } if (!c.colors.empty()) { - glEnableVertexAttribArray(VS::ARRAY_COLOR); + glEnableVertexAttribArray(RS::ARRAY_COLOR); glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Color) * vertices, c.colors.ptr()); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buf_ofs)); + glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buf_ofs)); buf_ofs += sizeof(Color) * vertices; } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); + glDisableVertexAttribArray(RS::ARRAY_COLOR); } if (!c.uvs.empty()) { - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uvs.ptr()); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs)); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs)); buf_ofs += sizeof(Vector2) * vertices; } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV); } if (!c.uv2s.empty()) { - glEnableVertexAttribArray(VS::ARRAY_TEX_UV2); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV2); glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector2) * vertices, c.uv2s.ptr()); - glVertexAttribPointer(VS::ARRAY_TEX_UV2, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs)); + glVertexAttribPointer(RS::ARRAY_TEX_UV2, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buf_ofs)); buf_ofs += sizeof(Vector2) * vertices; } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV2); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV2); } - glEnableVertexAttribArray(VS::ARRAY_VERTEX); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); glBufferSubData(GL_ARRAY_BUFFER, buf_ofs, sizeof(Vector3) * vertices, c.vertices.ptr()); - glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs)); + glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3), CAST_INT_TO_UCHAR_PTR(buf_ofs)); glDrawArrays(gl_primitive[c.primitive], 0, c.vertices.size()); } @@ -1901,18 +1901,18 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTING, true); switch (p_light->light_ptr->type) { - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_DIRECTIONAL, true); switch (p_light->light_ptr->directional_shadow_mode) { - case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: { + case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: { //no need } break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: { + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: { state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_USE_PSSM2, true); } break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: { + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: { state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_USE_PSSM4, true); } break; } @@ -1931,7 +1931,7 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas } } break; - case VS::LIGHT_OMNI: { + case RS::LIGHT_OMNI: { state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_OMNI, true); if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) { @@ -1946,7 +1946,7 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas state.scene_shader.set_conditional(SceneShaderGLES2::SHADOW_MODE_PCF_13, shadow_filter_mode == SHADOW_FILTER_PCF13); } } break; - case VS::LIGHT_SPOT: { + case RS::LIGHT_SPOT: { state.scene_shader.set_conditional(SceneShaderGLES2::LIGHT_MODE_SPOT, true); if (!state.render_no_shadows && shadow_atlas && p_light->light_ptr->shadow) { @@ -1969,8 +1969,8 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado RasterizerStorageGLES2::Light *light_ptr = light->light_ptr; //common parameters - float energy = light_ptr->param[VS::LIGHT_PARAM_ENERGY]; - float specular = light_ptr->param[VS::LIGHT_PARAM_SPECULAR]; + float energy = light_ptr->param[RS::LIGHT_PARAM_ENERGY]; + float specular = light_ptr->param[RS::LIGHT_PARAM_SPECULAR]; float sign = (light_ptr->negative && !accum_pass) ? -1 : 1; //inverse color for base pass lights only state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SPECULAR, specular); @@ -1982,7 +1982,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado //specific parameters switch (light_ptr->type) { - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { //not using inverse for performance, view should be normalized anyway Vector3 direction = p_view_transform.basis.xform_inv(light->transform.basis.xform(Vector3(0, 0, -1))).normalized(); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_DIRECTION, direction); @@ -1995,15 +1995,15 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado Color split_offsets; switch (light_ptr->directional_shadow_mode) { - case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: { + case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: { shadow_count = 1; } break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: { + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: { shadow_count = 2; } break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: { + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: { shadow_count = 4; } break; } @@ -2015,7 +2015,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado uint32_t width = light->directional_rect.size.x; uint32_t height = light->directional_rect.size.y; - if (light_ptr->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { + if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { width /= 2; height /= 2; @@ -2029,7 +2029,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado y += height; } - } else if (light_ptr->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { + } else if (light_ptr->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { height /= 2; @@ -2067,16 +2067,16 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SHADOW_MATRIX4, matrices[3]); } } break; - case VS::LIGHT_OMNI: { + case RS::LIGHT_OMNI: { Vector3 position = p_view_transform.xform_inv(light->transform.origin); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_POSITION, position); - float range = light_ptr->param[VS::LIGHT_PARAM_RANGE]; + float range = light_ptr->param[RS::LIGHT_PARAM_RANGE]; state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_RANGE, range); - float attenuation = light_ptr->param[VS::LIGHT_PARAM_ATTENUATION]; + float attenuation = light_ptr->param[RS::LIGHT_PARAM_ATTENUATION]; state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation); if (!state.render_no_shadows && light_ptr->shadow && shadow_atlas && shadow_atlas->shadow_owners.has(light->self)) { @@ -2101,7 +2101,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado uint32_t width = shadow_size; uint32_t height = shadow_size; - if (light->light_ptr->omni_shadow_detail == VS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { + if (light->light_ptr->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { height /= 2; } else { width /= 2; @@ -2121,7 +2121,7 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado } } break; - case VS::LIGHT_SPOT: { + case RS::LIGHT_SPOT: { Vector3 position = p_view_transform.xform_inv(light->transform.origin); @@ -2129,10 +2129,10 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado Vector3 direction = p_view_transform.inverse().basis.xform(light->transform.basis.xform(Vector3(0, 0, -1))).normalized(); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_DIRECTION, direction); - float attenuation = light_ptr->param[VS::LIGHT_PARAM_ATTENUATION]; - float range = light_ptr->param[VS::LIGHT_PARAM_RANGE]; - float spot_attenuation = light_ptr->param[VS::LIGHT_PARAM_SPOT_ATTENUATION]; - float angle = light_ptr->param[VS::LIGHT_PARAM_SPOT_ANGLE]; + float attenuation = light_ptr->param[RS::LIGHT_PARAM_ATTENUATION]; + float range = light_ptr->param[RS::LIGHT_PARAM_RANGE]; + float spot_attenuation = light_ptr->param[RS::LIGHT_PARAM_SPOT_ATTENUATION]; + float angle = light_ptr->param[RS::LIGHT_PARAM_SPOT_ANGLE]; angle = Math::cos(Math::deg2rad(angle)); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_ATTENUATION, attenuation); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SPOT_ATTENUATION, spot_attenuation); @@ -2259,19 +2259,19 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, bool prev_instancing = false; bool prev_depth_prepass = false; state.scene_shader.set_conditional(SceneShaderGLES2::SHADELESS, false); - RasterizerStorageGLES2::Material *prev_material = NULL; - RasterizerStorageGLES2::Geometry *prev_geometry = NULL; - RasterizerStorageGLES2::Skeleton *prev_skeleton = NULL; - RasterizerStorageGLES2::GeometryOwner *prev_owner = NULL; + RasterizerStorageGLES2::Material *prev_material = nullptr; + RasterizerStorageGLES2::Geometry *prev_geometry = nullptr; + RasterizerStorageGLES2::Skeleton *prev_skeleton = nullptr; + RasterizerStorageGLES2::GeometryOwner *prev_owner = nullptr; Transform view_transform_inverse = p_view_transform.inverse(); CameraMatrix projection_inverse = p_projection.inverse(); bool prev_base_pass = false; - LightInstance *prev_light = NULL; + LightInstance *prev_light = nullptr; bool prev_vertex_lit = false; - ReflectionProbeInstance *prev_refprobe_1 = NULL; - ReflectionProbeInstance *prev_refprobe_2 = NULL; + ReflectionProbeInstance *prev_refprobe_1 = nullptr; + ReflectionProbeInstance *prev_refprobe_2 = nullptr; int prev_blend_mode = -2; //will always catch the first go @@ -2299,7 +2299,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, using_fog = true; } - RasterizerStorageGLES2::Texture *prev_lightmap = NULL; + RasterizerStorageGLES2::Texture *prev_lightmap = nullptr; float lightmap_energy = 1.0; bool prev_use_lightmap_capture = false; @@ -2313,10 +2313,10 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, bool rebind = false; bool accum_pass = *e->use_accum_ptr; *e->use_accum_ptr = true; //set to accum for next time this is found - LightInstance *light = NULL; - ReflectionProbeInstance *refprobe_1 = NULL; - ReflectionProbeInstance *refprobe_2 = NULL; - RasterizerStorageGLES2::Texture *lightmap = NULL; + LightInstance *light = nullptr; + ReflectionProbeInstance *refprobe_1 = nullptr; + ReflectionProbeInstance *refprobe_2 = nullptr; + RasterizerStorageGLES2::Texture *lightmap = nullptr; bool use_lightmap_capture = false; bool rebind_light = false; bool rebind_reflection = false; @@ -2432,13 +2432,13 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } if (refprobe_1 != prev_refprobe_1 || refprobe_2 != prev_refprobe_2) { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE1, refprobe_1 != NULL); - state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE2, refprobe_2 != NULL); - if (refprobe_1 != NULL && refprobe_1 != prev_refprobe_1) { + state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE1, refprobe_1 != nullptr); + state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE2, refprobe_2 != nullptr); + if (refprobe_1 != nullptr && refprobe_1 != prev_refprobe_1) { glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5); glBindTexture(GL_TEXTURE_CUBE_MAP, refprobe_1->cubemap); } - if (refprobe_2 != NULL && refprobe_2 != prev_refprobe_2) { + if (refprobe_2 != nullptr && refprobe_2 != prev_refprobe_2) { glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 6); glBindTexture(GL_TEXTURE_CUBE_MAP, refprobe_2->cubemap); } @@ -2467,8 +2467,8 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, } if (lightmap != prev_lightmap) { - state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP, lightmap != NULL); - if (lightmap != NULL) { + state.scene_shader.set_conditional(SceneShaderGLES2::USE_LIGHTMAP, lightmap != nullptr); + if (lightmap != nullptr) { glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 4); glBindTexture(GL_TEXTURE_2D, lightmap->tex_id); } @@ -2490,7 +2490,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, rebind = true; } - bool instancing = e->instance->base_type == VS::INSTANCE_MULTIMESH; + bool instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH; if (instancing != prev_instancing) { @@ -2641,7 +2641,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, prev_use_lightmap_capture = use_lightmap_capture; } - _setup_light_type(NULL, NULL); //clear light stuff + _setup_light_type(nullptr, nullptr); //clear light stuff state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, false); state.scene_shader.set_conditional(SceneShaderGLES2::SHADELESS, false); state.scene_shader.set_conditional(SceneShaderGLES2::BASE_PASS, false); @@ -2726,10 +2726,10 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, vertices, GL_DYNAMIC_DRAW); // bind sky vertex array.... - glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, CAST_INT_TO_UCHAR_PTR(sizeof(Vector3))); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); + glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, 0); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 3, GL_FLOAT, GL_FALSE, sizeof(Vector3) * 2, CAST_INT_TO_UCHAR_PTR(sizeof(Vector3))); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_ASYM_PANO, asymmetrical); storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_PANORAMA, !asymmetrical); @@ -2752,8 +2752,8 @@ void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const C glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableVertexAttribArray(VS::ARRAY_VERTEX); - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + glDisableVertexAttribArray(RS::ARRAY_VERTEX); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV); glBindBuffer(GL_ARRAY_BUFFER, 0); storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_ASYM_PANO, false); @@ -2845,9 +2845,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::USE_ORTHOGONAL_PROJECTION, p_cam_projection.is_orthogonal()); state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_FAR_BLUR, true); - state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_LOW); - state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM); - state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_far_quality == VS::ENV_DOF_BLUR_QUALITY_HIGH); + state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_far_quality == RS::ENV_DOF_BLUR_QUALITY_LOW); + state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_far_quality == RS::ENV_DOF_BLUR_QUALITY_MEDIUM); + state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_far_quality == RS::ENV_DOF_BLUR_QUALITY_HIGH); state.effect_blur_shader.bind(); int qsteps[3] = { 4, 10, 20 }; @@ -2901,7 +2901,7 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p if (!storage->frame.current_rt->used_dof_blur_near) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); } int vp_h = storage->frame.current_rt->height; @@ -2911,9 +2911,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_BLUR, true); state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_NEAR_FIRST_TAP, true); - state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_LOW); - state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_MEDIUM); - state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_near_quality == VS::ENV_DOF_BLUR_QUALITY_HIGH); + state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_LOW, env->dof_blur_near_quality == RS::ENV_DOF_BLUR_QUALITY_LOW); + state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_MEDIUM, env->dof_blur_near_quality == RS::ENV_DOF_BLUR_QUALITY_MEDIUM); + state.effect_blur_shader.set_conditional(EffectBlurShaderGLES2::DOF_QUALITY_HIGH, env->dof_blur_near_quality == RS::ENV_DOF_BLUR_QUALITY_HIGH); state.effect_blur_shader.bind(); int qsteps[3] = { 4, 10, 20 }; @@ -3003,7 +3003,7 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p if (env->glow_enabled) { - for (int i = 0; i < VS::MAX_GLOW_LEVELS; i++) { + for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) { if (env->glow_levels & (1 << i)) { if (i >= storage->frame.current_rt->mip_maps[1].sizes.size()) { @@ -3156,9 +3156,9 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p } } - state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SCREEN, env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_SCREEN); - state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SOFTLIGHT, env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_SOFTLIGHT); - state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_REPLACE, env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_REPLACE); + state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SCREEN, env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_SCREEN); + state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_SOFTLIGHT, env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT); + state.tonemap_shader.set_conditional(TonemapShaderGLES2::USE_GLOW_REPLACE, env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_REPLACE); } //Adjustments @@ -3216,7 +3216,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const storage->info.render.object_count += p_cull_count; GLuint current_fb = 0; - Environment *env = NULL; + Environment *env = nullptr; int viewport_width, viewport_height; int viewport_x = 0; @@ -3288,7 +3288,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const LightInstance *light = light_instance_owner.getornull(light_rid); - if (light->light_ptr->type == VS::LIGHT_DIRECTIONAL) { + if (light->light_ptr->type == RS::LIGHT_DIRECTIONAL) { render_directional_lights++; //as going in reverse, directional lights are always first anyway } @@ -3300,7 +3300,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const } } else { - render_light_instances = NULL; + render_light_instances = nullptr; render_directional_lights = 0; render_light_instance_count = 0; } @@ -3318,11 +3318,11 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const } } else { - reflection_probe_instances = NULL; + reflection_probe_instances = nullptr; reflection_probe_count = 0; } - if (env && env->bg_mode == VS::ENV_BG_CANVAS) { + if (env && env->bg_mode == RS::ENV_BG_CANVAS) { // If using canvas background, copy 2d to screen copy texture // TODO: When GLES2 renders to current_rt->mip_maps[], this copy will no longer be needed _copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->copy_screen_effect.fbo); @@ -3358,22 +3358,22 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { clear_color = Color(0, 0, 0, 0); storage->frame.clear_request = false; - } else if (!env || env->bg_mode == VS::ENV_BG_CLEAR_COLOR || env->bg_mode == VS::ENV_BG_SKY) { + } else if (!env || env->bg_mode == RS::ENV_BG_CLEAR_COLOR || env->bg_mode == RS::ENV_BG_SKY) { if (storage->frame.clear_request) { clear_color = storage->frame.clear_request_color; storage->frame.clear_request = false; } - } else if (env->bg_mode == VS::ENV_BG_CANVAS || env->bg_mode == VS::ENV_BG_COLOR || env->bg_mode == VS::ENV_BG_COLOR_SKY) { + } else if (env->bg_mode == RS::ENV_BG_CANVAS || env->bg_mode == RS::ENV_BG_COLOR || env->bg_mode == RS::ENV_BG_COLOR_SKY) { clear_color = env->bg_color; storage->frame.clear_request = false; - } else if (env->bg_mode == VS::ENV_BG_CAMERA_FEED) { + } else if (env->bg_mode == RS::ENV_BG_CAMERA_FEED) { feed = CameraServer::get_singleton()->get_feed_by_id(env->camera_feed_id); storage->frame.clear_request = false; } else { storage->frame.clear_request = false; } - if (!env || env->bg_mode != VS::ENV_BG_KEEP) { + if (!env || env->bg_mode != RS::ENV_BG_KEEP) { glClearColor(clear_color.r, clear_color.g, clear_color.b, clear_color.a); glClear(GL_COLOR_BUFFER_BIT); } @@ -3385,26 +3385,26 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const glDisable(GL_SCISSOR_TEST); } - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // render sky - RasterizerStorageGLES2::Sky *sky = NULL; + RasterizerStorageGLES2::Sky *sky = nullptr; GLuint env_radiance_tex = 0; if (env) { switch (env->bg_mode) { - case VS::ENV_BG_COLOR_SKY: - case VS::ENV_BG_SKY: { + case RS::ENV_BG_COLOR_SKY: + case RS::ENV_BG_SKY: { sky = storage->sky_owner.getornull(env->sky); if (sky) { env_radiance_tex = sky->radiance; } } break; - case VS::ENV_BG_CAMERA_FEED: { + case RS::ENV_BG_CAMERA_FEED: { if (feed.is_valid() && (feed->get_base_width() > 0) && (feed->get_base_height() > 0)) { // copy our camera feed to our background @@ -3419,12 +3419,12 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const if (feed->get_datatype() == CameraFeed::FEED_RGB) { RID camera_RGBA = feed->get_texture(CameraServer::FEED_RGBA_IMAGE); - VS::get_singleton()->texture_bind(camera_RGBA, 0); + RS::get_singleton()->texture_bind(camera_RGBA, 0); } else if (feed->get_datatype() == CameraFeed::FEED_YCBCR) { RID camera_YCbCr = feed->get_texture(CameraServer::FEED_YCBCR_IMAGE); - VS::get_singleton()->texture_bind(camera_YCbCr, 0); + RS::get_singleton()->texture_bind(camera_YCbCr, 0); storage->shaders.copy.set_conditional(CopyShaderGLES2::YCBCR_TO_RGB, true); @@ -3432,8 +3432,8 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const RID camera_Y = feed->get_texture(CameraServer::FEED_Y_IMAGE); RID camera_CbCr = feed->get_texture(CameraServer::FEED_CBCR_IMAGE); - VS::get_singleton()->texture_bind(camera_Y, 0); - VS::get_singleton()->texture_bind(camera_CbCr, 1); + RS::get_singleton()->texture_bind(camera_Y, 0); + RS::get_singleton()->texture_bind(camera_CbCr, 1); storage->shaders.copy.set_conditional(CopyShaderGLES2::SEP_CBCR_TEXTURE, true); storage->shaders.copy.set_conditional(CopyShaderGLES2::YCBCR_TO_RGB, true); @@ -3444,8 +3444,8 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const storage->bind_quad_array(); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableVertexAttribArray(VS::ARRAY_VERTEX); - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); + glDisableVertexAttribArray(RS::ARRAY_VERTEX); + glDisableVertexAttribArray(RS::ARRAY_TEX_UV); glBindBuffer(GL_ARRAY_BUFFER, 0); // turn off everything used @@ -3464,7 +3464,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const clear_color = Color(0.0, 1.0, 0.0, 1.0); } } break; - case VS::ENV_BG_CANVAS: { + case RS::ENV_BG_CANVAS: { // use screen copy as background _copy_texture_to_buffer(storage->frame.current_rt->copy_screen_effect.color, current_fb); } break; @@ -3484,7 +3484,7 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const _render_render_list(render_list.elements, render_list.element_count, cam_transform, p_cam_projection, p_shadow_atlas, env, env_radiance_tex, 0.0, 0.0, reverse_cull, false, false); // then draw the sky after - if (env && env->bg_mode == VS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) { + if (env && env->bg_mode == RS::ENV_BG_SKY && (!storage->frame.current_rt || !storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT])) { if (sky && sky->panorama.is_valid()) { _draw_sky(sky, p_cam_projection, cam_transform, false, env->sky_custom_fov, env->bg_energy, env->sky_orientation); @@ -3616,7 +3616,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ // TODO directional light - if (light->type == VS::LIGHT_DIRECTIONAL) { + if (light->type == RS::LIGHT_DIRECTIONAL) { // set pssm stuff // TODO set this only when changed @@ -3651,7 +3651,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ width = light_instance->directional_rect.size.width; height = light_instance->directional_rect.size.height; - if (light->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { + if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { width /= 2; height /= 2; @@ -3665,7 +3665,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ y += height; } - } else if (light->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { + } else if (light->directional_shadow_mode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { height /= 2; @@ -3676,10 +3676,10 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ } } - float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, light->param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE]); - zfar = light->param[VS::LIGHT_PARAM_RANGE]; - bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS] * bias_mult; - normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult; + float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, light->param[RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE]); + zfar = light->param[RS::LIGHT_PARAM_RANGE]; + bias = light->param[RS::LIGHT_PARAM_SHADOW_BIAS] * bias_mult; + normal_bias = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult; fbo = directional_shadow.fbo; } else { @@ -3708,9 +3708,9 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ width = shadow_size; height = shadow_size; - if (light->type == VS::LIGHT_OMNI) { + if (light->type == RS::LIGHT_OMNI) { // cubemap only - if (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) { + if (light->omni_shadow_mode == RS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) { int cubemap_index = shadow_cubemaps.size() - 1; // find an appropriate cubemap to render to @@ -3727,7 +3727,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ light_transform = light_instance->shadow_transform[0].transform; custom_vp_size = shadow_cubemaps[cubemap_index].size; - zfar = light->param[VS::LIGHT_PARAM_RANGE]; + zfar = light->param[RS::LIGHT_PARAM_RANGE]; current_cubemap = cubemap_index; } else { @@ -3736,7 +3736,7 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ light_projection = light_instance->shadow_transform[0].camera; light_transform = light_instance->shadow_transform[0].transform; - if (light->omni_shadow_detail == VS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { + if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { height /= 2; y += p_pass * height; @@ -3747,22 +3747,22 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ state.dual_parbolloid_direction = p_pass == 0 ? 1.0 : -1.0; flip_facing = (p_pass == 1); - zfar = light->param[VS::LIGHT_PARAM_RANGE]; - bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS]; + zfar = light->param[RS::LIGHT_PARAM_RANGE]; + bias = light->param[RS::LIGHT_PARAM_SHADOW_BIAS]; state.dual_parbolloid_zfar = zfar; state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH_DUAL_PARABOLOID, true); } - } else if (light->type == VS::LIGHT_SPOT) { + } else if (light->type == RS::LIGHT_SPOT) { light_projection = light_instance->shadow_transform[0].camera; light_transform = light_instance->shadow_transform[0].transform; flip_facing = false; - zfar = light->param[VS::LIGHT_PARAM_RANGE]; - bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS]; - normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS]; + zfar = light->param[RS::LIGHT_PARAM_RANGE]; + bias = light->param[RS::LIGHT_PARAM_SHADOW_BIAS]; + normal_bias = light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS]; } } @@ -3806,13 +3806,13 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH, true); - _render_render_list(render_list.elements, render_list.element_count, light_transform, light_projection, RID(), NULL, 0, bias, normal_bias, flip_facing, false, true); + _render_render_list(render_list.elements, render_list.element_count, light_transform, light_projection, RID(), nullptr, 0, bias, normal_bias, flip_facing, false, true); state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH, false); state.scene_shader.set_conditional(SceneShaderGLES2::RENDER_DEPTH_DUAL_PARABOLOID, false); // convert cubemap to dual paraboloid if needed - if (light->type == VS::LIGHT_OMNI && (light->omni_shadow_mode == VS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) && p_pass == 5) { + if (light->type == RS::LIGHT_OMNI && (light->omni_shadow_mode == RS::LIGHT_OMNI_SHADOW_CUBE && storage->config.support_shadow_cubemaps) && p_pass == 5) { ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas); glBindFramebuffer(GL_FRAMEBUFFER, shadow_atlas->fbo); @@ -3827,14 +3827,14 @@ void RasterizerSceneGLES2::render_shadow(RID p_light, RID p_shadow_atlas, int p_ state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::Z_FLIP, i == 1); state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::Z_NEAR, light_projection.get_z_near()); state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::Z_FAR, light_projection.get_z_far()); - state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::BIAS, light->param[VS::LIGHT_PARAM_SHADOW_BIAS]); + state.cube_to_dp_shader.set_uniform(CubeToDpShaderGLES2::BIAS, light->param[RS::LIGHT_PARAM_SHADOW_BIAS]); uint32_t local_width = width; uint32_t local_height = height; uint32_t local_x = x; uint32_t local_y = y; - if (light->omni_shadow_detail == VS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { + if (light->omni_shadow_detail == RS::LIGHT_OMNI_SHADOW_DETAIL_HORIZONTAL) { local_height /= 2; local_y += i * local_height; } else { @@ -3922,7 +3922,7 @@ bool RasterizerSceneGLES2::free(RID p_rid) { return true; } -void RasterizerSceneGLES2::set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) { +void RasterizerSceneGLES2::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) { } void RasterizerSceneGLES2::initialize() { @@ -3977,7 +3977,7 @@ void RasterizerSceneGLES2::initialize() { { glGenBuffers(1, &state.sky_verts); glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts); - glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(Vector3) * 8, nullptr, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -3987,7 +3987,7 @@ void RasterizerSceneGLES2::initialize() { glGenBuffers(1, &state.immediate_buffer); glBindBuffer(GL_ARRAY_BUFFER, state.immediate_buffer); - glBufferData(GL_ARRAY_BUFFER, immediate_buffer_size * 1024, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, immediate_buffer_size * 1024, nullptr, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -4010,7 +4010,7 @@ void RasterizerSceneGLES2::initialize() { for (int i = 0; i < 6; i++) { - glTexImage2D(_cube_side_enum[i], 0, storage->config.depth_internalformat, cube_size, cube_size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, NULL); + glTexImage2D(_cube_side_enum[i], 0, storage->config.depth_internalformat, cube_size, cube_size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, nullptr); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -4050,7 +4050,7 @@ void RasterizerSceneGLES2::initialize() { glGenTextures(1, &directional_shadow.color); glBindTexture(GL_TEXTURE_2D, directional_shadow.color); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, directional_shadow.size, directional_shadow.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, directional_shadow.size, directional_shadow.size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -4061,7 +4061,7 @@ void RasterizerSceneGLES2::initialize() { glGenTextures(1, &directional_shadow.depth); glBindTexture(GL_TEXTURE_2D, directional_shadow.depth); - glTexImage2D(GL_TEXTURE_2D, 0, storage->config.depth_internalformat, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, storage->config.depth_internalformat, directional_shadow.size, directional_shadow.size, 0, GL_DEPTH_COMPONENT, storage->config.depth_type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index 174cdd8e2e..56c0e632c2 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -236,7 +236,7 @@ public: /* ENVIRONMENT API */ struct Environment { - VS::EnvironmentBG bg_mode; + RS::EnvironmentBG bg_mode; RID sky; float sky_custom_fov; @@ -259,7 +259,7 @@ public: float glow_intensity; float glow_strength; float glow_bloom; - VS::EnvironmentGlowBlendMode glow_blend_mode; + RS::EnvironmentGlowBlendMode glow_blend_mode; float glow_hdr_bleed_threshold; float glow_hdr_bleed_scale; float glow_hdr_luminance_cap; @@ -269,13 +269,13 @@ public: float dof_blur_far_distance; float dof_blur_far_transition; float dof_blur_far_amount; - VS::EnvironmentDOFBlurQuality dof_blur_far_quality; + RS::EnvironmentDOFBlurQuality dof_blur_far_quality; bool dof_blur_near_enabled; float dof_blur_near_distance; float dof_blur_near_transition; float dof_blur_near_amount; - VS::EnvironmentDOFBlurQuality dof_blur_near_quality; + RS::EnvironmentDOFBlurQuality dof_blur_near_quality; bool adjustments_enabled; float adjustments_brightness; @@ -300,7 +300,7 @@ public: float fog_height_curve; Environment() : - bg_mode(VS::ENV_BG_CLEAR_COLOR), + bg_mode(RS::ENV_BG_CLEAR_COLOR), sky_custom_fov(0.0), bg_energy(1.0), sky_ambient(0), @@ -313,7 +313,7 @@ public: glow_intensity(0.8), glow_strength(1.0), glow_bloom(0.0), - glow_blend_mode(VS::ENV_GLOW_BLEND_MODE_SOFTLIGHT), + glow_blend_mode(RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT), glow_hdr_bleed_threshold(1.0), glow_hdr_bleed_scale(2.0), glow_hdr_luminance_cap(12.0), @@ -322,12 +322,12 @@ public: dof_blur_far_distance(10), dof_blur_far_transition(5), dof_blur_far_amount(0.1), - dof_blur_far_quality(VS::ENV_DOF_BLUR_QUALITY_MEDIUM), + dof_blur_far_quality(RS::ENV_DOF_BLUR_QUALITY_MEDIUM), dof_blur_near_enabled(false), dof_blur_near_distance(2), dof_blur_near_transition(1), dof_blur_near_amount(0.1), - dof_blur_near_quality(VS::ENV_DOF_BLUR_QUALITY_MEDIUM), + dof_blur_near_quality(RS::ENV_DOF_BLUR_QUALITY_MEDIUM), adjustments_enabled(false), adjustments_brightness(1.0), adjustments_contrast(1.0), @@ -353,7 +353,7 @@ public: virtual RID environment_create(); - virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg); + virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg); virtual void environment_set_sky(RID p_env, RID p_sky); virtual void environment_set_sky_custom_fov(RID p_env, float p_scale); virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation); @@ -363,15 +363,15 @@ public: virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0); virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id); - virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality); - virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, VS::EnvironmentDOFBlurQuality p_quality); - virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale); + virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality); + virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, RS::EnvironmentDOFBlurQuality p_quality); + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale); virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture); virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness); - virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness); + virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness); - virtual void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale); + virtual void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale); virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp); @@ -381,7 +381,7 @@ public: virtual bool is_environment(RID p_env); - virtual VS::EnvironmentBG environment_get_background(RID p_env); + virtual RS::EnvironmentBG environment_get_background(RID p_env); virtual int environment_get_canvas_max_layer(RID p_env); /* LIGHT INSTANCE */ @@ -575,7 +575,7 @@ public: _FORCE_INLINE_ Element *add_element() { if (element_count + alpha_element_count >= max_elements) - return NULL; + return nullptr; elements[element_count] = &base_elements[element_count]; return elements[element_count++]; @@ -583,7 +583,7 @@ public: _FORCE_INLINE_ Element *add_alpha_element() { if (element_count + alpha_element_count >= max_elements) { - return NULL; + return nullptr; } int idx = max_elements - alpha_element_count - 1; @@ -650,7 +650,7 @@ public: virtual bool free(RID p_rid); virtual void set_scene_pass(uint64_t p_pass); - virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw); + virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw); void iteration(); void initialize(); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index f76c7da8e1..409722ff82 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -34,7 +34,7 @@ #include "core/project_settings.h" #include "rasterizer_canvas_gles2.h" #include "rasterizer_scene_gles2.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" GLuint RasterizerStorageGLES2::system_fbo = 0; @@ -127,11 +127,11 @@ PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC glCompressedTexSubImage3DOES; void RasterizerStorageGLES2::bind_quad_array() const { glBindBuffer(GL_ARRAY_BUFFER, resources.quadie); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8)); + glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0); + glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(8)); - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); + glEnableVertexAttribArray(RS::ARRAY_VERTEX); + glEnableVertexAttribArray(RS::ARRAY_TEX_UV); } Ref<Image> RasterizerStorageGLES2::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const { @@ -549,15 +549,15 @@ RID RasterizerStorageGLES2::texture_create() { return texture_owner.make_rid(texture); } -void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VisualServer::TextureType p_type, uint32_t p_flags) { +void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RenderingServer::TextureType p_type, uint32_t p_flags) { GLenum format; GLenum internal_format; GLenum type; bool compressed = false; - if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) { - p_flags &= ~VS::TEXTURE_FLAG_MIPMAPS; // no mipies for video + if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) { + p_flags &= ~RS::TEXTURE_FLAG_MIPMAPS; // no mipies for video } Texture *texture = texture_owner.getornull(p_texture); @@ -570,15 +570,15 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ texture->type = p_type; switch (p_type) { - case VS::TEXTURE_TYPE_2D: { + case RS::TEXTURE_TYPE_2D: { texture->target = GL_TEXTURE_2D; texture->images.resize(1); } break; - case VS::TEXTURE_TYPE_CUBEMAP: { + case RS::TEXTURE_TYPE_CUBEMAP: { texture->target = GL_TEXTURE_CUBE_MAP; texture->images.resize(6); } break; - case VS::TEXTURE_TYPE_2D_ARRAY: { + case RS::TEXTURE_TYPE_2D_ARRAY: { if (config.texture_array_supported) { texture->target = GL_TEXTURE_2D_ARRAY; texture->images.resize(p_depth_3d); @@ -587,7 +587,7 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ return; } } break; - case VS::TEXTURE_TYPE_3D: { + case RS::TEXTURE_TYPE_3D: { if (config.texture_3d_supported) { texture->target = GL_TEXTURE_3D; texture->images.resize(p_depth_3d); @@ -611,12 +611,12 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ bool is_po2 = p_width == po2_width && p_height == po2_height; - if (!is_po2 && (p_flags & VS::TEXTURE_FLAG_REPEAT || p_flags & VS::TEXTURE_FLAG_MIPMAPS)) { + if (!is_po2 && (p_flags & RS::TEXTURE_FLAG_REPEAT || p_flags & RS::TEXTURE_FLAG_MIPMAPS)) { - if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) { + if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) { //not supported ERR_PRINT("Streaming texture for non power of 2 or has mipmaps on this hardware: " + texture->path + "'. Mipmaps and repeat disabled."); - texture->flags &= ~(VS::TEXTURE_FLAG_REPEAT | VS::TEXTURE_FLAG_MIPMAPS); + texture->flags &= ~(RS::TEXTURE_FLAG_REPEAT | RS::TEXTURE_FLAG_MIPMAPS); } else { texture->alloc_height = po2_height; texture->alloc_width = po2_width; @@ -640,7 +640,7 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ glBindTexture(texture->target, texture->tex_id); #if defined(GLES_OVER_GL) || defined(ANDROID_ENABLED) - if ((p_type == VS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == VS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) { + if ((p_type == RS::TEXTURE_TYPE_3D && config.texture_3d_supported) || (p_type == RS::TEXTURE_TYPE_2D_ARRAY && config.texture_array_supported)) { int width = p_width; int height = p_height; @@ -648,23 +648,23 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ int mipmaps = 0; - while (width > 0 || height > 0 || (p_type == VS::TEXTURE_TYPE_3D && depth > 0)) { + while (width > 0 || height > 0 || (p_type == RS::TEXTURE_TYPE_3D && depth > 0)) { width = MAX(1, width); height = MAX(1, height); depth = MAX(1, depth); - glTexImage3D(texture->target, mipmaps, internal_format, width, height, depth, 0, format, type, NULL); + glTexImage3D(texture->target, mipmaps, internal_format, width, height, depth, 0, format, type, nullptr); width /= 2; height /= 2; - if (p_type == VS::TEXTURE_TYPE_3D) { + if (p_type == RS::TEXTURE_TYPE_3D) { depth /= 2; } mipmaps++; - if (!(p_flags & VS::TEXTURE_FLAG_MIPMAPS)) + if (!(p_flags & RS::TEXTURE_FLAG_MIPMAPS)) break; } #ifdef GLES_OVER_GL @@ -674,9 +674,9 @@ void RasterizerStorageGLES2::texture_allocate(RID p_texture, int p_width, int p_ } else #endif - if (p_flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) { + if (p_flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) { //prealloc if video - glTexImage2D(texture->target, 0, internal_format, texture->alloc_width, texture->alloc_height, 0, format, type, NULL); + glTexImage2D(texture->target, 0, internal_format, texture->alloc_width, texture->alloc_height, 0, format, type, nullptr); } texture->active = true; @@ -686,7 +686,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); - if ((texture->type == VS::TEXTURE_TYPE_2D_ARRAY && !config.texture_array_supported) || (texture->type == VS::TEXTURE_TYPE_3D && !config.texture_3d_supported)) { + if ((texture->type == RS::TEXTURE_TYPE_2D_ARRAY && !config.texture_array_supported) || (texture->type == RS::TEXTURE_TYPE_3D && !config.texture_3d_supported)) { return; } ERR_FAIL_COND(!texture->active); @@ -699,7 +699,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p GLenum internal_format; bool compressed = false; - if (config.keep_original_textures && !(texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { + if (config.keep_original_textures && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) { texture->images.write[p_layer] = p_image; } @@ -717,7 +717,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p img->resize_to_po2(false); } - if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING)) { + if (config.shrink_textures_x2 && (p_image->has_mipmaps() || !p_image->is_compressed()) && !(texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING)) { texture->alloc_height = MAX(1, texture->alloc_height / 2); texture->alloc_width = MAX(1, texture->alloc_width / 2); @@ -734,17 +734,17 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p GLenum blit_target = GL_TEXTURE_2D; switch (texture->type) { - case VS::TEXTURE_TYPE_2D: { + case RS::TEXTURE_TYPE_2D: { blit_target = GL_TEXTURE_2D; } break; - case VS::TEXTURE_TYPE_CUBEMAP: { + case RS::TEXTURE_TYPE_CUBEMAP: { ERR_FAIL_INDEX(p_layer, 6); blit_target = _cube_side_enum[p_layer]; } break; - case VS::TEXTURE_TYPE_2D_ARRAY: { + case RS::TEXTURE_TYPE_2D_ARRAY: { blit_target = GL_TEXTURE_2D_ARRAY; } break; - case VS::TEXTURE_TYPE_3D: { + case RS::TEXTURE_TYPE_3D: { blit_target = GL_TEXTURE_3D; } break; } @@ -758,17 +758,17 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p texture->ignore_mipmaps = compressed && !img->has_mipmaps(); - if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) + if ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); else { - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { + if (texture->flags & RS::TEXTURE_FLAG_FILTER) { glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } } - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { + if (texture->flags & RS::TEXTURE_FLAG_FILTER) { glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering @@ -777,9 +777,9 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering } - if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) { + if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) { - if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) { + if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); } else { @@ -793,7 +793,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } - int mipmaps = ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1; + int mipmaps = ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && img->has_mipmaps()) ? img->get_mipmap_count() + 1 : 1; int w = img->get_width(); int h = img->get_height(); @@ -804,7 +804,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p int size, ofs; img->get_mipmap_offset_and_size(i, ofs, size); - if (texture->type == VS::TEXTURE_TYPE_2D || texture->type == VS::TEXTURE_TYPE_CUBEMAP) { + if (texture->type == RS::TEXTURE_TYPE_2D || texture->type == RS::TEXTURE_TYPE_CUBEMAP) { if (compressed) { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); @@ -816,7 +816,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p } else { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - if (texture->flags & VS::TEXTURE_FLAG_USED_FOR_STREAMING) { + if (texture->flags & RS::TEXTURE_FLAG_USED_FOR_STREAMING) { glTexSubImage2D(blit_target, i, 0, 0, w, h, format, type, &read[ofs]); } else { glTexImage2D(blit_target, i, internal_format, w, h, 0, format, type, &read[ofs]); @@ -854,7 +854,7 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p texture->stored_cube_sides |= (1 << p_layer); - if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && mipmaps == 1 && !texture->ignore_mipmaps && (texture->type != VS::TEXTURE_TYPE_CUBEMAP || texture->stored_cube_sides == (1 << 6) - 1)) { + if ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && mipmaps == 1 && !texture->ignore_mipmaps && (texture->type != RS::TEXTURE_TYPE_CUBEMAP || texture->stored_cube_sides == (1 << 6) - 1)) { //generate mipmaps if they were requested and the image does not contain them glGenerateMipmap(texture->target); } @@ -875,7 +875,7 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) ERR_FAIL_COND_V(!texture->active, Ref<Image>()); ERR_FAIL_COND_V(texture->data_size == 0 && !texture->render_target, Ref<Image>()); - if (texture->type == VS::TEXTURE_TYPE_CUBEMAP && p_layer < 6 && p_layer >= 0 && !texture->images[p_layer].is_null()) { + if (texture->type == RS::TEXTURE_TYPE_CUBEMAP && p_layer < 6 && p_layer >= 0 && !texture->images[p_layer].is_null()) { return texture->images[p_layer]; } @@ -946,7 +946,7 @@ Ref<Image> RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) glBindFramebuffer(GL_FRAMEBUFFER, temp_framebuffer); glBindTexture(GL_TEXTURE_2D, temp_color_texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->alloc_width, texture->alloc_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->alloc_width, texture->alloc_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -997,16 +997,16 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); - bool had_mipmaps = texture->flags & VS::TEXTURE_FLAG_MIPMAPS; + bool had_mipmaps = texture->flags & RS::TEXTURE_FLAG_MIPMAPS; texture->flags = p_flags; glActiveTexture(GL_TEXTURE0); glBindTexture(texture->target, texture->tex_id); - if (((texture->flags & VS::TEXTURE_FLAG_REPEAT) || (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) { + if (((texture->flags & RS::TEXTURE_FLAG_REPEAT) || (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT)) && texture->target != GL_TEXTURE_CUBE_MAP) { - if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) { + if (texture->flags & RS::TEXTURE_FLAG_MIRRORED_REPEAT) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); } else { @@ -1019,21 +1019,21 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } - if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) { + if ((texture->flags & RS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) { if (!had_mipmaps && texture->mipmaps == 1) { glGenerateMipmap(texture->target); } glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); } else { - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { + if (texture->flags & RS::TEXTURE_FLAG_FILTER) { glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } else { glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } } - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { + if (texture->flags & RS::TEXTURE_FLAG_FILTER) { glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering @@ -1059,10 +1059,10 @@ Image::Format RasterizerStorageGLES2::texture_get_format(RID p_texture) const { return texture->format; } -VisualServer::TextureType RasterizerStorageGLES2::texture_get_type(RID p_texture) const { +RenderingServer::TextureType RasterizerStorageGLES2::texture_get_type(RID p_texture) const { Texture *texture = texture_owner.getornull(p_texture); - ERR_FAIL_COND_V(!texture, VS::TEXTURE_TYPE_2D); + ERR_FAIL_COND_V(!texture, RS::TEXTURE_TYPE_2D); return texture->type; } @@ -1135,7 +1135,7 @@ String RasterizerStorageGLES2::texture_get_path(RID p_texture) const { return texture->path; } -void RasterizerStorageGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info) { +void RasterizerStorageGLES2::texture_debug_usage(List<RS::TextureInfo> *r_info) { List<RID> textures; texture_owner.get_owned_list(&textures); @@ -1144,7 +1144,7 @@ void RasterizerStorageGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info) Texture *t = texture_owner.getornull(E->get()); if (!t) continue; - VS::TextureInfo tinfo; + RS::TextureInfo tinfo; tinfo.path = t->path; tinfo.format = t->format; tinfo.width = t->alloc_width; @@ -1180,7 +1180,7 @@ void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) { if (texture->proxy) { texture->proxy->proxy_owners.erase(texture); - texture->proxy = NULL; + texture->proxy = nullptr; } if (p_proxy.is_valid()) { @@ -1200,7 +1200,7 @@ void RasterizerStorageGLES2::texture_set_force_redraw_if_visible(RID p_texture, texture->redraw_if_visible = p_enable; } -void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) { Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); @@ -1208,7 +1208,7 @@ void RasterizerStorageGLES2::texture_set_detect_3d_callback(RID p_texture, Visua texture->detect_3d_ud = p_userdata; } -void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) { Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); @@ -1216,7 +1216,7 @@ void RasterizerStorageGLES2::texture_set_detect_srgb_callback(RID p_texture, Vis texture->detect_srgb_ud = p_userdata; } -void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageGLES2::texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata) { Texture *texture = texture_owner.getornull(p_texture); ERR_FAIL_COND(!texture); @@ -1265,7 +1265,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra glDisable(GL_SCISSOR_TEST); glDisable(GL_BLEND); - for (int i = 0; i < VS::ARRAY_MAX - 1; i++) { + for (int i = 0; i < RS::ARRAY_MAX - 1; i++) { glDisableVertexAttribArray(i); } } @@ -1301,7 +1301,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra // Mobile hardware (PowerVR specially) prefers this approach, // the previous approach with manual lod levels kills the game. for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, size, size, 0, format, type, NULL); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, size, size, 0, format, type, nullptr); } glGenerateMipmap(GL_TEXTURE_CUBE_MAP); @@ -1330,7 +1330,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra //make framebuffer size the texture size, need to use a separate texture for compatibility glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, resources.mipmap_blur_color); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, resources.mipmap_blur_color, 0); if (lod == 1) { @@ -1397,7 +1397,7 @@ void RasterizerStorageGLES2::sky_set_texture(RID p_sky, RID p_panorama, int p_ra RID RasterizerStorageGLES2::shader_create() { Shader *shader = memnew(Shader); - shader->mode = VS::SHADER_SPATIAL; + shader->mode = RS::SHADER_SPATIAL; shader->shader = &scene->state.scene_shader; RID rid = shader_owner.make_rid(shader); _shader_make_dirty(shader); @@ -1421,16 +1421,16 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) shader->code = p_code; String mode_string = ShaderLanguage::get_shader_type(p_code); - VS::ShaderMode mode; + RS::ShaderMode mode; if (mode_string == "canvas_item") - mode = VS::SHADER_CANVAS_ITEM; + mode = RS::SHADER_CANVAS_ITEM; else if (mode_string == "particles") - mode = VS::SHADER_PARTICLES; + mode = RS::SHADER_PARTICLES; else if (mode_string == "sky") - mode = VS::SHADER_SKY; + mode = RS::SHADER_SKY; else - mode = VS::SHADER_SPATIAL; + mode = RS::SHADER_SPATIAL; if (shader->custom_code_id && mode != shader->mode) { shader->shader->free_custom_shader(shader->custom_code_id); @@ -1440,10 +1440,10 @@ void RasterizerStorageGLES2::shader_set_code(RID p_shader, const String &p_code) shader->mode = mode; // TODO handle all shader types - if (mode == VS::SHADER_CANVAS_ITEM) { + if (mode == RS::SHADER_CANVAS_ITEM) { shader->shader = &canvas->state.canvas_shader; - } else if (mode == VS::SHADER_SPATIAL) { + } else if (mode == RS::SHADER_SPATIAL) { shader->shader = &scene->state.scene_shader; } else { return; @@ -1477,11 +1477,11 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const { } ShaderCompilerGLES2::GeneratedCode gen_code; - ShaderCompilerGLES2::IdentifierActions *actions = NULL; + ShaderCompilerGLES2::IdentifierActions *actions = nullptr; switch (p_shader->mode) { - case VS::SHADER_CANVAS_ITEM: { + case RS::SHADER_CANVAS_ITEM: { p_shader->canvas_item.light_mode = Shader::CanvasItem::LIGHT_MODE_NORMAL; p_shader->canvas_item.blend_mode = Shader::CanvasItem::BLEND_MODE_MIX; @@ -1508,7 +1508,7 @@ void RasterizerStorageGLES2::_update_shader(Shader *p_shader) const { actions->uniforms = &p_shader->uniforms; } break; - case VS::SHADER_SPATIAL: { + case RS::SHADER_SPATIAL: { p_shader->spatial.blend_mode = Shader::Spatial::BLEND_MODE_MIX; p_shader->spatial.depth_draw_mode = Shader::Spatial::DEPTH_DRAW_OPAQUE; p_shader->spatial.cull_mode = Shader::Spatial::CULL_MODE_BACK; @@ -1949,8 +1949,8 @@ void RasterizerStorageGLES2::material_remove_instance_owner(RID p_material, Rast } void RasterizerStorageGLES2::material_set_render_priority(RID p_material, int priority) { - ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN); - ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX); + ERR_FAIL_COND(priority < RS::MATERIAL_RENDER_PRIORITY_MIN); + ERR_FAIL_COND(priority > RS::MATERIAL_RENDER_PRIORITY_MAX); Material *material = material_owner.getornull(p_material); ERR_FAIL_COND(!material); @@ -1975,7 +1975,7 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) { bool can_cast_shadow = false; bool is_animated = false; - if (p_material->shader && p_material->shader->mode == VS::SHADER_SPATIAL) { + if (p_material->shader && p_material->shader->mode == RS::SHADER_SPATIAL) { if (p_material->shader->spatial.blend_mode == Shader::Spatial::BLEND_MODE_MIX && (!p_material->shader->spatial.uses_alpha || p_material->shader->spatial.depth_draw_mode == Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS)) { @@ -2087,14 +2087,14 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ uint32_t p_format = format; - static int src_size[VS::ARRAY_MAX]; - static int dst_size[VS::ARRAY_MAX]; - static int to_convert[VS::ARRAY_MAX]; + static int src_size[RS::ARRAY_MAX]; + static int dst_size[RS::ARRAY_MAX]; + static int to_convert[RS::ARRAY_MAX]; int src_stride = 0; int dst_stride = 0; - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { to_convert[i] = 0; if (!(p_format & (1 << i))) { @@ -2105,11 +2105,11 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { - if (p_format & VS::ARRAY_COMPRESS_VERTEX) { + if (p_format & RS::ARRAY_COMPRESS_VERTEX) { - if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) { + if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { src_size[i] = 4; dst_size[i] = 8; to_convert[i] = 2; @@ -2119,10 +2119,10 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ to_convert[i] = 3; } - format &= ~VS::ARRAY_COMPRESS_VERTEX; + format &= ~RS::ARRAY_COMPRESS_VERTEX; } else { - if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) { + if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { src_size[i] = 8; dst_size[i] = 8; } else { @@ -2132,9 +2132,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { - if (p_format & VS::ARRAY_COMPRESS_NORMAL) { + if (p_format & RS::ARRAY_COMPRESS_NORMAL) { src_size[i] = 4; dst_size[i] = 4; } else { @@ -2143,9 +2143,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { - if (p_format & VS::ARRAY_COMPRESS_TANGENT) { + if (p_format & RS::ARRAY_COMPRESS_TANGENT) { src_size[i] = 4; dst_size[i] = 4; } else { @@ -2154,9 +2154,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { - if (p_format & VS::ARRAY_COMPRESS_COLOR) { + if (p_format & RS::ARRAY_COMPRESS_COLOR) { src_size[i] = 4; dst_size[i] = 4; } else { @@ -2165,12 +2165,12 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { - if (p_format & VS::ARRAY_COMPRESS_TEX_UV) { + if (p_format & RS::ARRAY_COMPRESS_TEX_UV) { src_size[i] = 4; to_convert[i] = 2; - format &= ~VS::ARRAY_COMPRESS_TEX_UV; + format &= ~RS::ARRAY_COMPRESS_TEX_UV; } else { src_size[i] = 8; } @@ -2178,12 +2178,12 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ dst_size[i] = 8; } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { - if (p_format & VS::ARRAY_COMPRESS_TEX_UV2) { + if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) { src_size[i] = 4; to_convert[i] = 2; - format &= ~VS::ARRAY_COMPRESS_TEX_UV2; + format &= ~RS::ARRAY_COMPRESS_TEX_UV2; } else { src_size[i] = 8; } @@ -2191,9 +2191,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ dst_size[i] = 8; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { - if (p_format & VS::ARRAY_FLAG_USE_16_BIT_BONES) { + if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) { src_size[i] = 8; dst_size[i] = 8; } else { @@ -2202,9 +2202,9 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { - if (p_format & VS::ARRAY_COMPRESS_WEIGHTS) { + if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) { src_size[i] = 8; dst_size[i] = 8; } else { @@ -2213,7 +2213,7 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ } } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { src_size[i] = 0; dst_size[i] = 0; @@ -2234,7 +2234,7 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ int src_offset = 0; int dst_offset = 0; - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { if (src_size[i] == 0) { continue; //no go @@ -2272,27 +2272,27 @@ static Vector<uint8_t> _unpack_half_floats(const Vector<uint8_t> &array, uint32_ return ret; } -void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { +void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); - ERR_FAIL_COND(!(p_format & VS::ARRAY_FORMAT_VERTEX)); + ERR_FAIL_COND(!(p_format & RS::ARRAY_FORMAT_VERTEX)); //must have index and bones, both. { - uint32_t bones_weight = VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS; + uint32_t bones_weight = RS::ARRAY_FORMAT_BONES | RS::ARRAY_FORMAT_WEIGHTS; ERR_FAIL_COND_MSG((p_format & bones_weight) && (p_format & bones_weight) != bones_weight, "Array must have both bones and weights in format or none."); } //bool has_morph = p_blend_shapes.size(); - Surface::Attrib attribs[VS::ARRAY_MAX]; + Surface::Attrib attribs[RS::ARRAY_MAX]; int stride = 0; bool uses_half_float = false; - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { attribs[i].index = i; @@ -2308,15 +2308,15 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { - if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) { + if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { attribs[i].size = 2; } else { - attribs[i].size = (p_format & VS::ARRAY_COMPRESS_VERTEX) ? 4 : 3; + attribs[i].size = (p_format & RS::ARRAY_COMPRESS_VERTEX) ? 4 : 3; } - if (p_format & VS::ARRAY_COMPRESS_VERTEX) { + if (p_format & RS::ARRAY_COMPRESS_VERTEX) { attribs[i].type = _GL_HALF_FLOAT_OES; stride += attribs[i].size * 2; uses_half_float = true; @@ -2328,11 +2328,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: attribs[i].normalized = GL_FALSE; } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { attribs[i].size = 3; - if (p_format & VS::ARRAY_COMPRESS_NORMAL) { + if (p_format & RS::ARRAY_COMPRESS_NORMAL) { attribs[i].type = GL_BYTE; stride += 4; //pad extra byte attribs[i].normalized = GL_TRUE; @@ -2343,11 +2343,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: } } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { attribs[i].size = 4; - if (p_format & VS::ARRAY_COMPRESS_TANGENT) { + if (p_format & RS::ARRAY_COMPRESS_TANGENT) { attribs[i].type = GL_BYTE; stride += 4; attribs[i].normalized = GL_TRUE; @@ -2358,11 +2358,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { attribs[i].size = 4; - if (p_format & VS::ARRAY_COMPRESS_COLOR) { + if (p_format & RS::ARRAY_COMPRESS_COLOR) { attribs[i].type = GL_UNSIGNED_BYTE; stride += 4; attribs[i].normalized = GL_TRUE; @@ -2373,11 +2373,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { attribs[i].size = 2; - if (p_format & VS::ARRAY_COMPRESS_TEX_UV) { + if (p_format & RS::ARRAY_COMPRESS_TEX_UV) { attribs[i].type = _GL_HALF_FLOAT_OES; stride += 4; uses_half_float = true; @@ -2389,11 +2389,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: attribs[i].normalized = GL_FALSE; } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { attribs[i].size = 2; - if (p_format & VS::ARRAY_COMPRESS_TEX_UV2) { + if (p_format & RS::ARRAY_COMPRESS_TEX_UV2) { attribs[i].type = _GL_HALF_FLOAT_OES; stride += 4; uses_half_float = true; @@ -2404,11 +2404,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: attribs[i].normalized = GL_FALSE; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { attribs[i].size = 4; - if (p_format & VS::ARRAY_FLAG_USE_16_BIT_BONES) { + if (p_format & RS::ARRAY_FLAG_USE_16_BIT_BONES) { attribs[i].type = GL_UNSIGNED_SHORT; stride += 8; } else { @@ -2420,11 +2420,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: attribs[i].integer = true; } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { attribs[i].size = 4; - if (p_format & VS::ARRAY_COMPRESS_WEIGHTS) { + if (p_format & RS::ARRAY_COMPRESS_WEIGHTS) { attribs[i].type = GL_UNSIGNED_SHORT; stride += 8; @@ -2436,7 +2436,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: } } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { attribs[i].size = 1; @@ -2454,7 +2454,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: } } - for (int i = 0; i < VS::ARRAY_MAX - 1; i++) { + for (int i = 0; i < RS::ARRAY_MAX - 1; i++) { attribs[i].stride = stride; } @@ -2500,9 +2500,9 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: return; //do not go any further, above function used unpacked stuff will be used instead. } - if (p_format & VS::ARRAY_FORMAT_INDEX) { + if (p_format & RS::ARRAY_FORMAT_INDEX) { - index_array_size = attribs[VS::ARRAY_INDEX].stride * p_index_count; + index_array_size = attribs[RS::ARRAY_INDEX].stride * p_index_count; } ERR_FAIL_COND(p_index_array.size() != index_array_size); @@ -2545,7 +2545,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: surface->skeleton_bone_used.write[i] = !(surface->skeleton_bone_aabb[i].size.x < 0 || surface->skeleton_bone_aabb[i].size.y < 0 || surface->skeleton_bone_aabb[i].size.z < 0); } - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { surface->attribs[i] = attribs[i]; } @@ -2555,11 +2555,11 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: glGenBuffers(1, &surface->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id); - glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), (p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), (p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); - if (p_format & VS::ARRAY_FORMAT_INDEX) { + if (p_format & RS::ARRAY_FORMAT_INDEX) { const uint8_t *ir = p_index_array.ptr(); glGenBuffers(1, &surface->index_id); @@ -2616,16 +2616,16 @@ int RasterizerStorageGLES2::mesh_get_blend_shape_count(RID p_mesh) const { return mesh->blend_shape_count; } -void RasterizerStorageGLES2::mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) { +void RasterizerStorageGLES2::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); mesh->blend_shape_mode = p_mode; } -VS::BlendShapeMode RasterizerStorageGLES2::mesh_get_blend_shape_mode(RID p_mesh) const { +RS::BlendShapeMode RasterizerStorageGLES2::mesh_get_blend_shape_mode(RID p_mesh) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::BLEND_SHAPE_MODE_NORMALIZED); + ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED); return mesh->blend_shape_mode; } @@ -2723,10 +2723,10 @@ uint32_t RasterizerStorageGLES2::mesh_surface_get_format(RID p_mesh, int p_surfa return mesh->surfaces[p_surface]->format; } -VS::PrimitiveType RasterizerStorageGLES2::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { +RS::PrimitiveType RasterizerStorageGLES2::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_MAX); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), VS::PRIMITIVE_MAX); + ERR_FAIL_COND_V(!mesh, RS::PRIMITIVE_MAX); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), RS::PRIMITIVE_MAX); return mesh->surfaces[p_surface]->primitive; } @@ -2815,7 +2815,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { if (mesh->custom_aabb != AABB()) return mesh->custom_aabb; - Skeleton *sk = NULL; + Skeleton *sk = nullptr; if (p_skeleton.is_valid()) { sk = skeleton_owner.getornull(p_skeleton); } @@ -2827,7 +2827,7 @@ AABB RasterizerStorageGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { for (int i = 0; i < mesh->surfaces.size(); i++) { AABB laabb; - if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) { + if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) { int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); @@ -2939,7 +2939,7 @@ RID RasterizerStorageGLES2::multimesh_create() { return multimesh_owner.make_rid(multimesh); } -void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data) { +void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, RS::MultimeshColorFormat p_color_format, RS::MultimeshCustomDataFormat p_data) { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); @@ -2957,23 +2957,23 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances multimesh->data.resize(0); } - if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) { + if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) { multimesh->xform_floats = 8; } else { multimesh->xform_floats = 12; } - if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) { multimesh->color_floats = 1; - } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) { + } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) { multimesh->color_floats = 4; } else { multimesh->color_floats = 0; } - if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { multimesh->custom_data_floats = 1; - } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) { + } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) { multimesh->custom_data_floats = 4; } else { multimesh->custom_data_floats = 0; @@ -2987,7 +2987,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances int color_from = 0; int custom_data_from = 0; - if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) { + if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) { multimesh->data.write[i + 0] = 1.0; multimesh->data.write[i + 1] = 0.0; multimesh->data.write[i + 2] = 0.0; @@ -3015,7 +3015,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances custom_data_from = 12; } - if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) { union { uint32_t colu; float colf; @@ -3024,7 +3024,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances cu.colu = 0xFFFFFFFF; multimesh->data.write[i + color_from + 0] = cu.colf; custom_data_from = color_from + 1; - } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) { + } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) { multimesh->data.write[i + color_from + 0] = 1.0; multimesh->data.write[i + color_from + 1] = 1.0; multimesh->data.write[i + color_from + 2] = 1.0; @@ -3032,7 +3032,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances custom_data_from = color_from + 4; } - if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { union { uint32_t colu; float colf; @@ -3040,7 +3040,7 @@ void RasterizerStorageGLES2::multimesh_allocate(RID p_multimesh, int p_instances cu.colu = 0; multimesh->data.write[i + custom_data_from + 0] = cu.colf; - } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) { + } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) { multimesh->data.write[i + custom_data_from + 0] = 0.0; multimesh->data.write[i + custom_data_from + 1] = 0.0; multimesh->data.write[i + custom_data_from + 2] = 0.0; @@ -3094,7 +3094,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_transform(RID p_multimesh, i MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->size); - ERR_FAIL_COND(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D); + ERR_FAIL_COND(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D); int stride = multimesh->color_floats + multimesh->custom_data_floats + multimesh->xform_floats; @@ -3125,7 +3125,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_transform_2d(RID p_multimesh MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->size); - ERR_FAIL_COND(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_3D); + ERR_FAIL_COND(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_3D); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index]; @@ -3151,13 +3151,13 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->size); - ERR_FAIL_COND(multimesh->color_format == VS::MULTIMESH_COLOR_NONE); - ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_MAX); + ERR_FAIL_COND(multimesh->color_format == RS::MULTIMESH_COLOR_NONE); + ERR_FAIL_INDEX(multimesh->color_format, RS::MULTIMESH_COLOR_MAX); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats]; - if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) { uint8_t *data8 = (uint8_t *)dataptr; data8[0] = CLAMP(p_color.r * 255.0, 0, 255); @@ -3165,7 +3165,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p data8[2] = CLAMP(p_color.b * 255.0, 0, 255); data8[3] = CLAMP(p_color.a * 255.0, 0, 255); - } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) { + } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) { dataptr[0] = p_color.r; dataptr[1] = p_color.g; dataptr[2] = p_color.b; @@ -3184,13 +3184,13 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh, MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->size); - ERR_FAIL_COND(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE); - ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX); + ERR_FAIL_COND(multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_NONE); + ERR_FAIL_INDEX(multimesh->custom_data_format, RS::MULTIMESH_CUSTOM_DATA_MAX); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats]; - if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { uint8_t *data8 = (uint8_t *)dataptr; data8[0] = CLAMP(p_custom_data.r * 255.0, 0, 255); @@ -3198,7 +3198,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh, data8[2] = CLAMP(p_custom_data.b * 255.0, 0, 255); data8[3] = CLAMP(p_custom_data.a * 255.0, 0, 255); - } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) { + } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) { dataptr[0] = p_custom_data.r; dataptr[1] = p_custom_data.g; dataptr[2] = p_custom_data.b; @@ -3224,7 +3224,7 @@ Transform RasterizerStorageGLES2::multimesh_instance_get_transform(RID p_multime MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND_V(!multimesh, Transform()); ERR_FAIL_INDEX_V(p_index, multimesh->size, Transform()); - ERR_FAIL_COND_V(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D, Transform()); + ERR_FAIL_COND_V(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D, Transform()); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index]; @@ -3251,7 +3251,7 @@ Transform2D RasterizerStorageGLES2::multimesh_instance_get_transform_2d(RID p_mu MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND_V(!multimesh, Transform2D()); ERR_FAIL_INDEX_V(p_index, multimesh->size, Transform2D()); - ERR_FAIL_COND_V(multimesh->transform_format == VS::MULTIMESH_TRANSFORM_3D, Transform2D()); + ERR_FAIL_COND_V(multimesh->transform_format == RS::MULTIMESH_TRANSFORM_3D, Transform2D()); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index]; @@ -3272,13 +3272,13 @@ Color RasterizerStorageGLES2::multimesh_instance_get_color(RID p_multimesh, int MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND_V(!multimesh, Color()); ERR_FAIL_INDEX_V(p_index, multimesh->size, Color()); - ERR_FAIL_COND_V(multimesh->color_format == VS::MULTIMESH_COLOR_NONE, Color()); - ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_MAX, Color()); + ERR_FAIL_COND_V(multimesh->color_format == RS::MULTIMESH_COLOR_NONE, Color()); + ERR_FAIL_INDEX_V(multimesh->color_format, RS::MULTIMESH_COLOR_MAX, Color()); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats]; - if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multimesh->color_format == RS::MULTIMESH_COLOR_8BIT) { union { uint32_t colu; float colf; @@ -3288,7 +3288,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_color(RID p_multimesh, int return Color::hex(BSWAP32(cu.colu)); - } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) { + } else if (multimesh->color_format == RS::MULTIMESH_COLOR_FLOAT) { Color c; c.r = dataptr[0]; c.g = dataptr[1]; @@ -3305,13 +3305,13 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND_V(!multimesh, Color()); ERR_FAIL_INDEX_V(p_index, multimesh->size, Color()); - ERR_FAIL_COND_V(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE, Color()); - ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX, Color()); + ERR_FAIL_COND_V(multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_NONE, Color()); + ERR_FAIL_INDEX_V(multimesh->custom_data_format, RS::MULTIMESH_CUSTOM_DATA_MAX, Color()); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats]; - if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_8BIT) { union { uint32_t colu; float colf; @@ -3321,7 +3321,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh return Color::hex(BSWAP32(cu.colu)); - } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) { + } else if (multimesh->custom_data_format == RS::MULTIMESH_CUSTOM_DATA_FLOAT) { Color c; c.r = dataptr[0]; c.g = dataptr[1]; @@ -3400,7 +3400,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() { AABB aabb; - if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) { + if (multimesh->transform_format == RS::MULTIMESH_TRANSFORM_2D) { for (int i = 0; i < count; i += stride) { @@ -3472,7 +3472,7 @@ RID RasterizerStorageGLES2::immediate_create() { return immediate_owner.make_rid(im); } -void RasterizerStorageGLES2::immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture) { +void RasterizerStorageGLES2::immediate_begin(RID p_immediate, RS::PrimitiveType p_primitive, RID p_texture) { Immediate *im = immediate_owner.getornull(p_immediate); ERR_FAIL_COND(!im); ERR_FAIL_COND(im->building); @@ -3499,17 +3499,17 @@ void RasterizerStorageGLES2::immediate_vertex(RID p_immediate, const Vector3 &p_ im->aabb.expand_to(p_vertex); } - if (im->mask & VS::ARRAY_FORMAT_NORMAL) + if (im->mask & RS::ARRAY_FORMAT_NORMAL) c->normals.push_back(chunk_normal); - if (im->mask & VS::ARRAY_FORMAT_TANGENT) + if (im->mask & RS::ARRAY_FORMAT_TANGENT) c->tangents.push_back(chunk_tangent); - if (im->mask & VS::ARRAY_FORMAT_COLOR) + if (im->mask & RS::ARRAY_FORMAT_COLOR) c->colors.push_back(chunk_color); - if (im->mask & VS::ARRAY_FORMAT_TEX_UV) + if (im->mask & RS::ARRAY_FORMAT_TEX_UV) c->uvs.push_back(chunk_uv); - if (im->mask & VS::ARRAY_FORMAT_TEX_UV2) + if (im->mask & RS::ARRAY_FORMAT_TEX_UV2) c->uv2s.push_back(chunk_uv2); - im->mask |= VS::ARRAY_FORMAT_VERTEX; + im->mask |= RS::ARRAY_FORMAT_VERTEX; c->vertices.push_back(p_vertex); } @@ -3518,7 +3518,7 @@ void RasterizerStorageGLES2::immediate_normal(RID p_immediate, const Vector3 &p_ ERR_FAIL_COND(!im); ERR_FAIL_COND(!im->building); - im->mask |= VS::ARRAY_FORMAT_NORMAL; + im->mask |= RS::ARRAY_FORMAT_NORMAL; chunk_normal = p_normal; } @@ -3527,7 +3527,7 @@ void RasterizerStorageGLES2::immediate_tangent(RID p_immediate, const Plane &p_t ERR_FAIL_COND(!im); ERR_FAIL_COND(!im->building); - im->mask |= VS::ARRAY_FORMAT_TANGENT; + im->mask |= RS::ARRAY_FORMAT_TANGENT; chunk_tangent = p_tangent; } @@ -3536,7 +3536,7 @@ void RasterizerStorageGLES2::immediate_color(RID p_immediate, const Color &p_col ERR_FAIL_COND(!im); ERR_FAIL_COND(!im->building); - im->mask |= VS::ARRAY_FORMAT_COLOR; + im->mask |= RS::ARRAY_FORMAT_COLOR; chunk_color = p_color; } @@ -3545,7 +3545,7 @@ void RasterizerStorageGLES2::immediate_uv(RID p_immediate, const Vector2 &tex_uv ERR_FAIL_COND(!im); ERR_FAIL_COND(!im->building); - im->mask |= VS::ARRAY_FORMAT_TEX_UV; + im->mask |= RS::ARRAY_FORMAT_TEX_UV; chunk_uv = tex_uv; } @@ -3554,7 +3554,7 @@ void RasterizerStorageGLES2::immediate_uv2(RID p_immediate, const Vector2 &tex_u ERR_FAIL_COND(!im); ERR_FAIL_COND(!im->building); - im->mask |= VS::ARRAY_FORMAT_TEX_UV2; + im->mask |= RS::ARRAY_FORMAT_TEX_UV2; chunk_uv2 = tex_uv; } @@ -3626,9 +3626,9 @@ void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool glBindTexture(GL_TEXTURE_2D, skeleton->tex_id); #ifdef GLES_OVER_GL - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, p_bones * (skeleton->use_2d ? 2 : 3), 1, 0, GL_RGBA, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, p_bones * (skeleton->use_2d ? 2 : 3), 1, 0, GL_RGBA, GL_FLOAT, nullptr); #else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_bones * (skeleton->use_2d ? 2 : 3), 1, 0, GL_RGBA, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_bones * (skeleton->use_2d ? 2 : 3), 1, 0, GL_RGBA, GL_FLOAT, nullptr); #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -3812,34 +3812,34 @@ void RasterizerStorageGLES2::update_dirty_skeletons() { /* Light API */ -RID RasterizerStorageGLES2::light_create(VS::LightType p_type) { +RID RasterizerStorageGLES2::light_create(RS::LightType p_type) { Light *light = memnew(Light); light->type = p_type; - light->param[VS::LIGHT_PARAM_ENERGY] = 1.0; - light->param[VS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0; - light->param[VS::LIGHT_PARAM_SPECULAR] = 0.5; - light->param[VS::LIGHT_PARAM_RANGE] = 1.0; - light->param[VS::LIGHT_PARAM_SPOT_ANGLE] = 45; - light->param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45; - light->param[VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0; - light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1; - light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3; - light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6; - light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1; - light->param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1; + light->param[RS::LIGHT_PARAM_ENERGY] = 1.0; + light->param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0; + light->param[RS::LIGHT_PARAM_SPECULAR] = 0.5; + light->param[RS::LIGHT_PARAM_RANGE] = 1.0; + light->param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45; + light->param[RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45; + light->param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0; + light->param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1; + light->param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3; + light->param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6; + light->param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1; + light->param[RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1; light->color = Color(1, 1, 1, 1); light->shadow = false; light->negative = false; light->cull_mask = 0xFFFFFFFF; - light->directional_shadow_mode = VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; - light->omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; - light->omni_shadow_detail = VS::LIGHT_OMNI_SHADOW_DETAIL_VERTICAL; + light->directional_shadow_mode = RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; + light->omni_shadow_mode = RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; + light->omni_shadow_detail = RS::LIGHT_OMNI_SHADOW_DETAIL_VERTICAL; light->directional_blend_splits = false; - light->directional_range_mode = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; + light->directional_range_mode = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; light->reverse_cull = false; light->use_gi = true; light->version = 0; @@ -3854,20 +3854,20 @@ void RasterizerStorageGLES2::light_set_color(RID p_light, const Color &p_color) light->color = p_color; } -void RasterizerStorageGLES2::light_set_param(RID p_light, VS::LightParam p_param, float p_value) { +void RasterizerStorageGLES2::light_set_param(RID p_light, RS::LightParam p_param, float p_value) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); - ERR_FAIL_INDEX(p_param, VS::LIGHT_PARAM_MAX); + ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX); switch (p_param) { - case VS::LIGHT_PARAM_RANGE: - case VS::LIGHT_PARAM_SPOT_ANGLE: - case VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE: - case VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET: - case VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET: - case VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET: - case VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS: - case VS::LIGHT_PARAM_SHADOW_BIAS: { + case RS::LIGHT_PARAM_RANGE: + case RS::LIGHT_PARAM_SPOT_ANGLE: + case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE: + case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET: + case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET: + case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET: + case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS: + case RS::LIGHT_PARAM_SHADOW_BIAS: { light->version++; light->instance_change_notify(true, false); } break; @@ -3939,7 +3939,7 @@ void RasterizerStorageGLES2::light_set_use_gi(RID p_light, bool p_enabled) { light->instance_change_notify(true, false); } -void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) { +void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); @@ -3949,14 +3949,14 @@ void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOm light->instance_change_notify(true, false); } -VS::LightOmniShadowMode RasterizerStorageGLES2::light_omni_get_shadow_mode(RID p_light) { +RS::LightOmniShadowMode RasterizerStorageGLES2::light_omni_get_shadow_mode(RID p_light) { Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI_SHADOW_CUBE); + ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE); return light->omni_shadow_mode; } -void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) { +void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); @@ -3966,7 +3966,7 @@ void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, VS::Light light->instance_change_notify(true, false); } -void RasterizerStorageGLES2::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) { +void RasterizerStorageGLES2::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); @@ -3992,37 +3992,37 @@ bool RasterizerStorageGLES2::light_directional_get_blend_splits(RID p_light) con return light->directional_blend_splits; } -VS::LightDirectionalShadowMode RasterizerStorageGLES2::light_directional_get_shadow_mode(RID p_light) { +RS::LightDirectionalShadowMode RasterizerStorageGLES2::light_directional_get_shadow_mode(RID p_light) { Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL); return light->directional_shadow_mode; } -void RasterizerStorageGLES2::light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) { +void RasterizerStorageGLES2::light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); light->directional_range_mode = p_range_mode; } -VS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES2::light_directional_get_shadow_depth_range_mode(RID p_light) const { +RS::LightDirectionalShadowDepthRangeMode RasterizerStorageGLES2::light_directional_get_shadow_depth_range_mode(RID p_light) const { Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE); return light->directional_range_mode; } -VS::LightType RasterizerStorageGLES2::light_get_type(RID p_light) const { +RS::LightType RasterizerStorageGLES2::light_get_type(RID p_light) const { Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL); return light->type; } -float RasterizerStorageGLES2::light_get_param(RID p_light, VS::LightParam p_param) { +float RasterizerStorageGLES2::light_get_param(RID p_light, RS::LightParam p_param) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND_V(!light, 0.0); - ERR_FAIL_INDEX_V(p_param, VS::LIGHT_PARAM_MAX, 0.0); + ERR_FAIL_INDEX_V(p_param, RS::LIGHT_PARAM_MAX, 0.0); return light->param[p_param]; } @@ -4061,18 +4061,18 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const { switch (light->type) { - case VS::LIGHT_SPOT: { - float len = light->param[VS::LIGHT_PARAM_RANGE]; - float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; + case RS::LIGHT_SPOT: { + float len = light->param[RS::LIGHT_PARAM_RANGE]; + float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len; return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); }; - case VS::LIGHT_OMNI: { - float r = light->param[VS::LIGHT_PARAM_RANGE]; + case RS::LIGHT_OMNI: { + float r = light->param[RS::LIGHT_PARAM_RANGE]; return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); }; - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { return AABB(); }; } @@ -4097,13 +4097,13 @@ RID RasterizerStorageGLES2::reflection_probe_create() { reflection_probe->box_projection = false; reflection_probe->enable_shadows = false; reflection_probe->cull_mask = (1 << 20) - 1; - reflection_probe->update_mode = VS::REFLECTION_PROBE_UPDATE_ONCE; + reflection_probe->update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE; reflection_probe->resolution = 128; return reflection_probe_owner.make_rid(reflection_probe); } -void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) { +void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -4220,10 +4220,10 @@ AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const { return aabb; } -VS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const { +RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const { const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!reflection_probe, VS::REFLECTION_PROBE_UPDATE_ALWAYS); + ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS); return reflection_probe->update_mode; } @@ -4465,7 +4465,7 @@ float RasterizerStorageGLES2::lightmap_capture_get_energy(RID p_capture) const { const Vector<RasterizerStorage::LightmapCaptureOctree> *RasterizerStorageGLES2::lightmap_capture_get_octree_ptr(RID p_capture) const { const LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture); - ERR_FAIL_COND_V(!capture, NULL); + ERR_FAIL_COND_V(!capture, nullptr); return &capture->octree; } @@ -4518,7 +4518,7 @@ void RasterizerStorageGLES2::particles_set_fractional_delta(RID p_particles, boo void RasterizerStorageGLES2::particles_set_process_material(RID p_particles, RID p_material) { } -void RasterizerStorageGLES2::particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) { +void RasterizerStorageGLES2::particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) { } void RasterizerStorageGLES2::particles_set_draw_passes(RID p_particles, int p_passes) { @@ -4579,37 +4579,37 @@ void RasterizerStorageGLES2::instance_remove_skeleton(RID p_skeleton, Rasterizer void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) { - Instantiable *inst = NULL; + Instantiable *inst = nullptr; switch (p_instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { inst = mesh_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { inst = multimesh_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { inst = immediate_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - /*case VS::INSTANCE_PARTICLES: { + /*case RS::INSTANCE_PARTICLES: { inst = particles_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break;*/ - case VS::INSTANCE_REFLECTION_PROBE: { + case RS::INSTANCE_REFLECTION_PROBE: { inst = reflection_probe_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - case VS::INSTANCE_LIGHT: { + case RS::INSTANCE_LIGHT: { inst = light_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - /*case VS::INSTANCE_GI_PROBE: { + /*case RS::INSTANCE_GI_PROBE: { inst = gi_probe_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break;*/ - case VS::INSTANCE_LIGHTMAP_CAPTURE: { + case RS::INSTANCE_LIGHTMAP_CAPTURE: { inst = lightmap_capture_data_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; @@ -4623,38 +4623,38 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) { - Instantiable *inst = NULL; + Instantiable *inst = nullptr; switch (p_instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { inst = mesh_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { inst = multimesh_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { inst = immediate_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - /*case VS::INSTANCE_PARTICLES: { + /*case RS::INSTANCE_PARTICLES: { inst = particles_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break;*/ - case VS::INSTANCE_REFLECTION_PROBE: { + case RS::INSTANCE_REFLECTION_PROBE: { inst = reflection_probe_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - case VS::INSTANCE_LIGHT: { + case RS::INSTANCE_LIGHT: { inst = light_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; - /*case VS::INSTANCE_GI_PROBE: { + /*case RS::INSTANCE_GI_PROBE: { inst = gi_probe_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; */ - case VS::INSTANCE_LIGHTMAP_CAPTURE: { + case RS::INSTANCE_LIGHTMAP_CAPTURE: { inst = lightmap_capture_data_owner.getornull(p_base); ERR_FAIL_COND(!inst); } break; @@ -4721,9 +4721,9 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glGenTextures(1, &rt->color); glBindTexture(GL_TEXTURE_2D, rt->color); - glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, nullptr); - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { + if (texture->flags & RS::TEXTURE_FLAG_FILTER) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -4744,7 +4744,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glGenTextures(1, &rt->depth); glBindTexture(GL_TEXTURE_2D, rt->depth); - glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, config.depth_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, rt->width, rt->height, 0, GL_DEPTH_COMPONENT, config.depth_type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -4805,7 +4805,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { /* For MSAA */ #ifndef JAVASCRIPT_ENABLED - if (rt->msaa >= VS::VIEWPORT_MSAA_2X && rt->msaa <= VS::VIEWPORT_MSAA_16X && config.multisample_supported) { + if (rt->msaa >= RS::VIEWPORT_MSAA_2X && rt->msaa <= RS::VIEWPORT_MSAA_16X && config.multisample_supported) { rt->multisample_active = true; @@ -4841,7 +4841,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glGenTextures(1, &rt->multisample_color); glBindTexture(GL_TEXTURE_2D, rt->multisample_color); - glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, nullptr); // multisample buffer is same size as front buffer, so just use nearest glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -4894,9 +4894,9 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glBindTexture(GL_TEXTURE_2D, rt->copy_screen_effect.color); if (rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); } else { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, rt->width, rt->height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, rt->width, rt->height, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -4961,7 +4961,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].color); for (int l = 0; l < level + 1; l++) { - glTexImage2D(GL_TEXTURE_2D, l, color_internal_format, width, height, 0, color_format, color_type, NULL); + glTexImage2D(GL_TEXTURE_2D, l, color_internal_format, width, height, 0, color_format, color_type, nullptr); width = MAX(1, (width / 2)); height = MAX(1, (height / 2)); } @@ -4975,7 +4975,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { for (int l = 0; l < level + 1; l++) { glGenTextures(1, &rt->mip_maps[i].sizes.write[l].color); glBindTexture(GL_TEXTURE_2D, rt->mip_maps[i].sizes[l].color); - glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, width, height, 0, color_format, color_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, width, height, 0, color_format, color_type, nullptr); width = MAX(1, (width / 2)); height = MAX(1, (height / 2)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -5134,7 +5134,7 @@ RID RasterizerStorageGLES2::render_target_create() { Texture *t = memnew(Texture); - t->type = VS::TEXTURE_TYPE_2D; + t->type = RS::TEXTURE_TYPE_2D; t->flags = 0; t->width = 0; t->height = 0; @@ -5235,7 +5235,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar // allocate a texture t = memnew(Texture); - t->type = VS::TEXTURE_TYPE_2D; + t->type = RS::TEXTURE_TYPE_2D; t->flags = 0; t->width = 0; t->height = 0; @@ -5278,7 +5278,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar // Switch our texture on our frame buffer #if ANDROID_ENABLED - if (rt->msaa >= VS::VIEWPORT_MSAA_EXT_2X && rt->msaa <= VS::VIEWPORT_MSAA_EXT_4X) { + if (rt->msaa >= RS::VIEWPORT_MSAA_EXT_2X && rt->msaa <= RS::VIEWPORT_MSAA_EXT_4X) { // This code only applies to the Oculus Go and Oculus Quest. Due to the the tiled nature // of the GPU we can do a single render pass by rendering directly into our texture chains // texture and apply MSAA as we render. @@ -5287,7 +5287,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar // the normal MSAA modes need to be used to enable our two pass approach static const int msaa_value[] = { 2, 4 }; - int msaa = msaa_value[rt->msaa - VS::VIEWPORT_MSAA_EXT_2X]; + int msaa = msaa_value[rt->msaa - RS::VIEWPORT_MSAA_EXT_2X]; if (rt->external.depth == 0) { // create a multisample depth buffer, we're not reusing Godots because Godot's didn't get created.. @@ -5370,7 +5370,7 @@ void RasterizerStorageGLES2::render_target_set_as_unused(RID p_render_target) { rt->used_in_frame = false; } -void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) { +void RasterizerStorageGLES2::render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) { RenderTarget *rt = render_target_owner.getornull(p_render_target); ERR_FAIL_COND(!rt); @@ -5412,12 +5412,12 @@ RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) { glGenTextures(1, &cls->distance); glBindTexture(GL_TEXTURE_2D, cls->distance); if (config.use_rgba_2d_shadows) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cls->size, cls->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cls->size, cls->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); } else { #ifdef GLES_OVER_GL - glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, cls->size, cls->height, 0, _RED_OES, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, cls->size, cls->height, 0, _RED_OES, GL_FLOAT, nullptr); #else - glTexImage2D(GL_TEXTURE_2D, 0, GL_FLOAT, cls->size, cls->height, 0, _RED_OES, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_FLOAT, cls->size, cls->height, 0, _RED_OES, GL_FLOAT, nullptr); #endif } @@ -5544,22 +5544,22 @@ void RasterizerStorageGLES2::canvas_light_occluder_set_polylines(RID p_occluder, } } -VS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const { +RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const { if (mesh_owner.owns(p_rid)) { - return VS::INSTANCE_MESH; + return RS::INSTANCE_MESH; } else if (light_owner.owns(p_rid)) { - return VS::INSTANCE_LIGHT; + return RS::INSTANCE_LIGHT; } else if (multimesh_owner.owns(p_rid)) { - return VS::INSTANCE_MULTIMESH; + return RS::INSTANCE_MULTIMESH; } else if (immediate_owner.owns(p_rid)) { - return VS::INSTANCE_IMMEDIATE; + return RS::INSTANCE_IMMEDIATE; } else if (reflection_probe_owner.owns(p_rid)) { - return VS::INSTANCE_REFLECTION_PROBE; + return RS::INSTANCE_REFLECTION_PROBE; } else if (lightmap_capture_data_owner.owns(p_rid)) { - return VS::INSTANCE_LIGHTMAP_CAPTURE; + return RS::INSTANCE_LIGHTMAP_CAPTURE; } else { - return VS::INSTANCE_NONE; + return RS::INSTANCE_NONE; } } @@ -5611,7 +5611,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) { while (shader->materials.first()) { Material *m = shader->materials.first()->self(); - m->shader = NULL; + m->shader = nullptr; _material_make_dirty(m); shader->materials.remove(shader->materials.first()); @@ -5710,7 +5710,7 @@ bool RasterizerStorageGLES2::free(RID p_rid) { } } - multimesh_allocate(p_rid, 0, VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE); + multimesh_allocate(p_rid, 0, RS::MULTIMESH_TRANSFORM_3D, RS::MULTIMESH_COLOR_NONE); update_dirty_multimeshes(); @@ -5817,25 +5817,25 @@ void RasterizerStorageGLES2::render_info_end_capture() { info.snap.vertices_count = info.render.vertices_count - info.snap.vertices_count; } -int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) { +int RasterizerStorageGLES2::get_captured_render_info(RS::RenderInfo p_info) { switch (p_info) { - case VS::INFO_OBJECTS_IN_FRAME: { + case RS::INFO_OBJECTS_IN_FRAME: { return info.snap.object_count; } break; - case VS::INFO_VERTICES_IN_FRAME: { + case RS::INFO_VERTICES_IN_FRAME: { return info.snap.vertices_count; } break; - case VS::INFO_MATERIAL_CHANGES_IN_FRAME: { + case RS::INFO_MATERIAL_CHANGES_IN_FRAME: { return info.snap.material_switch_count; } break; - case VS::INFO_SHADER_CHANGES_IN_FRAME: { + case RS::INFO_SHADER_CHANGES_IN_FRAME: { return info.snap.shader_rebind_count; } break; - case VS::INFO_SURFACE_CHANGES_IN_FRAME: { + case RS::INFO_SURFACE_CHANGES_IN_FRAME: { return info.snap.surface_switch_count; } break; - case VS::INFO_DRAW_CALLS_IN_FRAME: { + case RS::INFO_DRAW_CALLS_IN_FRAME: { return info.snap.draw_call_count; } break; default: { @@ -5844,27 +5844,27 @@ int RasterizerStorageGLES2::get_captured_render_info(VS::RenderInfo p_info) { } } -int RasterizerStorageGLES2::get_render_info(VS::RenderInfo p_info) { +int RasterizerStorageGLES2::get_render_info(RS::RenderInfo p_info) { switch (p_info) { - case VS::INFO_OBJECTS_IN_FRAME: + case RS::INFO_OBJECTS_IN_FRAME: return info.render_final.object_count; - case VS::INFO_VERTICES_IN_FRAME: + case RS::INFO_VERTICES_IN_FRAME: return info.render_final.vertices_count; - case VS::INFO_MATERIAL_CHANGES_IN_FRAME: + case RS::INFO_MATERIAL_CHANGES_IN_FRAME: return info.render_final.material_switch_count; - case VS::INFO_SHADER_CHANGES_IN_FRAME: + case RS::INFO_SHADER_CHANGES_IN_FRAME: return info.render_final.shader_rebind_count; - case VS::INFO_SURFACE_CHANGES_IN_FRAME: + case RS::INFO_SURFACE_CHANGES_IN_FRAME: return info.render_final.surface_switch_count; - case VS::INFO_DRAW_CALLS_IN_FRAME: + case RS::INFO_DRAW_CALLS_IN_FRAME: return info.render_final.draw_call_count; - case VS::INFO_USAGE_VIDEO_MEM_TOTAL: + case RS::INFO_USAGE_VIDEO_MEM_TOTAL: return 0; //no idea - case VS::INFO_VIDEO_MEM_USED: + case RS::INFO_VIDEO_MEM_USED: return info.vertex_mem + info.texture_mem; - case VS::INFO_TEXTURE_MEM_USED: + case RS::INFO_TEXTURE_MEM_USED: return info.texture_mem; - case VS::INFO_VERTEX_MEM_USED: + case RS::INFO_VERTEX_MEM_USED: return info.vertex_mem; default: return 0; //no idea either @@ -5942,7 +5942,7 @@ void RasterizerStorageGLES2::initialize() { #ifdef IPHONE_ENABLED // appears that IPhone doesn't need to dlopen TODO: test this rigorously before removing - //void *gles2_lib = dlopen(NULL, RTLD_LAZY); + //void *gles2_lib = dlopen(nullptr, RTLD_LAZY); //glRenderbufferStorageMultisampleAPPLE = dlsym(gles2_lib, "glRenderbufferStorageMultisampleAPPLE"); //glResolveMultisampleFramebufferAPPLE = dlsym(gles2_lib, "glResolveMultisampleFramebufferAPPLE"); #elif ANDROID_ENABLED @@ -6014,7 +6014,7 @@ void RasterizerStorageGLES2::initialize() { GLuint depth; glGenTextures(1, &depth); glBindTexture(GL_TEXTURE_2D, depth); - glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, GL_DEPTH_COMPONENT, config.depth_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, GL_DEPTH_COMPONENT, config.depth_type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -6046,7 +6046,7 @@ void RasterizerStorageGLES2::initialize() { glGenTextures(1, &depth); glBindTexture(GL_TEXTURE_2D, depth); - glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -6074,7 +6074,7 @@ void RasterizerStorageGLES2::initialize() { frame.count = 0; frame.delta = 0; - frame.current_rt = NULL; + frame.current_rt = nullptr; frame.clear_request = false; glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &config.max_vertex_texture_image_units); @@ -6190,7 +6190,7 @@ void RasterizerStorageGLES2::initialize() { glGenTextures(1, &resources.white_tex_array); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D_ARRAY, resources.white_tex_array); - glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 8, 8, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 8, 8, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 8, 8, 1, GL_RGB, GL_UNSIGNED_BYTE, whitetexdata); glGenerateMipmap(GL_TEXTURE_2D_ARRAY); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 86965730e0..29651936fb 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -32,8 +32,8 @@ #define RASTERIZERSTORAGEGLES2_H #include "core/self_list.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering/shader_language.h" #include "shader_compiler_gles2.h" #include "shader_gles2.h" @@ -249,7 +249,7 @@ public: int width, height, depth; int alloc_width, alloc_height; Image::Format format; - VS::TextureType type; + RS::TextureType type; GLenum target; GLenum gl_format_cache; @@ -279,24 +279,24 @@ public: bool redraw_if_visible; - VisualServer::TextureDetectCallback detect_3d; + RenderingServer::TextureDetectCallback detect_3d; void *detect_3d_ud; - VisualServer::TextureDetectCallback detect_srgb; + RenderingServer::TextureDetectCallback detect_srgb; void *detect_srgb_ud; - VisualServer::TextureDetectCallback detect_normal; + RenderingServer::TextureDetectCallback detect_normal; void *detect_normal_ud; Texture() : - proxy(NULL), + proxy(nullptr), flags(0), width(0), height(0), alloc_width(0), alloc_height(0), format(Image::FORMAT_L8), - type(VS::TEXTURE_TYPE_2D), + type(RS::TEXTURE_TYPE_2D), target(0), data_size(0), total_data_size(0), @@ -307,14 +307,14 @@ public: active(false), tex_id(0), stored_cube_sides(0), - render_target(NULL), + render_target(nullptr), redraw_if_visible(false), - detect_3d(NULL), - detect_3d_ud(NULL), - detect_srgb(NULL), - detect_srgb_ud(NULL), - detect_normal(NULL), - detect_normal_ud(NULL) { + detect_3d(nullptr), + detect_3d_ud(nullptr), + detect_srgb(nullptr), + detect_srgb_ud(nullptr), + detect_normal(nullptr), + detect_normal_ud(nullptr) { } _ALWAYS_INLINE_ Texture *get_ptr() { @@ -331,7 +331,7 @@ public: } for (Set<Texture *>::Element *E = proxy_owners.front(); E; E = E->next()) { - E->get()->proxy = NULL; + E->get()->proxy = nullptr; } if (proxy) { @@ -345,14 +345,14 @@ public: Ref<Image> _get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, Image::Format &r_real_format, GLenum &r_gl_format, GLenum &r_gl_internal_format, GLenum &r_gl_type, bool &r_compressed, bool p_force_decompress) const; virtual RID texture_create(); - virtual void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, VS::TextureType p_type, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT); + virtual void texture_allocate(RID p_texture, int p_width, int p_height, int p_depth_3d, Image::Format p_format, RS::TextureType p_type, uint32_t p_flags = RS::TEXTURE_FLAGS_DEFAULT); virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, int p_layer = 0); virtual void texture_set_data_partial(RID p_texture, const Ref<Image> &p_image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int p_dst_mip, int p_layer = 0); virtual Ref<Image> texture_get_data(RID p_texture, int p_layer = 0) const; virtual void texture_set_flags(RID p_texture, uint32_t p_flags); virtual uint32_t texture_get_flags(RID p_texture) const; virtual Image::Format texture_get_format(RID p_texture) const; - virtual VS::TextureType texture_get_type(RID p_texture) const; + virtual RS::TextureType texture_get_type(RID p_texture) const; virtual uint32_t texture_get_texid(RID p_texture) const; virtual uint32_t texture_get_width(RID p_texture) const; virtual uint32_t texture_get_height(RID p_texture) const; @@ -365,7 +365,7 @@ public: virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable); - virtual void texture_debug_usage(List<VS::TextureInfo> *r_info); + virtual void texture_debug_usage(List<RS::TextureInfo> *r_info); virtual RID texture_create_radiance_cubemap(RID p_source, int p_resolution = -1) const; @@ -374,9 +374,9 @@ public: virtual void texture_set_proxy(RID p_texture, RID p_proxy); virtual Size2 texture_size_with_proxy(RID p_texture) const; - virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); - virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); - virtual void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_3d_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_srgb_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_normal_callback(RID p_texture, RenderingServer::TextureDetectCallback p_callback, void *p_userdata); virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable); @@ -402,7 +402,7 @@ public: RID self; - VS::ShaderMode mode; + RS::ShaderMode mode; ShaderGLES2 *shader; String code; SelfList<Material>::List materials; @@ -508,7 +508,7 @@ public: Shader() : dirty_list(this) { - shader = NULL; + shader = nullptr; valid = false; custom_code_id = 0; version = 1; @@ -561,7 +561,7 @@ public: dirty_list(this) { can_cast_shadow_cache = false; is_animated_cache = false; - shader = NULL; + shader = nullptr; line_width = 1.0; last_pass = 0; render_priority = 0; @@ -617,7 +617,7 @@ public: uint32_t offset; }; - Attrib attribs[VS::ARRAY_MAX]; + Attrib attribs[RS::ARRAY_MAX]; Mesh *mesh; uint32_t format; @@ -641,7 +641,7 @@ public: int array_byte_size; int index_array_byte_size; - VS::PrimitiveType primitive; + RS::PrimitiveType primitive; Vector<AABB> skeleton_bone_aabb; Vector<bool> skeleton_bone_used; @@ -655,12 +655,12 @@ public: int total_data_size; Surface() : - mesh(NULL), + mesh(nullptr), array_len(0), index_array_len(0), array_byte_size(0), index_array_byte_size(0), - primitive(VS::PRIMITIVE_POINTS), + primitive(RS::PRIMITIVE_POINTS), active(false), total_data_size(0) { } @@ -675,7 +675,7 @@ public: Vector<Surface *> surfaces; int blend_shape_count; - VS::BlendShapeMode blend_shape_mode; + RS::BlendShapeMode blend_shape_mode; AABB custom_aabb; @@ -694,7 +694,7 @@ public: Mesh() : blend_shape_count(0), - blend_shape_mode(VS::BLEND_SHAPE_MODE_NORMALIZED) { + blend_shape_mode(RS::BLEND_SHAPE_MODE_NORMALIZED) { } }; @@ -702,13 +702,13 @@ public: virtual RID mesh_create(); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, RS::PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount); virtual int mesh_get_blend_shape_count(RID p_mesh) const; - virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode); - virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; + virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode); + virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data); @@ -722,7 +722,7 @@ public: virtual Vector<uint8_t> mesh_surface_get_index_array(RID p_mesh, int p_surface) const; virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; - virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; + virtual RS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const; virtual Vector<Vector<uint8_t>> mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; @@ -744,9 +744,9 @@ public: RID mesh; int size; - VS::MultimeshTransformFormat transform_format; - VS::MultimeshColorFormat color_format; - VS::MultimeshCustomDataFormat custom_data_format; + RS::MultimeshTransformFormat transform_format; + RS::MultimeshColorFormat color_format; + RS::MultimeshCustomDataFormat custom_data_format; Vector<float> data; @@ -766,9 +766,9 @@ public: MultiMesh() : size(0), - transform_format(VS::MULTIMESH_TRANSFORM_2D), - color_format(VS::MULTIMESH_COLOR_NONE), - custom_data_format(VS::MULTIMESH_CUSTOM_DATA_NONE), + transform_format(RS::MULTIMESH_TRANSFORM_2D), + color_format(RS::MULTIMESH_COLOR_NONE), + custom_data_format(RS::MULTIMESH_CUSTOM_DATA_NONE), update_list(this), mesh_list(this), visible_instances(-1), @@ -786,7 +786,7 @@ public: virtual RID multimesh_create(); - virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, VS::MultimeshColorFormat p_color_format, VS::MultimeshCustomDataFormat p_data = VS::MULTIMESH_CUSTOM_DATA_NONE); + virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, RS::MultimeshColorFormat p_color_format, RS::MultimeshCustomDataFormat p_data = RS::MULTIMESH_CUSTOM_DATA_NONE); virtual int multimesh_get_instance_count(RID p_multimesh) const; virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh); @@ -817,7 +817,7 @@ public: struct Chunk { RID texture; - VS::PrimitiveType primitive; + RS::PrimitiveType primitive; Vector<Vector3> vertices; Vector<Vector3> normals; Vector<Plane> tangents; @@ -846,7 +846,7 @@ public: mutable RID_PtrOwner<Immediate> immediate_owner; virtual RID immediate_create(); - virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_primitive, RID p_texture = RID()); + virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_primitive, RID p_texture = RID()); virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex); virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal); virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent); @@ -906,8 +906,8 @@ public: /* Light API */ struct Light : Instantiable { - VS::LightType type; - float param[VS::LIGHT_PARAM_MAX]; + RS::LightType type; + float param[RS::LIGHT_PARAM_MAX]; Color color; Color shadow_color; @@ -921,11 +921,11 @@ public: uint32_t cull_mask; - VS::LightOmniShadowMode omni_shadow_mode; - VS::LightOmniShadowDetail omni_shadow_detail; + RS::LightOmniShadowMode omni_shadow_mode; + RS::LightOmniShadowDetail omni_shadow_detail; - VS::LightDirectionalShadowMode directional_shadow_mode; - VS::LightDirectionalShadowDepthRangeMode directional_range_mode; + RS::LightDirectionalShadowMode directional_shadow_mode; + RS::LightDirectionalShadowDepthRangeMode directional_range_mode; bool directional_blend_splits; @@ -934,10 +934,10 @@ public: mutable RID_PtrOwner<Light> light_owner; - virtual RID light_create(VS::LightType p_type); + virtual RID light_create(RS::LightType p_type); virtual void light_set_color(RID p_light, const Color &p_color); - virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value); + virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value); virtual void light_set_shadow(RID p_light, bool p_enabled); virtual void light_set_shadow_color(RID p_light, const Color &p_color); virtual void light_set_projector(RID p_light, RID p_texture); @@ -946,23 +946,23 @@ public: virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled); virtual void light_set_use_gi(RID p_light, bool p_enabled); - virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode); - virtual void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail); + virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode); + virtual void light_omni_set_shadow_detail(RID p_light, RS::LightOmniShadowDetail p_detail); - virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode); + virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode); virtual void light_directional_set_blend_splits(RID p_light, bool p_enable); virtual bool light_directional_get_blend_splits(RID p_light) const; - virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light); - virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light); + virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light); + virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light); - virtual void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode); - virtual VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const; + virtual void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode); + virtual RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const; virtual bool light_has_shadow(RID p_light) const; - virtual VS::LightType light_get_type(RID p_light) const; - virtual float light_get_param(RID p_light, VS::LightParam p_param); + virtual RS::LightType light_get_type(RID p_light) const; + virtual float light_get_param(RID p_light, RS::LightParam p_param); virtual Color light_get_color(RID p_light); virtual bool light_get_use_gi(RID p_light); @@ -973,7 +973,7 @@ public: struct ReflectionProbe : Instantiable { - VS::ReflectionProbeUpdateMode update_mode; + RS::ReflectionProbeUpdateMode update_mode; float intensity; Color interior_ambient; float interior_ambient_energy; @@ -992,7 +992,7 @@ public: virtual RID reflection_probe_create(); - virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode); + virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode); virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity); virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient); virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy); @@ -1007,7 +1007,7 @@ public: virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution); virtual AABB reflection_probe_get_aabb(RID p_probe) const; - virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; + virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const; virtual int reflection_probe_get_resolution(RID p_probe) const; @@ -1111,7 +1111,7 @@ public: virtual void particles_set_fractional_delta(RID p_particles, bool p_enable); virtual void particles_restart(RID p_particles); - virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order); + virtual void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order); virtual void particles_set_draw_passes(RID p_particles, int p_passes); virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh); @@ -1203,7 +1203,7 @@ public: bool flags[RENDER_TARGET_FLAG_MAX]; bool used_in_frame; - VS::ViewportMSAA msaa; + RS::ViewportMSAA msaa; RID texture; @@ -1223,7 +1223,7 @@ public: width(0), height(0), used_in_frame(false), - msaa(VS::VIEWPORT_MSAA_DISABLED), + msaa(RS::VIEWPORT_MSAA_DISABLED), used_dof_blur_near(false), mip_maps_allocated(false) { for (int i = 0; i < RENDER_TARGET_FLAG_MAX; ++i) { @@ -1247,7 +1247,7 @@ public: virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value); virtual bool render_target_was_used(RID p_render_target); virtual void render_target_set_as_unused(RID p_render_target); - virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa); + virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa); /* CANVAS SHADOW */ @@ -1279,7 +1279,7 @@ public: virtual RID canvas_light_occluder_create(); virtual void canvas_light_occluder_set_polylines(RID p_occluder, const Vector<Vector2> &p_lines); - virtual VS::InstanceType get_base_type(RID p_rid) const; + virtual RS::InstanceType get_base_type(RID p_rid) const; virtual bool free(RID p_rid); @@ -1309,9 +1309,9 @@ public: virtual void render_info_begin_capture(); virtual void render_info_end_capture(); - virtual int get_captured_render_info(VS::RenderInfo p_info); + virtual int get_captured_render_info(RS::RenderInfo p_info); - virtual int get_render_info(VS::RenderInfo p_info); + virtual int get_render_info(RS::RenderInfo p_info); virtual String get_video_adapter_name() const; virtual String get_video_adapter_vendor() const; diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 620fcdbdca..699d6e1484 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -226,7 +226,7 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri _dump_function_deps(p_node, E->get(), p_func_code, r_to_add, r_added); - SL::FunctionNode *fnode = NULL; + SL::FunctionNode *fnode = nullptr; for (int i = 0; i < p_node->functions.size(); i++) { if (p_node->functions[i].name == E->get()) { @@ -639,12 +639,12 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener code += _mkid(arr_node->name); } - if (arr_node->call_expression != NULL) { + if (arr_node->call_expression != nullptr) { code += "."; code += _dump_node_code(arr_node->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); } - if (arr_node->index_expression != NULL) { + if (arr_node->index_expression != nullptr) { code += "["; code += _dump_node_code(arr_node->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "]"; @@ -923,7 +923,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener code += _dump_node_code(member_node->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "."; code += member_node->name; - if (member_node->index_expression != NULL) { + if (member_node->index_expression != nullptr) { code += "["; code += _dump_node_code(member_node->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "]"; @@ -934,7 +934,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener return code.as_string(); } -Error ShaderCompilerGLES2::compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { +Error ShaderCompilerGLES2::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types()); @@ -945,7 +945,7 @@ Error ShaderCompilerGLES2::compile(VS::ShaderMode p_mode, const String &p_code, print_line(itos(i + 1) + " " + shader[i]); } - _err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); + _err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); return err; } @@ -975,210 +975,210 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { /** CANVAS ITEM SHADER **/ - actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; - actions[VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv"; - actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size"; - - actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix"; - actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; - actions[VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance"; - actions[VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time"; - actions[VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass"; - actions[VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom"; - - actions[VS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color"; - actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal"; - actions[VS::SHADER_CANVAS_ITEM].renames["NORMALMAP"] = "normal_map"; - actions[VS::SHADER_CANVAS_ITEM].renames["NORMALMAP_DEPTH"] = "normal_depth"; - actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture"; - actions[VS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size"; - actions[VS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture"; - actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv"; - actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture"; - actions[VS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size"; - actions[VS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord"; - actions[VS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord"; - - actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec"; - actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height"; - actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color"; - actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv"; - actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light"; - actions[VS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color"; - actions[VS::SHADER_CANVAS_ITEM].renames["SHADOW_VEC"] = "shadow_vec"; - - actions[VS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; - actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_VEC"] = "#define SHADOW_VEC_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; + actions[RS::SHADER_CANVAS_ITEM].renames["UV"] = "uv"; + actions[RS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size"; + + actions[RS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix"; + actions[RS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; + actions[RS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance"; + actions[RS::SHADER_CANVAS_ITEM].renames["TIME"] = "time"; + actions[RS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass"; + actions[RS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom"; + + actions[RS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color"; + actions[RS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal"; + actions[RS::SHADER_CANVAS_ITEM].renames["NORMALMAP"] = "normal_map"; + actions[RS::SHADER_CANVAS_ITEM].renames["NORMALMAP_DEPTH"] = "normal_depth"; + actions[RS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture"; + actions[RS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size"; + actions[RS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture"; + actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv"; + actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture"; + actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size"; + actions[RS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord"; + actions[RS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord"; + + actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec"; + actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height"; + actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color"; + actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv"; + actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light"; + actions[RS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color"; + actions[RS::SHADER_CANVAS_ITEM].renames["SHADOW_VEC"] = "shadow_vec"; + + actions[RS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[RS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_VEC"] = "#define SHADOW_VEC_USED\n"; // Ported from GLES3 - actions[VS::SHADER_CANVAS_ITEM].usage_defines["sinh"] = "#define SINH_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["cosh"] = "#define COSH_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["tanh"] = "#define TANH_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["asinh"] = "#define ASINH_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["acosh"] = "#define ACOSH_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["atanh"] = "#define ATANH_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["determinant"] = "#define DETERMINANT_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["transpose"] = "#define TRANSPOSE_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n"; - actions[VS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["sinh"] = "#define SINH_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["cosh"] = "#define COSH_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["tanh"] = "#define TANH_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["asinh"] = "#define ASINH_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["acosh"] = "#define ACOSH_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["atanh"] = "#define ATANH_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["determinant"] = "#define DETERMINANT_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["transpose"] = "#define TRANSPOSE_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n"; + actions[RS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n"; /** SPATIAL SHADER **/ - actions[VS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform"; - actions[VS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix"; - actions[VS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix"; - actions[VS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix"; - actions[VS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix"; - actions[VS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview"; - - actions[VS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz"; - actions[VS::SHADER_SPATIAL].renames["NORMAL"] = "normal"; - actions[VS::SHADER_SPATIAL].renames["TANGENT"] = "tangent"; - actions[VS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal"; - actions[VS::SHADER_SPATIAL].renames["POSITION"] = "position"; - actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp"; - actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp"; - actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp"; - actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size"; + actions[RS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform"; + actions[RS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix"; + actions[RS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix"; + actions[RS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix"; + actions[RS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix"; + actions[RS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview"; + + actions[RS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz"; + actions[RS::SHADER_SPATIAL].renames["NORMAL"] = "normal"; + actions[RS::SHADER_SPATIAL].renames["TANGENT"] = "tangent"; + actions[RS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal"; + actions[RS::SHADER_SPATIAL].renames["POSITION"] = "position"; + actions[RS::SHADER_SPATIAL].renames["UV"] = "uv_interp"; + actions[RS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp"; + actions[RS::SHADER_SPATIAL].renames["COLOR"] = "color_interp"; + actions[RS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size"; // gl_InstanceID is not available in OpenGL ES 2.0 - actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0"; + actions[RS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0"; //builtins - actions[VS::SHADER_SPATIAL].renames["TIME"] = "time"; - actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size"; - - actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord"; - actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing"; - actions[VS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap"; - actions[VS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth"; - actions[VS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo"; - actions[VS::SHADER_SPATIAL].renames["ALPHA"] = "alpha"; - actions[VS::SHADER_SPATIAL].renames["METALLIC"] = "metallic"; - actions[VS::SHADER_SPATIAL].renames["SPECULAR"] = "specular"; - actions[VS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness"; - actions[VS::SHADER_SPATIAL].renames["RIM"] = "rim"; - actions[VS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint"; - actions[VS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat"; - actions[VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss"; - actions[VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy"; - actions[VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow"; - actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; - actions[VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission"; - actions[VS::SHADER_SPATIAL].renames["AO"] = "ao"; - actions[VS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect"; - actions[VS::SHADER_SPATIAL].renames["EMISSION"] = "emission"; - actions[VS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord"; - actions[VS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom"; - actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv"; - actions[VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture"; - actions[VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture"; + actions[RS::SHADER_SPATIAL].renames["TIME"] = "time"; + actions[RS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size"; + + actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord"; + actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing"; + actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap"; + actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth"; + actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo"; + actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha"; + actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic"; + actions[RS::SHADER_SPATIAL].renames["SPECULAR"] = "specular"; + actions[RS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness"; + actions[RS::SHADER_SPATIAL].renames["RIM"] = "rim"; + actions[RS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint"; + actions[RS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat"; + actions[RS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss"; + actions[RS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy"; + actions[RS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow"; + actions[RS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; + actions[RS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission"; + actions[RS::SHADER_SPATIAL].renames["AO"] = "ao"; + actions[RS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect"; + actions[RS::SHADER_SPATIAL].renames["EMISSION"] = "emission"; + actions[RS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord"; + actions[RS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom"; + actions[RS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv"; + actions[RS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture"; + actions[RS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture"; // Defined in GLES3, but not available in GLES2 - //actions[VS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth"; - actions[VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor"; - actions[VS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB"; + //actions[RS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth"; + actions[RS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor"; + actions[RS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB"; //for light - actions[VS::SHADER_SPATIAL].renames["VIEW"] = "view"; - actions[VS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color"; - actions[VS::SHADER_SPATIAL].renames["LIGHT"] = "light"; - actions[VS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation"; - actions[VS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light"; - actions[VS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light"; - - actions[VS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT"; - actions[VS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n"; - actions[VS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM"; - actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n"; - actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT"; - actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n"; - actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY"; - actions[VS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n"; - actions[VS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n"; - actions[VS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP"; - actions[VS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n"; - actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n"; - - actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n"; - actions[VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; - - actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; - actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[RS::SHADER_SPATIAL].renames["VIEW"] = "view"; + actions[RS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color"; + actions[RS::SHADER_SPATIAL].renames["LIGHT"] = "light"; + actions[RS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation"; + actions[RS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light"; + actions[RS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light"; + + actions[RS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT"; + actions[RS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n"; + actions[RS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM"; + actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n"; + actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT"; + actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n"; + actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY"; + actions[RS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n"; + actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n"; + actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP"; + actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n"; + actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n"; + + actions[RS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n"; + actions[RS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; + + actions[RS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[RS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; // Ported from GLES3 - actions[VS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n"; - - actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n"; + + actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n"; // Defined in GLES3, could be implemented in GLES2 too if there's a need for it - //actions[VS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n"; + //actions[RS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n"; // Defined in GLES3, might not be possible in GLES2 as gl_FrontFacing is not available - //actions[VS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n"; - //actions[VS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; + //actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n"; + //actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley"); if (!force_lambert) { - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; } - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx"); if (!force_blinn) { - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n"; } else { - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n"; } - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; // No defines for particle shaders in GLES2, there are no GPU particles diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h index dd10a27c0d..757dcdd4f2 100644 --- a/drivers/gles2/shader_compiler_gles2.h +++ b/drivers/gles2/shader_compiler_gles2.h @@ -33,9 +33,9 @@ #include "core/pair.h" #include "core/string_builder.h" -#include "servers/visual/shader_language.h" -#include "servers/visual/shader_types.h" -#include "servers/visual_server.h" +#include "servers/rendering/shader_language.h" +#include "servers/rendering/shader_types.h" +#include "servers/rendering_server.h" class ShaderCompilerGLES2 { public: @@ -91,10 +91,10 @@ private: Set<StringName> used_rmode_defines; Set<StringName> internal_functions; - DefaultIdentifierActions actions[VS::SHADER_MAX]; + DefaultIdentifierActions actions[RS::SHADER_MAX]; public: - Error compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code); + Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code); ShaderCompilerGLES2(); }; diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index f03f1ffa4f..2c335c6c5a 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -55,7 +55,7 @@ #endif -ShaderGLES2 *ShaderGLES2::active = NULL; +ShaderGLES2 *ShaderGLES2::active = nullptr; //#define DEBUG_SHADER @@ -103,10 +103,10 @@ bool ShaderGLES2::bind() { } void ShaderGLES2::unbind() { - version = NULL; + version = nullptr; glUseProgram(0); uniforms_dirty = true; - active = NULL; + active = nullptr; } static void _display_error_with_code(const String &p_error, const Vector<const char *> &p_code) { @@ -196,19 +196,19 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { CharString code_string2; CharString code_globals; - CustomCode *cc = NULL; + CustomCode *cc = nullptr; if (conditional_version.code_version > 0) { cc = custom_code_map.getptr(conditional_version.code_version); - ERR_FAIL_COND_V(!cc, NULL); + ERR_FAIL_COND_V(!cc, nullptr); v.code_version = cc->version; } // program v.id = glCreateProgram(); - ERR_FAIL_COND_V(v.id == 0, NULL); + ERR_FAIL_COND_V(v.id == 0, nullptr); if (cc) { for (int i = 0; i < cc->custom_defines.size(); i++) { @@ -244,7 +244,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { #endif v.vert_id = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(v.vert_id, strings.size(), &strings[0], NULL); + glShaderSource(v.vert_id, strings.size(), &strings[0], nullptr); glCompileShader(v.vert_id); GLint status; @@ -281,7 +281,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { v.id = 0; } - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } strings.resize(string_base_size); @@ -320,7 +320,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { #endif v.frag_id = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(v.frag_id, strings.size(), &strings[0], NULL); + glShaderSource(v.frag_id, strings.size(), &strings[0], nullptr); glCompileShader(v.frag_id); glGetShaderiv(v.frag_id, GL_COMPILE_STATUS, &status); @@ -357,7 +357,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { v.id = 0; } - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } glAttachShader(v.id, v.frag_id); @@ -384,7 +384,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { v.id = 0; ERR_PRINT("No OpenGL program link log. What the frick?"); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (iloglen == 0) { @@ -407,7 +407,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { glDeleteProgram(v.id); v.id = 0; - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } // get uniform locations @@ -553,7 +553,7 @@ void ShaderGLES2::setup( } void ShaderGLES2::finish() { - const VersionKey *V = NULL; + const VersionKey *V = nullptr; while ((V = version_map.next(V))) { Version &v = version_map[*V]; @@ -565,7 +565,7 @@ void ShaderGLES2::finish() { } void ShaderGLES2::clear_caches() { - const VersionKey *V = NULL; + const VersionKey *V = nullptr; while ((V = version_map.next(V))) { Version &v = version_map[*V]; @@ -578,7 +578,7 @@ void ShaderGLES2::clear_caches() { version_map.clear(); custom_code_map.clear(); - version = NULL; + version = nullptr; last_custom_code = 1; uniforms_dirty = true; } @@ -1093,7 +1093,7 @@ void ShaderGLES2::use_material(void *p_material) { } ShaderGLES2::ShaderGLES2() { - version = NULL; + version = nullptr; last_custom_code = 1; uniforms_dirty = true; } diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h index d5e8159479..d20d5bc585 100644 --- a/drivers/gles2/shader_gles2.h +++ b/drivers/gles2/shader_gles2.h @@ -44,7 +44,7 @@ #include "core/math/camera_matrix.h" #include "core/pair.h" #include "core/variant.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" #include <stdio.h> @@ -121,7 +121,7 @@ private: id = 0; vert_id = 0; frag_id = 0; - uniform_location = NULL; + uniform_location = nullptr; code_version = 0; ok = false; } diff --git a/drivers/gles2/shaders/SCsub b/drivers/gles2/shaders/SCsub index d7ae0243e6..bcd6ea79fb 100644 --- a/drivers/gles2/shaders/SCsub +++ b/drivers/gles2/shaders/SCsub @@ -1,23 +1,23 @@ #!/usr/bin/env python -Import('env') +Import("env") -if 'GLES2_GLSL' in env['BUILDERS']: - env.GLES2_GLSL('copy.glsl'); -# env.GLES2_GLSL('resolve.glsl'); - env.GLES2_GLSL('canvas.glsl'); - env.GLES2_GLSL('canvas_shadow.glsl'); - env.GLES2_GLSL('scene.glsl'); - env.GLES2_GLSL('cubemap_filter.glsl'); - env.GLES2_GLSL('cube_to_dp.glsl'); -# env.GLES2_GLSL('blend_shape.glsl'); -# env.GLES2_GLSL('screen_space_reflection.glsl'); - env.GLES2_GLSL('effect_blur.glsl'); -# env.GLES2_GLSL('subsurf_scattering.glsl'); -# env.GLES2_GLSL('ssao.glsl'); -# env.GLES2_GLSL('ssao_minify.glsl'); -# env.GLES2_GLSL('ssao_blur.glsl'); -# env.GLES2_GLSL('exposure.glsl'); - env.GLES2_GLSL('tonemap.glsl'); -# env.GLES2_GLSL('particles.glsl'); - env.GLES2_GLSL('lens_distorted.glsl'); +if "GLES2_GLSL" in env["BUILDERS"]: + env.GLES2_GLSL("copy.glsl") + # env.GLES2_GLSL('resolve.glsl'); + env.GLES2_GLSL("canvas.glsl") + env.GLES2_GLSL("canvas_shadow.glsl") + env.GLES2_GLSL("scene.glsl") + env.GLES2_GLSL("cubemap_filter.glsl") + env.GLES2_GLSL("cube_to_dp.glsl") + # env.GLES2_GLSL('blend_shape.glsl'); + # env.GLES2_GLSL('screen_space_reflection.glsl'); + env.GLES2_GLSL("effect_blur.glsl") + # env.GLES2_GLSL('subsurf_scattering.glsl'); + # env.GLES2_GLSL('ssao.glsl'); + # env.GLES2_GLSL('ssao_minify.glsl'); + # env.GLES2_GLSL('ssao_blur.glsl'); + # env.GLES2_GLSL('exposure.glsl'); + env.GLES2_GLSL("tonemap.glsl") + # env.GLES2_GLSL('particles.glsl'); + env.GLES2_GLSL("lens_distorted.glsl") diff --git a/drivers/gles2/shaders/blend_shape.glsl b/drivers/gles2/shaders/blend_shape.glsl index a1e954e33d..0d0b3e24e4 100644 --- a/drivers/gles2/shaders/blend_shape.glsl +++ b/drivers/gles2/shaders/blend_shape.glsl @@ -2,7 +2,7 @@ [vertex] /* -from VisualServer: +from RenderingServer: ARRAY_VERTEX=0, ARRAY_NORMAL=1, diff --git a/drivers/png/SCsub b/drivers/png/SCsub index 87b54cecaf..db08be0c47 100644 --- a/drivers/png/SCsub +++ b/drivers/png/SCsub @@ -1,11 +1,11 @@ #!/usr/bin/env python -Import('env') +Import("env") env_png = env.Clone() # Thirdparty source files -if env['builtin_libpng']: +if env["builtin_libpng"]: thirdparty_dir = "#thirdparty/libpng/" thirdparty_sources = [ "png.c", @@ -32,6 +32,7 @@ if env['builtin_libpng']: # Currently .ASM filter_neon.S does not compile on NT. import os + use_neon = "neon_enabled" in env and env["neon_enabled"] and os.name != "nt" if use_neon: env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 2)]) @@ -45,7 +46,7 @@ if env['builtin_libpng']: if use_neon: env_neon = env_thirdparty.Clone() if "S_compiler" in env: - env_neon['CC'] = env['S_compiler'] + env_neon["CC"] = env["S_compiler"] neon_sources = [] neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c")) neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon_intrinsics.c")) @@ -56,4 +57,4 @@ if env['builtin_libpng']: # Godot source files env_png.add_source_files(env.drivers_sources, "*.cpp") -Export('env') +Export("env") diff --git a/drivers/png/png_driver_common.cpp b/drivers/png/png_driver_common.cpp index efd488fd5c..f17abcb54c 100644 --- a/drivers/png/png_driver_common.cpp +++ b/drivers/png/png_driver_common.cpp @@ -110,7 +110,7 @@ Error png_to_image(const uint8_t *p_source, size_t p_size, Ref<Image> p_image) { uint8_t *writer = buffer.ptrw(); // read image data to buffer and release libpng resources - success = png_image_finish_read(&png_img, NULL, writer, stride, NULL); + success = png_image_finish_read(&png_img, nullptr, writer, stride, nullptr); ERR_FAIL_COND_V_MSG(check_error(png_img), ERR_FILE_CORRUPT, png_img.message); ERR_FAIL_COND_V(!success, ERR_FILE_CORRUPT); @@ -175,7 +175,7 @@ Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) { uint8_t *writer = p_buffer.ptrw(); success = png_image_write_to_memory(&png_img, &writer[buffer_offset], - &compressed_size, 0, reader, 0, NULL); + &compressed_size, 0, reader, 0, nullptr); ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message); } if (!success) { @@ -189,7 +189,7 @@ Error image_to_png(const Ref<Image> &p_image, Vector<uint8_t> &p_buffer) { uint8_t *writer = p_buffer.ptrw(); success = png_image_write_to_memory(&png_img, &writer[buffer_offset], - &compressed_size, 0, reader, 0, NULL); + &compressed_size, 0, reader, 0, nullptr); ERR_FAIL_COND_V_MSG(check_error(png_img), FAILED, png_img.message); ERR_FAIL_COND_V(!success, FAILED); } diff --git a/drivers/pulseaudio/SCsub b/drivers/pulseaudio/SCsub index 28b315ae66..91e1140b75 100644 --- a/drivers/pulseaudio/SCsub +++ b/drivers/pulseaudio/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index ee9278fb8f..8a47f6cf96 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -98,7 +98,7 @@ void AudioDriverPulseAudio::detect_channels(bool capture) { pa_operation *pa_op = pa_context_get_server_info(pa_ctx, &AudioDriverPulseAudio::pa_server_info_cb, (void *)this); if (pa_op) { while (pa_status == 0) { - int ret = pa_mainloop_iterate(pa_ml, 1, NULL); + int ret = pa_mainloop_iterate(pa_ml, 1, nullptr); if (ret < 0) { ERR_PRINT("pa_mainloop_iterate error"); } @@ -128,7 +128,7 @@ void AudioDriverPulseAudio::detect_channels(bool capture) { if (pa_op) { while (pa_status == 0) { - int ret = pa_mainloop_iterate(pa_ml, 1, NULL); + int ret = pa_mainloop_iterate(pa_ml, 1, nullptr); if (ret < 0) { ERR_PRINT("pa_mainloop_iterate error"); } @@ -203,7 +203,7 @@ Error AudioDriverPulseAudio::init_device() { pa_map.map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT; pa_str = pa_stream_new(pa_ctx, "Sound", &spec, &pa_map); - if (pa_str == NULL) { + if (pa_str == nullptr) { ERR_PRINT("PulseAudio: pa_stream_new error: " + String(pa_strerror(pa_context_errno(pa_ctx)))); ERR_FAIL_V(ERR_CANT_OPEN); } @@ -220,9 +220,9 @@ Error AudioDriverPulseAudio::init_device() { attr.maxlength = (uint32_t)-1; attr.minreq = (uint32_t)-1; - const char *dev = device_name == "Default" ? NULL : device_name.utf8().get_data(); + const char *dev = device_name == "Default" ? nullptr : device_name.utf8().get_data(); pa_stream_flags flags = pa_stream_flags(PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE); - int error_code = pa_stream_connect_playback(pa_str, dev, &attr, flags, NULL, NULL); + int error_code = pa_stream_connect_playback(pa_str, dev, &attr, flags, nullptr, nullptr); ERR_FAIL_COND_V(error_code < 0, ERR_CANT_OPEN); samples_in.resize(buffer_frames * channels); @@ -244,31 +244,31 @@ Error AudioDriverPulseAudio::init() { mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE); pa_ml = pa_mainloop_new(); - ERR_FAIL_COND_V(pa_ml == NULL, ERR_CANT_OPEN); + ERR_FAIL_COND_V(pa_ml == nullptr, ERR_CANT_OPEN); pa_ctx = pa_context_new(pa_mainloop_get_api(pa_ml), "Godot"); - ERR_FAIL_COND_V(pa_ctx == NULL, ERR_CANT_OPEN); + ERR_FAIL_COND_V(pa_ctx == nullptr, ERR_CANT_OPEN); pa_ready = 0; pa_context_set_state_callback(pa_ctx, pa_state_cb, (void *)this); - int ret = pa_context_connect(pa_ctx, NULL, PA_CONTEXT_NOFLAGS, NULL); + int ret = pa_context_connect(pa_ctx, nullptr, PA_CONTEXT_NOFLAGS, nullptr); if (ret < 0) { if (pa_ctx) { pa_context_unref(pa_ctx); - pa_ctx = NULL; + pa_ctx = nullptr; } if (pa_ml) { pa_mainloop_free(pa_ml); - pa_ml = NULL; + pa_ml = nullptr; } return ERR_CANT_OPEN; } while (pa_ready == 0) { - ret = pa_mainloop_iterate(pa_ml, 1, NULL); + ret = pa_mainloop_iterate(pa_ml, 1, nullptr); if (ret < 0) { ERR_PRINT("pa_mainloop_iterate error"); } @@ -278,12 +278,12 @@ Error AudioDriverPulseAudio::init() { if (pa_ctx) { pa_context_disconnect(pa_ctx); pa_context_unref(pa_ctx); - pa_ctx = NULL; + pa_ctx = nullptr; } if (pa_ml) { pa_mainloop_free(pa_ml); - pa_ml = NULL; + pa_ml = nullptr; } return ERR_CANT_OPEN; @@ -377,7 +377,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) { int ret; do { - ret = pa_mainloop_iterate(ad->pa_ml, 0, NULL); + ret = pa_mainloop_iterate(ad->pa_ml, 0, nullptr); } while (ret > 0); if (avail_bytes > 0 && pa_stream_get_state(ad->pa_str) == PA_STREAM_READY) { @@ -385,7 +385,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) { if (bytes > 0) { size_t bytes_to_write = MIN(bytes, avail_bytes); const void *ptr = ad->samples_out.ptr(); - ret = pa_stream_write(ad->pa_str, (char *)ptr + write_ofs, bytes_to_write, NULL, 0LL, PA_SEEK_RELATIVE); + ret = pa_stream_write(ad->pa_str, (char *)ptr + write_ofs, bytes_to_write, nullptr, 0LL, PA_SEEK_RELATIVE); if (ret != 0) { ERR_PRINT("PulseAudio: pa_stream_write error: " + String(pa_strerror(ret))); } else { @@ -432,7 +432,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) { pa_operation *pa_op = pa_context_get_server_info(ad->pa_ctx, &AudioDriverPulseAudio::pa_server_info_cb, (void *)ad); if (pa_op) { while (ad->pa_status == 0) { - ret = pa_mainloop_iterate(ad->pa_ml, 1, NULL); + ret = pa_mainloop_iterate(ad->pa_ml, 1, nullptr); if (ret < 0) { ERR_PRINT("pa_mainloop_iterate error"); } @@ -463,7 +463,7 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) { if (ad->pa_rec_str && pa_stream_get_state(ad->pa_rec_str) == PA_STREAM_READY) { size_t bytes = pa_stream_readable_size(ad->pa_rec_str); if (bytes > 0) { - const void *ptr = NULL; + const void *ptr = nullptr; size_t maxbytes = ad->input_buffer.size() * sizeof(int16_t); bytes = MIN(bytes, maxbytes); @@ -555,7 +555,7 @@ Array AudioDriverPulseAudio::get_device_list() { pa_devices.clear(); pa_devices.push_back("Default"); - if (pa_ctx == NULL) { + if (pa_ctx == nullptr) { return pa_devices; } @@ -566,7 +566,7 @@ Array AudioDriverPulseAudio::get_device_list() { pa_operation *pa_op = pa_context_get_sink_info_list(pa_ctx, pa_sinklist_cb, (void *)this); if (pa_op) { while (pa_status == 0) { - int ret = pa_mainloop_iterate(pa_ml, 1, NULL); + int ret = pa_mainloop_iterate(pa_ml, 1, nullptr); if (ret < 0) { ERR_PRINT("pa_mainloop_iterate error"); } @@ -613,7 +613,7 @@ void AudioDriverPulseAudio::finish_device() { if (pa_str) { pa_stream_disconnect(pa_str); pa_stream_unref(pa_str); - pa_str = NULL; + pa_str = nullptr; } } @@ -630,17 +630,17 @@ void AudioDriverPulseAudio::finish() { if (pa_ctx) { pa_context_disconnect(pa_ctx); pa_context_unref(pa_ctx); - pa_ctx = NULL; + pa_ctx = nullptr; } if (pa_ml) { pa_mainloop_free(pa_ml); - pa_ml = NULL; + pa_ml = nullptr; } memdelete(thread); - thread = NULL; + thread = nullptr; } Error AudioDriverPulseAudio::capture_init_device() { @@ -680,12 +680,12 @@ Error AudioDriverPulseAudio::capture_init_device() { attr.fragsize = input_buffer_size * sizeof(int16_t); pa_rec_str = pa_stream_new(pa_ctx, "Record", &spec, &pa_rec_map); - if (pa_rec_str == NULL) { + if (pa_rec_str == nullptr) { ERR_PRINT("PulseAudio: pa_stream_new error: " + String(pa_strerror(pa_context_errno(pa_ctx)))); ERR_FAIL_V(ERR_CANT_OPEN); } - const char *dev = capture_device_name == "Default" ? NULL : capture_device_name.utf8().get_data(); + const char *dev = capture_device_name == "Default" ? nullptr : capture_device_name.utf8().get_data(); pa_stream_flags flags = pa_stream_flags(PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE); int error_code = pa_stream_connect_record(pa_rec_str, dev, &attr, flags); if (error_code < 0) { @@ -709,7 +709,7 @@ void AudioDriverPulseAudio::capture_finish_device() { ERR_PRINT("PulseAudio: pa_stream_disconnect error: " + String(pa_strerror(ret))); } pa_stream_unref(pa_rec_str); - pa_rec_str = NULL; + pa_rec_str = nullptr; } } @@ -757,7 +757,7 @@ Array AudioDriverPulseAudio::capture_get_device_list() { pa_rec_devices.clear(); pa_rec_devices.push_back("Default"); - if (pa_ctx == NULL) { + if (pa_ctx == nullptr) { return pa_rec_devices; } @@ -768,7 +768,7 @@ Array AudioDriverPulseAudio::capture_get_device_list() { pa_operation *pa_op = pa_context_get_source_info_list(pa_ctx, pa_sourcelist_cb, (void *)this); if (pa_op) { while (pa_status == 0) { - int ret = pa_mainloop_iterate(pa_ml, 1, NULL); + int ret = pa_mainloop_iterate(pa_ml, 1, nullptr); if (ret < 0) { ERR_PRINT("pa_mainloop_iterate error"); } @@ -794,11 +794,11 @@ String AudioDriverPulseAudio::capture_get_device() { } AudioDriverPulseAudio::AudioDriverPulseAudio() : - thread(NULL), - pa_ml(NULL), - pa_ctx(NULL), - pa_str(NULL), - pa_rec_str(NULL), + thread(nullptr), + pa_ml(nullptr), + pa_ctx(nullptr), + pa_str(nullptr), + pa_rec_str(nullptr), device_name("Default"), new_device("Default"), default_device(""), diff --git a/drivers/spirv-reflect/SCsub b/drivers/spirv-reflect/SCsub index 8ff27da114..d0ffaf068d 100644 --- a/drivers/spirv-reflect/SCsub +++ b/drivers/spirv-reflect/SCsub @@ -1,17 +1,17 @@ #!/usr/bin/env python -Import('env') +Import("env") env_spirv_reflect = env.Clone() env_spirv_reflect.disable_warnings() thirdparty_dir = "#thirdparty/spirv-reflect/" thirdparty_sources = [ - "spirv_reflect.c" + "spirv_reflect.c", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_spirv_reflect.add_source_files(env.drivers_sources, thirdparty_sources) -Export('env') +Export("env") diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index 4888f56099..91ef613546 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") -env["check_c_headers"] = [ [ "mntent.h", "HAVE_MNTENT" ] ] +env["check_c_headers"] = [["mntent.h", "HAVE_MNTENT"]] diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index 715bc56003..00103684c7 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -129,7 +129,7 @@ String DirAccessUnix::get_next() { dirent *entry = readdir(dir_stream); - if (entry == NULL) { + if (entry == nullptr) { list_dir_end(); return ""; } @@ -173,7 +173,7 @@ void DirAccessUnix::list_dir_end() { if (dir_stream) closedir(dir_stream); - dir_stream = 0; + dir_stream = nullptr; _cisdir = false; } @@ -207,7 +207,7 @@ static void _get_drives(List<String> *list) { char strings[4096]; while (getmntent_r(mtab, &mnt, strings, sizeof(strings))) { - if (mnt.mnt_dir != NULL && _filter_drive(&mnt)) { + if (mnt.mnt_dir != nullptr && _filter_drive(&mnt)) { // Avoid duplicates if (!list->find(mnt.mnt_dir)) { list->push_back(mnt.mnt_dir); @@ -306,7 +306,7 @@ Error DirAccessUnix::change_dir(String p_dir) { // prev_dir is the directory we are changing out of String prev_dir; char real_current_dir_name[2048]; - ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG); + ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG); if (prev_dir.parse_utf8(real_current_dir_name)) prev_dir = real_current_dir_name; //no utf8, maybe latin? @@ -327,7 +327,7 @@ Error DirAccessUnix::change_dir(String p_dir) { String base = _get_root_path(); if (base != String() && !try_dir.begins_with(base)) { - ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG); + ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == nullptr, ERR_BUG); String new_dir; new_dir.parse_utf8(real_current_dir_name); @@ -410,14 +410,14 @@ String DirAccessUnix::get_filesystem_type() const { DirAccessUnix::DirAccessUnix() { - dir_stream = 0; + dir_stream = nullptr; _cisdir = false; /* determine drive count */ // set current directory to an absolute path of the current directory char real_current_dir_name[2048]; - ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == NULL); + ERR_FAIL_COND(getcwd(real_current_dir_name, 2048) == nullptr); if (current_dir.parse_utf8(real_current_dir_name)) current_dir = real_current_dir_name; diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 91164dc3f9..4aa408a1f0 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -76,7 +76,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { if (f) fclose(f); - f = NULL; + f = nullptr; path_src = p_path; path = fix_path(p_path); @@ -119,7 +119,7 @@ Error FileAccessUnix::_open(const String &p_path, int p_mode_flags) { f = fopen(path.utf8().get_data(), mode_string); - if (f == NULL) { + if (f == nullptr) { switch (errno) { case ENOENT: { last_error = ERR_FILE_NOT_FOUND; @@ -155,7 +155,7 @@ void FileAccessUnix::close() { return; fclose(f); - f = NULL; + f = nullptr; if (close_notification_func) { close_notification_func(path, flags); @@ -175,7 +175,7 @@ void FileAccessUnix::close() { bool FileAccessUnix::is_open() const { - return (f != NULL); + return (f != nullptr); } String FileAccessUnix::get_path() const { @@ -352,10 +352,10 @@ FileAccess *FileAccessUnix::create_libc() { return memnew(FileAccessUnix); } -CloseNotificationFunc FileAccessUnix::close_notification_func = NULL; +CloseNotificationFunc FileAccessUnix::close_notification_func = nullptr; FileAccessUnix::FileAccessUnix() : - f(NULL), + f(nullptr), flags(0), last_error(OK) { } diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 08c099f771..5e3dedfc2f 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -107,13 +107,13 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) { }; hints.ai_flags &= ~AI_NUMERICHOST; - int s = getaddrinfo(p_hostname.utf8().get_data(), NULL, &hints, &result); + int s = getaddrinfo(p_hostname.utf8().get_data(), nullptr, &hints, &result); if (s != 0) { ERR_PRINT("getaddrinfo failed! Cannot resolve hostname."); return IP_Address(); }; - if (result == NULL || result->ai_addr == NULL) { + if (result == nullptr || result->ai_addr == nullptr) { ERR_PRINT("Invalid response from getaddrinfo"); if (result) freeaddrinfo(result); @@ -175,7 +175,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size); int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME, - NULL, addrs, &buf_size); + nullptr, addrs, &buf_size); if (err == NO_ERROR) { break; }; @@ -189,7 +189,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co IP_ADAPTER_ADDRESSES *adapter = addrs; - while (adapter != NULL) { + while (adapter != nullptr) { Interface_Info info; info.name = adapter->AdapterName; @@ -197,7 +197,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co info.index = String::num_uint64(adapter->IfIndex); IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress; - while (address != NULL) { + while (address != nullptr) { int family = address->Address.lpSockaddr->sa_family; if (family != AF_INET && family != AF_INET6) continue; @@ -219,13 +219,13 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const { - struct ifaddrs *ifAddrStruct = NULL; - struct ifaddrs *ifa = NULL; + struct ifaddrs *ifAddrStruct = nullptr; + struct ifaddrs *ifa = nullptr; int family; getifaddrs(&ifAddrStruct); - for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) { + for (ifa = ifAddrStruct; ifa != nullptr; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) continue; @@ -248,7 +248,7 @@ void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) co info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr)); } - if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct); + if (ifAddrStruct != nullptr) freeifaddrs(ifAddrStruct); } #endif diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index 4adeeb1d9b..7c6543c3a2 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -86,7 +86,7 @@ #define SOCK_CLOSE closesocket // connect is broken on windows under certain conditions, reasons unknown: // See https://github.com/godotengine/webrtc-native/issues/6 -#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::WSAConnect(p_sock, p_addr, p_addr_len, NULL, NULL, NULL, NULL) +#define SOCK_CONNECT(p_sock, p_addr, p_addr_len) ::WSAConnect(p_sock, p_addr, p_addr_len, nullptr, nullptr, nullptr, nullptr) // Workaround missing flag in MinGW #if defined(__MINGW32__) && !defined(SIO_UDP_NETRESET) @@ -155,7 +155,7 @@ NetSocket *NetSocketPosix::_create_func() { void NetSocketPosix::make_default() { #if defined(WINDOWS_ENABLED) - if (_create == NULL) { + if (_create == nullptr) { WSADATA data; WSAStartup(MAKEWORD(2, 2), &data); } @@ -165,10 +165,10 @@ void NetSocketPosix::make_default() { void NetSocketPosix::cleanup() { #if defined(WINDOWS_ENABLED) - if (_create != NULL) { + if (_create != nullptr) { WSACleanup(); } - _create = NULL; + _create = nullptr; #endif } @@ -446,15 +446,15 @@ Error NetSocketPosix::poll(PollType p_type, int p_timeout) const { #if defined(WINDOWS_ENABLED) bool ready = false; fd_set rd, wr, ex; - fd_set *rdp = NULL; - fd_set *wrp = NULL; + fd_set *rdp = nullptr; + fd_set *wrp = nullptr; FD_ZERO(&rd); FD_ZERO(&wr); FD_ZERO(&ex); FD_SET(_sock, &ex); struct timeval timeout = { p_timeout, 0 }; - // For blocking operation, pass NULL timeout pointer to select. - struct timeval *tp = NULL; + // For blocking operation, pass nullptr timeout pointer to select. + struct timeval *tp = nullptr; if (p_timeout >= 0) { // If timeout is non-negative, we want to specify the timeout instead. tp = &timeout; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 458488f3e9..53c60951b7 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -41,7 +41,7 @@ #include "drivers/unix/net_socket_posix.h" #include "drivers/unix/rw_lock_posix.h" #include "drivers/unix/thread_posix.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #ifdef __APPLE__ #include <mach-o/dyld.h> @@ -109,7 +109,7 @@ void OS_Unix::initialize_debugging() { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = handle_interrupt; - sigaction(SIGINT, &action, NULL); + sigaction(SIGINT, &action, nullptr); } } @@ -172,24 +172,24 @@ String OS_Unix::get_name() const { uint64_t OS_Unix::get_unix_time() const { - return time(NULL); + return time(nullptr); }; uint64_t OS_Unix::get_system_time_secs() const { struct timeval tv_now; - gettimeofday(&tv_now, NULL); + gettimeofday(&tv_now, nullptr); return uint64_t(tv_now.tv_sec); } uint64_t OS_Unix::get_system_time_msecs() const { struct timeval tv_now; - gettimeofday(&tv_now, NULL); + gettimeofday(&tv_now, nullptr); return uint64_t(tv_now.tv_sec) * 1000 + uint64_t(tv_now.tv_usec) / 1000; } OS::Date OS_Unix::get_date(bool utc) const { - time_t t = time(NULL); + time_t t = time(nullptr); struct tm *lt; if (utc) lt = gmtime(&t); @@ -209,7 +209,7 @@ OS::Date OS_Unix::get_date(bool utc) const { } OS::Time OS_Unix::get_time(bool utc) const { - time_t t = time(NULL); + time_t t = time(nullptr); struct tm *lt; if (utc) lt = gmtime(&t); @@ -224,7 +224,7 @@ OS::Time OS_Unix::get_time(bool utc) const { } OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { - time_t t = time(NULL); + time_t t = time(nullptr); struct tm *lt = localtime(&t); char name[16]; strftime(name, 16, "%Z", lt); @@ -379,7 +379,7 @@ int OS_Unix::get_process_id() const { bool OS_Unix::has_environment(const String &p_var) const { - return getenv(p_var.utf8().get_data()) != NULL; + return getenv(p_var.utf8().get_data()) != nullptr; } String OS_Unix::get_locale() const { @@ -433,7 +433,7 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S p_symbol_handle = dlsym(p_library_handle, p_name.utf8().get_data()); error = dlerror(); - if (error != NULL) { + if (error != nullptr) { ERR_FAIL_COND_V_MSG(!p_optional, ERR_CANT_RESOLVE, "Can't resolve symbol " + p_name + ". Error: " + error + "."); return ERR_CANT_RESOLVE; @@ -511,7 +511,7 @@ String OS_Unix::get_executable_path() const { int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; char buf[MAXPATHLEN]; size_t len = sizeof(buf); - if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) { + if (sysctl(mib, 4, buf, &len, nullptr, 0) != 0) { WARN_PRINT("Couldn't get executable path from sysctl"); return OS::get_executable_path(); } diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index c381890834..90679ddf1d 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -85,7 +85,7 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp index bb3eebd267..f219a0905c 100644 --- a/drivers/unix/rw_lock_posix.cpp +++ b/drivers/unix/rw_lock_posix.cpp @@ -91,7 +91,7 @@ void RWLockPosix::make_default() { RWLockPosix::RWLockPosix() { //rwlock=PTHREAD_RWLOCK_INITIALIZER; fails on OSX - pthread_rwlock_init(&rwlock, NULL); + pthread_rwlock_init(&rwlock, nullptr); } RWLockPosix::~RWLockPosix() { diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index 21f49a7e38..c227aec6d6 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -75,7 +75,7 @@ void *ThreadPosix::thread_callback(void *userdata) { ScriptServer::thread_exit(); - return NULL; + return nullptr; } Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_user, const Settings &) { @@ -108,7 +108,7 @@ void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) { ERR_FAIL_COND(!tp); ERR_FAIL_COND(tp->pthread == 0); - pthread_join(tp->pthread, NULL); + pthread_join(tp->pthread, nullptr); tp->pthread = 0; } diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub index de776b19b2..7ffdac27d5 100644 --- a/drivers/vulkan/SCsub +++ b/drivers/vulkan/SCsub @@ -1,10 +1,10 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") -if env['builtin_vulkan']: +if env["builtin_vulkan"]: # Use bundled Vulkan headers thirdparty_dir = "#thirdparty/vulkan" env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/loader"]) @@ -27,48 +27,56 @@ if env['builtin_vulkan']: ] vma_sources = [thirdparty_dir + "/vk_mem_alloc.cpp"] - if env['platform'] == "windows": + if env["platform"] == "windows": loader_sources.append("dirent_on_windows.c") loader_sources.append("dxgi_loader.c") - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_WIN32_KHR', - 'VULKAN_NON_CMAKE_BUILD', - 'WIN32_LEAN_AND_MEAN', - 'API_NAME=\\"%s\\"' % 'Vulkan' - ]) - if not env.msvc: # Windows 7+, missing in mingw headers - env_thirdparty.AppendUnique(CPPDEFINES=[ - "CM_GETIDLIST_FILTER_CLASS=0x00000200", - "CM_GETIDLIST_FILTER_PRESENT=0x00000100" - ]) - elif env['platform'] == "osx": - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_MACOS_MVK', - 'VULKAN_NON_CMAKE_BUILD', - 'SYSCONFDIR=\\"%s\\"' % '/etc', - 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', - 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' - ]) - elif env['platform'] == "iphone": - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_IOS_MVK', - 'VULKAN_NON_CMAKE_BUILD', - 'SYSCONFDIR=\\"%s\\"' % '/etc', - 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', - 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' - ]) - elif env['platform'] == "linuxbsd": - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_XLIB_KHR', - 'VULKAN_NON_CMAKE_BUILD', - 'SYSCONFDIR=\\"%s\\"' % '/etc', - 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', - 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' - ]) + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_WIN32_KHR", + "VULKAN_NON_CMAKE_BUILD", + "WIN32_LEAN_AND_MEAN", + 'API_NAME=\\"%s\\"' % "Vulkan", + ] + ) + if not env.msvc: # Windows 7+, missing in mingw headers + env_thirdparty.AppendUnique( + CPPDEFINES=["CM_GETIDLIST_FILTER_CLASS=0x00000200", "CM_GETIDLIST_FILTER_PRESENT=0x00000100"] + ) + elif env["platform"] == "osx": + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_MACOS_MVK", + "VULKAN_NON_CMAKE_BUILD", + 'SYSCONFDIR=\\"%s\\"' % "/etc", + 'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share", + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg", + ] + ) + elif env["platform"] == "iphone": + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_IOS_MVK", + "VULKAN_NON_CMAKE_BUILD", + 'SYSCONFDIR=\\"%s\\"' % "/etc", + 'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share", + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg", + ] + ) + elif env["platform"] == "linuxbsd": + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_XLIB_KHR", + "VULKAN_NON_CMAKE_BUILD", + 'SYSCONFDIR=\\"%s\\"' % "/etc", + 'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share", + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg", + ] + ) import platform - if (platform.system() == "Linux"): + + if platform.system() == "Linux": # In glibc since 2.17 and musl libc since 1.1.24. Used by loader.c. - env_thirdparty.AppendUnique(CPPDEFINES=['HAVE_SECURE_GETENV']) + env_thirdparty.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"]) loader_sources = [thirdparty_dir + "/loader/" + file for file in loader_sources] env_thirdparty.add_source_files(env.drivers_sources, loader_sources) diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 8ebf5b0f04..69957d9939 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1234,13 +1234,13 @@ const VkImageType RenderingDeviceVulkan::vulkan_image_type[RenderingDevice::TEXT Error RenderingDeviceVulkan::_buffer_allocate(Buffer *p_buffer, uint32_t p_size, uint32_t p_usage, VmaMemoryUsage p_mapping) { VkBufferCreateInfo bufferInfo; bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - bufferInfo.pNext = NULL; + bufferInfo.pNext = nullptr; bufferInfo.flags = 0; bufferInfo.size = p_size; bufferInfo.usage = p_usage; bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; bufferInfo.queueFamilyIndexCount = 0; - bufferInfo.pQueueFamilyIndices = 0; + bufferInfo.pQueueFamilyIndices = nullptr; VmaAllocationCreateInfo allocInfo; allocInfo.flags = 0; @@ -1248,10 +1248,10 @@ Error RenderingDeviceVulkan::_buffer_allocate(Buffer *p_buffer, uint32_t p_size, allocInfo.requiredFlags = 0; allocInfo.preferredFlags = 0; allocInfo.memoryTypeBits = 0; - allocInfo.pool = NULL; - allocInfo.pUserData = NULL; + allocInfo.pool = nullptr; + allocInfo.pUserData = nullptr; - VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &p_buffer->buffer, &p_buffer->allocation, NULL); + VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &p_buffer->buffer, &p_buffer->allocation, nullptr); ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); p_buffer->size = p_size; p_buffer->buffer_info.buffer = p_buffer->buffer; @@ -1265,8 +1265,8 @@ Error RenderingDeviceVulkan::_buffer_free(Buffer *p_buffer) { ERR_FAIL_COND_V(p_buffer->size == 0, ERR_INVALID_PARAMETER); vmaDestroyBuffer(allocator, p_buffer->buffer, p_buffer->allocation); - p_buffer->buffer = NULL; - p_buffer->allocation = NULL; + p_buffer->buffer = nullptr; + p_buffer->allocation = nullptr; p_buffer->size = 0; return OK; @@ -1276,13 +1276,13 @@ Error RenderingDeviceVulkan::_insert_staging_block() { VkBufferCreateInfo bufferInfo; bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - bufferInfo.pNext = NULL; + bufferInfo.pNext = nullptr; bufferInfo.flags = 0; bufferInfo.size = staging_buffer_block_size; bufferInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; bufferInfo.queueFamilyIndexCount = 0; - bufferInfo.pQueueFamilyIndices = 0; + bufferInfo.pQueueFamilyIndices = nullptr; VmaAllocationCreateInfo allocInfo; allocInfo.flags = 0; @@ -1290,12 +1290,12 @@ Error RenderingDeviceVulkan::_insert_staging_block() { allocInfo.requiredFlags = 0; allocInfo.preferredFlags = 0; allocInfo.memoryTypeBits = 0; - allocInfo.pool = NULL; - allocInfo.pUserData = NULL; + allocInfo.pool = nullptr; + allocInfo.pUserData = nullptr; StagingBufferBlock block; - VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &block.buffer, &block.allocation, NULL); + VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &block.buffer, &block.allocation, nullptr); ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vmaCreateBuffer failed with error " + itos(err) + "."); block.frame_used = 0; @@ -1459,7 +1459,7 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c //map staging buffer (It's CPU and coherent) - void *data_ptr = NULL; + void *data_ptr = nullptr; { VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr); ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + "."); @@ -1492,11 +1492,11 @@ void RenderingDeviceVulkan::_memory_barrier(VkPipelineStageFlags p_src_stage_mas VkMemoryBarrier mem_barrier; mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; - mem_barrier.pNext = NULL; + mem_barrier.pNext = nullptr; mem_barrier.srcAccessMask = p_src_access; mem_barrier.dstAccessMask = p_dst_sccess; - vkCmdPipelineBarrier(p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, p_src_stage_mask, p_dst_stage_mask, 0, 1, &mem_barrier, 0, NULL, 0, NULL); + vkCmdPipelineBarrier(p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, p_src_stage_mask, p_dst_stage_mask, 0, 1, &mem_barrier, 0, nullptr, 0, nullptr); } void RenderingDeviceVulkan::_full_barrier(bool p_sync_with_draw) { @@ -1539,7 +1539,7 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f VkBufferMemoryBarrier buffer_mem_barrier; buffer_mem_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; - buffer_mem_barrier.pNext = NULL; + buffer_mem_barrier.pNext = nullptr; buffer_mem_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; buffer_mem_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; buffer_mem_barrier.srcAccessMask = p_src_access; @@ -1548,7 +1548,7 @@ void RenderingDeviceVulkan::_buffer_memory_barrier(VkBuffer buffer, uint64_t p_f buffer_mem_barrier.offset = p_from; buffer_mem_barrier.size = p_size; - vkCmdPipelineBarrier(p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, p_src_stage_mask, p_dst_stage_mask, 0, 0, NULL, 1, &buffer_mem_barrier, 0, NULL); + vkCmdPipelineBarrier(p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, p_src_stage_mask, p_dst_stage_mask, 0, 0, nullptr, 1, &buffer_mem_barrier, 0, nullptr); } /*****************/ @@ -1561,7 +1561,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T VkImageCreateInfo image_create_info; image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - image_create_info.pNext = NULL; + image_create_info.pNext = nullptr; image_create_info.flags = 0; VkImageFormatListCreateInfoKHR format_list_create_info; @@ -1574,7 +1574,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T } format_list_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR; - format_list_create_info.pNext = NULL; + format_list_create_info.pNext = nullptr; format_list_create_info.viewFormatCount = allowed_formats.size(); format_list_create_info.pViewFormats = allowed_formats.ptr(); image_create_info.pNext = &format_list_create_info; @@ -1665,7 +1665,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; image_create_info.queueFamilyIndexCount = 0; - image_create_info.pQueueFamilyIndices = NULL; + image_create_info.pQueueFamilyIndices = nullptr; image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; uint32_t required_mipmaps = get_image_required_mipmaps(image_create_info.extent.width, image_create_info.extent.height, image_create_info.extent.depth); @@ -1744,8 +1744,8 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T allocInfo.requiredFlags = 0; allocInfo.preferredFlags = 0; allocInfo.memoryTypeBits = 0; - allocInfo.pool = NULL; - allocInfo.pUserData = NULL; + allocInfo.pool = nullptr; + allocInfo.pUserData = nullptr; Texture texture; @@ -1806,7 +1806,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T VkImageViewCreateInfo image_view_create_info; image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - image_view_create_info.pNext = NULL; + image_view_create_info.pNext = nullptr; image_view_create_info.flags = 0; image_view_create_info.image = texture.image; @@ -1852,7 +1852,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; } - err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view); + err = vkCreateImageView(device, &image_view_create_info, nullptr, &texture.view); if (err) { vmaDestroyImage(allocator, texture.image, texture.allocation); @@ -1863,7 +1863,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; @@ -1877,7 +1877,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T image_memory_barrier.subresourceRange.baseArrayLayer = 0; image_memory_barrier.subresourceRange.layerCount = image_create_info.arrayLayers; - vkCmdPipelineBarrier(frames[frame].setup_command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(frames[frame].setup_command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } RID id = texture_owner.make_rid(texture); @@ -1910,7 +1910,7 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID VkImageViewCreateInfo image_view_create_info; image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - image_view_create_info.pNext = NULL; + image_view_create_info.pNext = nullptr; image_view_create_info.flags = 0; image_view_create_info.image = texture.image; @@ -1961,7 +1961,7 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; } - VkResult err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view); + VkResult err = vkCreateImageView(device, &image_view_create_info, nullptr, &texture.view); ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateImageView failed with error " + itos(err) + "."); texture.owner = p_with_texture; @@ -2002,7 +2002,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p VkImageViewCreateInfo image_view_create_info; image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - image_view_create_info.pNext = NULL; + image_view_create_info.pNext = nullptr; image_view_create_info.flags = 0; image_view_create_info.image = texture.image; @@ -2059,7 +2059,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; } - VkResult err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view); + VkResult err = vkCreateImageView(device, &image_view_create_info, nullptr, &texture.view); ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateImageView failed with error " + itos(err) + "."); texture.owner = p_with_texture; @@ -2121,7 +2121,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; image_memory_barrier.oldLayout = texture->layout; @@ -2136,7 +2136,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con image_memory_barrier.subresourceRange.baseArrayLayer = p_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } uint32_t mipmap_offset = 0; @@ -2169,7 +2169,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con uint8_t *write_ptr; { //map - void *data_ptr = NULL; + void *data_ptr = nullptr; VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr); ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + "."); write_ptr = (uint8_t *)data_ptr; @@ -2258,7 +2258,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; @@ -2272,7 +2272,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con image_memory_barrier.subresourceRange.baseArrayLayer = p_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } return OK; @@ -2380,7 +2380,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t { //Source image barrier VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; image_memory_barrier.oldLayout = tex->layout; @@ -2395,7 +2395,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t image_memory_barrier.subresourceRange.baseArrayLayer = p_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } uint32_t computed_w = tex->width; @@ -2437,7 +2437,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t { //restore src VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; @@ -2451,7 +2451,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t image_memory_barrier.subresourceRange.baseArrayLayer = p_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } _flush(true); @@ -2546,7 +2546,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, { //Source VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; image_memory_barrier.oldLayout = src_tex->layout; @@ -2561,12 +2561,12 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, image_memory_barrier.subresourceRange.baseArrayLayer = p_src_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } { //Dest VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; image_memory_barrier.oldLayout = dst_tex->layout; @@ -2581,7 +2581,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, image_memory_barrier.subresourceRange.baseArrayLayer = p_dst_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } //COPY @@ -2617,7 +2617,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, { //restore src VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; @@ -2631,14 +2631,14 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, image_memory_barrier.subresourceRange.baseArrayLayer = p_src_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } { //make dst readable VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; @@ -2653,7 +2653,7 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture, image_memory_barrier.subresourceRange.baseArrayLayer = p_src_layer; image_memory_barrier.subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } } @@ -2691,7 +2691,7 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, if (src_tex->layout != VK_IMAGE_LAYOUT_GENERAL) { //storage may be in general state VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; image_memory_barrier.oldLayout = src_tex->layout; @@ -2707,7 +2707,7 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, image_memory_barrier.subresourceRange.layerCount = p_layers; layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } VkClearColorValue clear_color; @@ -2729,7 +2729,7 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; @@ -2744,7 +2744,7 @@ Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, image_memory_barrier.subresourceRange.baseArrayLayer = p_base_layer; image_memory_barrier.subresourceRange.layerCount = p_layers; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); } return OK; @@ -2944,27 +2944,27 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF subpass.flags = 0; subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; subpass.inputAttachmentCount = 0; //unsupported for now - subpass.pInputAttachments = NULL; + subpass.pInputAttachments = nullptr; subpass.colorAttachmentCount = color_references.size(); subpass.pColorAttachments = color_references.ptr(); subpass.pDepthStencilAttachment = depth_stencil_references.ptr(); subpass.pResolveAttachments = resolve_references.ptr(); subpass.preserveAttachmentCount = 0; - subpass.pPreserveAttachments = NULL; + subpass.pPreserveAttachments = nullptr; VkRenderPassCreateInfo render_pass_create_info; render_pass_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - render_pass_create_info.pNext = NULL; + render_pass_create_info.pNext = nullptr; render_pass_create_info.flags = 0; render_pass_create_info.attachmentCount = attachments.size(); render_pass_create_info.pAttachments = attachments.ptr(); render_pass_create_info.subpassCount = 1; render_pass_create_info.pSubpasses = &subpass; render_pass_create_info.dependencyCount = 0; - render_pass_create_info.pDependencies = NULL; + render_pass_create_info.pDependencies = nullptr; VkRenderPass render_pass; - VkResult res = vkCreateRenderPass(device, &render_pass_create_info, NULL, &render_pass); + VkResult res = vkCreateRenderPass(device, &render_pass_create_info, nullptr, &render_pass); ERR_FAIL_COND_V_MSG(res, VK_NULL_HANDLE, "vkCreateRenderPass failed with error " + itos(res) + "."); if (r_color_attachment_count) { @@ -3083,7 +3083,7 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) { VkSamplerCreateInfo sampler_create_info; sampler_create_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; - sampler_create_info.pNext = NULL; + sampler_create_info.pNext = nullptr; sampler_create_info.flags = 0; sampler_create_info.magFilter = p_state.mag_filter == SAMPLER_FILTER_LINEAR ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; sampler_create_info.minFilter = p_state.min_filter == SAMPLER_FILTER_LINEAR ? VK_FILTER_LINEAR : VK_FILTER_NEAREST; @@ -3113,7 +3113,7 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) { sampler_create_info.unnormalizedCoordinates = p_state.unnormalized_uvw; VkSampler sampler; - VkResult res = vkCreateSampler(device, &sampler_create_info, NULL, &sampler); + VkResult res = vkCreateSampler(device, &sampler_create_info, nullptr, &sampler); ERR_FAIL_COND_V_MSG(res, RID(), "vkCreateSampler failed with error " + itos(res) + "."); return sampler_owner.make_rid(sampler); @@ -3178,7 +3178,7 @@ RenderingDevice::VertexFormatID RenderingDeviceVulkan::vertex_format_create(cons } vdcache.create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - vdcache.create_info.pNext = NULL; + vdcache.create_info.pNext = nullptr; vdcache.create_info.flags = 0; vdcache.create_info.vertexAttributeDescriptionCount = p_vertex_formats.size(); @@ -3546,7 +3546,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } layout_binding.binding = binding; layout_binding.stageFlags = shader_stage_masks[p_stage]; - layout_binding.pImmutableSamplers = NULL; //no support for this yet + layout_binding.pImmutableSamplers = nullptr; //no support for this yet info.stages = 1 << p_stage; info.binding = binding; @@ -3600,7 +3600,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed parsing shader."); uint32_t binding_count = 0; - result = spvReflectEnumerateDescriptorBindings(&module, &binding_count, NULL); + result = spvReflectEnumerateDescriptorBindings(&module, &binding_count, nullptr); ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating descriptor bindings."); @@ -3742,7 +3742,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages layout_binding.binding = info.binding; layout_binding.stageFlags = shader_stage_masks[stage]; - layout_binding.pImmutableSamplers = NULL; //no support for this yet + layout_binding.pImmutableSamplers = nullptr; //no support for this yet info.stages = 1 << stage; info.binding = info.binding; @@ -3760,7 +3760,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages if (stage == SHADER_STAGE_VERTEX) { uint32_t iv_count = 0; - result = spvReflectEnumerateInputVariables(&module, &iv_count, NULL); + result = spvReflectEnumerateInputVariables(&module, &iv_count, nullptr); ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating input variables."); @@ -3783,7 +3783,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages if (stage == SHADER_STAGE_FRAGMENT) { uint32_t ov_count = 0; - result = spvReflectEnumerateOutputVariables(&module, &ov_count, NULL); + result = spvReflectEnumerateOutputVariables(&module, &ov_count, nullptr); ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating output variables."); @@ -3803,7 +3803,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages } } uint32_t pc_count = 0; - result = spvReflectEnumeratePushConstantBlocks(&module, &pc_count, NULL); + result = spvReflectEnumeratePushConstantBlocks(&module, &pc_count, nullptr); ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed enumerating push constants."); @@ -3817,7 +3817,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages ERR_FAIL_COND_V_MSG(result != SPV_REFLECT_RESULT_SUCCESS, RID(), "Reflection of SPIR-V shader stage '" + String(shader_stage_names[p_stages[i].shader_stage]) + "' failed obtaining push constants."); #if 0 - if (pconstants[0] == NULL) { + if (pconstants[0] == nullptr) { FileAccess *f = FileAccess::open("res://popo.spv", FileAccess::WRITE); f->store_buffer((const uint8_t *)&SpirV[0], SpirV.size() * sizeof(uint32_t)); memdelete(f); @@ -3857,7 +3857,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages for (int i = 0; i < p_stages.size(); i++) { VkShaderModuleCreateInfo shader_module_create_info; shader_module_create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - shader_module_create_info.pNext = NULL; + shader_module_create_info.pNext = nullptr; shader_module_create_info.flags = 0; shader_module_create_info.codeSize = p_stages[i].spir_v.size(); const uint8_t *r = p_stages[i].spir_v.ptr(); @@ -3865,7 +3865,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages shader_module_create_info.pCode = (const uint32_t *)r; VkShaderModule module; - VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module); + VkResult res = vkCreateShaderModule(device, &shader_module_create_info, nullptr, &module); if (res) { success = false; error_text = "Error (" + itos(res) + ") creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]); @@ -3882,12 +3882,12 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages VkPipelineShaderStageCreateInfo shader_stage; shader_stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - shader_stage.pNext = NULL; + shader_stage.pNext = nullptr; shader_stage.flags = 0; shader_stage.stage = shader_stage_bits[p_stages[i].shader_stage]; shader_stage.module = module; shader_stage.pName = "main"; - shader_stage.pSpecializationInfo = NULL; + shader_stage.pSpecializationInfo = nullptr; shader.pipeline_stages.push_back(shader_stage); } @@ -3900,13 +3900,13 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages //empty ones are fine if they were not used according to spec (binding count will be 0) VkDescriptorSetLayoutCreateInfo layout_create_info; layout_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; - layout_create_info.pNext = NULL; + layout_create_info.pNext = nullptr; layout_create_info.flags = 0; layout_create_info.bindingCount = set_bindings[i].size(); layout_create_info.pBindings = set_bindings[i].ptr(); VkDescriptorSetLayout layout; - VkResult res = vkCreateDescriptorSetLayout(device, &layout_create_info, NULL, &layout); + VkResult res = vkCreateDescriptorSetLayout(device, &layout_create_info, nullptr, &layout); if (res) { error_text = "Error (" + itos(res) + ") creating descriptor set layout for set " + itos(i); success = false; @@ -3943,7 +3943,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages //create pipeline layout VkPipelineLayoutCreateInfo pipeline_layout_create_info; pipeline_layout_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; - pipeline_layout_create_info.pNext = NULL; + pipeline_layout_create_info.pNext = nullptr; pipeline_layout_create_info.flags = 0; pipeline_layout_create_info.setLayoutCount = shader.sets.size(); @@ -3965,10 +3965,10 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages pipeline_layout_create_info.pPushConstantRanges = &push_constant_range; } else { pipeline_layout_create_info.pushConstantRangeCount = 0; - pipeline_layout_create_info.pPushConstantRanges = NULL; + pipeline_layout_create_info.pPushConstantRanges = nullptr; } - VkResult err = vkCreatePipelineLayout(device, &pipeline_layout_create_info, NULL, &shader.pipeline_layout); + VkResult err = vkCreatePipelineLayout(device, &pipeline_layout_create_info, nullptr, &shader.pipeline_layout); if (err) { error_text = "Error (" + itos(err) + ") creating pipeline layout."; @@ -3979,11 +3979,11 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages if (!success) { //clean up if failed for (int i = 0; i < shader.pipeline_stages.size(); i++) { - vkDestroyShaderModule(device, shader.pipeline_stages[i].module, NULL); + vkDestroyShaderModule(device, shader.pipeline_stages[i].module, nullptr); } for (int i = 0; i < shader.sets.size(); i++) { - vkDestroyDescriptorSetLayout(device, shader.sets[i].descriptor_set_layout, NULL); + vkDestroyDescriptorSetLayout(device, shader.sets[i].descriptor_set_layout, nullptr); } ERR_FAIL_V_MSG(RID(), error_text); @@ -4064,7 +4064,7 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF VkBufferViewCreateInfo view_create_info; view_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; - view_create_info.pNext = NULL; + view_create_info.pNext = nullptr; view_create_info.flags = 0; view_create_info.buffer = texture_buffer.buffer.buffer; view_create_info.format = vulkan_formats[p_format]; @@ -4073,7 +4073,7 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF texture_buffer.view = VK_NULL_HANDLE; - VkResult res = vkCreateBufferView(device, &view_create_info, NULL, &texture_buffer.view); + VkResult res = vkCreateBufferView(device, &view_create_info, nullptr, &texture_buffer.view); if (res) { _buffer_free(&texture_buffer.buffer); ERR_FAIL_V_MSG(RID(), "Unable to create buffer view, error " + itos(res) + "."); @@ -4088,7 +4088,7 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a descriptor_pools[p_key] = Set<DescriptorPool *>(); } - DescriptorPool *pool = NULL; + DescriptorPool *pool = nullptr; for (Set<DescriptorPool *>::Element *E = descriptor_pools[p_key].front(); E; E = E->next()) { if (E->get()->usage < max_descriptors_per_pool) { @@ -4104,7 +4104,7 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a VkDescriptorPoolCreateInfo descriptor_pool_create_info; descriptor_pool_create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - descriptor_pool_create_info.pNext = NULL; + descriptor_pool_create_info.pNext = nullptr; descriptor_pool_create_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; // can't think how somebody may NOT need this flag.. descriptor_pool_create_info.maxSets = max_descriptors_per_pool; Vector<VkDescriptorPoolSize> sizes; @@ -4169,10 +4169,10 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a descriptor_pool_create_info.poolSizeCount = sizes.size(); descriptor_pool_create_info.pPoolSizes = sizes.ptr(); - VkResult res = vkCreateDescriptorPool(device, &descriptor_pool_create_info, NULL, &pool->pool); + VkResult res = vkCreateDescriptorPool(device, &descriptor_pool_create_info, nullptr, &pool->pool); if (res) { memdelete(pool); - ERR_FAIL_COND_V_MSG(res, NULL, "vkCreateDescriptorPool failed with error " + itos(res) + "."); + ERR_FAIL_COND_V_MSG(res, nullptr, "vkCreateDescriptorPool failed with error " + itos(res) + "."); } descriptor_pools[p_key].insert(pool); } @@ -4189,7 +4189,7 @@ void RenderingDeviceVulkan::_descriptor_pool_free(const DescriptorPoolKey &p_key ERR_FAIL_COND(p_pool->usage == 0); p_pool->usage--; if (p_pool->usage == 0) { - vkDestroyDescriptorPool(device, p_pool->pool, NULL); + vkDestroyDescriptorPool(device, p_pool->pool, nullptr); descriptor_pools[p_key].erase(p_pool); memdelete(p_pool); if (descriptor_pools[p_key].empty()) { @@ -4249,8 +4249,8 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, VkWriteDescriptorSet write; //common header write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - write.pNext = NULL; - write.dstSet = NULL; //will assign afterwards when everything is valid + write.pNext = nullptr; + write.dstSet = nullptr; //will assign afterwards when everything is valid write.dstBinding = set_uniform.binding; uint32_t type_size = 1; @@ -4282,8 +4282,8 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.descriptorCount = uniform.ids.size(); write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; write.pImageInfo = image_infos.push_back(image_info)->get().ptr(); - write.pBufferInfo = NULL; - write.pTexelBufferView = NULL; + write.pBufferInfo = nullptr; + write.pTexelBufferView = nullptr; type_size = uniform.ids.size(); @@ -4337,8 +4337,8 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.descriptorCount = uniform.ids.size() / 2; write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; write.pImageInfo = image_infos.push_back(image_info)->get().ptr(); - write.pBufferInfo = NULL; - write.pTexelBufferView = NULL; + write.pBufferInfo = nullptr; + write.pTexelBufferView = nullptr; type_size = uniform.ids.size() / 2; @@ -4363,7 +4363,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, "Texture (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") needs the TEXTURE_USAGE_SAMPLING_BIT usage flag set in order to be used as uniform."); VkDescriptorImageInfo img_info; - img_info.sampler = NULL; + img_info.sampler = nullptr; img_info.imageView = texture->view; if (texture->usage_flags & (TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | TEXTURE_USAGE_RESOLVE_ATTACHMENT_BIT)) { @@ -4389,8 +4389,8 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.descriptorCount = uniform.ids.size(); write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; write.pImageInfo = image_infos.push_back(image_info)->get().ptr(); - write.pBufferInfo = NULL; - write.pTexelBufferView = NULL; + write.pBufferInfo = nullptr; + write.pTexelBufferView = nullptr; type_size = uniform.ids.size(); } break; @@ -4416,7 +4416,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, "Image (binding: " + itos(uniform.binding) + ", index " + itos(j) + ") needs the TEXTURE_USAGE_STORAGE_BIT usage flag set in order to be used as uniform."); VkDescriptorImageInfo img_info; - img_info.sampler = NULL; + img_info.sampler = nullptr; img_info.imageView = texture->view; if (texture->owner.is_valid()) { @@ -4438,8 +4438,8 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.descriptorCount = uniform.ids.size(); write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; write.pImageInfo = image_infos.push_back(image_info)->get().ptr(); - write.pBufferInfo = NULL; - write.pTexelBufferView = NULL; + write.pBufferInfo = nullptr; + write.pTexelBufferView = nullptr; type_size = uniform.ids.size(); @@ -4467,7 +4467,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.dstArrayElement = 0; write.descriptorCount = uniform.ids.size(); write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; - write.pImageInfo = NULL; + write.pImageInfo = nullptr; write.pBufferInfo = buffer_infos.push_back(buffer_info)->get().ptr(); write.pTexelBufferView = buffer_views.push_back(buffer_view)->get().ptr(); @@ -4533,9 +4533,9 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.dstArrayElement = 0; write.descriptorCount = 1; write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - write.pImageInfo = NULL; + write.pImageInfo = nullptr; write.pBufferInfo = &buffer->buffer_info; - write.pTexelBufferView = NULL; + write.pTexelBufferView = nullptr; } break; case UNIFORM_TYPE_STORAGE_BUFFER: { @@ -4552,9 +4552,9 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, write.dstArrayElement = 0; write.descriptorCount = 1; write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; - write.pImageInfo = NULL; + write.pImageInfo = nullptr; write.pBufferInfo = &buffer->buffer_info; - write.pTexelBufferView = NULL; + write.pTexelBufferView = nullptr; } break; case UNIFORM_TYPE_INPUT_ATTACHMENT: { @@ -4578,7 +4578,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, VkDescriptorSetAllocateInfo descriptor_set_allocate_info; descriptor_set_allocate_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - descriptor_set_allocate_info.pNext = NULL; + descriptor_set_allocate_info.pNext = nullptr; descriptor_set_allocate_info.descriptorPool = pool->pool; descriptor_set_allocate_info.descriptorSetCount = 1; descriptor_set_allocate_info.pSetLayouts = &shader->sets[p_shader_set].descriptor_set_layout; @@ -4619,7 +4619,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, for (int i = 0; i < writes.size(); i++) { writes.write[i].dstSet = descriptor_set; } - vkUpdateDescriptorSets(device, writes.size(), writes.ptr(), 0, NULL); + vkUpdateDescriptorSets(device, writes.size(), writes.ptr(), 0, nullptr); } return id; @@ -4638,7 +4638,7 @@ Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint VkPipelineStageFlags dst_stage_mask; VkAccessFlags dst_access; - Buffer *buffer = NULL; + Buffer *buffer = nullptr; if (vertex_buffer_owner.owns(p_buffer)) { dst_stage_mask = VK_PIPELINE_STAGE_VERTEX_INPUT_BIT; dst_access = VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT; @@ -4684,7 +4684,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { _THREAD_SAFE_METHOD_ - Buffer *buffer = NULL; + Buffer *buffer = nullptr; if (vertex_buffer_owner.owns(p_buffer)) { buffer = vertex_buffer_owner.getornull(p_buffer); } else if (index_buffer_owner.owns(p_buffer)) { @@ -4783,12 +4783,12 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma } else { //does not use vertices pipeline_vertex_input_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - pipeline_vertex_input_state_create_info.pNext = NULL; + pipeline_vertex_input_state_create_info.pNext = nullptr; pipeline_vertex_input_state_create_info.flags = 0; pipeline_vertex_input_state_create_info.vertexBindingDescriptionCount = 0; - pipeline_vertex_input_state_create_info.pVertexBindingDescriptions = NULL; + pipeline_vertex_input_state_create_info.pVertexBindingDescriptions = nullptr; pipeline_vertex_input_state_create_info.vertexAttributeDescriptionCount = 0; - pipeline_vertex_input_state_create_info.pVertexAttributeDescriptions = NULL; + pipeline_vertex_input_state_create_info.pVertexAttributeDescriptions = nullptr; ERR_FAIL_COND_V_MSG(shader->vertex_input_mask != 0, RID(), "Shader contains vertex inputs, but no vertex input description was provided for pipeline creation."); @@ -4799,7 +4799,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma VkPipelineInputAssemblyStateCreateInfo input_assembly_create_info; input_assembly_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; - input_assembly_create_info.pNext = NULL; + input_assembly_create_info.pNext = nullptr; input_assembly_create_info.flags = 0; static const VkPrimitiveTopology topology_list[RENDER_PRIMITIVE_MAX] = { @@ -4822,24 +4822,24 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma //tesselation VkPipelineTessellationStateCreateInfo tesselation_create_info; tesselation_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; - tesselation_create_info.pNext = NULL; + tesselation_create_info.pNext = nullptr; tesselation_create_info.flags = 0; ERR_FAIL_COND_V(p_rasterization_state.patch_control_points < 1 || p_rasterization_state.patch_control_points > limits.maxTessellationPatchSize, RID()); tesselation_create_info.patchControlPoints = p_rasterization_state.patch_control_points; VkPipelineViewportStateCreateInfo viewport_state_create_info; viewport_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; - viewport_state_create_info.pNext = NULL; + viewport_state_create_info.pNext = nullptr; viewport_state_create_info.flags = 0; viewport_state_create_info.viewportCount = 1; //if VR extensions are supported at some point, this will have to be customizable in the framebuffer format - viewport_state_create_info.pViewports = NULL; + viewport_state_create_info.pViewports = nullptr; viewport_state_create_info.scissorCount = 1; - viewport_state_create_info.pScissors = NULL; + viewport_state_create_info.pScissors = nullptr; //rasterization VkPipelineRasterizationStateCreateInfo rasterization_state_create_info; rasterization_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; - rasterization_state_create_info.pNext = NULL; + rasterization_state_create_info.pNext = nullptr; rasterization_state_create_info.flags = 0; rasterization_state_create_info.depthClampEnable = p_rasterization_state.enable_depth_clamp; rasterization_state_create_info.rasterizerDiscardEnable = p_rasterization_state.discard_primitives; @@ -4862,7 +4862,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma //multisample VkPipelineMultisampleStateCreateInfo multisample_state_create_info; multisample_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; - multisample_state_create_info.pNext = NULL; + multisample_state_create_info.pNext = nullptr; multisample_state_create_info.flags = 0; multisample_state_create_info.rasterizationSamples = rasterization_sample_count[p_multisample_state.sample_count]; @@ -4882,7 +4882,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma } multisample_state_create_info.pSampleMask = sample_mask.ptr(); } else { - multisample_state_create_info.pSampleMask = NULL; + multisample_state_create_info.pSampleMask = nullptr; } multisample_state_create_info.alphaToCoverageEnable = p_multisample_state.enable_alpha_to_coverage; @@ -4892,7 +4892,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma VkPipelineDepthStencilStateCreateInfo depth_stencil_state_create_info; depth_stencil_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - depth_stencil_state_create_info.pNext = NULL; + depth_stencil_state_create_info.pNext = nullptr; depth_stencil_state_create_info.flags = 0; depth_stencil_state_create_info.depthTestEnable = p_depth_stencil_state.enable_depth_test; depth_stencil_state_create_info.depthWriteEnable = p_depth_stencil_state.enable_depth_write; @@ -4931,7 +4931,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma //blend state VkPipelineColorBlendStateCreateInfo color_blend_state_create_info; color_blend_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; - color_blend_state_create_info.pNext = NULL; + color_blend_state_create_info.pNext = nullptr; color_blend_state_create_info.flags = 0; color_blend_state_create_info.logicOpEnable = p_blend_state.enable_logic_op; ERR_FAIL_INDEX_V(p_blend_state.logic_op, LOGIC_OP_MAX, RID()); @@ -4988,7 +4988,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma VkPipelineDynamicStateCreateInfo dynamic_state_create_info; dynamic_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; - dynamic_state_create_info.pNext = NULL; + dynamic_state_create_info.pNext = nullptr; dynamic_state_create_info.flags = 0; Vector<VkDynamicState> dynamic_states; //vulkan is weird.. @@ -5030,7 +5030,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma VkGraphicsPipelineCreateInfo graphics_pipeline_create_info; graphics_pipeline_create_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; - graphics_pipeline_create_info.pNext = NULL; + graphics_pipeline_create_info.pNext = nullptr; graphics_pipeline_create_info.flags = 0; graphics_pipeline_create_info.stageCount = shader->pipeline_stages.size(); @@ -5048,11 +5048,11 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma graphics_pipeline_create_info.renderPass = fb_format.render_pass; graphics_pipeline_create_info.subpass = 0; - graphics_pipeline_create_info.basePipelineHandle = NULL; + graphics_pipeline_create_info.basePipelineHandle = nullptr; graphics_pipeline_create_info.basePipelineIndex = 0; RenderPipeline pipeline; - VkResult err = vkCreateGraphicsPipelines(device, NULL, 1, &graphics_pipeline_create_info, NULL, &pipeline.pipeline); + VkResult err = vkCreateGraphicsPipelines(device, nullptr, 1, &graphics_pipeline_create_info, nullptr, &pipeline.pipeline); ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateGraphicsPipelines failed with error " + itos(err) + "."); pipeline.set_formats = shader->set_formats; @@ -5116,16 +5116,16 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader) { VkComputePipelineCreateInfo compute_pipeline_create_info; compute_pipeline_create_info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO; - compute_pipeline_create_info.pNext = NULL; + compute_pipeline_create_info.pNext = nullptr; compute_pipeline_create_info.flags = 0; compute_pipeline_create_info.stage = shader->pipeline_stages[0]; compute_pipeline_create_info.layout = shader->pipeline_layout; - compute_pipeline_create_info.basePipelineHandle = NULL; + compute_pipeline_create_info.basePipelineHandle = nullptr; compute_pipeline_create_info.basePipelineIndex = 0; ComputePipeline pipeline; - VkResult err = vkCreateComputePipelines(device, NULL, 1, &compute_pipeline_create_info, NULL, &pipeline.pipeline); + VkResult err = vkCreateComputePipelines(device, nullptr, 1, &compute_pipeline_create_info, nullptr, &pipeline.pipeline); ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateComputePipelines failed with error " + itos(err) + "."); pipeline.set_formats = shader->set_formats; @@ -5193,8 +5193,8 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di _THREAD_SAFE_METHOD_ - ERR_FAIL_COND_V_MSG(draw_list != NULL, INVALID_ID, "Only one draw list can be active at the same time."); - ERR_FAIL_COND_V_MSG(compute_list != NULL, INVALID_ID, "Only one draw/compute list can be active at the same time."); + ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time."); + ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time."); VkCommandBuffer command_buffer = frames[frame].draw_command_buffer; draw_list = memnew(DrawList); @@ -5207,7 +5207,7 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin_for_screen(Di VkRenderPassBeginInfo render_pass_begin; render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - render_pass_begin.pNext = NULL; + render_pass_begin.pNext = nullptr; render_pass_begin.renderPass = context->window_get_render_pass(p_screen); render_pass_begin.framebuffer = context->window_get_framebuffer(p_screen); @@ -5268,7 +5268,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu VkFramebufferCreateInfo framebuffer_create_info; framebuffer_create_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_create_info.pNext = NULL; + framebuffer_create_info.pNext = nullptr; framebuffer_create_info.flags = 0; framebuffer_create_info.renderPass = version.render_pass; Vector<VkImageView> attachments; @@ -5285,7 +5285,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu framebuffer_create_info.height = p_framebuffer->size.height; framebuffer_create_info.layers = 1; - VkResult err = vkCreateFramebuffer(device, &framebuffer_create_info, NULL, &version.framebuffer); + VkResult err = vkCreateFramebuffer(device, &framebuffer_create_info, nullptr, &version.framebuffer); ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkCreateFramebuffer failed with error " + itos(err) + "."); p_framebuffer->framebuffers.insert(vk, version); @@ -5301,7 +5301,7 @@ Error RenderingDeviceVulkan::_draw_list_render_pass_begin(Framebuffer *framebuff VkRenderPassBeginInfo render_pass_begin; render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - render_pass_begin.pNext = NULL; + render_pass_begin.pNext = nullptr; render_pass_begin.renderPass = render_pass; render_pass_begin.framebuffer = vkframebuffer; @@ -5404,8 +5404,8 @@ RenderingDevice::DrawListID RenderingDeviceVulkan::draw_list_begin(RID p_framebu _THREAD_SAFE_METHOD_ - ERR_FAIL_COND_V_MSG(draw_list != NULL, INVALID_ID, "Only one draw list can be active at the same time."); - ERR_FAIL_COND_V_MSG(compute_list != NULL, INVALID_ID, "Only one draw/compute list can be active at the same time."); + ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time."); + ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time."); Framebuffer *framebuffer = framebuffer_owner.getornull(p_framebuffer); ERR_FAIL_COND_V(!framebuffer, INVALID_ID); @@ -5542,11 +5542,11 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p VkCommandPoolCreateInfo cmd_pool_info; cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - cmd_pool_info.pNext = NULL; + cmd_pool_info.pNext = nullptr; cmd_pool_info.queueFamilyIndex = context->get_graphics_queue(); cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; - VkResult res = vkCreateCommandPool(device, &cmd_pool_info, NULL, &split_draw_list_allocators.write[i].command_pool); + VkResult res = vkCreateCommandPool(device, &cmd_pool_info, nullptr, &split_draw_list_allocators.write[i].command_pool); ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + "."); for (int j = 0; j < frame_count; j++) { @@ -5556,7 +5556,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p VkCommandBufferAllocateInfo cmdbuf; //no command buffer exists, create it. cmdbuf.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - cmdbuf.pNext = NULL; + cmdbuf.pNext = nullptr; cmdbuf.commandPool = split_draw_list_allocators[i].command_pool; cmdbuf.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; cmdbuf.commandBufferCount = 1; @@ -5593,7 +5593,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p VkCommandBufferInheritanceInfo inheritance_info; inheritance_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; - inheritance_info.pNext = NULL; + inheritance_info.pNext = nullptr; inheritance_info.renderPass = render_pass; inheritance_info.subpass = 0; inheritance_info.framebuffer = vkframebuffer; @@ -5603,21 +5603,21 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - cmdbuf_begin.pNext = NULL; + cmdbuf_begin.pNext = nullptr; cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; cmdbuf_begin.pInheritanceInfo = &inheritance_info; VkResult res = vkResetCommandBuffer(command_buffer, 0); if (res) { memdelete_arr(draw_list); - draw_list = NULL; + draw_list = nullptr; ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkResetCommandBuffer failed with error " + itos(res) + "."); } res = vkBeginCommandBuffer(command_buffer, &cmdbuf_begin); if (res) { memdelete_arr(draw_list); - draw_list = NULL; + draw_list = nullptr; ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkBeginCommandBuffer failed with error " + itos(res) + "."); } @@ -5658,30 +5658,30 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p RenderingDeviceVulkan::DrawList *RenderingDeviceVulkan::_get_draw_list_ptr(DrawListID p_id) { if (p_id < 0) { - return NULL; + return nullptr; } if (!draw_list) { - return NULL; + return nullptr; } else if (p_id == ID_TYPE_DRAW_LIST) { if (draw_list_split) { - return NULL; + return nullptr; } return draw_list; } else if (p_id >> DrawListID(ID_BASE_SHIFT) == ID_TYPE_SPLIT_DRAW_LIST) { if (!draw_list_split) { - return NULL; + return nullptr; } uint64_t index = p_id & ((DrawListID(1) << DrawListID(ID_BASE_SHIFT)) - 1); //mask if (index >= draw_list_count) { - return NULL; + return nullptr; } return &draw_list[index]; } else { - return NULL; + return nullptr; } } @@ -5927,7 +5927,7 @@ void RenderingDeviceVulkan::draw_list_draw(DrawListID p_list, bool p_use_indices #endif if (!dl->state.sets[i].bound) { //All good, see if this requires re-binding - vkCmdBindDescriptorSets(dl->command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, dl->state.pipeline_layout, i, 1, &dl->state.sets[i].descriptor_set, 0, NULL); + vkCmdBindDescriptorSets(dl->command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, dl->state.pipeline_layout, i, 1, &dl->state.sets[i].descriptor_set, 0, nullptr); dl->state.sets[i].bound = true; } } @@ -6046,13 +6046,13 @@ void RenderingDeviceVulkan::draw_list_end() { vkCmdExecuteCommands(frames[frame].draw_command_buffer, draw_list_count, command_buffers); vkCmdEndRenderPass(frames[frame].draw_command_buffer); memdelete_arr(draw_list); - draw_list = NULL; + draw_list = nullptr; } else { //just end the list vkCmdEndRenderPass(draw_list->command_buffer); memdelete(draw_list); - draw_list = NULL; + draw_list = nullptr; } for (int i = 0; i < draw_list_bound_textures.size(); i++) { @@ -6085,8 +6085,8 @@ void RenderingDeviceVulkan::draw_list_end() { RenderingDevice::ComputeListID RenderingDeviceVulkan::compute_list_begin() { - ERR_FAIL_COND_V_MSG(draw_list != NULL, INVALID_ID, "Only one draw list can be active at the same time."); - ERR_FAIL_COND_V_MSG(compute_list != NULL, INVALID_ID, "Only one draw/compute list can be active at the same time."); + ERR_FAIL_COND_V_MSG(draw_list != nullptr, INVALID_ID, "Only one draw list can be active at the same time."); + ERR_FAIL_COND_V_MSG(compute_list != nullptr, INVALID_ID, "Only one draw/compute list can be active at the same time."); compute_list = memnew(ComputeList); compute_list->command_buffer = frames[frame].draw_command_buffer; @@ -6189,7 +6189,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.oldLayout = textures_to_sampled[i]->layout; @@ -6204,7 +6204,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, image_memory_barrier.subresourceRange.baseArrayLayer = 0; image_memory_barrier.subresourceRange.layerCount = textures_to_sampled[i]->layers; - vkCmdPipelineBarrier(cl->command_buffer, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(cl->command_buffer, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); textures_to_sampled[i]->layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; @@ -6220,7 +6220,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.oldLayout = textures_to_storage[i]->layout; @@ -6235,7 +6235,7 @@ void RenderingDeviceVulkan::compute_list_bind_uniform_set(ComputeListID p_list, image_memory_barrier.subresourceRange.baseArrayLayer = 0; image_memory_barrier.subresourceRange.layerCount = textures_to_storage[i]->layers; - vkCmdPipelineBarrier(cl->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(cl->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); textures_to_storage[i]->layout = VK_IMAGE_LAYOUT_GENERAL; @@ -6329,7 +6329,7 @@ void RenderingDeviceVulkan::compute_list_dispatch(ComputeListID p_list, uint32_t #endif if (!cl->state.sets[i].bound) { //All good, see if this requires re-binding - vkCmdBindDescriptorSets(cl->command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, cl->state.pipeline_layout, i, 1, &cl->state.sets[i].descriptor_set, 0, NULL); + vkCmdBindDescriptorSets(cl->command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, cl->state.pipeline_layout, i, 1, &cl->state.sets[i].descriptor_set, 0, nullptr); cl->state.sets[i].bound = true; } } @@ -6352,7 +6352,7 @@ void RenderingDeviceVulkan::compute_list_end() { VkImageMemoryBarrier image_memory_barrier; image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + image_memory_barrier.pNext = nullptr; image_memory_barrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; image_memory_barrier.oldLayout = E->get()->layout; @@ -6367,13 +6367,13 @@ void RenderingDeviceVulkan::compute_list_end() { image_memory_barrier.subresourceRange.baseArrayLayer = 0; image_memory_barrier.subresourceRange.layerCount = E->get()->layers; - vkCmdPipelineBarrier(compute_list->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, &image_memory_barrier); + vkCmdPipelineBarrier(compute_list->command_buffer, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); E->get()->layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } memdelete(compute_list); - compute_list = NULL; + compute_list = nullptr; #ifdef FORCE_FULL_BARRIER _full_barrier(true); #else @@ -6389,7 +6389,7 @@ void RenderingDeviceVulkan::draw_list_render_secondary_to_framebuffer(ID p_frame VkRenderPassBeginInfo render_pass_begin; render_pass_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - render_pass_begin.pNext = NULL; + render_pass_begin.pNext = nullptr; render_pass_begin.renderPass = context->get_render_pass(); render_pass_begin.framebuffer = context->get_frame_framebuffer(frame); @@ -6547,9 +6547,9 @@ void RenderingDeviceVulkan::swap_buffers() { { VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - cmdbuf_begin.pNext = NULL; + cmdbuf_begin.pNext = nullptr; cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - cmdbuf_begin.pInheritanceInfo = NULL; + cmdbuf_begin.pInheritanceInfo = nullptr; VkResult err = vkResetCommandBuffer(frames[frame].setup_command_buffer, 0); ERR_FAIL_COND_MSG(err, "vkResetCommandBuffer failed with error " + itos(err) + "."); @@ -6588,7 +6588,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { while (frames[p_frame].render_pipelines_to_dispose_of.front()) { RenderPipeline *pipeline = &frames[p_frame].render_pipelines_to_dispose_of.front()->get(); - vkDestroyPipeline(device, pipeline->pipeline, NULL); + vkDestroyPipeline(device, pipeline->pipeline, nullptr); frames[p_frame].render_pipelines_to_dispose_of.pop_front(); } @@ -6596,7 +6596,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { while (frames[p_frame].compute_pipelines_to_dispose_of.front()) { ComputePipeline *pipeline = &frames[p_frame].compute_pipelines_to_dispose_of.front()->get(); - vkDestroyPipeline(device, pipeline->pipeline, NULL); + vkDestroyPipeline(device, pipeline->pipeline, nullptr); frames[p_frame].compute_pipelines_to_dispose_of.pop_front(); } @@ -6615,7 +6615,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { while (frames[p_frame].buffer_views_to_dispose_of.front()) { VkBufferView buffer_view = frames[p_frame].buffer_views_to_dispose_of.front()->get(); - vkDestroyBufferView(device, buffer_view, NULL); + vkDestroyBufferView(device, buffer_view, nullptr); frames[p_frame].buffer_views_to_dispose_of.pop_front(); } @@ -6626,15 +6626,15 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { //descriptor set layout for each set for (int i = 0; i < shader->sets.size(); i++) { - vkDestroyDescriptorSetLayout(device, shader->sets[i].descriptor_set_layout, NULL); + vkDestroyDescriptorSetLayout(device, shader->sets[i].descriptor_set_layout, nullptr); } //pipeline layout - vkDestroyPipelineLayout(device, shader->pipeline_layout, NULL); + vkDestroyPipelineLayout(device, shader->pipeline_layout, nullptr); //shaders themselves for (int i = 0; i < shader->pipeline_stages.size(); i++) { - vkDestroyShaderModule(device, shader->pipeline_stages[i].module, NULL); + vkDestroyShaderModule(device, shader->pipeline_stages[i].module, nullptr); } frames[p_frame].shaders_to_dispose_of.pop_front(); @@ -6644,7 +6644,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { while (frames[p_frame].samplers_to_dispose_of.front()) { VkSampler sampler = frames[p_frame].samplers_to_dispose_of.front()->get(); - vkDestroySampler(device, sampler, NULL); + vkDestroySampler(device, sampler, nullptr); frames[p_frame].samplers_to_dispose_of.pop_front(); } @@ -6655,8 +6655,8 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { for (Map<Framebuffer::VersionKey, Framebuffer::Version>::Element *E = framebuffer->framebuffers.front(); E; E = E->next()) { //first framebuffer, then render pass because it depends on it - vkDestroyFramebuffer(device, E->get().framebuffer, NULL); - vkDestroyRenderPass(device, E->get().render_pass, NULL); + vkDestroyFramebuffer(device, E->get().framebuffer, nullptr); + vkDestroyRenderPass(device, E->get().render_pass, nullptr); } frames[p_frame].framebuffers_to_dispose_of.pop_front(); @@ -6669,7 +6669,7 @@ void RenderingDeviceVulkan::_free_pending_resources(int p_frame) { if (texture->bound) { WARN_PRINT("Deleted a texture while it was bound.."); } - vkDestroyImageView(device, texture->view, NULL); + vkDestroyImageView(device, texture->view, nullptr); if (texture->owner.is_null()) { //actually owns the image and the allocation too vmaDestroyImage(allocator, texture->image, texture->allocation); @@ -6708,9 +6708,9 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { if (p_current_frame) { VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - cmdbuf_begin.pNext = NULL; + cmdbuf_begin.pNext = nullptr; cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - cmdbuf_begin.pInheritanceInfo = NULL; + cmdbuf_begin.pInheritanceInfo = nullptr; VkResult err = vkBeginCommandBuffer(frames[frame].setup_command_buffer, &cmdbuf_begin); ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); @@ -6720,9 +6720,9 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { if (p_current_frame) { VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - cmdbuf_begin.pNext = NULL; + cmdbuf_begin.pNext = nullptr; cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - cmdbuf_begin.pInheritanceInfo = NULL; + cmdbuf_begin.pInheritanceInfo = nullptr; VkResult err = vkBeginCommandBuffer(frames[frame].draw_command_buffer, &cmdbuf_begin); ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); @@ -6757,11 +6757,11 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { { //create command pool, one per frame is recommended VkCommandPoolCreateInfo cmd_pool_info; cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - cmd_pool_info.pNext = NULL; + cmd_pool_info.pNext = nullptr; cmd_pool_info.queueFamilyIndex = p_context->get_graphics_queue(); cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; - VkResult res = vkCreateCommandPool(device, &cmd_pool_info, NULL, &frames[i].command_pool); + VkResult res = vkCreateCommandPool(device, &cmd_pool_info, nullptr, &frames[i].command_pool); ERR_FAIL_COND_MSG(res, "vkCreateCommandPool failed with error " + itos(res) + "."); } @@ -6770,7 +6770,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { VkCommandBufferAllocateInfo cmdbuf; //no command buffer exists, create it. cmdbuf.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - cmdbuf.pNext = NULL; + cmdbuf.pNext = nullptr; cmdbuf.commandPool = frames[i].command_pool; cmdbuf.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; cmdbuf.commandBufferCount = 1; @@ -6787,12 +6787,12 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { VkQueryPoolCreateInfo query_pool_create_info; query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; query_pool_create_info.flags = 0; - query_pool_create_info.pNext = NULL; + query_pool_create_info.pNext = nullptr; query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; query_pool_create_info.queryCount = max_timestamp_query_elements; query_pool_create_info.pipelineStatistics = 0; - vkCreateQueryPool(device, &query_pool_create_info, NULL, &frames[i].timestamp_pool); + vkCreateQueryPool(device, &query_pool_create_info, nullptr, &frames[i].timestamp_pool); frames[i].timestamp_names = memnew_arr(String, max_timestamp_query_elements); frames[i].timestamp_cpu_values = memnew_arr(uint64_t, max_timestamp_query_elements); @@ -6809,9 +6809,9 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { //setting up things can be done in the meantime until swap_buffers(), which is called before advance. VkCommandBufferBeginInfo cmdbuf_begin; cmdbuf_begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - cmdbuf_begin.pNext = NULL; + cmdbuf_begin.pNext = nullptr; cmdbuf_begin.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - cmdbuf_begin.pInheritanceInfo = NULL; + cmdbuf_begin.pInheritanceInfo = nullptr; VkResult err = vkBeginCommandBuffer(frames[0].setup_command_buffer, &cmdbuf_begin); ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); @@ -6853,11 +6853,11 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { //check to make sure DescriptorPoolKey is good static_assert(sizeof(uint64_t) * 3 >= UNIFORM_TYPE_MAX * sizeof(uint16_t)); - draw_list = NULL; + draw_list = nullptr; draw_list_count = 0; draw_list_split = false; - compute_list = NULL; + compute_list = nullptr; } template <class T> @@ -6880,7 +6880,7 @@ void RenderingDeviceVulkan::capture_timestamp(const String &p_name, bool p_sync_ VkMemoryBarrier memoryBarrier; memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; - memoryBarrier.pNext = NULL; + memoryBarrier.pNext = nullptr; memoryBarrier.srcAccessMask = VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | @@ -6912,7 +6912,7 @@ void RenderingDeviceVulkan::capture_timestamp(const String &p_name, bool p_sync_ VK_ACCESS_HOST_READ_BIT | VK_ACCESS_HOST_WRITE_BIT; - vkCmdPipelineBarrier(p_sync_to_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 1, &memoryBarrier, 0, NULL, 0, NULL); + vkCmdPipelineBarrier(p_sync_to_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 1, &memoryBarrier, 0, nullptr, 0, nullptr); } vkCmdWriteTimestamp(p_sync_to_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, frames[frame].timestamp_pool, frames[frame].timestamp_count); frames[frame].timestamp_names[frames[frame].timestamp_count] = p_name; @@ -7030,8 +7030,8 @@ void RenderingDeviceVulkan::finalize() { for (int i = 0; i < frame_count; i++) { int f = (frame + i) % frame_count; _free_pending_resources(f); - vkDestroyCommandPool(device, frames[i].command_pool, NULL); - vkDestroyQueryPool(device, frames[i].timestamp_pool, NULL); + vkDestroyCommandPool(device, frames[i].command_pool, nullptr); + vkDestroyQueryPool(device, frames[i].timestamp_pool, nullptr); memdelete_arr(frames[i].timestamp_names); memdelete_arr(frames[i].timestamp_cpu_values); memdelete_arr(frames[i].timestamp_result_names); @@ -7040,7 +7040,7 @@ void RenderingDeviceVulkan::finalize() { } for (int i = 0; i < split_draw_list_allocators.size(); i++) { - vkDestroyCommandPool(device, split_draw_list_allocators[i].command_pool, NULL); + vkDestroyCommandPool(device, split_draw_list_allocators[i].command_pool, nullptr); } memdelete_arr(frames); diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index 7f1697b2b5..208109bba3 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -34,7 +34,7 @@ #include "core/oa_hash_map.h" #include "core/os/thread_safe.h" #include "core/rid_owner.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rendering_device.h" #ifdef DEBUG_ENABLED #define _DEBUG @@ -78,7 +78,7 @@ class RenderingDeviceVulkan : public RenderingDevice { static void get_compressed_image_format_block_dimensions(DataFormat p_format, uint32_t &r_w, uint32_t &r_h); uint32_t get_compressed_image_format_block_byte_size(DataFormat p_format); static uint32_t get_compressed_image_format_pixel_rshift(DataFormat p_format); - static uint32_t get_image_format_required_size(DataFormat p_format, uint32_t p_width, uint32_t p_height, uint32_t p_depth, uint32_t p_mipmaps, uint32_t *r_blockw = NULL, uint32_t *r_blockh = NULL, uint32_t *r_depth = NULL); + static uint32_t get_image_format_required_size(DataFormat p_format, uint32_t p_width, uint32_t p_height, uint32_t p_depth, uint32_t p_mipmaps, uint32_t *r_blockw = nullptr, uint32_t *r_blockh = nullptr, uint32_t *r_depth = nullptr); static uint32_t get_image_required_mipmaps(uint32_t p_width, uint32_t p_height, uint32_t p_depth); static bool format_has_stencil(DataFormat p_format); @@ -207,8 +207,8 @@ class RenderingDeviceVulkan : public RenderingDevice { VkDescriptorBufferInfo buffer_info; //used for binding Buffer() { size = 0; - buffer = NULL; - allocation = NULL; + buffer = nullptr; + allocation = nullptr; } }; @@ -260,7 +260,7 @@ class RenderingDeviceVulkan : public RenderingDevice { } }; - VkRenderPass _render_pass_create(const Vector<AttachmentFormat> &p_format, InitialAction p_initial_action, FinalAction p_final_action, InitialAction p_initial_depth_action, FinalAction p_final_depthcolor_action, int *r_color_attachment_count = NULL); + VkRenderPass _render_pass_create(const Vector<AttachmentFormat> &p_format, InitialAction p_initial_action, FinalAction p_final_action, InitialAction p_initial_depth_action, FinalAction p_final_depthcolor_action, int *r_color_attachment_count = nullptr); // This is a cache and it's never freed, it ensures // IDs for a given format are always unique. diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index 494c64ff55..d3666bca52 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -51,20 +51,20 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanContext::_debug_messenger_callback( void *pUserData) { // This error needs to be ignored because the AMD allocator will mix up memory types on IGP processors. - if (strstr(pCallbackData->pMessage, "Mapping an image with layout") != NULL && - strstr(pCallbackData->pMessage, "can result in undefined behavior if this memory is used by the device") != NULL) { + if (strstr(pCallbackData->pMessage, "Mapping an image with layout") != nullptr && + strstr(pCallbackData->pMessage, "can result in undefined behavior if this memory is used by the device") != nullptr) { return VK_FALSE; } // This needs to be ignored because Validator is wrong here. - if (strstr(pCallbackData->pMessage, "SPIR-V module not valid: Pointer operand") != NULL && - strstr(pCallbackData->pMessage, "must be a memory object") != NULL) { + if (strstr(pCallbackData->pMessage, "SPIR-V module not valid: Pointer operand") != nullptr && + strstr(pCallbackData->pMessage, "must be a memory object") != nullptr) { return VK_FALSE; } // Workaround for Vulkan-Loader usability bug: https://github.com/KhronosGroup/Vulkan-Loader/issues/262. - if (strstr(pCallbackData->pMessage, "wrong ELF class: ELFCLASS32") != NULL) { + if (strstr(pCallbackData->pMessage, "wrong ELF class: ELFCLASS32") != nullptr) { return VK_FALSE; } - if (pCallbackData->pMessageIdName && strstr(pCallbackData->pMessageIdName, "UNASSIGNED-CoreValidation-DrawState-ClearCmdBeforeDraw") != NULL) { + if (pCallbackData->pMessageIdName && strstr(pCallbackData->pMessageIdName, "UNASSIGNED-CoreValidation-DrawState-ClearCmdBeforeDraw") != nullptr) { return VK_FALSE; } @@ -92,7 +92,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanContext::_debug_messenger_callback( "\n\t\tObject[" + String::num_int64(object) + "]" + " - " + string_VkObjectType(pCallbackData->pObjects[object].objectType) + ", Handle " + String::num_int64(pCallbackData->pObjects[object].objectHandle); - if (NULL != pCallbackData->pObjects[object].pObjectName && strlen(pCallbackData->pObjects[object].pObjectName) > 0) { + if (nullptr != pCallbackData->pObjects[object].pObjectName && strlen(pCallbackData->pObjects[object].pObjectName) > 0) { objects_string += ", Name \"" + String(pCallbackData->pObjects[object].pObjectName) + "\""; } } @@ -172,7 +172,7 @@ Error VulkanContext::_create_validation_layers() { "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_core_validation", "VK_LAYER_GOOGLE_unique_objects" }; VkBool32 validation_found = 0; - err = vkEnumerateInstanceLayerProperties(&instance_layer_count, NULL); + err = vkEnumerateInstanceLayerProperties(&instance_layer_count, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); const char **instance_validation_layers = instance_validation_layers_alt1; if (instance_layer_count > 0) { @@ -222,12 +222,12 @@ Error VulkanContext::_initialize_extensions() { VkBool32 platformSurfaceExtFound = 0; memset(extension_names, 0, sizeof(extension_names)); - err = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL); + err = vkEnumerateInstanceExtensionProperties(nullptr, &instance_extension_count, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); if (instance_extension_count > 0) { VkExtensionProperties *instance_extensions = (VkExtensionProperties *)malloc(sizeof(VkExtensionProperties) * instance_extension_count); - err = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, instance_extensions); + err = vkEnumerateInstanceExtensionProperties(nullptr, &instance_extension_count, instance_extensions); if (err) { free(instance_extensions); ERR_FAIL_V(ERR_CANT_CREATE); @@ -286,7 +286,7 @@ Error VulkanContext::_create_physical_device() { CharString namecs = name.utf8(); const VkApplicationInfo app = { /*sType*/ VK_STRUCTURE_TYPE_APPLICATION_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*pApplicationName*/ cs.get_data(), /*applicationVersion*/ 0, /*pEngineName*/ namecs.get_data(), @@ -295,7 +295,7 @@ Error VulkanContext::_create_physical_device() { }; VkInstanceCreateInfo inst_info = { /*sType*/ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*pApplicationInfo*/ &app, /*enabledLayerCount*/ enabled_layer_count, @@ -313,7 +313,7 @@ Error VulkanContext::_create_physical_device() { if (use_validation_layers) { // VK_EXT_debug_utils style dbg_messenger_create_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT; - dbg_messenger_create_info.pNext = NULL; + dbg_messenger_create_info.pNext = nullptr; dbg_messenger_create_info.flags = 0; dbg_messenger_create_info.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT; @@ -327,7 +327,7 @@ Error VulkanContext::_create_physical_device() { uint32_t gpu_count; - VkResult err = vkCreateInstance(&inst_info, NULL, &inst); + VkResult err = vkCreateInstance(&inst_info, nullptr, &inst); ERR_FAIL_COND_V_MSG(err == VK_ERROR_INCOMPATIBLE_DRIVER, ERR_CANT_CREATE, "Cannot find a compatible Vulkan installable client driver (ICD).\n\n" "vkCreateInstance Failure"); @@ -342,7 +342,7 @@ Error VulkanContext::_create_physical_device() { "vkCreateInstance Failure"); /* Make initial call to query gpu_count, then second call for gpu info*/ - err = vkEnumeratePhysicalDevices(inst, &gpu_count, NULL); + err = vkEnumeratePhysicalDevices(inst, &gpu_count, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); ERR_FAIL_COND_V_MSG(gpu_count == 0, ERR_CANT_CREATE, @@ -366,12 +366,12 @@ Error VulkanContext::_create_physical_device() { enabled_extension_count = 0; memset(extension_names, 0, sizeof(extension_names)); - err = vkEnumerateDeviceExtensionProperties(gpu, NULL, &device_extension_count, NULL); + err = vkEnumerateDeviceExtensionProperties(gpu, nullptr, &device_extension_count, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); if (device_extension_count > 0) { VkExtensionProperties *device_extensions = (VkExtensionProperties *)malloc(sizeof(VkExtensionProperties) * device_extension_count); - err = vkEnumerateDeviceExtensionProperties(gpu, NULL, &device_extension_count, device_extensions); + err = vkEnumerateDeviceExtensionProperties(gpu, nullptr, &device_extension_count, device_extensions); if (err) { free(device_extensions); ERR_FAIL_V(ERR_CANT_CREATE); @@ -449,16 +449,16 @@ Error VulkanContext::_create_physical_device() { (PFN_vkCmdInsertDebugUtilsLabelEXT)vkGetInstanceProcAddr(inst, "vkCmdInsertDebugUtilsLabelEXT"); SetDebugUtilsObjectNameEXT = (PFN_vkSetDebugUtilsObjectNameEXT)vkGetInstanceProcAddr(inst, "vkSetDebugUtilsObjectNameEXT"); - if (NULL == CreateDebugUtilsMessengerEXT || NULL == DestroyDebugUtilsMessengerEXT || - NULL == SubmitDebugUtilsMessageEXT || NULL == CmdBeginDebugUtilsLabelEXT || - NULL == CmdEndDebugUtilsLabelEXT || NULL == CmdInsertDebugUtilsLabelEXT || - NULL == SetDebugUtilsObjectNameEXT) { + if (nullptr == CreateDebugUtilsMessengerEXT || nullptr == DestroyDebugUtilsMessengerEXT || + nullptr == SubmitDebugUtilsMessageEXT || nullptr == CmdBeginDebugUtilsLabelEXT || + nullptr == CmdEndDebugUtilsLabelEXT || nullptr == CmdInsertDebugUtilsLabelEXT || + nullptr == SetDebugUtilsObjectNameEXT) { ERR_FAIL_V_MSG(ERR_CANT_CREATE, "GetProcAddr: Failed to init VK_EXT_debug_utils\n" "GetProcAddr: Failure"); } - err = CreateDebugUtilsMessengerEXT(inst, &dbg_messenger_create_info, NULL, &dbg_messenger); + err = CreateDebugUtilsMessengerEXT(inst, &dbg_messenger_create_info, nullptr, &dbg_messenger); switch (err) { case VK_SUCCESS: break; @@ -478,7 +478,7 @@ Error VulkanContext::_create_physical_device() { vkGetPhysicalDeviceProperties(gpu, &gpu_props); /* Call with NULL data to get count */ - vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queue_family_count, NULL); + vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queue_family_count, nullptr); ERR_FAIL_COND_V(queue_family_count == 0, ERR_CANT_CREATE); queue_props = (VkQueueFamilyProperties *)malloc(queue_family_count * sizeof(VkQueueFamilyProperties)); @@ -492,7 +492,7 @@ Error VulkanContext::_create_physical_device() { #define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \ { \ fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \ - ERR_FAIL_COND_V_MSG(fp##entrypoint == NULL, ERR_CANT_CREATE, \ + ERR_FAIL_COND_V_MSG(fp##entrypoint == nullptr, ERR_CANT_CREATE, \ "vkGetInstanceProcAddr failed to find vk" #entrypoint); \ } @@ -511,7 +511,7 @@ Error VulkanContext::_create_device() { float queue_priorities[1] = { 0.0 }; VkDeviceQueueCreateInfo queues[2]; queues[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - queues[0].pNext = NULL; + queues[0].pNext = nullptr; queues[0].queueFamilyIndex = graphics_queue_family_index; queues[0].queueCount = 1; queues[0].pQueuePriorities = queue_priorities; @@ -519,12 +519,12 @@ Error VulkanContext::_create_device() { VkDeviceCreateInfo sdevice = { /*sType*/ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*queueCreateInfoCount*/ 1, /*pQueueCreateInfos*/ queues, /*enabledLayerCount*/ 0, - /*ppEnabledLayerNames*/ NULL, + /*ppEnabledLayerNames*/ nullptr, /*enabledExtensionCount*/ enabled_extension_count, /*ppEnabledExtensionNames*/ (const char *const *)extension_names, /*pEnabledFeatures*/ &physical_device_features, // If specific features are required, pass them in here @@ -532,14 +532,14 @@ Error VulkanContext::_create_device() { }; if (separate_present_queue) { queues[1].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - queues[1].pNext = NULL; + queues[1].pNext = nullptr; queues[1].queueFamilyIndex = present_queue_family_index; queues[1].queueCount = 1; queues[1].pQueuePriorities = queue_priorities; queues[1].flags = 0; sdevice.queueCreateInfoCount = 2; } - err = vkCreateDevice(gpu, &sdevice, NULL, &device); + err = vkCreateDevice(gpu, &sdevice, nullptr, &device); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); return OK; } @@ -593,12 +593,12 @@ Error VulkanContext::_initialize_queues(VkSurfaceKHR surface) { _create_device(); - static PFN_vkGetDeviceProcAddr g_gdpa = NULL; + static PFN_vkGetDeviceProcAddr g_gdpa = nullptr; #define GET_DEVICE_PROC_ADDR(dev, entrypoint) \ { \ if (!g_gdpa) g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(inst, "vkGetDeviceProcAddr"); \ fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \ - ERR_FAIL_COND_V_MSG(fp##entrypoint == NULL, ERR_CANT_CREATE, \ + ERR_FAIL_COND_V_MSG(fp##entrypoint == nullptr, ERR_CANT_CREATE, \ "vkGetDeviceProcAddr failed to find vk" #entrypoint); \ } @@ -622,7 +622,7 @@ Error VulkanContext::_initialize_queues(VkSurfaceKHR surface) { // Get the list of VkFormat's that are supported: uint32_t formatCount; - VkResult err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &formatCount, NULL); + VkResult err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &formatCount, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); VkSurfaceFormatKHR *surfFormats = (VkSurfaceFormatKHR *)malloc(formatCount * sizeof(VkSurfaceFormatKHR)); err = fpGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &formatCount, surfFormats); @@ -662,7 +662,7 @@ Error VulkanContext::_create_semaphores() { // rendering and waiting for drawing to be complete before presenting VkSemaphoreCreateInfo semaphoreCreateInfo = { /*sType*/ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, }; @@ -670,21 +670,21 @@ Error VulkanContext::_create_semaphores() { // ahead of the image presents VkFenceCreateInfo fence_ci = { /*sType*/ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ VK_FENCE_CREATE_SIGNALED_BIT }; for (uint32_t i = 0; i < FRAME_LAG; i++) { - err = vkCreateFence(device, &fence_ci, NULL, &fences[i]); + err = vkCreateFence(device, &fence_ci, nullptr, &fences[i]); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); - err = vkCreateSemaphore(device, &semaphoreCreateInfo, NULL, &image_acquired_semaphores[i]); + err = vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &image_acquired_semaphores[i]); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); - err = vkCreateSemaphore(device, &semaphoreCreateInfo, NULL, &draw_complete_semaphores[i]); + err = vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &draw_complete_semaphores[i]); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); if (separate_present_queue) { - err = vkCreateSemaphore(device, &semaphoreCreateInfo, NULL, &image_ownership_semaphores[i]); + err = vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &image_ownership_semaphores[i]); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); } } @@ -753,7 +753,7 @@ VkFramebuffer VulkanContext::window_get_framebuffer(DisplayServer::WindowID p_wi void VulkanContext::window_destroy(DisplayServer::WindowID p_window_id) { ERR_FAIL_COND(!windows.has(p_window_id)); _clean_up_swap_chain(&windows[p_window_id]); - vkDestroySurfaceKHR(inst, windows[p_window_id].surface, NULL); + vkDestroySurfaceKHR(inst, windows[p_window_id].surface, nullptr); windows.erase(p_window_id); } @@ -765,20 +765,20 @@ Error VulkanContext::_clean_up_swap_chain(Window *window) { vkDeviceWaitIdle(device); //this destroys images associated it seems - fpDestroySwapchainKHR(device, window->swapchain, NULL); + fpDestroySwapchainKHR(device, window->swapchain, nullptr); window->swapchain = VK_NULL_HANDLE; - vkDestroyRenderPass(device, window->render_pass, NULL); + vkDestroyRenderPass(device, window->render_pass, nullptr); if (window->swapchain_image_resources) { for (uint32_t i = 0; i < swapchainImageCount; i++) { - vkDestroyImageView(device, window->swapchain_image_resources[i].view, NULL); - vkDestroyFramebuffer(device, window->swapchain_image_resources[i].framebuffer, NULL); + vkDestroyImageView(device, window->swapchain_image_resources[i].view, nullptr); + vkDestroyFramebuffer(device, window->swapchain_image_resources[i].framebuffer, nullptr); } free(window->swapchain_image_resources); - window->swapchain_image_resources = NULL; + window->swapchain_image_resources = nullptr; } if (separate_present_queue) { - vkDestroyCommandPool(device, window->present_cmd_pool, NULL); + vkDestroyCommandPool(device, window->present_cmd_pool, nullptr); } return OK; } @@ -796,7 +796,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { ERR_FAIL_COND_V(err, ERR_CANT_CREATE); uint32_t presentModeCount; - err = fpGetPhysicalDeviceSurfacePresentModesKHR(gpu, window->surface, &presentModeCount, NULL); + err = fpGetPhysicalDeviceSurfacePresentModesKHR(gpu, window->surface, &presentModeCount, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); VkPresentModeKHR *presentModes = (VkPresentModeKHR *)malloc(presentModeCount * sizeof(VkPresentModeKHR)); ERR_FAIL_COND_V(!presentModes, ERR_CANT_CREATE); @@ -918,7 +918,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { VkSwapchainCreateInfoKHR swapchain_ci = { /*sType*/ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*surface*/ window->surface, /*minImageCount*/ desiredNumOfSwapchainImages, @@ -932,19 +932,19 @@ Error VulkanContext::_update_swap_chain(Window *window) { /*imageUsage*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, /*imageSharingMode*/ VK_SHARING_MODE_EXCLUSIVE, /*queueFamilyIndexCount*/ 0, - /*pQueueFamilyIndices*/ NULL, + /*pQueueFamilyIndices*/ nullptr, /*preTransform*/ (VkSurfaceTransformFlagBitsKHR)preTransform, /*compositeAlpha*/ compositeAlpha, /*presentMode*/ swapchainPresentMode, /*clipped*/ true, - /*oldSwapchain*/ NULL, + /*oldSwapchain*/ nullptr, }; - err = fpCreateSwapchainKHR(device, &swapchain_ci, NULL, &window->swapchain); + err = fpCreateSwapchainKHR(device, &swapchain_ci, nullptr, &window->swapchain); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); uint32_t sp_image_count; - err = fpGetSwapchainImagesKHR(device, window->swapchain, &sp_image_count, NULL); + err = fpGetSwapchainImagesKHR(device, window->swapchain, &sp_image_count, nullptr); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); if (swapchainImageCount == 0) { @@ -972,7 +972,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { for (uint32_t i = 0; i < swapchainImageCount; i++) { VkImageViewCreateInfo color_image_view = { /*sType*/ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*image*/ swapchainImages[i], /*viewType*/ VK_IMAGE_VIEW_TYPE_2D, @@ -994,7 +994,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { color_image_view.image = window->swapchain_image_resources[i].image; - err = vkCreateImageView(device, &color_image_view, NULL, &window->swapchain_image_resources[i].view); + err = vkCreateImageView(device, &color_image_view, nullptr, &window->swapchain_image_resources[i].view); if (err) { free(swapchainImages); ERR_FAIL_V(ERR_CANT_CREATE); @@ -1028,33 +1028,33 @@ Error VulkanContext::_update_swap_chain(Window *window) { /*flags*/ 0, /*pipelineBindPoint*/ VK_PIPELINE_BIND_POINT_GRAPHICS, /*inputAttachmentCount*/ 0, - /*pInputAttachments*/ NULL, + /*pInputAttachments*/ nullptr, /*colorAttachmentCount*/ 1, /*pColorAttachments*/ &color_reference, - /*pResolveAttachments*/ NULL, - /*pDepthStencilAttachment*/ NULL, + /*pResolveAttachments*/ nullptr, + /*pDepthStencilAttachment*/ nullptr, /*preserveAttachmentCount*/ 0, - /*pPreserveAttachments*/ NULL, + /*pPreserveAttachments*/ nullptr, }; const VkRenderPassCreateInfo rp_info = { /*sTyp*/ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*attachmentCount*/ 1, /*pAttachments*/ &attachment, /*subpassCount*/ 1, /*pSubpasses*/ &subpass, /*dependencyCount*/ 0, - /*pDependencies*/ NULL, + /*pDependencies*/ nullptr, }; - err = vkCreateRenderPass(device, &rp_info, NULL, &window->render_pass); + err = vkCreateRenderPass(device, &rp_info, nullptr, &window->render_pass); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); for (uint32_t i = 0; i < swapchainImageCount; i++) { const VkFramebufferCreateInfo fb_info = { /*sType*/ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*renderPass*/ window->render_pass, /*attachmentCount*/ 1, @@ -1064,7 +1064,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { /*layers*/ 1, }; - err = vkCreateFramebuffer(device, &fb_info, NULL, &window->swapchain_image_resources[i].framebuffer); + err = vkCreateFramebuffer(device, &fb_info, nullptr, &window->swapchain_image_resources[i].framebuffer); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); } } @@ -1074,15 +1074,15 @@ Error VulkanContext::_update_swap_chain(Window *window) { if (separate_present_queue) { const VkCommandPoolCreateInfo present_cmd_pool_info = { /*sType*/ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ 0, /*queueFamilyIndex*/ present_queue_family_index, }; - err = vkCreateCommandPool(device, &present_cmd_pool_info, NULL, &window->present_cmd_pool); + err = vkCreateCommandPool(device, &present_cmd_pool_info, nullptr, &window->present_cmd_pool); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); const VkCommandBufferAllocateInfo present_cmd_info = { /*sType*/ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*commandPool*/ window->present_cmd_pool, /*level*/ VK_COMMAND_BUFFER_LEVEL_PRIMARY, /*commandBufferCount*/ 1, @@ -1094,16 +1094,16 @@ Error VulkanContext::_update_swap_chain(Window *window) { const VkCommandBufferBeginInfo cmd_buf_info = { /*sType*/ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*flags*/ VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, - /*pInheritanceInfo*/ NULL, + /*pInheritanceInfo*/ nullptr, }; err = vkBeginCommandBuffer(window->swapchain_image_resources[i].graphics_to_present_cmd, &cmd_buf_info); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); VkImageMemoryBarrier image_ownership_barrier = { /*sType*/ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*srcAccessMask*/ 0, /*dstAccessMask*/ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, /*oldLayout*/ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, @@ -1115,7 +1115,7 @@ Error VulkanContext::_update_swap_chain(Window *window) { }; vkCmdPipelineBarrier(window->swapchain_image_resources[i].graphics_to_present_cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, NULL, 0, NULL, 1, &image_ownership_barrier); + VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_ownership_barrier); err = vkEndCommandBuffer(window->swapchain_image_resources[i].graphics_to_present_cmd); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); } @@ -1163,16 +1163,16 @@ void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) { //use a fence to wait for everything done VkSubmitInfo submit_info; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - submit_info.pNext = NULL; - submit_info.pWaitDstStageMask = NULL; + submit_info.pNext = nullptr; + submit_info.pWaitDstStageMask = nullptr; submit_info.waitSemaphoreCount = 0; - submit_info.pWaitSemaphores = NULL; + submit_info.pWaitSemaphores = nullptr; submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = command_buffer_queue.ptr(); submit_info.signalSemaphoreCount = 0; - submit_info.pSignalSemaphores = NULL; + submit_info.pSignalSemaphores = nullptr; VkResult err = vkQueueSubmit(graphics_queue, 1, &submit_info, VK_NULL_HANDLE); - command_buffer_queue.write[0] = NULL; + command_buffer_queue.write[0] = nullptr; ERR_FAIL_COND(err); vkDeviceWaitIdle(device); } @@ -1183,14 +1183,14 @@ void VulkanContext::flush(bool p_flush_setup, bool p_flush_pending) { VkSubmitInfo submit_info; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - submit_info.pNext = NULL; - submit_info.pWaitDstStageMask = NULL; + submit_info.pNext = nullptr; + submit_info.pWaitDstStageMask = nullptr; submit_info.waitSemaphoreCount = 0; - submit_info.pWaitSemaphores = NULL; + submit_info.pWaitSemaphores = nullptr; submit_info.commandBufferCount = command_buffer_count - 1; submit_info.pCommandBuffers = command_buffer_queue.ptr() + 1; submit_info.signalSemaphoreCount = 0; - submit_info.pSignalSemaphores = NULL; + submit_info.pSignalSemaphores = nullptr; VkResult err = vkQueueSubmit(graphics_queue, 1, &submit_info, VK_NULL_HANDLE); ERR_FAIL_COND(err); vkDeviceWaitIdle(device); @@ -1274,10 +1274,10 @@ Error VulkanContext::swap_buffers() { // engine has fully released ownership to the application, and it is // okay to render to the image. - const VkCommandBuffer *commands_ptr = NULL; + const VkCommandBuffer *commands_ptr = nullptr; uint32_t commands_to_submit = 0; - if (command_buffer_queue[0] == NULL) { + if (command_buffer_queue[0] == nullptr) { //no setup command, but commands to submit, submit from the first and skip command if (command_buffer_count > 1) { commands_ptr = command_buffer_queue.ptr() + 1; @@ -1291,7 +1291,7 @@ Error VulkanContext::swap_buffers() { VkPipelineStageFlags pipe_stage_flags; VkSubmitInfo submit_info; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - submit_info.pNext = NULL; + submit_info.pNext = nullptr; submit_info.pWaitDstStageMask = &pipe_stage_flags; pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; submit_info.waitSemaphoreCount = 1; @@ -1303,7 +1303,7 @@ Error VulkanContext::swap_buffers() { err = vkQueueSubmit(graphics_queue, 1, &submit_info, fences[frame_index]); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); - command_buffer_queue.write[0] = NULL; + command_buffer_queue.write[0] = nullptr; command_buffer_count = 1; if (separate_present_queue) { @@ -1339,13 +1339,13 @@ Error VulkanContext::swap_buffers() { // otherwise wait for draw complete VkPresentInfoKHR present = { /*sType*/ VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, - /*pNext*/ NULL, + /*pNext*/ nullptr, /*waitSemaphoreCount*/ 1, /*pWaitSemaphores*/ (separate_present_queue) ? &image_ownership_semaphores[frame_index] : &draw_complete_semaphores[frame_index], /*swapchainCount*/ 0, - /*pSwapchain*/ NULL, - /*pImageIndices*/ NULL, - /*pResults*/ NULL, + /*pSwapchain*/ nullptr, + /*pImageIndices*/ nullptr, + /*pResults*/ nullptr, }; VkSwapchainKHR *pSwapchains = (VkSwapchainKHR *)alloca(sizeof(VkSwapchainKHR *) * windows.size()); @@ -1483,15 +1483,15 @@ VkPhysicalDeviceLimits VulkanContext::get_device_limits() const { } VulkanContext::VulkanContext() { - queue_props = NULL; + queue_props = nullptr; command_buffer_count = 0; - instance_validation_layers = NULL; + instance_validation_layers = nullptr; use_validation_layers = true; VK_KHR_incremental_present_enabled = true; VK_GOOGLE_display_timing_enabled = true; command_buffer_queue.resize(1); //first one is the setup command always - command_buffer_queue.write[0] = NULL; + command_buffer_queue.write[0] = nullptr; command_buffer_count = 1; queues_initialized = false; diff --git a/drivers/wasapi/SCsub b/drivers/wasapi/SCsub index 4c24925192..4e1b5f2a36 100644 --- a/drivers/wasapi/SCsub +++ b/drivers/wasapi/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index fa78771993..ab2976f02c 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -54,10 +54,10 @@ const IID IID_IAudioClient = __uuidof(IAudioClient); const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient); const IID IID_IAudioCaptureClient = __uuidof(IAudioCaptureClient); -#define SAFE_RELEASE(memory) \ - if ((memory) != NULL) { \ - (memory)->Release(); \ - (memory) = NULL; \ +#define SAFE_RELEASE(memory) \ + if ((memory) != nullptr) { \ + (memory)->Release(); \ + (memory) = nullptr; \ } #define REFTIMES_PER_SEC 10000000 @@ -75,11 +75,11 @@ class CMMNotificationClient : public IMMNotificationClient { public: CMMNotificationClient() : _cRef(1), - _pEnumerator(NULL) {} + _pEnumerator(nullptr) {} virtual ~CMMNotificationClient() { - if ((_pEnumerator) != NULL) { + if ((_pEnumerator) != nullptr) { (_pEnumerator)->Release(); - (_pEnumerator) = NULL; + (_pEnumerator) = nullptr; } } @@ -103,7 +103,7 @@ public: AddRef(); *ppvInterface = (IMMNotificationClient *)this; } else { - *ppvInterface = NULL; + *ppvInterface = nullptr; return E_NOINTERFACE; } return S_OK; @@ -143,23 +143,23 @@ static CMMNotificationClient notif_client; Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_capture, bool reinit) { WAVEFORMATEX *pwfex; - IMMDeviceEnumerator *enumerator = NULL; - IMMDevice *device = NULL; + IMMDeviceEnumerator *enumerator = nullptr; + IMMDevice *device = nullptr; - CoInitialize(NULL); + CoInitialize(nullptr); - HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&enumerator); + HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&enumerator); ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN); if (p_device->device_name == "Default") { hr = enumerator->GetDefaultAudioEndpoint(p_capture ? eCapture : eRender, eConsole, &device); } else { - IMMDeviceCollection *devices = NULL; + IMMDeviceCollection *devices = nullptr; hr = enumerator->EnumAudioEndpoints(p_capture ? eCapture : eRender, DEVICE_STATE_ACTIVE, &devices); ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN); - LPWSTR strId = NULL; + LPWSTR strId = nullptr; bool found = false; UINT count = 0; @@ -167,12 +167,12 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN); for (ULONG i = 0; i < count && !found; i++) { - IMMDevice *tmp_device = NULL; + IMMDevice *tmp_device = nullptr; hr = devices->Item(i, &tmp_device); ERR_BREAK(hr != S_OK); - IPropertyStore *props = NULL; + IPropertyStore *props = nullptr; hr = tmp_device->OpenPropertyStore(STGM_READ, &props); ERR_BREAK(hr != S_OK); @@ -202,7 +202,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c CoTaskMemFree(strId); } - if (device == NULL) { + if (device == nullptr) { hr = enumerator->GetDefaultAudioEndpoint(p_capture ? eCapture : eRender, eConsole, &device); } } @@ -224,7 +224,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c ERR_PRINT("WASAPI: RegisterEndpointNotificationCallback error"); } - hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&p_device->audio_client); + hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, (void **)&p_device->audio_client); SAFE_RELEASE(device) if (reinit) { @@ -246,7 +246,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c print_verbose("WASAPI: wBitsPerSample = " + itos(pwfex->wBitsPerSample)); print_verbose("WASAPI: cbSize = " + itos(pwfex->cbSize)); - WAVEFORMATEX *closest = NULL; + WAVEFORMATEX *closest = nullptr; hr = p_device->audio_client->IsFormatSupported(AUDCLNT_SHAREMODE_SHARED, pwfex, &closest); if (hr == S_FALSE) { WARN_PRINT("WASAPI: Mix format is not supported by the Device"); @@ -295,7 +295,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_c pwfex->nAvgBytesPerSec = pwfex->nSamplesPerSec * pwfex->nChannels * (pwfex->wBitsPerSample / 8); } - hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, NULL); + hr = p_device->audio_client->Initialize(AUDCLNT_SHAREMODE_SHARED, streamflags, p_capture ? REFTIMES_PER_SEC : 0, 0, pwfex, nullptr); ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_CANT_OPEN, "WASAPI: Initialize failed with error 0x" + String::num_uint64(hr, 16) + "."); if (p_capture) { @@ -424,14 +424,14 @@ AudioDriver::SpeakerMode AudioDriverWASAPI::get_speaker_mode() const { Array AudioDriverWASAPI::audio_device_get_list(bool p_capture) { Array list; - IMMDeviceCollection *devices = NULL; - IMMDeviceEnumerator *enumerator = NULL; + IMMDeviceCollection *devices = nullptr; + IMMDeviceEnumerator *enumerator = nullptr; list.push_back(String("Default")); - CoInitialize(NULL); + CoInitialize(nullptr); - HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&enumerator); + HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&enumerator); ERR_FAIL_COND_V(hr != S_OK, Array()); hr = enumerator->EnumAudioEndpoints(p_capture ? eCapture : eRender, DEVICE_STATE_ACTIVE, &devices); @@ -442,12 +442,12 @@ Array AudioDriverWASAPI::audio_device_get_list(bool p_capture) { ERR_FAIL_COND_V(hr != S_OK, Array()); for (ULONG i = 0; i < count; i++) { - IMMDevice *device = NULL; + IMMDevice *device = nullptr; hr = devices->Item(i, &device); ERR_BREAK(hr != S_OK); - IPropertyStore *props = NULL; + IPropertyStore *props = nullptr; hr = device->OpenPropertyStore(STGM_READ, &props); ERR_BREAK(hr != S_OK); @@ -594,7 +594,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) { // Check how much frames are available on the WASAPI buffer UINT32 write_frames = MIN(ad->buffer_frames - cur_frames, avail_frames); if (write_frames > 0) { - BYTE *buffer = NULL; + BYTE *buffer = nullptr; hr = ad->audio_output.render_client->GetBuffer(write_frames, &buffer); if (hr == S_OK) { @@ -693,7 +693,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) { HRESULT hr = ad->audio_input.capture_client->GetNextPacketSize(&packet_length); if (hr == S_OK) { while (packet_length != 0) { - hr = ad->audio_input.capture_client->GetBuffer(&data, &num_frames_available, &flags, NULL, NULL); + hr = ad->audio_input.capture_client->GetBuffer(&data, &num_frames_available, &flags, nullptr, nullptr); ERR_BREAK(hr != S_OK); // fixme: Only works for floating point atm @@ -796,7 +796,7 @@ void AudioDriverWASAPI::finish() { Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } finish_capture_device(); @@ -855,7 +855,7 @@ String AudioDriverWASAPI::capture_get_device() { AudioDriverWASAPI::AudioDriverWASAPI() { - thread = NULL; + thread = nullptr; samples_in.clear(); diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h index 3ea61c6010..01a4666812 100644 --- a/drivers/wasapi/audio_driver_wasapi.h +++ b/drivers/wasapi/audio_driver_wasapi.h @@ -59,9 +59,9 @@ class AudioDriverWASAPI : public AudioDriver { String new_device; AudioDeviceWASAPI() : - audio_client(NULL), - render_client(NULL), - capture_client(NULL), + audio_client(nullptr), + render_client(nullptr), + capture_client(nullptr), active(false), format_tag(0), bits_per_sample(0), diff --git a/drivers/windows/SCsub b/drivers/windows/SCsub index 28b315ae66..91e1140b75 100644 --- a/drivers/windows/SCsub +++ b/drivers/windows/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index cf09f79832..a8618b05d7 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -67,7 +67,7 @@ Error DirAccessWindows::list_dir_begin() { _cishidden = false; list_dir_end(); - p->h = FindFirstFileExW((current_dir + "\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, NULL, 0); + p->h = FindFirstFileExW((current_dir + "\\*").c_str(), FindExInfoStandard, &p->fu, FindExSearchNameMatch, nullptr, 0); return (p->h == INVALID_HANDLE_VALUE) ? ERR_CANT_OPEN : OK; } @@ -175,7 +175,7 @@ Error DirAccessWindows::make_dir(String p_dir) { p_dir = "\\\\?\\" + p_dir; //done according to // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx - success = CreateDirectoryW(p_dir.c_str(), NULL); + success = CreateDirectoryW(p_dir.c_str(), nullptr); err = GetLastError(); if (success) { @@ -206,7 +206,13 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) { if (p_include_drive) { return current_dir; } else { - return current_dir.right(current_dir.find(":") + 1); + if (_get_root_string() == "") { + int p = current_dir.find(":"); + if (p != -1) { + return current_dir.right(p + 1); + } + } + return current_dir; } } @@ -269,11 +275,11 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) { if (p_path.to_lower() == p_new_path.to_lower()) { WCHAR tmpfile[MAX_PATH]; - if (!GetTempFileNameW(fix_path(get_current_dir()).c_str(), NULL, 0, tmpfile)) { + if (!GetTempFileNameW(fix_path(get_current_dir()).c_str(), nullptr, 0, tmpfile)) { return FAILED; } - if (!::ReplaceFileW(tmpfile, p_path.c_str(), NULL, 0, NULL, NULL)) { + if (!::ReplaceFileW(tmpfile, p_path.c_str(), nullptr, 0, nullptr, nullptr)) { DeleteFileW(tmpfile); return FAILED; } @@ -343,7 +349,7 @@ FileType DirAccessWindows::get_file_type(const String& p_file) const { size_t DirAccessWindows::get_space_left() { uint64_t bytes = 0; - if (!GetDiskFreeSpaceEx(NULL, (PULARGE_INTEGER)&bytes, NULL, NULL)) + if (!GetDiskFreeSpaceEx(nullptr, (PULARGE_INTEGER)&bytes, nullptr, nullptr)) return 0; //this is either 0 or a value in bytes. diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 01d2b8716f..69078b3326 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -117,7 +117,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) { errno_t errcode = _wfopen_s(&f, path.c_str(), mode_string); - if (f == NULL) { + if (f == nullptr) { switch (errcode) { case ENOENT: { last_error = ERR_FILE_NOT_FOUND; @@ -140,7 +140,7 @@ void FileAccessWindows::close() { return; fclose(f); - f = NULL; + f = nullptr; if (save_path != "") { @@ -164,7 +164,7 @@ void FileAccessWindows::close() { rename_error = _wrename((save_path + ".tmp").c_str(), save_path.c_str()) != 0; } else { //atomic replace for existing file - rename_error = !ReplaceFileW(save_path.c_str(), (save_path + ".tmp").c_str(), NULL, 2 | 4, NULL, NULL); + rename_error = !ReplaceFileW(save_path.c_str(), (save_path + ".tmp").c_str(), nullptr, 2 | 4, nullptr, nullptr); } if (rename_error) { attempts--; @@ -196,7 +196,7 @@ String FileAccessWindows::get_path_absolute() const { bool FileAccessWindows::is_open() const { - return (f != NULL); + return (f != nullptr); } void FileAccessWindows::seek(size_t p_position) { @@ -318,7 +318,7 @@ bool FileAccessWindows::file_exists(const String &p_name) { //printf("opening file %s\n", p_fname.c_str()); String filename = fix_path(p_name); _wfopen_s(&g, filename.c_str(), L"rb"); - if (g == NULL) { + if (g == nullptr) { return false; } else { @@ -354,7 +354,7 @@ Error FileAccessWindows::_set_unix_permissions(const String &p_file, uint32_t p_ } FileAccessWindows::FileAccessWindows() : - f(NULL), + f(nullptr), flags(0), prev_op(0), last_error(OK) { diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp index a7f34b64ca..aea2db2603 100644 --- a/drivers/windows/thread_windows.cpp +++ b/drivers/windows/thread_windows.cpp @@ -64,7 +64,7 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void ThreadWindows *tr = memnew(ThreadWindows); tr->callback = p_callback; tr->user = p_user; - tr->handle = CreateEvent(NULL, TRUE, FALSE, NULL); + tr->handle = CreateEvent(nullptr, TRUE, FALSE, nullptr); QueueUserWorkItem(thread_callback, tr, WT_EXECUTELONGFUNCTION); @@ -91,7 +91,7 @@ void ThreadWindows::make_default() { } ThreadWindows::ThreadWindows() : - handle(NULL) { + handle(nullptr) { } ThreadWindows::~ThreadWindows() { diff --git a/drivers/winmidi/SCsub b/drivers/winmidi/SCsub index 4c24925192..4e1b5f2a36 100644 --- a/drivers/winmidi/SCsub +++ b/drivers/winmidi/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") # Driver source files env.add_source_files(env.drivers_sources, "*.cpp") diff --git a/drivers/xaudio2/SCsub b/drivers/xaudio2/SCsub index de750525ab..6778ad281e 100644 --- a/drivers/xaudio2/SCsub +++ b/drivers/xaudio2/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") -env.Append(CPPDEFINES=['XAUDIO2_ENABLED']) -env.Append(LINKFLAGS=['xaudio2_8.lib']) +env.Append(CPPDEFINES=["XAUDIO2_ENABLED"]) +env.Append(LINKFLAGS=["xaudio2_8.lib"]) diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index 9c7cb4f0f3..120bfa2b36 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -43,7 +43,7 @@ Error AudioDriverXAudio2::init() { thread_exited = false; exit_thread = false; pcm_open = false; - samples_in = NULL; + samples_in = nullptr; mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE); // FIXME: speaker_mode seems unused in the Xaudio2 driver so far @@ -193,11 +193,11 @@ void AudioDriverXAudio2::finish() { mastering_voice->DestroyVoice(); memdelete(thread); - thread = NULL; + thread = nullptr; } AudioDriverXAudio2::AudioDriverXAudio2() : - thread(NULL), + thread(nullptr), current_buffer(0) { wave_format = { 0 }; for (int i = 0; i < AUDIO_BUFFERS; i++) { diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index 108891a288..eb4a6d6e95 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -50,7 +50,7 @@ class AudioDriverXAudio2 : public AudioDriver { HANDLE buffer_end_event; XAudio2DriverVoiceCallback() : - buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {} + buffer_end_event(CreateEvent(nullptr, FALSE, FALSE, nullptr)) {} void STDMETHODCALLTYPE OnBufferEnd(void *pBufferContext) { SetEvent(buffer_end_event); } diff --git a/editor/SCsub b/editor/SCsub index 61562d70d3..13ae85bbf0 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.editor_sources = [] @@ -16,24 +16,24 @@ def _make_doc_data_class_path(to_path): 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") - g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n"); + g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n") for c in sorted(env.doc_class_path): - g.write("\t{\"" + c + "\", \"" + env.doc_class_path[c] + "\"},\n") - g.write("\t{NULL, NULL}\n") + g.write('\t{"' + c + '", "' + env.doc_class_path[c] + '"},\n') + g.write("\t{nullptr, nullptr}\n") g.write("};\n") g.close() -if env['tools']: +if env["tools"]: # Register exporters reg_exporters_inc = '#include "register_exporters.h"\n' - reg_exporters = 'void register_exporters() {\n' + reg_exporters = "void register_exporters() {\n" for e in env.platform_exporters: env.add_source_files(env.editor_sources, "#platform/" + e + "/export/export.cpp") - reg_exporters += '\tregister_' + e + '_exporter();\n' + reg_exporters += "\tregister_" + e + "_exporter();\n" reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n' - reg_exporters += '}\n' + reg_exporters += "}\n" # NOTE: It is safe to generate this file here, since this is still executed serially with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f: @@ -50,12 +50,12 @@ if env['tools']: for d in doc_dirs: try: - for f in os.listdir(os.path.join(env.Dir('#').abspath, d)): + for f in os.listdir(os.path.join(env.Dir("#").abspath, d)): docs.append("#" + os.path.join(d, f)) except OSError: pass - _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor")) + _make_doc_data_class_path(os.path.join(env.Dir("#").abspath, "editor")) docs = sorted(docs) env.Depends("#editor/doc_data_compressed.gen.h", docs) @@ -63,32 +63,36 @@ if env['tools']: import glob - path = env.Dir('.').abspath + path = env.Dir(".").abspath # Editor translations tlist = glob.glob(path + "/translations/*.po") - env.Depends('#editor/editor_translations.gen.h', tlist) - env.CommandNoCache('#editor/editor_translations.gen.h', tlist, run_in_subprocess(editor_builders.make_editor_translations_header)) + env.Depends("#editor/editor_translations.gen.h", tlist) + env.CommandNoCache( + "#editor/editor_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_editor_translations_header) + ) # Documentation translations tlist = glob.glob(env.Dir("#doc").abspath + "/translations/*.po") - env.Depends('#editor/doc_translations.gen.h', tlist) - env.CommandNoCache('#editor/doc_translations.gen.h', tlist, run_in_subprocess(editor_builders.make_doc_translations_header)) + env.Depends("#editor/doc_translations.gen.h", tlist) + env.CommandNoCache( + "#editor/doc_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_doc_translations_header) + ) # Fonts flist = glob.glob(path + "/../thirdparty/fonts/*.ttf") flist.extend(glob.glob(path + "/../thirdparty/fonts/*.otf")) flist.sort() - env.Depends('#editor/builtin_fonts.gen.h', flist) - env.CommandNoCache('#editor/builtin_fonts.gen.h', flist, run_in_subprocess(editor_builders.make_fonts_header)) + env.Depends("#editor/builtin_fonts.gen.h", flist) + env.CommandNoCache("#editor/builtin_fonts.gen.h", flist, run_in_subprocess(editor_builders.make_fonts_header)) env.add_source_files(env.editor_sources, "*.cpp") - SConscript('debugger/SCsub') - SConscript('fileserver/SCsub') - SConscript('icons/SCsub') - SConscript('import/SCsub') - SConscript('plugins/SCsub') + SConscript("debugger/SCsub") + SConscript("fileserver/SCsub") + SConscript("icons/SCsub") + SConscript("import/SCsub") + SConscript("plugins/SCsub") lib = env.add_library("editor", env.editor_sources) env.Prepend(LIBS=[lib]) diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index f3e3025e81..e6a020bf41 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -277,7 +277,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { NodePath path = animation->track_get_path(track); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); @@ -1162,11 +1162,11 @@ void AnimationBezierTrackEdit::_bind_methods() { } AnimationBezierTrackEdit::AnimationBezierTrackEdit() { - undo_redo = NULL; - timeline = NULL; - root = NULL; - menu = NULL; - block_animation_update_ptr = NULL; + undo_redo = nullptr; + timeline = nullptr; + root = nullptr; + menu = nullptr; + block_animation_update_ptr = nullptr; moving_selection_attempt = false; moving_selection = false; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 4f06a753a7..b393ff5fd4 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -242,7 +242,7 @@ public: args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args.write[idx] = Variant::construct(t, NULL, 0, err); + args.write[idx] = Variant::construct(t, nullptr, 0, err); } change_notify_deserved = true; d_new["args"] = args; @@ -693,7 +693,7 @@ public: key_ofs = 0; track = -1; setting = false; - root_path = NULL; + root_path = nullptr; } }; @@ -905,7 +905,7 @@ public: args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args.write[idx] = Variant::construct(t, NULL, 0, err); + args.write[idx] = Variant::construct(t, nullptr, 0, err); } change_notify_deserved = true; d_new["args"] = args; @@ -1389,7 +1389,7 @@ public: AnimationMultiTrackKeyEdit() { use_fps = false; setting = false; - root_path = NULL; + root_path = nullptr; } }; @@ -1859,7 +1859,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { use_fps = false; editing = false; name_limit = 150 * EDSCALE; - zoom = NULL; + zoom = nullptr; play_position_pos = 0; play_position = memnew(Control); @@ -1958,7 +1958,7 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += type_icon->get_width() + hsep; NodePath path = animation->track_get_path(track); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); } @@ -2483,7 +2483,7 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant Vector<StringName> leftover_path; Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path); - Object *obj = NULL; + Object *obj = nullptr; if (res.is_valid()) { obj = res.ptr(); } else if (node) { @@ -3090,12 +3090,12 @@ void AnimationTrackEdit::_bind_methods() { } AnimationTrackEdit::AnimationTrackEdit() { - undo_redo = NULL; - timeline = NULL; - root = NULL; - path = NULL; - path_popup = NULL; - menu = NULL; + undo_redo = nullptr; + timeline = nullptr; + root = nullptr; + path = nullptr; + path_popup = nullptr; + menu = nullptr; clicking_on_name = false; dropping_at = 0; @@ -3140,7 +3140,7 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_ Callable::CallError ce; return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *()); } - return NULL; + return nullptr; } AnimationTrackEdit *AnimationTrackEditPlugin::create_audio_track_edit() { @@ -3148,14 +3148,14 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_audio_track_edit() { if (get_script_instance()) { return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_audio_track_edit").operator Object *()); } - return NULL; + return nullptr; } AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object *p_object) { if (get_script_instance()) { return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_animation_track_edit", p_object).operator Object *()); } - return NULL; + return nullptr; } /////////////////////////////////////// @@ -3304,7 +3304,7 @@ Ref<Animation> AnimationTrackEditor::get_current_animation() const { } void AnimationTrackEditor::_root_removed(Node *p_root) { - root = NULL; + root = nullptr; } void AnimationTrackEditor::set_root(Node *p_root) { @@ -3902,7 +3902,7 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b return PropertyInfo(); } -static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool *r_valid = NULL) { +static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool *r_valid = nullptr) { Vector<String> subindices; if (r_valid) { *r_valid = true; @@ -4123,7 +4123,7 @@ void AnimationTrackEditor::_update_tracks() { bool use_filter = selected_filter->is_pressed(); for (int i = 0; i < animation->get_track_count(); i++) { - AnimationTrackEdit *track_edit = NULL; + AnimationTrackEdit *track_edit = nullptr; //find hint and info for plugin @@ -4184,7 +4184,7 @@ void AnimationTrackEditor::_update_tracks() { if (animation->track_get_type(i) == Animation::TYPE_ANIMATION) { NodePath path = animation->track_get_path(i); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); } @@ -4199,7 +4199,7 @@ void AnimationTrackEditor::_update_tracks() { } } - if (track_edit == NULL) { + if (track_edit == nullptr) { //no valid plugin_found track_edit = memnew(AnimationTrackEdit); } @@ -4752,7 +4752,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { params.push_back(arg); } else { Callable::CallError ce; - Variant arg = Variant::construct(E->get().arguments[i].type, NULL, 0, ce); + Variant arg = Variant::construct(E->get().arguments[i].type, nullptr, 0, ce); params.push_back(arg); } } @@ -4838,21 +4838,21 @@ void AnimationTrackEditor::_clear_key_edit() { if (key_edit) { //if key edit is the object being inspected, remove it first if (EditorNode::get_singleton()->get_inspector()->get_edited_object() == key_edit) { - EditorNode::get_singleton()->push_item(NULL); + EditorNode::get_singleton()->push_item(nullptr); } //then actually delete it memdelete(key_edit); - key_edit = NULL; + key_edit = nullptr; } if (multi_key_edit) { if (EditorNode::get_singleton()->get_inspector()->get_edited_object() == multi_key_edit) { - EditorNode::get_singleton()->push_item(NULL); + EditorNode::get_singleton()->push_item(nullptr); } memdelete(multi_key_edit); - multi_key_edit = NULL; + multi_key_edit = nullptr; } } @@ -5264,7 +5264,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { for (int i = 0; i < animation->get_track_count(); i++) { NodePath path = animation->track_get_path(i); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); @@ -5361,7 +5361,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->create_action(TTR("Paste Tracks")); for (int i = 0; i < track_clipboard.size(); i++) { undo_redo->add_do_method(animation.ptr(), "add_track", track_clipboard[i].track_type); - Node *exists = NULL; + Node *exists = nullptr; NodePath path = track_clipboard[i].base_path; if (root) { @@ -5607,7 +5607,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { bool prop_exists = false; Variant::Type valid_type = Variant::NIL; - Object *obj = NULL; + Object *obj = nullptr; RES res; Vector<StringName> leftover_path; @@ -5753,7 +5753,7 @@ void AnimationTrackEditor::_bind_methods() { } AnimationTrackEditor::AnimationTrackEditor() { - root = NULL; + root = nullptr; undo_redo = EditorNode::get_singleton()->get_undo_redo(); @@ -5945,8 +5945,8 @@ AnimationTrackEditor::AnimationTrackEditor() { icvb->add_child(insert_confirm_bezier); keying = false; moving_selection = 0; - key_edit = NULL; - multi_key_edit = NULL; + key_edit = nullptr; + multi_key_edit = nullptr; box_selection = memnew(Control); add_child(box_selection); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 7c4cc6db53..96a60cc135 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -379,7 +379,7 @@ class AnimationTrackEditor : public VBoxContainer { void _root_removed(Node *p_root); - PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val = NULL); + PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val = nullptr); void _timeline_value_changed(double); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index ea0d7511fe..695c294ad2 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -303,7 +303,7 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, Vector<Color> color; color.push_back(Color(0.75, 0.75, 0.75)); - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); if (p_selected) { Color accent = get_theme_color("accent_color", "Editor"); @@ -673,7 +673,7 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } if (lines.size() > 2) { - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); } int limit = to_x - from_x - 4; @@ -926,7 +926,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int Vector<Color> color; color.push_back(Color(0.75, 0.75, 0.75)); - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); Color cut_color = get_theme_color("accent_color", "Editor"); cut_color.a = 0.7; @@ -1255,7 +1255,7 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } if (lines.size() > 2) { - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); } int limit = to_x - from_x - 4; @@ -1335,7 +1335,7 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj return memnew(AnimationTrackEditColor); } - return NULL; + return nullptr; } AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_audio_track_edit() { diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp index f14b12b132..9f6785ec06 100644 --- a/editor/array_property_edit.cpp +++ b/editor/array_property_edit.cpp @@ -43,7 +43,7 @@ Variant ArrayPropertyEdit::get_array() const { Variant arr = o->get(property); if (!arr.is_array()) { Callable::CallError ce; - arr = Variant::construct(default_type, NULL, 0, ce); + arr = Variant::construct(default_type, nullptr, 0, ce); } return arr; } @@ -110,7 +110,7 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { new_type = arr.get(size - 1).get_type(); } if (new_type != Variant::NIL) { - init = Variant::construct(new_type, NULL, 0, ce); + init = Variant::construct(new_type, nullptr, 0, ce); for (int i = size; i < newsize; i++) { ur->add_do_method(this, "_set_value", i, init); } @@ -140,7 +140,7 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { Variant value = arr.get(idx); if (value.get_type() != type && type >= 0 && type < Variant::VARIANT_MAX) { Callable::CallError ce; - Variant new_value = Variant::construct(Variant::Type(type), NULL, 0, ce); + Variant new_value = Variant::construct(Variant::Type(type), nullptr, 0, ce); UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Array Value Type")); diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 64d435a901..fe28c913a7 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -212,7 +212,7 @@ void AudioStreamPreviewGenerator::_bind_methods() { ADD_SIGNAL(MethodInfo("preview_updated", PropertyInfo(Variant::INT, "obj_id"))); } -AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = NULL; +AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = nullptr; void AudioStreamPreviewGenerator::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { @@ -221,7 +221,7 @@ void AudioStreamPreviewGenerator::_notification(int p_what) { if (!E->get().generating) { if (E->get().thread) { Thread::wait_to_finish(E->get().thread); - E->get().thread = NULL; + E->get().thread = nullptr; } if (!ObjectDB::get_instance(E->key())) { //no longer in use, get rid of preview to_erase.push_back(E->key()); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 26bc6dfaf2..157a9cdca7 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -82,7 +82,7 @@ GotoLineDialog::GotoLineDialog() { line = memnew(LineEdit); vbc->add_child(line); register_text_enter(line); - text_editor = NULL; + text_editor = nullptr; set_hide_on_ok(false); } @@ -1656,7 +1656,7 @@ void CodeTextEditor::update_toggle_scripts_button() { CodeTextEditor::CodeTextEditor() { - code_complete_func = NULL; + code_complete_func = nullptr; ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL); ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS); ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD | KEY_0); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 7f03fd30f0..bef5c3c2b0 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -40,7 +40,7 @@ static Node *_find_first_script(Node *p_root, Node *p_node) { if (p_node != p_root && p_node->get_owner() != p_root) { - return NULL; + return nullptr; } if (!p_node->get_script().is_null()) { return p_node; @@ -54,7 +54,7 @@ static Node *_find_first_script(Node *p_root, Node *p_node) { } } - return NULL; + return nullptr; } class ConnectDialogBinds : public Object { @@ -315,7 +315,7 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) { source = static_cast<Node *>(c.source); signal = c.signal; - tree->set_selected(NULL); + tree->set_selected(nullptr); tree->set_marked(source, true); if (c.target) { @@ -574,7 +574,7 @@ void ConnectionsDock::_make_or_edit_connection() { } // IMPORTANT NOTE: _disconnect and _connect cause an update_tree, which will delete the object "it" is pointing to. - it = NULL; + it = nullptr; if (add_script_function) { editor->emit_signal("script_add_function_request", target, cToMake.method, script_function_args); @@ -924,7 +924,7 @@ void ConnectionsDock::update_tree() { icon = get_theme_icon("Object", "EditorIcons"); } - TreeItem *pitem = NULL; + TreeItem *pitem = nullptr; if (node_signals2.size()) { pitem = tree->create_item(root); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 8f29a4f720..91d0d5c32c 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -203,7 +203,7 @@ public: void set_node(Node *p_node); void update_tree(); - ConnectionsDock(EditorNode *p_editor = NULL); + ConnectionsDock(EditorNode *p_editor = nullptr); ~ConnectionsDock(); }; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 6210b580ba..6cbb1b1791 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -314,7 +314,7 @@ void CreateDialog::_update_search() { root->set_icon(0, search_options->get_theme_icon(base_type, "EditorIcons")); } - TreeItem *to_select = search_box->get_text() == base_type ? root : NULL; + TreeItem *to_select = search_box->get_text() == base_type ? root : nullptr; for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) { @@ -417,7 +417,7 @@ void CreateDialog::_update_search() { favorite->set_pressed(favorite_list.find(to_select->get_text(0)) != -1); } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void CreateDialog::_confirmed() { @@ -538,7 +538,7 @@ Object *CreateDialog::instance_selected() { } } - return NULL; + return nullptr; } void CreateDialog::_item_selected() { diff --git a/editor/debugger/SCsub b/editor/debugger/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/debugger/SCsub +++ b/editor/debugger/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 9587daf93e..00ed2bbc4c 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -125,7 +125,7 @@ void EditorDebuggerInspector::_object_selected(ObjectID p_object) { } ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { - EditorDebuggerRemoteObject *debugObj = NULL; + EditorDebuggerRemoteObject *debugObj = nullptr; SceneDebuggerObject obj; obj.deserialize(p_arr); @@ -211,7 +211,7 @@ void EditorDebuggerInspector::clear_cache() { for (Map<ObjectID, EditorDebuggerRemoteObject *>::Element *E = remote_objects.front(); E; E = E->next()) { EditorNode *editor = EditorNode::get_singleton(); if (editor->get_editor_history()->get_current() == E->value()->get_instance_id()) { - editor->push_item(NULL); + editor->push_item(nullptr); } memdelete(E->value()); } @@ -221,7 +221,7 @@ void EditorDebuggerInspector::clear_cache() { Object *EditorDebuggerInspector::get_object(ObjectID p_id) { if (remote_objects.has(p_id)) return remote_objects[p_id]; - return NULL; + return nullptr; } void EditorDebuggerInspector::add_stack_variable(const Array &p_array) { diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 5c9b977247..3302b50103 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -47,7 +47,7 @@ void _for_all(TabContainer *p_node, const Func &p_func) { } } -EditorDebuggerNode *EditorDebuggerNode::singleton = NULL; +EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr; EditorDebuggerNode::EditorDebuggerNode() { if (!singleton) @@ -291,13 +291,13 @@ void EditorDebuggerNode::_notification(int p_what) { // Take connections. if (server->is_connection_available()) { - ScriptEditorDebugger *debugger = NULL; + ScriptEditorDebugger *debugger = nullptr; _for_all(tabs, [&](ScriptEditorDebugger *dbg) { if (debugger || dbg->is_session_active()) return; debugger = dbg; }); - if (debugger == NULL) { + if (debugger == nullptr) { if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active. debugger = _add_debugger(); } else { @@ -356,7 +356,7 @@ void EditorDebuggerNode::_debugger_changed(int p_tab) { if (get_inspected_remote_object()) { // Clear inspected object, you can only inspect objects in selected debugger. // Hopefully, in the future, we will have one inspector per debugger. - EditorNode::get_singleton()->push_item(NULL); + EditorNode::get_singleton()->push_item(nullptr); } if (remote_scene_tree->is_visible_in_tree()) { get_current_debugger()->request_remote_tree(); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 6181ccdb5f..9467442c9a 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -85,9 +85,9 @@ private: }; Ref<EditorDebuggerServer> server; - TabContainer *tabs = NULL; - Button *debugger_button = NULL; - MenuButton *script_menu = NULL; + TabContainer *tabs = nullptr; + Button *debugger_button = nullptr; + MenuButton *script_menu = nullptr; Ref<Script> stack_script; // Why?!? @@ -95,7 +95,7 @@ private: int last_warning_count = 0; float inspect_edited_object_timeout = 0; - EditorDebuggerTree *remote_scene_tree = NULL; + EditorDebuggerTree *remote_scene_tree = nullptr; float remote_scene_tree_timeout = 0.0; bool auto_switch_remote_scene_tree = false; bool debug_with_external_editor = false; diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 427b929ccb..c2b94c79bb 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -135,7 +135,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int // Nodes are in a flatten list, depth first. Use a stack of parents, avoid recursion. List<Pair<TreeItem *, int>> parents; for (int i = 0; i < p_tree->nodes.size(); i++) { - TreeItem *parent = NULL; + TreeItem *parent = nullptr; if (parents.size()) { // Find last parent. Pair<TreeItem *, int> &p = parents[0]; parent = p.first; @@ -191,7 +191,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int // Check if parent expects more children. for (int j = 0; j < parents.size(); j++) { if (parents[j].first == item) { - parent = NULL; + parent = nullptr; break; // Might have more children. } } @@ -211,7 +211,7 @@ String EditorDebuggerTree::get_selected_path() { String EditorDebuggerTree::_get_path(TreeItem *p_item) { ERR_FAIL_COND_V(!p_item, ""); - if (p_item->get_parent() == NULL) { + if (p_item->get_parent() == nullptr) { return "/root"; } String text = p_item->get_text(0); diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index d9084bc596..342eb23194 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -50,8 +50,8 @@ private: int debugger_id = 0; bool updating_scene_tree = false; Set<ObjectID> unfold_cache; - PopupMenu *item_menu = NULL; - EditorFileDialog *file_dialog = NULL; + PopupMenu *item_menu = nullptr; + EditorFileDialog *file_dialog = nullptr; String _get_path(TreeItem *p_item); void _scene_tree_folded(Object *p_obj); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index bdb1ebd4d7..1971abadc4 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -138,7 +138,7 @@ void ScriptEditorDebugger::update_tabs() { } void ScriptEditorDebugger::clear_style() { - tabs->add_theme_style_override("panel", NULL); + tabs->add_theme_style_override("panel", nullptr); } void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) { @@ -923,7 +923,7 @@ void ScriptEditorDebugger::stop() { res_path_cache.clear(); profiler_signature.clear(); - inspector->edit(NULL); + inspector->edit(nullptr); _update_buttons_state(); } @@ -973,7 +973,7 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { msg.push_back(frame); _put_msg("get_stack_frame_vars", msg); } else { - inspector->edit(NULL); + inspector->edit(nullptr); } } diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index 7944d7cb99..9cb7dc2edf 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -107,7 +107,7 @@ private: Button *docontinue; // Reference to "Remote" tab in scene tree. Needed by _live_edit_set and buttons state. // Each debugger should have it's tree in the future I guess. - const Tree *editor_remote_tree = NULL; + const Tree *editor_remote_tree = nullptr; List<Vector<float>> perf_history; Vector<float> perf_max; @@ -255,7 +255,7 @@ public: bool is_skip_breakpoints(); virtual Size2 get_minimum_size() const; - ScriptEditorDebugger(EditorNode *p_editor = NULL); + ScriptEditorDebugger(EditorNode *p_editor = nullptr); ~ScriptEditorDebugger(); }; diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 8ba706d4b3..2302fb0780 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -592,7 +592,7 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve set_title(TTR("Error loading:") + " " + p_for_file.get_file()); files->clear(); - TreeItem *root = files->create_item(NULL); + TreeItem *root = files->create_item(nullptr); for (int i = 0; i < report.size(); i++) { String dep; @@ -674,7 +674,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa for (int i = 0; i < efsd->get_subdir_count(); i++) { - TreeItem *dir_item = NULL; + TreeItem *dir_item = nullptr; if (p_parent) { dir_item = files->create_item(p_parent); dir_item->set_text(0, efsd->get_subdir(i)->get_name()); @@ -730,7 +730,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa void OrphanResourcesDialog::refresh() { HashMap<String, int> refs; - _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, NULL); + _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, nullptr); files->clear(); TreeItem *root = files->create_item(); _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, root); diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp index 82db639379..7169986b14 100644 --- a/editor/dictionary_property_edit.cpp +++ b/editor/dictionary_property_edit.cpp @@ -96,7 +96,7 @@ Node *DictionaryPropertyEdit::get_node() { Object *o = ObjectDB::get_instance(obj); if (!o) - return NULL; + return nullptr; return cast_to<Node>(o); } diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp index 66134b4428..096be1fe4b 100644 --- a/editor/doc_data.cpp +++ b/editor/doc_data.cpp @@ -265,7 +265,7 @@ void DocData::generate(bool p_basic_types) { List<PropertyInfo>::Element *EO = own_properties.front(); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - bool inherited = EO == NULL; + bool inherited = EO == nullptr; if (EO && EO->get() == E->get()) { inherited = false; EO = EO->next(); @@ -372,7 +372,7 @@ void DocData::generate(bool p_basic_types) { if (skip_setter_getter_methods && setters_getters.has(E->get().name)) { // Don't skip parametric setters and getters, i.e. method which require // one or more parameters to define what property should be set or retrieved. - // E.g. CPUParticles::set_param(Parameter param, float value). + // E.g. CPUParticles3D::set_param(Parameter param, float value). if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) { continue; } @@ -534,7 +534,7 @@ void DocData::generate(bool p_basic_types) { c.name = cname; Callable::CallError cerror; - Variant v = Variant::construct(Variant::Type(i), NULL, 0, cerror); + Variant v = Variant::construct(Variant::Type(i), nullptr, 0, cerror); List<MethodInfo> method_list; v.get_method_list(&method_list); diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index 33ee95c2d8..b0bcc2b448 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -100,7 +100,7 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St il->set_mouse_filter(Control::MOUSE_FILTER_IGNORE); il->add_theme_constant_override("hseparation", 16 * EDSCALE); while (*names_ptr) { - il->add_item(String::utf8(*names_ptr++), NULL, false); + il->add_item(String::utf8(*names_ptr++), nullptr, false); } il->set_max_columns(il->get_item_count() < 4 || single_column ? 1 : 16); vbc->add_child(il); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index d61fe8f08a..74c4102003 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -85,7 +85,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { package_path = p_path; Set<String> files_sorted; - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io); @@ -102,7 +102,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { //get filename unz_file_info info; char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String name = fname; files_sorted.insert(name); @@ -212,7 +212,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { void EditorAssetInstaller::ok_pressed() { - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io); @@ -234,7 +234,7 @@ void EditorAssetInstaller::ok_pressed() { //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String name = fname; @@ -297,10 +297,10 @@ void EditorAssetInstaller::ok_pressed() { } msg += failed_files[i]; } - if (EditorNode::get_singleton() != NULL) + if (EditorNode::get_singleton() != nullptr) EditorNode::get_singleton()->show_warning(msg); } else { - if (EditorNode::get_singleton() != NULL) + if (EditorNode::get_singleton() != nullptr) EditorNode::get_singleton()->show_warning(TTR("Package installed successfully!"), TTR("Success!")); } EditorFileSystem::get_singleton()->scan_changes(); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 55bdd2070b..7e499facd5 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1007,7 +1007,7 @@ void EditorAudioBuses::_update_buses() { memdelete(bus_hb->get_child(0)); } - drop_end = NULL; + drop_end = nullptr; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { @@ -1045,7 +1045,7 @@ void EditorAudioBuses::_notification(int p_what) { if (drop_end) { drop_end->queue_delete(); - drop_end = NULL; + drop_end = nullptr; } } break; case NOTIFICATION_PROCESS: { @@ -1296,7 +1296,7 @@ void EditorAudioBuses::_bind_methods() { EditorAudioBuses::EditorAudioBuses() { - drop_end = NULL; + drop_end = nullptr; top_hb = memnew(HBoxContainer); add_child(top_hb); @@ -1402,7 +1402,7 @@ void AudioBusesEditorPlugin::edit(Object *p_node) { bool AudioBusesEditorPlugin::handles(Object *p_node) const { - return (Object::cast_to<AudioBusLayout>(p_node) != NULL); + return (Object::cast_to<AudioBusLayout>(p_node) != nullptr); } void AudioBusesEditorPlugin::make_visible(bool p_visible) { diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 72098c7232..be1551629d 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -133,7 +133,7 @@ public: void update_bus(); void update_send(); - EditorAudioBus(EditorAudioBuses *p_buses = NULL, bool p_is_master = false); + EditorAudioBus(EditorAudioBuses *p_buses = nullptr, bool p_is_master = false); }; class EditorAudioBusDrop : public Control { diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index a6a383ba58..ed628ff620 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -240,7 +240,7 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu case BUTTON_MOVE_UP: case BUTTON_MOVE_DOWN: { - TreeItem *swap = NULL; + TreeItem *swap = nullptr; if (p_button == BUTTON_MOVE_UP) { swap = ti->get_prev(); @@ -326,7 +326,7 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { - if (autoload_add_path->get_line_edit()->get_text() != "" && _autoload_name_is_valid(p_name, NULL)) { + if (autoload_add_path->get_line_edit()->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } @@ -334,19 +334,19 @@ void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { add_autoload->set_disabled( - p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), NULL)); + p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); } void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { add_autoload->set_disabled( - autoload_add_path->get_line_edit()->get_text() == "" || !_autoload_name_is_valid(p_name, NULL)); + autoload_add_path->get_line_edit()->get_text() == "" || !_autoload_name_is_valid(p_name, nullptr)); } Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { RES res = ResourceLoader::load(p_path); - ERR_FAIL_COND_V_MSG(res.is_null(), NULL, "Can't autoload: " + p_path + "."); - Node *n = NULL; + ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + "."); + Node *n = nullptr; if (res->is_class("PackedScene")) { Ref<PackedScene> ps = res; n = ps->instance(); @@ -354,17 +354,17 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { Ref<Script> s = res; StringName ibt = s->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); - ERR_FAIL_COND_V_MSG(!valid_type, NULL, "Script does not inherit a Node: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + "."); Object *obj = ClassDB::instance(ibt); - ERR_FAIL_COND_V_MSG(obj == NULL, NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(obj == nullptr, nullptr, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + "."); n = Object::cast_to<Node>(obj); n->set_script(s); } - ERR_FAIL_COND_V_MSG(!n, NULL, "Path in autoload not a node or script: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in autoload not a node or script: " + p_path + "."); return n; } @@ -429,7 +429,7 @@ void EditorAutoloadSettings::update_autoload() { to_remove.erase(name); need_to_add = false; } else { - info.node = NULL; + info.node = nullptr; } } } @@ -474,7 +474,7 @@ void EditorAutoloadSettings::update_autoload() { if (info.node) { info.node->queue_delete(); - info.node = NULL; + info.node = nullptr; } } @@ -505,7 +505,7 @@ void EditorAutoloadSettings::update_autoload() { if (!info->in_editor && !info->is_singleton) { // No reason to keep this node memdelete(info->node); - info->node = NULL; + info->node = nullptr; } } @@ -523,7 +523,7 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control PackedStringArray autoloads; - TreeItem *next = tree->get_next_selected(NULL); + TreeItem *next = tree->get_next_selected(nullptr); while (next) { autoloads.push_back(next->get_text(0)); @@ -604,7 +604,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int order = ProjectSettings::get_singleton()->get_order("autoload/" + name); AutoLoadInfo aux; - List<AutoLoadInfo>::Element *E = NULL; + List<AutoLoadInfo>::Element *E = nullptr; if (!move_to_back) { aux.order = order; @@ -805,9 +805,9 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } } - if (!info.is_singleton && !info.in_editor && info.node != NULL) { + if (!info.is_singleton && !info.in_editor && info.node != nullptr) { memdelete(info.node); - info.node = NULL; + info.node = nullptr; } } diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index 653a1b0a78..2716442ec9 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -63,7 +63,7 @@ class EditorAutoloadSettings : public VBoxContainer { AutoLoadInfo() { is_singleton = false; in_editor = false; - node = NULL; + node = nullptr; } }; @@ -78,7 +78,7 @@ class EditorAutoloadSettings : public VBoxContainer { LineEdit *autoload_add_name; Button *add_autoload; - bool _autoload_name_is_valid(const String &p_name, String *r_error = NULL); + bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr); void _autoload_add(); void _autoload_selected(); diff --git a/editor/editor_builders.py b/editor/editor_builders.py index 44c3e50dfc..ea32e24f6e 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -25,6 +25,7 @@ def make_doc_header(target, source, env): buf = (docbegin + buf + docend).encode("utf-8") decomp_size = len(buf) import zlib + buf = zlib.compress(buf) g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") @@ -55,7 +56,7 @@ def make_fonts_header(target, source, env): # saving uncompressed, since freetype will reference from memory pointer xl_names = [] for i in range(len(source)): - with open(source[i], "rb")as f: + with open(source[i], "rb") as f: buf = f.read() name = os.path.splitext(os.path.basename(source[i]))[0] @@ -111,8 +112,10 @@ def make_translations_header(target, source, env, category): g.write("};\n\n") g.write("static {}TranslationList _{}_translations[] = {{\n".format(category.capitalize(), category)) for x in xl_names: - g.write("\t{{ \"{}\", {}, {}, _{}_translation_{}_compressed }},\n".format(x[0], str(x[1]), str(x[2]), category, x[0])) - g.write("\t{NULL, 0, 0, NULL}\n") + g.write( + '\t{{ "{}", {}, {}, _{}_translation_{}_compressed }},\n'.format(x[0], str(x[1]), str(x[2]), category, x[0]) + ) + g.write("\t{nullptr, 0, 0, nullptr}\n") g.write("};\n") g.write("#endif") @@ -128,5 +131,5 @@ def make_doc_translations_header(target, source, env): make_translations_header(target, source, env, "doc") -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 1c19327da7..942b4a8ee6 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -270,7 +270,7 @@ EditorPlugin *EditorData::get_editor(Object *p_object) { return editor_plugins[i]; } - return NULL; + return nullptr; } EditorPlugin *EditorData::get_subeditor(Object *p_object) { @@ -281,7 +281,7 @@ EditorPlugin *EditorData::get_subeditor(Object *p_object) { return editor_plugins[i]; } - return NULL; + return nullptr; } Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { @@ -302,7 +302,7 @@ EditorPlugin *EditorData::get_editor(String p_name) { return editor_plugins[i]; } - return NULL; + return nullptr; } void EditorData::copy_object_params(Object *p_object) { @@ -464,7 +464,7 @@ UndoRedo &EditorData::get_undo_redo() { void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo = NULL; + p_plugin->undo_redo = nullptr; editor_plugins.erase(p_plugin); } @@ -479,7 +479,7 @@ int EditorData::get_editor_plugin_count() const { } EditorPlugin *EditorData::get_editor_plugin(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), nullptr); return editor_plugins[p_idx]; } @@ -506,7 +506,7 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i Ref<Script> script = get_custom_types()[p_inherits][i].script; Object *ob = ClassDB::instance(p_inherits); - ERR_FAIL_COND_V(!ob, NULL); + ERR_FAIL_COND_V(!ob, nullptr); if (ob->is_class("Node")) { ob->call("set_name", p_type); } @@ -516,7 +516,7 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i } } - return NULL; + return nullptr; } void EditorData::remove_custom_type(const String &p_type) { @@ -540,7 +540,7 @@ int EditorData::add_edited_scene(int p_at_pos) { if (p_at_pos < 0) p_at_pos = edited_scene.size(); EditedScene es; - es.root = NULL; + es.root = nullptr; es.path = String(); es.history_current = -1; es.version = 0; @@ -680,10 +680,10 @@ void EditorData::set_edited_scene(int p_idx) { } Node *EditorData::get_edited_scene_root(int p_idx) { if (p_idx < 0) { - ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), NULL); + ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), nullptr); return edited_scene[current_edited_scene].root; } else { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), nullptr); return edited_scene[p_idx].root; } } @@ -915,7 +915,7 @@ Object *EditorData::script_class_instance(const String &p_class) { return obj; } } - return NULL; + return nullptr; } Ref<Script> EditorData::script_class_load_script(const String &p_class) const { @@ -1018,7 +1018,7 @@ void EditorSelection::add_node(Node *p_node) { changed = true; nl_changed = true; - Object *meta = NULL; + Object *meta = nullptr; for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { meta = E->get()->call("_get_editor_data", p_node); diff --git a/editor/editor_data.h b/editor/editor_data.h index 5095ea8479..4f5d68bfed 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -265,7 +265,7 @@ public: template <class T> T *get_node_editor_data(Node *p_node) { if (!selection.has(p_node)) - return NULL; + return nullptr; return Object::cast_to<T>(selection[p_node]); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 5883b5eb1e..e8167070d4 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -358,12 +358,12 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat zipOpenNewFileInZip(zip, path.utf8().get_data(), - NULL, - NULL, + nullptr, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION); @@ -582,6 +582,14 @@ String EditorExportPlugin::get_ios_cpp_code() const { return ios_cpp_code; } +void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) { + ios_project_static_libs.push_back(p_path); +} + +Vector<String> EditorExportPlugin::get_ios_project_static_libs() const { + return ios_project_static_libs; +} + void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { if (get_script_instance()) { @@ -617,6 +625,7 @@ void EditorExportPlugin::skip() { void EditorExportPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags"), &EditorExportPlugin::add_shared_object); + ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib); ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework); ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content); @@ -1070,7 +1079,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co FileAccess *src_f; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io); + zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io); ZipData zd; zd.ep = &ep; @@ -1080,7 +1089,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co if (err != OK && err != ERR_SKIP) ERR_PRINT("Failed to export project files"); - zipClose(zip, NULL); + zipClose(zip, nullptr); return OK; } @@ -1153,7 +1162,7 @@ EditorExportPlatform::EditorExportPlatform() { //// -EditorExport *EditorExport::singleton = NULL; +EditorExport *EditorExport::singleton = nullptr; void EditorExport::_save() { @@ -1686,7 +1695,7 @@ void EditorExportPlatformPC::set_fixup_embedded_pck_func(FixUpEmbeddedPckFunc p_ EditorExportPlatformPC::EditorExportPlatformPC() { chmod_flags = -1; - fixup_embedded_pck_func = NULL; + fixup_embedded_pck_func = nullptr; } /////////////////////// diff --git a/editor/editor_export.h b/editor/editor_export.h index 81790eb0a4..f47fe9c95e 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -212,7 +212,7 @@ protected: FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset); bool exists_export_template(String template_file_name, String *err) const; - String find_export_template(String template_file_name, String *err = NULL) const; + String find_export_template(String template_file_name, String *err = nullptr) const; void gen_export_flags(Vector<String> &r_flags, int p_flags); public: @@ -238,9 +238,9 @@ public: virtual String get_name() const = 0; virtual Ref<Texture2D> get_logo() const = 0; - Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL); + Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr); - Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = NULL, bool p_embed = false, int64_t *r_embedded_start = NULL, int64_t *r_embedded_size = NULL); + Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr); Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path); virtual bool poll_export() { return false; } @@ -291,6 +291,7 @@ class EditorExportPlugin : public Reference { bool skipped; Vector<String> ios_frameworks; + Vector<String> ios_project_static_libs; String ios_plist_content; String ios_linker_flags; Vector<String> ios_bundle_files; @@ -322,6 +323,7 @@ protected: void add_shared_object(const String &p_path, const Vector<String> &tags); void add_ios_framework(const String &p_path); + void add_ios_project_static_lib(const String &p_path); void add_ios_plist_content(const String &p_plist_content); void add_ios_linker_flags(const String &p_flags); void add_ios_bundle_file(const String &p_path); @@ -336,6 +338,7 @@ protected: public: Vector<String> get_ios_frameworks() const; + Vector<String> get_ios_project_static_libs() const; String get_ios_plist_content() const; String get_ios_linker_flags() const; Vector<String> get_ios_bundle_files() const; diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 6e13ec7967..e2b79efb43 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -787,7 +787,7 @@ Ref<EditorFeatureProfile> EditorFeatureProfileManager::get_current_profile() { return current; } -EditorFeatureProfileManager *EditorFeatureProfileManager::singleton = NULL; +EditorFeatureProfileManager *EditorFeatureProfileManager::singleton = nullptr; void EditorFeatureProfileManager::_bind_methods() { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index fca59946ae..71ade56e39 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -44,11 +44,11 @@ #include "scene/gui/margin_container.h" #include "servers/display_server.h" -EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = NULL; -EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = NULL; +EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = nullptr; +EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = nullptr; -EditorFileDialog::RegisterFunc EditorFileDialog::register_func = NULL; -EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = NULL; +EditorFileDialog::RegisterFunc EditorFileDialog::register_func = nullptr; +EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = nullptr; VBoxContainer *EditorFileDialog::get_vbox() { return vbox; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index ad34b59c5c..c211d5852a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -41,7 +41,7 @@ #include "editor_resource_preview.h" #include "editor_settings.h" -EditorFileSystem *EditorFileSystem::singleton = NULL; +EditorFileSystem *EditorFileSystem::singleton = nullptr; //the name is the version, to keep compatibility with different versions of Godot #define CACHE_FILE_NAME "filesystem_cache6" @@ -75,7 +75,7 @@ int EditorFileSystemDirectory::get_subdir_count() const { EditorFileSystemDirectory *EditorFileSystemDirectory::get_subdir(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, subdirs.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, subdirs.size(), nullptr); return subdirs[p_idx]; } @@ -176,7 +176,7 @@ void EditorFileSystemDirectory::_bind_methods() { EditorFileSystemDirectory::EditorFileSystemDirectory() { modified_time = 0; - parent = NULL; + parent = nullptr; verified = false; } @@ -300,7 +300,7 @@ void EditorFileSystem::_scan_filesystem() { sp.progress = &scan_progress; new_filesystem = memnew(EditorFileSystemDirectory); - new_filesystem->parent = NULL; + new_filesystem->parent = nullptr; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); d->change_dir("res://"); @@ -383,7 +383,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { break; } else if (err != OK) { @@ -430,7 +430,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&md5_stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&md5_stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { break; @@ -622,7 +622,7 @@ void EditorFileSystem::scan() { memdelete(filesystem); //file_type_cache.clear(); filesystem = new_filesystem; - new_filesystem = NULL; + new_filesystem = nullptr; _update_scan_actions(); scanning = false; emit_signal("filesystem_changed"); @@ -1124,8 +1124,8 @@ void EditorFileSystem::_notification(int p_what) { } Thread::wait_to_finish(active_thread); memdelete(active_thread); - thread = NULL; - thread_sources = NULL; + thread = nullptr; + thread_sources = nullptr; WARN_PRINT("Scan thread aborted..."); set_process(false); } @@ -1134,8 +1134,8 @@ void EditorFileSystem::_notification(int p_what) { memdelete(filesystem); if (new_filesystem) memdelete(new_filesystem); - filesystem = NULL; - new_filesystem = NULL; + filesystem = nullptr; + new_filesystem = nullptr; } break; case NOTIFICATION_PROCESS: { @@ -1152,7 +1152,7 @@ void EditorFileSystem::_notification(int p_what) { Thread::wait_to_finish(thread_sources); memdelete(thread_sources); - thread_sources = NULL; + thread_sources = nullptr; if (_update_scan_actions()) emit_signal("filesystem_changed"); emit_signal("sources_changed", sources_changed.size() > 0); @@ -1166,10 +1166,10 @@ void EditorFileSystem::_notification(int p_what) { if (filesystem) memdelete(filesystem); filesystem = new_filesystem; - new_filesystem = NULL; + new_filesystem = nullptr; Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; _update_scan_actions(); emit_signal("filesystem_changed"); emit_signal("sources_changed", sources_changed.size() > 0); @@ -1308,7 +1308,7 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector String EditorFileSystem::get_file_type(const String &p_file) const { - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { @@ -1322,13 +1322,13 @@ String EditorFileSystem::get_file_type(const String &p_file) const { EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int *r_index) const { if (!filesystem || scanning) - return NULL; + return nullptr; - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { - return NULL; + return nullptr; } if (r_index) @@ -1340,12 +1340,12 @@ EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p_path) { if (!filesystem || scanning) - return NULL; + return nullptr; String f = ProjectSettings::get_singleton()->localize_path(p_path); if (!f.begins_with("res://")) - return NULL; + return nullptr; f = f.substr(6, f.length()); f = f.replace("\\", "/"); @@ -1358,7 +1358,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p Vector<String> path = f.split("/"); if (path.size() == 0) - return NULL; + return nullptr; EditorFileSystemDirectory *fs = filesystem; @@ -1374,7 +1374,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p } if (idx == -1) { - return NULL; + return nullptr; } else { fs = fs->get_subdir(idx); @@ -1483,7 +1483,7 @@ void EditorFileSystem::_queue_update_script_classes() { void EditorFileSystem::update_file(const String &p_file) { - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { @@ -1684,7 +1684,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector } md5s->close(); - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(file, &fs, cpos); ERR_FAIL_COND_V_MSG(!found, ERR_UNCONFIGURED, "Can't find file '" + file + "'."); @@ -1718,7 +1718,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector void EditorFileSystem::_reimport_file(const String &p_file) { - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(p_file, &fs, cpos); ERR_FAIL_COND_MSG(!found, "Can't find file '" + p_file + "'."); @@ -1980,7 +1980,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } //group may have changed, so also update group reference - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (_find_file(p_files[i], &fs, cpos)) { @@ -2131,14 +2131,14 @@ EditorFileSystem::EditorFileSystem() { singleton = this; filesystem = memnew(EditorFileSystemDirectory); //like, empty - filesystem->parent = NULL; + filesystem->parent = nullptr; - thread = NULL; + thread = nullptr; scanning = false; importing = false; use_threads = true; - thread_sources = NULL; - new_filesystem = NULL; + thread_sources = nullptr; + new_filesystem = nullptr; abort_scan = false; scanning_changes = false; diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 9789dacdc1..55a2ed3d09 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -129,9 +129,9 @@ class EditorFileSystem : public Node { ItemAction() { action = ACTION_NONE; - dir = NULL; - new_dir = NULL; - new_file = NULL; + dir = nullptr; + new_dir = nullptr; + new_file = nullptr; } }; diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 9d8c46cc2d..a36e2f360e 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -39,10 +39,8 @@ #include "editor_settings.h" #define CONTRIBUTE_URL "https://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html" -#define CONTRIBUTE2_URL "https://github.com/godotengine/godot-docs" -#define REQUEST_URL "https://github.com/godotengine/godot-docs/issues/new" -DocData *EditorHelp::doc = NULL; +DocData *EditorHelp::doc = nullptr; void EditorHelp::_init_colors() { @@ -109,7 +107,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { String link = p_select.substr(tag_end + 1, p_select.length()).lstrip(" "); String topic; - Map<String, int> *table = NULL; + Map<String, int> *table = nullptr; if (tag == "method") { topic = "class_method"; diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 6fba5b1b4c..01a50cad2c 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -317,7 +317,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() { iterator_doc = EditorHelp::get_doc_data()->class_list.front(); matches.clear(); - matched_item = NULL; + matched_item = nullptr; return true; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 181811207c..c92d1d009d 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -71,7 +71,7 @@ Size2 EditorProperty::get_minimum_size() const { ms.width += check->get_width() + get_theme_constant("hseparation", "CheckBox") + get_theme_constant("hseparator", "Tree"); } - if (bottom_editor != NULL && bottom_editor->is_visible()) { + if (bottom_editor != nullptr && bottom_editor->is_visible()) { ms.height += get_theme_constant("vseparation", "Tree"); Size2 bems = bottom_editor->get_combined_minimum_size(); //bems.width += get_constant("item_margin", "Tree"); @@ -856,7 +856,7 @@ void EditorProperty::_bind_methods() { EditorProperty::EditorProperty() { draw_top_bg = true; - object = NULL; + object = nullptr; split_ratio = 0.5; selectable = true; text_size = 0; @@ -873,8 +873,8 @@ EditorProperty::EditorProperty() { property_usage = 0; selected = false; selected_focusable = -1; - label_reference = NULL; - bottom_editor = NULL; + label_reference = nullptr; + bottom_editor = nullptr; } //////////////////////////////////////////////// //////////////////////////////////////////////// @@ -888,7 +888,7 @@ void EditorInspectorPlugin::add_custom_control(Control *control) { void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Control *p_prop) { - ERR_FAIL_COND(Object::cast_to<EditorProperty>(p_prop) == NULL); + ERR_FAIL_COND(Object::cast_to<EditorProperty>(p_prop) == nullptr); AddedEditor ae; ae.properties.push_back(p_for_property); @@ -1257,7 +1257,7 @@ void EditorInspectorSection::_bind_methods() { } EditorInspectorSection::EditorInspectorSection() { - object = NULL; + object = nullptr; foldable = false; vbox = memnew(VBoxContainer); vbox_added = false; @@ -1297,7 +1297,7 @@ EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, V } } } - return NULL; + return nullptr; } void EditorInspector::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) { @@ -1473,12 +1473,12 @@ void EditorInspector::update_tree() { } } - // TreeItem *current_category = NULL; + // TreeItem *current_category = nullptr; String filter = search_box ? search_box->get_text() : ""; String group; String group_base; - VBoxContainer *category_vbox = NULL; + VBoxContainer *category_vbox = nullptr; List<PropertyInfo> plist; @@ -1535,7 +1535,7 @@ void EditorInspector::update_tree() { EditorInspectorCategory *category = memnew(EditorInspectorCategory); main_vbox->add_child(category); - category_vbox = NULL; //reset + category_vbox = nullptr; //reset String type = p.name; category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object"); @@ -1569,7 +1569,7 @@ void EditorInspector::update_tree() { } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name)) continue; - if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && VS::get_singleton()->is_low_end()) + if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end()) continue; //do not show this property in low end gfx if (p.name == "script" && (hide_script || bool(object->call("_hide_script_from_inspector")))) { @@ -1621,7 +1621,7 @@ void EditorInspector::update_tree() { continue; } - if (category_vbox == NULL) { + if (category_vbox == nullptr) { category_vbox = memnew(VBoxContainer); main_vbox->add_child(category_vbox); } @@ -1659,7 +1659,7 @@ void EditorInspector::update_tree() { if (current_vbox == main_vbox) { //do not add directly to the main vbox, given it has no spacing - if (category_vbox == NULL) { + if (category_vbox == nullptr) { category_vbox = memnew(VBoxContainer); } current_vbox = category_vbox; @@ -2143,7 +2143,7 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().name == p_path) { Callable::CallError ce; - to_create = Variant::construct(E->get().type, NULL, 0, ce); + to_create = Variant::construct(E->get().type, nullptr, 0, ce); break; } } @@ -2191,7 +2191,7 @@ void EditorInspector::_resource_selected(const String &p_path, RES p_resource) { void EditorInspector::_node_removed(Node *p_node) { if (p_node == object) { - edit(NULL); + edit(nullptr); } } @@ -2211,14 +2211,14 @@ void EditorInspector::_notification(int p_what) { } } if (p_what == NOTIFICATION_PREDELETE) { - edit(NULL); //just in case + edit(nullptr); //just in case } if (p_what == NOTIFICATION_EXIT_TREE) { if (!sub_inspector) { get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); } - edit(NULL); + edit(nullptr); } if (p_what == NOTIFICATION_PROCESS) { @@ -2328,8 +2328,8 @@ void EditorInspector::_bind_methods() { } EditorInspector::EditorInspector() { - object = NULL; - undo_redo = NULL; + object = nullptr; + undo_redo = nullptr; main_vbox = memnew(VBoxContainer); main_vbox->set_h_size_flags(SIZE_EXPAND_FILL); main_vbox->add_theme_constant_override("separation", 0); @@ -2349,7 +2349,7 @@ EditorInspector::EditorInspector() { update_tree_pending = false; refresh_countdown = 0; read_only = false; - search_box = NULL; + search_box = nullptr; keying = false; _prop_edited = "property_edited"; set_process(true); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 91e53edeac..c89a7bcf23 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -66,7 +66,7 @@ void EditorLog::_notification(int p_what) { } else if (p_what == NOTIFICATION_THEME_CHANGED) { Ref<DynamicFont> df_output_code = get_theme_font("output_source", "EditorFonts"); if (df_output_code.is_valid()) { - if (log != NULL) { + if (log != nullptr) { log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d7b771c80f..205d5f2944 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -61,9 +61,9 @@ #include "scene/gui/texture_progress.h" #include "scene/gui/tool_button.h" #include "scene/resources/packed_scene.h" -#include "servers/navigation_2d_server.h" -#include "servers/navigation_server.h" -#include "servers/physics_2d_server.h" +#include "servers/navigation_server_2d.h" +#include "servers/navigation_server_3d.h" +#include "servers/physics_server_2d.h" #include "editor/audio_stream_preview.h" #include "editor/debugger/editor_debugger_node.h" @@ -174,7 +174,7 @@ #include <stdio.h> #include <stdlib.h> -EditorNode *EditorNode::singleton = NULL; +EditorNode *EditorNode::singleton = nullptr; void EditorNode::_update_scene_tabs() { @@ -358,13 +358,17 @@ void EditorNode::_notification(int p_what) { scene_root->set_default_canvas_item_texture_repeat(tr); } - VS::DOFBokehShape dof_shape = VS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape"))); - VS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape); - VS::DOFBlurQuality dof_quality = VS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))); + RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape"))); + RS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape); + RS::DOFBlurQuality dof_quality = RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))); bool dof_jitter = GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter"); - VS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter); - VS::get_singleton()->environment_set_ssao_quality(VS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size")); - VS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve")); + RS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter); + RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size")); + RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve")); + bool glow_bicubic = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0; + RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic); + RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality"))); + RS::get_singleton()->environment_set_ssr_roughness_quality(ssr_roughness_quality); } ResourceImporterTexture::get_singleton()->update_imports(); @@ -384,7 +388,7 @@ void EditorNode::_notification(int p_what) { case NOTIFICATION_EXIT_TREE: { editor_data.save_editor_external_data(); - FileAccess::set_file_close_fail_notify_callback(NULL); + FileAccess::set_file_close_fail_notify_callback(nullptr); log->deinit(); // do not get messages anymore editor_data.clear_edited_scenes(); } break; @@ -404,9 +408,9 @@ void EditorNode::_notification(int p_what) { _initializing_addons = false; } - VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true); - VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true); - VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true); feature_profile_manager->notify_changed(); @@ -511,7 +515,9 @@ void EditorNode::_notification(int p_what) { p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon("HelpSearch", "EditorIcons")); p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon("Instance", "EditorIcons")); p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ISSUES), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon("Instance", "EditorIcons")); p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon("Instance", "EditorIcons")); p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); @@ -861,7 +867,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->set_current_path(p_resource->get_path()); if (extensions.size()) { String ext = p_resource->get_path().get_extension().to_lower(); - if (extensions.find(ext) == NULL) { + if (extensions.find(ext) == nullptr) { file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get())); } } @@ -1118,7 +1124,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { EditorProgress save("save", TTR("Saving Scene"), 4); - if (editor_data.get_edited_scene_root() != NULL) { + if (editor_data.get_edited_scene_root() != nullptr) { save.step(TTR("Analyzing"), 0); int c2d = 0; @@ -1557,7 +1563,7 @@ void EditorNode::_dialog_action(String p_file) { save_resource_in_path(saving_resource, p_file); saving_resource = Ref<Resource>(); ObjectID current = editor_history.get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!current_obj); current_obj->_change_notify(); } break; @@ -1703,10 +1709,10 @@ void EditorNode::edit_item(Object *p_object) { void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) { if (!p_object) { - get_inspector()->edit(NULL); - node_dock->set_node(NULL); - scene_tree_dock->set_selected(NULL); - inspector_dock->update(NULL); + get_inspector()->edit(nullptr); + node_dock->set_node(nullptr); + scene_tree_dock->set_selected(nullptr); + inspector_dock->update(nullptr); return; } @@ -1767,17 +1773,17 @@ static bool overrides_external_editor(Object *p_object) { void EditorNode::_edit_current() { ObjectID current = editor_history.get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; bool inspector_only = editor_history.is_current_inspector_only(); this->current = current_obj; if (!current_obj) { - scene_tree_dock->set_selected(NULL); - get_inspector()->edit(NULL); - node_dock->set_node(NULL); - inspector_dock->update(NULL); + scene_tree_dock->set_selected(nullptr); + get_inspector()->edit(nullptr); + node_dock->set_node(nullptr); + inspector_dock->update(nullptr); _display_top_editors(false); @@ -1798,9 +1804,9 @@ void EditorNode::_edit_current() { Resource *current_res = Object::cast_to<Resource>(current_obj); ERR_FAIL_COND(!current_res); get_inspector()->edit(current_res); - scene_tree_dock->set_selected(NULL); - node_dock->set_node(NULL); - inspector_dock->update(NULL); + scene_tree_dock->set_selected(nullptr); + node_dock->set_node(nullptr); + inspector_dock->update(nullptr); EditorNode::get_singleton()->get_import_dock()->set_edit_path(current_res->get_path()); int subr_idx = current_res->get_path().find("::"); @@ -1829,9 +1835,9 @@ void EditorNode::_edit_current() { scene_tree_dock->set_selected(current_node); inspector_dock->update(current_node); } else { - node_dock->set_node(NULL); - scene_tree_dock->set_selected(NULL); - inspector_dock->update(NULL); + node_dock->set_node(nullptr); + scene_tree_dock->set_selected(nullptr); + inspector_dock->update(nullptr); } if (get_edited_scene() && get_edited_scene()->get_filename() != String()) { @@ -1843,7 +1849,7 @@ void EditorNode::_edit_current() { } else { - Node *selected_node = NULL; + Node *selected_node = nullptr; if (current_obj->is_class("EditorDebuggerRemoteObject")) { editable_warning = TTR("This is a remote object, so changes to it won't be kept.\nPlease read the documentation relevant to debugging to better understand this workflow."); @@ -1872,9 +1878,9 @@ void EditorNode::_edit_current() { } get_inspector()->edit(current_obj); - node_dock->set_node(NULL); + node_dock->set_node(nullptr); scene_tree_dock->set_selected(selected_node); - inspector_dock->update(NULL); + inspector_dock->update(nullptr); } if (current_obj == prev_inspected_object) { @@ -1900,7 +1906,7 @@ void EditorNode::_edit_current() { for (int i = 0; i < editor_table.size(); i++) { if (editor_table[i] == main_plugin && !main_editor_buttons[i]->is_visible()) { - main_plugin = NULL; //if button is not visible, then no plugin active + main_plugin = nullptr; //if button is not visible, then no plugin active } } @@ -2229,7 +2235,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->set_current_path(scene->get_filename()); if (extensions.size()) { String ext = scene->get_filename().get_extension().to_lower(); - if (extensions.find(ext) == NULL) { + if (extensions.find(ext) == nullptr) { file->set_current_path(scene->get_filename().replacen("." + ext, "." + extensions.front()->get())); } } @@ -2629,9 +2635,12 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case HELP_QA: { OS::get_singleton()->shell_open("https://godotengine.org/qa/"); } break; - case HELP_ISSUES: { + case HELP_REPORT_A_BUG: { OS::get_singleton()->shell_open("https://github.com/godotengine/godot/issues"); } break; + case HELP_SEND_DOCS_FEEDBACK: { + OS::get_singleton()->shell_open("https://github.com/godotengine/godot-docs/issues"); + } break; case HELP_COMMUNITY: { OS::get_singleton()->shell_open("https://godotengine.org/community"); } break; @@ -2739,7 +2748,7 @@ void EditorNode::_discard_changes(const String &p_str) { case SCENE_TAB_CLOSE: { Node *scene = editor_data.get_edited_scene_root(tab_closing); - if (scene != NULL) { + if (scene != nullptr) { String scene_filename = scene->get_filename(); if (scene_filename != "") { previous_scenes.push_back(scene_filename); @@ -3119,7 +3128,7 @@ Dictionary EditorNode::_get_main_scene_state() { void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { - if (get_edited_scene() != p_for_scene && p_for_scene != NULL) + if (get_edited_scene() != p_for_scene && p_for_scene != nullptr) return; //not for this scene changing_scene = false; @@ -3414,7 +3423,7 @@ void EditorNode::open_request(const String &p_path) { if (!opening_prev) { List<String>::Element *prev_scene = previous_scenes.find(p_path); - if (prev_scene != NULL) { + if (prev_scene != nullptr) { prev_scene->erase(); } } @@ -3636,7 +3645,7 @@ void EditorNode::stop_child_process(OS::ProcessID p_pid) { } Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) const { - ERR_FAIL_COND_V(!p_object, NULL); + ERR_FAIL_COND_V(!p_object, nullptr); Ref<Script> script = p_object->get_script(); @@ -3663,7 +3672,7 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons } } - return NULL; + return nullptr; } StringName EditorNode::get_object_custom_type_name(const Object *p_object) const { @@ -3709,11 +3718,11 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons return icon; } } - return NULL; + return nullptr; } Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { - ERR_FAIL_COND_V(!p_object || !gui_base, NULL); + ERR_FAIL_COND_V(!p_object || !gui_base, nullptr); Ref<Script> script = p_object->get_script(); if (script.is_null() && p_object->is_class("Script")) { @@ -3754,11 +3763,11 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String if (p_fallback.length()) return gui_base->get_theme_icon(p_fallback, "EditorIcons"); - return NULL; + return nullptr; } Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { - ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty."); + ERR_FAIL_COND_V_MSG(p_class.empty(), nullptr, "Class name cannot be empty."); if (gui_base->has_theme_icon(p_class, "EditorIcons")) { return gui_base->get_theme_icon(p_class, "EditorIcons"); @@ -3775,7 +3784,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p while (script.is_valid()) { String current_icon_path; - script->get_language()->get_global_class_name(script->get_path(), NULL, ¤t_icon_path); + script->get_language()->get_global_class_name(script->get_path(), nullptr, ¤t_icon_path); icon = _load_custom_class_icon(current_icon_path); if (icon.is_valid()) { return icon; @@ -3805,7 +3814,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons")) return gui_base->get_theme_icon(p_fallback, "EditorIcons"); - return NULL; + return nullptr; } void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) { @@ -4403,7 +4412,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String String name = names[j]; //find it, in a horribly inefficient way int atidx = -1; - Control *node = NULL; + Control *node = nullptr; for (int k = 0; k < DOCK_SLOT_MAX; k++) { if (!dock_slot[k]->has_node(name)) continue; @@ -4969,7 +4978,7 @@ void EditorNode::add_control_to_dock(DockSlot p_slot, Control *p_control) { void EditorNode::remove_control_from_dock(Control *p_control) { - Control *dock = NULL; + Control *dock = nullptr; for (int i = 0; i < DOCK_SLOT_MAX; i++) { if (p_control->get_parent() == dock_slot[i]) { dock = dock_slot[i]; @@ -5092,7 +5101,7 @@ void EditorNode::add_tool_menu_item(const String &p_name, Object *p_handler, con void EditorNode::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) { ERR_FAIL_NULL(p_submenu); - ERR_FAIL_COND(p_submenu->get_parent() != NULL); + ERR_FAIL_COND(p_submenu->get_parent() != nullptr); tool_menu->add_child(p_submenu); tool_menu->add_submenu_item(p_name, p_submenu->get_name(), TOOLS_CUSTOM); @@ -5479,7 +5488,7 @@ void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_err static void _execute_thread(void *p_ud) { EditorNode::ExecuteThreadArgs *eta = (EditorNode::ExecuteThreadArgs *)p_ud; - Error err = OS::get_singleton()->execute(eta->path, eta->args, true, NULL, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex); + Error err = OS::get_singleton()->execute(eta->path, eta->args, true, nullptr, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex); print_verbose("Thread exit status: " + itos(eta->exitcode)); if (err != OK) { eta->exitcode = err; @@ -5542,12 +5551,12 @@ EditorNode::EditorNode() { InputFilter::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; - VisualServer::get_singleton()->set_debug_generate_wireframes(true); + RenderingServer::get_singleton()->set_debug_generate_wireframes(true); - NavigationServer::get_singleton()->set_active(false); // no nav by default if editor + NavigationServer3D::get_singleton()->set_active(false); // no nav by default if editor - PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor - Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor + PhysicsServer3D::get_singleton()->set_active(false); // no physics by default if editor + PhysicsServer2D::get_singleton()->set_active(false); // no physics by default if editor ScriptServer::set_scripting_enabled(false); // no scripting by default if editor EditorHelp::generate_doc(); //before any editor classes are created @@ -6023,7 +6032,7 @@ EditorNode::EditorNode() { scene_root = memnew(SubViewport); //scene_root->set_usage(Viewport::USAGE_2D); canvas BG mode prevents usage of this as 2D - VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); @@ -6259,7 +6268,8 @@ EditorNode::EditorNode() { p->add_separator(); p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Docs")), HELP_DOCS); p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Q&A")), HELP_QA); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/issue_tracker", TTR("Issue Tracker")), HELP_ISSUES); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); p->add_separator(); p->add_icon_shortcut(gui_base->get_theme_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About")), HELP_ABOUT); @@ -6699,7 +6709,7 @@ EditorNode::EditorNode() { update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn(); update_spinner_step = 0; - editor_plugin_screen = NULL; + editor_plugin_screen = nullptr; editor_plugins_over = memnew(EditorPluginList); editor_plugins_force_over = memnew(EditorPluginList); editor_plugins_force_input_forwarding = memnew(EditorPluginList); @@ -6710,7 +6720,7 @@ EditorNode::EditorNode() { EditorExport::get_singleton()->add_export_plugin(export_text_to_binary_plugin); _edit_current(); - current = NULL; + current = nullptr; saving_resource = Ref<Resource>(); reference_resource_mem = true; @@ -6727,7 +6737,7 @@ EditorNode::EditorNode() { saved_version = 1; unsaved_cache = true; - _last_instanced_scene = NULL; + _last_instanced_scene = nullptr; quick_open = memnew(EditorQuickOpen); gui_base->add_child(quick_open); diff --git a/editor/editor_node.h b/editor/editor_node.h index 9d251690d2..c6f04b0749 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -194,7 +194,8 @@ private: HELP_SEARCH, HELP_DOCS, HELP_QA, - HELP_ISSUES, + HELP_REPORT_A_BUG, + HELP_SEND_DOCS_FEEDBACK, HELP_COMMUNITY, HELP_ABOUT, diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 2cafbe3cca..746ebc8292 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -41,7 +41,7 @@ #include "plugins/node_3d_editor_plugin.h" #include "scene/3d/camera_3d.h" #include "scene/gui/popup_menu.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) { @@ -51,7 +51,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ meshes.push_back(p_meshes[i]); } - Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, NULL, p_preview_size); + Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, nullptr, p_preview_size); Array ret; for (int i = 0; i < textures.size(); i++) { ret.push_back(textures[i]); @@ -64,25 +64,25 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh int size = p_preview_size; - RID scenario = VS::get_singleton()->scenario_create(); + RID scenario = RS::get_singleton()->scenario_create(); - RID viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ALWAYS); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, size, size); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - RID viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + RID viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, size, size); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - RID camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); + RID camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); - RID light = VS::get_singleton()->directional_light_create(); - RID light_instance = VS::get_singleton()->instance_create2(light, scenario); + RID light = RS::get_singleton()->directional_light_create(); + RID light_instance = RS::get_singleton()->instance_create2(light, scenario); - RID light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + RID light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size()); @@ -97,12 +97,12 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh } Transform mesh_xform; - if (p_transforms != NULL) { + if (p_transforms != nullptr) { mesh_xform = (*p_transforms)[i]; } - RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(), scenario); - VS::get_singleton()->instance_set_transform(inst, mesh_xform); + RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario); + RS::get_singleton()->instance_set_transform(inst, mesh_xform); AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; @@ -121,32 +121,32 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh xform.invert(); xform = mesh_xform * xform; - VS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); - VS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); + RS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); - VS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); - VS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); ep.step(TTR("Thumbnail..."), i); Main::iteration(); Main::iteration(); - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_CONTINUE(!img.is_valid() || img->empty()); Ref<ImageTexture> it(memnew(ImageTexture)); it->create_from_image(img); - VS::get_singleton()->free(inst); + RS::get_singleton()->free(inst); textures.push_back(it); } - VS::get_singleton()->free(viewport); - VS::get_singleton()->free(light); - VS::get_singleton()->free(light_instance); - VS::get_singleton()->free(light2); - VS::get_singleton()->free(light_instance2); - VS::get_singleton()->free(camera); - VS::get_singleton()->free(scenario); + RS::get_singleton()->free(viewport); + RS::get_singleton()->free(light); + RS::get_singleton()->free(light_instance); + RS::get_singleton()->free(light2); + RS::get_singleton()->free(light_instance2); + RS::get_singleton()->free(camera); + RS::get_singleton()->free(scenario); return textures; } @@ -194,7 +194,7 @@ Array EditorInterface::get_open_scenes() const { int scns_amount = scenes.size(); for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) { - if (scenes[idx_scn].root == NULL) + if (scenes[idx_scn].root == nullptr) continue; ret.push_back(scenes[idx_scn].root->get_filename()); } @@ -278,7 +278,7 @@ void EditorInterface::set_distraction_free_mode(bool p_enter) { EditorNode::get_singleton()->set_distraction_free_mode(p_enter); } -EditorInterface *EditorInterface::singleton = NULL; +EditorInterface *EditorInterface::singleton = nullptr; void EditorInterface::_bind_methods() { @@ -337,7 +337,7 @@ void EditorPlugin::remove_autoload_singleton(const String &p_name) { } ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) { - ERR_FAIL_NULL_V(p_control, NULL); + ERR_FAIL_NULL_V(p_control, nullptr); return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control); } @@ -914,7 +914,7 @@ void EditorPlugin::_bind_methods() { } EditorPlugin::EditorPlugin() : - undo_redo(NULL), + undo_redo(nullptr), input_event_forwarding_always_enabled(false), force_draw_over_forwarding_enabled(false), last_main_screen_name("") { diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 12b042d0e5..2ca96ceed2 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -268,7 +268,7 @@ class EditorPlugins { public: static int get_plugin_count() { return creation_func_count; } static EditorPlugin *create(int p_idx, EditorNode *p_editor) { - ERR_FAIL_INDEX_V(p_idx, creation_func_count, NULL); + ERR_FAIL_INDEX_V(p_idx, creation_func_count, nullptr); return creation_funcs[p_idx](p_editor); } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index af83e808fc..1f3ff1b332 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -165,8 +165,8 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() { open_big_text = memnew(ToolButton); open_big_text->connect("pressed", callable_mp(this, &EditorPropertyMultilineText::_open_big_text)); hb->add_child(open_big_text); - big_text_dialog = NULL; - big_text = NULL; + big_text_dialog = nullptr; + big_text = nullptr; } ///////////////////// TEXT ENUM ///////////////////////// @@ -303,7 +303,7 @@ EditorPropertyPath::EditorPropertyPath() { path_edit->set_clip_text(true); path_hb->add_child(path_edit); add_focusable(path); - dialog = NULL; + dialog = nullptr; path_edit->connect("pressed", callable_mp(this, &EditorPropertyPath::_path_pressed)); folder = false; global = false; @@ -448,7 +448,7 @@ void EditorPropertyMember::_bind_methods() { } EditorPropertyMember::EditorPropertyMember() { - selector = NULL; + selector = nullptr; property = memnew(Button); property->set_clip_text(true); add_child(property); @@ -1882,7 +1882,7 @@ EditorPropertyColor::EditorPropertyColor() { void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { NodePath path = p_path; - Node *base_node = NULL; + Node *base_node = nullptr; if (!use_path_from_scene_root) { base_node = Object::cast_to<Node>(get_edited_object()); @@ -1945,7 +1945,7 @@ void EditorPropertyNodePath::update_property() { } assign->set_flat(true); - Node *base_node = NULL; + Node *base_node = nullptr; if (base_hint != NodePath()) { if (get_tree()->get_root()->has_node(base_hint)) { base_node = get_tree()->get_root()->get_node(base_hint); @@ -2008,7 +2008,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { hbc->add_child(clear); use_path_from_scene_root = false; - scene_tree = NULL; //do not allocate unnecessarily + scene_tree = nullptr; //do not allocate unnecessarily } ///////////////////// RID ///////////////////////// @@ -2248,7 +2248,7 @@ void EditorPropertyResource::_menu_option(int p_which) { return; } - Object *obj = NULL; + Object *obj = nullptr; if (ScriptServer::is_global_class(intype)) { obj = ClassDB::instance(ScriptServer::get_global_class_native_base(intype)); @@ -2598,10 +2598,10 @@ void EditorPropertyResource::update_property() { sub_inspector->refresh(); } else { if (sub_inspector) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(sub_inspector_vbox); - sub_inspector = NULL; - sub_inspector_vbox = NULL; + sub_inspector = nullptr; + sub_inspector_vbox = nullptr; if (opened_editor) { EditorNode::get_singleton()->hide_top_editors(); opened_editor = false; @@ -2823,8 +2823,8 @@ void EditorPropertyResource::_bind_methods() { EditorPropertyResource::EditorPropertyResource() { opened_editor = false; - sub_inspector = NULL; - sub_inspector_vbox = NULL; + sub_inspector = nullptr; + sub_inspector_vbox = nullptr; use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector")); HBoxContainer *hbc = memnew(HBoxContainer); @@ -2860,8 +2860,8 @@ EditorPropertyResource::EditorPropertyResource() { edit->connect("gui_input", callable_mp(this, &EditorPropertyResource::_button_input)); add_focusable(edit); - file = NULL; - scene_tree = NULL; + file = nullptr; + scene_tree = nullptr; dropping = false; add_to_group("_editor_resource_properties"); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 13eb2e19d6..b4ce60171b 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -199,7 +199,7 @@ void EditorPropertyArray::_change_type_menu(int p_index) { Variant value; Callable::CallError ce; - value = Variant::construct(Variant::Type(p_index), NULL, 0, ce); + value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); Variant array = object->get_array(); array.set(changing_type_idx, value); @@ -263,9 +263,9 @@ void EditorPropertyArray::update_property() { edit->set_text(String("(Nil) ") + arrtype); edit->set_pressed(false); if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } return; } @@ -340,7 +340,7 @@ void EditorPropertyArray::update_property() { for (int i = 0; i < amount; i++) { String prop_name = "indices/" + itos(i + offset); - EditorProperty *prop = NULL; + EditorProperty *prop = nullptr; Variant value = array.get(i + offset); Variant::Type value_type = value.get_type(); @@ -353,7 +353,7 @@ void EditorPropertyArray::update_property() { editor->setup("Object"); prop = editor; } else { - prop = EditorInspector::instantiate_property_editor(NULL, value_type, "", subtype_hint, subtype_hint_string, 0); + prop = EditorInspector::instantiate_property_editor(nullptr, value_type, "", subtype_hint, subtype_hint_string, 0); } prop->set_object_and_property(object.ptr(), prop_name); @@ -391,9 +391,9 @@ void EditorPropertyArray::update_property() { } else { if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } } } @@ -419,7 +419,7 @@ void EditorPropertyArray::_edit_pressed() { Variant array = get_edited_object()->get(get_edited_property()); if (!array.is_array()) { Callable::CallError ce; - array = Variant::construct(array_type, NULL, 0, ce); + array = Variant::construct(array_type, nullptr, 0, ce); get_edited_object()->set(get_edited_property(), array); } @@ -450,7 +450,7 @@ void EditorPropertyArray::_length_changed(double p_page) { for (int i = previous_size; i < size; i++) { if (array.get(i).get_type() == Variant::NIL) { Callable::CallError ce; - array.set(i, Variant::construct(subtype, NULL, 0, ce)); + array.set(i, Variant::construct(subtype, nullptr, 0, ce)); } } } @@ -460,7 +460,7 @@ void EditorPropertyArray::_length_changed(double p_page) { // Pool*Array don't initialize their elements, have to do it manually for (int i = previous_size; i < size; i++) { Callable::CallError ce; - array.set(i, Variant::construct(array.get(i).get_type(), NULL, 0, ce)); + array.set(i, Variant::construct(array.get(i).get_type(), nullptr, 0, ce)); } } @@ -505,9 +505,9 @@ EditorPropertyArray::EditorPropertyArray() { edit->set_toggle_mode(true); add_child(edit); add_focusable(edit); - vbox = NULL; - page = NULL; - length = NULL; + vbox = nullptr; + page = nullptr; + length = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); @@ -585,7 +585,7 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { if (changing_type_idx < 0) { Variant value; Callable::CallError ce; - value = Variant::construct(Variant::Type(p_index), NULL, 0, ce); + value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); if (changing_type_idx == -1) { object->set_new_item_key(value); } else { @@ -601,7 +601,7 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { Variant value; Callable::CallError ce; - value = Variant::construct(Variant::Type(p_index), NULL, 0, ce); + value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); Variant key = dict.get_key_at_index(changing_type_idx); dict[key] = value; } else { @@ -624,9 +624,9 @@ void EditorPropertyDictionary::update_property() { edit->set_text("Dictionary (Nil)"); //This provides symmetry with the array property. edit->set_pressed(false); if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } return; } @@ -683,7 +683,7 @@ void EditorPropertyDictionary::update_property() { dict = dict.duplicate(); object->set_dict(dict); - VBoxContainer *add_vbox = NULL; + VBoxContainer *add_vbox = nullptr; for (int i = 0; i < amount + 2; i++) { String prop_name; @@ -702,7 +702,7 @@ void EditorPropertyDictionary::update_property() { value = object->get_new_item_value(); } - EditorProperty *prop = NULL; + EditorProperty *prop = nullptr; switch (value.get_type()) { case Variant::NIL: { @@ -962,9 +962,9 @@ void EditorPropertyDictionary::update_property() { } else { if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } } } @@ -981,7 +981,7 @@ void EditorPropertyDictionary::_edit_pressed() { Variant prop_val = get_edited_object()->get(get_edited_property()); if (prop_val.get_type() == Variant::NIL) { Callable::CallError ce; - prop_val = Variant::construct(Variant::DICTIONARY, NULL, 0, ce); + prop_val = Variant::construct(Variant::DICTIONARY, nullptr, 0, ce); get_edited_object()->set(get_edited_property(), prop_val); } @@ -1012,8 +1012,8 @@ EditorPropertyDictionary::EditorPropertyDictionary() { edit->set_toggle_mode(true); add_child(edit); add_focusable(edit); - vbox = NULL; - page = NULL; + vbox = nullptr; + page = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 398850f2d6..2a4300f833 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -99,7 +99,7 @@ void EditorResourcePreviewGenerator::_bind_methods() { EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() { } -EditorResourcePreview *EditorResourcePreview::singleton = NULL; +EditorResourcePreview *EditorResourcePreview::singleton = nullptr; void EditorResourcePreview::_thread_func(void *ud) { @@ -465,16 +465,16 @@ void EditorResourcePreview::stop() { preview_sem.post(); while (!exited) { OS::get_singleton()->delay_usec(10000); - VisualServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server + RenderingServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server } Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } } EditorResourcePreview::EditorResourcePreview() { - thread = NULL; + thread = nullptr; singleton = this; order = 0; exit = false; diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp index 628055cac6..c03fd4f6f5 100644 --- a/editor/editor_run_script.cpp +++ b/editor/editor_run_script.cpp @@ -56,7 +56,7 @@ Node *EditorScript::get_scene() { if (!editor) { EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method.")); - return NULL; + return nullptr; } return editor->get_edited_scene(); @@ -73,7 +73,7 @@ void EditorScript::_run() { Callable::CallError ce; ce.error = Callable::CallError::CALL_OK; - get_script_instance()->call("_run", NULL, 0, ce); + get_script_instance()->call("_run", nullptr, 0, ce); if (ce.error != Callable::CallError::CALL_OK) { EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?")); @@ -95,5 +95,5 @@ void EditorScript::_bind_methods() { EditorScript::EditorScript() { - editor = NULL; + editor = nullptr; } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 2c895a3e9d..bccc38ca1b 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -127,7 +127,7 @@ public: } SectionedInspectorFilter() { - edited = NULL; + edited = nullptr; } }; @@ -142,7 +142,7 @@ void SectionedInspector::_section_selected() { return; selected_category = sections->get_selected()->get_metadata(0); - filter->set_section(selected_category, sections->get_selected()->get_children() == NULL); + filter->set_section(selected_category, sections->get_selected()->get_children() == nullptr); inspector->set_property_prefix(selected_category + "/"); } @@ -177,8 +177,8 @@ void SectionedInspector::edit(Object *p_object) { obj = ObjectID(); sections->clear(); - filter->set_edited(NULL); - inspector->edit(NULL); + filter->set_edited(nullptr); + inspector->edit(nullptr); return; } @@ -308,7 +308,7 @@ SectionedInspector::SectionedInspector() : sections(memnew(Tree)), filter(memnew(SectionedInspectorFilter)), inspector(memnew(EditorInspector)), - search_box(NULL) { + search_box(nullptr) { add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up VBoxContainer *left_vb = memnew(VBoxContainer); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 286ca7b184..7ce6e3edb8 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -53,7 +53,7 @@ // PRIVATE METHODS -Ref<EditorSettings> EditorSettings::singleton = NULL; +Ref<EditorSettings> EditorSettings::singleton = nullptr; // Properties @@ -177,7 +177,7 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { _THREAD_SAFE_METHOD_ - const String *k = NULL; + const String *k = nullptr; Set<_EVCSort> vclist; while ((k = props.next(k))) { @@ -778,7 +778,7 @@ void EditorSettings::create() { if (singleton.ptr()) return; //pointless - DirAccess *dir = NULL; + DirAccess *dir = nullptr; String data_path; String data_dir; @@ -1524,7 +1524,7 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) { Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) { if (!EditorSettings::get_singleton()) { - return NULL; + return nullptr; } Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 2c115c66cb..4eefe844d2 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -362,7 +362,7 @@ void EditorSpinSlider::_evaluate_input_text() { return; } - Variant v = expr->execute(Array(), NULL, false); + Variant v = expr->execute(Array(), nullptr, false); if (v.get_type() == Variant::NIL) return; set_value(v); diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index cd5768551f..1205e0b37c 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -46,7 +46,7 @@ void EditorSubScene::_path_changed(const String &p_path) { if (scene) { memdelete(scene); - scene = NULL; + scene = nullptr; } if (p_path == "") @@ -61,7 +61,7 @@ void EditorSubScene::_path_changed(const String &p_path) { if (!scene) return; - _fill_tree(scene, NULL); + _fill_tree(scene, nullptr); } void EditorSubScene::_path_browse() { @@ -72,7 +72,7 @@ void EditorSubScene::_path_browse() { void EditorSubScene::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible() && scene == NULL) { + if (is_visible() && scene == nullptr) { _path_browse(); } } @@ -209,7 +209,7 @@ void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { if (!is_root) { memdelete(scene); } - scene = NULL; + scene = nullptr; //return selnode; } @@ -226,7 +226,7 @@ void EditorSubScene::_bind_methods() { EditorSubScene::EditorSubScene() { - scene = NULL; + scene = nullptr; is_root = false; set_title(TTR("Select Node(s) to Import")); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index ac902854b7..663068b2b5 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -248,7 +248,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = } } - ImageLoaderSVG::set_convert_colors(NULL); + ImageLoaderSVG::set_convert_colors(nullptr); #else WARN_PRINT("SVG support disabled, editor icons won't be rendered."); #endif @@ -418,7 +418,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 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) { + if (p_theme != nullptr && 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")); @@ -427,7 +427,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { editor_register_and_generate_icons(theme, dark_theme, thumb_size); } // thumbnail size has changed, so we regenerate the medium sizes - if (p_theme != NULL && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { + if (p_theme != nullptr && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true); } diff --git a/editor/editor_themes.h b/editor/editor_themes.h index 6e9630804f..4d9bfc56c8 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -33,8 +33,8 @@ #include "scene/resources/theme.h" -Ref<Theme> create_editor_theme(Ref<Theme> p_theme = NULL); +Ref<Theme> create_editor_theme(Ref<Theme> p_theme = nullptr); -Ref<Theme> create_custom_theme(Ref<Theme> p_theme = NULL); +Ref<Theme> create_custom_theme(Ref<Theme> p_theme = nullptr); #endif diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index c420cf44e7..6f3a8d9ea7 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -30,7 +30,7 @@ #include "editor_vcs_interface.h" -EditorVCSInterface *EditorVCSInterface::singleton = NULL; +EditorVCSInterface *EditorVCSInterface::singleton = nullptr; void EditorVCSInterface::_bind_methods() { diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 61ec9c44c2..7cb18432a7 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -184,7 +184,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ // unzClose() will take care of closing the file stored in the unzFile, // so we don't need to `memdelete(fa)` in this method. - FileAccess *fa = NULL; + FileAccess *fa = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&fa); unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); @@ -203,7 +203,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String file = fname; @@ -258,7 +258,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ ret = unzGoToFirstFile(pkg); - EditorProgress *p = NULL; + EditorProgress *p = nullptr; if (p_use_progress) { p = memnew(EditorProgress("ltask", TTR("Extracting Export Templates"), fc)); } @@ -270,7 +270,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ //get filename unz_file_info info; char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String file_path(String(fname).simplify_path()); @@ -587,7 +587,7 @@ Error ExportTemplateManager::install_android_template() { const String &source_zip = templates_path.plus_file("android_source.zip"); ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io); @@ -611,7 +611,7 @@ Error ExportTemplateManager::install_android_template() { // Get file path. unz_file_info info; char fpath[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, nullptr, 0, nullptr, 0); String path = fpath; String base_dir = path.get_base_dir(); diff --git a/editor/fileserver/SCsub b/editor/fileserver/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/fileserver/SCsub +++ b/editor/fileserver/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index e1fcddda3a..236ae16ccf 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -843,7 +843,7 @@ void FileSystemDock::_tree_activate_file() { if (selected) { String path = selected->get_metadata(0); TreeItem *parent = selected->get_parent(); - bool is_favorite = parent != NULL && parent->get_metadata(0) == "Favorites"; + bool is_favorite = parent != nullptr && parent->get_metadata(0) == "Favorites"; if ((!is_favorite && path.ends_with("/")) || path == "Favorites") { bool collapsed = selected->is_collapsed(); @@ -955,7 +955,7 @@ void FileSystemDock::_push_to_history() { } void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const { - if (efsd == NULL) + if (efsd == nullptr) return; for (int i = 0; i < efsd->get_subdir_count(); i++) { @@ -1871,7 +1871,7 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) return Variant(); } - bool is_favorite = selected->get_parent() != NULL && tree->get_root()->get_children() == selected->get_parent(); + bool is_favorite = selected->get_parent() != nullptr && tree->get_root()->get_children() == selected->get_parent(); all_favorites &= is_favorite; all_not_favorites &= !is_favorite; selected = tree->get_next_selected(selected); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 61afc9115f..d73180c831 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -708,7 +708,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin TreeItem *file_item; Map<String, TreeItem *>::Element *E = _file_items.find(fpath); - if (E == NULL) { + if (E == nullptr) { file_item = _results_display->create_item(); file_item->set_text(0, fpath); file_item->set_metadata(0, fpath); @@ -813,7 +813,7 @@ void FindInFilesPanel::_on_result_selected() { TreeItem *item = _results_display->get_selected(); Map<TreeItem *, Result>::Element *E = _result_items.find(item); - if (E == NULL) + if (E == nullptr) return; Result r = E->value(); @@ -845,7 +845,7 @@ void FindInFilesPanel::_on_replace_all_clicked() { continue; Map<TreeItem *, Result>::Element *F = _result_items.find(item); - ERR_FAIL_COND(F == NULL); + ERR_FAIL_COND(F == nullptr); locations.push_back(F->value()); } diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 686ca869a6..7e5d2e87d6 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -68,7 +68,7 @@ void GroupDialog::_load_nodes(Node *p_current) { keep = false; } - TreeItem *node = NULL; + TreeItem *node = nullptr; NodePath path = scene_tree->get_edited_scene_root()->get_path_to(p_current); if (keep && p_current->is_in_group(selected_group)) { if (remove_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) { @@ -122,7 +122,7 @@ bool GroupDialog::_can_edit(Node *p_node, String p_group) { } void GroupDialog::_add_pressed() { - TreeItem *selected = nodes_to_add->get_next_selected(NULL); + TreeItem *selected = nodes_to_add->get_next_selected(nullptr); if (!selected) { return; @@ -151,7 +151,7 @@ void GroupDialog::_add_pressed() { } void GroupDialog::_removed_pressed() { - TreeItem *selected = nodes_to_remove->get_next_selected(NULL); + TreeItem *selected = nodes_to_remove->get_next_selected(nullptr); if (!selected) { return; @@ -662,7 +662,7 @@ void GroupsEditor::_bind_methods() { GroupsEditor::GroupsEditor() { - node = NULL; + node = nullptr; VBoxContainer *vbc = this; diff --git a/editor/icons/GizmoCPUParticles.svg b/editor/icons/GizmoCPUParticles3D.svg index d4e86d9c42..d4e86d9c42 100644 --- a/editor/icons/GizmoCPUParticles.svg +++ b/editor/icons/GizmoCPUParticles3D.svg diff --git a/editor/icons/GizmoParticles.svg b/editor/icons/GizmoGPUParticles3D.svg index 1c5d8c5f2d..1c5d8c5f2d 100644 --- a/editor/icons/GizmoParticles.svg +++ b/editor/icons/GizmoGPUParticles3D.svg diff --git a/editor/icons/SCsub b/editor/icons/SCsub index b39c74c66a..f0d51999f0 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -1,21 +1,21 @@ #!/usr/bin/env python -Import('env') +Import("env") from platform_methods import run_in_subprocess import editor_icons_builders -make_editor_icons_builder = Builder(action=run_in_subprocess(editor_icons_builders.make_editor_icons_action), - suffix='.h', - src_suffix='.svg') +make_editor_icons_builder = Builder( + action=run_in_subprocess(editor_icons_builders.make_editor_icons_action), suffix=".h", src_suffix=".svg" +) -env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder +env["BUILDERS"]["MakeEditorIconsBuilder"] = make_editor_icons_builder # Editor's own icons icon_sources = Glob("*.svg") # Module icons for module_icons in env.module_icons_paths: - icon_sources += Glob('#' + module_icons + "/*.svg") + icon_sources += Glob("#" + module_icons + "/*.svg") -env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#editor/editor_icons.gen.h', icon_sources)]) +env.Alias("editor_icons", [env.MakeEditorIconsBuilder("#editor/editor_icons.gen.h", icon_sources)]) diff --git a/editor/icons/SubViewport.svg b/editor/icons/SubViewport.svg new file mode 100644 index 0000000000..103b1006ad --- /dev/null +++ b/editor/icons/SubViewport.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 2c-.5304.0000801-1.0390625.2108475-1.4140625.5859375-.37509.37501-.5858575.8836225-.5859375 1.4140625v8c.0000803.5304.2108475 1.039063.5859375 1.414062.37501.375091.8836225.585858 1.4140625.585938h10c1.1046 0 2-.89543 2-2v-8c0-1.1046-.89543-2-2-2zm0 1h10c.55228.0000096.99999.44772 1 1v8c-.00001.55228-.44772.99999-1 1h-10c-.55228-.00001-.99999-.44772-1-1v-8c.0000096-.55228.44772-.99999 1-1zm3 1c-.5304.0001-1.0390625.2108375-1.4140625.5859375-.37509.375-.5858575.8836225-.5859375 1.4140625v4c.00008.5304.2108475 1.039062.5859375 1.414062.37501.3751.8836225.585838 1.4140625.585938h4c1.1046 0 2-.8954 2-2v-4c0-1.1046-.89543-2-2-2zm0 1h4c.55228 0 .99999.4477 1 1v4c-.00001.5523-.44772 1-1 1h-4c-.55228 0-.99999-.4477-1-1v-4c.00001-.5523.44772-1 1-1z" fill="#e0e0e0" fill-opacity=".996078"/></svg>
\ No newline at end of file diff --git a/editor/icons/ViewportContainer.svg b/editor/icons/SubViewportContainer.svg index 18dcddc15f..18dcddc15f 100644 --- a/editor/icons/ViewportContainer.svg +++ b/editor/icons/SubViewportContainer.svg diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py index a00f21c265..d7145abe50 100644 --- a/editor/icons/editor_icons_builders.py +++ b/editor/icons/editor_icons_builders.py @@ -22,16 +22,16 @@ def make_editor_icons_action(target, source, env): icons_string.write('\t"') - with open(fname, 'rb') as svgf: + with open(fname, "rb") as svgf: b = svgf.read(1) - while(len(b) == 1): + while len(b) == 1: icons_string.write("\\" + str(hex(ord(b)))[1:]) b = svgf.read(1) icons_string.write('"') if fname != svg_icons[-1]: icons_string.write(",") - icons_string.write('\n') + icons_string.write("\n") s = StringIO() s.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") @@ -40,7 +40,7 @@ def make_editor_icons_action(target, source, env): s.write("static const int editor_icons_count = {};\n".format(len(svg_icons))) s.write("static const char *editor_icons_sources[] = {\n") s.write(icons_string.getvalue()) - s.write('};\n\n') + s.write("};\n\n") s.write("static const char *editor_icons_names[] = {\n") # this is used to store the indices of thumbnail icons @@ -63,11 +63,11 @@ def make_editor_icons_action(target, source, env): if fname != svg_icons[-1]: s.write(",") - s.write('\n') + s.write("\n") index += 1 - s.write('};\n') + s.write("};\n") if thumb_medium_indices: s.write("\n\n") @@ -91,5 +91,5 @@ def make_editor_icons_action(target, source, env): icons_string.close() -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/editor/import/SCsub b/editor/import/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/import/SCsub +++ b/editor/import/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 8ef9d17083..9e49fa9066 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -1540,7 +1540,7 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { } if (parser.is_empty()) //nothing else to parse... - return NULL; + return nullptr; while (parser.read() == OK) { @@ -1548,7 +1548,7 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { break; } - return NULL; + return nullptr; } Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { @@ -1572,7 +1572,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { String empty_draw_type = ""; - Node *node = NULL; + Node *node = nullptr; name = parser.has_attribute("name") ? parser.get_attribute_value_safe("name") : parser.get_attribute_value_safe("id"); if (name == "") { @@ -2140,7 +2140,7 @@ void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton NodeJoint *nj = static_cast<NodeJoint *>(node); nj->owner = p_skeleton; } else { - p_skeleton = NULL; + p_skeleton = nullptr; } for (int i = 0; i < node->children.size(); i++) { @@ -2240,7 +2240,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { SkinControllerData &cd = E->get(); - NodeSkeleton *skeleton = NULL; + NodeSkeleton *skeleton = nullptr; for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { @@ -2257,7 +2257,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { Node *node = state.scene_map[name]; ERR_CONTINUE(node->type != Node::TYPE_JOINT); - NodeSkeleton *sk = NULL; + NodeSkeleton *sk = nullptr; while (node && !sk) { diff --git a/editor/import/collada.h b/editor/import/collada.h index 4707d7d779..b74332fb22 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -404,7 +404,7 @@ public: Node() { noname = false; type = TYPE_NODE; - parent = NULL; + parent = nullptr; ignore_anim = false; } virtual ~Node() { @@ -424,7 +424,7 @@ public: String sid; NodeJoint() { type = TYPE_JOINT; - owner = NULL; + owner = nullptr; } }; @@ -631,7 +631,7 @@ private: // private stuff String _read_empty_draw_type(XMLParser &parser); void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner); - void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton = NULL); + void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton = nullptr); void _find_morph_nodes(VisualScene *p_vscene, Node *p_node); bool _remove_node(Node *p_parent, Node *p_node); void _remove_node(VisualScene *p_vscene, Node *p_node); diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index e67dd37b88..697ddfba96 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -58,7 +58,7 @@ struct ColladaImport { List<int> anim_tracks; NodeMap() { - node = NULL; + node = nullptr; bone = -1; } }; @@ -195,7 +195,7 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { - Node3D *node = NULL; + Node3D *node = nullptr; switch (p_node->type) { @@ -318,7 +318,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } else { //mesh since nothing else node = memnew(MeshInstance3D); - //Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + //Object::cast_to<MeshInstance3D>(node)->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true); } } break; case Collada::Node::TYPE_SKELETON: { @@ -536,7 +536,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me /* NORMAL SOURCE */ - const Collada::MeshData::Source *normal_src = NULL; + const Collada::MeshData::Source *normal_src = nullptr; int normal_ofs = 0; if (p.sources.has("NORMAL")) { @@ -547,7 +547,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me normal_src = &meshdata.sources[normal_source_id]; } - const Collada::MeshData::Source *binormal_src = NULL; + const Collada::MeshData::Source *binormal_src = nullptr; int binormal_ofs = 0; if (p.sources.has("TEXBINORMAL")) { @@ -558,7 +558,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me binormal_src = &meshdata.sources[binormal_source_id]; } - const Collada::MeshData::Source *tangent_src = NULL; + const Collada::MeshData::Source *tangent_src = nullptr; int tangent_ofs = 0; if (p.sources.has("TEXTANGENT")) { @@ -569,7 +569,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me tangent_src = &meshdata.sources[tangent_source_id]; } - const Collada::MeshData::Source *uv_src = NULL; + const Collada::MeshData::Source *uv_src = nullptr; int uv_ofs = 0; if (p.sources.has("TEXCOORD0")) { @@ -580,7 +580,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me uv_src = &meshdata.sources[uv_source_id]; } - const Collada::MeshData::Source *uv2_src = NULL; + const Collada::MeshData::Source *uv2_src = nullptr; int uv2_ofs = 0; if (p.sources.has("TEXCOORD1")) { @@ -591,7 +591,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me uv2_src = &meshdata.sources[uv2_source_id]; } - const Collada::MeshData::Source *color_src = NULL; + const Collada::MeshData::Source *color_src = nullptr; int color_ofs = 0; if (p.sources.has("COLOR")) { @@ -614,7 +614,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me if (p_skin_controller) { - const Collada::SkinControllerData::Source *weight_src = NULL; + const Collada::SkinControllerData::Source *weight_src = nullptr; int weight_ofs = 0; if (p_skin_controller->weights.sources.has("WEIGHT")) { @@ -922,10 +922,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me if (has_weights) { Vector<float> weights; Vector<int> bones; - weights.resize(VS::ARRAY_WEIGHTS_SIZE); - bones.resize(VS::ARRAY_WEIGHTS_SIZE); + weights.resize(RS::ARRAY_WEIGHTS_SIZE); + bones.resize(RS::ARRAY_WEIGHTS_SIZE); //float sum=0.0; - for (int l = 0; l < VS::ARRAY_WEIGHTS_SIZE; l++) { + for (int l = 0; l < RS::ARRAY_WEIGHTS_SIZE; l++) { if (l < vertex_array[k].weights.size()) { weights.write[l] = vertex_array[k].weights[l].weight; bones.write[l] = vertex_array[k].weights[l].bone_idx; @@ -963,7 +963,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me //////////////////////////// Array d = surftool->commit_to_arrays(); - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); Array mr; @@ -1047,7 +1047,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres const Collada::CurveData::Source &interps = cd.sources[cd.control_vertices["INTERPOLATION"]]; ERR_FAIL_COND_V(interps.stride != 1, ERR_INVALID_DATA); - const Collada::CurveData::Source *tilts = NULL; + const Collada::CurveData::Source *tilts = nullptr; if (cd.control_vertices.has("TILT") && cd.sources.has(cd.control_vertices["TILT"])) tilts = &cd.sources[cd.control_vertices["TILT"]]; @@ -1091,8 +1091,8 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres ERR_FAIL_COND_V(!mi, ERR_BUG); - Collada::SkinControllerData *skin = NULL; - Collada::MorphControllerData *morph = NULL; + Collada::SkinControllerData *skin = nullptr; + Collada::MorphControllerData *morph = nullptr; String meshid; Transform apply_xform; Vector<int> bone_remap; @@ -1173,7 +1173,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2]; mesh->set_name(meshdata.name); - Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh>>(), false); + Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, nullptr, Vector<Ref<ArrayMesh>>(), false); ERR_FAIL_COND_V(err, err); morphs.push_back(mesh); @@ -1777,7 +1777,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & EditorSceneImporter::IMPORT_USE_COMPRESSION); - ERR_FAIL_COND_V_MSG(err != OK, NULL, "Cannot load scene from file '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Cannot load scene from file '" + p_path + "'."); if (state.missing_textures.size()) { diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 822a6450be..932a064e76 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -40,7 +40,7 @@ class EditorSceneImporterCollada : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorSceneImporterCollada(); diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 4383b1b084..be4679b6d3 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -52,7 +52,7 @@ public: virtual int get_import_order() const; virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr); }; #endif //EDITOR_IMPORT_PLUGIN_H diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 208dc8fc26..6ad2aa4142 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1266,7 +1266,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } Vector<uint8_t> data; - const uint8_t *data_ptr = NULL; + const uint8_t *data_ptr = nullptr; int data_size = 0; if (d.has("uri")) { @@ -1307,7 +1307,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (mimetype.findn("png") != -1) { //is a png - ERR_FAIL_COND_V(Image::_png_mem_loader_func == NULL, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); const Ref<Image> img = Image::_png_mem_loader_func(data_ptr, data_size); @@ -1323,7 +1323,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (mimetype.findn("jpeg") != -1) { //is a jpg - ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == NULL, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); const Ref<Image> img = Image::_jpg_mem_loader_func(data_ptr, data_size); @@ -2985,19 +2985,19 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla //text file Error err = _parse_glb(p_path, state); if (err) - return NULL; + return nullptr; } else { //text file Error err = _parse_json(p_path, state); if (err) - return NULL; + return nullptr; } - ERR_FAIL_COND_V(!state.json.has("asset"), NULL); + ERR_FAIL_COND_V(!state.json.has("asset"), nullptr); Dictionary asset = state.json["asset"]; - ERR_FAIL_COND_V(!asset.has("version"), NULL); + ERR_FAIL_COND_V(!asset.has("version"), nullptr); String version = asset["version"]; @@ -3008,77 +3008,77 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla /* STEP 0 PARSE SCENE */ Error err = _parse_scenes(state); if (err != OK) - return NULL; + return nullptr; /* STEP 1 PARSE NODES */ err = _parse_nodes(state); if (err != OK) - return NULL; + return nullptr; /* STEP 2 PARSE BUFFERS */ err = _parse_buffers(state, p_path.get_base_dir()); if (err != OK) - return NULL; + return nullptr; /* STEP 3 PARSE BUFFER VIEWS */ err = _parse_buffer_views(state); if (err != OK) - return NULL; + return nullptr; /* STEP 4 PARSE ACCESSORS */ err = _parse_accessors(state); if (err != OK) - return NULL; + return nullptr; /* STEP 5 PARSE IMAGES */ err = _parse_images(state, p_path.get_base_dir()); if (err != OK) - return NULL; + return nullptr; /* STEP 6 PARSE TEXTURES */ err = _parse_textures(state); if (err != OK) - return NULL; + return nullptr; /* STEP 7 PARSE TEXTURES */ err = _parse_materials(state); if (err != OK) - return NULL; + return nullptr; /* STEP 9 PARSE SKINS */ err = _parse_skins(state); if (err != OK) - return NULL; + return nullptr; /* STEP 10 DETERMINE SKELETONS */ err = _determine_skeletons(state); if (err != OK) - return NULL; + return nullptr; /* STEP 11 CREATE SKELETONS */ err = _create_skeletons(state); if (err != OK) - return NULL; + return nullptr; /* STEP 12 CREATE SKINS */ err = _create_skins(state); if (err != OK) - return NULL; + return nullptr; /* STEP 13 PARSE MESHES (we have enough info now) */ err = _parse_meshes(state); if (err != OK) - return NULL; + return nullptr; /* STEP 14 PARSE CAMERAS */ err = _parse_cameras(state); if (err != OK) - return NULL; + return nullptr; /* STEP 15 PARSE ANIMATIONS */ err = _parse_animations(state); if (err != OK) - return NULL; + return nullptr; /* STEP 16 ASSIGN SCENE NAMES */ _assign_scene_names(state); diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 79395cca93..d127a87782 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -415,7 +415,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorSceneImporterGLTF(); diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h index dd95cb687a..927fac566e 100644 --- a/editor/import/resource_importer_bitmask.h +++ b/editor/import/resource_importer_bitmask.h @@ -51,7 +51,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterBitMap(); ~ResourceImporterBitMap(); diff --git a/editor/import/resource_importer_csv.h b/editor/import/resource_importer_csv.h index 2030dd1f99..7aa48f68de 100644 --- a/editor/import/resource_importer_csv.h +++ b/editor/import/resource_importer_csv.h @@ -49,7 +49,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterCSV(); }; diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index ec33d6aa16..742f6b8f60 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -49,7 +49,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterCSVTranslation(); }; diff --git a/editor/import/resource_importer_image.h b/editor/import/resource_importer_image.h index 6ad77eec1b..abb74d0665 100644 --- a/editor/import/resource_importer_image.h +++ b/editor/import/resource_importer_image.h @@ -50,7 +50,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterImage(); }; diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index d472070808..a4cbc81b26 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -259,7 +259,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const Ref<Image> image; image.instance(); - Error err = ImageLoader::load_image(p_source_file, image, NULL, false, 1.0); + Error err = ImageLoader::load_image(p_source_file, image, nullptr, false, 1.0); if (err != OK) return err; @@ -383,7 +383,7 @@ const char *ResourceImporterLayeredTexture::compression_formats[] = { "etc", "etc2", "pvrtc", - NULL + nullptr }; String ResourceImporterLayeredTexture::get_import_settings_string() const { @@ -438,7 +438,7 @@ bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_p return valid; } -ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = NULL; +ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = nullptr; ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() { diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index 6a6bc89a81..40e5c9023e 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -114,7 +114,7 @@ public: void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); void update_imports(); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 4be6f2ed80..6a6eadfa5c 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -428,7 +428,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in if (r_err) { *r_err = err; } - return NULL; + return nullptr; } Node3D *scene = memnew(Node3D); @@ -502,7 +502,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s List<Ref<Mesh>> meshes; - Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], NULL); + Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], nullptr); ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V(meshes.size() != 1, ERR_BUG); diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 678be45106..7485e60f7b 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -40,7 +40,7 @@ class EditorOBJImporter : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorOBJImporter(); @@ -62,7 +62,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterOBJ(); }; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index fb57773b18..b5766a48a0 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -72,7 +72,7 @@ Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, return get_script_instance()->call("_import_scene", p_path, p_flags, p_bake_fps); } - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { @@ -81,7 +81,7 @@ Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint3 return get_script_instance()->call("_import_animation", p_path, p_flags); } - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } //for documenters, these functions are useful when an importer calls an external conversion helper (like, fbx2gltf), @@ -311,7 +311,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (!isroot && _teststr(name, "noimp")) { memdelete(p_node); - return NULL; + return nullptr; } if (Object::cast_to<MeshInstance3D>(p_node)) { @@ -400,7 +400,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> fixed_name = _fixstr(name, "convcolonly"); } - ERR_FAIL_COND_V(fixed_name == String(), NULL); + ERR_FAIL_COND_V(fixed_name == String(), nullptr); if (shapes.size()) { @@ -432,7 +432,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> Object::cast_to<Node3D>(sb)->set_transform(Object::cast_to<Node3D>(p_node)->get_transform()); p_node->replace_by(sb); memdelete(p_node); - p_node = NULL; + p_node = nullptr; CollisionShape3D *colshape = memnew(CollisionShape3D); if (empty_draw_type == "CUBE") { BoxShape3D *boxShape = memnew(BoxShape3D); @@ -448,7 +448,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } else if (empty_draw_type == "IMAGE") { WorldMarginShape3D *world_margin_shape = memnew(WorldMarginShape3D); colshape->set_shape(world_margin_shape); - colshape->set_name("WorldMarginShape"); + colshape->set_name("WorldMarginShape3D"); } else { SphereShape3D *sphereShape = memnew(SphereShape3D); sphereShape->set_radius(1); @@ -558,7 +558,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); - ERR_FAIL_COND_V(mesh.is_null(), NULL); + ERR_FAIL_COND_V(mesh.is_null(), nullptr); NavigationRegion3D *nmi = memnew(NavigationRegion3D); nmi->set_name(_fixstr(name, "navmesh")); @@ -1229,7 +1229,7 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte break; } - ERR_FAIL_COND_V(!importer.is_valid(), NULL); + ERR_FAIL_COND_V(!importer.is_valid(), nullptr); List<String> missing; Error err; @@ -1261,7 +1261,7 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito break; } - ERR_FAIL_COND_V(!importer.is_valid(), NULL); + ERR_FAIL_COND_V(!importer.is_valid(), nullptr); return importer->import_animation(p_path, p_flags, p_bake_fps); } @@ -1327,7 +1327,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p String root_type = p_options["nodes/root_type"]; root_type = root_type.split(" ")[0]; // full root_type is "ClassName (filename.gd)" for a script global class. - Ref<Script> root_script = NULL; + Ref<Script> root_script = nullptr; if (ScriptServer::is_global_class(root_type)) { root_script = ResourceLoader::load(ScriptServer::get_global_class_path(root_type)); root_type = ScriptServer::get_global_class_base(root_type); @@ -1533,7 +1533,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p return OK; } -ResourceImporterScene *ResourceImporterScene::singleton = NULL; +ResourceImporterScene *ResourceImporterScene::singleton = nullptr; ResourceImporterScene::ResourceImporterScene() { singleton = this; @@ -1550,10 +1550,10 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla Error error; Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); - ERR_FAIL_COND_V_MSG(!ps.is_valid(), NULL, "Cannot load scene as text resource from path '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'."); Node *scene = ps->instance(); - ERR_FAIL_COND_V(!scene, NULL); + ERR_FAIL_COND_V(!scene, nullptr); return scene; } diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index bb01725854..f48f181951 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -66,7 +66,7 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorSceneImporter() {} @@ -154,7 +154,7 @@ public: void _filter_tracks(Node *scene, const String &p_text); void _optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); Node *import_scene_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps); Ref<Animation> import_animation_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps); @@ -168,7 +168,7 @@ class EditorSceneImporterESCN : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); }; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 0090d30b9c..f8ed9304b6 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -36,7 +36,7 @@ #include "editor/editor_file_system.h" #include "editor/editor_node.h" -void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_channel) { +void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) { MutexLock lock(singleton->mutex); @@ -424,7 +424,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String String normal_map = p_options["roughness/src_normal"]; Ref<Image> normal_image; - Image::RoughnessChannel roughness_channel; + Image::RoughnessChannel roughness_channel = Image::ROUGHNESS_CHANNEL_R; if (mipmaps && roughness > 1 && FileAccess::exists(normal_map)) { normal_image.instance(); @@ -434,7 +434,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } Ref<Image> image; image.instance(); - Error err = ImageLoader::load_image(p_source_file, image, NULL, hdr_as_srgb, scale); + Error err = ImageLoader::load_image(p_source_file, image, nullptr, hdr_as_srgb, scale); if (err != OK) return err; @@ -575,7 +575,7 @@ const char *ResourceImporterTexture::compression_formats[] = { "etc", "etc2", "pvrtc", - NULL + nullptr }; String ResourceImporterTexture::get_import_settings_string() const { @@ -630,7 +630,7 @@ bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) co return valid; } -ResourceImporterTexture *ResourceImporterTexture::singleton = NULL; +ResourceImporterTexture *ResourceImporterTexture::singleton = nullptr; ResourceImporterTexture::ResourceImporterTexture() { diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index ed0fe1be89..e1c71ff1b8 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -35,7 +35,7 @@ #include "core/io/resource_importer.h" #include "core/os/file_access.h" #include "scene/resources/texture.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class StreamTexture; @@ -63,16 +63,16 @@ protected: int flags; String normal_path_for_roughness; - VS::TextureDetectRoughnessChannel channel_for_roughness; + RS::TextureDetectRoughnessChannel channel_for_roughness; MakeInfo() { flags = 0; - channel_for_roughness = VS::TEXTURE_DETECT_ROUGNHESS_R; + channel_for_roughness = RS::TEXTURE_DETECT_ROUGNHESS_R; } }; Map<StringName, MakeInfo> make_flags; - static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VisualServer::TextureDetectRoughnessChannel p_channel); + static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel); static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex); static void _texture_reimport_normal(const Ref<StreamTexture> &p_tex); @@ -104,7 +104,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); void update_imports(); diff --git a/editor/import/resource_importer_texture_atlas.h b/editor/import/resource_importer_texture_atlas.h index a36cae5872..c61fa5c040 100644 --- a/editor/import/resource_importer_texture_atlas.h +++ b/editor/import/resource_importer_texture_atlas.h @@ -63,7 +63,7 @@ public: virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; virtual String get_option_group_file() const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths); ResourceImporterTextureAtlas(); diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index 6df5b88b13..bc2f023e6b 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -162,7 +162,7 @@ public: } } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterWAV(); }; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 223e7a841f..3715547bdc 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -112,7 +112,7 @@ void InspectorDock::_menu_option(int p_option) { editor_data->get_undo_redo().clear_history(); - editor->get_editor_plugins_over()->edit(NULL); + editor->get_editor_plugins_over()->edit(nullptr); editor->get_editor_plugins_over()->edit(current); } break; @@ -166,7 +166,7 @@ void InspectorDock::_resource_file_selected(String p_file) { void InspectorDock::_save_resource(bool save_as) const { ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -180,7 +180,7 @@ void InspectorDock::_save_resource(bool save_as) const { void InspectorDock::_unref_resource() const { ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -191,7 +191,7 @@ void InspectorDock::_unref_resource() const { void InspectorDock::_copy_resource() const { ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -397,7 +397,7 @@ void InspectorDock::update(Object *p_object) { editor_path->set_disabled(true); editor_path->set_text(""); editor_path->set_tooltip(""); - editor_path->set_icon(NULL); + editor_path->set_icon(nullptr); return; } diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index 67f0d991bd..ab43e45af7 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -86,7 +86,7 @@ void EditorNode3DGizmo::clear() { for (int i = 0; i < instances.size(); i++) { if (instances[i].instance.is_valid()) - VS::get_singleton()->free(instances[i].instance); + RS::get_singleton()->free(instances[i].instance); } billboard_handle = false; @@ -168,16 +168,16 @@ void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) { void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) { - instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario()); - VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); + instance = RS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario()); + RS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); if (skin_reference.is_valid()) { - VS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton()); + RS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton()); } if (extra_margin) - VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_extra_visibility_margin(instance, 1); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, RS::SHADOW_CASTING_SETTING_OFF); int layer = p_hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER; - VS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26 + RS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26 } void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) { @@ -191,9 +191,9 @@ void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, ins.material = p_material; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); if (ins.material.is_valid()) { - VS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); + RS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); } } @@ -246,7 +246,7 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate ins.mesh = mesh; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } instances.push_back(ins); @@ -310,7 +310,7 @@ void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, ins.billboard = true; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } selectable_icon_size = p_scale; @@ -346,8 +346,8 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< Ref<ArrayMesh> mesh = memnew(ArrayMesh); Array a; - a.resize(VS::ARRAY_MAX); - a[VS::ARRAY_VERTEX] = p_handles; + a.resize(RS::ARRAY_MAX); + a[RS::ARRAY_VERTEX] = p_handles; Vector<Color> colors; { colors.resize(p_handles.size()); @@ -364,7 +364,7 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< w[i] = col; } } - a[VS::ARRAY_COLOR] = colors; + a[RS::ARRAY_COLOR] = colors; mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a); mesh->surface_set_material(0, p_material); @@ -384,7 +384,7 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< ins.extra_margin = true; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } instances.push_back(ins); if (!p_secondary) { @@ -410,14 +410,14 @@ void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, cubem.set_size(p_size); Array arrays = cubem.surface_get_arrays(0); - PackedVector3Array vertex = arrays[VS::ARRAY_VERTEX]; + PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX]; Vector3 *w = vertex.ptrw(); for (int i = 0; i < vertex.size(); ++i) { w[i] += p_position; } - arrays[VS::ARRAY_VERTEX] = vertex; + arrays[RS::ARRAY_VERTEX] = vertex; Ref<ArrayMesh> m = memnew(ArrayMesh); m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), arrays); @@ -708,7 +708,7 @@ void EditorNode3DGizmo::transform() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); for (int i = 0; i < instances.size(); i++) { - VS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform()); } } @@ -720,7 +720,7 @@ void EditorNode3DGizmo::free() { for (int i = 0; i < instances.size(); i++) { if (instances[i].instance.is_valid()) - VS::get_singleton()->free(instances[i].instance); + RS::get_singleton()->free(instances[i].instance); instances.write[i].instance = RID(); } @@ -733,7 +733,7 @@ void EditorNode3DGizmo::set_hidden(bool p_hidden) { hidden = p_hidden; int layer = hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER; for (int i = 0; i < instances.size(); ++i) { - VS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer); + RS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer); } } @@ -773,17 +773,17 @@ EditorNode3DGizmo::EditorNode3DGizmo() { valid = false; billboard_handle = false; hidden = false; - base = NULL; + base = nullptr; selected = false; instanced = false; - spatial_node = NULL; - gizmo_plugin = NULL; + spatial_node = nullptr; + gizmo_plugin = nullptr; selectable_icon_size = -1.0f; } EditorNode3DGizmo::~EditorNode3DGizmo() { - if (gizmo_plugin != NULL) gizmo_plugin->unregister_gizmo(this); + if (gizmo_plugin != nullptr) gizmo_plugin->unregister_gizmo(this); clear(); } @@ -812,7 +812,7 @@ LightNode3DGizmoPlugin::LightNode3DGizmoPlugin() { } bool LightNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<Light3D>(p_spatial) != NULL; + return Object::cast_to<Light3D>(p_spatial) != nullptr; } String LightNode3DGizmoPlugin::get_name() const { @@ -1097,7 +1097,7 @@ AudioStreamPlayer3DNode3DGizmoPlugin::AudioStreamPlayer3DNode3DGizmoPlugin() { } bool AudioStreamPlayer3DNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<AudioStreamPlayer3D>(p_spatial) != NULL; + return Object::cast_to<AudioStreamPlayer3D>(p_spatial) != nullptr; } String AudioStreamPlayer3DNode3DGizmoPlugin::get_name() const { @@ -1242,7 +1242,7 @@ CameraNode3DGizmoPlugin::CameraNode3DGizmoPlugin() { } bool CameraNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<Camera3D>(p_spatial) != NULL; + return Object::cast_to<Camera3D>(p_spatial) != nullptr; } String CameraNode3DGizmoPlugin::get_name() const { @@ -1493,7 +1493,7 @@ MeshInstanceNode3DGizmoPlugin::MeshInstanceNode3DGizmoPlugin() { } bool MeshInstanceNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<MeshInstance3D>(p_spatial) != NULL && Object::cast_to<SoftBody3D>(p_spatial) == NULL; + return Object::cast_to<MeshInstance3D>(p_spatial) != nullptr && Object::cast_to<SoftBody3D>(p_spatial) == nullptr; } String MeshInstanceNode3DGizmoPlugin::get_name() const { @@ -1530,7 +1530,7 @@ Sprite3DNode3DGizmoPlugin::Sprite3DNode3DGizmoPlugin() { } bool Sprite3DNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<Sprite3D>(p_spatial) != NULL; + return Object::cast_to<Sprite3D>(p_spatial) != nullptr; } String Sprite3DNode3DGizmoPlugin::get_name() const { @@ -1585,7 +1585,7 @@ Position3DNode3DGizmoPlugin::Position3DNode3DGizmoPlugin() { mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); Array d; - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); d[Mesh::ARRAY_VERTEX] = cursor_points; d[Mesh::ARRAY_COLOR] = cursor_colors; pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d); @@ -1593,7 +1593,7 @@ Position3DNode3DGizmoPlugin::Position3DNode3DGizmoPlugin() { } bool Position3DNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<Position3D>(p_spatial) != NULL; + return Object::cast_to<Position3D>(p_spatial) != nullptr; } String Position3DNode3DGizmoPlugin::get_name() const { @@ -1620,7 +1620,7 @@ SkeletonNode3DGizmoPlugin::SkeletonNode3DGizmoPlugin() { } bool SkeletonNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<Skeleton3D>(p_spatial) != NULL; + return Object::cast_to<Skeleton3D>(p_spatial) != nullptr; } String SkeletonNode3DGizmoPlugin::get_name() const { @@ -1827,7 +1827,7 @@ PhysicalBoneNode3DGizmoPlugin::PhysicalBoneNode3DGizmoPlugin() { } bool PhysicalBoneNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<PhysicalBone3D>(p_spatial) != NULL; + return Object::cast_to<PhysicalBone3D>(p_spatial) != nullptr; } String PhysicalBoneNode3DGizmoPlugin::get_name() const { @@ -1967,11 +1967,11 @@ RayCastNode3DGizmoPlugin::RayCastNode3DGizmoPlugin() { } bool RayCastNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<RayCast3D>(p_spatial) != NULL; + return Object::cast_to<RayCast3D>(p_spatial) != nullptr; } String RayCastNode3DGizmoPlugin::get_name() const { - return "RayCast"; + return "RayCast3D"; } int RayCastNode3DGizmoPlugin::get_priority() const { @@ -2021,11 +2021,11 @@ SpringArmNode3DGizmoPlugin::SpringArmNode3DGizmoPlugin() { } bool SpringArmNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<SpringArm3D>(p_spatial) != NULL; + return Object::cast_to<SpringArm3D>(p_spatial) != nullptr; } String SpringArmNode3DGizmoPlugin::get_name() const { - return "SpringArm"; + return "SpringArm3D"; } int SpringArmNode3DGizmoPlugin::get_priority() const { @@ -2041,11 +2041,11 @@ VehicleWheelNode3DGizmoPlugin::VehicleWheelNode3DGizmoPlugin() { } bool VehicleWheelNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<VehicleWheel3D>(p_spatial) != NULL; + return Object::cast_to<VehicleWheel3D>(p_spatial) != nullptr; } String VehicleWheelNode3DGizmoPlugin::get_name() const { - return "VehicleWheel"; + return "VehicleWheel3D"; } int VehicleWheelNode3DGizmoPlugin::get_priority() const { @@ -2115,11 +2115,11 @@ SoftBodyNode3DGizmoPlugin::SoftBodyNode3DGizmoPlugin() { } bool SoftBodyNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<SoftBody3D>(p_spatial) != NULL; + return Object::cast_to<SoftBody3D>(p_spatial) != nullptr; } String SoftBodyNode3DGizmoPlugin::get_name() const { - return "SoftBody"; + return "SoftBody3D"; } int SoftBodyNode3DGizmoPlugin::get_priority() const { @@ -2162,7 +2162,7 @@ void SoftBodyNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } String SoftBodyNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - return "SoftBody pin point"; + return "SoftBody3D pin point"; } Variant SoftBodyNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { @@ -2191,11 +2191,11 @@ VisibilityNotifierGizmoPlugin::VisibilityNotifierGizmoPlugin() { } bool VisibilityNotifierGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<VisibilityNotifier3D>(p_spatial) != NULL; + return Object::cast_to<VisibilityNotifier3D>(p_spatial) != nullptr; } String VisibilityNotifierGizmoPlugin::get_name() const { - return "VisibilityNotifier"; + return "VisibilityNotifier3D"; } int VisibilityNotifierGizmoPlugin::get_priority() const { @@ -2342,59 +2342,59 @@ void VisibilityNotifierGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// -CPUParticlesGizmoPlugin::CPUParticlesGizmoPlugin() { - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCPUParticles", "EditorIcons")); +CPUParticles3DGizmoPlugin::CPUParticles3DGizmoPlugin() { + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCPUParticles3D", "EditorIcons")); } -bool CPUParticlesGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<CPUParticles3D>(p_spatial) != NULL; +bool CPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<CPUParticles3D>(p_spatial) != nullptr; } -String CPUParticlesGizmoPlugin::get_name() const { - return "CPUParticles"; +String CPUParticles3DGizmoPlugin::get_name() const { + return "CPUParticles3D"; } -int CPUParticlesGizmoPlugin::get_priority() const { +int CPUParticles3DGizmoPlugin::get_priority() const { return -1; } -bool CPUParticlesGizmoPlugin::is_selectable_when_hidden() const { +bool CPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -void CPUParticlesGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { +void CPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> icon = get_material("particles_icon", p_gizmo); p_gizmo->add_unscaled_billboard(icon, 0.05); } //// -ParticlesGizmoPlugin::ParticlesGizmoPlugin() { +GPUParticles3DGizmoPlugin::GPUParticles3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particles", Color(0.8, 0.7, 0.4)); create_material("particles_material", gizmo_color); gizmo_color.a = 0.1; create_material("particles_solid_material", gizmo_color); - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoParticles", "EditorIcons")); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGPUParticles3D", "EditorIcons")); create_handle_material("handles"); } -bool ParticlesGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<GPUParticles3D>(p_spatial) != NULL; +bool GPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<GPUParticles3D>(p_spatial) != nullptr; } -String ParticlesGizmoPlugin::get_name() const { - return "Particles"; +String GPUParticles3DGizmoPlugin::get_name() const { + return "GPUParticles3D"; } -int ParticlesGizmoPlugin::get_priority() const { +int GPUParticles3DGizmoPlugin::get_priority() const { return -1; } -bool ParticlesGizmoPlugin::is_selectable_when_hidden() const { +bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -String ParticlesGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Size X"; @@ -2407,12 +2407,12 @@ String ParticlesGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, i return ""; } -Variant ParticlesGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); return particles->get_visibility_aabb(); } -void ParticlesGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); @@ -2464,7 +2464,7 @@ void ParticlesGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Cam } } -void ParticlesGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); @@ -2480,7 +2480,7 @@ void ParticlesGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, ur->commit_action(); } -void ParticlesGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { +void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); @@ -2548,7 +2548,7 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() { } bool ReflectionProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<ReflectionProbe>(p_spatial) != NULL; + return Object::cast_to<ReflectionProbe>(p_spatial) != nullptr; } String ReflectionProbeGizmoPlugin::get_name() const { @@ -2736,7 +2736,7 @@ GIProbeGizmoPlugin::GIProbeGizmoPlugin() { } bool GIProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<GIProbe>(p_spatial) != NULL; + return Object::cast_to<GIProbe>(p_spatial) != nullptr; } String GIProbeGizmoPlugin::get_name() const { @@ -2980,7 +2980,7 @@ void BakedIndirectLightGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, in } bool BakedIndirectLightGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<BakedLightmap>(p_spatial) != NULL; + return Object::cast_to<BakedLightmap>(p_spatial) != nullptr; } String BakedIndirectLightGizmoPlugin::get_name() const { @@ -3044,7 +3044,7 @@ CollisionShapeNode3DGizmoPlugin::CollisionShapeNode3DGizmoPlugin() { } bool CollisionShapeNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<CollisionShape3D>(p_spatial) != NULL; + return Object::cast_to<CollisionShape3D>(p_spatial) != nullptr; } String CollisionShapeNode3DGizmoPlugin::get_name() const { @@ -3672,7 +3672,7 @@ CollisionPolygonNode3DGizmoPlugin::CollisionPolygonNode3DGizmoPlugin() { } bool CollisionPolygonNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<CollisionPolygon3D>(p_spatial) != NULL; + return Object::cast_to<CollisionPolygon3D>(p_spatial) != nullptr; } String CollisionPolygonNode3DGizmoPlugin::get_name() const { @@ -3721,11 +3721,11 @@ NavigationMeshNode3DGizmoPlugin::NavigationMeshNode3DGizmoPlugin() { } bool NavigationMeshNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<NavigationRegion3D>(p_spatial) != NULL; + return Object::cast_to<NavigationRegion3D>(p_spatial) != nullptr; } String NavigationMeshNode3DGizmoPlugin::get_name() const { - return "NavigationRegion"; + return "NavigationRegion3D"; } int NavigationMeshNode3DGizmoPlugin::get_priority() const { @@ -4085,7 +4085,7 @@ JointNode3DGizmoPlugin::JointNode3DGizmoPlugin() { } bool JointNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to<Joint3D>(p_spatial) != NULL; + return Object::cast_to<Joint3D>(p_spatial) != nullptr; } String JointNode3DGizmoPlugin::get_name() const { @@ -4101,12 +4101,12 @@ void JointNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); - Node3D *node_body_a = NULL; + Node3D *node_body_a = nullptr; if (!joint->get_node_a().is_empty()) { node_body_a = Object::cast_to<Node3D>(joint->get_node(joint->get_node_a())); } - Node3D *node_body_b = NULL; + Node3D *node_body_b = nullptr; if (!joint->get_node_b().is_empty()) { node_body_b = Object::cast_to<Node3D>(joint->get_node(joint->get_node_b())); } @@ -4141,8 +4141,8 @@ void JointNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { hinge->get_param(HingeJoint3D::PARAM_LIMIT_UPPER), hinge->get_flag(HingeJoint3D::FLAG_USE_LIMIT), points, - node_body_a ? &body_a_points : NULL, - node_body_b ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_b ? &body_b_points : nullptr); p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(body_a_points); @@ -4166,8 +4166,8 @@ void JointNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_LOWER), slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_UPPER), points, - node_body_a ? &body_a_points : NULL, - node_body_b ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_b ? &body_b_points : nullptr); p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(body_a_points); @@ -4188,8 +4188,8 @@ void JointNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { node_body_b ? node_body_b->get_global_transform() : Transform(), cone->get_param(ConeTwistJoint3D::PARAM_SWING_SPAN), cone->get_param(ConeTwistJoint3D::PARAM_TWIST_SPAN), - node_body_a ? &body_a_points : NULL, - node_body_b ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_b ? &body_b_points : nullptr); p_gizmo->add_collision_segments(body_a_points); p_gizmo->add_collision_segments(body_b_points); @@ -4229,8 +4229,8 @@ void JointNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { gen->get_flag_z(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT), points, - node_body_a ? &body_a_points : NULL, - node_body_a ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_a ? &body_b_points : nullptr); p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(body_a_points); diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h index 014b736a0d..f8339b4c6c 100644 --- a/editor/node_3d_editor_gizmos.h +++ b/editor/node_3d_editor_gizmos.h @@ -236,8 +236,8 @@ public: VisibilityNotifierGizmoPlugin(); }; -class CPUParticlesGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(CPUParticlesGizmoPlugin, EditorNode3DGizmoPlugin); +class CPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin { + GDCLASS(CPUParticles3DGizmoPlugin, EditorNode3DGizmoPlugin); public: bool has_gizmo(Node3D *p_spatial); @@ -245,12 +245,12 @@ public: int get_priority() const; bool is_selectable_when_hidden() const; void redraw(EditorNode3DGizmo *p_gizmo); - CPUParticlesGizmoPlugin(); + CPUParticles3DGizmoPlugin(); }; -class ParticlesGizmoPlugin : public EditorNode3DGizmoPlugin { +class GPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(ParticlesGizmoPlugin, EditorNode3DGizmoPlugin); + GDCLASS(GPUParticles3DGizmoPlugin, EditorNode3DGizmoPlugin); public: bool has_gizmo(Node3D *p_spatial); @@ -264,7 +264,7 @@ public: void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - ParticlesGizmoPlugin(); + GPUParticles3DGizmoPlugin(); }; class ReflectionProbeGizmoPlugin : public EditorNode3DGizmoPlugin { diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index 0c511e4819..a076b1eecc 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -60,7 +60,7 @@ void NodeDock::_notification(int p_what) { } } -NodeDock *NodeDock::singleton = NULL; +NodeDock *NodeDock::singleton = nullptr; void NodeDock::update_lists() { diff --git a/editor/plugins/SCsub b/editor/plugins/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/plugins/SCsub +++ b/editor/plugins/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index e3e9eae31a..c26daa3857 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -218,7 +218,7 @@ void AbstractPolygon2DEditor::_notification(int p_what) { void AbstractPolygon2DEditor::_node_removed(Node *p_node) { if (p_node == _get_node()) { - edit(NULL); + edit(nullptr); hide(); canvas_item_editor->update_viewport(); @@ -690,7 +690,7 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { canvas_item_editor->update_viewport(); } else { - _set_node(NULL); + _set_node(nullptr); } } @@ -801,7 +801,7 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive) { - canvas_item_editor = NULL; + canvas_item_editor = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -854,7 +854,7 @@ void AbstractPolygon2DEditorPlugin::make_visible(bool p_visible) { } else { polygon_editor->hide(); - polygon_editor->edit(NULL); + polygon_editor->edit(nullptr); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 86c43ea9ab..eb50df2166 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -589,7 +589,7 @@ void AnimationNodeBlendSpace1DEditor::edit(const Ref<AnimationNode> &p_node) { } } -AnimationNodeBlendSpace1DEditor *AnimationNodeBlendSpace1DEditor::singleton = NULL; +AnimationNodeBlendSpace1DEditor *AnimationNodeBlendSpace1DEditor::singleton = nullptr; AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() { singleton = this; diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 843beacfd6..4343535eb6 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -810,7 +810,7 @@ void AnimationNodeBlendSpace2DEditor::_open_editor() { } void AnimationNodeBlendSpace2DEditor::_removed_from_graph() { - EditorNode::get_singleton()->edit_item(NULL); + EditorNode::get_singleton()->edit_item(nullptr); } void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() { @@ -833,7 +833,7 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() { ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendSpace2DEditor::_removed_from_graph); } -AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = NULL; +AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = nullptr; AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 4491c002e3..54c60aba71 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -579,7 +579,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano for (Set<String>::Element *E = paths.front(); E; E = E->next()) { NodePath path = E->get(); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; String accum; for (int i = 0; i < path.get_name_count(); i++) { String name = path.get_name(i); @@ -608,7 +608,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano } } - Node *node = NULL; + Node *node = nullptr; if (base->has_node(accum)) { node = base->get_node(accum); } @@ -710,7 +710,7 @@ void AnimationNodeBlendTreeEditor::_edit_filters(const String &p_which) { void AnimationNodeBlendTreeEditor::_removed_from_graph() { if (is_visible()) { - EditorNode::get_singleton()->edit_item(NULL); + EditorNode::get_singleton()->edit_item(nullptr); } } @@ -756,7 +756,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { } AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); - AnimationPlayer *player = NULL; + AnimationPlayer *player = nullptr; if (graph_player->has_node(graph_player->get_animation_player())) { player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player())); } @@ -802,7 +802,7 @@ void AnimationNodeBlendTreeEditor::_bind_methods() { ClassDB::bind_method("_update_filters", &AnimationNodeBlendTreeEditor::_update_filters); } -AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = NULL; +AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr; void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) { diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 41af2ab0cc..d96a3b0bab 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -41,17 +41,17 @@ #include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning. #include "editor/plugins/node_3d_editor_plugin.h" // For onion skinning. #include "scene/main/window.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void AnimationPlayerEditor::_node_removed(Node *p_node) { if (player && player == p_node) { - player = NULL; + player = nullptr; set_process(false); track_editor->set_animation(Ref<Animation>()); - track_editor->set_root(NULL); + track_editor->set_root(nullptr); track_editor->show_select_node_warning(true); _update_player(); } @@ -299,7 +299,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { } else { track_editor->set_animation(Ref<Animation>()); - track_editor->set_root(NULL); + track_editor->set_root(nullptr); } autoplay->set_pressed(current == player->get_autoplay()); @@ -407,7 +407,7 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) file->set_current_path(p_resource->get_path()); if (extensions.size()) { String ext = p_resource->get_path().get_extension().to_lower(); - if (extensions.find(ext) == NULL) { + if (extensions.find(ext) == nullptr) { file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get())); } } @@ -729,7 +729,7 @@ void AnimationPlayerEditor::_animation_edit() { } } else { track_editor->set_animation(Ref<Animation>()); - track_editor->set_root(NULL); + track_editor->set_root(nullptr); } } @@ -845,10 +845,10 @@ void AnimationPlayerEditor::_update_player() { frame->set_editable(animlist.size() != 0); animation->set_disabled(animlist.size() == 0); autoplay->set_disabled(animlist.size() == 0); - tool_anim->set_disabled(player == NULL); + tool_anim->set_disabled(player == nullptr); onion_toggle->set_disabled(animlist.size() == 0); onion_skinning->set_disabled(animlist.size() == 0); - pin->set_disabled(player == NULL); + pin->set_disabled(player == nullptr); if (!player) { AnimationPlayerEditor::singleton->get_track_editor()->update_keying(); @@ -947,8 +947,8 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o alpha += alpha_step; if (onion.captures_valid[cidx]) { - VS::get_singleton()->canvas_item_add_texture_rect_region( - ci, dst_rect, VS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); + RS::get_singleton()->canvas_item_add_texture_rect_region( + ci, dst_rect, RS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); } cidx++; @@ -961,8 +961,8 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o alpha -= alpha_step; if (onion.captures_valid[cidx]) { - VS::get_singleton()->canvas_item_add_texture_rect_region( - ci, dst_rect, VS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); + RS::get_singleton()->canvas_item_add_texture_rect_region( + ci, dst_rect, RS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); } cidx++; @@ -1318,17 +1318,17 @@ void AnimationPlayerEditor::_allocate_onion_layers() { bool is_present = onion.differences_only && i == captures - 1; // Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport. - onion.captures.write[i] = VS::get_singleton()->viewport_create(); + onion.captures.write[i] = RS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height); - VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS); - VS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present); - VS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas); + RS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height); + RS::get_singleton()->viewport_set_update_mode(onion.captures[i], RS::VIEWPORT_UPDATE_ALWAYS); + RS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present); + RS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas); } // Reset the capture canvas item to the current root viewport texture (defensive). - VS::get_singleton()->canvas_item_clear(onion.capture.canvas_item); - VS::get_singleton()->canvas_item_add_texture_rect(onion.capture.canvas_item, Rect2(Point2(), capture_size), get_tree()->get_root()->get_texture()->get_rid()); + RS::get_singleton()->canvas_item_clear(onion.capture.canvas_item); + RS::get_singleton()->canvas_item_add_texture_rect(onion.capture.canvas_item, Rect2(Point2(), capture_size), get_tree()->get_root()->get_texture()->get_rid()); onion.capture_size = capture_size; } @@ -1337,7 +1337,7 @@ void AnimationPlayerEditor::_free_onion_layers() { for (int i = 0; i < onion.captures.size(); i++) { if (onion.captures[i].is_valid()) { - VS::get_singleton()->free(onion.captures[i]); + RS::get_singleton()->free(onion.captures[i]); } } onion.captures.clear(); @@ -1421,18 +1421,18 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Tweak the root viewport to ensure it's rendered before our target. RID root_vp = get_tree()->get_root()->get_viewport_rid(); Rect2 root_vp_screen_rect = Rect2(Vector2(), get_tree()->get_root()->get_size()); - VS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2()); - VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_ALWAYS); + RS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2()); + RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_ALWAYS); RID present_rid; if (onion.differences_only) { // Capture present scene as it is. - VS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, RID()); + RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, RID()); present_rid = onion.captures[onion.captures.size() - 1]; - VS::get_singleton()->viewport_set_active(present_rid, true); - VS::get_singleton()->viewport_set_parent_viewport(root_vp, present_rid); - VS::get_singleton()->draw(false); - VS::get_singleton()->viewport_set_active(present_rid, false); + RS::get_singleton()->viewport_set_active(present_rid, true); + RS::get_singleton()->viewport_set_parent_viewport(root_vp, present_rid); + RS::get_singleton()->draw(false); + RS::get_singleton()->viewport_set_active(present_rid, false); } // Backup current animation state. @@ -1441,10 +1441,10 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Render every past/future step with the capture shader. - VS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid()); + RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid()); onion.capture.material->set_shader_param("bkg_color", GLOBAL_GET("rendering/environment/default_clear_color")); onion.capture.material->set_shader_param("differences_only", onion.differences_only); - onion.capture.material->set_shader_param("present", onion.differences_only ? VS::get_singleton()->viewport_get_texture(present_rid) : RID()); + onion.capture.material->set_shader_param("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID()); int step_off_a = onion.past ? -onion.steps : 0; int step_off_b = onion.future ? onion.steps : 0; @@ -1468,19 +1468,19 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds. values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D). - VS::get_singleton()->viewport_set_active(onion.captures[cidx], true); - VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]); - VS::get_singleton()->draw(false); - VS::get_singleton()->viewport_set_active(onion.captures[cidx], false); + RS::get_singleton()->viewport_set_active(onion.captures[cidx], true); + RS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]); + RS::get_singleton()->draw(false); + RS::get_singleton()->viewport_set_active(onion.captures[cidx], false); } cidx++; } // Restore root viewport. - VS::get_singleton()->viewport_set_parent_viewport(root_vp, RID()); - VS::get_singleton()->viewport_attach_to_screen(root_vp, root_vp_screen_rect); - VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_WHEN_VISIBLE); + RS::get_singleton()->viewport_set_parent_viewport(root_vp, RID()); + RS::get_singleton()->viewport_attach_to_screen(root_vp, root_vp_screen_rect); + RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_WHEN_VISIBLE); // Restore animation state // (Seeking with update=true wouldn't do the trick because the current value of the properties @@ -1549,7 +1549,7 @@ void AnimationPlayerEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_stop_onion_skinning"), &AnimationPlayerEditor::_stop_onion_skinning); } -AnimationPlayerEditor *AnimationPlayerEditor::singleton = NULL; +AnimationPlayerEditor *AnimationPlayerEditor::singleton = nullptr; AnimationPlayer *AnimationPlayerEditor::get_player() const { @@ -1565,7 +1565,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay set_focus_mode(FOCUS_ALL); - player = NULL; + player = nullptr; HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); @@ -1764,9 +1764,9 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay onion.last_frame = 0; onion.can_overlay = false; onion.capture_size = Size2(); - onion.capture.canvas = VS::get_singleton()->canvas_create(); - onion.capture.canvas_item = VS::get_singleton()->canvas_item_create(); - VS::get_singleton()->canvas_item_set_parent(onion.capture.canvas_item, onion.capture.canvas); + onion.capture.canvas = RS::get_singleton()->canvas_create(); + onion.capture.canvas_item = RS::get_singleton()->canvas_item_create(); + RS::get_singleton()->canvas_item_set_parent(onion.capture.canvas_item, onion.capture.canvas); onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial)); @@ -1792,14 +1792,14 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \ } \ "); - VS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); + RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); } AnimationPlayerEditor::~AnimationPlayerEditor() { _free_onion_layers(); - VS::get_singleton()->free(onion.capture.canvas); - VS::get_singleton()->free(onion.capture.canvas_item); + RS::get_singleton()->free(onion.capture.canvas); + RS::get_singleton()->free(onion.capture.canvas_item); } void AnimationPlayerEditorPlugin::_notification(int p_what) { diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 8ff8c92f4d..9267c0df5c 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -1082,7 +1082,7 @@ void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) { void AnimationNodeStateMachineEditor::_removed_from_graph() { - EditorNode::get_singleton()->edit_item(NULL); + EditorNode::get_singleton()->edit_item(nullptr); } void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { @@ -1241,7 +1241,7 @@ void AnimationNodeStateMachineEditor::_bind_methods() { ClassDB::bind_method("_open_editor", &AnimationNodeStateMachineEditor::_open_editor); } -AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = NULL; +AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = nullptr; AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 605696aa75..e771c5610f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -169,7 +169,7 @@ void AnimationTreeEditor::_notification(int p_what) { void AnimationTreeEditor::_bind_methods() { } -AnimationTreeEditor *AnimationTreeEditor::singleton = NULL; +AnimationTreeEditor *AnimationTreeEditor::singleton = nullptr; void AnimationTreeEditor::add_plugin(AnimationTreeNodeEditorPlugin *p_editor) { ERR_FAIL_COND(p_editor->get_parent()); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 3b104e34b2..14c44b7973 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -635,7 +635,7 @@ void EditorAssetLibrary::_install_asset() { EditorAssetLibraryItemDownload *d = Object::cast_to<EditorAssetLibraryItemDownload>(downloads_hb->get_child(i)); if (d && d->get_asset_id() == description->get_asset_id()) { - if (EditorNode::get_singleton() != NULL) + if (EditorNode::get_singleton() != nullptr) EditorNode::get_singleton()->show_warning(TTR("Download for this asset is already in progress!")); return; } @@ -1305,7 +1305,7 @@ void EditorAssetLibrary::_asset_file_selected(const String &p_file) { if (asset_installer) { memdelete(asset_installer); - asset_installer = NULL; + asset_installer = nullptr; } asset_installer = memnew(EditorAssetInstaller); @@ -1500,7 +1500,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER); error_hb->add_child(error_tr); - description = NULL; + description = nullptr; set_process(true); set_process_unhandled_input(true); @@ -1520,7 +1520,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { add_child(asset_open); asset_open->connect("file_selected", callable_mp(this, &EditorAssetLibrary::_asset_file_selected)); - asset_installer = NULL; + asset_installer = nullptr; } /////// diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 6cffda49d0..0459ac7618 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -89,7 +89,7 @@ void AudioStreamEditor::_draw_preview() { Vector<Color> color; color.push_back(get_theme_color("contrast_color_2", "Editor")); - VS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); + RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); } void AudioStreamEditor::_preview_changed(ObjectID p_which) { diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp index 6bc9562c5a..ba161244d6 100644 --- a/editor/plugins/baked_lightmap_editor_plugin.cpp +++ b/editor/plugins/baked_lightmap_editor_plugin.cpp @@ -81,25 +81,25 @@ void BakedLightmapEditorPlugin::make_visible(bool p_visible) { } } -EditorProgress *BakedLightmapEditorPlugin::tmp_progress = NULL; +EditorProgress *BakedLightmapEditorPlugin::tmp_progress = nullptr; void BakedLightmapEditorPlugin::bake_func_begin(int p_steps) { - ERR_FAIL_COND(tmp_progress != NULL); + ERR_FAIL_COND(tmp_progress != nullptr); tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), p_steps, true)); } bool BakedLightmapEditorPlugin::bake_func_step(int p_step, const String &p_description) { - ERR_FAIL_COND_V(tmp_progress == NULL, false); + ERR_FAIL_COND_V(tmp_progress == nullptr, false); return tmp_progress->step(p_description, p_step, false); } void BakedLightmapEditorPlugin::bake_func_end() { - ERR_FAIL_COND(tmp_progress == NULL); + ERR_FAIL_COND(tmp_progress == nullptr); memdelete(tmp_progress); - tmp_progress = NULL; + tmp_progress = nullptr; } void BakedLightmapEditorPlugin::_bind_methods() { @@ -116,7 +116,7 @@ BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) { bake->hide(); bake->connect("pressed", this, "_bake"); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake); - lightmap = NULL; + lightmap = nullptr; BakedLightmap::bake_begin_function = bake_func_begin; BakedLightmap::bake_step_function = bake_func_step; diff --git a/editor/plugins/camera_3d_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp index 3d9b74c2da..8bc1374269 100644 --- a/editor/plugins/camera_3d_editor_plugin.cpp +++ b/editor/plugins/camera_3d_editor_plugin.cpp @@ -35,15 +35,15 @@ void Camera3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; - Node3DEditor::get_singleton()->set_custom_camera(NULL); + node = nullptr; + Node3DEditor::get_singleton()->set_custom_camera(nullptr); hide(); } } void Camera3DEditor::_pressed() { - Node *sn = (node && preview->is_pressed()) ? node : NULL; + Node *sn = (node && preview->is_pressed()) ? node : nullptr; Node3DEditor::get_singleton()->set_custom_camera(sn); } @@ -56,13 +56,13 @@ void Camera3DEditor::edit(Node *p_camera) { if (!node) { preview->set_pressed(false); - Node3DEditor::get_singleton()->set_custom_camera(NULL); + Node3DEditor::get_singleton()->set_custom_camera(nullptr); } else { if (preview->is_pressed()) Node3DEditor::get_singleton()->set_custom_camera(p_camera); else - Node3DEditor::get_singleton()->set_custom_camera(NULL); + Node3DEditor::get_singleton()->set_custom_camera(nullptr); } } @@ -96,9 +96,9 @@ bool Camera3DEditorPlugin::handles(Object *p_object) const { void Camera3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - //Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object)); + //Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object)); } else { - Node3DEditor::get_singleton()->set_can_preview(NULL); + Node3DEditor::get_singleton()->set_can_preview(nullptr); } } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ba9cba5515..2f7747d0ff 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -48,7 +48,7 @@ #include "scene/2d/touch_screen_button.h" #include "scene/gui/grid_container.h" #include "scene/gui/nine_patch_rect.h" -#include "scene/gui/viewport_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/main/canvas_layer.h" #include "scene/main/window.h" #include "scene/resources/packed_scene.h" @@ -503,7 +503,7 @@ Object *CanvasItemEditor::_get_editor_data(Object *p_what) { CanvasItem *ci = Object::cast_to<CanvasItem>(p_what); if (!ci) - return NULL; + return nullptr; return memnew(CanvasItemEditorSelectedItem); } @@ -667,7 +667,7 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from)); Vector<Vector2> bone_shape; - if (!_get_bone_shape(&bone_shape, NULL, E)) + if (!_get_bone_shape(&bone_shape, nullptr, E)) continue; // Check if the point is inside the Polygon2D @@ -1343,7 +1343,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { if (drag_selection.size() == 1) { new_pos = snap_point(drag_from, SNAP_NODE_SIDES | SNAP_NODE_CENTER | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, drag_selection[0]); } else { - new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, NULL, drag_selection); + new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection); } for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); @@ -2031,7 +2031,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { Vector<List<Dictionary>> all_bones_ik_states; for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { List<Dictionary> bones_ik_states; - _save_canvas_item_ik_chain(E->get(), NULL, &bones_ik_states); + _save_canvas_item_ik_chain(E->get(), nullptr, &bones_ik_states); all_bones_ik_states.push_back(bones_ik_states); } @@ -2046,7 +2046,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { previous_pos = _get_encompassing_rect_from_list(drag_selection).position; } - Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, NULL, drag_selection); + Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, nullptr, drag_selection); if (drag_type == DRAG_MOVE_X) { new_pos.y = previous_pos.y; @@ -2133,7 +2133,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { Vector<List<Dictionary>> all_bones_ik_states; for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { List<Dictionary> bones_ik_states; - _save_canvas_item_ik_chain(E->get(), NULL, &bones_ik_states); + _save_canvas_item_ik_chain(E->get(), nullptr, &bones_ik_states); all_bones_ik_states.push_back(bones_ik_states); } @@ -2299,7 +2299,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { return true; // Find the item to select - CanvasItem *canvas_item = NULL; + CanvasItem *canvas_item = nullptr; // Retrieve the bones Vector<_SelectResult> selection = Vector<_SelectResult>(); @@ -3427,7 +3427,7 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c } } if (points.size() >= 2) { - VisualServer::get_singleton()->canvas_item_add_line(ci, points[0], points[1], p_color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, points[0], points[1], p_color); } } @@ -3455,7 +3455,7 @@ void CanvasItemEditor::_draw_axis() { }; for (int i = 0; i < 4; i++) { - VisualServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color); } } } @@ -3512,8 +3512,8 @@ void CanvasItemEditor::_draw_bones() { outline_colors.push_back(bone_outline_color); } - VisualServer::get_singleton()->canvas_item_add_polygon(ci, bone_shape_outline, outline_colors); - VisualServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID()); + RenderingServer::get_singleton()->canvas_item_add_polygon(ci, bone_shape_outline, outline_colors); + RenderingServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID()); } } } @@ -3744,7 +3744,7 @@ void CanvasItemEditor::_draw_viewport() { } RID ci = viewport->get_canvas_item(); - VisualServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D()); + RenderingServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D()); EditorPluginList *over_plugin_list = editor->get_editor_plugins_over(); if (!over_plugin_list->empty()) { @@ -4911,7 +4911,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { bool preview = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE)); preview = !preview; - VS::get_singleton()->canvas_set_disable_scale(!preview); + RS::get_singleton()->canvas_set_disable_scale(!preview); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE), preview); } break; @@ -5434,7 +5434,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { viewport_scrollable->set_h_size_flags(Control::SIZE_EXPAND_FILL); viewport_scrollable->connect("draw", callable_mp(this, &CanvasItemEditor::_update_scrollbars)); - ViewportContainer *scene_tree = memnew(ViewportContainer); + SubViewportContainer *scene_tree = memnew(SubViewportContainer); viewport_scrollable->add_child(scene_tree); scene_tree->set_stretch(true); scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE); @@ -5800,7 +5800,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { call_deferred("set_state", get_state()); } -CanvasItemEditor *CanvasItemEditor::singleton = NULL; +CanvasItemEditor *CanvasItemEditor::singleton = nullptr; void CanvasItemEditorPlugin::edit(Object *p_object) { @@ -5818,13 +5818,13 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) { if (p_visible) { canvas_item_editor->show(); canvas_item_editor->set_physics_process(true); - VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false); + RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false); } else { canvas_item_editor->hide(); canvas_item_editor->set_physics_process(false); - VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true); } } @@ -5886,8 +5886,8 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons ERR_FAIL_COND(res.is_null()); Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - if (texture != NULL || scene != NULL) { - if (texture != NULL) { + if (texture != nullptr || scene != nullptr) { + if (texture != nullptr) { Sprite2D *sprite = memnew(Sprite2D); sprite->set_texture(texture); sprite->set_modulate(Color(1, 1, 1, 0.7f)); @@ -5953,7 +5953,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child); editor_data->get_undo_redo().add_do_method(child, "set_owner", editor->get_edited_scene()); editor_data->get_undo_redo().add_do_reference(child); - editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)nullptr); } if (parent) { @@ -6064,7 +6064,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { continue; } Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - if (scene != NULL && scene.is_valid()) { + if (scene != nullptr && scene.is_valid()) { if (!target_node) { // Without root node act the same as "Load Inherited Scene" Error err = EditorNode::get_singleton()->load_scene(path, false, true); @@ -6079,7 +6079,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { } } else { Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); - if (texture != NULL && texture.is_valid()) { + if (texture != nullptr && texture.is_valid()) { Node *child; if (default_type == "Light2D") child = memnew(Light2D); @@ -6209,7 +6209,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p list.push_back(root_node); } else { drop_pos = p_point; - target_node = NULL; + target_node = nullptr; } } @@ -6258,7 +6258,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte types.push_back("TextureRect"); types.push_back("NinePatchRect"); - target_node = NULL; + target_node = nullptr; editor = p_node; editor_data = editor->get_scene_tree_dock()->get_editor_data(); canvas_item_editor = p_canvas_item_editor; @@ -6307,7 +6307,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte label_desc->hide(); canvas_item_editor->get_controls_container()->add_child(label_desc); - VS::get_singleton()->canvas_set_disable_scale(true); + RS::get_singleton()->canvas_set_disable_scale(true); } CanvasItemEditorViewport::~CanvasItemEditorViewport() { diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 34965868e0..9f1a92f563 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -613,7 +613,7 @@ public: SNAP_DEFAULT = SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL, }; - Point2 snap_point(Point2 p_target, unsigned int p_modes = SNAP_DEFAULT, unsigned int p_forced_modes = 0, const CanvasItem *p_self_canvas_item = NULL, List<CanvasItem *> p_other_nodes_exceptions = List<CanvasItem *>()); + Point2 snap_point(Point2 p_target, unsigned int p_modes = SNAP_DEFAULT, unsigned int p_forced_modes = 0, const CanvasItem *p_self_canvas_item = nullptr, List<CanvasItem *> p_other_nodes_exceptions = List<CanvasItem *>()); float snap_angle(float p_target, float p_start = 0) const; Transform2D get_canvas_transform() const { return transform; } diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 3d32c0b698..87e9987aa1 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -42,7 +42,7 @@ void CollisionPolygon2DEditor::_set_node(Node *p_polygon) { CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 5b35a4826c..26adc5156b 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -66,7 +66,7 @@ void CollisionPolygon3DEditor::_notification(int p_what) { void CollisionPolygon3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; if (imgeom->get_parent() == p_node) p_node->remove_child(imgeom); hide(); @@ -507,7 +507,7 @@ void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) { prev_depth = -1; } else { - node = NULL; + node = nullptr; if (imgeom->get_parent()) imgeom->get_parent()->remove_child(imgeom); @@ -523,7 +523,7 @@ void CollisionPolygon3DEditor::_bind_methods() { CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { - node = NULL; + node = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -591,7 +591,7 @@ void Polygon3DEditorPlugin::make_visible(bool p_visible) { } else { collision_polygon_editor->hide(); - collision_polygon_editor->edit(NULL); + collision_polygon_editor->edit(nullptr); } } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 709ff91fc0..594dd0d0cb 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -39,6 +39,13 @@ #include "scene/resources/rectangle_shape_2d.h" #include "scene/resources/segment_shape_2d.h" +void CollisionShape2DEditor::_node_removed(Node *p_node) { + + if (p_node == node) { + node = nullptr; + } +} + Variant CollisionShape2DEditor::get_handle_value(int idx) const { switch (shape_type) { @@ -525,6 +532,20 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } } +void CollisionShape2DEditor::_notification(int p_what) { + + switch (p_what) { + + case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed)); + } break; + + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed)); + } break; + } +} + void CollisionShape2DEditor::edit(Node *p_node) { if (!canvas_item_editor) { @@ -540,7 +561,7 @@ void CollisionShape2DEditor::edit(Node *p_node) { edit_handle = -1; shape_type = -1; - node = NULL; + node = nullptr; } canvas_item_editor->update_viewport(); @@ -553,8 +574,8 @@ void CollisionShape2DEditor::_bind_methods() { CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) { - node = NULL; - canvas_item_editor = NULL; + node = nullptr; + canvas_item_editor = nullptr; editor = p_editor; undo_redo = p_editor->get_undo_redo(); @@ -576,7 +597,7 @@ bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const { void CollisionShape2DEditorPlugin::make_visible(bool visible) { if (!visible) { - edit(NULL); + edit(nullptr); } } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 025420a886..6bb621c476 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -71,6 +71,8 @@ class CollisionShape2DEditor : public Control { void _get_current_shape_type(); protected: + void _notification(int p_what); + void _node_removed(Node *p_node); static void _bind_methods(); public: diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 022663a61d..b005519a5e 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -251,7 +251,7 @@ void CPUParticles2DEditorPlugin::_bind_methods() { CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { - particles = NULL; + particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 887e9e48df..0c2fbaf62a 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -35,7 +35,7 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } @@ -128,7 +128,7 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) { } else { particles_editor->particles_editor_hb->hide(); particles_editor->hide(); - particles_editor->edit(NULL); + particles_editor->edit(nullptr); } } diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h index aac9cc9a2f..796c842e07 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.h +++ b/editor/plugins/cpu_particles_3d_editor_plugin.h @@ -72,7 +72,7 @@ class CPUParticles3DEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual String get_name() const { return "CPUParticles"; } + virtual String get_name() const { return "CPUParticles3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 0fd8ea4fb5..71c5a78e0b 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -755,7 +755,7 @@ void CurveEditor::_bind_methods() { bool EditorInspectorPluginCurve::can_handle(Object *p_object) { - return Object::cast_to<Curve>(p_object) != NULL; + return Object::cast_to<Curve>(p_object) != nullptr; } void EditorInspectorPluginCurve::parse_begin(Object *p_object) { diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 3c173ab783..a8c4bddccf 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -328,19 +328,19 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si if (material->get_shader_mode() == Shader::MODE_SPATIAL) { - VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); + RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture preview_done = false; - VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); - VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); + RS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); @@ -358,35 +358,35 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { - scenario = VS::get_singleton()->scenario_create(); + scenario = RS::get_singleton()->scenario_create(); - viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, 128, 128); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, 128, 128); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); - VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); - VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); + camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); + RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); - light = VS::get_singleton()->directional_light_create(); - light_instance = VS::get_singleton()->instance_create2(light, scenario); - VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + light = RS::get_singleton()->directional_light_create(); + light_instance = RS::get_singleton()->instance_create2(light, scenario); + RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - //VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + //RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); - VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); - sphere = VS::get_singleton()->mesh_create(); - sphere_instance = VS::get_singleton()->instance_create2(sphere, scenario); + sphere = RS::get_singleton()->mesh_create(); + sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario); int lats = 32; int lons = 32; @@ -453,25 +453,25 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { } Array arr; - arr.resize(VS::ARRAY_MAX); - arr[VS::ARRAY_VERTEX] = vertices; - arr[VS::ARRAY_NORMAL] = normals; - arr[VS::ARRAY_TANGENT] = tangents; - arr[VS::ARRAY_TEX_UV] = uvs; - VS::get_singleton()->mesh_add_surface_from_arrays(sphere, VS::PRIMITIVE_TRIANGLES, arr); + arr.resize(RS::ARRAY_MAX); + arr[RS::ARRAY_VERTEX] = vertices; + arr[RS::ARRAY_NORMAL] = normals; + arr[RS::ARRAY_TANGENT] = tangents; + arr[RS::ARRAY_TEX_UV] = uvs; + RS::get_singleton()->mesh_add_surface_from_arrays(sphere, RS::PRIMITIVE_TRIANGLES, arr); } EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() { - VS::get_singleton()->free(sphere); - VS::get_singleton()->free(sphere_instance); - VS::get_singleton()->free(viewport); - VS::get_singleton()->free(light); - VS::get_singleton()->free(light_instance); - VS::get_singleton()->free(light2); - VS::get_singleton()->free(light_instance2); - VS::get_singleton()->free(camera); - VS::get_singleton()->free(scenario); + RS::get_singleton()->free(sphere); + RS::get_singleton()->free(sphere_instance); + RS::get_singleton()->free(viewport); + RS::get_singleton()->free(light); + RS::get_singleton()->free(light_instance); + RS::get_singleton()->free(light2); + RS::get_singleton()->free(light_instance2); + RS::get_singleton()->free(camera); + RS::get_singleton()->free(scenario); } /////////////////////////////////////////////////////////////////////////// @@ -706,7 +706,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 Ref<Mesh> mesh = p_from; ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>()); - VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); + RS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; @@ -723,21 +723,21 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 xform.basis.scale(Vector3(m, m, m)); xform.origin = -xform.basis.xform(ofs); //-ofs*m; xform.origin.z -= rot_aabb.size.z * 2; - VS::get_singleton()->instance_set_transform(mesh_instance, xform); + RS::get_singleton()->instance_set_transform(mesh_instance, xform); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture preview_done = false; - VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); - VS::get_singleton()->instance_set_base(mesh_instance, RID()); + RS::get_singleton()->instance_set_base(mesh_instance, RID()); img->convert(Image::FORMAT_RGBA8); @@ -759,49 +759,49 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { - scenario = VS::get_singleton()->scenario_create(); + scenario = RS::get_singleton()->scenario_create(); - viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, 128, 128); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, 128, 128); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); - VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); - //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); - VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); + camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); + RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); + //RS::get_singleton()->camera_set_perspective(camera,45,0.1,10); + RS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - light = VS::get_singleton()->directional_light_create(); - light_instance = VS::get_singleton()->instance_create2(light, scenario); - VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + light = RS::get_singleton()->directional_light_create(); + light_instance = RS::get_singleton()->instance_create2(light, scenario); + RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); - light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + //RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); + light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); - VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); - //sphere = VS::get_singleton()->mesh_create(); - mesh_instance = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_scenario(mesh_instance, scenario); + //sphere = RS::get_singleton()->mesh_create(); + mesh_instance = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_scenario(mesh_instance, scenario); } EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { - //VS::get_singleton()->free(sphere); - VS::get_singleton()->free(mesh_instance); - VS::get_singleton()->free(viewport); - VS::get_singleton()->free(light); - VS::get_singleton()->free(light_instance); - VS::get_singleton()->free(light2); - VS::get_singleton()->free(light_instance2); - VS::get_singleton()->free(camera); - VS::get_singleton()->free(scenario); + //RS::get_singleton()->free(sphere); + RS::get_singleton()->free(mesh_instance); + RS::get_singleton()->free(viewport); + RS::get_singleton()->free(light); + RS::get_singleton()->free(light_instance); + RS::get_singleton()->free(light2); + RS::get_singleton()->free(light_instance2); + RS::get_singleton()->free(camera); + RS::get_singleton()->free(scenario); } /////////////////////////////////////////////////////////////////////////// @@ -849,16 +849,16 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, font->draw(canvas_item, pos, sampled_text); preview_done = false; - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture - VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture + RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } - VS::get_singleton()->canvas_item_clear(canvas_item); + RS::get_singleton()->canvas_item_clear(canvas_item); - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); img->convert(Image::FORMAT_RGBA8); @@ -891,22 +891,22 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 EditorFontPreviewPlugin::EditorFontPreviewPlugin() { - viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); - VS::get_singleton()->viewport_set_size(viewport, 128, 128); - VS::get_singleton()->viewport_set_active(viewport, true); - viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_size(viewport, 128, 128); + RS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - canvas = VS::get_singleton()->canvas_create(); - canvas_item = VS::get_singleton()->canvas_item_create(); + canvas = RS::get_singleton()->canvas_create(); + canvas_item = RS::get_singleton()->canvas_item_create(); - VS::get_singleton()->viewport_attach_canvas(viewport, canvas); - VS::get_singleton()->canvas_item_set_parent(canvas_item, canvas); + RS::get_singleton()->viewport_attach_canvas(viewport, canvas); + RS::get_singleton()->canvas_item_set_parent(canvas_item, canvas); } EditorFontPreviewPlugin::~EditorFontPreviewPlugin() { - VS::get_singleton()->free(canvas_item); - VS::get_singleton()->free(canvas); - VS::get_singleton()->free(viewport); + RS::get_singleton()->free(canvas_item); + RS::get_singleton()->free(canvas); + RS::get_singleton()->free(viewport); } diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp index 908a32fdb6..6a171c4703 100644 --- a/editor/plugins/gi_probe_editor_plugin.cpp +++ b/editor/plugins/gi_probe_editor_plugin.cpp @@ -113,25 +113,25 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) { } } -EditorProgress *GIProbeEditorPlugin::tmp_progress = NULL; +EditorProgress *GIProbeEditorPlugin::tmp_progress = nullptr; void GIProbeEditorPlugin::bake_func_begin(int p_steps) { - ERR_FAIL_COND(tmp_progress != NULL); + ERR_FAIL_COND(tmp_progress != nullptr); tmp_progress = memnew(EditorProgress("bake_gi", TTR("Bake GI Probe"), p_steps)); } void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) { - ERR_FAIL_COND(tmp_progress == NULL); + ERR_FAIL_COND(tmp_progress == nullptr); tmp_progress->step(p_description, p_step, false); } void GIProbeEditorPlugin::bake_func_end() { - ERR_FAIL_COND(tmp_progress == NULL); + ERR_FAIL_COND(tmp_progress == nullptr); memdelete(tmp_progress); - tmp_progress = NULL; + tmp_progress = nullptr; } void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String &p_path) { @@ -163,7 +163,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { bake_hb->add_child(bake_info); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); - gi_probe = NULL; + gi_probe = nullptr; probe_file = memnew(EditorFileDialog); probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); probe_file->add_filter("*.res"); diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 89bff7ccab..29c47a2b67 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -360,7 +360,7 @@ void GPUParticles2DEditorPlugin::_bind_methods() { GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { - particles = NULL; + particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index 904786ffae..008d04a211 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -87,7 +87,7 @@ protected: static void _bind_methods(); public: - virtual String get_name() const { return "Particles2D"; } + virtual String get_name() const { return "GPUParticles2D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 655f03b7e0..534a228098 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -236,7 +236,7 @@ GPUParticles3DEditorBase::GPUParticles3DEditorBase() { void GPUParticles3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } @@ -424,7 +424,7 @@ void GPUParticles3DEditor::_bind_methods() { GPUParticles3DEditor::GPUParticles3DEditor() { - node = NULL; + node = nullptr; particles_editor_hb = memnew(HBoxContainer); Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); options = memnew(MenuButton); @@ -476,7 +476,7 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) { } else { particles_editor->particles_editor_hb->hide(); particles_editor->hide(); - particles_editor->edit(NULL); + particles_editor->edit(nullptr); } } diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index d730457d01..cf1cff32c0 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -108,7 +108,7 @@ class GPUParticles3DEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual String get_name() const { return "Particles"; } + virtual String get_name() const { return "GPUParticles3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 54b7840124..67de610ae7 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -79,7 +79,7 @@ GradientEditor::GradientEditor() { bool EditorInspectorPluginGradient::can_handle(Object *p_object) { - return Object::cast_to<Gradient>(p_object) != NULL; + return Object::cast_to<Gradient>(p_object) != nullptr; } void EditorInspectorPluginGradient::parse_begin(Object *p_object) { diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 9ae4d2ae9d..1dbc78804b 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -163,7 +163,7 @@ void ItemListOptionButtonPlugin::erase(int p_idx) { ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() { - ob = NULL; + ob = nullptr; } /////////////////////////////////////////////////////////////// @@ -205,7 +205,7 @@ void ItemListPopupMenuPlugin::erase(int p_idx) { ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() { - pp = NULL; + pp = nullptr; } /////////////////////////////////////////////////////////////// @@ -244,7 +244,7 @@ void ItemListItemListPlugin::erase(int p_idx) { ItemListItemListPlugin::ItemListItemListPlugin() { - pp = NULL; + pp = nullptr; } /////////////////////////////////////////////////////////////// @@ -254,7 +254,7 @@ ItemListItemListPlugin::ItemListItemListPlugin() { void ItemListEditor::_node_removed(Node *p_node) { if (p_node == item_list) { - item_list = NULL; + item_list = nullptr; hide(); dialog->hide(); } @@ -311,7 +311,7 @@ void ItemListEditor::edit(Node *p_item_list) { if (!item_list) { selected_idx = -1; - property_editor->edit(NULL); + property_editor->edit(nullptr); return; } @@ -329,7 +329,7 @@ void ItemListEditor::edit(Node *p_item_list) { } selected_idx = -1; - property_editor->edit(NULL); + property_editor->edit(nullptr); } bool ItemListEditor::handles(Object *p_object) const { @@ -349,7 +349,7 @@ void ItemListEditor::_bind_methods() { ItemListEditor::ItemListEditor() { selected_idx = -1; - item_list = NULL; + item_list = nullptr; toolbar_button = memnew(ToolButton); toolbar_button->set_text(TTR("Items")); @@ -408,7 +408,7 @@ void ItemListEditorPlugin::make_visible(bool p_visible) { } else { item_list_editor->hide(); - item_list_editor->edit(NULL); + item_list_editor->edit(nullptr); } } diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 22df287f97..f8550a884b 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -112,7 +112,7 @@ void LightOccluder2DEditor::_create_resource() { LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } LightOccluder2DEditorPlugin::LightOccluder2DEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 4ac9d0af3b..5b887390a6 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -64,7 +64,7 @@ void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, con Line2DEditor::Line2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 8129b9bd86..00e8a05e4e 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "material_editor_plugin.h" #include "editor/editor_scale.h" -#include "scene/gui/viewport_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/resources/particles_material.h" #include "scene/resources/sky_material.h" @@ -110,7 +110,7 @@ void MaterialEditor::_bind_methods() { MaterialEditor::MaterialEditor() { - vc = memnew(ViewportContainer); + vc = memnew(SubViewportContainer); vc->set_stretch(true); add_child(vc); vc->set_anchors_and_margins_preset(PRESET_WIDE); @@ -256,14 +256,14 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { @@ -273,7 +273,7 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p if (texture.is_valid()) { smat->set_shader_param(E->get().name, texture); } else { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } } @@ -302,17 +302,17 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } @@ -340,17 +340,17 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } @@ -378,17 +378,17 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } @@ -416,17 +416,17 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } @@ -454,17 +454,17 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> & Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 0938e79ca2..50036e4f72 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -41,13 +41,13 @@ #include "scene/3d/mesh_instance_3d.h" #include "scene/resources/material.h" -class ViewportContainer; +class SubViewportContainer; class MaterialEditor : public Control { GDCLASS(MaterialEditor, Control); - ViewportContainer *vc; + SubViewportContainer *vc; SubViewport *viewport; MeshInstance3D *sphere_instance; MeshInstance3D *box_instance; diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index a8b455fdd2..5e657c3b71 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -173,7 +173,7 @@ MeshEditor::MeshEditor() { bool EditorInspectorPluginMesh::can_handle(Object *p_object) { - return Object::cast_to<Mesh>(p_object) != NULL; + return Object::cast_to<Mesh>(p_object) != nullptr; } void EditorInspectorPluginMesh::parse_begin(Object *p_object) { diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 59810517d9..072e21f260 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -36,12 +36,12 @@ #include "scene/3d/camera_3d.h" #include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" -#include "scene/gui/viewport_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/resources/material.h" -class MeshEditor : public ViewportContainer { +class MeshEditor : public SubViewportContainer { - GDCLASS(MeshEditor, ViewportContainer); + GDCLASS(MeshEditor, SubViewportContainer); float rot_x; float rot_y; diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index a4e7b2df08..7819f62bc7 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -40,7 +40,7 @@ void MeshInstance3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; options->hide(); } } @@ -337,18 +337,15 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { const Vector2 *r = uv.ptr(); Vector<int> indices = a[Mesh::ARRAY_INDEX]; - const int *ri; + const int *ri = nullptr; int ic; - bool use_indices; if (indices.size()) { ic = indices.size(); ri = indices.ptr(); - use_indices = true; } else { ic = uv.size(); - use_indices = false; } for (int j = 0; j < ic; j += 3) { @@ -356,7 +353,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { for (int k = 0; k < 3; k++) { MeshInstance3DEditorEdgeSort edge; - if (use_indices) { + if (ri) { edge.a = r[ri[j + k]]; edge.b = r[ri[j + ((k + 1) % 3)]]; } else { @@ -392,17 +389,17 @@ void MeshInstance3DEditor::_create_outline_mesh() { Ref<Mesh> mesh = node->get_mesh(); if (mesh.is_null()) { - err_dialog->set_text(TTR("MeshInstance lacks a Mesh!")); + err_dialog->set_text(TTR("MeshInstance3D lacks a Mesh.")); err_dialog->popup_centered(); return; } if (mesh->get_surface_count() == 0) { - err_dialog->set_text(TTR("Mesh has not surface to create outlines from!")); + err_dialog->set_text(TTR("Mesh has not surface to create outlines from.")); err_dialog->popup_centered(); return; } else if (mesh->get_surface_count() == 1 && mesh->surface_get_primitive_type(0) != Mesh::PRIMITIVE_TRIANGLES) { - err_dialog->set_text(TTR("Mesh primitive type is not PRIMITIVE_TRIANGLES!")); + err_dialog->set_text(TTR("Mesh primitive type is not PRIMITIVE_TRIANGLES.")); err_dialog->popup_centered(); return; } @@ -410,7 +407,7 @@ void MeshInstance3DEditor::_create_outline_mesh() { Ref<Mesh> mesho = mesh->create_outline(outline_size->get_value()); if (mesho.is_null()) { - err_dialog->set_text(TTR("Could not create outline!")); + err_dialog->set_text(TTR("Could not create outline.")); err_dialog->popup_centered(); return; } @@ -447,7 +444,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() { options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance3D", "EditorIcons")); options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody3D and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection.")); @@ -514,7 +511,7 @@ void MeshInstance3DEditorPlugin::make_visible(bool p_visible) { } else { mesh_editor->options->hide(); - mesh_editor->edit(NULL); + mesh_editor->edit(nullptr); } } diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 658e3ea565..4f482c2b43 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -37,7 +37,7 @@ void MultiMeshEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } @@ -82,7 +82,7 @@ void MultiMeshEditor::_populate() { if (!ms_instance) { - err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance).")); + err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance3D).")); err_dialog->popup_centered(); return; } @@ -371,7 +371,7 @@ MultiMeshEditor::MultiMeshEditor() { populate_dialog->add_child(std); std->connect("selected", callable_mp(this, &MultiMeshEditor::_browsed)); - _last_pp_node = NULL; + _last_pp_node = nullptr; err_dialog = memnew(AcceptDialog); add_child(err_dialog); @@ -394,7 +394,7 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) { } else { multimesh_editor->options->hide(); - multimesh_editor->edit(NULL); + multimesh_editor->edit(nullptr); } } diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 6671d0b6b4..e41b32ac86 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -123,7 +123,7 @@ void NavigationPolygonEditor::_create_resource() { NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 07eaf3f63f..2a27332051 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -48,7 +48,7 @@ #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/3d/visual_instance_3d.h" -#include "scene/gui/viewport_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/resources/packed_scene.h" #include "scene/resources/surface_tool.h" #include "servers/display_server.h" @@ -418,12 +418,12 @@ Vector3 Node3DEditorViewport::_get_camera_position() const { Point2 Node3DEditorViewport::_point_to_screen(const Vector3 &p_point) { - return camera->unproject_position(p_point) * viewport_container->get_stretch_shrink(); + return camera->unproject_position(p_point) * subviewport_container->get_stretch_shrink(); } Vector3 Node3DEditorViewport::_get_ray_pos(const Vector2 &p_pos) const { - return camera->project_ray_origin(p_pos / viewport_container->get_stretch_shrink()); + return camera->project_ray_origin(p_pos / subviewport_container->get_stretch_shrink()); } Vector3 Node3DEditorViewport::_get_camera_normal() const { @@ -433,7 +433,7 @@ Vector3 Node3DEditorViewport::_get_camera_normal() const { Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const { - return camera->project_ray_normal(p_pos / viewport_container->get_stretch_shrink()); + return camera->project_ray_normal(p_pos / subviewport_container->get_stretch_shrink()); } void Node3DEditorViewport::_clear_selected() { @@ -494,14 +494,14 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); - Vector2 shrinked_pos = p_pos / viewport_container->get_stretch_shrink(); + Vector2 shrinked_pos = p_pos / subviewport_container->get_stretch_shrink(); - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); Set<Ref<EditorNode3DGizmo>> found_gizmos; Node *edited_scene = get_tree()->get_edited_scene_root(); ObjectID closest; - Node *item = NULL; + Node *item = nullptr; float closest_dist = 1e20; int selected_handle = -1; @@ -563,7 +563,7 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); Set<Ref<EditorNode3DGizmo>> found_gizmos; r_includes_current = false; @@ -588,7 +588,7 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu Vector3 normal; int handle = -1; - bool inters = seg->intersect_ray(camera, p_pos, point, normal, NULL, p_alt_select); + bool inters = seg->intersect_ray(camera, p_pos, point, normal, nullptr, p_alt_select); if (!inters) continue; @@ -686,7 +686,7 @@ void Node3DEditorViewport::_select_region() { frustum.push_back(far); } - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario()); + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario()); Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); @@ -2273,7 +2273,7 @@ static bool is_shortcut_pressed(const String &p_path) { return false; } InputEventKey *k = Object::cast_to<InputEventKey>(shortcut->get_shortcut().ptr()); - if (k == NULL) { + if (k == nullptr) { return false; } const InputFilter &input = *InputFilter::get_singleton(); @@ -2386,16 +2386,16 @@ void Node3DEditorViewport::_notification(int p_what) { _update_freelook(delta); Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root(); - if (previewing_cinema && scene_root != NULL) { + if (previewing_cinema && scene_root != nullptr) { Camera3D *cam = scene_root->get_viewport()->get_camera(); - if (cam != NULL && cam != previewing) { + if (cam != nullptr && cam != previewing) { //then switch the viewport's camera to the scene's viewport camera - if (previewing != NULL) { + if (previewing != nullptr) { previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); } previewing = cam; previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); surface->update(); } } @@ -2437,7 +2437,7 @@ void Node3DEditorViewport::_notification(int p_what) { aabb_s.scale(se->aabb.size); t.basis = t.basis * aabb_s; - VisualServer::get_singleton()->instance_set_transform(se->sbox_instance, t); + RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t); } if (changed || (spatial_editor->is_gizmo_visible() && !exist)) { @@ -2472,8 +2472,8 @@ void Node3DEditorViewport::_notification(int p_what) { bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION)); - if (shrink != (viewport_container->get_stretch_shrink() > 1)) { - viewport_container->set_stretch_shrink(shrink ? 2 : 1); + if (shrink != (subviewport_container->get_stretch_shrink() > 1)) { + subviewport_container->set_stretch_shrink(shrink ? 2 : 1); } //update msaa if changed @@ -2643,7 +2643,7 @@ void Node3DEditorViewport::_draw() { if (_edit.mode == TRANSFORM_ROTATE) { Point2 center = _point_to_screen(_edit.center); - VisualServer::get_singleton()->canvas_item_add_line( + RenderingServer::get_singleton()->canvas_item_add_line( ci, _edit.mouse_pos, center, @@ -2950,7 +2950,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { if (current) { preview_camera->hide(); } else { - if (previewing != NULL) + if (previewing != nullptr) preview_camera->show(); } } break; @@ -3082,51 +3082,51 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) { uint32_t layer = 1 << (GIZMO_BASE_LAYER + p_idx); for (int i = 0; i < 3; i++) { - move_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer); - - move_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer); - - rotate_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer); - - scale_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); - - scale_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer); + move_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer); + + move_plane_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer); + + rotate_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer); + + scale_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); + + scale_plane_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer); } } void Node3DEditorViewport::_finish_gizmo_instances() { for (int i = 0; i < 3; i++) { - VS::get_singleton()->free(move_gizmo_instance[i]); - VS::get_singleton()->free(move_plane_gizmo_instance[i]); - VS::get_singleton()->free(rotate_gizmo_instance[i]); - VS::get_singleton()->free(scale_gizmo_instance[i]); - VS::get_singleton()->free(scale_plane_gizmo_instance[i]); + RS::get_singleton()->free(move_gizmo_instance[i]); + RS::get_singleton()->free(move_plane_gizmo_instance[i]); + RS::get_singleton()->free(rotate_gizmo_instance[i]); + RS::get_singleton()->free(scale_gizmo_instance[i]); + RS::get_singleton()->free(scale_plane_gizmo_instance[i]); } } void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { @@ -3137,8 +3137,8 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { if (!p_activate) { previewing->disconnect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - previewing = NULL; - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore + previewing = nullptr; + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore if (!preview) preview_camera->hide(); view_menu->set_disabled(false); @@ -3148,7 +3148,7 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { previewing = preview; previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace view_menu->set_disabled(true); surface->update(); } @@ -3157,11 +3157,11 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) { previewing_cinema = p_activate; if (!previewing_cinema) { - if (previewing != NULL) + if (previewing != nullptr) previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - previewing = NULL; - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore + previewing = nullptr; + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore preview_camera->set_pressed(false); if (!preview) { preview_camera->hide(); @@ -3212,11 +3212,11 @@ void Node3DEditorViewport::update_transform_gizmo_view() { if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) { for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); } return; } @@ -3237,23 +3237,23 @@ void Node3DEditorViewport::update_transform_gizmo_view() { const int viewport_base_height = 400 * MAX(1, EDSCALE); gizmo_scale = (gizmo_size / Math::abs(dd)) * MAX(1, EDSCALE) * - MIN(viewport_base_height, viewport_container->get_size().height) / viewport_base_height / - viewport_container->get_stretch_shrink(); + MIN(viewport_base_height, subviewport_container->get_size().height) / viewport_base_height / + subviewport_container->get_stretch_shrink(); Vector3 scale = Vector3(1, 1, 1) * gizmo_scale; xform.basis.scale(scale); for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); - VisualServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); - VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)); - VisualServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); - VisualServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); + RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); + RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); + RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)); + RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); + RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); } } @@ -3363,7 +3363,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { if (Object::cast_to<Camera3D>(pv)) { previewing = Object::cast_to<Camera3D>(pv); previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace view_menu->set_disabled(true); surface->update(); preview_camera->set_pressed(true); @@ -3398,7 +3398,7 @@ Dictionary Node3DEditorViewport::get_state() const { d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS)); d["information"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); d["fps"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS)); - d["half_res"] = viewport_container->get_stretch_shrink() > 1; + d["half_res"] = subviewport_container->get_stretch_shrink() > 1; d["cinematic_preview"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW)); if (previewing) d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing); @@ -3478,7 +3478,7 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const Vector3 world_ray = _get_ray(p_pos); Vector3 world_pos = _get_ray_pos(p_pos); - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario()); + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario()); Set<Ref<EditorNode3DGizmo>> found_gizmos; float closest_dist = MAX_DISTANCE; @@ -3503,7 +3503,7 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const Vector3 hit_point; Vector3 hit_normal; - bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, NULL, false); + bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, nullptr, false); if (!inters) continue; @@ -3568,8 +3568,8 @@ void Node3DEditorViewport::_create_preview(const Vector<String> &files) const { ERR_CONTINUE(res.is_null()); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); - if (mesh != NULL || scene != NULL) { - if (mesh != NULL) { + if (mesh != nullptr || scene != nullptr) { + if (mesh != nullptr) { MeshInstance3D *mesh_instance = memnew(MeshInstance3D); mesh_instance->set_mesh(mesh); preview_node->add_child(mesh_instance); @@ -3620,10 +3620,10 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); - Node *instanced_scene = NULL; + Node *instanced_scene = nullptr; - if (mesh != NULL || scene != NULL) { - if (mesh != NULL) { + if (mesh != nullptr || scene != nullptr) { + if (mesh != nullptr) { MeshInstance3D *mesh_instance = memnew(MeshInstance3D); mesh_instance->set_mesh(mesh); mesh_instance->set_name(path.get_file().get_basename()); @@ -3637,7 +3637,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po } } - if (instanced_scene == NULL) { + if (instanced_scene == nullptr) { return false; } @@ -3648,7 +3648,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po } } - if (scene != NULL) { + if (scene != nullptr) { instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); } @@ -3689,7 +3689,7 @@ void Node3DEditorViewport::_perform_drop_data() { } Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); - if (mesh != NULL || scene != NULL) { + if (mesh != nullptr || scene != nullptr) { bool success = _create_instance(target_node, path, drop_pos); if (!success) { error_files.push_back(path); @@ -3829,8 +3829,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito zoom_indicator_delay = 0.0; spatial_editor = p_spatial_editor; - ViewportContainer *c = memnew(ViewportContainer); - viewport_container = c; + SubViewportContainer *c = memnew(SubViewportContainer); + subviewport_container = c; c->set_stretch(true); add_child(c); c->set_anchors_and_margins_preset(Control::PRESET_WIDE); @@ -3964,10 +3964,10 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito preview_camera->set_h_size_flags(0); preview_camera->hide(); preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); - previewing = NULL; + previewing = nullptr; gizmo_scale = 1.0; - preview_node = NULL; + preview_node = nullptr; info_label = memnew(Label); info_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); @@ -4030,7 +4030,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito surface->add_child(top_right_vbox); - accept = NULL; + accept = nullptr; freelook_active = false; freelook_speed = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_base_speed"); @@ -4393,12 +4393,12 @@ Node3DEditorViewportContainer::Node3DEditorViewportContainer() { /////////////////////////////////////////////////////////////////// -Node3DEditor *Node3DEditor::singleton = NULL; +Node3DEditor *Node3DEditor::singleton = nullptr; Node3DEditorSelectedItem::~Node3DEditorSelectedItem() { if (sbox_instance.is_valid()) - VisualServer::get_singleton()->free(sbox_instance); + RenderingServer::get_singleton()->free(sbox_instance); } void Node3DEditor::select_gizmo_highlight_axis(int p_axis) { @@ -4479,13 +4479,13 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) { Node3D *sp = Object::cast_to<Node3D>(p_what); if (!sp) - return NULL; + return nullptr; Node3DEditorSelectedItem *si = memnew(Node3DEditorSelectedItem); si->sp = sp; - si->sbox_instance = VisualServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario()); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF); + si->sbox_instance = RenderingServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario()); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, RS::SHADOW_CASTING_SETTING_OFF); return si; } @@ -4649,7 +4649,7 @@ void Node3DEditor::set_state(const Dictionary &p_state) { if (use != view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN))) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), use); - VisualServer::get_singleton()->instance_set_visible(origin_instance, use); + RenderingServer::get_singleton()->instance_set_visible(origin_instance, use); } } @@ -4954,7 +4954,7 @@ void Node3DEditor::_menu_item_pressed(int p_option) { bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option)); origin_enabled = !is_checked; - VisualServer::get_singleton()->instance_set_visible(origin_instance, origin_enabled); + RenderingServer::get_singleton()->instance_set_visible(origin_instance, origin_enabled); // Update the grid since its appearance depends on whether the origin is enabled _finish_grid(); _init_grid(); @@ -4969,7 +4969,7 @@ void Node3DEditor::_menu_item_pressed(int p_option) { for (int i = 0; i < 3; ++i) { if (grid_enable[i]) { - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled); grid_visible[i] = grid_enabled; } } @@ -5129,19 +5129,19 @@ void Node3DEditor::_init_indicators() { _init_grid(); - origin = VisualServer::get_singleton()->mesh_create(); + origin = RenderingServer::get_singleton()->mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_VERTEX] = origin_points; - d[VisualServer::ARRAY_COLOR] = origin_colors; + d.resize(RS::ARRAY_MAX); + d[RenderingServer::ARRAY_VERTEX] = origin_points; + d[RenderingServer::ARRAY_COLOR] = origin_colors; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin, VisualServer::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid()); + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(origin, RenderingServer::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid()); - origin_instance = VisualServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << Node3DEditorViewport::GIZMO_GRID_LAYER); + origin_instance = RenderingServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << Node3DEditorViewport::GIZMO_GRID_LAYER); - VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, VS::SHADOW_CASTING_SETTING_OFF); + RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, RS::SHADOW_CASTING_SETTING_OFF); } { @@ -5506,33 +5506,33 @@ void Node3DEditor::_init_grid() { grid_colors[i].push_back(line_color); } - grid[i] = VisualServer::get_singleton()->mesh_create(); + grid[i] = RenderingServer::get_singleton()->mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_VERTEX] = grid_points[i]; - d[VisualServer::ARRAY_COLOR] = grid_colors[i]; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid()); - grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); + d.resize(RS::ARRAY_MAX); + d[RenderingServer::ARRAY_VERTEX] = grid_points[i]; + d[RenderingServer::ARRAY_COLOR] = grid_colors[i]; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid()); + grid_instance[i] = RenderingServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]); - VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]); + RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER); } } void Node3DEditor::_finish_indicators() { - VisualServer::get_singleton()->free(origin_instance); - VisualServer::get_singleton()->free(origin); + RenderingServer::get_singleton()->free(origin_instance); + RenderingServer::get_singleton()->free(origin); _finish_grid(); } void Node3DEditor::_finish_grid() { for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->free(grid_instance[i]); - VisualServer::get_singleton()->free(grid[i]); + RenderingServer::get_singleton()->free(grid_instance[i]); + RenderingServer::get_singleton()->free(grid[i]); } } @@ -5658,8 +5658,8 @@ void Node3DEditor::snap_selected_nodes_to_floor() { } } - PhysicsDirectSpaceState *ss = get_tree()->get_root()->get_world()->get_direct_space_state(); - PhysicsDirectSpaceState::RayResult result; + PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world()->get_direct_space_state(); + PhysicsDirectSpaceState3D::RayResult result; Array keys = snap_data.keys(); @@ -5903,7 +5903,7 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { void Node3DEditor::_node_removed(Node *p_node) { if (p_node == selected) - selected = NULL; + selected = nullptr; } void Node3DEditor::_register_all_gizmos() { @@ -5919,8 +5919,8 @@ void Node3DEditor::_register_all_gizmos() { add_gizmo_plugin(Ref<SpringArmNode3DGizmoPlugin>(memnew(SpringArmNode3DGizmoPlugin))); add_gizmo_plugin(Ref<VehicleWheelNode3DGizmoPlugin>(memnew(VehicleWheelNode3DGizmoPlugin))); add_gizmo_plugin(Ref<VisibilityNotifierGizmoPlugin>(memnew(VisibilityNotifierGizmoPlugin))); - add_gizmo_plugin(Ref<ParticlesGizmoPlugin>(memnew(ParticlesGizmoPlugin))); - add_gizmo_plugin(Ref<CPUParticlesGizmoPlugin>(memnew(CPUParticlesGizmoPlugin))); + add_gizmo_plugin(Ref<GPUParticles3DGizmoPlugin>(memnew(GPUParticles3DGizmoPlugin))); + add_gizmo_plugin(Ref<CPUParticles3DGizmoPlugin>(memnew(CPUParticles3DGizmoPlugin))); add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin))); add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin))); // add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin))); @@ -5952,11 +5952,11 @@ void Node3DEditor::clear() { viewports[i]->reset(); } - VisualServer::get_singleton()->instance_set_visible(origin_instance, true); + RenderingServer::get_singleton()->instance_set_visible(origin_instance, true); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true); for (int i = 0; i < 3; ++i) { if (grid_enable[i]) { - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], true); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], true); grid_visible[i] = true; } } @@ -5979,7 +5979,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { undo_redo = p_editor->get_undo_redo(); VBoxContainer *vbc = this; - custom_camera = NULL; + custom_camera = nullptr; singleton = this; editor = p_editor; editor_selection = editor->get_editor_selection(); @@ -6313,9 +6313,9 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { xform_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_xform_dialog_action)); - scenario_debug = VisualServer::SCENARIO_DEBUG_DISABLED; + scenario_debug = RenderingServer::SCENARIO_DEBUG_DISABLED; - selected = NULL; + selected = nullptr; set_process_unhandled_key_input(true); add_to_group("_spatial_editor_group"); @@ -6761,8 +6761,8 @@ EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() { EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() { for (int i = 0; i < current_gizmos.size(); ++i) { - current_gizmos[i]->set_plugin(NULL); - current_gizmos[i]->get_spatial_node()->set_gizmo(NULL); + current_gizmos[i]->set_plugin(nullptr); + current_gizmos[i]->get_spatial_node()->set_gizmo(nullptr); } if (Node3DEditor::get_singleton()) { Node3DEditor::get_singleton()->update_all_gizmos(); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index af6bc43b80..552afb99e0 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -43,7 +43,7 @@ class Camera3D; class Node3DEditor; class EditorNode3DGizmoPlugin; class Node3DEditorViewport; -class ViewportContainer; +class SubViewportContainer; class EditorNode3DGizmo : public Node3DGizmo { @@ -123,7 +123,7 @@ public: Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; } Vector3 get_handle_pos(int p_idx) const; bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum); - bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false); + bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = nullptr, bool p_sec_first = false); virtual void clear(); virtual void create(); @@ -256,7 +256,7 @@ private: UndoRedo *undo_redo; CheckBox *preview_camera; - ViewportContainer *viewport_container; + SubViewportContainer *subviewport_container; MenuButton *view_menu; PopupMenu *display_submenu; @@ -295,7 +295,7 @@ private: void _clear_selected(); void _select_clicked(bool p_append, bool p_single, bool p_allow_locked = false); void _select(Node *p_node, bool p_append, bool p_single); - ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false); + ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = nullptr, bool p_alt_select = false); void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false); Vector3 _get_ray_pos(const Vector2 &p_pos) const; Vector3 _get_ray(const Vector2 &p_pos) const; @@ -487,7 +487,7 @@ public: RID sbox_instance; Node3DEditorSelectedItem() { - sp = NULL; + sp = nullptr; last_xform_dirty = true; } ~Node3DEditorSelectedItem(); @@ -578,7 +578,7 @@ private: ToolMode tool_mode; bool orthogonal; - VisualServer::ScenarioDebugMode scenario_debug; + RenderingServer::ScenarioDebugMode scenario_debug; RID origin; RID origin_instance; @@ -761,7 +761,7 @@ public: Ref<ArrayMesh> get_scale_plane_gizmo(int idx) const { return scale_plane_gizmo[idx]; } void update_transform_gizmo(); - void update_all_gizmos(Node *p_node = NULL); + void update_all_gizmos(Node *p_node = nullptr); void snap_selected_nodes_to_floor(); void select_gizmo_highlight_axis(int p_axis); void set_custom_camera(Node *p_camera) { custom_camera = p_camera; } @@ -788,7 +788,7 @@ public: void set_can_preview(Camera3D *p_preview); Node3DEditorViewport *get_editor_viewport(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, static_cast<int>(VIEWPORTS_COUNT), NULL); + ERR_FAIL_INDEX_V(p_idx, static_cast<int>(VIEWPORTS_COUNT), nullptr); return viewports[p_idx]; } diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 75c5fcb994..4516b7035b 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -56,7 +56,7 @@ void Path2DEditor::_notification(int p_what) { void Path2DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } @@ -288,7 +288,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 gpoint = mm->get_position(); Ref<Curve2D> curve = node->get_curve(); - if (curve == NULL) return true; + if (curve == nullptr) return true; if (curve->get_point_count() < 2) return true; // Find edge @@ -449,7 +449,7 @@ void Path2DEditor::edit(Node *p_path2d) { // node may have been deleted at this point if (node && node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed))) node->disconnect("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)); - node = NULL; + node = nullptr; } } @@ -532,7 +532,7 @@ void Path2DEditor::_handle_option_pressed(int p_option) { Path2DEditor::Path2DEditor(EditorNode *p_editor) { - canvas_item_editor = NULL; + canvas_item_editor = nullptr; editor = p_editor; undo_redo = editor->get_undo_redo(); mirror_handle_angle = true; @@ -620,7 +620,7 @@ void Path2DEditorPlugin::make_visible(bool p_visible) { path2d_editor->hide(); path2d_editor->base_hb->hide(); - path2d_editor->edit(NULL); + path2d_editor->edit(nullptr); } } diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index f3729a3e89..3ee8225418 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -460,7 +460,7 @@ void Path3DEditorPlugin::edit(Object *p_object) { } } else { Path3D *pre = path; - path = NULL; + path = nullptr; if (pre) { pre->get_curve()->emit_signal("changed"); } @@ -494,7 +494,7 @@ void Path3DEditorPlugin::make_visible(bool p_visible) { { Path3D *pre = path; - path = NULL; + path = nullptr; if (pre && pre->get_curve().is_valid()) { pre->get_curve()->emit_signal("changed"); } @@ -553,11 +553,11 @@ void Path3DEditorPlugin::_notification(int p_what) { void Path3DEditorPlugin::_bind_methods() { } -Path3DEditorPlugin *Path3DEditorPlugin::singleton = NULL; +Path3DEditorPlugin *Path3DEditorPlugin::singleton = nullptr; Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { - path = NULL; + path = nullptr; editor = p_node; singleton = this; mirror_handle_angle = true; @@ -637,7 +637,7 @@ Ref<EditorNode3DGizmo> PathNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) { } String PathNode3DGizmoPlugin::get_name() const { - return "Path"; + return "Path3D"; } int PathNode3DGizmoPlugin::get_priority() const { diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index ca051295f0..715f8d1bb5 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -50,7 +50,7 @@ public: virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); virtual void redraw(); - PathNode3DGizmo(Path3D *p_path = NULL); + PathNode3DGizmo(Path3D *p_path = nullptr); }; class PathNode3DGizmoPlugin : public EditorNode3DGizmoPlugin { @@ -103,9 +103,7 @@ public: static Path3DEditorPlugin *singleton; virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event); - //virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); } - //virtual Ref<Node3DEditorGizmo> create_spatial_gizmo(Spatial *p_spatial); - virtual String get_name() const { return "Path"; } + virtual String get_name() const { return "Path3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index dd6d7b109b..6d38f7f318 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -49,7 +49,7 @@ void PhysicalBone3DEditor::_set_move_joint() { PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) : editor(p_editor), - selected(NULL) { + selected(nullptr) { spatial_editor_hb = memnew(HBoxContainer); spatial_editor_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -90,7 +90,7 @@ void PhysicalBone3DEditor::show() { PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin(EditorNode *p_editor) : editor(p_editor), - selected(NULL), + selected(nullptr), physical_bone_editor(editor) {} void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) { @@ -100,8 +100,8 @@ void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) { } else { physical_bone_editor.hide(); - physical_bone_editor.set_selected(NULL); - selected = NULL; + physical_bone_editor.set_selected(nullptr); + selected = nullptr; } } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 5a94c95dd7..1f7a5b9968 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -107,7 +107,7 @@ void Polygon2DEditor::_notification(int p_what) { void Polygon2DEditor::_sync_bones() { - Skeleton2D *skeleton = NULL; + Skeleton2D *skeleton = nullptr; if (!node->has_node(node->get_skeleton())) { error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node")); error->popup_centered(); @@ -990,9 +990,9 @@ void Polygon2DEditor::_uv_draw() { mtx.elements[2] = -uv_draw_ofs; mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom)); - VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx); + RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx); uv_edit_draw->draw_texture(base_tex, Point2()); - VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D()); + RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D()); if (snap_show_grid) { Color grid_color = Color(1.0, 1.0, 1.0, 0.15); @@ -1031,7 +1031,7 @@ void Polygon2DEditor::_uv_draw() { uvs = node->get_polygon(); } - const float *weight_r; + const float *weight_r = nullptr; if (uv_edit_mode[3]->is_pressed()) { int bone_selected = -1; @@ -1044,7 +1044,6 @@ void Polygon2DEditor::_uv_draw() { } if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == uvs.size()) { - weight_r = node->get_bone_weights(bone_selected).ptr(); } } @@ -1250,7 +1249,7 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const { Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; snap_offset = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_offset", Vector2()); snap_step = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_step", Vector2(10, 10)); use_snap = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_enabled", false); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 8def56f968..852feeb675 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -181,7 +181,7 @@ void ResourcePreloaderEditor::_update_library() { tree->clear(); tree->set_hide_root(true); - TreeItem *root = tree->create_item(NULL); + TreeItem *root = tree->create_item(nullptr); List<StringName> rnames; preloader->get_resource_list(&rnames); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 516c52a8a4..67e836082d 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -88,7 +88,7 @@ void EditorPropertyRootMotion::_node_assign() { for (Set<String>::Element *E = paths.front(); E; E = E->next()) { NodePath path = E->get(); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; String accum; for (int i = 0; i < path.get_name_count(); i++) { String name = path.get_name(i); @@ -117,7 +117,7 @@ void EditorPropertyRootMotion::_node_assign() { } } - Node *node = NULL; + Node *node = nullptr; if (base->has_node(accum)) { node = base->get_node(accum); } @@ -212,7 +212,7 @@ void EditorPropertyRootMotion::update_property() { } assign->set_flat(true); - Node *base_node = NULL; + Node *base_node = nullptr; if (base_hint != NodePath()) { if (get_tree()->get_root()->has_node(base_hint)) { base_node = get_tree()->get_root()->get_node(base_hint); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 0e867f7b16..dd80fff008 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -193,7 +193,7 @@ void ScriptEditorQuickOpen::_update_search() { } } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void ScriptEditorQuickOpen::_confirmed() { @@ -252,7 +252,7 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { ///////////////////////////////// -ScriptEditor *ScriptEditor::script_editor = NULL; +ScriptEditor *ScriptEditor::script_editor = nullptr; /*** SCRIPT EDITOR ******/ @@ -321,7 +321,7 @@ void ScriptEditor::_set_execution(REF p_script, int p_line) { if (!se) continue; - if ((script != NULL && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { se->set_executing_line(p_line); } } @@ -337,7 +337,7 @@ void ScriptEditor::_clear_execution(REF p_script) { if (!se) continue; - if ((script != NULL && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { se->clear_executing_line(); } } @@ -348,7 +348,7 @@ ScriptEditorBase *ScriptEditor::_get_current_editor() const { int selected = tab_container->get_current_tab(); if (selected < 0 || selected >= tab_container->get_child_count()) - return NULL; + return nullptr; return Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected)); } @@ -434,7 +434,7 @@ void ScriptEditor::_go_to_tab(int p_idx) { Object::cast_to<ScriptEditorBase>(c)->ensure_focus(); Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { notify_script_changed(script); } @@ -575,7 +575,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { } Ref<Script> script = current->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { previous_scripts.push_back(script->get_path()); notify_script_close(script); } @@ -737,7 +737,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) { } Ref<TextFile> text_file = script; - if (text_file != NULL) { + if (text_file != nullptr) { se->apply_code(); _save_text_file(text_file, text_file->get_path()); break; @@ -775,7 +775,7 @@ void ScriptEditor::_reload_scripts() { } Ref<Script> script = edited_res; - if (script != NULL) { + if (script != nullptr) { Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true); ERR_CONTINUE(!rel_script.is_valid()); script->set_source_code(rel_script->get_source_code()); @@ -784,7 +784,7 @@ void ScriptEditor::_reload_scripts() { } Ref<TextFile> text_file = edited_res; - if (text_file != NULL) { + if (text_file != nullptr) { Error err; Ref<TextFile> rel_text_file = _load_text_file(text_file->get_path(), &err); ERR_CONTINUE(!rel_text_file.is_valid()); @@ -961,9 +961,9 @@ Ref<Script> ScriptEditor::_get_current_script() { if (current) { Ref<Script> script = current->get_edited_resource(); - return script != NULL ? script : NULL; + return script != nullptr ? script : nullptr; } else { - return NULL; + return nullptr; } } @@ -1093,11 +1093,6 @@ void ScriptEditor::_menu_option(int p_option) { OS::get_singleton()->shell_open("https://docs.godotengine.org/"); } break; - case REQUEST_DOCS: { - - OS::get_singleton()->shell_open("https://github.com/godotengine/godot-docs/issues/new"); - } break; - case WINDOW_NEXT: { _history_forward(); @@ -1145,7 +1140,7 @@ void ScriptEditor::_menu_option(int p_option) { } Ref<TextFile> text_file = current->get_edited_resource(); - if (text_file != NULL) { + if (text_file != nullptr) { current->apply_code(); _save_text_file(text_file, text_file->get_path()); break; @@ -1169,7 +1164,7 @@ void ScriptEditor::_menu_option(int p_option) { } Ref<TextFile> text_file = current->get_edited_resource(); - if (text_file != NULL) { + if (text_file != nullptr) { file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_option = FILE_SAVE_AS; @@ -1198,7 +1193,7 @@ void ScriptEditor::_menu_option(int p_option) { case FILE_RUN: { Ref<Script> scr = current->get_edited_resource(); - if (scr == NULL || scr.is_null()) { + if (scr == nullptr || scr.is_null()) { EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running.")); break; } @@ -1398,7 +1393,6 @@ void ScriptEditor::_notification(int p_what) { help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); site_search->set_icon(get_theme_icon("Instance", "EditorIcons")); - request_docs->set_icon(get_theme_icon("Issue", "EditorIcons")); script_forward->set_icon(get_theme_icon("Forward", "EditorIcons")); script_back->set_icon(get_theme_icon("Back", "EditorIcons")); @@ -1467,7 +1461,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { if (se) { Ref<Script> script = se->get_edited_resource(); - if (script == NULL || !script.is_valid()) + if (script == nullptr || !script.is_valid()) continue; if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed @@ -1500,7 +1494,7 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { continue; Ref<Script> script = se->get_edited_resource(); - if (script == NULL) { + if (script == nullptr) { continue; } @@ -1992,7 +1986,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra const bool should_open = open_dominant || !EditorNode::get_singleton()->is_changing_scene(); - if (script != NULL && script->get_language()->overrides_external_editor()) { + if (script != nullptr && script->get_language()->overrides_external_editor()) { if (should_open) { Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col); if (err != OK) @@ -2070,7 +2064,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra if (!se) continue; - if ((script != NULL && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { + if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { if (should_open) { if (tab_container->get_current_tab() != i) { @@ -2092,7 +2086,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra // doesn't have it, make a new one - ScriptEditorBase *se = NULL; + ScriptEditorBase *se = nullptr; for (int i = script_editor_func_count - 1; i >= 0; i--) { se = script_editor_funcs[i](p_resource); @@ -2107,7 +2101,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i](); se->add_syntax_highlighter(highlighter); - if (script != NULL && !highlighter_set) { + if (script != nullptr && !highlighter_set) { List<String> languages = highlighter->get_supported_languages(); if (languages.find(script->get_language()->get_name())) { se->set_syntax_highlighter(highlighter); @@ -2188,7 +2182,7 @@ void ScriptEditor::save_all_scripts() { if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) { Ref<TextFile> text_file = edited_res; - if (text_file != NULL) { + if (text_file != nullptr) { _save_text_file(text_file, text_file->get_path()); continue; } @@ -2574,7 +2568,7 @@ void ScriptEditor::_make_script_list_context_menu() { context_menu->add_separator(); if (se) { Ref<Script> scr = se->get_edited_resource(); - if (scr != NULL) { + if (scr != nullptr) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT); if (!scr.is_null() && scr->is_tool()) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_RUN); @@ -2831,7 +2825,7 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { Object::cast_to<ScriptEditorBase>(n)->ensure_focus(); Ref<Script> script = Object::cast_to<ScriptEditorBase>(n)->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { notify_script_changed(script); } } @@ -2872,7 +2866,7 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { continue; Ref<Script> script = se->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { out_scripts.push_back(script); } } @@ -3260,12 +3254,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(site_search); site_search->set_tooltip(TTR("Open Godot online documentation.")); - request_docs = memnew(ToolButton); - request_docs->set_text(TTR("Request Docs")); - request_docs->connect("pressed", callable_mp(this, &ScriptEditor::_menu_option), varray(REQUEST_DOCS)); - menu_hb->add_child(request_docs); - request_docs->set_tooltip(TTR("Help improve the Godot documentation by giving feedback.")); - help_search = memnew(ToolButton); help_search->set_text(TTR("Search Help")); help_search->connect("pressed", callable_mp(this, &ScriptEditor::_menu_option), varray(SEARCH_HELP)); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index ec598f0b42..e895867268 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -159,7 +159,6 @@ class ScriptEditor : public PanelContainer { REPLACE_IN_FILES, SEARCH_HELP, SEARCH_WEBSITE, - REQUEST_DOCS, HELP_SEARCH_FIND, HELP_SEARCH_FIND_NEXT, HELP_SEARCH_FIND_PREVIOUS, @@ -204,7 +203,6 @@ class ScriptEditor : public PanelContainer { Button *help_search; Button *site_search; - Button *request_docs; EditorHelpSearch *help_search_dialog; ItemList *script_list; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 2e95bb92f4..4b8383e1e5 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -747,7 +747,7 @@ static Vector<Node *> _find_all_node_for_script(Node *p_base, Node *p_current, c static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) { if (p_current->get_owner() != p_base && p_base != p_current) - return NULL; + return nullptr; Ref<Script> c = p_current->get_script(); if (c == p_script) return p_current; @@ -757,7 +757,7 @@ static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Scri return found; } - return NULL; + return nullptr; } static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) { @@ -999,7 +999,7 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) { } void ScriptTextEditor::update_toggle_scripts_button() { - if (code_editor != NULL) { + if (code_editor != nullptr) { code_editor->update_toggle_scripts_button(); } } @@ -1436,7 +1436,7 @@ void ScriptTextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { TextEdit *te = code_editor->get_text_edit(); te->_set_syntax_highlighting(p_highlighter); - if (p_highlighter != NULL) + if (p_highlighter != nullptr) highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true); else highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(TTR("Standard")), true); @@ -1444,7 +1444,7 @@ void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) void ScriptTextEditor::_change_syntax_highlighter(int p_idx) { Map<String, SyntaxHighlighter *>::Element *el = highlighters.front(); - while (el != NULL) { + while (el != nullptr) { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(el->key()), false); el = el->next(); } @@ -1517,7 +1517,7 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) - return NULL; + return nullptr; Ref<Script> scr = p_current_node->get_script(); @@ -1530,7 +1530,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const return n; } - return NULL; + return nullptr; } void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { @@ -1877,7 +1877,7 @@ ScriptTextEditor::ScriptTextEditor() { convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F6), EDIT_CAPITALIZE); convert_case->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option)); - highlighters[TTR("Standard")] = NULL; + highlighters[TTR("Standard")] = nullptr; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); @@ -1944,7 +1944,7 @@ ScriptTextEditor::ScriptTextEditor() { ScriptTextEditor::~ScriptTextEditor() { for (const Map<String, SyntaxHighlighter *>::Element *E = highlighters.front(); E; E = E->next()) { - if (E->get() != NULL) { + if (E->get() != nullptr) { memdelete(E->get()); } } @@ -1956,7 +1956,7 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { if (Object::cast_to<Script>(*p_resource)) { return memnew(ScriptTextEditor); } - return NULL; + return nullptr; } void ScriptTextEditor::register_editor() { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index c38bb09567..2a36700105 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -39,7 +39,7 @@ #include "editor/editor_settings.h" #include "editor/property_editor.h" #include "servers/display_server.h" -#include "servers/visual/shader_types.h" +#include "servers/rendering/shader_types.h" /*** SHADER SCRIPT EDITOR ****/ @@ -150,16 +150,16 @@ void ShaderTextEditor::_load_theme_settings() { if (shader.is_valid()) { - for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) { + for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) { for (const Map<StringName, ShaderLanguage::BuiltInInfo>::Element *F = E->get().built_ins.front(); F; F = F->next()) { keywords.push_back(F->key()); } } - for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())).size(); i++) { + for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())).size(); i++) { - keywords.push_back(ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode()))[i]); + keywords.push_back(ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()))[i]); } } @@ -200,7 +200,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo ShaderLanguage sl; String calltip; - sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip); + sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip); get_text_edit()->set_code_hint(calltip); } @@ -215,7 +215,7 @@ void ShaderTextEditor::_validate_script() { ShaderLanguage sl; - Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types()); + Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types()); if (err != OK) { String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text(); @@ -716,7 +716,7 @@ void ShaderEditorPlugin::edit(Object *p_object) { bool ShaderEditorPlugin::handles(Object *p_object) const { Shader *shader = Object::cast_to<Shader>(p_object); - return shader != NULL && shader->is_text_shader(); + return shader != nullptr && shader->is_text_shader(); } void ShaderEditorPlugin::make_visible(bool p_visible) { diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 900b40bd7a..f02ed590fc 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -39,7 +39,7 @@ #include "scene/gui/text_edit.h" #include "scene/main/timer.h" #include "scene/resources/shader.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" class ShaderTextEditor : public CodeTextEditor { diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 96b2e56538..c81d3f787e 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -38,7 +38,7 @@ void Skeleton2DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; options->hide(); } } @@ -131,7 +131,7 @@ void Skeleton2DEditorPlugin::make_visible(bool p_visible) { } else { sprite_editor->options->hide(); - sprite_editor->edit(NULL); + sprite_editor->edit(nullptr); } } diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index ae289dae4b..fac4cb19d8 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -144,7 +144,7 @@ void Skeleton3DEditor::_notification(int p_what) { void Skeleton3DEditor::_node_removed(Node *p_node) { if (p_node == skeleton) { - skeleton = NULL; + skeleton = nullptr; options->hide(); } } @@ -153,7 +153,7 @@ void Skeleton3DEditor::_bind_methods() { } Skeleton3DEditor::Skeleton3DEditor() { - skeleton = NULL; + skeleton = nullptr; options = memnew(MenuButton); Node3DEditor::get_singleton()->add_control_to_menu_panel(options); @@ -182,7 +182,7 @@ void Skeleton3DEditorPlugin::make_visible(bool p_visible) { } else { skeleton_editor->options->hide(); - skeleton_editor->edit(NULL); + skeleton_editor->edit(nullptr); } } diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 606e04bb79..2ba5a817bc 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -49,7 +49,7 @@ class Skeleton3DEditor : public Node { PhysicalBone3D *physical_bone; Transform relative_rest; // Relative to skeleton node BoneInfo() : - physical_bone(NULL) {} + physical_bone(nullptr) {} }; Skeleton3D *skeleton; diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp index 4b6a86bb5a..a22534eac0 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp @@ -90,7 +90,7 @@ SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) { play_btn->hide(); play_btn->connect("pressed", callable_mp(this, &SkeletonIK3DEditorPlugin::_play)); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, play_btn); - skeleton_ik = NULL; + skeleton_ik = nullptr; } SkeletonIK3DEditorPlugin::~SkeletonIK3DEditorPlugin() {} diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h index 1466d670ba..88472a2963 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.h +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h @@ -51,7 +51,7 @@ protected: static void _bind_methods(); public: - virtual String get_name() const { return "SkeletonIK"; } + virtual String get_name() const { return "SkeletonIK3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index ce994ee6c7..ab0f15d3d0 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -42,7 +42,7 @@ void Sprite2DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; options->hide(); } } @@ -593,7 +593,7 @@ void Sprite2DEditorPlugin::make_visible(bool p_visible) { } else { sprite_editor->options->hide(); - sprite_editor->edit(NULL); + sprite_editor->edit(nullptr); } } diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h index d0ebf9c84e..0add77843b 100644 --- a/editor/plugins/sprite_2d_editor_plugin.h +++ b/editor/plugins/sprite_2d_editor_plugin.h @@ -104,7 +104,7 @@ class Sprite2DEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual String get_name() const { return "Sprite"; } + virtual String get_name() const { return "Sprite2D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 41db0308c2..fbb6616dea 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -34,7 +34,7 @@ bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) { - return Object::cast_to<StyleBox>(p_object) != NULL; + return Object::cast_to<StyleBox>(p_object) != nullptr; } void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) { diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index aa86c48af1..2786a568ea 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -41,7 +41,7 @@ void TextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) { void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { TextEdit *te = code_editor->get_text_edit(); te->_set_syntax_highlighting(p_highlighter); - if (p_highlighter != NULL) { + if (p_highlighter != nullptr) { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true); } else { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text("Standard"), true); @@ -49,7 +49,7 @@ void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { // little work around. GDScript highlighter goes through text_edit for colours, // so to remove all colours we need to set and unset them here. - if (p_highlighter == NULL) { // standard + if (p_highlighter == nullptr) { // standard TextEdit *text_edit = code_editor->get_text_edit(); text_edit->add_theme_color_override("number_color", colors_cache.font_color); text_edit->add_theme_color_override("function_color", colors_cache.font_color); @@ -62,7 +62,7 @@ void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { void TextEditor::_change_syntax_highlighter(int p_idx) { Map<String, SyntaxHighlighter *>::Element *el = highlighters.front(); - while (el != NULL) { + while (el != nullptr) { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(el->key()), false); el = el->next(); } @@ -533,7 +533,7 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { if (Object::cast_to<TextFile>(*p_resource)) { return memnew(TextEditor); } - return NULL; + return nullptr; } void TextEditor::register_editor() { @@ -694,7 +694,7 @@ TextEditor::TextEditor() { convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE); convert_case->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); - highlighters["Standard"] = NULL; + highlighters["Standard"] = nullptr; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); @@ -727,7 +727,7 @@ TextEditor::TextEditor() { TextEditor::~TextEditor() { for (const Map<String, SyntaxHighlighter *>::Element *E = highlighters.front(); E; E = E->next()) { - if (E->get() != NULL) { + if (E->get() != nullptr) { memdelete(E->get()); } } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 3f76854571..c1184c1c89 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -144,7 +144,7 @@ TextureEditor::~TextureEditor() { // bool EditorInspectorPluginTexture::can_handle(Object *p_object) { - return Object::cast_to<ImageTexture>(p_object) != NULL || Object::cast_to<AtlasTexture>(p_object) != NULL || Object::cast_to<StreamTexture>(p_object) != NULL || Object::cast_to<LargeTexture>(p_object) != NULL || Object::cast_to<AnimatedTexture>(p_object) != NULL; + return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<StreamTexture>(p_object) != nullptr || Object::cast_to<LargeTexture>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr; } void EditorInspectorPluginTexture::parse_begin(Object *p_object) { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 029159180c..cd69c1e6f9 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -49,7 +49,7 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) { } void TextureRegionEditor::_region_draw() { - Ref<Texture2D> base_tex = NULL; + Ref<Texture2D> base_tex = nullptr; if (node_sprite) base_tex = node_sprite->get_texture(); else if (node_sprite_3d) @@ -68,9 +68,9 @@ void TextureRegionEditor::_region_draw() { mtx.elements[2] = -draw_ofs * draw_zoom; mtx.scale_basis(Vector2(draw_zoom, draw_zoom)); - VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx); + RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx); edit_draw->draw_texture(base_tex, Point2()); - VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D()); + RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D()); if (snap_mode == SNAP_GRID) { Color grid_color = Color(1.0, 1.0, 1.0, 0.15); @@ -672,7 +672,7 @@ void TextureRegionEditor::_update_autoslice() { autoslice_is_dirty = false; autoslice_cache.clear(); - Ref<Texture2D> texture = NULL; + Ref<Texture2D> texture = nullptr; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) @@ -767,11 +767,11 @@ void TextureRegionEditor::_notification(int p_what) { void TextureRegionEditor::_node_removed(Object *p_obj) { if (p_obj == node_sprite || p_obj == node_sprite_3d || p_obj == node_ninepatch || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) { - node_sprite = NULL; - node_sprite_3d = NULL; - node_ninepatch = NULL; - obj_styleBox = Ref<StyleBox>(NULL); - atlas_tex = Ref<AtlasTexture>(NULL); + node_sprite = nullptr; + node_sprite_3d = nullptr; + node_ninepatch = nullptr; + obj_styleBox = Ref<StyleBox>(nullptr); + atlas_tex = Ref<AtlasTexture>(nullptr); hide(); } } @@ -793,7 +793,7 @@ bool TextureRegionEditor::is_atlas_texture() { } bool TextureRegionEditor::is_ninepatch() { - return node_ninepatch != NULL; + return node_ninepatch != nullptr; } Sprite3D *TextureRegionEditor::get_sprite_3d() { @@ -826,11 +826,11 @@ void TextureRegionEditor::edit(Object *p_obj) { p_obj->add_change_receptor(this); _edit_region(); } else { - node_sprite = NULL; - node_sprite_3d = NULL; - node_ninepatch = NULL; - obj_styleBox = Ref<StyleBoxTexture>(NULL); - atlas_tex = Ref<AtlasTexture>(NULL); + node_sprite = nullptr; + node_sprite_3d = nullptr; + node_ninepatch = nullptr; + obj_styleBox = Ref<StyleBoxTexture>(nullptr); + atlas_tex = Ref<AtlasTexture>(nullptr); } edit_draw->update(); if ((node_sprite && !node_sprite->is_region()) || (node_sprite_3d && !node_sprite_3d->is_region())) { @@ -850,7 +850,7 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro } void TextureRegionEditor::_edit_region() { - Ref<Texture2D> texture = NULL; + Ref<Texture2D> texture = nullptr; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) @@ -896,11 +896,11 @@ Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const { } TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) { - node_sprite = NULL; - node_sprite_3d = NULL; - node_ninepatch = NULL; - obj_styleBox = Ref<StyleBoxTexture>(NULL); - atlas_tex = Ref<AtlasTexture>(NULL); + node_sprite = nullptr; + node_sprite_3d = nullptr; + node_ninepatch = nullptr; + obj_styleBox = Ref<StyleBoxTexture>(nullptr); + atlas_tex = Ref<AtlasTexture>(nullptr); editor = p_editor; undo_redo = editor->get_undo_redo(); @@ -1057,7 +1057,7 @@ void TextureRegionEditorPlugin::make_visible(bool p_visible) { manually_hidden = false; } texture_region_button->hide(); - region_editor->edit(NULL); + region_editor->edit(nullptr); } } diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 83dc84a0c2..ce421ac0a5 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -38,6 +38,13 @@ #include "editor/editor_settings.h" #include "scene/gui/split_container.h" +void TileMapEditor::_node_removed(Node *p_node) { + + if (p_node == node) { + node = nullptr; + } +} + void TileMapEditor::_notification(int p_what) { switch (p_what) { @@ -60,6 +67,7 @@ void TileMapEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed)); paint_button->set_icon(get_theme_icon("Edit", "EditorIcons")); bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons")); picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); @@ -80,6 +88,10 @@ void TileMapEditor::_notification(int p_what) { p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_theme_icon("Remove", "EditorIcons")); } break; + + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &TileMapEditor::_node_removed)); + } break; } } @@ -627,7 +639,7 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, if (r != bucket_cache_rect) _clear_bucket_cache(); // Cache grid is not initialized - if (bucket_cache_visited == NULL) { + if (bucket_cache_visited == nullptr) { bucket_cache_visited = new bool[area]; invalidate_cache = true; } @@ -894,7 +906,7 @@ void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Po void TileMapEditor::_clear_bucket_cache() { if (bucket_cache_visited) { delete[] bucket_cache_visited; - bucket_cache_visited = NULL; + bucket_cache_visited = nullptr; } } @@ -1773,7 +1785,7 @@ void TileMapEditor::edit(Node *p_tile_map) { _update_palette(); } else { - node = NULL; + node = nullptr; if (canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter))) canvas_item_editor_viewport->disconnect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)); @@ -1889,11 +1901,11 @@ void TileMapEditor::_clear_transform() { TileMapEditor::TileMapEditor(EditorNode *p_editor) { - node = NULL; + node = nullptr; manual_autotile = false; priority_atlastile = false; manual_position = Vector2(0, 0); - canvas_item_editor_viewport = NULL; + canvas_item_editor_viewport = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -1906,7 +1918,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { transpose = false; bucket_cache_tile = -1; - bucket_cache_visited = NULL; + bucket_cache_visited = nullptr; invalid_cell.resize(1); invalid_cell.write[0] = TileMap::INVALID_CELL; @@ -2142,7 +2154,7 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { tile_map_editor->get_toolbar()->hide(); tile_map_editor->get_toolbar_right()->hide(); tile_map_editor->get_tile_info()->hide(); - tile_map_editor->edit(NULL); + tile_map_editor->edit(nullptr); } } diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index 74969d3e64..f43e5bb5cb 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -211,6 +211,7 @@ class TileMapEditor : public VBoxContainer { protected: void _notification(int p_what); + void _node_removed(Node *p_node); static void _bind_methods(); CellOp _get_op_from_cell(const Point2i &p_pos); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index f5ffcc1a28..d1dda68c1d 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -528,8 +528,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { toolbar->add_child(spin_priority); spin_z_index = memnew(SpinBox); - spin_z_index->set_min(VS::CANVAS_ITEM_Z_MIN); - spin_z_index->set_max(VS::CANVAS_ITEM_Z_MAX); + spin_z_index->set_min(RS::CANVAS_ITEM_Z_MIN); + spin_z_index->set_max(RS::CANVAS_ITEM_Z_MAX); spin_z_index->set_step(1); spin_z_index->set_custom_minimum_size(Size2(100, 0)); spin_z_index->connect("value_changed", callable_mp(this, &TileSetEditor::_on_z_index_changed)); @@ -725,7 +725,7 @@ void TileSetEditor::_on_texture_list_selected(int p_index) { update_workspace_minsize(); } else { current_item_index = -1; - preview->set_texture(NULL); + preview->set_texture(nullptr); workspace->set_custom_minimum_size(Size2i()); update_workspace_tile_mode(); } @@ -3003,7 +3003,7 @@ void TileSetEditor::select_coord(const Vector2 &coord) { } } if (!found_collision_shape) - _set_edited_collision_shape(Ref<ConvexPolygonShape2D>(NULL)); + _set_edited_collision_shape(Ref<ConvexPolygonShape2D>(nullptr)); if (edited_occlusion_shape != tileset->autotile_get_light_occluder(get_current_tile(), coord)) edited_occlusion_shape = tileset->autotile_get_light_occluder(get_current_tile(), coord); if (edited_navigation_shape != tileset->autotile_get_navigation_polygon(get_current_tile(), coord)) @@ -3485,7 +3485,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_navigation_offset")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_shape_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_shape_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); - p_list->push_back(PropertyInfo(Variant::INT, "tile_z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1")); + p_list->push_back(PropertyInfo(Variant::INT, "tile_z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1")); } if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_COLLISION && tileset_editor->edited_collision_shape.is_valid()) { p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_collision", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_collision_shape->get_class())); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 3998a3233b..fe8392593b 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -35,7 +35,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" -VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = NULL; +VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr; void VersionControlEditorPlugin::_bind_methods() { @@ -171,7 +171,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { for (int i = 0; i < modified_file_paths.size(); i++) { file_path = modified_file_paths.get_key_at_index(i); - TreeItem *found = stage_files->search_item_text(file_path, 0, true); + TreeItem *found = stage_files->search_item_text(file_path, nullptr, true); if (!found) { ChangeType change_index = (ChangeType)(int)modified_file_paths.get_value_at_index(i); @@ -385,7 +385,7 @@ void VersionControlEditorPlugin::shut_down() { } EditorVCSInterface::get_singleton()->shut_down(); memdelete(EditorVCSInterface::get_singleton()); - EditorVCSInterface::set_singleton(NULL); + EditorVCSInterface::set_singleton(nullptr); EditorNode::get_singleton()->remove_control_from_dock(version_commit_dock); EditorNode::get_singleton()->remove_bottom_panel_item(version_control_dock); @@ -438,7 +438,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { set_up_choice->connect("item_selected", callable_mp(this, &VersionControlEditorPlugin::_selected_a_vcs)); set_up_hbc->add_child(set_up_choice); - set_up_init_settings = NULL; + set_up_init_settings = nullptr; set_up_init_button = memnew(Button); set_up_init_button->set_text(TTR("Initialize")); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 36f81b21ba..b1bd6392d8 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -45,14 +45,14 @@ #include "scene/main/window.h" #include "scene/resources/visual_shader_nodes.h" #include "servers/display_server.h" -#include "servers/visual/shader_types.h" +#include "servers/rendering/shader_types.h" Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) { if (get_script_instance()) { return get_script_instance()->call("create_editor", p_parent_resource, p_node); } - return NULL; + return nullptr; } void VisualShaderNodePlugin::_bind_methods() { @@ -352,7 +352,7 @@ void VisualShaderEditor::_update_options_menu() { for (int i = 0; i < options.size(); i++) { String path = options[i].category; Vector<String> subfolders = path.split("/"); - TreeItem *category = NULL; + TreeItem *category = nullptr; if (!folders.has(path)) { category = root; @@ -536,7 +536,7 @@ void VisualShaderEditor::_update_graph() { node->connect("dragged", callable_mp(this, &VisualShaderEditor::_node_dragged), varray(nodes[n_i])); - Control *custom_editor = NULL; + Control *custom_editor = nullptr; int port_offset = 0; if (is_group) { @@ -584,7 +584,7 @@ void VisualShaderEditor::_update_graph() { custom_editor->call_deferred("_show_prop_names", true); continue; } - custom_editor = NULL; + custom_editor = nullptr; } if (is_group) { @@ -1087,7 +1087,7 @@ void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) { } void VisualShaderEditor::_rebuild() { - if (visual_shader != NULL) { + if (visual_shader != nullptr) { EditorNode::get_singleton()->get_log()->clear(); visual_shader->rebuild(); } @@ -1111,7 +1111,7 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p group_node->set_size(size); - GraphNode *gn = NULL; + GraphNode *gn = nullptr; if (edit_type->get_selected() == p_type) { // check - otherwise the error will be emitted Node *node2 = graph->get_node(itos(p_node)); gn = Object::cast_to<GraphNode>(node2); @@ -1126,7 +1126,7 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p if (!expression_node.is_null()) { Control *text_box = expression_node->get_control(0); Size2 box_size = size; - if (gn != NULL) { + if (gn != nullptr) { if (box_size.x < 150 * EDSCALE || box_size.y < 0) { box_size.x = gn->get_size().x; } @@ -1274,7 +1274,7 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, ERR_FAIL_COND(!button); Variant value = vsn->get_input_port_default_value(p_port); property_editor->set_position(button->get_screen_position() + Vector2(0, button->get_size().height)); - property_editor->edit(NULL, "", value.get_type(), value, 0, ""); + property_editor->edit(nullptr, "", value.get_type(), value, 0, ""); property_editor->popup(); editing_node = p_node; editing_port = p_port; @@ -1304,7 +1304,7 @@ void VisualShaderEditor::_add_texture_node(const String &p_path) { VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { - ERR_FAIL_INDEX_V(p_idx, add_options.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, add_options.size(), nullptr); Ref<VisualShaderNode> vsnode; @@ -1312,7 +1312,7 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { if (!is_custom && add_options[p_idx].type != String()) { VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type)); - ERR_FAIL_COND_V(!vsn, NULL); + ERR_FAIL_COND_V(!vsn, nullptr); VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn); @@ -1410,10 +1410,10 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { vsnode = Ref<VisualShaderNode>(vsn); } else { - ERR_FAIL_COND_V(add_options[p_idx].script.is_null(), NULL); + ERR_FAIL_COND_V(add_options[p_idx].script.is_null(), nullptr); String base_type = add_options[p_idx].script->get_instance_base_type(); VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(base_type)); - ERR_FAIL_COND_V(!vsn, NULL); + ERR_FAIL_COND_V(!vsn, nullptr); vsnode = Ref<VisualShaderNode>(vsn); vsnode->set_script(add_options[p_idx].script); } @@ -2068,7 +2068,7 @@ void VisualShaderEditor::_member_filter_changed(const String &p_text) { void VisualShaderEditor::_member_selected() { TreeItem *item = members->get_selected(); - if (item != NULL && item->has_meta("id")) { + if (item != nullptr && item->has_meta("id")) { members_dialog->get_ok()->set_disabled(false); highend_label->set_visible(add_options[item->get_meta("id")].highend); node_desc->set_text(_get_description(item->get_meta("id"))); @@ -2084,7 +2084,7 @@ void VisualShaderEditor::_member_unselected() { void VisualShaderEditor::_member_create() { TreeItem *item = members->get_selected(); - if (item != NULL && item->has_meta("id")) { + if (item != nullptr && item->has_meta("id")) { int idx = members->get_selected()->get_meta("id"); _add_node(idx, add_options[idx].sub_func); members_dialog->hide(); @@ -2263,7 +2263,7 @@ void VisualShaderEditor::_update_preview() { ShaderLanguage sl; - Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types()); + Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types()); for (int i = 0; i < preview_text->get_line_count(); i++) { preview_text->set_line_as_marked(i, false); @@ -2298,7 +2298,7 @@ void VisualShaderEditor::_bind_methods() { ClassDB::bind_method("_is_available", &VisualShaderEditor::_is_available); } -VisualShaderEditor *VisualShaderEditor::singleton = NULL; +VisualShaderEditor *VisualShaderEditor::singleton = nullptr; VisualShaderEditor::VisualShaderEditor() { @@ -3129,7 +3129,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<StringName> properties = p_node->get_editable_properties(); if (properties.size() == 0) { - return NULL; + return nullptr; } List<PropertyInfo> props; @@ -3147,7 +3147,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par } if (pinfo.size() == 0) - return NULL; + return nullptr; properties.clear(); @@ -3158,7 +3158,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par EditorProperty *prop = EditorInspector::instantiate_property_editor(node.ptr(), pinfo[i].type, pinfo[i].name, pinfo[i].hint, pinfo[i].hint_string, pinfo[i].usage); if (!prop) - return NULL; + return nullptr; if (Object::cast_to<EditorPropertyResource>(prop)) { Object::cast_to<EditorPropertyResource>(prop)->set_use_sub_inspector(false); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 859718cba4..86df069b8b 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -135,7 +135,7 @@ void BackgroundProgress::end_task(const String &p_task) { //////////////////////////////////////////////// -ProgressDialog *ProgressDialog::singleton = NULL; +ProgressDialog *ProgressDialog::singleton = nullptr; void ProgressDialog::_notification(int p_what) { } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 39c24519c0..b30cd89c96 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -196,7 +196,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { name->set_editable(false); export_path->hide(); runnable->set_disabled(true); - parameters->edit(NULL); + parameters->edit(nullptr); presets->unselect_all(); duplicate_preset->set_disabled(true); delete_preset->set_disabled(true); @@ -1244,7 +1244,7 @@ ProjectExportDialog::ProjectExportDialog() { delete_preset->set_disabled(true); script_key_error->hide(); sections->hide(); - parameters->edit(NULL); + parameters->edit(nullptr); // Deletion dialog. diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index d3856cf778..0ca540a33f 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -191,7 +191,7 @@ private: if (valid_path != "" && !d->file_exists("project.godot")) { if (valid_path.ends_with(".zip")) { - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io); @@ -208,7 +208,7 @@ private: while (ret == UNZ_OK) { unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); if (String(fname).ends_with("project.godot")) { break; @@ -522,7 +522,7 @@ private: zip_path = project_path->get_text(); } - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); @@ -543,7 +543,7 @@ private: //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String path = fname; @@ -955,8 +955,8 @@ public: bool hover; ProjectListItemControl() { - favorite_button = NULL; - icon = NULL; + favorite_button = nullptr; + icon = nullptr; icon_needs_reload = true; hover = false; } @@ -1036,7 +1036,7 @@ public: grayed = p_grayed; missing = p_missing; version = p_version; - control = NULL; + control = nullptr; } _FORCE_INLINE_ bool operator==(const Item &l) const { @@ -1236,7 +1236,7 @@ void ProjectList::load_projects() { // Clear whole list for (int i = 0; i < _projects.size(); ++i) { Item &project = _projects.write[i]; - CRASH_COND(project.control == NULL); + CRASH_COND(project.control == nullptr); memdelete(project.control); // Why not queue_free()? } _projects.clear(); @@ -1346,7 +1346,7 @@ void ProjectList::create_project_item_control(int p_index) { ERR_FAIL_COND(p_index != _scroll_children->get_child_count()); Item &item = _projects.write[p_index]; - ERR_FAIL_COND(item.control != NULL); // Already created + ERR_FAIL_COND(item.control != nullptr); // Already created Ref<Texture2D> favorite_icon = get_theme_icon("Favorites", "EditorIcons"); Color font_color = get_theme_color("font_color", "Tree"); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index dfecadeda5..42493191a8 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -41,7 +41,7 @@ #include "scene/gui/margin_container.h" #include "scene/gui/tab_container.h" -ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL; +ProjectSettingsEditor *ProjectSettingsEditor::singleton = nullptr; static const char *_button_names[JOY_BUTTON_MAX] = { "DualShock Cross, Xbox A, Nintendo B", @@ -750,7 +750,7 @@ void ProjectSettingsEditor::_update_actions() { item->set_range(1, action["deadzone"]); item->set_custom_bg_color(1, input_editor->get_theme_color("prop_subsection", "Editor")); - const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != NULL; + const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != nullptr; const String tooltip = is_builtin_input ? TTR("Built-in actions can't be removed as they're used for UI navigation.") : TTR("Remove"); item->add_button(2, input_editor->get_theme_icon("Add", "EditorIcons"), 1, false, TTR("Add Event")); item->add_button(2, input_editor->get_theme_icon("Remove", "EditorIcons"), 2, false, tooltip); @@ -883,7 +883,7 @@ void ProjectSettingsEditor::_item_add() { // Initialize the property with the default value for the given type. // The type list starts at 1 (as we exclude Nil), so add 1 to the selected value. Callable::CallError ce; - const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), NULL, 0, ce); + const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), nullptr, 0, ce); String catname = category->get_text().strip_edges(); String propname = property->get_text().strip_edges(); @@ -1537,7 +1537,7 @@ void ProjectSettingsEditor::_update_translations() { updating_translations = true; translation_list->clear(); - TreeItem *root = translation_list->create_item(NULL); + TreeItem *root = translation_list->create_item(nullptr); translation_list->set_hide_root(true); if (ProjectSettings::get_singleton()->has_setting("locale/translations")) { @@ -1589,7 +1589,7 @@ void ProjectSettingsEditor::_update_translations() { translation_locales_list_created = true; translation_filter->clear(); - root = translation_filter->create_item(NULL); + root = translation_filter->create_item(nullptr); translation_filter->set_hide_root(true); translation_filter_treeitems.clear(); for (int i = 0; i < s; i++) { @@ -1622,8 +1622,8 @@ void ProjectSettingsEditor::_update_translations() { translation_remap->clear(); translation_remap_options->clear(); - root = translation_remap->create_item(NULL); - TreeItem *root2 = translation_remap_options->create_item(NULL); + root = translation_remap->create_item(nullptr); + TreeItem *root2 = translation_remap_options->create_item(nullptr); translation_remap->set_hide_root(true); translation_remap_options->set_hide_root(true); translation_res_option_add_button->set_disabled(true); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 41e15f47cc..444cae42c5 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1194,7 +1194,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } else if (owner) { - Node *node = NULL; + Node *node = nullptr; if (owner->is_class("Node")) node = Object::cast_to<Node>(owner); @@ -1500,7 +1500,7 @@ void CustomPropertyEditor::_draw_easing() { iflp = 1.0 - iflp; } - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color); prev = h; } @@ -1541,7 +1541,7 @@ void CustomPropertyEditor::_modified(String p_string) { v = value_editor[0]->get_text().to_int(); return; } else { - v = expr->execute(Array(), NULL, false); + v = expr->execute(Array(), nullptr, false); } emit_signal("variant_changed"); @@ -1713,7 +1713,7 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) { if (err != OK) { out = value_editor[0]->get_text().to_double(); } else { - out = expr->execute(Array(), NULL, false); + out = expr->execute(Array(), nullptr, false); } return out; } @@ -1924,7 +1924,7 @@ CustomPropertyEditor::CustomPropertyEditor() { action_buttons[i]->set_flat(true); } - color_picker = NULL; + color_picker = nullptr; file = memnew(EditorFileDialog); add_child(file); @@ -1963,7 +1963,7 @@ CustomPropertyEditor::CustomPropertyEditor() { add_child(menu); menu->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_menu_option)); - evaluator = NULL; + evaluator = nullptr; spinbox = memnew(SpinBox); add_child(spinbox); @@ -1975,6 +1975,6 @@ CustomPropertyEditor::CustomPropertyEditor() { slider->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); slider->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); - create_dialog = NULL; - property_select = NULL; + create_dialog = nullptr; + property_select = nullptr; } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 54b94ebb95..1960ecc604 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -96,7 +96,7 @@ void PropertySelector::_update_search() { } else if (type != Variant::NIL) { Variant v; Callable::CallError ce; - v = Variant::construct(type, NULL, 0, ce); + v = Variant::construct(type, nullptr, 0, ce); v.get_property_list(&props); } else { @@ -116,7 +116,7 @@ void PropertySelector::_update_search() { } } - TreeItem *category = NULL; + TreeItem *category = nullptr; bool found = false; @@ -152,7 +152,7 @@ void PropertySelector::_update_search() { for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { if (E->get().usage == PROPERTY_USAGE_CATEGORY) { - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); @@ -191,7 +191,7 @@ void PropertySelector::_update_search() { item->set_selectable(0, true); } - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } } else { @@ -201,7 +201,7 @@ void PropertySelector::_update_search() { if (type != Variant::NIL) { Variant v; Callable::CallError ce; - v = Variant::construct(type, NULL, 0, ce); + v = Variant::construct(type, nullptr, 0, ce); v.get_method_list(&methods); } else { @@ -220,14 +220,14 @@ void PropertySelector::_update_search() { } } - TreeItem *category = NULL; + TreeItem *category = nullptr; bool found = false; bool script_methods = false; for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { if (E->get().name.begins_with("*")) { - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); @@ -310,12 +310,12 @@ void PropertySelector::_update_search() { } } - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void PropertySelector::_confirmed() { @@ -410,7 +410,7 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const type = Variant::NIL; script = ObjectID(); properties = false; - instance = NULL; + instance = nullptr; virtuals_only = p_virtuals_only; popup_centered_ratio(0.6); @@ -427,7 +427,7 @@ void PropertySelector::select_method_from_script(const Ref<Script> &p_script, co type = Variant::NIL; script = p_script->get_instance_id(); properties = false; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -443,7 +443,7 @@ void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const type = p_type; script = ObjectID(); properties = false; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -464,7 +464,7 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str script = scr->get_instance_id(); } properties = false; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -480,7 +480,7 @@ void PropertySelector::select_property_from_base_type(const String &p_base, cons type = Variant::NIL; script = ObjectID(); properties = true; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -498,7 +498,7 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script, type = Variant::NIL; script = p_script->get_instance_id(); properties = true; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -515,7 +515,7 @@ void PropertySelector::select_property_from_basic_type(Variant::Type p_type, con type = p_type; script = ObjectID(); properties = true; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index f9efe6a50d..1363fe2942 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -38,8 +38,8 @@ #include "editor_settings.h" #include "scene/resources/texture.h" -static void (*_base_image_compress_pvrtc2_func)(Image *) = NULL; -static void (*_base_image_compress_pvrtc4_func)(Image *) = NULL; +static void (*_base_image_compress_pvrtc2_func)(Image *) = nullptr; +static void (*_base_image_compress_pvrtc4_func)(Image *) = nullptr; static void _compress_image(Image::CompressMode p_mode, Image *p_image) { diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 58bb061b58..4d9870235d 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -241,7 +241,7 @@ void EditorQuickOpen::_update_search() { ti->set_as_cursor(0); } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void EditorQuickOpen::_confirmed() { diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index c14462f07d..0266ef6a2b 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -45,7 +45,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; - preview_node = NULL; + preview_node = nullptr; set_title(TTR("Batch Rename")); @@ -369,7 +369,7 @@ void RenameDialog::_update_substitute() { void RenameDialog::_post_popup() { EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); - preview_node = NULL; + preview_node = nullptr; Array selected_node_list = editor_selection->get_selected_nodes(); ERR_FAIL_COND(selected_node_list.size() == 0); @@ -386,7 +386,7 @@ void RenameDialog::_update_preview_int(int new_value) { void RenameDialog::_update_preview(String new_text) { - if (lock_preview_update || preview_node == NULL) + if (lock_preview_update || preview_node == nullptr) return; has_errors = false; diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 1cd0a2cb0f..194dd57648 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -110,7 +110,7 @@ public: void reset(); void rename(); - RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo = NULL); + RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo = nullptr); ~RenameDialog(){}; }; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 7d429eb4b5..eaefd04c6b 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -47,7 +47,7 @@ #include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void SceneTreeDock::_nodes_drag_begin() { @@ -438,7 +438,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { return; editor_data->get_undo_redo().create_action(TTR("Clear Script")); - editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)NULL); + editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)nullptr); for (int i = 0; i < selection.size(); i++) { @@ -495,7 +495,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (index < lowest_id) lowest_id = index; if (E->get()->get_parent() != common_parent) - common_parent = NULL; + common_parent = nullptr; } if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0)) @@ -548,7 +548,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)")); editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); - Node *dupsingle = NULL; + Node *dupsingle = nullptr; List<Node *> editable_children; selection.sort_custom<Node::Comparator>(); @@ -675,7 +675,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(node, "add_child", root); editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename()); editor_data->get_undo_redo().add_do_method(root, "set_filename", String()); - editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)nullptr); editor_data->get_undo_redo().add_do_method(root, "set_owner", node); _node_replace_owner(root, root, node, MODE_DO); @@ -685,7 +685,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, node->get_index()); - editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)nullptr); editor_data->get_undo_redo().add_undo_method(node, "set_owner", root); _node_replace_owner(root, root, root, MODE_UNDO); @@ -962,7 +962,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { case TOOL_CREATE_USER_INTERFACE: case TOOL_CREATE_FAVORITE: { - Node *new_node = NULL; + Node *new_node = nullptr; if (TOOL_CREATE_FAVORITE == p_tool) { String name = selected_favorite_root.get_slicec(' ', 0); @@ -998,7 +998,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", new_node); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_do_reference(new_node); - editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)nullptr); editor_data->get_undo_redo().commit_action(); editor->edit_node(new_node); @@ -1144,7 +1144,7 @@ void SceneTreeDock::_notification(int p_what) { } break; case NOTIFICATION_PROCESS: { - bool show_create_root = bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) && get_tree()->get_edited_scene_root() == NULL; + bool show_create_root = bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) && get_tree()->get_edited_scene_root() == nullptr; if (show_create_root != create_root_dialog->is_visible_in_tree() && !remote_tree->is_visible()) { if (show_create_root) { @@ -1202,7 +1202,7 @@ void SceneTreeDock::_node_selected() { if (!node) { - editor->push_item(NULL); + editor->push_item(nullptr); return; } @@ -1466,7 +1466,7 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { for (int i = 0; i < p_node->get_child_count(); i++) _fill_path_renames(base_path, new_base_path, p_node->get_child(i), &path_renames); - perform_node_renames(NULL, &path_renames); + perform_node_renames(nullptr, &path_renames); } bool SceneTreeDock::_validate_no_foreign() { @@ -1662,7 +1662,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V } } - perform_node_renames(NULL, &path_renames); + perform_node_renames(nullptr, &path_renames); editor_data->get_undo_redo().commit_action(); } @@ -1805,7 +1805,7 @@ void SceneTreeDock::_delete_confirm() { if (entire_scene) { - editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)NULL); + editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)nullptr); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", edited_scene); editor_data->get_undo_redo().add_undo_method(edited_scene, "set_owner", edited_scene->get_owner()); editor_data->get_undo_redo().add_undo_method(scene_tree, "update_tree"); @@ -1822,10 +1822,10 @@ void SceneTreeDock::_delete_confirm() { if (!n->is_inside_tree() || !n->get_parent()) continue; - fill_path_renames(n, NULL, &path_renames); + fill_path_renames(n, nullptr, &path_renames); } - perform_node_renames(NULL, &path_renames); + perform_node_renames(nullptr, &path_renames); //delete for read for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { Node *n = E->get(); @@ -1859,7 +1859,7 @@ void SceneTreeDock::_delete_confirm() { if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) editor->get_viewport_control()->update(); - editor->push_item(NULL); + editor->push_item(nullptr); // Fixes the EditorHistory from still offering deleted notes EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); @@ -1908,7 +1908,7 @@ void SceneTreeDock::_selection_changed() { } else if (selection_size == 1) { editor->push_item(EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0]); } else { - editor->push_item(NULL); + editor->push_item(nullptr); } _update_script_button(); } @@ -1958,7 +1958,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_do_reference(child); - editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)nullptr); } editor_data->get_undo_redo().commit_action(); @@ -1982,7 +1982,7 @@ void SceneTreeDock::_create() { if (current_option == TOOL_NEW) { - Node *parent = NULL; + Node *parent = nullptr; if (edited_scene) { // If root exists in edited scene @@ -2052,7 +2052,7 @@ void SceneTreeDock::_create() { } } - Node *parent = NULL; + Node *parent = nullptr; if (only_one_top_node) parent = top_node->get_parent(); else @@ -2096,7 +2096,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop memdelete(default_oldnode); } - editor->push_item(NULL); + editor->push_item(nullptr); //reconnect signals List<MethodInfo> sl; @@ -2120,7 +2120,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<Node *> to_erase; for (int i = 0; i < n->get_child_count(); i++) { - if (n->get_child(i)->get_owner() == NULL && n->is_owned_by_parent()) { + if (n->get_child(i)->get_owner() == nullptr && n->is_owned_by_parent()) { to_erase.push_back(n->get_child(i)); } } @@ -2267,7 +2267,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { if (p_type == -1) { //drop at above selected node if (to_node == EditorNode::get_singleton()->get_edited_scene()) { - to_node = NULL; + to_node = nullptr; ERR_FAIL_MSG("Cannot perform drop above the root node!"); } @@ -2282,7 +2282,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { return; } - Node *lower_sibling = NULL; + Node *lower_sibling = nullptr; if (_has_visible_children(to_node)) { to_pos = 0; @@ -2500,8 +2500,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { bool is_external = (selection[0]->get_filename() != ""); if (is_external) { - bool is_inherited = selection[0]->get_scene_inherited_state() != NULL; - bool is_top_level = selection[0]->get_owner() == NULL; + bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr; + bool is_top_level = selection[0]->get_owner() == nullptr; if (is_inherited && is_top_level) { menu->add_separator(); if (profile_allow_editing) { @@ -2634,7 +2634,7 @@ void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) { } void SceneTreeDock::add_remote_tree_editor(Control *p_remote) { - ERR_FAIL_COND(remote_tree != NULL); + ERR_FAIL_COND(remote_tree != nullptr); add_child(p_remote); remote_tree = p_remote; remote_tree->hide(); @@ -2787,7 +2787,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel set_name("Scene"); editor = p_editor; - edited_scene = NULL; + edited_scene = nullptr; editor_data = &p_editor_data; editor_selection = p_editor_selection; scene_root = p_scene_root; @@ -2869,7 +2869,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel edit_local->set_toggle_mode(true); edit_local->connect("pressed", callable_mp(this, &SceneTreeDock::_local_tree_selected)); - remote_tree = NULL; + remote_tree = nullptr; button_hb->hide(); create_root_dialog = memnew(VBoxContainer); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index e41ea1ce97..31ef1ce7d0 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -247,10 +247,10 @@ public: void import_subscene(); void set_edited_scene(Node *p_scene); void instance(const String &p_file); - void instance_scenes(const Vector<String> &p_files, Node *p_parent = NULL); + void instance_scenes(const Vector<String> &p_files, Node *p_parent = nullptr); void set_selected(Node *p_node, bool p_emit_selected = false); void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames); - void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = NULL); + void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 831b7b6775..251c911038 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -42,7 +42,7 @@ Node *SceneTreeEditor::get_scene_node() { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); return get_tree()->get_edited_scene_root(); } @@ -78,7 +78,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->create_action(TTR("Toggle Visible")); _toggle_visible(n); List<Node *> selection = editor_selection->get_selected_node_list(); - if (selection.size() > 1 && selection.find(n) != NULL) { + if (selection.size() > 1 && selection.find(n) != nullptr) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Node *nv = E->get(); ERR_FAIL_COND(!nv); @@ -504,7 +504,7 @@ void SceneTreeEditor::_node_removed(Node *p_node) { } if (p_node == selected) { - selected = NULL; + selected = nullptr; emit_signal("node_selected"); } } @@ -529,7 +529,7 @@ void SceneTreeEditor::_update_tree() { updating_tree = true; tree->clear(); if (get_scene_node()) { - _add_nodes(get_scene_node(), NULL); + _add_nodes(get_scene_node(), nullptr); last_hash = hash_djb2_one_64(0); _compute_hash(get_scene_node(), last_hash); } @@ -667,7 +667,7 @@ void SceneTreeEditor::_notification(int p_what) { TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { if (!p_node) - return NULL; + return nullptr; NodePath np = p_node->get_metadata(0); if (np == p_path) @@ -682,7 +682,7 @@ TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { children = children->get_next(); } - return NULL; + return nullptr; } void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { @@ -697,7 +697,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { if (selected == p_node) return; - TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : NULL; + TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : nullptr; if (item) { // make visible when it's collapsed @@ -713,7 +713,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { } else { if (!p_node) - selected = NULL; + selected = nullptr; _update_tree(); selected = p_node; } @@ -906,7 +906,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from Vector<Node *> selected; Vector<Ref<Texture2D>> icons; - TreeItem *next = tree->get_next_selected(NULL); + TreeItem *next = tree->get_next_selected(nullptr); while (next) { NodePath np = next->get_metadata(0); @@ -1117,16 +1117,16 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope connect_to_script_mode = false; connecting_signal = false; - undo_redo = NULL; + undo_redo = nullptr; tree_dirty = true; - selected = NULL; + selected = nullptr; marked_selectable = false; marked_children_selectable = false; can_rename = p_can_rename; can_open_instance = p_can_open_instance; display_foreign = false; - editor_selection = NULL; + editor_selection = nullptr; if (p_label) { Label *label = memnew(Label); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 6bd06aff64..8910e8ec3a 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -125,8 +125,8 @@ void EditorSettingsDialog::_notification(int p_what) { } } break; case NOTIFICATION_READY: { - undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, NULL); - undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, NULL); + undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, nullptr); + undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, nullptr); undo_redo->set_commit_notify_callback(_undo_redo_callback, this); } break; case NOTIFICATION_ENTER_TREE: { @@ -263,7 +263,7 @@ void EditorSettingsDialog::_update_shortcuts() { // remove sections with no shortcuts for (Map<String, TreeItem *>::Element *E = sections.front(); E; E = E->next()) { TreeItem *section = E->get(); - if (section->get_children() == NULL) { + if (section->get_children() == nullptr) { root->remove_child(section); } } @@ -362,7 +362,7 @@ void EditorSettingsDialog::_tabs_tab_changed(int p_tab) { void EditorSettingsDialog::_focus_current_search_box() { Control *tab = tabs->get_current_tab_control(); - LineEdit *current_search_box = NULL; + LineEdit *current_search_box = nullptr; if (tab == tab_general) current_search_box = search_box; else if (tab == tab_shortcuts) diff --git a/editor/translations/extract.py b/editor/translations/extract.py index 10859c7c90..749bad5fff 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -10,23 +10,23 @@ import sys line_nb = False for arg in sys.argv[1:]: - if (arg == "--with-line-nb"): + if arg == "--with-line-nb": print("Enabling line numbers in the context locations.") line_nb = True else: os.sys.exit("Non supported argument '" + arg + "'. Aborting.") -if (not os.path.exists("editor")): +if not os.path.exists("editor"): os.sys.exit("ERROR: This script should be started from the root of the git repo.") matches = [] -for root, dirnames, filenames in os.walk('.'): +for root, dirnames, filenames in os.walk("."): dirnames[:] = [d for d in dirnames if d not in ["thirdparty"]] - for filename in fnmatch.filter(filenames, '*.cpp'): + for filename in fnmatch.filter(filenames, "*.cpp"): matches.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.h'): + for filename in fnmatch.filter(filenames, "*.h"): matches.append(os.path.join(root, filename)) matches.sort() @@ -51,52 +51,54 @@ msgstr "" "Content-Transfer-Encoding: 8-bit\\n" """ + def process_file(f, fname): global main_po, unique_str, unique_loc l = f.readline() lc = 1 - while (l): + while l: - patterns = ['RTR(\"', 'TTR(\"', 'TTRC(\"'] + patterns = ['RTR("', 'TTR("', 'TTRC("'] idx = 0 pos = 0 - while (pos >= 0): + while pos >= 0: pos = l.find(patterns[idx], pos) - if (pos == -1): - if (idx < len(patterns) - 1): + if pos == -1: + if idx < len(patterns) - 1: idx += 1 pos = 0 continue pos += len(patterns[idx]) msg = "" - while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')): + while pos < len(l) and (l[pos] != '"' or l[pos - 1] == "\\"): msg += l[pos] pos += 1 - location = os.path.relpath(fname).replace('\\', '/') - if (line_nb): + location = os.path.relpath(fname).replace("\\", "/") + if line_nb: location += ":" + str(lc) - if (not msg in unique_str): + if not msg in unique_str: main_po += "\n#: " + location + "\n" main_po += 'msgid "' + msg + '"\n' main_po += 'msgstr ""\n' unique_str.append(msg) unique_loc[msg] = [location] - elif (not location in unique_loc[msg]): + elif not location in unique_loc[msg]: # Add additional location to previous occurrence too msg_pos = main_po.find('\nmsgid "' + msg + '"') - if (msg_pos == -1): + if msg_pos == -1: print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.") - main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] + main_po = main_po[:msg_pos] + " " + location + main_po[msg_pos:] unique_loc[msg].append(location) l = f.readline() lc += 1 + print("Updating the editor.pot template...") for fname in matches: @@ -106,7 +108,7 @@ for fname in matches: with open("editor.pot", "w") as f: f.write(main_po) -if (os.name == "posix"): +if os.name == "posix": print("Wrapping template at 79 characters for compatibility with Weblate.") os.system("msgmerge -w79 editor.pot editor.pot > editor.pot.wrap") shutil.move("editor.pot.wrap", "editor.pot") @@ -114,7 +116,7 @@ if (os.name == "posix"): shutil.move("editor.pot", "editor/translations/editor.pot") # TODO: Make that in a portable way, if we care; if not, kudos to Unix users -if (os.name == "posix"): +if os.name == "posix": added = subprocess.check_output(r"git diff editor/translations/editor.pot | grep \+msgid | wc -l", shell=True) removed = subprocess.check_output(r"git diff editor/translations/editor.pot | grep \\\-msgid | wc -l", shell=True) print("\n# Template changes compared to the staged status:") diff --git a/gles_builders.py b/gles_builders.py index 92cf9357cf..6ff2f4248b 100644 --- a/gles_builders.py +++ b/gles_builders.py @@ -7,7 +7,6 @@ from platform_methods import subprocess_main class LegacyGLHeaderStruct: - def __init__(self): self.vertex_lines = [] self.fragment_lines = [] @@ -73,7 +72,7 @@ def include_file_in_legacygl_header(filename, header_data, depth): ifdefline = line.replace("#ifdef ", "").strip() if line.find("_EN_") != -1: - enumbase = ifdefline[:ifdefline.find("_EN_")] + enumbase = ifdefline[: ifdefline.find("_EN_")] ifdefline = ifdefline.replace("_EN_", "_") line = line.replace("_EN_", "_") if enumbase not in header_data.enums: @@ -86,12 +85,12 @@ def include_file_in_legacygl_header(filename, header_data, depth): if line.find("uniform") != -1 and line.lower().find("texunit:") != -1: # texture unit - texunitstr = line[line.find(":") + 1:].strip() + texunitstr = line[line.find(":") + 1 :].strip() if texunitstr == "auto": texunit = "-1" else: texunit = str(int(texunitstr)) - uline = line[:line.lower().find("//")] + uline = line[: line.lower().find("//")] uline = uline.replace("uniform", "") uline = uline.replace("highp", "") uline = uline.replace(";", "") @@ -99,10 +98,10 @@ def include_file_in_legacygl_header(filename, header_data, depth): for x in lines: x = x.strip() - x = x[x.rfind(" ") + 1:] + x = x[x.rfind(" ") + 1 :] if x.find("[") != -1: # unfiorm array - x = x[:x.find("[")] + x = x[: x.find("[")] if not x in header_data.texunit_names: header_data.texunits += [(x, texunit)] @@ -110,10 +109,10 @@ def include_file_in_legacygl_header(filename, header_data, depth): elif line.find("uniform") != -1 and line.lower().find("ubo:") != -1: # uniform buffer object - ubostr = line[line.find(":") + 1:].strip() + ubostr = line[line.find(":") + 1 :].strip() ubo = str(int(ubostr)) - uline = line[:line.lower().find("//")] - uline = uline[uline.find("uniform") + len("uniform"):] + uline = line[: line.lower().find("//")] + uline = uline[uline.find("uniform") + len("uniform") :] uline = uline.replace("highp", "") uline = uline.replace(";", "") uline = uline.replace("{", "").strip() @@ -121,10 +120,10 @@ def include_file_in_legacygl_header(filename, header_data, depth): for x in lines: x = x.strip() - x = x[x.rfind(" ") + 1:] + x = x[x.rfind(" ") + 1 :] if x.find("[") != -1: # unfiorm array - x = x[:x.find("[")] + x = x[: x.find("[")] if not x in header_data.ubo_names: header_data.ubos += [(x, ubo)] @@ -137,10 +136,10 @@ def include_file_in_legacygl_header(filename, header_data, depth): for x in lines: x = x.strip() - x = x[x.rfind(" ") + 1:] + x = x[x.rfind(" ") + 1 :] if x.find("[") != -1: # unfiorm array - x = x[:x.find("[")] + x = x[: x.find("[")] if not x in header_data.uniforms: header_data.uniforms += [x] @@ -150,7 +149,7 @@ def include_file_in_legacygl_header(filename, header_data, depth): uline = uline.replace("attribute ", "") uline = uline.replace("highp ", "") uline = uline.replace(";", "") - uline = uline[uline.find(" "):].strip() + uline = uline[uline.find(" ") :].strip() if uline.find("//") != -1: name, bind = uline.split("//") @@ -163,7 +162,7 @@ def include_file_in_legacygl_header(filename, header_data, depth): uline = line.replace("out ", "") uline = uline.replace("highp ", "") uline = uline.replace(";", "") - uline = uline[uline.find(" "):].strip() + uline = uline[uline.find(" ") :].strip() if uline.find("//") != -1: name, bind = uline.split("//") @@ -200,17 +199,19 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n") out_file_base = out_file - out_file_base = out_file_base[out_file_base.rfind("/") + 1:] - out_file_base = out_file_base[out_file_base.rfind("\\") + 1:] + out_file_base = out_file_base[out_file_base.rfind("/") + 1 :] + out_file_base = out_file_base[out_file_base.rfind("\\") + 1 :] out_file_ifdef = out_file_base.replace(".", "_").upper() fd.write("#ifndef " + out_file_ifdef + class_suffix + "_120\n") fd.write("#define " + out_file_ifdef + class_suffix + "_120\n") - out_file_class = out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "Shader" + class_suffix + out_file_class = ( + out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "Shader" + class_suffix + ) fd.write("\n\n") - fd.write("#include \"" + include + "\"\n\n\n") + fd.write('#include "' + include + '"\n\n\n') fd.write("class " + out_file_class + " : public Shader" + class_suffix + " {\n\n") - fd.write("\t virtual String get_shader_name() const { return \"" + out_file_class + "\"; }\n") + fd.write('\t virtual String get_shader_name() const { return "' + out_file_class + '"; }\n') fd.write("public:\n\n") @@ -228,29 +229,64 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n") if header_data.conditionals: - fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n") + fd.write( + "\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n" + ) fd.write("\t#ifdef DEBUG_ENABLED\n ") - fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; if (!is_version_valid()) return; ERR_FAIL_COND( get_active()!=this ); \n\n ") + fd.write( + "\t#define _FU if (get_uniform(p_uniform)<0) return; if (!is_version_valid()) return; ERR_FAIL_COND( get_active()!=this ); \n\n " + ) fd.write("\t#else\n ") fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; \n\n ") fd.write("\t#endif\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Size2i& p_vec2) { _FU GLint vec2[2]={p_vec2.x,p_vec2.y}; glUniform2iv(get_uniform(p_uniform),1,vec2); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n") - fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n") - - fd.write("""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Size2i& p_vec2) { _FU GLint vec2[2]={p_vec2.x,p_vec2.y}; glUniform2iv(get_uniform(p_uniform),1,vec2); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n" + ) + fd.write( + "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n" + ) + + fd.write( + """\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU const Transform &tr = p_transform; @@ -276,9 +312,11 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); } - """) + """ + ) - fd.write("""_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform2D& p_transform) { _FU + fd.write( + """_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform2D& p_transform) { _FU const Transform2D &tr = p_transform; @@ -304,9 +342,11 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); } - """) + """ + ) - fd.write("""_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU + fd.write( + """_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU GLfloat matrix[16]; @@ -320,7 +360,8 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix); } - """) + """ + ) fd.write("\n\n#undef _FU\n\n\n") @@ -340,21 +381,25 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 x = header_data.enums[xv] bits = 1 amt = len(x) - while (2 ** bits < amt): + while 2 ** bits < amt: bits += 1 strs = "{" for i in range(amt): - strs += "\"#define " + x[i] + "\\n\"," + strs += '"#define ' + x[i] + '\\n",' c = {} c["set_mask"] = "uint64_t(" + str(i) + ")<<" + str(bitofs) - c["clear_mask"] = "((uint64_t(1)<<40)-1) ^ (((uint64_t(1)<<" + str(bits) + ") - 1)<<" + str(bitofs) + ")" + c["clear_mask"] = ( + "((uint64_t(1)<<40)-1) ^ (((uint64_t(1)<<" + str(bits) + ") - 1)<<" + str(bitofs) + ")" + ) enum_vals.append(c) enum_constants.append(x[i]) - strs += "NULL}" + strs += "nullptr}" - fd.write("\t\t\t{(uint64_t(1<<" + str(bits) + ")-1)<<" + str(bitofs) + "," + str(bitofs) + "," + strs + "},\n") + fd.write( + "\t\t\t{(uint64_t(1<<" + str(bits) + ")-1)<<" + str(bitofs) + "," + str(bitofs) + "," + strs + "},\n" + ) bitofs += bits fd.write("\t\t};\n\n") @@ -373,31 +418,31 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 fd.write("\t\tstatic const char* _conditional_strings[]={\n") if header_data.conditionals: for x in header_data.conditionals: - fd.write("\t\t\t\"#define " + x + "\\n\",\n") + fd.write('\t\t\t"#define ' + x + '\\n",\n') conditionals_found.append(x) fd.write("\t\t};\n\n") else: - fd.write("\t\tstatic const char **_conditional_strings=NULL;\n") + fd.write("\t\tstatic const char **_conditional_strings=nullptr;\n") if header_data.uniforms: fd.write("\t\tstatic const char* _uniform_strings[]={\n") if header_data.uniforms: for x in header_data.uniforms: - fd.write("\t\t\t\"" + x + "\",\n") + fd.write('\t\t\t"' + x + '",\n') fd.write("\t\t};\n\n") else: - fd.write("\t\tstatic const char **_uniform_strings=NULL;\n") + fd.write("\t\tstatic const char **_uniform_strings=nullptr;\n") if output_attribs: if header_data.attributes: fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n") for x in header_data.attributes: - fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n") fd.write("\t\t};\n\n") else: - fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n") + fd.write("\t\tstatic AttributePair *_attribute_pairs=nullptr;\n") feedback_count = 0 @@ -408,9 +453,9 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 name = x[0] cond = x[1] if cond in conditionals_found: - fd.write("\t\t\t{\"" + name + "\"," + str(conditionals_found.index(cond)) + "},\n") + fd.write('\t\t\t{"' + name + '",' + str(conditionals_found.index(cond)) + "},\n") else: - fd.write("\t\t\t{\"" + name + "\",-1},\n") + fd.write('\t\t\t{"' + name + '",-1},\n') feedback_count += 1 @@ -419,33 +464,33 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 if gles2: pass else: - fd.write("\t\tstatic const Feedback* _feedbacks=NULL;\n") + fd.write("\t\tstatic const Feedback* _feedbacks=nullptr;\n") if header_data.texunits: fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") for x in header_data.texunits: - fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n") fd.write("\t\t};\n\n") else: - fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n") + fd.write("\t\tstatic TexUnitPair *_texunit_pairs=nullptr;\n") if not gles2 and header_data.ubos: fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n") for x in header_data.ubos: - fd.write("\t\t\t{\"" + x[0] + "\"," + x[1] + "},\n") + fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n") fd.write("\t\t};\n\n") else: if gles2: pass else: - fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n") + fd.write("\t\tstatic UBOPair *_ubo_pairs=nullptr;\n") fd.write("\t\tstatic const char _vertex_code[]={\n") for x in header_data.vertex_lines: for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") + fd.write(str(ord("\n")) + ",") fd.write("\t\t0};\n\n") fd.write("\t\tstatic const int _vertex_code_start=" + str(header_data.vertex_offset) + ";\n") @@ -455,28 +500,73 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") + fd.write(str(ord("\n")) + ",") fd.write("\t\t0};\n\n") fd.write("\t\tstatic const int _fragment_code_start=" + str(header_data.fragment_offset) + ";\n") if output_attribs: if gles2: - fd.write("\t\tsetup(_conditional_strings," + str(len(header_data.conditionals)) + ",_uniform_strings," + str(len(header_data.uniforms)) + ",_attribute_pairs," + str( - len(header_data.attributes)) + ", _texunit_pairs," + str(len(header_data.texunits)) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write( + "\t\tsetup(_conditional_strings," + + str(len(header_data.conditionals)) + + ",_uniform_strings," + + str(len(header_data.uniforms)) + + ",_attribute_pairs," + + str(len(header_data.attributes)) + + ", _texunit_pairs," + + str(len(header_data.texunits)) + + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n" + ) else: - fd.write("\t\tsetup(_conditional_strings," + str(len(header_data.conditionals)) + ",_uniform_strings," + str(len(header_data.uniforms)) + ",_attribute_pairs," + str( - len(header_data.attributes)) + ", _texunit_pairs," + str(len(header_data.texunits)) + ",_ubo_pairs," + str(len(header_data.ubos)) + ",_feedbacks," + str( - feedback_count) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write( + "\t\tsetup(_conditional_strings," + + str(len(header_data.conditionals)) + + ",_uniform_strings," + + str(len(header_data.uniforms)) + + ",_attribute_pairs," + + str(len(header_data.attributes)) + + ", _texunit_pairs," + + str(len(header_data.texunits)) + + ",_ubo_pairs," + + str(len(header_data.ubos)) + + ",_feedbacks," + + str(feedback_count) + + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n" + ) else: if gles2: - fd.write("\t\tsetup(_conditional_strings," + str(len(header_data.conditionals)) + ",_uniform_strings," + str(len(header_data.uniforms)) + ",_texunit_pairs," + str( - len(header_data.texunits)) + ",_enums," + str(len(header_data.enums)) + ",_enum_values," + str( - enum_value_count) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write( + "\t\tsetup(_conditional_strings," + + str(len(header_data.conditionals)) + + ",_uniform_strings," + + str(len(header_data.uniforms)) + + ",_texunit_pairs," + + str(len(header_data.texunits)) + + ",_enums," + + str(len(header_data.enums)) + + ",_enum_values," + + str(enum_value_count) + + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n" + ) else: - fd.write("\t\tsetup(_conditional_strings," + str(len(header_data.conditionals)) + ",_uniform_strings," + str(len(header_data.uniforms)) + ",_texunit_pairs," + str( - len(header_data.texunits)) + ",_enums," + str(len(header_data.enums)) + ",_enum_values," + str(enum_value_count) + ",_ubo_pairs," + str(len(header_data.ubos)) + ",_feedbacks," + str( - feedback_count) + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n") + fd.write( + "\t\tsetup(_conditional_strings," + + str(len(header_data.conditionals)) + + ",_uniform_strings," + + str(len(header_data.uniforms)) + + ",_texunit_pairs," + + str(len(header_data.texunits)) + + ",_enums," + + str(len(header_data.enums)) + + ",_enum_values," + + str(enum_value_count) + + ",_ubo_pairs," + + str(len(header_data.ubos)) + + ",_feedbacks," + + str(feedback_count) + + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n" + ) fd.write("\t}\n\n") @@ -495,12 +585,12 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2 def build_gles2_headers(target, source, env): for x in source: - build_legacygl_header(str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True, gles2=True) - + build_legacygl_header( + str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True, gles2=True + ) class RDHeaderStruct: - def __init__(self): self.vertex_lines = [] self.fragment_lines = [] @@ -594,30 +684,30 @@ def build_rd_header(filename): fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n") out_file_base = out_file - out_file_base = out_file_base[out_file_base.rfind("/") + 1:] - out_file_base = out_file_base[out_file_base.rfind("\\") + 1:] + out_file_base = out_file_base[out_file_base.rfind("/") + 1 :] + out_file_base = out_file_base[out_file_base.rfind("\\") + 1 :] out_file_ifdef = out_file_base.replace(".", "_").upper() fd.write("#ifndef " + out_file_ifdef + "_RD\n") fd.write("#define " + out_file_ifdef + "_RD\n") out_file_class = out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "ShaderRD" fd.write("\n") - fd.write("#include \"servers/visual/rasterizer_rd/shader_rd.h\"\n\n") + fd.write('#include "servers/rendering/rasterizer_rd/shader_rd.h"\n\n') fd.write("class " + out_file_class + " : public ShaderRD {\n\n") fd.write("public:\n\n") fd.write("\t" + out_file_class + "() {\n\n") - if (len(header_data.compute_lines)): + if len(header_data.compute_lines): fd.write("\t\tstatic const char _compute_code[] = {\n") for x in header_data.compute_lines: for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") + fd.write(str(ord("\n")) + ",") fd.write("\t\t0};\n\n") - fd.write("\t\tsetup(nullptr, nullptr, _compute_code, \"" + out_file_class + "\");\n") + fd.write('\t\tsetup(nullptr, nullptr, _compute_code, "' + out_file_class + '");\n') fd.write("\t}\n") else: @@ -626,17 +716,17 @@ def build_rd_header(filename): for x in header_data.vertex_lines: for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") + fd.write(str(ord("\n")) + ",") fd.write("\t\t0};\n\n") - + fd.write("\t\tstatic const char _fragment_code[]={\n") for x in header_data.fragment_lines: for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") + fd.write(str(ord("\n")) + ",") fd.write("\t\t0};\n\n") - fd.write("\t\tsetup(_vertex_code, _fragment_code, nullptr, \"" + out_file_class + "\");\n") + fd.write('\t\tsetup(_vertex_code, _fragment_code, nullptr, "' + out_file_class + '");\n') fd.write("\t}\n") fd.write("};\n\n") @@ -650,5 +740,5 @@ def build_rd_headers(target, source, env): build_rd_header(str(x)) -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/main/SCsub b/main/SCsub index 0262701d79..7a301b82bc 100644 --- a/main/SCsub +++ b/main/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") from platform_methods import run_in_subprocess import main_builders @@ -14,13 +14,15 @@ env.Depends("#main/splash.gen.h", "#main/splash.png") env.CommandNoCache("#main/splash.gen.h", "#main/splash.png", run_in_subprocess(main_builders.make_splash)) env.Depends("#main/splash_editor.gen.h", "#main/splash_editor.png") -env.CommandNoCache("#main/splash_editor.gen.h", "#main/splash_editor.png", run_in_subprocess(main_builders.make_splash_editor)) +env.CommandNoCache( + "#main/splash_editor.gen.h", "#main/splash_editor.png", run_in_subprocess(main_builders.make_splash_editor) +) env.Depends("#main/app_icon.gen.h", "#main/app_icon.png") env.CommandNoCache("#main/app_icon.gen.h", "#main/app_icon.png", run_in_subprocess(main_builders.make_app_icon)) if env["tools"]: - SConscript('tests/SCsub') + SConscript("tests/SCsub") lib = env.add_library("main", env.main_sources) env.Prepend(LIBS=[lib]) diff --git a/main/main.cpp b/main/main.cpp index 9e7e0e8842..2a525dbe5a 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -65,13 +65,13 @@ #include "servers/audio_server.h" #include "servers/camera_server.h" #include "servers/display_server.h" -#include "servers/navigation_2d_server.h" -#include "servers/navigation_server.h" -#include "servers/physics_2d_server.h" -#include "servers/physics_server.h" +#include "servers/navigation_server_2d.h" +#include "servers/navigation_server_3d.h" +#include "servers/physics_server_2d.h" +#include "servers/physics_server_3d.h" #include "servers/register_server_types.h" -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "servers/rendering/rendering_server_raster.h" +#include "servers/rendering/rendering_server_wrap_mt.h" #ifdef TOOLS_ENABLED #include "editor/doc_data.h" @@ -87,29 +87,29 @@ // Singletons // Initialized in setup() -static Engine *engine = NULL; -static ProjectSettings *globals = NULL; -static InputFilter *input = NULL; -static InputMap *input_map = NULL; -static TranslationServer *translation_server = NULL; -static Performance *performance = NULL; -static PackedData *packed_data = NULL; +static Engine *engine = nullptr; +static ProjectSettings *globals = nullptr; +static InputFilter *input = nullptr; +static InputMap *input_map = nullptr; +static TranslationServer *translation_server = nullptr; +static Performance *performance = nullptr; +static PackedData *packed_data = nullptr; #ifdef MINIZIP_ENABLED -static ZipArchive *zip_packed_data = NULL; +static ZipArchive *zip_packed_data = nullptr; #endif -static FileAccessNetworkClient *file_access_network_client = NULL; -static MessageQueue *message_queue = NULL; +static FileAccessNetworkClient *file_access_network_client = nullptr; +static MessageQueue *message_queue = nullptr; // Initialized in setup2() -static AudioServer *audio_server = NULL; -static DisplayServer *display_server = NULL; -static VisualServer *visual_server = NULL; -static CameraServer *camera_server = NULL; -static ARVRServer *arvr_server = NULL; -static PhysicsServer *physics_server = NULL; -static Physics2DServer *physics_2d_server = NULL; -static NavigationServer *navigation_server = NULL; -static Navigation2DServer *navigation_2d_server = NULL; +static AudioServer *audio_server = nullptr; +static DisplayServer *display_server = nullptr; +static RenderingServer *rendering_server = nullptr; +static CameraServer *camera_server = nullptr; +static ARVRServer *arvr_server = nullptr; +static PhysicsServer3D *physics_server = nullptr; +static PhysicsServer2D *physics_2d_server = nullptr; +static NavigationServer3D *navigation_server = nullptr; +static NavigationServer2D *navigation_2d_server = nullptr; // We error out if setup2() doesn't turn this true static bool _start_success = false; @@ -180,23 +180,23 @@ static String get_full_version_string() { return String(VERSION_FULL_BUILD) + hash; } -// FIXME: Could maybe be moved to PhysicsServerManager and Physics2DServerManager directly +// FIXME: Could maybe be moved to PhysicsServer3DManager and PhysicsServer2DManager directly // to have less code in main.cpp. void initialize_physics() { /// 3D Physics Server - physics_server = PhysicsServerManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServerManager::setting_property_name)); + physics_server = PhysicsServer3DManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServer3DManager::setting_property_name)); if (!physics_server) { // Physics server not found, Use the default physics - physics_server = PhysicsServerManager::new_default_server(); + physics_server = PhysicsServer3DManager::new_default_server(); } ERR_FAIL_COND(!physics_server); physics_server->init(); /// 2D Physics server - physics_2d_server = Physics2DServerManager::new_server(ProjectSettings::get_singleton()->get(Physics2DServerManager::setting_property_name)); + physics_2d_server = PhysicsServer2DManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServer2DManager::setting_property_name)); if (!physics_2d_server) { // Physics server not found, Use the default physics - physics_2d_server = Physics2DServerManager::new_default_server(); + physics_2d_server = PhysicsServer2DManager::new_default_server(); } ERR_FAIL_COND(!physics_2d_server); physics_2d_server->init(); @@ -213,25 +213,25 @@ void finalize_physics() { void finalize_display() { - visual_server->finish(); - memdelete(visual_server); + rendering_server->finish(); + memdelete(rendering_server); memdelete(display_server); } void initialize_navigation_server() { - ERR_FAIL_COND(navigation_server != NULL); + ERR_FAIL_COND(navigation_server != nullptr); - navigation_server = NavigationServerManager::new_default_server(); - navigation_2d_server = memnew(Navigation2DServer); + navigation_server = NavigationServer3DManager::new_default_server(); + navigation_2d_server = memnew(NavigationServer2D); } void finalize_navigation_server() { memdelete(navigation_server); - navigation_server = NULL; + navigation_server = nullptr; memdelete(navigation_2d_server); - navigation_2d_server = NULL; + navigation_2d_server = nullptr; } //#define DEBUG_INIT @@ -1273,12 +1273,12 @@ Error Main::setup2(Thread::ID p_main_tid_override) { /* Initialize Visual Server */ - visual_server = memnew(VisualServerRaster); + rendering_server = memnew(RenderingServerRaster); if (OS::get_singleton()->get_render_thread_mode() != OS::RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD)); + rendering_server = memnew(RenderingServerWrapMT(rendering_server, OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD)); } - visual_server->init(); + rendering_server->init(); OS::get_singleton()->initialize_joypads(); @@ -1333,7 +1333,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { MAIN_PRINT("Main: Load Remaps"); Color clear = GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3)); - VisualServer::get_singleton()->set_default_clear_color(clear); + RenderingServer::get_singleton()->set_default_clear_color(clear); if (show_logo) { //boot logo! String boot_logo_path = GLOBAL_DEF("application/boot_splash/image", String()); @@ -1355,7 +1355,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color); if (boot_logo.is_valid()) { OS::get_singleton()->_msec_splash = OS::get_singleton()->get_ticks_msec(); - VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter); + RenderingServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, boot_logo_filter); } else { #ifndef NO_DEFAULT_BOOT_LOGO @@ -1367,9 +1367,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) { #endif MAIN_PRINT("Main: ClearColor"); - VisualServer::get_singleton()->set_default_clear_color(boot_bg_color); + RenderingServer::get_singleton()->set_default_clear_color(boot_bg_color); MAIN_PRINT("Main: Image"); - VisualServer::get_singleton()->set_boot_image(splash, boot_bg_color, false); + RenderingServer::get_singleton()->set_boot_image(splash, boot_bg_color, false); #endif } @@ -1380,7 +1380,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { } MAIN_PRINT("Main: DCC"); - VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3))); + RenderingServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3))); MAIN_PRINT("Main: END"); GLOBAL_DEF("application/config/icon", String()); @@ -1642,7 +1642,7 @@ bool Main::start() { game_path = GLOBAL_DEF("application/run/main_scene", ""); } - MainLoop *main_loop = NULL; + MainLoop *main_loop = nullptr; if (editor) { main_loop = memnew(SceneTree); }; @@ -1772,7 +1772,7 @@ bool Main::start() { RES res = ResourceLoader::load(path); ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + path); - Node *n = NULL; + Node *n = nullptr; if (res->is_class("PackedScene")) { Ref<PackedScene> ps = res; n = ps->instance(); @@ -1784,7 +1784,7 @@ bool Main::start() { Object *obj = ClassDB::instance(ibt); - ERR_CONTINUE_MSG(obj == NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); + ERR_CONTINUE_MSG(obj == nullptr, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); n = Object::cast_to<Node>(obj); n->set_script(script_res); @@ -1811,7 +1811,7 @@ bool Main::start() { } #ifdef TOOLS_ENABLED - EditorNode *editor_node = NULL; + EditorNode *editor_node = nullptr; if (editor) { editor_node = memnew(EditorNode); sml->get_root()->add_child(editor_node); @@ -1826,7 +1826,7 @@ bool Main::start() { { int directional_atlas_size = GLOBAL_GET("rendering/quality/directional_shadow/size"); - VisualServer::get_singleton()->directional_shadow_atlas_set_size(directional_atlas_size); + RenderingServer::get_singleton()->directional_shadow_atlas_set_size(directional_atlas_size); } if (!editor && !project_manager) { @@ -1961,7 +1961,7 @@ bool Main::start() { Crypto::load_default_certificates(GLOBAL_DEF("network/ssl/certificates", "")); if (game_path != "") { - Node *scene = NULL; + Node *scene = nullptr; Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path); if (scenedata.is_valid()) scene = scenedata->instance(); @@ -2101,25 +2101,25 @@ bool Main::iteration() { uint64_t physics_begin = OS::get_singleton()->get_ticks_usec(); - PhysicsServer::get_singleton()->sync(); - PhysicsServer::get_singleton()->flush_queries(); + PhysicsServer3D::get_singleton()->sync(); + PhysicsServer3D::get_singleton()->flush_queries(); - Physics2DServer::get_singleton()->sync(); - Physics2DServer::get_singleton()->flush_queries(); + PhysicsServer2D::get_singleton()->sync(); + PhysicsServer2D::get_singleton()->flush_queries(); if (OS::get_singleton()->get_main_loop()->iteration(frame_slice * time_scale)) { exit = true; break; } - NavigationServer::get_singleton_mut()->process(frame_slice * time_scale); + NavigationServer3D::get_singleton_mut()->process(frame_slice * time_scale); message_queue->flush(); - PhysicsServer::get_singleton()->step(frame_slice * time_scale); + PhysicsServer3D::get_singleton()->step(frame_slice * time_scale); - Physics2DServer::get_singleton()->end_sync(); - Physics2DServer::get_singleton()->step(frame_slice * time_scale); + PhysicsServer2D::get_singleton()->end_sync(); + PhysicsServer2D::get_singleton()->step(frame_slice * time_scale); message_queue->flush(); @@ -2137,17 +2137,17 @@ bool Main::iteration() { } message_queue->flush(); - VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames. + RenderingServer::get_singleton()->sync(); //sync if still drawing from previous frames. if (DisplayServer::get_singleton()->can_any_window_draw() && !disable_render_loop) { if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) { - if (VisualServer::get_singleton()->has_changed()) { - VisualServer::get_singleton()->draw(true, scaled_step); // flush visual commands + if (RenderingServer::get_singleton()->has_changed()) { + RenderingServer::get_singleton()->draw(true, scaled_step); // flush visual commands Engine::get_singleton()->frames_drawn++; } } else { - VisualServer::get_singleton()->draw(true, scaled_step); // flush visual commands + RenderingServer::get_singleton()->draw(true, scaled_step); // flush visual commands Engine::get_singleton()->frames_drawn++; force_redraw_requested = false; } @@ -2262,7 +2262,7 @@ void Main::cleanup() { ScriptServer::finish_languages(); // Sync pending commands that may have been queued from a different thread during ScriptServer finalization - VisualServer::get_singleton()->sync(); + RenderingServer::get_singleton()->sync(); #ifdef TOOLS_ENABLED EditorNode::unregister_editor_types(); diff --git a/main/main_builders.py b/main/main_builders.py index aebac2b022..2ea774e3b4 100644 --- a/main/main_builders.py +++ b/main/main_builders.py @@ -18,7 +18,7 @@ def make_splash(target, source, env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef BOOT_SPLASH_H\n") g.write("#define BOOT_SPLASH_H\n") - g.write('static const Color boot_splash_bg_color = Color(0.14, 0.14, 0.14);\n') + 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(str(buf[i]) + ",\n") @@ -37,7 +37,7 @@ def make_splash_editor(target, source, env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef BOOT_SPLASH_EDITOR_H\n") g.write("#define BOOT_SPLASH_EDITOR_H\n") - g.write('static const Color boot_splash_editor_bg_color = Color(0.14, 0.14, 0.14);\n') + 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(str(buf[i]) + ",\n") @@ -63,5 +63,5 @@ def make_app_icon(target, source, env): g.write("#endif") -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/main/performance.cpp b/main/performance.cpp index c7e3a41aa6..3ca7d7bed8 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -35,11 +35,11 @@ #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "servers/audio_server.h" -#include "servers/physics_2d_server.h" -#include "servers/physics_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/physics_server_3d.h" +#include "servers/rendering_server.h" -Performance *Performance::singleton = NULL; +Performance *Performance::singleton = nullptr; void Performance::_bind_methods() { @@ -135,22 +135,22 @@ float Performance::get_monitor(Monitor p_monitor) const { case OBJECT_RESOURCE_COUNT: return ResourceCache::get_cached_resource_count(); case OBJECT_NODE_COUNT: return _get_node_count(); case OBJECT_ORPHAN_NODE_COUNT: return Node::orphan_node_count; - case RENDER_OBJECTS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_OBJECTS_IN_FRAME); - case RENDER_VERTICES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_VERTICES_IN_FRAME); - case RENDER_MATERIAL_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME); - case RENDER_SHADER_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME); - case RENDER_SURFACE_CHANGES_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME); - case RENDER_DRAW_CALLS_IN_FRAME: return VS::get_singleton()->get_render_info(VS::INFO_DRAW_CALLS_IN_FRAME); - case RENDER_VIDEO_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VIDEO_MEM_USED); - case RENDER_TEXTURE_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED); - case RENDER_VERTEX_MEM_USED: return VS::get_singleton()->get_render_info(VS::INFO_VERTEX_MEM_USED); - case RENDER_USAGE_VIDEO_MEM_TOTAL: return VS::get_singleton()->get_render_info(VS::INFO_USAGE_VIDEO_MEM_TOTAL); - case PHYSICS_2D_ACTIVE_OBJECTS: return Physics2DServer::get_singleton()->get_process_info(Physics2DServer::INFO_ACTIVE_OBJECTS); - case PHYSICS_2D_COLLISION_PAIRS: return Physics2DServer::get_singleton()->get_process_info(Physics2DServer::INFO_COLLISION_PAIRS); - case PHYSICS_2D_ISLAND_COUNT: return Physics2DServer::get_singleton()->get_process_info(Physics2DServer::INFO_ISLAND_COUNT); - case PHYSICS_3D_ACTIVE_OBJECTS: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_ACTIVE_OBJECTS); - case PHYSICS_3D_COLLISION_PAIRS: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_COLLISION_PAIRS); - case PHYSICS_3D_ISLAND_COUNT: return PhysicsServer::get_singleton()->get_process_info(PhysicsServer::INFO_ISLAND_COUNT); + case RENDER_OBJECTS_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_OBJECTS_IN_FRAME); + case RENDER_VERTICES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_VERTICES_IN_FRAME); + case RENDER_MATERIAL_CHANGES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_MATERIAL_CHANGES_IN_FRAME); + case RENDER_SHADER_CHANGES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_SHADER_CHANGES_IN_FRAME); + case RENDER_SURFACE_CHANGES_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_SURFACE_CHANGES_IN_FRAME); + case RENDER_DRAW_CALLS_IN_FRAME: return RS::get_singleton()->get_render_info(RS::INFO_DRAW_CALLS_IN_FRAME); + case RENDER_VIDEO_MEM_USED: return RS::get_singleton()->get_render_info(RS::INFO_VIDEO_MEM_USED); + case RENDER_TEXTURE_MEM_USED: return RS::get_singleton()->get_render_info(RS::INFO_TEXTURE_MEM_USED); + case RENDER_VERTEX_MEM_USED: return RS::get_singleton()->get_render_info(RS::INFO_VERTEX_MEM_USED); + case RENDER_USAGE_VIDEO_MEM_TOTAL: return RS::get_singleton()->get_render_info(RS::INFO_USAGE_VIDEO_MEM_TOTAL); + case PHYSICS_2D_ACTIVE_OBJECTS: return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ACTIVE_OBJECTS); + case PHYSICS_2D_COLLISION_PAIRS: return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_COLLISION_PAIRS); + case PHYSICS_2D_ISLAND_COUNT: return PhysicsServer2D::get_singleton()->get_process_info(PhysicsServer2D::INFO_ISLAND_COUNT); + case PHYSICS_3D_ACTIVE_OBJECTS: return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ACTIVE_OBJECTS); + case PHYSICS_3D_COLLISION_PAIRS: return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_COLLISION_PAIRS); + case PHYSICS_3D_ISLAND_COUNT: return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ISLAND_COUNT); case AUDIO_OUTPUT_LATENCY: return AudioServer::get_singleton()->get_output_latency(); default: { diff --git a/main/tests/SCsub b/main/tests/SCsub index 437d9ed777..cb1d35b12f 100644 --- a/main/tests/SCsub +++ b/main/tests/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/python -Import('env') +Import("env") env.tests_sources = [] env.add_source_files(env.tests_sources, "*.cpp") diff --git a/main/tests/test_astar.cpp b/main/tests/test_astar.cpp index e82d885af2..e0b4a7f2c8 100644 --- a/main/tests/test_astar.cpp +++ b/main/tests/test_astar.cpp @@ -351,7 +351,7 @@ TestFunc test_funcs[] = { test_abcx, test_add_remove, test_solutions, - NULL + nullptr }; MainLoop *test() { @@ -370,7 +370,7 @@ MainLoop *test() { } OS::get_singleton()->print("\n"); OS::get_singleton()->print("Passed %i of %i tests\n", passed, count); - return NULL; + return nullptr; } } // namespace TestAStar diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index 0e7c45f603..971460c655 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -396,7 +396,7 @@ static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_i } } -static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = NULL) { +static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = nullptr) { String txt; if (p_func->_static) @@ -947,17 +947,17 @@ MainLoop *test(TestType p_type) { List<String> cmdlargs = OS::get_singleton()->get_cmdline_args(); if (cmdlargs.empty()) { - return NULL; + return nullptr; } String test = cmdlargs.back()->get(); if (!test.ends_with(".gd") && !test.ends_with(".gdc")) { print_line("This test expects a path to a GDScript file as its last parameter. Got: " + test); - return NULL; + return nullptr; } FileAccess *fa = FileAccess::open(test, FileAccess::READ); - ERR_FAIL_COND_V_MSG(!fa, NULL, "Could not open file: " + test); + ERR_FAIL_COND_V_MSG(!fa, nullptr, "Could not open file: " + test); Vector<uint8_t> buf; int flen = fa->get_len(); @@ -1030,11 +1030,11 @@ MainLoop *test(TestType p_type) { if (err) { print_line("Parse Error:\n" + itos(parser.get_error_line()) + ":" + itos(parser.get_error_column()) + ":" + parser.get_error()); memdelete(fa); - return NULL; + return nullptr; } const GDScriptParser::Node *root = parser.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, NULL); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, nullptr); const GDScriptParser::ClassNode *cnode = static_cast<const GDScriptParser::ClassNode *>(root); _parser_show_class(cnode, 0, lines); @@ -1048,7 +1048,7 @@ MainLoop *test(TestType p_type) { if (err) { print_line("Parse Error:\n" + itos(parser.get_error_line()) + ":" + itos(parser.get_error_column()) + ":" + parser.get_error()); memdelete(fa); - return NULL; + return nullptr; } Ref<GDScript> gds; @@ -1059,7 +1059,7 @@ MainLoop *test(TestType p_type) { if (err) { print_line("Compile Error:\n" + itos(gdc.get_error_line()) + ":" + itos(gdc.get_error_column()) + ":" + gdc.get_error()); - return NULL; + return nullptr; } Ref<GDScript> current = gds; @@ -1083,7 +1083,7 @@ MainLoop *test(TestType p_type) { memdelete(fa); - return NULL; + return nullptr; } } // namespace TestGDScript @@ -1093,7 +1093,7 @@ namespace TestGDScript { MainLoop *test(TestType p_type) { ERR_PRINT("The GDScript module is disabled, therefore GDScript tests cannot be used."); - return NULL; + return nullptr; } } // namespace TestGDScript diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp index beb955d045..922a55b88e 100644 --- a/main/tests/test_main.cpp +++ b/main/tests/test_main.cpp @@ -40,8 +40,8 @@ #include "test_math.h" #include "test_oa_hash_map.h" #include "test_ordered_hash_map.h" -#include "test_physics.h" #include "test_physics_2d.h" +#include "test_physics_3d.h" #include "test_render.h" #include "test_shader_lang.h" #include "test_string.h" @@ -51,8 +51,8 @@ const char **tests_get_names() { static const char *test_names[] = { "string", "math", - "physics", "physics_2d", + "physics_3d", "render", "oa_hash_map", "gui", @@ -63,7 +63,7 @@ const char **tests_get_names() { "gd_bytecode", "ordered_hash_map", "astar", - NULL + nullptr }; return test_names; @@ -81,14 +81,14 @@ MainLoop *test_main(String p_test, const List<String> &p_args) { return TestMath::test(); } - if (p_test == "physics") { + if (p_test == "physics_2d") { - return TestPhysics::test(); + return TestPhysics2D::test(); } - if (p_test == "physics_2d") { + if (p_test == "physics_3d") { - return TestPhysics2D::test(); + return TestPhysics3D::test(); } if (p_test == "render") { @@ -144,7 +144,7 @@ MainLoop *test_main(String p_test, const List<String> &p_args) { } print_line("Unknown test: " + p_test); - return NULL; + return nullptr; } #else @@ -152,7 +152,7 @@ MainLoop *test_main(String p_test, const List<String> &p_args) { const char **tests_get_names() { static const char *test_names[] = { - NULL + nullptr }; return test_names; @@ -160,7 +160,7 @@ const char **tests_get_names() { MainLoop *test_main(String p_test, const List<String> &p_args) { - return NULL; + return nullptr; } #endif diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index d91503501d..38f7371802 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -43,7 +43,7 @@ #include "core/vmap.h" #include "scene/main/node.h" #include "scene/resources/texture.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" #include "core/method_ptrcall.h" @@ -475,18 +475,18 @@ MainLoop *test() { if (cmdlargs.empty()) { //try editor! - return NULL; + return nullptr; } String test = cmdlargs.back()->get(); if (test == "math") { // Not a file name but the test name, abort. // FIXME: This test is ugly as heck, needs fixing :) - return NULL; + return nullptr; } FileAccess *fa = FileAccess::open(test, FileAccess::READ); - ERR_FAIL_COND_V_MSG(!fa, NULL, "Could not open file: " + test); + ERR_FAIL_COND_V_MSG(!fa, nullptr, "Could not open file: " + test); Vector<uint8_t> buf; int flen = fa->get_len(); @@ -580,7 +580,7 @@ MainLoop *test() { List<String> args; args.push_back("-l"); - Error err = OS::get_singleton()->execute("/bin/ls", args, true, NULL, &ret); + Error err = OS::get_singleton()->execute("/bin/ls", args, true, nullptr, &ret); print_line("error: " + itos(err)); print_line(ret); @@ -660,6 +660,6 @@ MainLoop *test() { print_line("scalar /=: " + v); } - return NULL; + return nullptr; } } // namespace TestMath diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp index ac53f124d2..cffec7fa77 100644 --- a/main/tests/test_oa_hash_map.cpp +++ b/main/tests/test_oa_hash_map.cpp @@ -152,6 +152,6 @@ MainLoop *test() { map.set(5, 1); } - return NULL; + return nullptr; } } // namespace TestOAHashMap diff --git a/main/tests/test_ordered_hash_map.cpp b/main/tests/test_ordered_hash_map.cpp index a5553217e2..0720eebaf9 100644 --- a/main/tests/test_ordered_hash_map.cpp +++ b/main/tests/test_ordered_hash_map.cpp @@ -141,7 +141,7 @@ TestFunc test_funcs[] = { test_size, test_iteration, test_const_iteration, - 0 + nullptr }; @@ -168,6 +168,6 @@ MainLoop *test() { OS::get_singleton()->print("Passed %i of %i tests\n", passed, count); - return NULL; + return nullptr; } } // namespace TestOrderedHashMap diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 4403e40b76..6feff3b0a9 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -36,8 +36,8 @@ #include "core/print_string.h" #include "scene/resources/texture.h" #include "servers/display_server.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" static const unsigned char convex_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x40, 0x8, 0x6, 0x0, 0x0, 0x0, 0xaa, 0x69, 0x71, 0xde, 0x0, 0x0, 0x0, 0x1, 0x73, 0x52, 0x47, 0x42, 0x0, 0xae, 0xce, 0x1c, 0xe9, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf9, 0x43, 0xbb, 0x7f, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xdb, 0x6, 0xa, 0x3, 0x13, 0x31, 0x66, 0xa7, 0xac, 0x79, 0x0, 0x0, 0x4, 0xef, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x9b, 0xdd, 0x4e, 0x2a, 0x57, 0x14, 0xc7, 0xf7, 0x1e, 0xc0, 0x19, 0x38, 0x32, 0x80, 0xa, 0x6a, 0xda, 0x18, 0xa3, 0xc6, 0x47, 0x50, 0x7b, 0xa1, 0xd9, 0x36, 0x27, 0x7e, 0x44, 0xed, 0x45, 0x4d, 0x93, 0x3e, 0x40, 0x1f, 0x64, 0x90, 0xf4, 0x1, 0xbc, 0xf0, 0xc2, 0x9c, 0x57, 0x30, 0x4d, 0xbc, 0xa8, 0x6d, 0xc, 0x69, 0x26, 0xb5, 0x68, 0x8b, 0x35, 0x7e, 0x20, 0xb4, 0xf5, 0x14, 0xbf, 0x51, 0x3c, 0x52, 0xe, 0xc, 0xe, 0xc8, 0xf0, 0xb1, 0x7a, 0x51, 0x3d, 0xb1, 0x9e, 0x19, 0x1c, 0x54, 0x70, 0x1c, 0xdc, 0x9, 0x17, 0x64, 0x8, 0xc9, 0xff, 0xb7, 0xd6, 0x7f, 0xcd, 0x3f, 0x2b, 0xd9, 0x8, 0xbd, 0x9c, 0xda, 0x3e, 0xf8, 0x31, 0xff, 0xc, 0x0, 0x8, 0x42, 0x88, 0x9c, 0x9f, 0x9f, 0xbf, 0xa, 0x87, 0xc3, 0xad, 0x7d, 0x7d, 0x7d, 0x7f, 0x23, 0x84, 0x78, 0x8c, 0x31, 0xaf, 0x55, 0x0, 0xc6, 0xc7, 0x14, 0x1e, 0x8f, 0xc7, 0xbf, 0x38, 0x3c, 0x3c, 0x6c, 0x9b, 0x9f, 0x9f, 0x6f, 0xb8, 0x82, 0x9b, 0xee, 0xe8, 0xe8, 0xf8, 0x12, 0x0, 0xbe, 0xd3, 0x2a, 0x8, 0xfc, 0x50, 0xd1, 0xf9, 0x7c, 0x9e, 0x8a, 0x46, 0xa3, 0x5f, 0x9d, 0x9e, 0x9e, 0x7e, 0xb2, 0xb0, 0xb0, 0x60, 0xe5, 0x79, 0x1e, 0xf1, 0xfc, 0x7f, 0x3a, 0x9, 0x21, 0x88, 0x10, 0x82, 0x26, 0x26, 0x26, 0xde, 0x77, 0x75, 0x75, 0x85, 0x59, 0x96, 0xfd, 0x5e, 0x6b, 0x20, 0xf0, 0x7d, 0x85, 0x4b, 0x92, 0xf4, 0xfa, 0xe0, 0xe0, 0xe0, 0xd3, 0xb9, 0xb9, 0xb9, 0x46, 0x49, 0x92, 0xea, 0x6f, 0xa, 0xbf, 0x7d, 0x8, 0x21, 0x68, 0x70, 0x70, 0xb0, 0x38, 0x39, 0x39, 0x79, 0xd6, 0xd9, 0xd9, 0xb9, 0xcf, 0x30, 0xcc, 0xa2, 0xd6, 0xad, 0x21, 0x2b, 0x1c, 0x0, 0x38, 0x41, 0x10, 0xfc, 0xdb, 0xdb, 0xdb, 0x27, 0x1e, 0x8f, 0x27, 0x4b, 0x8, 0x1, 0x84, 0x90, 0xea, 0xf, 0x21, 0x4, 0x3c, 0x1e, 0x4f, 0x76, 0x67, 0x67, 0x67, 0x3f, 0x9f, 0xcf, 0xff, 0x7c, 0x5, 0xf3, 0xd9, 0x0, 0xe0, 0x2, 0x81, 0xc0, 0xa9, 0xdb, 0xed, 0x2e, 0x94, 0x2b, 0x5c, 0xe, 0xc4, 0xca, 0xca, 0x8a, 0x18, 0x8d, 0x46, 0x3, 0x0, 0xc0, 0x69, 0x1e, 0x4, 0x0, 0x90, 0x48, 0x24, 0x12, 0xe4, 0x38, 0xee, 0x41, 0xc2, 0x6f, 0x43, 0xe0, 0x38, 0xe, 0xfc, 0x7e, 0xbf, 0x10, 0x8b, 0xc5, 0xd6, 0x35, 0xd, 0x22, 0x9b, 0xcd, 0x7a, 0x96, 0x97, 0x97, 0x33, 0xf, 0xad, 0x7c, 0x29, 0x10, 0x9b, 0x9b, 0x9b, 0xef, 0x2e, 0x2e, 0x2e, 0x7e, 0xd5, 0x1c, 0x8, 0x0, 0x20, 0xe1, 0x70, 0x38, 0xfc, 0x98, 0xd5, 0x57, 0x2, 0xe1, 0x76, 0xbb, 0xf3, 0xa1, 0x50, 0xe8, 0x38, 0x9b, 0xcd, 0xfe, 0xa2, 0x9, 0x8, 0x0, 0x40, 0x2e, 0x2f, 0x2f, 0x7d, 0x4b, 0x4b, 0x4b, 0xb9, 0x4a, 0x54, 0x5f, 0x9, 0xc4, 0xd2, 0xd2, 0x92, 0xb4, 0xb7, 0xb7, 0xf7, 0x36, 0x97, 0xcb, 0x4d, 0x3d, 0x29, 0x8, 0x0, 0xe0, 0x42, 0xa1, 0xd0, 0x71, 0xb5, 0xc4, 0xdf, 0xb6, 0xc5, 0x93, 0xe, 0x4a, 0x0, 0x20, 0xa9, 0x54, 0xea, 0x37, 0xb7, 0xdb, 0x5d, 0xa8, 0xa6, 0x78, 0x39, 0x10, 0x6b, 0x6b, 0x6b, 0xf1, 0x64, 0x32, 0xb9, 0x5a, 0x55, 0x10, 0x0, 0xc0, 0x6d, 0x6c, 0x6c, 0x9c, 0x57, 0xbb, 0xfa, 0x25, 0x40, 0x14, 0x3, 0x81, 0x40, 0x34, 0x93, 0xc9, 0x2c, 0x57, 0x1c, 0x4, 0x0, 0x90, 0x58, 0x2c, 0xb6, 0x5e, 0xe9, 0xc1, 0x77, 0x1f, 0x10, 0x53, 0x53, 0x53, 0x52, 0xc5, 0x83, 0x14, 0x0, 0x70, 0x7e, 0xbf, 0x5f, 0xd0, 0x42, 0xf5, 0x95, 0x40, 0xf8, 0x7c, 0xbe, 0xcb, 0xa3, 0xa3, 0xa3, 0x3f, 0x1e, 0xbd, 0x1b, 0x0, 0x80, 0x1c, 0x1f, 0x1f, 0x87, 0xb4, 0x56, 0xfd, 0xaa, 0x5, 0x29, 0x51, 0x14, 0xbf, 0xf5, 0xf9, 0x7c, 0x97, 0x5a, 0xad, 0xbe, 0x12, 0x88, 0xf5, 0xf5, 0xf5, 0xd8, 0x83, 0x83, 0x54, 0xb5, 0x42, 0x8f, 0x66, 0x83, 0x94, 0xd6, 0xbd, 0x5f, 0xce, 0x7c, 0x38, 0x3c, 0x3c, 0xfc, 0xb3, 0x50, 0x28, 0xb8, 0xcb, 0x2, 0x1, 0x0, 0xdc, 0xf4, 0xf4, 0xf4, 0xfe, 0x73, 0x15, 0x2f, 0x17, 0xa4, 0x22, 0x91, 0x48, 0x50, 0xb5, 0x2d, 0x0, 0x80, 0x9b, 0x99, 0x99, 0x79, 0xfb, 0xdc, 0x1, 0xc8, 0x5, 0xa9, 0x44, 0x22, 0xf1, 0xfb, 0x9d, 0x10, 0x0, 0x80, 0x9b, 0x9d, 0x9d, 0xd, 0xea, 0x5, 0xc0, 0xad, 0xfd, 0x43, 0x1a, 0x0, 0xb8, 0xdb, 0x9a, 0xa9, 0x8f, 0xb6, 0xa4, 0x46, 0xa3, 0xa4, 0xb7, 0xd5, 0x37, 0xcf, 0xf3, 0x68, 0x75, 0x75, 0xf5, 0x4c, 0xee, 0x99, 0x1c, 0x80, 0x9c, 0x1e, 0xf7, 0xff, 0x16, 0x8b, 0x45, 0x50, 0x5, 0xa0, 0xb7, 0xb7, 0xb7, 0x85, 0x10, 0xa2, 0x2b, 0xf1, 0x84, 0x10, 0xd4, 0xdf, 0xdf, 0x6f, 0x57, 0x3, 0x80, 0x37, 0x18, 0xc, 0x5, 0x3d, 0x2, 0xa0, 0x69, 0x3a, 0x8b, 0x10, 0xe2, 0x4b, 0x2, 0xc0, 0x18, 0xf3, 0xc1, 0x60, 0x70, 0x47, 0x8f, 0x16, 0x38, 0x3a, 0x3a, 0x5a, 0x93, 0x5b, 0xc3, 0x7f, 0x64, 0x81, 0xba, 0xba, 0x3a, 0x49, 0x8f, 0x0, 0x1a, 0x1a, 0x1a, 0xd4, 0xcd, 0x0, 0x93, 0xc9, 0xa4, 0xcb, 0x21, 0xe8, 0x74, 0x3a, 0xd5, 0x1, 0xa0, 0x69, 0x5a, 0x77, 0x1d, 0x80, 0x31, 0x2e, 0x38, 0x9d, 0x4e, 0xb1, 0x66, 0x1, 0x30, 0xc, 0x23, 0x28, 0x3d, 0x93, 0x9b, 0x1, 0xb9, 0x9a, 0x6, 0x60, 0x36, 0x9b, 0x75, 0xd7, 0x1, 0x4a, 0x21, 0xa8, 0x26, 0x0, 0x94, 0xa, 0x41, 0xb2, 0x0, 0x18, 0x86, 0xc9, 0xe9, 0xd, 0x80, 0x52, 0x8, 0x92, 0x5, 0x60, 0xb1, 0x58, 0x74, 0x67, 0x1, 0xa5, 0x10, 0xa4, 0x4, 0x40, 0x77, 0x43, 0xd0, 0xe1, 0x70, 0xa8, 0x9f, 0x1, 0x14, 0x45, 0x1, 0x45, 0x51, 0x79, 0x3d, 0x1, 0x68, 0x6e, 0x6e, 0x4e, 0xaa, 0x6, 0x80, 0x10, 0x42, 0x6, 0x83, 0x41, 0x37, 0x36, 0x28, 0x15, 0x82, 0x6a, 0x2, 0x0, 0x4d, 0xd3, 0xa9, 0x52, 0xcf, 0x95, 0x0, 0xe8, 0x66, 0xe, 0x98, 0xcd, 0x66, 0xa1, 0x6c, 0x0, 0x7a, 0x5a, 0x8b, 0x59, 0x2c, 0x96, 0x64, 0xcd, 0x2, 0xb8, 0x2b, 0x4, 0xe9, 0xde, 0x2, 0x77, 0x85, 0xa0, 0x9a, 0xb0, 0x40, 0xa9, 0x10, 0xa4, 0x8, 0xc0, 0x64, 0x32, 0xe9, 0x6, 0x40, 0xa9, 0x10, 0x54, 0xaa, 0x3, 0x74, 0xf3, 0x16, 0x70, 0xb9, 0x5c, 0xe5, 0x3, 0xe8, 0xe9, 0xe9, 0x69, 0xd5, 0xc3, 0x66, 0x18, 0x63, 0x5c, 0x68, 0x6a, 0x6a, 0x12, 0xcb, 0x5, 0xa0, 0x9b, 0xd5, 0x38, 0x4d, 0xd3, 0x29, 0x8a, 0xa2, 0xa0, 0x2c, 0x0, 0x18, 0x63, 0x3e, 0x14, 0xa, 0xfd, 0x55, 0xb, 0x21, 0x48, 0xd1, 0x2, 0x7a, 0x59, 0x8d, 0xdf, 0x1b, 0x80, 0x1e, 0x56, 0xe3, 0x84, 0x10, 0x34, 0x30, 0x30, 0x60, 0xbb, 0xeb, 0x77, 0x46, 0x5, 0xef, 0x48, 0xcf, 0x4d, 0xec, 0x8d, 0x99, 0x5, 0xf5, 0xf5, 0xf5, 0xef, 0x46, 0x47, 0x47, 0xb, 0x2e, 0x97, 0xeb, 0xbc, 0x54, 0x8, 0x52, 0x4, 0xc0, 0x30, 0x8c, 0xf4, 0x5c, 0x4, 0x9b, 0x4c, 0xa6, 0xf4, 0xf8, 0xf8, 0xb8, 0xc8, 0xb2, 0x6c, 0x32, 0x9d, 0x4e, 0xff, 0xd4, 0xdd, 0xdd, 0x7d, 0x66, 0x34, 0x1a, 0x8b, 0xd7, 0x3, 0xfd, 0xae, 0x5b, 0x29, 0xb2, 0x57, 0x66, 0xb6, 0xb6, 0xb6, 0xde, 0xc4, 0xe3, 0xf1, 0x6f, 0xae, 0xaf, 0xc1, 0x28, 0x5d, 0x85, 0x79, 0x2, 0xc1, 0x60, 0xb5, 0x5a, 0xa3, 0xa3, 0xa3, 0xa3, 0x45, 0xab, 0xd5, 0x9a, 0x2a, 0x16, 0x8b, 0x8b, 0x6d, 0x6d, 0x6d, 0xef, 0xd5, 0x8a, 0x55, 0xd, 0x20, 0x91, 0x48, 0xbc, 0x3e, 0x38, 0x38, 0xf8, 0xda, 0x6e, 0xb7, 0xf7, 0x5f, 0x5c, 0x5c, 0xd4, 0x7b, 0xbd, 0xde, 0xbc, 0x20, 0x8, 0xcd, 0x85, 0x42, 0x81, 0xfe, 0xf0, 0xae, 0xac, 0x10, 0x98, 0x9b, 0xd5, 0xc5, 0x18, 0x17, 0x59, 0x96, 0x3d, 0x1d, 0x19, 0x19, 0x1, 0x96, 0x65, 0x5, 0x8a, 0xa2, 0x7e, 0x6c, 0x69, 0x69, 0x49, 0x3d, 0x44, 0xb0, 0x2a, 0x0, 0x1f, 0xcc, 0x74, 0x75, 0x41, 0xea, 0xfa, 0x7b, 0x32, 0x99, 0x64, 0x76, 0x77, 0x77, 0x5d, 0xe, 0x87, 0xa3, 0x5f, 0x14, 0xc5, 0x57, 0x57, 0x60, 0x5a, 0x8b, 0xc5, 0xa2, 0xf1, 0xbe, 0x50, 0x6e, 0xa, 0x66, 0x18, 0x26, 0x31, 0x36, 0x36, 0x96, 0x65, 0x59, 0x36, 0x29, 0x49, 0x92, 0xb7, 0xbd, 0xbd, 0xfd, 0x9f, 0x72, 0xda, 0xf9, 0xd1, 0x1, 0xa8, 0x1, 0x93, 0xcf, 0xe7, 0xa9, 0x93, 0x93, 0x13, 0x1b, 0x4d, 0xd3, 0x9f, 0xb, 0x82, 0x60, 0xf5, 0x7a, 0xbd, 0xd9, 0x54, 0x2a, 0xe5, 0xcc, 0x64, 0x32, 0xe, 0xb9, 0x6e, 0xb9, 0x16, 0x8c, 0x31, 0x2e, 0xda, 0x6c, 0xb6, 0xc8, 0xd0, 0xd0, 0x10, 0x65, 0xb3, 0xd9, 0x92, 0x95, 0xa8, 0x6e, 0xc5, 0x0, 0xa8, 0xe9, 0x96, 0x68, 0x34, 0x6a, 0xdd, 0xdf, 0xdf, 0x6f, 0x76, 0xb9, 0x5c, 0x9f, 0x89, 0xa2, 0x58, 0xbf, 0xb8, 0xb8, 0x8, 0x26, 0x93, 0x29, 0x3b, 0x3c, 0x3c, 0x8c, 0xed, 0x76, 0x7b, 0xd2, 0x68, 0x34, 0xfe, 0xd0, 0xd8, 0xd8, 0x98, 0xae, 0xb6, 0xe0, 0x8a, 0x1, 0x50, 0xb, 0xe6, 0xa9, 0x5, 0xbf, 0x9c, 0x97, 0xf3, 0xff, 0xf3, 0x2f, 0x6a, 0x82, 0x7f, 0xf6, 0x4e, 0xca, 0x1b, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 @@ -66,8 +66,8 @@ class TestPhysics2DMainLoop : public MainLoop { BodyShapeData body_shape_data[8]; void _create_body_shape_data() { - VisualServer *vs = VisualServer::get_singleton(); - Physics2DServer *ps = Physics2DServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); // SEGMENT @@ -86,13 +86,13 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 2, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_2d_create(image); + body_shape_data[PhysicsServer2D::SHAPE_SEGMENT].image = vs->texture_2d_create(image); RID segment_shape = ps->segment_shape_create(); Rect2 sg(Point2(-16, 0), Point2(16, 0)); ps->shape_set_data(segment_shape, sg); - body_shape_data[Physics2DServer::SHAPE_SEGMENT].shape = segment_shape; + body_shape_data[PhysicsServer2D::SHAPE_SEGMENT].shape = segment_shape; } // CIRCLE @@ -113,12 +113,12 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 32, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_2d_create(image); + body_shape_data[PhysicsServer2D::SHAPE_CIRCLE].image = vs->texture_2d_create(image); RID circle_shape = ps->circle_shape_create(); ps->shape_set_data(circle_shape, 16); - body_shape_data[Physics2DServer::SHAPE_CIRCLE].shape = circle_shape; + body_shape_data[PhysicsServer2D::SHAPE_CIRCLE].shape = circle_shape; } // BOX @@ -140,12 +140,12 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 32, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_2d_create(image); + body_shape_data[PhysicsServer2D::SHAPE_RECTANGLE].image = vs->texture_2d_create(image); RID rectangle_shape = ps->rectangle_shape_create(); ps->shape_set_data(rectangle_shape, Vector2(16, 16)); - body_shape_data[Physics2DServer::SHAPE_RECTANGLE].shape = rectangle_shape; + body_shape_data[PhysicsServer2D::SHAPE_RECTANGLE].shape = rectangle_shape; } // CAPSULE @@ -168,12 +168,12 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(32, 64, 0, Image::FORMAT_LA8, pixels)); - body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_2d_create(image); + body_shape_data[PhysicsServer2D::SHAPE_CAPSULE].image = vs->texture_2d_create(image); RID capsule_shape = ps->capsule_shape_create(); ps->shape_set_data(capsule_shape, Vector2(16, 32)); - body_shape_data[Physics2DServer::SHAPE_CAPSULE].shape = capsule_shape; + body_shape_data[PhysicsServer2D::SHAPE_CAPSULE].shape = capsule_shape; } // CONVEX @@ -182,7 +182,7 @@ class TestPhysics2DMainLoop : public MainLoop { Ref<Image> image = memnew(Image(convex_png)); - body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image); + body_shape_data[PhysicsServer2D::SHAPE_CONVEX_POLYGON].image = vs->texture_2d_create(image); RID convex_polygon_shape = ps->convex_polygon_shape_create(); @@ -197,14 +197,14 @@ class TestPhysics2DMainLoop : public MainLoop { arr.push_back(Point2(11, 7) - sb); ps->shape_set_data(convex_polygon_shape, arr); - body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape; + body_shape_data[PhysicsServer2D::SHAPE_CONVEX_POLYGON].shape = convex_polygon_shape; } } void _do_ray_query() { /* - Physics2DServer *ps = Physics2DServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); ps->query_intersection_segment(ray_query,ray_from,ray_to); */ } @@ -246,16 +246,16 @@ protected: } } - RID _add_body(Physics2DServer::ShapeType p_shape, const Transform2D &p_xform) { + RID _add_body(PhysicsServer2D::ShapeType p_shape, const Transform2D &p_xform) { - VisualServer *vs = VisualServer::get_singleton(); - Physics2DServer *ps = Physics2DServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); RID body = ps->body_create(); ps->body_add_shape(body, body_shape_data[p_shape].shape); ps->body_set_space(body, space); - ps->body_set_continuous_collision_detection_mode(body, Physics2DServer::CCD_MODE_CAST_SHAPE); - ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform); + ps->body_set_continuous_collision_detection_mode(body, PhysicsServer2D::CCD_MODE_CAST_SHAPE); + ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, p_xform); //print_line("add body with xform: "+p_xform); RID sprite = vs->canvas_item_create(); @@ -273,7 +273,7 @@ protected: void _add_plane(const Vector2 &p_normal, real_t p_d) { - Physics2DServer *ps = Physics2DServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); Array arr; arr.push_back(p_normal); @@ -283,23 +283,23 @@ protected: ps->shape_set_data(plane, arr); RID plane_body = ps->body_create(); - ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC); + ps->body_set_mode(plane_body, PhysicsServer2D::BODY_MODE_STATIC); ps->body_set_space(plane_body, space); ps->body_add_shape(plane_body, plane); } void _add_concave(const Vector<Vector2> &p_points, const Transform2D &p_xform = Transform2D()) { - Physics2DServer *ps = Physics2DServer::get_singleton(); - VisualServer *vs = VisualServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); RID concave = ps->concave_polygon_shape_create(); ps->shape_set_data(concave, p_points); RID body = ps->body_create(); - ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC); + ps->body_set_mode(body, PhysicsServer2D::BODY_MODE_STATIC); ps->body_set_space(body, space); ps->body_add_shape(body, concave); - ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform); + ps->body_set_state(body, PhysicsServer2D::BODY_STATE_TRANSFORM, p_xform); RID sprite = vs->canvas_item_create(); vs->canvas_item_set_parent(sprite, canvas); @@ -310,8 +310,8 @@ protected: } void _body_moved(Object *p_state, RID p_sprite) { - Physics2DDirectBodyState *state = (Physics2DDirectBodyState *)p_state; - VisualServer::get_singleton()->canvas_item_set_transform(p_sprite, state->get_transform()); + PhysicsDirectBodyState2D *state = (PhysicsDirectBodyState2D *)p_state; + RenderingServer::get_singleton()->canvas_item_set_transform(p_sprite, state->get_transform()); } void _ray_query_callback(const RID &p_rid, ObjectID p_id, int p_shape, const Vector2 &p_point, const Vector2 &p_normal) { @@ -324,7 +324,7 @@ protected: ray_end = ray_to; } - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); vs->canvas_item_clear(ray); vs->canvas_item_add_line(ray, ray_from, ray_end, p_rid.is_valid() ? Color(0, 1, 0.4) : Color(1, 0.4, 0), 2); @@ -341,14 +341,14 @@ protected: public: virtual void init() { - VisualServer *vs = VisualServer::get_singleton(); - Physics2DServer *ps = Physics2DServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); space = ps->space_create(); ps->space_set_active(space, true); ps->set_active(true); - ps->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, Vector2(0, 1)); - ps->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY, 98); + ps->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, Vector2(0, 1)); + ps->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, 98); { @@ -378,25 +378,25 @@ public: for (int i = 0; i < 32; i++) { - Physics2DServer::ShapeType types[4] = { - Physics2DServer::SHAPE_CIRCLE, - Physics2DServer::SHAPE_CAPSULE, - Physics2DServer::SHAPE_RECTANGLE, - Physics2DServer::SHAPE_CONVEX_POLYGON, + PhysicsServer2D::ShapeType types[4] = { + PhysicsServer2D::SHAPE_CIRCLE, + PhysicsServer2D::SHAPE_CAPSULE, + PhysicsServer2D::SHAPE_RECTANGLE, + PhysicsServer2D::SHAPE_CONVEX_POLYGON, }; - Physics2DServer::ShapeType type = types[i % 4]; - //type=Physics2DServer::SHAPE_SEGMENT; + PhysicsServer2D::ShapeType type = types[i % 4]; + //type=PhysicsServer2D::SHAPE_SEGMENT; _add_body(type, Transform2D(i * 0.8, Point2(152 + i * 40, 100 - 40 * i))); /* if (i==0) - ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC); + ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC); */ } - //RID b= _add_body(Physics2DServer::SHAPE_CIRCLE,Transform2D(0,Point2(101,140))); - //ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC); + //RID b= _add_body(PhysicsServer2D::SHAPE_CIRCLE,Transform2D(0,Point2(101,140))); + //ps->body_set_mode(b,PhysicsServer2D::BODY_MODE_STATIC); Point2 prev; diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics_3d.cpp index 7727af6ad1..2d208ee317 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics_3d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* test_physics.cpp */ +/* test_physics_3d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "test_physics.h" +#include "test_physics_3d.h" #include "core/map.h" #include "core/math/math_funcs.h" @@ -37,12 +37,12 @@ #include "core/os/os.h" #include "core/print_string.h" #include "servers/display_server.h" -#include "servers/physics_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_3d.h" +#include "servers/rendering_server.h" -class TestPhysicsMainLoop : public MainLoop { +class TestPhysics3DMainLoop : public MainLoop { - GDCLASS(TestPhysicsMainLoop, MainLoop); + GDCLASS(TestPhysics3DMainLoop, MainLoop); enum { LINK_COUNT = 20, @@ -65,13 +65,13 @@ class TestPhysicsMainLoop : public MainLoop { Point2 joy_direction; List<RID> bodies; - Map<PhysicsServer::ShapeType, RID> type_shape_map; - Map<PhysicsServer::ShapeType, RID> type_mesh_map; + Map<PhysicsServer3D::ShapeType, RID> type_shape_map; + Map<PhysicsServer3D::ShapeType, RID> type_mesh_map; void body_changed_transform(Object *p_state, RID p_visual_instance) { - PhysicsDirectBodyState *state = (PhysicsDirectBodyState *)p_state; - VisualServer *vs = VisualServer::get_singleton(); + PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state; + RenderingServer *vs = RenderingServer::get_singleton(); Transform t = state->get_transform(); vs->instance_set_transform(p_visual_instance, t); } @@ -81,26 +81,26 @@ class TestPhysicsMainLoop : public MainLoop { protected: static void _bind_methods() { - ClassDB::bind_method("body_changed_transform", &TestPhysicsMainLoop::body_changed_transform); + ClassDB::bind_method("body_changed_transform", &TestPhysics3DMainLoop::body_changed_transform); } - RID create_body(PhysicsServer::ShapeType p_shape, PhysicsServer::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) { + RID create_body(PhysicsServer3D::ShapeType p_shape, PhysicsServer3D::BodyMode p_body, const Transform p_location, bool p_active_default = true, const Transform &p_shape_xform = Transform()) { - VisualServer *vs = VisualServer::get_singleton(); - PhysicsServer *ps = PhysicsServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); RID mesh_instance = vs->instance_create2(type_mesh_map[p_shape], scenario); RID body = ps->body_create(p_body, !p_active_default); ps->body_set_space(body, space); - ps->body_set_param(body, PhysicsServer::BODY_PARAM_BOUNCE, 0.0); + ps->body_set_param(body, PhysicsServer3D::BODY_PARAM_BOUNCE, 0.0); //todo set space ps->body_add_shape(body, type_shape_map[p_shape]); ps->body_set_force_integration_callback(body, this, "body_changed_transform", mesh_instance); - ps->body_set_state(body, PhysicsServer::BODY_STATE_TRANSFORM, p_location); + ps->body_set_state(body, PhysicsServer3D::BODY_STATE_TRANSFORM, p_location); bodies.push_back(body); - if (p_body == PhysicsServer::BODY_MODE_STATIC) { + if (p_body == PhysicsServer3D::BODY_MODE_STATIC) { vs->instance_set_transform(mesh_instance, p_location); } @@ -109,12 +109,12 @@ protected: RID create_static_plane(const Plane &p_plane) { - PhysicsServer *ps = PhysicsServer::get_singleton(); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); - RID world_margin_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE); + RID world_margin_shape = ps->shape_create(PhysicsServer3D::SHAPE_PLANE); ps->shape_set_data(world_margin_shape, p_plane); - RID b = ps->body_create(PhysicsServer::BODY_MODE_STATIC); + RID b = ps->body_create(PhysicsServer3D::BODY_MODE_STATIC); ps->body_set_space(b, space); //todo set space ps->body_add_shape(b, world_margin_shape); @@ -123,24 +123,24 @@ protected: void configure_body(RID p_body, float p_mass, float p_friction, float p_bounce) { - PhysicsServer *ps = PhysicsServer::get_singleton(); - ps->body_set_param(p_body, PhysicsServer::BODY_PARAM_MASS, p_mass); - ps->body_set_param(p_body, PhysicsServer::BODY_PARAM_FRICTION, p_friction); - ps->body_set_param(p_body, PhysicsServer::BODY_PARAM_BOUNCE, p_bounce); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); + ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_MASS, p_mass); + ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_FRICTION, p_friction); + ps->body_set_param(p_body, PhysicsServer3D::BODY_PARAM_BOUNCE, p_bounce); } void init_shapes() { - VisualServer *vs = VisualServer::get_singleton(); - PhysicsServer *ps = PhysicsServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); /* SPHERE SHAPE */ RID sphere_mesh = vs->make_sphere_mesh(10, 20, 0.5); - type_mesh_map[PhysicsServer::SHAPE_SPHERE] = sphere_mesh; + type_mesh_map[PhysicsServer3D::SHAPE_SPHERE] = sphere_mesh; - RID sphere_shape = ps->shape_create(PhysicsServer::SHAPE_SPHERE); + RID sphere_shape = ps->shape_create(PhysicsServer3D::SHAPE_SPHERE); ps->shape_set_data(sphere_shape, 0.5); - type_shape_map[PhysicsServer::SHAPE_SPHERE] = sphere_shape; + type_shape_map[PhysicsServer3D::SHAPE_SPHERE] = sphere_shape; /* BOX SHAPE */ @@ -148,11 +148,11 @@ protected: RID box_mesh = vs->mesh_create(); Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes); vs->mesh_add_surface_from_mesh_data(box_mesh, box_data); - type_mesh_map[PhysicsServer::SHAPE_BOX] = box_mesh; + type_mesh_map[PhysicsServer3D::SHAPE_BOX] = box_mesh; - RID box_shape = ps->shape_create(PhysicsServer::SHAPE_BOX); + RID box_shape = ps->shape_create(PhysicsServer3D::SHAPE_BOX); ps->shape_set_data(box_shape, Vector3(0.5, 0.5, 0.5)); - type_shape_map[PhysicsServer::SHAPE_BOX] = box_shape; + type_shape_map[PhysicsServer3D::SHAPE_BOX] = box_shape; /* CAPSULE SHAPE */ @@ -162,14 +162,14 @@ protected: Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes); vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data); - type_mesh_map[PhysicsServer::SHAPE_CAPSULE] = capsule_mesh; + type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh; - RID capsule_shape = ps->shape_create(PhysicsServer::SHAPE_CAPSULE); + RID capsule_shape = ps->shape_create(PhysicsServer3D::SHAPE_CAPSULE); Dictionary capsule_params; capsule_params["radius"] = 0.5; capsule_params["height"] = 1.4; ps->shape_set_data(capsule_shape, capsule_params); - type_shape_map[PhysicsServer::SHAPE_CAPSULE] = capsule_shape; + type_shape_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_shape; /* CONVEX SHAPE */ @@ -180,18 +180,18 @@ protected: QuickHull::build(convex_data.vertices, convex_data); vs->mesh_add_surface_from_mesh_data(convex_mesh, convex_data); - type_mesh_map[PhysicsServer::SHAPE_CONVEX_POLYGON] = convex_mesh; + type_mesh_map[PhysicsServer3D::SHAPE_CONVEX_POLYGON] = convex_mesh; - RID convex_shape = ps->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON); + RID convex_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON); ps->shape_set_data(convex_shape, convex_data.vertices); - type_shape_map[PhysicsServer::SHAPE_CONVEX_POLYGON] = convex_shape; + type_shape_map[PhysicsServer3D::SHAPE_CONVEX_POLYGON] = convex_shape; } void make_trimesh(Vector<Vector3> p_faces, const Transform &p_xform = Transform()) { - VisualServer *vs = VisualServer::get_singleton(); - PhysicsServer *ps = PhysicsServer::get_singleton(); - RID trimesh_shape = ps->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); + RID trimesh_shape = ps->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON); ps->shape_set_data(trimesh_shape, p_faces); p_faces = ps->shape_get_data(trimesh_shape); // optimized one Vector<Vector3> normals; // for drawing @@ -205,19 +205,19 @@ protected: RID trimesh_mesh = vs->mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); - d[VS::ARRAY_VERTEX] = p_faces; - d[VS::ARRAY_NORMAL] = normals; - vs->mesh_add_surface_from_arrays(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, d); + d.resize(RS::ARRAY_MAX); + d[RS::ARRAY_VERTEX] = p_faces; + d[RS::ARRAY_NORMAL] = normals; + vs->mesh_add_surface_from_arrays(trimesh_mesh, RS::PRIMITIVE_TRIANGLES, d); RID triins = vs->instance_create2(trimesh_mesh, scenario); - RID tribody = ps->body_create(PhysicsServer::BODY_MODE_STATIC); + RID tribody = ps->body_create(PhysicsServer3D::BODY_MODE_STATIC); ps->body_set_space(tribody, space); //todo set space ps->body_add_shape(tribody, trimesh_shape); Transform tritrans = p_xform; - ps->body_set_state(tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans); + ps->body_set_state(tribody, PhysicsServer3D::BODY_STATE_TRANSFORM, tritrans); vs->instance_set_transform(triins, tritrans); } @@ -276,11 +276,11 @@ public: if (mover.is_valid()) { - PhysicsServer *ps = PhysicsServer::get_singleton(); - Transform t = ps->body_get_state(mover, PhysicsServer::BODY_STATE_TRANSFORM); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); + Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM); t.origin += Vector3(x, y, 0); - ps->body_set_state(mover, PhysicsServer::BODY_STATE_TRANSFORM, t); + ps->body_set_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM, t); } } } @@ -294,11 +294,11 @@ public: ofs_x = ofs_y = 0; init_shapes(); - PhysicsServer *ps = PhysicsServer::get_singleton(); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); space = ps->space_create(); ps->space_set_active(space, true); - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); /* LIGHT */ RID lightaux = vs->directional_light_create(); @@ -335,17 +335,17 @@ public: if (mover.is_valid()) { static float joy_speed = 10; - PhysicsServer *ps = PhysicsServer::get_singleton(); - Transform t = ps->body_get_state(mover, PhysicsServer::BODY_STATE_TRANSFORM); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); + Transform t = ps->body_get_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM); t.origin += Vector3(joy_speed * joy_direction.x * p_time, -joy_speed * joy_direction.y * p_time, 0); - ps->body_set_state(mover, PhysicsServer::BODY_STATE_TRANSFORM, t); + ps->body_set_state(mover, PhysicsServer3D::BODY_STATE_TRANSFORM, t); }; Transform cameratr; cameratr.rotate(Vector3(0, 1, 0), ofs_x); cameratr.rotate(Vector3(1, 0, 0), -ofs_y); cameratr.translate(Vector3(0, 2, 8)); - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); vs->camera_set_transform(camera, cameratr); return quit; @@ -361,17 +361,17 @@ public: void test_character() { - VisualServer *vs = VisualServer::get_singleton(); - PhysicsServer *ps = PhysicsServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer3D *ps = PhysicsServer3D::get_singleton(); Vector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5, 1, 12, 5, Vector3::AXIS_Y); RID capsule_mesh = vs->mesh_create(); Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes); vs->mesh_add_surface_from_mesh_data(capsule_mesh, capsule_data); - type_mesh_map[PhysicsServer::SHAPE_CAPSULE] = capsule_mesh; + type_mesh_map[PhysicsServer3D::SHAPE_CAPSULE] = capsule_mesh; - RID capsule_shape = ps->shape_create(PhysicsServer::SHAPE_CAPSULE); + RID capsule_shape = ps->shape_create(PhysicsServer3D::SHAPE_CAPSULE); Dictionary capsule_params; capsule_params["radius"] = 0.5; capsule_params["height"] = 1; @@ -381,14 +381,14 @@ public: ps->shape_set_data(capsule_shape, capsule_params); RID mesh_instance = vs->instance_create2(capsule_mesh, scenario); - character = ps->body_create(PhysicsServer::BODY_MODE_CHARACTER); + character = ps->body_create(PhysicsServer3D::BODY_MODE_CHARACTER); ps->body_set_space(character, space); //todo add space ps->body_add_shape(character, capsule_shape); ps->body_set_force_integration_callback(character, this, "body_changed_transform", mesh_instance); - ps->body_set_state(character, PhysicsServer::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(-2, 5, -2))); + ps->body_set_state(character, PhysicsServer3D::BODY_STATE_TRANSFORM, Transform(Basis(), Vector3(-2, 5, -2))); bodies.push_back(character); } @@ -396,21 +396,21 @@ public: for (int i = 0; i < 35; i++) { - static const PhysicsServer::ShapeType shape_idx[] = { - PhysicsServer::SHAPE_CAPSULE, - PhysicsServer::SHAPE_BOX, - PhysicsServer::SHAPE_SPHERE, - PhysicsServer::SHAPE_CONVEX_POLYGON + static const PhysicsServer3D::ShapeType shape_idx[] = { + PhysicsServer3D::SHAPE_CAPSULE, + PhysicsServer3D::SHAPE_BOX, + PhysicsServer3D::SHAPE_SPHERE, + PhysicsServer3D::SHAPE_CONVEX_POLYGON }; - PhysicsServer::ShapeType type = shape_idx[i % 4]; + PhysicsServer3D::ShapeType type = shape_idx[i % 4]; Transform t; t.origin = Vector3(0.0 * i, 3.5 + 1.1 * i, 0.7 + 0.0 * i); t.basis.rotate(Vector3(0.2, -1, 0), Math_PI / 2 * 0.6); - create_body(type, PhysicsServer::BODY_MODE_RIGID, t); + create_body(type, PhysicsServer3D::BODY_MODE_RIGID, t); } create_static_plane(Plane(Vector3(0, 1, 0), -1)); @@ -418,7 +418,7 @@ public: void test_activate() { - create_body(PhysicsServer::SHAPE_BOX, PhysicsServer::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true); + create_body(PhysicsServer3D::SHAPE_BOX, PhysicsServer3D::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true); create_static_plane(Plane(Vector3(0, 1, 0), -1)); } @@ -426,14 +426,14 @@ public: return false; } - TestPhysicsMainLoop() { + TestPhysics3DMainLoop() { } }; -namespace TestPhysics { +namespace TestPhysics3D { MainLoop *test() { - return memnew(TestPhysicsMainLoop); + return memnew(TestPhysics3DMainLoop); } -} // namespace TestPhysics +} // namespace TestPhysics3D diff --git a/main/tests/test_physics.h b/main/tests/test_physics_3d.h index fbbc59bba9..d03f2c6573 100644 --- a/main/tests/test_physics.h +++ b/main/tests/test_physics_3d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* test_physics.h */ +/* test_physics_3d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,7 +33,7 @@ #include "core/os/main_loop.h" -namespace TestPhysics { +namespace TestPhysics3D { MainLoop *test(); } diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index 0fbc5ea697..bcfcf61e25 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -37,7 +37,7 @@ #include "core/os/os.h" #include "core/print_string.h" #include "servers/display_server.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #define OBJECT_COUNT 50 @@ -75,7 +75,7 @@ public: virtual void init() { print_line("INITIALIZING TEST RENDER"); - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); test_cube = vs->get_test_cube(); scenario = vs->scenario_create(); @@ -126,7 +126,7 @@ public: print_line("ERR: " + itos(err)); test_cube = vs->mesh_create(); vs->mesh_add_surface_from_mesh_data(test_cube, md); - //vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME); + //vs->scenario_set_debug(scenario,RS::SCENARIO_DEBUG_WIREFRAME); /* RID sm = vs->shader_create(); @@ -174,16 +174,16 @@ public: vs->camera_set_perspective(camera, 60, 0.1, 1000); /* - RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI ); - vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 ); - vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 ); - vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 ); + RID lightaux = vs->light_create( RenderingServer::LIGHT_OMNI ); + vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_RADIUS, 80 ); + vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_ATTENUATION, 1 ); + vs->light_set_var( lightaux, RenderingServer::LIGHT_VAR_ENERGY, 1.5 ); light = vs->instance_create( lightaux ); */ RID lightaux; lightaux = vs->directional_light_create(); - //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); + //vs->light_set_color( lightaux, RenderingServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0)); //vs->light_set_shadow( lightaux, true ); light = vs->instance_create2(lightaux, scenario); @@ -194,10 +194,10 @@ public: vs->instance_set_transform(light, lla); lightaux = vs->omni_light_create(); - //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) ); + //vs->light_set_color( lightaux, RenderingServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0)); - vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RANGE, 4); - vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8); + vs->light_set_param(lightaux, RenderingServer::LIGHT_PARAM_RANGE, 4); + vs->light_set_param(lightaux, RenderingServer::LIGHT_PARAM_ENERGY, 8); //vs->light_set_shadow( lightaux, true ); //light = vs->instance_create( lightaux ); @@ -206,7 +206,7 @@ public: } virtual bool iteration(float p_time) { - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); //Transform t; //t.rotate(Vector3(0, 1, 0), ofs); //t.translate(Vector3(0,0,20 )); diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp index 941a6771bf..1e85f7f1d2 100644 --- a/main/tests/test_shader_lang.cpp +++ b/main/tests/test_shader_lang.cpp @@ -37,7 +37,7 @@ #include "core/print_string.h" #include "scene/gui/control.h" #include "scene/gui/text_edit.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" typedef ShaderLanguage SL; @@ -310,7 +310,7 @@ MainLoop *test() { if (cmdlargs.empty()) { //try editor! print_line("usage: godot -test shader_lang <shader>"); - return NULL; + return nullptr; } String test = cmdlargs.back()->get(); @@ -318,7 +318,7 @@ MainLoop *test() { FileAccess *fa = FileAccess::open(test, FileAccess::READ); if (!fa) { - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } String code; @@ -347,13 +347,13 @@ MainLoop *test() { if (err) { print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text()); - return NULL; + return nullptr; } else { String code2; recreate_code(&code2, sl.get_shader()); print_line("code:\n\n" + code2); } - return NULL; + return nullptr; } } // namespace TestShaderLang diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 84731746fa..7438e2bae9 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -1071,7 +1071,7 @@ bool test_33() { OS::get_singleton()->print("\n\nTest 33: parse_utf8(null, -1)\n"); String empty; - return empty.parse_utf8(NULL, -1); + return empty.parse_utf8(nullptr, -1); } bool test_34() { @@ -1164,7 +1164,7 @@ TestFunc test_funcs[] = { test_33, test_34, test_35, - 0 + nullptr }; @@ -1195,6 +1195,6 @@ MainLoop *test() { OS::get_singleton()->print("Passed %i of %i tests\n", passed, count); - return NULL; + return nullptr; } } // namespace TestString diff --git a/methods.py b/methods.py index dc82c97361..89a229e4ab 100644 --- a/methods.py +++ b/methods.py @@ -8,13 +8,13 @@ def add_source_files(self, sources, files, warn_duplicates=True): # Convert string to list of absolute paths (including expanding wildcard) if isinstance(files, (str, bytes)): # Keep SCons project-absolute path as they are (no wildcard support) - if files.startswith('#'): - if '*' in files: + if files.startswith("#"): + if "*" in files: print("ERROR: Wildcards can't be expanded in SCons project-absolute path: '{}'".format(files)) return files = [files] else: - dir_path = self.Dir('.').abspath + dir_path = self.Dir(".").abspath files = sorted(glob.glob(dir_path + "/" + files)) # Add each path as compiled Object following environment (self) configuration @@ -22,7 +22,7 @@ def add_source_files(self, sources, files, warn_duplicates=True): obj = self.Object(path) if obj in sources: if warn_duplicates: - print("WARNING: Object \"{}\" already included in environment sources.".format(obj)) + print('WARNING: Object "{}" already included in environment sources.'.format(obj)) else: continue sources.append(obj) @@ -33,20 +33,20 @@ def disable_warnings(self): if self.msvc: # We have to remove existing warning level defines before appending /w, # otherwise we get: "warning D9025 : overriding '/W3' with '/w'" - warn_flags = ['/Wall', '/W4', '/W3', '/W2', '/W1', '/WX'] - self.Append(CCFLAGS=['/w']) - self.Append(CFLAGS=['/w']) - self.Append(CXXFLAGS=['/w']) - self['CCFLAGS'] = [x for x in self['CCFLAGS'] if not x in warn_flags] - self['CFLAGS'] = [x for x in self['CFLAGS'] if not x in warn_flags] - self['CXXFLAGS'] = [x for x in self['CXXFLAGS'] if not x in warn_flags] + warn_flags = ["/Wall", "/W4", "/W3", "/W2", "/W1", "/WX"] + self.Append(CCFLAGS=["/w"]) + self.Append(CFLAGS=["/w"]) + self.Append(CXXFLAGS=["/w"]) + self["CCFLAGS"] = [x for x in self["CCFLAGS"] if not x in warn_flags] + self["CFLAGS"] = [x for x in self["CFLAGS"] if not x in warn_flags] + self["CXXFLAGS"] = [x for x in self["CXXFLAGS"] if not x in warn_flags] else: - self.Append(CCFLAGS=['-w']) - self.Append(CFLAGS=['-w']) - self.Append(CXXFLAGS=['-w']) + self.Append(CCFLAGS=["-w"]) + self.Append(CFLAGS=["-w"]) + self.Append(CXXFLAGS=["-w"]) -def add_module_version_string(self,s): +def add_module_version_string(self, s): self.module_version_string += "." + s @@ -64,16 +64,16 @@ def update_version(module_version_string=""): 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_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") f.write("#define VERSION_MINOR " + str(version.minor) + "\n") f.write("#define VERSION_PATCH " + str(version.patch) + "\n") - f.write("#define VERSION_STATUS \"" + str(version.status) + "\"\n") - f.write("#define VERSION_BUILD \"" + str(build_name) + "\"\n") - f.write("#define VERSION_MODULE_CONFIG \"" + str(version.module_config) + module_version_string + "\"\n") + f.write('#define VERSION_STATUS "' + str(version.status) + '"\n') + f.write('#define VERSION_BUILD "' + str(build_name) + '"\n') + 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('#define VERSION_WEBSITE "' + str(version.website) + '"\n') f.write("#endif // VERSION_GENERATED_GEN_H\n") f.close() @@ -99,7 +99,7 @@ def update_version(module_version_string=""): else: githash = head - fhash.write("#define VERSION_HASH \"" + githash + "\"\n") + fhash.write('#define VERSION_HASH "' + githash + '"\n') fhash.write("#endif // VERSION_HASH_GEN_H\n") fhash.close() @@ -158,17 +158,17 @@ def detect_modules(): try: with open("modules/" + x + "/register_types.h"): includes_cpp += '#include "modules/' + x + '/register_types.h"\n' - register_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' - register_cpp += '\tregister_' + x + '_types();\n' - register_cpp += '#endif\n' - preregister_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' - preregister_cpp += '#ifdef MODULE_' + x.upper() + '_HAS_PREREGISTER\n' - preregister_cpp += '\tpreregister_' + x + '_types();\n' - preregister_cpp += '#endif\n' - preregister_cpp += '#endif\n' - unregister_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' - unregister_cpp += '\tunregister_' + x + '_types();\n' - unregister_cpp += '#endif\n' + register_cpp += "#ifdef MODULE_" + x.upper() + "_ENABLED\n" + register_cpp += "\tregister_" + x + "_types();\n" + register_cpp += "#endif\n" + preregister_cpp += "#ifdef MODULE_" + x.upper() + "_ENABLED\n" + preregister_cpp += "#ifdef MODULE_" + x.upper() + "_HAS_PREREGISTER\n" + preregister_cpp += "\tpreregister_" + x + "_types();\n" + preregister_cpp += "#endif\n" + preregister_cpp += "#endif\n" + unregister_cpp += "#ifdef MODULE_" + x.upper() + "_ENABLED\n" + unregister_cpp += "\tunregister_" + x + "_types();\n" + unregister_cpp += "#endif\n" except IOError: pass @@ -191,7 +191,12 @@ void register_module_types() { void unregister_module_types() { %s } -""" % (includes_cpp, preregister_cpp, register_cpp, unregister_cpp) +""" % ( + includes_cpp, + preregister_cpp, + register_cpp, + unregister_cpp, + ) # NOTE: It is safe to generate this file here, since this is still executed serially with open("modules/register_module_types.gen.cpp", "w") as f: @@ -206,7 +211,7 @@ def disable_module(self): def use_windows_spawn_fix(self, platform=None): - if (os.name != "nt"): + if os.name != "nt": return # not needed, only for windows # On Windows, due to the limited command line length, when creating a static library @@ -217,14 +222,21 @@ def use_windows_spawn_fix(self, platform=None): # got built correctly regardless the invocation strategy. # Furthermore, since SCons will rebuild the library from scratch when an object file # changes, no multiple versions of the same object file will be present. - self.Replace(ARFLAGS='q') + self.Replace(ARFLAGS="q") def mySubProcess(cmdline, env): startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env) + proc = subprocess.Popen( + cmdline, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + startupinfo=startupinfo, + shell=False, + env=env, + ) _, err = proc.communicate() rv = proc.wait() if rv: @@ -235,7 +247,7 @@ def use_windows_spawn_fix(self, platform=None): def mySpawn(sh, escape, cmd, args, env): - newargs = ' '.join(args[1:]) + newargs = " ".join(args[1:]) cmdline = cmd + " " + newargs rv = 0 @@ -251,15 +263,15 @@ def use_windows_spawn_fix(self, platform=None): return rv - self['SPAWN'] = mySpawn + self["SPAWN"] = mySpawn def save_active_platforms(apnames, ap): for x in ap: - names = ['logo'] + names = ["logo"] if os.path.isfile(x + "/run_icon.png"): - names.append('run_icon') + names.append("run_icon") for name in names: pngf = open(x + "/" + name + ".png", "rb") @@ -269,7 +281,7 @@ def save_active_platforms(apnames, ap): while len(b) == 1: str += hex(ord(b)) b = pngf.read(1) - if (len(b) == 1): + if len(b) == 1: str += "," str += "};\n" @@ -289,30 +301,46 @@ def no_verbose(sys, env): # Colors are disabled in non-TTY environments such as pipes. This means # that if output is redirected to a file, it will not contain color codes if sys.stdout.isatty(): - colors['cyan'] = '\033[96m' - colors['purple'] = '\033[95m' - colors['blue'] = '\033[94m' - colors['green'] = '\033[92m' - colors['yellow'] = '\033[93m' - colors['red'] = '\033[91m' - colors['end'] = '\033[0m' + colors["cyan"] = "\033[96m" + colors["purple"] = "\033[95m" + colors["blue"] = "\033[94m" + colors["green"] = "\033[92m" + colors["yellow"] = "\033[93m" + colors["red"] = "\033[91m" + colors["end"] = "\033[0m" else: - colors['cyan'] = '' - colors['purple'] = '' - colors['blue'] = '' - colors['green'] = '' - colors['yellow'] = '' - colors['red'] = '' - colors['end'] = '' - - compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) - java_compile_source_message = '%sCompiling %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) - compile_shared_source_message = '%sCompiling shared %s==> %s$SOURCE%s' % (colors['blue'], colors['purple'], colors['yellow'], colors['end']) - link_program_message = '%sLinking Program %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - link_library_message = '%sLinking Static Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - ranlib_library_message = '%sRanlib Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - link_shared_library_message = '%sLinking Shared Library %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) - java_library_message = '%sCreating Java Archive %s==> %s$TARGET%s' % (colors['red'], colors['purple'], colors['yellow'], colors['end']) + colors["cyan"] = "" + colors["purple"] = "" + colors["blue"] = "" + colors["green"] = "" + colors["yellow"] = "" + colors["red"] = "" + colors["end"] = "" + + compile_source_message = "{}Compiling {}==> {}$SOURCE{}".format( + colors["blue"], colors["purple"], colors["yellow"], colors["end"] + ) + java_compile_source_message = "{}Compiling {}==> {}$SOURCE{}".format( + colors["blue"], colors["purple"], colors["yellow"], colors["end"] + ) + compile_shared_source_message = "{}Compiling shared {}==> {}$SOURCE{}".format( + colors["blue"], colors["purple"], colors["yellow"], colors["end"] + ) + link_program_message = "{}Linking Program {}==> {}$TARGET{}".format( + colors["red"], colors["purple"], colors["yellow"], colors["end"] + ) + link_library_message = "{}Linking Static Library {}==> {}$TARGET{}".format( + colors["red"], colors["purple"], colors["yellow"], colors["end"] + ) + ranlib_library_message = "{}Ranlib Library {}==> {}$TARGET{}".format( + colors["red"], colors["purple"], colors["yellow"], colors["end"] + ) + link_shared_library_message = "{}Linking Shared Library {}==> {}$TARGET{}".format( + colors["red"], colors["purple"], colors["yellow"], colors["end"] + ) + java_library_message = "{}Creating Java Archive {}==> {}$TARGET{}".format( + colors["red"], colors["purple"], colors["yellow"], colors["end"] + ) env.Append(CXXCOMSTR=[compile_source_message]) env.Append(CCCOMSTR=[compile_source_message]) @@ -353,70 +381,79 @@ def detect_visual_c_compiler_version(tools_env): vc_chosen_compiler_str = "" # Start with Pre VS 2017 checks which uses VCINSTALLDIR: - if 'VCINSTALLDIR' in tools_env: + if "VCINSTALLDIR" in tools_env: # print("Checking VCINSTALLDIR") # find() works with -1 so big ifs below are needed... the simplest solution, in fact # First test if amd64 and amd64_x86 compilers are present in the path vc_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64;") - if(vc_amd64_compiler_detection_index > -1): + if vc_amd64_compiler_detection_index > -1: vc_chosen_compiler_index = vc_amd64_compiler_detection_index vc_chosen_compiler_str = "amd64" vc_amd64_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\amd64_x86;") - if(vc_amd64_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): + if vc_amd64_x86_compiler_detection_index > -1 and ( + vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index + ): vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index vc_chosen_compiler_str = "amd64_x86" # Now check the 32 bit compilers vc_x86_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN;") - if(vc_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): + if vc_x86_compiler_detection_index > -1 and ( + vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_compiler_detection_index + ): vc_chosen_compiler_index = vc_x86_compiler_detection_index vc_chosen_compiler_str = "x86" - vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env['VCINSTALLDIR'] + "BIN\\x86_amd64;") - if(vc_x86_amd64_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): + vc_x86_amd64_compiler_detection_index = tools_env["PATH"].find(tools_env["VCINSTALLDIR"] + "BIN\\x86_amd64;") + if vc_x86_amd64_compiler_detection_index > -1 and ( + vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index + ): vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index vc_chosen_compiler_str = "x86_amd64" # and for VS 2017 and newer we check VCTOOLSINSTALLDIR: - if 'VCTOOLSINSTALLDIR' in tools_env: + if "VCTOOLSINSTALLDIR" in tools_env: # Newer versions have a different path available - vc_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X64;") - if(vc_amd64_compiler_detection_index > -1): + vc_amd64_compiler_detection_index = ( + tools_env["PATH"].upper().find(tools_env["VCTOOLSINSTALLDIR"].upper() + "BIN\\HOSTX64\\X64;") + ) + if vc_amd64_compiler_detection_index > -1: vc_chosen_compiler_index = vc_amd64_compiler_detection_index vc_chosen_compiler_str = "amd64" - vc_amd64_x86_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X86;") - if(vc_amd64_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index)): + vc_amd64_x86_compiler_detection_index = ( + tools_env["PATH"].upper().find(tools_env["VCTOOLSINSTALLDIR"].upper() + "BIN\\HOSTX64\\X86;") + ) + if vc_amd64_x86_compiler_detection_index > -1 and ( + vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_amd64_x86_compiler_detection_index + ): vc_chosen_compiler_index = vc_amd64_x86_compiler_detection_index vc_chosen_compiler_str = "amd64_x86" - vc_x86_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX86\\X86;") - if(vc_x86_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_compiler_detection_index)): + vc_x86_compiler_detection_index = ( + tools_env["PATH"].upper().find(tools_env["VCTOOLSINSTALLDIR"].upper() + "BIN\\HOSTX86\\X86;") + ) + if vc_x86_compiler_detection_index > -1 and ( + vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_compiler_detection_index + ): vc_chosen_compiler_index = vc_x86_compiler_detection_index vc_chosen_compiler_str = "x86" - vc_x86_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX86\\X64;") - if(vc_x86_amd64_compiler_detection_index > -1 - and (vc_chosen_compiler_index == -1 - or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index)): + vc_x86_amd64_compiler_detection_index = ( + tools_env["PATH"].upper().find(tools_env["VCTOOLSINSTALLDIR"].upper() + "BIN\\HOSTX86\\X64;") + ) + if vc_x86_amd64_compiler_detection_index > -1 and ( + vc_chosen_compiler_index == -1 or vc_chosen_compiler_index > vc_x86_amd64_compiler_detection_index + ): vc_chosen_compiler_index = vc_x86_amd64_compiler_detection_index vc_chosen_compiler_str = "x86_amd64" return vc_chosen_compiler_str + def find_visual_c_batch_file(env): from SCons.Tool.MSCommon.vc import get_default_version, get_host_target, find_batch_file @@ -424,6 +461,7 @@ def find_visual_c_batch_file(env): (host_platform, target_platform, _) = get_host_target(env) return find_batch_file(env, version, host_platform, target_platform)[0] + def generate_cpp_hint_file(filename): if os.path.isfile(filename): # Don't overwrite an existing hint file since the user may have customized it. @@ -435,15 +473,19 @@ def generate_cpp_hint_file(filename): except IOError: print("Could not write cpp.hint file.") + def generate_vs_project(env, num_jobs): batch_file = find_visual_c_batch_file(env) if batch_file: + def build_commandline(commands): - common_build_prefix = ['cmd /V /C set "plat=$(PlatformTarget)"', - '(if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64"))', - 'set "tools=yes"', - '(if "$(Configuration)"=="release" (set "tools=no"))', - 'call "' + batch_file + '" !plat!'] + common_build_prefix = [ + 'cmd /V /C set "plat=$(PlatformTarget)"', + '(if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64"))', + 'set "tools=yes"', + '(if "$(Configuration)"=="release" (set "tools=no"))', + 'call "' + batch_file + '" !plat!', + ] result = " ^& ".join(common_build_prefix + [commands]) return result @@ -459,87 +501,104 @@ def generate_vs_project(env, num_jobs): # to double quote off the directory. However, the path ends # in a backslash, so we need to remove this, lest it escape the # last double quote off, confusing MSBuild - env['MSVSBUILDCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" platform=windows progress=no target=$(Configuration) tools=!tools! -j' + str(num_jobs)) - env['MSVSREBUILDCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" platform=windows progress=no target=$(Configuration) tools=!tools! vsproj=yes -j' + str(num_jobs)) - env['MSVSCLEANCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" --clean platform=windows progress=no target=$(Configuration) tools=!tools! -j' + str(num_jobs)) + env["MSVSBUILDCOM"] = build_commandline( + "scons --directory=\"$(ProjectDir.TrimEnd('\\'))\" platform=windows progress=no target=$(Configuration) tools=!tools! -j" + + str(num_jobs) + ) + env["MSVSREBUILDCOM"] = build_commandline( + "scons --directory=\"$(ProjectDir.TrimEnd('\\'))\" platform=windows progress=no target=$(Configuration) tools=!tools! vsproj=yes -j" + + str(num_jobs) + ) + env["MSVSCLEANCOM"] = build_commandline( + "scons --directory=\"$(ProjectDir.TrimEnd('\\'))\" --clean platform=windows progress=no target=$(Configuration) tools=!tools! -j" + + str(num_jobs) + ) # This version information (Win32, x64, Debug, Release, Release_Debug seems to be # required for Visual Studio to understand that it needs to generate an NMAKE # project. Do not modify without knowing what you are doing. - debug_variants = ['debug|Win32'] + ['debug|x64'] - release_variants = ['release|Win32'] + ['release|x64'] - release_debug_variants = ['release_debug|Win32'] + ['release_debug|x64'] + debug_variants = ["debug|Win32"] + ["debug|x64"] + release_variants = ["release|Win32"] + ["release|x64"] + release_debug_variants = ["release_debug|Win32"] + ["release_debug|x64"] variants = debug_variants + release_variants + release_debug_variants - debug_targets = ['bin\\godot.windows.tools.32.exe'] + ['bin\\godot.windows.tools.64.exe'] - release_targets = ['bin\\godot.windows.opt.32.exe'] + ['bin\\godot.windows.opt.64.exe'] - release_debug_targets = ['bin\\godot.windows.opt.tools.32.exe'] + ['bin\\godot.windows.opt.tools.64.exe'] + debug_targets = ["bin\\godot.windows.tools.32.exe"] + ["bin\\godot.windows.tools.64.exe"] + release_targets = ["bin\\godot.windows.opt.32.exe"] + ["bin\\godot.windows.opt.64.exe"] + release_debug_targets = ["bin\\godot.windows.opt.tools.32.exe"] + ["bin\\godot.windows.opt.tools.64.exe"] targets = debug_targets + release_targets + release_debug_targets - if not env.get('MSVS'): - env['MSVS']['PROJECTSUFFIX'] = '.vcxproj' - env['MSVS']['SOLUTIONSUFFIX'] = '.sln' + if not env.get("MSVS"): + env["MSVS"]["PROJECTSUFFIX"] = ".vcxproj" + env["MSVS"]["SOLUTIONSUFFIX"] = ".sln" env.MSVSProject( - target=['#godot' + env['MSVSPROJECTSUFFIX']], + target=["#godot" + env["MSVSPROJECTSUFFIX"]], incs=env.vs_incs, srcs=env.vs_srcs, runfile=targets, buildtarget=targets, auto_build_solution=1, - variant=variants) + variant=variants, + ) else: - print("Could not locate Visual Studio batch file for setting up the build environment. Not generating VS project.") + print("Could not locate Visual Studio batch file to set up the build environment. Not generating VS project.") + def precious_program(env, program, sources, **args): program = env.ProgramOriginal(program, sources, **args) env.Precious(program) return program + def add_shared_library(env, name, sources, **args): library = env.SharedLibrary(name, sources, **args) env.NoCache(library) return library + def add_library(env, name, sources, **args): library = env.Library(name, sources, **args) env.NoCache(library) return library + def add_program(env, name, sources, **args): program = env.Program(name, sources, **args) env.NoCache(program) return program + def CommandNoCache(env, target, sources, command, **args): result = env.Command(target, sources, command, **args) env.NoCache(result) return result + def detect_darwin_sdk_path(platform, env): - sdk_name = '' - if platform == 'osx': - sdk_name = 'macosx' - var_name = 'MACOS_SDK_PATH' - elif platform == 'iphone': - sdk_name = 'iphoneos' - var_name = 'IPHONESDK' - elif platform == 'iphonesimulator': - sdk_name = 'iphonesimulator' - var_name = 'IPHONESDK' + sdk_name = "" + if platform == "osx": + sdk_name = "macosx" + var_name = "MACOS_SDK_PATH" + elif platform == "iphone": + sdk_name = "iphoneos" + var_name = "IPHONESDK" + elif platform == "iphonesimulator": + sdk_name = "iphonesimulator" + var_name = "IPHONESDK" else: raise Exception("Invalid platform argument passed to detect_darwin_sdk_path") if not env[var_name]: try: - sdk_path = subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip().decode("utf-8") + 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): print("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name)) raise + def is_vanilla_clang(env): if not using_clang(env): return False - version = subprocess.check_output([env['CXX'], '--version']).strip().decode("utf-8") + version = subprocess.check_output([env["CXX"], "--version"]).strip().decode("utf-8") return not version.startswith("Apple") @@ -552,20 +611,22 @@ 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 = subprocess.check_output([env.subst(env['CXX']), '--version']).strip().decode("utf-8") + 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 else: # TODO: Implement for MSVC return None - match = re.search('[0-9]+\.[0-9.]+', version) + match = re.search("[0-9]+\.[0-9.]+", version) if match is not None: - return list(map(int, match.group().split('.'))) + return list(map(int, match.group().split("."))) else: return None + def using_gcc(env): - return 'gcc' in os.path.basename(env["CC"]) + return "gcc" in os.path.basename(env["CC"]) + def using_clang(env): - return 'clang' in os.path.basename(env["CC"]) + return "clang" in os.path.basename(env["CC"]) diff --git a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj index 0b8a508d2f..4b2870b67a 100644 --- a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj +++ b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj @@ -50,10 +50,10 @@ 1FF4C1841F584E3F00A41E41 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; }; 1FF4C1861F584E5600A41E41 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; 1FF4C1881F584E7600A41E41 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; - 1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = $binary.entitlements; sourceTree = "<group>"; }; + 1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = "<group>"; }; 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = "<group>"; }; D07CD44D1C5D589C00B7FB28 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; }; - D0BCFE3418AEBDA2004A7AAE /* $binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = $binary.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D0BCFE3418AEBDA2004A7AAE /* $binary.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "$binary.app"; sourceTree = BUILT_PRODUCTS_DIR; }; D0BCFE3718AEBDA2004A7AAE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D0BCFE3918AEBDA2004A7AAE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; E360193621F32F37009258C1 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; @@ -62,7 +62,7 @@ D0BCFE3F18AEBDA2004A7AAE /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; D0BCFE4318AEBDA2004A7AAE /* $binary-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "$binary-Info.plist"; sourceTree = "<group>"; }; D0BCFE4518AEBDA2004A7AAE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; }; - D0BCFE7718AEBFEB004A7AAE /* $binary.pck */ = {isa = PBXFileReference; lastKnownFileType = file; path = $binary.pck; sourceTree = "<group>"; }; + D0BCFE7718AEBFEB004A7AAE /* $binary.pck */ = {isa = PBXFileReference; lastKnownFileType = file; path = "$binary.pck"; sourceTree = "<group>"; }; /* End PBXFileReference section */ $additional_pbx_files @@ -155,7 +155,7 @@ D0BCFE4218AEBDA2004A7AAE /* Supporting Files */, 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */, ); - path = $binary; + path = "$binary"; sourceTree = "<group>"; }; D0BCFE4218AEBDA2004A7AAE /* Supporting Files */ = { @@ -422,7 +422,7 @@ ARCHS = "$godot_archs"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CODE_SIGN_ENTITLEMENTS = $binary/$binary.entitlements; + CODE_SIGN_ENTITLEMENTS = "$binary/$binary.entitlements"; CODE_SIGN_IDENTITY = "$code_sign_identity_debug"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "$code_sign_identity_debug"; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; @@ -448,7 +448,7 @@ ARCHS = "$godot_archs"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CODE_SIGN_ENTITLEMENTS = $binary/$binary.entitlements; + CODE_SIGN_ENTITLEMENTS = "$binary/$binary.entitlements"; CODE_SIGN_IDENTITY = "$code_sign_identity_release"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "$code_sign_identity_release"; CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)"; diff --git a/misc/hooks/README.md b/misc/hooks/README.md index b18ba7df38..5661c239ed 100644 --- a/misc/hooks/README.md +++ b/misc/hooks/README.md @@ -5,16 +5,33 @@ contributors to make sure they comply with our requirements. ## List of hooks -- Pre-commit hook for clang-format: Applies clang-format to the staged files - before accepting a commit; blocks the commit and generates a patch if the - style is not respected. - Should work on Linux and macOS. You may need to edit the file if your - clang-format binary is not in the `$PATH`, or if you want to enable colored - output with pygmentize. -- Pre-commit hook for makerst: Checks the class reference syntax using `makerst.py`. - Should work on Linux and macOS. +- Pre-commit hook for `clang-format`: Applies `clang-format` to the staged + files before accepting a commit; blocks the commit and generates a patch if + the style is not respected. + You may need to edit the file if your `clang-format` binary is not in the + `PATH`, or if you want to enable colored output with `pygmentize`. +- Pre-commit hook for `black`: Applies `black` to the staged Python files + before accepting a commit. +- Pre-commit hook for `makerst`: Checks the class reference syntax using + `makerst.py`. ## Installation -Copy all the files from this folder into your `.git/hooks` folder, and make sure -the hooks and helper scripts are executable. +Copy all the files from this folder into your `.git/hooks` folder, and make +sure the hooks and helper scripts are executable. + +#### Linux/MacOS + +The hooks rely on bash scripts and tools which should be in the system `PATH`, +so they should work out of the box on Linux/macOS. + +#### Windows + +##### clang-format +- Download LLVM for Windows (version 8 or later) from + <https://releases.llvm.org/download.html> +- Make sure LLVM is added to the `PATH` during installation + +##### black +- Python installation: make sure Python is added to the `PATH` +- Install `black` - in any console: `pip3 install black` diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit index 36e9935785..40cb00253b 100755 --- a/misc/hooks/pre-commit +++ b/misc/hooks/pre-commit @@ -14,7 +14,7 @@ # as this script. Hooks should return 0 if successful and nonzero to cancel the # commit. They are executed in the order in which they are listed. #HOOKS="pre-commit-compile pre-commit-uncrustify" -HOOKS="pre-commit-clang-format pre-commit-makerst" +HOOKS="pre-commit-clang-format pre-commit-black pre-commit-makerst" ########################################################### # There should be no need to change anything below this line. diff --git a/misc/hooks/pre-commit-black b/misc/hooks/pre-commit-black new file mode 100755 index 0000000000..2dcc2e8cf1 --- /dev/null +++ b/misc/hooks/pre-commit-black @@ -0,0 +1,132 @@ +#!/usr/bin/env bash + +# git pre-commit hook that runs a black stylecheck. +# Based on pre-commit-clang-format. + +################################################################## +# SETTINGS +# Set path to black binary. +BLACK=`which black` +BLACK_OPTIONS="-l 120" + +# Remove any older patches from previous commits. Set to true or false. +DELETE_OLD_PATCHES=false + +# File types to parse. +FILE_NAMES="SConstruct SCsub" +FILE_EXTS="py" + +# Use pygmentize instead of cat to parse diff with highlighting. +# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac) +PYGMENTIZE=`which pygmentize` +if [ ! -z "$PYGMENTIZE" ]; then + READER="pygmentize -l diff" +else + READER=cat +fi + +################################################################## +# There should be no need to change anything below this line. + +. "$(dirname -- "$0")/canonicalize_filename.sh" + +# exit on error +set -e + +# check whether the given file matches any of the set extensions +matches_name_or_extension() { + local filename=$(basename "$1") + local extension=".${filename##*.}" + + for name in $FILE_NAMES; do [[ "$name" == "$filename" ]] && return 0; done + for ext in $FILE_EXTS; do [[ "$ext" == "$extension" ]] && return 0; done + + return 1 +} + +# necessary check for initial commit +if git rev-parse --verify HEAD >/dev/null 2>&1 ; then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +if [ ! -x "$BLACK" ] ; then + printf "Error: black executable not found.\n" + printf "Set the correct path in $(canonicalize_filename "$0").\n" + exit 1 +fi + +# create a random filename to store our generated patch +prefix="pre-commit-black" +suffix="$(date +%s)" +patch="/tmp/$prefix-$suffix.patch" + +# clean up any older black patches +$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch + +# create one patch containing all changes to the files +git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; +do + # ignore thirdparty files + if grep -q "thirdparty" <<< $file; then + continue; + fi + + # ignore file if not one of the names or extensions we handle + if ! matches_name_or_extension "$file"; then + continue; + fi + + # format our file with black, create a patch with diff and append it to our $patch + # The sed call is necessary to transform the patch from + # --- $file timestamp + # +++ $file timestamp + # to both lines working on the same file and having a/ and b/ prefix. + # Else it can not be applied with 'git apply'. + "$BLACK" "$BLACK_OPTIONS" --diff "$file" | \ + sed -e "1s|--- |--- a/|" -e "2s|+++ |+++ b/|" >> "$patch" +done + +# if no patch has been generated all is ok, clean up the file stub and exit +if [ ! -s "$patch" ] ; then + printf "Files in this commit comply with the black formatter rules.\n" + rm -f "$patch" + exit 0 +fi + +# a patch has been created, notify the user and exit +printf "\nThe following differences were found between the code to commit " +printf "and the black formatter rules:\n\n" +$READER "$patch" +printf "\n" + +# Allows us to read user input below, assigns stdin to keyboard +exec < /dev/tty + +while true; do + read -p "Do you want to apply that patch (Y - Apply, N - Do not apply, S - Apply and stage files)? [Y/N/S] " yn + case $yn in + [Yy] ) git apply $patch; + printf "The patch was applied. You can now stage the changes and commit again.\n\n"; + break + ;; + [Nn] ) printf "\nYou can apply these changes with:\n git apply $patch\n"; + printf "(may need to be called from the root directory of your repository)\n"; + printf "Aborting commit. Apply changes and commit again or skip checking with"; + printf " --no-verify (not recommended).\n\n"; + break + ;; + [Ss] ) git apply $patch; + git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; + do git add $file; + done + printf "The patch was applied and the changed files staged. You can now commit.\n\n"; + break + ;; + * ) echo "Please answer yes or no." + ;; + esac +done +exit 1 # we don't commit in any case diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format index e309233a8b..c5cf4ecbb1 100755 --- a/misc/hooks/pre-commit-clang-format +++ b/misc/hooks/pre-commit-clang-format @@ -15,28 +15,28 @@ ################################################################## # SETTINGS -# Set path to clang-format binary -# CLANG_FORMAT="/usr/bin/clang-format" +# Set path to clang-format binary. CLANG_FORMAT=`which clang-format` # Remove any older patches from previous commits. Set to true or false. -# DELETE_OLD_PATCHES=false DELETE_OLD_PATCHES=false # Only parse files with the extensions in FILE_EXTS. Set to true or false. # If false every changed file in the commit will be parsed with clang-format. # If true only files matching one of the extensions are parsed with clang-format. -# PARSE_EXTS=true PARSE_EXTS=true # File types to parse. Only effective when PARSE_EXTS is true. -# FILE_EXTS=".c .h .cpp .hpp" FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl" # Use pygmentize instead of cat to parse diff with highlighting. # Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac) -# READER="pygmentize -l diff" -READER=cat +PYGMENTIZE=`which pygmentize` +if [ ! -z "$PYGMENTIZE" ]; then + READER="pygmentize -l diff" +else + READER=cat +fi ################################################################## # There should be no need to change anything below this line. diff --git a/misc/hooks/pre-commit-makerst b/misc/hooks/pre-commit-makerst index d9b684e73b..b990788b99 100755 --- a/misc/hooks/pre-commit-makerst +++ b/misc/hooks/pre-commit-makerst @@ -2,4 +2,11 @@ # Git pre-commit hook that checks the class reference syntax using makerst.py. -doc/tools/makerst.py doc/classes modules --dry-run +# Workaround because we can't execute the .py file directly on windows +PYTHON=python +py_ver=$($PYTHON -c "import sys; print(sys.version_info.major)") +if [[ "$py_ver" != "3" ]]; then + PYTHON+=3 +fi + +$PYTHON doc/tools/makerst.py doc/classes modules --dry-run diff --git a/misc/scripts/fix_headers.py b/misc/scripts/fix_headers.py index f0038a8351..7af97eec4b 100755 --- a/misc/scripts/fix_headers.py +++ b/misc/scripts/fix_headers.py @@ -37,24 +37,24 @@ files = open("files", "r") fname = files.readline() -while (fname != ""): +while fname != "": # Handle replacing $filename with actual filename and keep alignment fsingle = fname.strip() - if (fsingle.find("/") != -1): - fsingle = fsingle[fsingle.rfind("/") + 1:] + if fsingle.find("/") != -1: + fsingle = fsingle[fsingle.rfind("/") + 1 :] rep_fl = "$filename" rep_fi = fsingle len_fl = len(rep_fl) len_fi = len(rep_fi) # Pad with spaces to keep alignment - if (len_fi < len_fl): + if len_fi < len_fl: for x in range(len_fl - len_fi): rep_fi += " " - elif (len_fl < len_fi): + elif len_fl < len_fi: for x in range(len_fi - len_fl): rep_fl += " " - if (header.find(rep_fl) != -1): + if header.find(rep_fl) != -1: text = header.replace(rep_fl, rep_fi) else: text = header.replace("$filename", fsingle) @@ -71,21 +71,21 @@ while (fname != ""): line = fileread.readline() header_done = False - while (line.strip() == ""): # Skip empty lines at the top + while line.strip() == "": # Skip empty lines at the top line = fileread.readline() - if (line.find("/**********") == -1): # Godot header starts this way + if line.find("/**********") == -1: # Godot header starts this way # Maybe starting with a non-Godot comment, abort header magic header_done = True - while (not header_done): # Handle header now - if (line.find("/*") != 0): # No more starting with a comment + while not header_done: # Handle header now + if line.find("/*") != 0: # No more starting with a comment header_done = True - if (line.strip() != ""): + if line.strip() != "": text += line line = fileread.readline() - while (line != ""): # Dump everything until EOF + while line != "": # Dump everything until EOF text += line line = fileread.readline() diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh index b33cb0a7b4..2eee61a459 100755 --- a/misc/scripts/fix_style.sh +++ b/misc/scripts/fix_style.sh @@ -1,9 +1,10 @@ #!/usr/bin/env bash # Command line arguments +run_black=false run_clang_format=false run_fix_headers=false -usage="Invalid argument. Usage:\n$0 <option>\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a" +usage="Invalid argument. Usage:\n$0 <option>\n\t--black|-b\n\t--clang-format|-c\n\t--headers|-h\n\t--all|-a" if [ -z "$1" ]; then echo -e $usage @@ -12,6 +13,9 @@ fi while [ $# -gt 0 ]; do case "$1" in + --black|-b) + run_black=true + ;; --clang-format|-c) run_clang_format=true ;; @@ -19,6 +23,7 @@ while [ $# -gt 0 ]; do run_fix_headers=true ;; --all|-a) + run_black=true run_clang_format=true run_fix_headers=true ;; @@ -32,6 +37,19 @@ done echo "Removing generated files, some have binary data and make clang-format freeze." find -name "*.gen.*" -delete +# Apply black +if $run_black; then + echo -e "Formatting Python files..." + PY_FILES=$(find \( -path "./.git" \ + -o -path "./thirdparty" \ + \) -prune \ + -o \( -name "SConstruct" \ + -o -name "SCsub" \ + -o -name "*.py" \ + \) -print) + black -l 120 $PY_FILES +fi + # Apply clang-format if $run_clang_format; then # Sync list with pre-commit hook diff --git a/misc/travis/black-format.sh b/misc/travis/black-format.sh new file mode 100755 index 0000000000..75b153f6bb --- /dev/null +++ b/misc/travis/black-format.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +BLACK=black +BLACK_OPTIONS="-l 120" + +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + # Travis only clones the PR branch and uses its HEAD commit as detached HEAD, + # so it's problematic when we want an exact commit range for format checks. + # We fetch upstream to ensure that we have the proper references to resolve. + # Ideally we would use $TRAVIS_COMMIT_RANGE but it doesn't play well with PR + # updates, as it only includes changes since the previous state of the PR. + if [ -z "$(git remote | grep upstream)" ]; then + git remote add upstream https://github.com/godotengine/godot \ + --no-tags -f -t $TRAVIS_BRANCH + fi + RANGE="upstream/$TRAVIS_BRANCH HEAD" +else + # Test only the last commit, since $TRAVIS_COMMIT_RANGE wouldn't support + # force pushes. + RANGE=HEAD +fi + +FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/| grep -E "(SConstruct|SCsub|\.py)$") +echo "Checking files:\n$FILES" + +# create a random filename to store our generated patch +prefix="static-check-black" +suffix="$(date +%s)" +patch="/tmp/$prefix-$suffix.patch" + +for file in $FILES; do + "$BLACK" "$BLACK_OPTIONS" --diff "$file" | \ + sed -e "1s|--- |--- a/|" -e "2s|+++ |+++ b/|" >> "$patch" +done + +# if no patch has been generated all is ok, clean up the file stub and exit +if [ ! -s "$patch" ] ; then + printf "Files in this commit comply with the black formatting rules.\n" + rm -f "$patch" + exit 0 +fi + +# a patch has been created, notify the user and exit +printf "\n*** The following differences were found between the code to commit " +printf "and the black formatting rules:\n\n" +pygmentize -l diff "$patch" +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n" +exit 1 diff --git a/misc/travis/clang-format.sh b/misc/travis/clang-format.sh index a6585578e1..c917744ece 100755 --- a/misc/travis/clang-format.sh +++ b/misc/travis/clang-format.sh @@ -8,8 +8,10 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then # We fetch upstream to ensure that we have the proper references to resolve. # Ideally we would use $TRAVIS_COMMIT_RANGE but it doesn't play well with PR # updates, as it only includes changes since the previous state of the PR. - git remote add upstream https://github.com/godotengine/godot \ - --no-tags -f -t $TRAVIS_BRANCH + if [ -z "$(git remote | grep upstream)" ]; then + git remote add upstream https://github.com/godotengine/godot \ + --no-tags -f -t $TRAVIS_BRANCH + fi RANGE="upstream/$TRAVIS_BRANCH HEAD" else # Test only the last commit, since $TRAVIS_COMMIT_RANGE wouldn't support @@ -41,6 +43,6 @@ fi # a patch has been created, notify the user and exit printf "\n*** The following differences were found between the code to commit " printf "and the clang-format rules:\n\n" -cat "$patch" +pygmentize -l diff "$patch" printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n" exit 1 diff --git a/modules/SCsub b/modules/SCsub index 5b39b18334..1671b398e5 100644 --- a/modules/SCsub +++ b/modules/SCsub @@ -1,12 +1,12 @@ #!/usr/bin/env python -Import('env') +Import("env") import modules_builders env_modules = env.Clone() -Export('env_modules') +Export("env_modules") # Header with MODULE_*_ENABLED defines. env.CommandNoCache("modules_enabled.gen.h", Value(env.module_list), modules_builders.generate_modules_enabled) diff --git a/modules/arkit/SCsub b/modules/arkit/SCsub index c05595ea2a..61c0a8248c 100644 --- a/modules/arkit/SCsub +++ b/modules/arkit/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_arkit = env_modules.Clone() @@ -9,4 +9,4 @@ env_arkit = env_modules.Clone() modules_sources = [] env_arkit.add_source_files(modules_sources, "*.cpp") env_arkit.add_source_files(modules_sources, "*.mm") -mod_lib = env_modules.add_library('#bin/libgodot_arkit_module' + env['LIBSUFFIX'], modules_sources) +mod_lib = env_modules.add_library("#bin/libgodot_arkit_module" + env["LIBSUFFIX"], modules_sources) diff --git a/modules/arkit/arkit_interface.mm b/modules/arkit/arkit_interface.mm index 90d9d7b03a..031e1e115e 100644 --- a/modules/arkit/arkit_interface.mm +++ b/modules/arkit/arkit_interface.mm @@ -31,7 +31,7 @@ #include "core/input/input_filter.h" #include "core/os/os.h" #include "scene/resources/surface_tool.h" -#include "servers/visual/visual_server_globals.h" +#include "servers/rendering/rendering_server_globals.h" #import <ARKit/ARKit.h> #import <UIKit/UIKit.h> diff --git a/modules/arkit/config.py b/modules/arkit/config.py index 96e41826c5..e68603fc93 100644 --- a/modules/arkit/config.py +++ b/modules/arkit/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return platform == 'iphone' + return platform == "iphone" + def configure(env): pass diff --git a/modules/assimp/SCsub b/modules/assimp/SCsub index cef2396dfb..f1d0c742b4 100644 --- a/modules/assimp/SCsub +++ b/modules/assimp/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_assimp = env_modules.Clone() @@ -10,85 +10,85 @@ env_assimp = env_modules.Clone() if True: # env['builtin_assimp']: thirdparty_dir = "#thirdparty/assimp" - env_assimp.Prepend(CPPPATH=['#thirdparty/assimp']) - env_assimp.Prepend(CPPPATH=['#thirdparty/assimp/code']) - env_assimp.Prepend(CPPPATH=['#thirdparty/assimp/include']) + env_assimp.Prepend(CPPPATH=["#thirdparty/assimp"]) + env_assimp.Prepend(CPPPATH=["#thirdparty/assimp/code"]) + env_assimp.Prepend(CPPPATH=["#thirdparty/assimp/include"]) - #env_assimp.Append(CPPDEFINES=['ASSIMP_DOUBLE_PRECISION']) # TODO default to what godot is compiled with for future double support - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_SINGLETHREADED']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_BOOST_WORKAROUND']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OWN_ZLIB']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_EXPORT']) + # env_assimp.Append(CPPDEFINES=['ASSIMP_DOUBLE_PRECISION']) # TODO default to what godot is compiled with for future double support + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_SINGLETHREADED"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_BOOST_WORKAROUND"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OWN_ZLIB"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_EXPORT"]) # Importers we don't need - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_3D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_3DS_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_3MF_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_AC_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_AMF_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_ASE_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_ASSBIN_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_B3D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_BLEND_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_BVH_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_C4D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_COB_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_COLLADA_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_CSM_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_DXF_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_GLTF2_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_GLTF_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_HMP_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_IFC_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_IRR_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_IRRMESH_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_LWO_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_LWS_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_M3D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD2_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD3_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD5_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MD5_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MDC_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MDL_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MMD_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MS3D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_NDO_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_NFF_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OBJ_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OFF_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OGRE_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_OPENGEX_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_PLY_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_Q3BSP_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_Q3D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_RAW_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_SIB_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_SMD_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_STEP_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_STL_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_TERRAGEN_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_X3D_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_XGL_IMPORTER']) - env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_X_IMPORTER']) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_3D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_3DS_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_3MF_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_AC_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_AMF_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_ASE_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_ASSBIN_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_B3D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_BLEND_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_BVH_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_C4D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_COB_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_COLLADA_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_CSM_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_DXF_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_GLTF2_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_GLTF_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_HMP_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_IFC_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_IRR_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_IRRMESH_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_LWO_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_LWS_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_M3D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD2_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD3_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD5_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MD5_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MDC_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MDL_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MMD_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_MS3D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_NDO_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_NFF_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OBJ_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OFF_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OGRE_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_OPENGEX_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_PLY_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_Q3BSP_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_Q3D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_RAW_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_SIB_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_SMD_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_STEP_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_STL_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_TERRAGEN_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_X3D_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_XGL_IMPORTER"]) + env_assimp.Append(CPPDEFINES=["ASSIMP_BUILD_NO_X_IMPORTER"]) + + if env["platform"] == "windows": + env_assimp.Append(CPPDEFINES=["PLATFORM_WINDOWS"]) + env_assimp.Append(CPPDEFINES=[("PLATFORM", "WINDOWS")]) + elif env["platform"] == "linuxbsd": + env_assimp.Append(CPPDEFINES=["PLATFORM_LINUX"]) + env_assimp.Append(CPPDEFINES=[("PLATFORM", "LINUX")]) + elif env["platform"] == "osx": + env_assimp.Append(CPPDEFINES=["PLATFORM_DARWIN"]) + env_assimp.Append(CPPDEFINES=[("PLATFORM", "DARWIN")]) - if(env['platform'] == 'windows'): - env_assimp.Append(CPPDEFINES=['PLATFORM_WINDOWS']) - env_assimp.Append(CPPDEFINES=[('PLATFORM', 'WINDOWS')]) - elif(env['platform'] == 'linuxbsd'): - env_assimp.Append(CPPDEFINES=['PLATFORM_LINUX']) - env_assimp.Append(CPPDEFINES=[('PLATFORM', 'LINUX')]) - elif(env['platform'] == 'osx'): - env_assimp.Append(CPPDEFINES=['PLATFORM_DARWIN']) - env_assimp.Append(CPPDEFINES=[('PLATFORM', 'DARWIN')]) - env_thirdparty = env_assimp.Clone() env_thirdparty.disable_warnings() - env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/CApi/*.cpp')) - env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/Common/*.cpp')) - env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/PostProcessing/*.cpp')) - env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/Material/*.cpp')) - env_thirdparty.add_source_files(env.modules_sources, Glob('#thirdparty/assimp/code/FBX/*.cpp')) + env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/CApi/*.cpp")) + env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/Common/*.cpp")) + env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/PostProcessing/*.cpp")) + env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/Material/*.cpp")) + env_thirdparty.add_source_files(env.modules_sources, Glob("#thirdparty/assimp/code/FBX/*.cpp")) # Godot's own source files env_assimp.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/assimp/config.py b/modules/assimp/config.py index 098f1eafa9..53b8f2f2e3 100644 --- a/modules/assimp/config.py +++ b/modules/assimp/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return env['tools'] + return env["tools"] + def configure(env): pass diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 1482fe99eb..cc74674eff 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -62,7 +62,7 @@ aiBone *get_bone_by_name(const aiScene *scene, aiString bone_name) { } } - return NULL; + return nullptr; } void EditorSceneImporterAssimp::get_extensions(List<String> *r_extensions) const { @@ -149,7 +149,7 @@ Node *EditorSceneImporterAssimp::import_scene(const String &p_path, uint32_t p_f 0; aiScene *scene = (aiScene *)importer.ReadFile(s_path.c_str(), post_process_Steps); - ERR_FAIL_COND_V_MSG(scene == NULL, NULL, String("Open Asset Import failed to open: ") + String(importer.GetErrorString())); + ERR_FAIL_COND_V_MSG(scene == nullptr, nullptr, String("Open Asset Import failed to open: ") + String(importer.GetErrorString())); return _generate_scene(p_path, scene, p_flags, p_bake_fps, max_bone_weights); } @@ -284,7 +284,7 @@ T EditorSceneImporterAssimp::_interpolate_track(const Vector<float> &p_times, co aiBone *EditorSceneImporterAssimp::get_bone_from_stack(ImportState &state, aiString name) { List<aiBone *>::Element *iter; - aiBone *bone = NULL; + aiBone *bone = nullptr; for (iter = state.bone_stack.front(); iter; iter = iter->next()) { bone = (aiBone *)iter->get(); @@ -294,32 +294,32 @@ aiBone *EditorSceneImporterAssimp::get_bone_from_stack(ImportState &state, aiStr } } - return NULL; + return nullptr; } Node3D * EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, const uint32_t p_flags, int p_bake_fps, const int32_t p_max_bone_weights) { - ERR_FAIL_COND_V(scene == NULL, NULL); + ERR_FAIL_COND_V(scene == nullptr, nullptr); ImportState state; state.path = p_path; state.assimp_scene = scene; state.max_bone_weights = p_max_bone_weights; - state.animation_player = NULL; + state.animation_player = nullptr; // populate light map for (unsigned int l = 0; l < scene->mNumLights; l++) { aiLight *ai_light = scene->mLights[l]; - ERR_CONTINUE(ai_light == NULL); + ERR_CONTINUE(ai_light == nullptr); state.light_cache[AssimpUtils::get_assimp_string(ai_light->mName)] = l; } // fill camera cache for (unsigned int c = 0; c < scene->mNumCameras; c++) { aiCamera *ai_camera = scene->mCameras[c]; - ERR_CONTINUE(ai_camera == NULL); + ERR_CONTINUE(ai_camera == nullptr); state.camera_cache[AssimpUtils::get_assimp_string(ai_camera->mName)] = c; } @@ -333,7 +333,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, RegenerateBoneStack(state); - Node *last_valid_parent = NULL; + Node *last_valid_parent = nullptr; List<const aiNode *>::Element *iter; for (iter = state.nodes.front(); iter; iter = iter->next()) { @@ -343,7 +343,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, String node_name = AssimpUtils::get_assimp_string(element_assimp_node->mName); //print_verbose("node: " + node_name); - Node3D *spatial = NULL; + Node3D *spatial = nullptr; Transform transform = AssimpUtils::assimp_matrix_transform(element_assimp_node->mTransformation); // retrieve this node bone @@ -361,13 +361,13 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, if (!state.armature_skeletons.has(element_assimp_node)) { state.armature_skeletons.insert(element_assimp_node, skeleton); } - } else if (bone != NULL) { + } else if (bone != nullptr) { continue; } else { spatial = memnew(Node3D); } - ERR_CONTINUE_MSG(spatial == NULL, "FBX Import - are we out of ram?"); + ERR_CONTINUE_MSG(spatial == nullptr, "FBX Import - are we out of ram?"); // we on purpose set the transform and name after creating the node. spatial->set_name(node_name); @@ -387,7 +387,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, if (parent_lookup) { Node3D *parent_node = parent_lookup->value(); - ERR_FAIL_COND_V_MSG(parent_node == NULL, state.root, + ERR_FAIL_COND_V_MSG(parent_node == nullptr, state.root, "Parent node invalid even though lookup successful, out of ram?"); if (spatial != state.root) { @@ -434,7 +434,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, aiNode *parent_node = bone_node->mParent; String bone_name = AssimpUtils::get_anim_string_from_assimp(bone->mName); - ERR_CONTINUE_MSG(armature_for_bone == NULL, "Armature for bone invalid: " + bone_name); + ERR_CONTINUE_MSG(armature_for_bone == nullptr, "Armature for bone invalid: " + bone_name); Skeleton3D *skeleton = state.armature_skeletons[armature_for_bone]; state.skeleton_bone_map[bone] = skeleton; @@ -454,7 +454,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, skeleton->set_bone_rest(boneIdx, pform); skeleton->set_bone_pose(boneIdx, pform); - if (parent_node != NULL) { + if (parent_node != nullptr) { int parent_bone_id = skeleton->find_bone(AssimpUtils::get_anim_string_from_assimp(parent_node->mName)); int current_bone_id = boneIdx; skeleton->set_bone_parent(current_bone_id, parent_bone_id); @@ -470,8 +470,8 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, const aiNode *assimp_node = key_value_pair->key(); Node3D *mesh_template = key_value_pair->value(); - ERR_CONTINUE(assimp_node == NULL); - ERR_CONTINUE(mesh_template == NULL); + ERR_CONTINUE(assimp_node == nullptr); + ERR_CONTINUE(mesh_template == nullptr); Node *parent_node = mesh_template->get_parent(); @@ -479,7 +479,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene, continue; } - if (parent_node == NULL) { + if (parent_node == nullptr) { print_error("Found invalid parent node!"); continue; // root node } @@ -661,7 +661,7 @@ Node *EditorSceneImporterAssimp::get_node_by_name(ImportState &state, String nam return node; } } - return NULL; + return nullptr; } /* Bone stack is a fifo handler for multiple armatures since armatures aren't a thing in assimp (yet) */ @@ -691,7 +691,7 @@ void EditorSceneImporterAssimp::RegenerateBoneStack(ImportState &state, aiMesh * // iterate over all the bones on the mesh for this node only! for (unsigned int boneIndex = 0; boneIndex < mesh->mNumBones; boneIndex++) { aiBone *bone = mesh->mBones[boneIndex]; - if (state.bone_stack.find(bone) == NULL) { + if (state.bone_stack.find(bone) == nullptr) { state.bone_stack.push_back(bone); } } @@ -711,7 +711,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim print_verbose("import animation: " + name); float ticks_per_second = anim->mTicksPerSecond; - if (state.assimp_scene->mMetaData != NULL && Math::is_equal_approx(ticks_per_second, 0.0f)) { + if (state.assimp_scene->mMetaData != nullptr && Math::is_equal_approx(ticks_per_second, 0.0f)) { int32_t time_mode = 0; state.assimp_scene->mMetaData->Get("TimeMode", time_mode); ticks_per_second = AssimpUtils::get_fbx_fps(time_mode, state.assimp_scene); @@ -747,9 +747,9 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim continue; //do not bother } - Skeleton3D *skeleton = NULL; + Skeleton3D *skeleton = nullptr; NodePath node_path; - aiBone *bone = NULL; + aiBone *bone = nullptr; // Import skeleton bone animation for this track // Any bone will do, no point in processing more than just what is in the skeleton @@ -806,7 +806,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim Node *item = get_node_by_name(state, mesh_name); ERR_CONTINUE_MSG(!item, "failed to look up node by name"); const MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(item); - ERR_CONTINUE(mesh_instance == NULL); + ERR_CONTINUE(mesh_instance == nullptr); String base_path = state.root->get_path_to(mesh_instance); @@ -940,7 +940,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat } // Work out normal calculations? - this needs work it doesn't work properly on huestos - if (ai_mesh->mNormals != NULL) { + if (ai_mesh->mNormals != nullptr) { const aiVector3D normals = ai_mesh->mNormals[j]; const Vector3 godot_normal = Vector3(normals.x, normals.y, normals.z); st->add_normal(godot_normal); @@ -1208,9 +1208,9 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat } Array array_copy; - array_copy.resize(VisualServer::ARRAY_MAX); + array_copy.resize(RenderingServer::ARRAY_MAX); - for (int l = 0; l < VisualServer::ARRAY_MAX; l++) { + for (int l = 0; l < RenderingServer::ARRAY_MAX; l++) { array_copy[l] = array_mesh[l].duplicate(true); } @@ -1224,13 +1224,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat Vector3 position = Vector3(ai_pos.x, ai_pos.y, ai_pos.z); vertices.ptrw()[l] = position; } - PackedVector3Array new_vertices = array_copy[VisualServer::ARRAY_VERTEX].duplicate(true); + PackedVector3Array new_vertices = array_copy[RenderingServer::ARRAY_VERTEX].duplicate(true); ERR_CONTINUE(vertices.size() != new_vertices.size()); for (int32_t l = 0; l < new_vertices.size(); l++) { Vector3 *w = new_vertices.ptrw(); w[l] = vertices[l]; } - array_copy[VisualServer::ARRAY_VERTEX] = new_vertices; + array_copy[RenderingServer::ARRAY_VERTEX] = new_vertices; } int32_t color_set = 0; @@ -1242,13 +1242,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat Color color = Color(ai_color.r, ai_color.g, ai_color.b, ai_color.a); colors.ptrw()[l] = color; } - PackedColorArray new_colors = array_copy[VisualServer::ARRAY_COLOR].duplicate(true); + PackedColorArray new_colors = array_copy[RenderingServer::ARRAY_COLOR].duplicate(true); ERR_CONTINUE(colors.size() != new_colors.size()); for (int32_t l = 0; l < colors.size(); l++) { Color *w = new_colors.ptrw(); w[l] = colors[l]; } - array_copy[VisualServer::ARRAY_COLOR] = new_colors; + array_copy[RenderingServer::ARRAY_COLOR] = new_colors; } if (ai_mesh->mAnimMeshes[j]->HasNormals()) { @@ -1259,13 +1259,13 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat Vector3 normal = Vector3(ai_normal.x, ai_normal.y, ai_normal.z); normals.ptrw()[l] = normal; } - PackedVector3Array new_normals = array_copy[VisualServer::ARRAY_NORMAL].duplicate(true); + PackedVector3Array new_normals = array_copy[RenderingServer::ARRAY_NORMAL].duplicate(true); ERR_CONTINUE(normals.size() != new_normals.size()); for (int l = 0; l < normals.size(); l++) { Vector3 *w = new_normals.ptrw(); w[l] = normals[l]; } - array_copy[VisualServer::ARRAY_NORMAL] = new_normals; + array_copy[RenderingServer::ARRAY_NORMAL] = new_normals; } if (ai_mesh->mAnimMeshes[j]->HasTangentsAndBitangents()) { @@ -1275,7 +1275,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat for (size_t l = 0; l < num_vertices; l++) { AssimpUtils::calc_tangent_from_mesh(ai_mesh, j, l, l, w); } - PackedFloat32Array new_tangents = array_copy[VisualServer::ARRAY_TANGENT].duplicate(true); + PackedFloat32Array new_tangents = array_copy[RenderingServer::ARRAY_TANGENT].duplicate(true); ERR_CONTINUE(new_tangents.size() != tangents.size() * 4); for (int32_t l = 0; l < tangents.size(); l++) { new_tangents.ptrw()[l + 0] = tangents[l].r; @@ -1283,7 +1283,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat new_tangents.ptrw()[l + 2] = tangents[l].b; new_tangents.ptrw()[l + 3] = tangents[l].a; } - array_copy[VisualServer::ARRAY_TANGENT] = new_tangents; + array_copy[RenderingServer::ARRAY_TANGENT] = new_tangents; } morphs[j] = array_copy; @@ -1325,8 +1325,8 @@ EditorSceneImporterAssimp::create_mesh(ImportState &state, const aiNode *assimp_ mesh_key += itos(surface_indices[i]); } - Skeleton3D *skeleton = NULL; - aiNode *armature = NULL; + Skeleton3D *skeleton = nullptr; + aiNode *armature = nullptr; if (!state.mesh_cache.has(mesh_key)) { mesh = _generate_mesh_from_surface_indices(state, surface_indices, assimp_node, skin, skeleton); @@ -1411,9 +1411,9 @@ Node3D *EditorSceneImporterAssimp::create_light( ImportState &state, const String &node_name, Transform &look_at_transform) { - Light3D *light = NULL; + Light3D *light = nullptr; aiLight *assimp_light = state.assimp_scene->mLights[state.light_cache[node_name]]; - ERR_FAIL_COND_V(!assimp_light, NULL); + ERR_FAIL_COND_V(!assimp_light, nullptr); if (assimp_light->mType == aiLightSource_DIRECTIONAL) { light = memnew(DirectionalLight3D); @@ -1422,7 +1422,7 @@ Node3D *EditorSceneImporterAssimp::create_light( } else if (assimp_light->mType == aiLightSource_SPOT) { light = memnew(SpotLight3D); } - ERR_FAIL_COND_V(light == NULL, NULL); + ERR_FAIL_COND_V(light == nullptr, nullptr); if (assimp_light->mType != aiLightSource_POINT) { Vector3 pos = Vector3( @@ -1458,10 +1458,10 @@ Node3D *EditorSceneImporterAssimp::create_camera( const String &node_name, Transform &look_at_transform) { aiCamera *camera = state.assimp_scene->mCameras[state.camera_cache[node_name]]; - ERR_FAIL_COND_V(!camera, NULL); + ERR_FAIL_COND_V(!camera, nullptr); Camera3D *camera_node = memnew(Camera3D); - ERR_FAIL_COND_V(!camera_node, NULL); + ERR_FAIL_COND_V(!camera_node, nullptr); float near = camera->mClipPlaneNear; if (Math::is_equal_approx(near, 0.0f)) { near = 0.1f; @@ -1483,7 +1483,7 @@ void EditorSceneImporterAssimp::_generate_node( ImportState &state, const aiNode *assimp_node) { - ERR_FAIL_COND(assimp_node == NULL); + ERR_FAIL_COND(assimp_node == nullptr); state.nodes.push_back(assimp_node); String parent_name = AssimpUtils::get_assimp_string(assimp_node->mParent->mName); @@ -1498,7 +1498,7 @@ void EditorSceneImporterAssimp::_generate_node( // is this an armature // parent null // and this is the first bone :) - if (parent_bone == NULL && current_bone) { + if (parent_bone == nullptr && current_bone) { state.armature_nodes.push_back(assimp_node->mParent); print_verbose("found valid armature: " + parent_name); } diff --git a/modules/assimp/editor_scene_importer_assimp.h b/modules/assimp/editor_scene_importer_assimp.h index 5059138b64..ab00a6c3aa 100644 --- a/modules/assimp/editor_scene_importer_assimp.h +++ b/modules/assimp/editor_scene_importer_assimp.h @@ -138,7 +138,7 @@ public: virtual void get_extensions(List<String> *r_extensions) const; virtual uint32_t get_import_flags() const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); Ref<Image> load_image(ImportState &state, const aiScene *p_scene, String p_path); static void RegenerateBoneStack(ImportState &state); diff --git a/modules/assimp/import_state.h b/modules/assimp/import_state.h index b16366b38c..cda1a854f0 100644 --- a/modules/assimp/import_state.h +++ b/modules/assimp/import_state.h @@ -118,12 +118,12 @@ struct RecursiveState { bone(_bone) {} Transform node_transform; - Skeleton3D *skeleton = NULL; - Node3D *new_node = NULL; + Skeleton3D *skeleton = nullptr; + Node3D *new_node = nullptr; String node_name; - aiNode *assimp_node = NULL; - Node *parent_node = NULL; - aiBone *bone = NULL; + aiNode *assimp_node = nullptr; + Node *parent_node = nullptr; + aiBone *bone = nullptr; }; } // namespace AssimpImporter diff --git a/modules/assimp/import_utils.h b/modules/assimp/import_utils.h index 30c00f8765..f78931add3 100644 --- a/modules/assimp/import_utils.h +++ b/modules/assimp/import_utils.h @@ -233,7 +233,7 @@ public: static Transform _get_global_assimp_node_transform(const aiNode *p_current_node) { aiNode const *current_node = p_current_node; Transform xform; - while (current_node != NULL) { + while (current_node != nullptr) { xform = assimp_matrix_transform(current_node->mTransformation) * xform; current_node = current_node->mParent; } @@ -319,7 +319,7 @@ public: */ static void set_texture_mapping_mode(aiTextureMapMode *map_mode, Ref<ImageTexture> texture) { ERR_FAIL_COND(texture.is_null()); - ERR_FAIL_COND(map_mode == NULL); + ERR_FAIL_COND(map_mode == nullptr); // FIXME: Commented out during Vulkan port. /* aiTextureMapMode tex_mode = map_mode[0]; @@ -358,13 +358,13 @@ public: print_verbose("Open Asset Import: Loading embedded texture " + filename); if (tex->mHeight == 0) { if (tex->CheckFormat("png")) { - ERR_FAIL_COND_V(Image::_png_mem_loader_func == NULL, Ref<Image>()); + ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, Ref<Image>()); Ref<Image> img = Image::_png_mem_loader_func((uint8_t *)tex->pcData, tex->mWidth); ERR_FAIL_COND_V(img.is_null(), Ref<Image>()); state.path_to_image_cache.insert(p_path, img); return img; } else if (tex->CheckFormat("jpg")) { - ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == NULL, Ref<Image>()); + ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, Ref<Image>()); Ref<Image> img = Image::_jpg_mem_loader_func((uint8_t *)tex->pcData, tex->mWidth); ERR_FAIL_COND_V(img.is_null(), Ref<Image>()); state.path_to_image_cache.insert(p_path, img); @@ -440,7 +440,7 @@ public: String &path, AssimpImageData &image_state) { aiString ai_filename = aiString(); - if (AI_SUCCESS == ai_material->GetTexture(texture_type, 0, &ai_filename, NULL, NULL, NULL, NULL, image_state.map_mode)) { + if (AI_SUCCESS == ai_material->GetTexture(texture_type, 0, &ai_filename, nullptr, nullptr, nullptr, nullptr, image_state.map_mode)) { return CreateAssimpTexture(state, ai_filename, filename, path, image_state); } diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub index 63324e920b..dc7b176d24 100644 --- a/modules/basis_universal/SCsub +++ b/modules/basis_universal/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_basisu = env_modules.Clone() @@ -9,36 +9,38 @@ env_basisu = env_modules.Clone() # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/basis_universal/" tool_sources = [ - "basisu_astc_decomp.cpp", - "basisu_backend.cpp", - "basisu_basis_file.cpp", - "basisu_comp.cpp", - "basisu_enc.cpp", - "basisu_etc.cpp", - "basisu_frontend.cpp", - "basisu_global_selector_palette_helpers.cpp", - "basisu_gpu_texture.cpp", - "basisu_pvrtc1_4.cpp", - "basisu_resample_filters.cpp", - "basisu_resampler.cpp", - "basisu_ssim.cpp", - "lodepng.cpp", + "basisu_astc_decomp.cpp", + "basisu_backend.cpp", + "basisu_basis_file.cpp", + "basisu_comp.cpp", + "basisu_enc.cpp", + "basisu_etc.cpp", + "basisu_frontend.cpp", + "basisu_global_selector_palette_helpers.cpp", + "basisu_gpu_texture.cpp", + "basisu_pvrtc1_4.cpp", + "basisu_resample_filters.cpp", + "basisu_resampler.cpp", + "basisu_ssim.cpp", + "lodepng.cpp", ] tool_sources = [thirdparty_dir + file for file in tool_sources] transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"] # Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC. if not env.msvc: - env_basisu.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path, '-isystem', Dir(thirdparty_dir + "transcoder").path]) + env_basisu.Append( + CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir(thirdparty_dir + "transcoder").path] + ) else: env_basisu.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) -if env['target'] == "debug": - env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) +if env["target"] == "debug": + env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) env_thirdparty = env_basisu.Clone() env_thirdparty.disable_warnings() -if env['tools']: +if env["tools"]: env_thirdparty.add_source_files(env.modules_sources, tool_sources) env_thirdparty.add_source_files(env.modules_sources, transcoder_sources) diff --git a/modules/basis_universal/config.py b/modules/basis_universal/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/basis_universal/config.py +++ b/modules/basis_universal/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index c29e91b5aa..f31c889a6d 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -31,7 +31,7 @@ #include "register_types.h" #include "core/os/os.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #include "texture_basisu.h" #ifdef TOOLS_ENABLED @@ -98,7 +98,7 @@ static Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image:: params.m_mip_gen = false; //sorry, please some day support provided mipmaps. params.m_source_images.push_back(buimg); - BasisDecompressFormat decompress_format; + BasisDecompressFormat decompress_format = BASIS_DECOMPRESS_RG; params.m_check_for_alpha = false; switch (p_channels) { @@ -158,16 +158,16 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { const uint8_t *ptr = r; int size = p_buffer.size(); - basist::transcoder_texture_format format; - Image::Format imgfmt; + basist::transcoder_texture_format format = basist::transcoder_texture_format::cTFTotalTextureFormats; + Image::Format imgfmt = Image::FORMAT_MAX; switch (*(uint32_t *)(ptr)) { case BASIS_DECOMPRESS_RG: { - if (VS::get_singleton()->has_os_feature("rgtc")) { + if (RS::get_singleton()->has_os_feature("rgtc")) { format = basist::transcoder_texture_format::cTFBC5; // get this from renderer imgfmt = Image::FORMAT_RGTC_RG; - } else if (VS::get_singleton()->has_os_feature("etc2")) { + } else if (RS::get_singleton()->has_os_feature("etc2")) { //unfortunately, basis universal does not support // ERR_FAIL_V(image); //unimplemented here @@ -179,13 +179,13 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { } } break; case BASIS_DECOMPRESS_RGB: { - if (VS::get_singleton()->has_os_feature("bptc")) { + if (RS::get_singleton()->has_os_feature("bptc")) { format = basist::transcoder_texture_format::cTFBC7_M6_OPAQUE_ONLY; // get this from renderer imgfmt = Image::FORMAT_BPTC_RGBA; - } else if (VS::get_singleton()->has_os_feature("s3tc")) { + } else if (RS::get_singleton()->has_os_feature("s3tc")) { format = basist::transcoder_texture_format::cTFBC1; // get this from renderer imgfmt = Image::FORMAT_DXT1; - } else if (VS::get_singleton()->has_os_feature("etc")) { + } else if (RS::get_singleton()->has_os_feature("etc")) { format = basist::transcoder_texture_format::cTFETC1; // get this from renderer imgfmt = Image::FORMAT_ETC; @@ -196,13 +196,13 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { } break; case BASIS_DECOMPRESS_RGBA: { - if (VS::get_singleton()->has_os_feature("bptc")) { + if (RS::get_singleton()->has_os_feature("bptc")) { format = basist::transcoder_texture_format::cTFBC7_M5; // get this from renderer imgfmt = Image::FORMAT_BPTC_RGBA; - } else if (VS::get_singleton()->has_os_feature("s3tc")) { + } else if (RS::get_singleton()->has_os_feature("s3tc")) { format = basist::transcoder_texture_format::cTFBC3; // get this from renderer imgfmt = Image::FORMAT_DXT5; - } else if (VS::get_singleton()->has_os_feature("etc2")) { + } else if (RS::get_singleton()->has_os_feature("etc2")) { format = basist::transcoder_texture_format::cTFETC2; // get this from renderer imgfmt = Image::FORMAT_ETC2_RGBA8; } else { @@ -212,10 +212,10 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { } } break; case BASIS_DECOMPRESS_RG_AS_RA: { - if (VS::get_singleton()->has_os_feature("s3tc")) { + if (RS::get_singleton()->has_os_feature("s3tc")) { format = basist::transcoder_texture_format::cTFBC3; // get this from renderer imgfmt = Image::FORMAT_DXT5_RA_AS_RG; - } else if (VS::get_singleton()->has_os_feature("etc2")) { + } else if (RS::get_singleton()->has_os_feature("etc2")) { format = basist::transcoder_texture_format::cTFETC2; // get this from renderer imgfmt = Image::FORMAT_ETC2_RGBA8; } else { @@ -229,7 +229,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) { ptr += 4; size -= 4; - basist::basisu_transcoder tr(NULL); + basist::basisu_transcoder tr(nullptr); ERR_FAIL_COND_V(!tr.validate_header(ptr, size), image); @@ -282,7 +282,7 @@ void unregister_basis_universal_types() { #ifdef TOOLS_ENABLED delete sel_codebook; - Image::basis_universal_packer = NULL; + Image::basis_universal_packer = nullptr; #endif - Image::basis_universal_unpacker = NULL; + Image::basis_universal_unpacker = nullptr; } diff --git a/modules/basis_universal/texture_basisu.cpp b/modules/basis_universal/texture_basisu.cpp index 12f3241c98..2ed0340927 100644 --- a/modules/basis_universal/texture_basisu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -72,7 +72,7 @@ bool TextureBasisU::has_alpha() const { void TextureBasisU::set_flags(uint32_t p_flags) { flags = p_flags; - VisualServer::get_singleton()->texture_set_flags(texture, p_flags); + RenderingServer::get_singleton()->texture_set_flags(texture, p_flags); }; uint32_t TextureBasisU::get_flags() const { @@ -105,7 +105,7 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { imgfmt = Image::FORMAT_ETC2_RGBA8; }; - basist::basisu_transcoder tr(NULL); + basist::basisu_transcoder tr(nullptr); ERR_FAIL_COND(!tr.validate_header(ptr, size)); @@ -144,8 +144,8 @@ void TextureBasisU::set_basisu_data(const Vector<uint8_t>& p_data) { img.instance(); img->create(info.m_width, info.m_height, info.m_total_levels > 1, imgfmt, gpudata); - VisualServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), VS::TEXTURE_TYPE_2D, flags); - VisualServer::get_singleton()->texture_set_data(texture, img); + RenderingServer::get_singleton()->texture_allocate(texture, tex_size.x, tex_size.y, 0, img->get_format(), RS::TEXTURE_TYPE_2D, flags); + RenderingServer::get_singleton()->texture_set_data(texture, img); }; Error TextureBasisU::import(const Ref<Image>& p_img) { @@ -221,13 +221,13 @@ Vector<uint8_t> TextureBasisU::get_basisu_data() const { TextureBasisU::TextureBasisU() { flags = FLAGS_DEFAULT; - texture = VisualServer::get_singleton()->texture_create(); + texture = RenderingServer::get_singleton()->texture_create(); }; TextureBasisU::~TextureBasisU() { - VisualServer::get_singleton()->free(texture); + RenderingServer::get_singleton()->free(texture); }; #endif diff --git a/modules/bmp/SCsub b/modules/bmp/SCsub index e7da7cf108..4f3405ff28 100644 --- a/modules/bmp/SCsub +++ b/modules/bmp/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_bmp = env_modules.Clone() diff --git a/modules/bmp/config.py b/modules/bmp/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/bmp/config.py +++ b/modules/bmp/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index 71e5076e78..ea2b2b548f 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -38,7 +38,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image, Error err = OK; - if (p_buffer == NULL) + if (p_buffer == nullptr) err = FAILED; if (err == OK) { @@ -151,7 +151,7 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image, line -= line_width; } - if (p_color_buffer == NULL || color_table_size == 0) { // regular pixels + if (p_color_buffer == nullptr || color_table_size == 0) { // regular pixels p_image->create(width, height, 0, Image::FORMAT_RGBA8, data); diff --git a/modules/bmp/register_types.cpp b/modules/bmp/register_types.cpp index d5cc6c5eb3..6220e956d6 100644 --- a/modules/bmp/register_types.cpp +++ b/modules/bmp/register_types.cpp @@ -32,7 +32,7 @@ #include "image_loader_bmp.h" -static ImageLoaderBMP *image_loader_bmp = NULL; +static ImageLoaderBMP *image_loader_bmp = nullptr; void register_bmp_types() { image_loader_bmp = memnew(ImageLoaderBMP); diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub index 02d0a31a69..692c749886 100644 --- a/modules/bullet/SCsub +++ b/modules/bullet/SCsub @@ -1,208 +1,203 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_bullet = env_modules.Clone() # Thirdparty source files -if env['builtin_bullet']: +if env["builtin_bullet"]: # Build only version 2 for now (as of 2.89) # Sync file list with relevant upstream CMakeLists.txt for each folder. thirdparty_dir = "#thirdparty/bullet/" bullet2_src = [ # BulletCollision - "BulletCollision/BroadphaseCollision/btAxisSweep3.cpp" - , "BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp" - , "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp" - , "BulletCollision/BroadphaseCollision/btDbvt.cpp" - , "BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp" - , "BulletCollision/BroadphaseCollision/btDispatcher.cpp" - , "BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp" - , "BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp" - , "BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp" - , "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp" - , "BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp" - , "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.cpp" - , "BulletCollision/CollisionDispatch/btCollisionObject.cpp" - , "BulletCollision/CollisionDispatch/btCollisionWorld.cpp" - , "BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp" - , "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp" - , "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btGhostObject.cpp" - , "BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp" - , "BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp" - , "BulletCollision/CollisionDispatch/btManifoldResult.cpp" - , "BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp" - , "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp" - , "BulletCollision/CollisionDispatch/btUnionFind.cpp" - , "BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp" - , "BulletCollision/CollisionShapes/btBoxShape.cpp" - , "BulletCollision/CollisionShapes/btBox2dShape.cpp" - , "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp" - , "BulletCollision/CollisionShapes/btCapsuleShape.cpp" - , "BulletCollision/CollisionShapes/btCollisionShape.cpp" - , "BulletCollision/CollisionShapes/btCompoundShape.cpp" - , "BulletCollision/CollisionShapes/btConcaveShape.cpp" - , "BulletCollision/CollisionShapes/btConeShape.cpp" - , "BulletCollision/CollisionShapes/btConvexHullShape.cpp" - , "BulletCollision/CollisionShapes/btConvexInternalShape.cpp" - , "BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp" - , "BulletCollision/CollisionShapes/btConvexPolyhedron.cpp" - , "BulletCollision/CollisionShapes/btConvexShape.cpp" - , "BulletCollision/CollisionShapes/btConvex2dShape.cpp" - , "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp" - , "BulletCollision/CollisionShapes/btCylinderShape.cpp" - , "BulletCollision/CollisionShapes/btEmptyShape.cpp" - , "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp" - , "BulletCollision/CollisionShapes/btMiniSDF.cpp" - , "BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp" - , "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp" - , "BulletCollision/CollisionShapes/btMultiSphereShape.cpp" - , "BulletCollision/CollisionShapes/btOptimizedBvh.cpp" - , "BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp" - , "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp" - , "BulletCollision/CollisionShapes/btSdfCollisionShape.cpp" - , "BulletCollision/CollisionShapes/btShapeHull.cpp" - , "BulletCollision/CollisionShapes/btSphereShape.cpp" - , "BulletCollision/CollisionShapes/btStaticPlaneShape.cpp" - , "BulletCollision/CollisionShapes/btStridingMeshInterface.cpp" - , "BulletCollision/CollisionShapes/btTetrahedronShape.cpp" - , "BulletCollision/CollisionShapes/btTriangleBuffer.cpp" - , "BulletCollision/CollisionShapes/btTriangleCallback.cpp" - , "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp" - , "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp" - , "BulletCollision/CollisionShapes/btTriangleMesh.cpp" - , "BulletCollision/CollisionShapes/btTriangleMeshShape.cpp" - , "BulletCollision/CollisionShapes/btUniformScalingShape.cpp" - , "BulletCollision/Gimpact/btContactProcessing.cpp" - , "BulletCollision/Gimpact/btGenericPoolAllocator.cpp" - , "BulletCollision/Gimpact/btGImpactBvh.cpp" - , "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp" - , "BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp" - , "BulletCollision/Gimpact/btGImpactShape.cpp" - , "BulletCollision/Gimpact/btTriangleShapeEx.cpp" - , "BulletCollision/Gimpact/gim_box_set.cpp" - , "BulletCollision/Gimpact/gim_contact.cpp" - , "BulletCollision/Gimpact/gim_memory.cpp" - , "BulletCollision/Gimpact/gim_tri_collision.cpp" - , "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp" - , "BulletCollision/NarrowPhaseCollision/btConvexCast.cpp" - , "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp" - , "BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp" - , "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp" - , "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp" - , "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp" - , "BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp" - , "BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp" - , "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp" - , "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp" - , "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp" - + "BulletCollision/BroadphaseCollision/btAxisSweep3.cpp", + "BulletCollision/BroadphaseCollision/btBroadphaseProxy.cpp", + "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.cpp", + "BulletCollision/BroadphaseCollision/btDbvt.cpp", + "BulletCollision/BroadphaseCollision/btDbvtBroadphase.cpp", + "BulletCollision/BroadphaseCollision/btDispatcher.cpp", + "BulletCollision/BroadphaseCollision/btOverlappingPairCache.cpp", + "BulletCollision/BroadphaseCollision/btQuantizedBvh.cpp", + "BulletCollision/BroadphaseCollision/btSimpleBroadphase.cpp", + "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp", + "BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp", + "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.cpp", + "BulletCollision/CollisionDispatch/btCollisionObject.cpp", + "BulletCollision/CollisionDispatch/btCollisionWorld.cpp", + "BulletCollision/CollisionDispatch/btCollisionWorldImporter.cpp", + "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp", + "BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btGhostObject.cpp", + "BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp", + "BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp", + "BulletCollision/CollisionDispatch/btManifoldResult.cpp", + "BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp", + "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp", + "BulletCollision/CollisionDispatch/btUnionFind.cpp", + "BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp", + "BulletCollision/CollisionShapes/btBoxShape.cpp", + "BulletCollision/CollisionShapes/btBox2dShape.cpp", + "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp", + "BulletCollision/CollisionShapes/btCapsuleShape.cpp", + "BulletCollision/CollisionShapes/btCollisionShape.cpp", + "BulletCollision/CollisionShapes/btCompoundShape.cpp", + "BulletCollision/CollisionShapes/btConcaveShape.cpp", + "BulletCollision/CollisionShapes/btConeShape.cpp", + "BulletCollision/CollisionShapes/btConvexHullShape.cpp", + "BulletCollision/CollisionShapes/btConvexInternalShape.cpp", + "BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp", + "BulletCollision/CollisionShapes/btConvexPolyhedron.cpp", + "BulletCollision/CollisionShapes/btConvexShape.cpp", + "BulletCollision/CollisionShapes/btConvex2dShape.cpp", + "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp", + "BulletCollision/CollisionShapes/btCylinderShape.cpp", + "BulletCollision/CollisionShapes/btEmptyShape.cpp", + "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp", + "BulletCollision/CollisionShapes/btMiniSDF.cpp", + "BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp", + "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp", + "BulletCollision/CollisionShapes/btMultiSphereShape.cpp", + "BulletCollision/CollisionShapes/btOptimizedBvh.cpp", + "BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp", + "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp", + "BulletCollision/CollisionShapes/btSdfCollisionShape.cpp", + "BulletCollision/CollisionShapes/btShapeHull.cpp", + "BulletCollision/CollisionShapes/btSphereShape.cpp", + "BulletCollision/CollisionShapes/btStaticPlaneShape.cpp", + "BulletCollision/CollisionShapes/btStridingMeshInterface.cpp", + "BulletCollision/CollisionShapes/btTetrahedronShape.cpp", + "BulletCollision/CollisionShapes/btTriangleBuffer.cpp", + "BulletCollision/CollisionShapes/btTriangleCallback.cpp", + "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp", + "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp", + "BulletCollision/CollisionShapes/btTriangleMesh.cpp", + "BulletCollision/CollisionShapes/btTriangleMeshShape.cpp", + "BulletCollision/CollisionShapes/btUniformScalingShape.cpp", + "BulletCollision/Gimpact/btContactProcessing.cpp", + "BulletCollision/Gimpact/btGenericPoolAllocator.cpp", + "BulletCollision/Gimpact/btGImpactBvh.cpp", + "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.cpp", + "BulletCollision/Gimpact/btGImpactQuantizedBvh.cpp", + "BulletCollision/Gimpact/btGImpactShape.cpp", + "BulletCollision/Gimpact/btTriangleShapeEx.cpp", + "BulletCollision/Gimpact/gim_box_set.cpp", + "BulletCollision/Gimpact/gim_contact.cpp", + "BulletCollision/Gimpact/gim_memory.cpp", + "BulletCollision/Gimpact/gim_tri_collision.cpp", + "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp", + "BulletCollision/NarrowPhaseCollision/btConvexCast.cpp", + "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.cpp", + "BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp", + "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp", + "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp", + "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp", + "BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp", + "BulletCollision/NarrowPhaseCollision/btRaycastCallback.cpp", + "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp", + "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp", + "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp", # BulletDynamics - , "BulletDynamics/Character/btKinematicCharacterController.cpp" - , "BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btContactConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btFixedConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btGearConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp" - , "BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp" - , "BulletDynamics/ConstraintSolver/btHingeConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp" - , "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp" - , "BulletDynamics/ConstraintSolver/btBatchedConstraints.cpp" - , "BulletDynamics/ConstraintSolver/btNNCGConstraintSolver.cpp" - , "BulletDynamics/ConstraintSolver/btSliderConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btTypedConstraint.cpp" - , "BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp" - , "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp" - , "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.cpp" - , "BulletDynamics/Dynamics/btSimulationIslandManagerMt.cpp" - , "BulletDynamics/Dynamics/btRigidBody.cpp" - , "BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp" - #, "BulletDynamics/Dynamics/Bullet-C-API.cpp" - , "BulletDynamics/Vehicle/btRaycastVehicle.cpp" - , "BulletDynamics/Vehicle/btWheelInfo.cpp" - , "BulletDynamics/Featherstone/btMultiBody.cpp" - , "BulletDynamics/Featherstone/btMultiBodyConstraint.cpp" - , "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp" - , "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp" - , "BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp" - , "BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp" - , "BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp" - , "BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp" - , "BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp" - , "BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp" - , "BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp" - , "BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp" - , "BulletDynamics/MLCPSolvers/btDantzigLCP.cpp" - , "BulletDynamics/MLCPSolvers/btMLCPSolver.cpp" - , "BulletDynamics/MLCPSolvers/btLemkeAlgorithm.cpp" - + "BulletDynamics/Character/btKinematicCharacterController.cpp", + "BulletDynamics/ConstraintSolver/btConeTwistConstraint.cpp", + "BulletDynamics/ConstraintSolver/btContactConstraint.cpp", + "BulletDynamics/ConstraintSolver/btFixedConstraint.cpp", + "BulletDynamics/ConstraintSolver/btGearConstraint.cpp", + "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.cpp", + "BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.cpp", + "BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.cpp", + "BulletDynamics/ConstraintSolver/btHinge2Constraint.cpp", + "BulletDynamics/ConstraintSolver/btHingeConstraint.cpp", + "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.cpp", + "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp", + "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.cpp", + "BulletDynamics/ConstraintSolver/btBatchedConstraints.cpp", + "BulletDynamics/ConstraintSolver/btNNCGConstraintSolver.cpp", + "BulletDynamics/ConstraintSolver/btSliderConstraint.cpp", + "BulletDynamics/ConstraintSolver/btSolve2LinearConstraint.cpp", + "BulletDynamics/ConstraintSolver/btTypedConstraint.cpp", + "BulletDynamics/ConstraintSolver/btUniversalConstraint.cpp", + "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp", + "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.cpp", + "BulletDynamics/Dynamics/btSimulationIslandManagerMt.cpp", + "BulletDynamics/Dynamics/btRigidBody.cpp", + "BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp", + # "BulletDynamics/Dynamics/Bullet-C-API.cpp", + "BulletDynamics/Vehicle/btRaycastVehicle.cpp", + "BulletDynamics/Vehicle/btWheelInfo.cpp", + "BulletDynamics/Featherstone/btMultiBody.cpp", + "BulletDynamics/Featherstone/btMultiBodyConstraint.cpp", + "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.cpp", + "BulletDynamics/Featherstone/btMultiBodyDynamicsWorld.cpp", + "BulletDynamics/Featherstone/btMultiBodyFixedConstraint.cpp", + "BulletDynamics/Featherstone/btMultiBodyGearConstraint.cpp", + "BulletDynamics/Featherstone/btMultiBodyJointLimitConstraint.cpp", + "BulletDynamics/Featherstone/btMultiBodyJointMotor.cpp", + "BulletDynamics/Featherstone/btMultiBodyMLCPConstraintSolver.cpp", + "BulletDynamics/Featherstone/btMultiBodyPoint2Point.cpp", + "BulletDynamics/Featherstone/btMultiBodySliderConstraint.cpp", + "BulletDynamics/Featherstone/btMultiBodySphericalJointMotor.cpp", + "BulletDynamics/MLCPSolvers/btDantzigLCP.cpp", + "BulletDynamics/MLCPSolvers/btMLCPSolver.cpp", + "BulletDynamics/MLCPSolvers/btLemkeAlgorithm.cpp", # BulletInverseDynamics - , "BulletInverseDynamics/IDMath.cpp" - , "BulletInverseDynamics/MultiBodyTree.cpp" - , "BulletInverseDynamics/details/MultiBodyTreeInitCache.cpp" - , "BulletInverseDynamics/details/MultiBodyTreeImpl.cpp" - + "BulletInverseDynamics/IDMath.cpp", + "BulletInverseDynamics/MultiBodyTree.cpp", + "BulletInverseDynamics/details/MultiBodyTreeInitCache.cpp", + "BulletInverseDynamics/details/MultiBodyTreeImpl.cpp", # BulletSoftBody - , "BulletSoftBody/btSoftBody.cpp" - , "BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp" - , "BulletSoftBody/btSoftBodyHelpers.cpp" - , "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp" - , "BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp" - , "BulletSoftBody/btSoftRigidDynamicsWorld.cpp" - , "BulletSoftBody/btSoftMultiBodyDynamicsWorld.cpp" - , "BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp" - , "BulletSoftBody/btDefaultSoftBodySolver.cpp" - , "BulletSoftBody/btDeformableBackwardEulerObjective.cpp" - , "BulletSoftBody/btDeformableBodySolver.cpp" - , "BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp" - , "BulletSoftBody/btDeformableContactProjection.cpp" - , "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.cpp" - , "BulletSoftBody/btDeformableContactConstraint.cpp" - + "BulletSoftBody/btSoftBody.cpp", + "BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp", + "BulletSoftBody/btSoftBodyHelpers.cpp", + "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp", + "BulletSoftBody/btSoftRigidCollisionAlgorithm.cpp", + "BulletSoftBody/btSoftRigidDynamicsWorld.cpp", + "BulletSoftBody/btSoftMultiBodyDynamicsWorld.cpp", + "BulletSoftBody/btSoftSoftCollisionAlgorithm.cpp", + "BulletSoftBody/btDefaultSoftBodySolver.cpp", + "BulletSoftBody/btDeformableBackwardEulerObjective.cpp", + "BulletSoftBody/btDeformableBodySolver.cpp", + "BulletSoftBody/btDeformableMultiBodyConstraintSolver.cpp", + "BulletSoftBody/btDeformableContactProjection.cpp", + "BulletSoftBody/btDeformableMultiBodyDynamicsWorld.cpp", + "BulletSoftBody/btDeformableContactConstraint.cpp", # clew - , "clew/clew.c" - + "clew/clew.c", # LinearMath - , "LinearMath/btAlignedAllocator.cpp" - , "LinearMath/btConvexHull.cpp" - , "LinearMath/btConvexHullComputer.cpp" - , "LinearMath/btGeometryUtil.cpp" - , "LinearMath/btPolarDecomposition.cpp" - , "LinearMath/btQuickprof.cpp" - , "LinearMath/btSerializer.cpp" - , "LinearMath/btSerializer64.cpp" - , "LinearMath/btThreads.cpp" - , "LinearMath/btVector3.cpp" - , "LinearMath/TaskScheduler/btTaskScheduler.cpp" - , "LinearMath/TaskScheduler/btThreadSupportPosix.cpp" - , "LinearMath/TaskScheduler/btThreadSupportWin32.cpp" + "LinearMath/btAlignedAllocator.cpp", + "LinearMath/btConvexHull.cpp", + "LinearMath/btConvexHullComputer.cpp", + "LinearMath/btGeometryUtil.cpp", + "LinearMath/btPolarDecomposition.cpp", + "LinearMath/btQuickprof.cpp", + "LinearMath/btSerializer.cpp", + "LinearMath/btSerializer64.cpp", + "LinearMath/btThreads.cpp", + "LinearMath/btVector3.cpp", + "LinearMath/TaskScheduler/btTaskScheduler.cpp", + "LinearMath/TaskScheduler/btThreadSupportPosix.cpp", + "LinearMath/TaskScheduler/btThreadSupportWin32.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in bullet2_src] # Treat Bullet headers as system headers to avoid raising warnings. Not supported on MSVC. if not env.msvc: - env_bullet.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path]) + env_bullet.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path]) else: env_bullet.Prepend(CPPPATH=[thirdparty_dir]) # if env['target'] == "debug" or env['target'] == "release_debug": diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp index e8a5c1475a..4d727529ef 100644 --- a/modules/bullet/area_bullet.cpp +++ b/modules/bullet/area_bullet.cpp @@ -46,7 +46,7 @@ AreaBullet::AreaBullet() : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA), monitorable(true), - spOv_mode(PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED), + spOv_mode(PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED), spOv_gravityPoint(false), spOv_gravityPointDistanceScale(0), spOv_gravityPointAttenuation(1), @@ -86,11 +86,11 @@ void AreaBullet::dispatch_callbacks() { switch (otherObj.state) { case OVERLAP_STATE_ENTER: otherObj.state = OVERLAP_STATE_INSIDE; - call_event(otherObj.object, PhysicsServer::AREA_BODY_ADDED); + call_event(otherObj.object, PhysicsServer3D::AREA_BODY_ADDED); otherObj.object->on_enter_area(this); break; case OVERLAP_STATE_EXIT: - call_event(otherObj.object, PhysicsServer::AREA_BODY_REMOVED); + call_event(otherObj.object, PhysicsServer3D::AREA_BODY_REMOVED); otherObj.object->on_exit_area(this); overlappingObjects.remove(i); // Remove after callback break; @@ -101,7 +101,7 @@ void AreaBullet::dispatch_callbacks() { } } -void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer::AreaBodyStatus p_status) { +void AreaBullet::call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status) { InOutEventCallback &event = eventsCallbacks[static_cast<int>(p_otherObject->getType())]; Object *areaGodoObject = ObjectDB::get_instance(event.event_callback_id); @@ -130,7 +130,7 @@ void AreaBullet::scratch() { void AreaBullet::clear_overlaps(bool p_notify) { for (int i = overlappingObjects.size() - 1; 0 <= i; --i) { if (p_notify) - call_event(overlappingObjects[i].object, PhysicsServer::AREA_BODY_REMOVED); + call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED); overlappingObjects[i].object->on_exit_area(this); } overlappingObjects.clear(); @@ -140,7 +140,7 @@ void AreaBullet::remove_overlap(CollisionObjectBullet *p_object, bool p_notify) for (int i = overlappingObjects.size() - 1; 0 <= i; --i) { if (overlappingObjects[i].object == p_object) { if (p_notify) - call_event(overlappingObjects[i].object, PhysicsServer::AREA_BODY_REMOVED); + call_event(overlappingObjects[i].object, PhysicsServer3D::AREA_BODY_REMOVED); overlappingObjects[i].object->on_exit_area(this); overlappingObjects.remove(i); break; @@ -218,30 +218,30 @@ void AreaBullet::put_overlap_as_inside(int p_index) { } } -void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) { +void AreaBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) { switch (p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: + case PhysicsServer3D::AREA_PARAM_GRAVITY: set_spOv_gravityMag(p_value); break; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: + case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: set_spOv_gravityVec(p_value); break; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: + case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: set_spOv_linearDump(p_value); break; - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: set_spOv_angularDump(p_value); break; - case PhysicsServer::AREA_PARAM_PRIORITY: + case PhysicsServer3D::AREA_PARAM_PRIORITY: set_spOv_priority(p_value); break; - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: + case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: set_spOv_gravityPoint(p_value); break; - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: + case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: set_spOv_gravityPointDistanceScale(p_value); break; - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: + case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: set_spOv_gravityPointAttenuation(p_value); break; default: @@ -249,23 +249,23 @@ void AreaBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant & } } -Variant AreaBullet::get_param(PhysicsServer::AreaParameter p_param) const { +Variant AreaBullet::get_param(PhysicsServer3D::AreaParameter p_param) const { switch (p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: + case PhysicsServer3D::AREA_PARAM_GRAVITY: return spOv_gravityMag; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: + case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: return spOv_gravityVec; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: + case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: return spOv_linearDump; - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: return spOv_angularDump; - case PhysicsServer::AREA_PARAM_PRIORITY: + case PhysicsServer3D::AREA_PARAM_PRIORITY: return spOv_priority; - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: + case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: return spOv_gravityPoint; - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: + case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return spOv_gravityPointDistanceScale; - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: + case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return spOv_gravityPointAttenuation; default: WARN_PRINT("Area doesn't support this parameter in the Bullet backend: " + itos(p_param)); diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h index 18888c6725..0272350510 100644 --- a/modules/bullet/area_bullet.h +++ b/modules/bullet/area_bullet.h @@ -33,7 +33,7 @@ #include "collision_object_bullet.h" #include "core/vector.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include "space_bullet.h" /** @@ -65,7 +65,7 @@ public: OverlapState state; OverlappingObjectData() : - object(NULL), + object(nullptr), state(OVERLAP_STATE_ENTER) {} OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) : object(p_object), @@ -88,7 +88,7 @@ private: Vector<OverlappingObjectData> overlappingObjects; bool monitorable; - PhysicsServer::AreaSpaceOverrideMode spOv_mode; + PhysicsServer3D::AreaSpaceOverrideMode spOv_mode; bool spOv_gravityPoint; real_t spOv_gravityPointDistanceScale; real_t spOv_gravityPointAttenuation; @@ -114,8 +114,8 @@ public: bool is_monitoring() const; - _FORCE_INLINE_ void set_spOv_mode(PhysicsServer::AreaSpaceOverrideMode p_mode) { spOv_mode = p_mode; } - _FORCE_INLINE_ PhysicsServer::AreaSpaceOverrideMode get_spOv_mode() { return spOv_mode; } + _FORCE_INLINE_ void set_spOv_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) { spOv_mode = p_mode; } + _FORCE_INLINE_ PhysicsServer3D::AreaSpaceOverrideMode get_spOv_mode() { return spOv_mode; } _FORCE_INLINE_ void set_spOv_gravityPoint(bool p_isGP) { spOv_gravityPoint = p_isGP; } _FORCE_INLINE_ bool is_spOv_gravityPoint() { return spOv_gravityPoint; } @@ -146,7 +146,7 @@ public: virtual void set_space(SpaceBullet *p_space); virtual void dispatch_callbacks(); - void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer::AreaBodyStatus p_status); + void call_event(CollisionObjectBullet *p_otherObject, PhysicsServer3D::AreaBodyStatus p_status); void set_on_state_change(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant()); void scratch(); @@ -162,8 +162,8 @@ public: void put_overlap_as_exit(int p_index); void put_overlap_as_inside(int p_index); - void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value); - Variant get_param(PhysicsServer::AreaParameter p_param) const; + void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value); + Variant get_param(PhysicsServer3D::AreaParameter p_param) const; void set_event_callback(Type p_callbackObjectType, ObjectID p_id, const StringName &p_method); bool has_event_callback(Type p_callbackObjectType); diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp index 4071723a3e..0f54f848dc 100644 --- a/modules/bullet/btRayShape.cpp +++ b/modules/bullet/btRayShape.cpp @@ -43,6 +43,7 @@ btRayShape::btRayShape(btScalar length) : m_shapeAxis(0, 0, 1) { m_shapeType = CUSTOM_CONVEX_SHAPE_TYPE; setLength(length); + slipsOnSlope = false; } btRayShape::~btRayShape() { diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 89868babc6..2705c749a2 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -74,19 +74,19 @@ body->get_space()->add_constraint(joint, joint->is_disabled_collisions_between_bodies()); // <--------------- Joint creation asserts -void BulletPhysicsServer::_bind_methods() { - //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer::DoTest); +void BulletPhysicsServer3D::_bind_methods() { + //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer3D::DoTest); } -BulletPhysicsServer::BulletPhysicsServer() : - PhysicsServer(), +BulletPhysicsServer3D::BulletPhysicsServer3D() : + PhysicsServer3D(), active(true), active_spaces_count(0) {} -BulletPhysicsServer::~BulletPhysicsServer() {} +BulletPhysicsServer3D::~BulletPhysicsServer3D() {} -RID BulletPhysicsServer::shape_create(ShapeType p_shape) { - ShapeBullet *shape = NULL; +RID BulletPhysicsServer3D::shape_create(ShapeType p_shape) { + ShapeBullet *shape = nullptr; switch (p_shape) { case SHAPE_PLANE: { @@ -133,51 +133,51 @@ RID BulletPhysicsServer::shape_create(ShapeType p_shape) { CreateThenReturnRID(shape_owner, shape) } -void BulletPhysicsServer::shape_set_data(RID p_shape, const Variant &p_data) { +void BulletPhysicsServer3D::shape_set_data(RID p_shape, const Variant &p_data) { ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); shape->set_data(p_data); } -void BulletPhysicsServer::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { +void BulletPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { //WARN_PRINT("Bias not supported by Bullet physics engine"); } -PhysicsServer::ShapeType BulletPhysicsServer::shape_get_type(RID p_shape) const { +PhysicsServer3D::ShapeType BulletPhysicsServer3D::shape_get_type(RID p_shape) const { ShapeBullet *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND_V(!shape, PhysicsServer::SHAPE_CUSTOM); + ERR_FAIL_COND_V(!shape, PhysicsServer3D::SHAPE_CUSTOM); return shape->get_type(); } -Variant BulletPhysicsServer::shape_get_data(RID p_shape) const { +Variant BulletPhysicsServer3D::shape_get_data(RID p_shape) const { ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, Variant()); return shape->get_data(); } -void BulletPhysicsServer::shape_set_margin(RID p_shape, real_t p_margin) { +void BulletPhysicsServer3D::shape_set_margin(RID p_shape, real_t p_margin) { ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); shape->set_margin(p_margin); } -real_t BulletPhysicsServer::shape_get_margin(RID p_shape) const { +real_t BulletPhysicsServer3D::shape_get_margin(RID p_shape) const { ShapeBullet *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0.0); return shape->get_margin(); } -real_t BulletPhysicsServer::shape_get_custom_solver_bias(RID p_shape) const { +real_t BulletPhysicsServer3D::shape_get_custom_solver_bias(RID p_shape) const { //WARN_PRINT("Bias not supported by Bullet physics engine"); return 0.; } -RID BulletPhysicsServer::space_create() { +RID BulletPhysicsServer3D::space_create() { SpaceBullet *space = bulletnew(SpaceBullet); CreateThenReturnRID(space_owner, space); } -void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) { +void BulletPhysicsServer3D::space_set_active(RID p_space, bool p_active) { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -195,64 +195,64 @@ void BulletPhysicsServer::space_set_active(RID p_space, bool p_active) { } } -bool BulletPhysicsServer::space_is_active(RID p_space) const { +bool BulletPhysicsServer3D::space_is_active(RID p_space) const { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, false); return -1 != active_spaces.find(space); } -void BulletPhysicsServer::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { +void BulletPhysicsServer3D::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); space->set_param(p_param, p_value); } -real_t BulletPhysicsServer::space_get_param(RID p_space, SpaceParameter p_param) const { +real_t BulletPhysicsServer3D::space_get_param(RID p_space, SpaceParameter p_param) const { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_param(p_param); } -PhysicsDirectSpaceState *BulletPhysicsServer::space_get_direct_state(RID p_space) { +PhysicsDirectSpaceState3D *BulletPhysicsServer3D::space_get_direct_state(RID p_space) { SpaceBullet *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, NULL); + ERR_FAIL_COND_V(!space, nullptr); return space->get_direct_state(); } -void BulletPhysicsServer::space_set_debug_contacts(RID p_space, int p_max_contacts) { +void BulletPhysicsServer3D::space_set_debug_contacts(RID p_space, int p_max_contacts) { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); space->set_debug_contacts(p_max_contacts); } -Vector<Vector3> BulletPhysicsServer::space_get_contacts(RID p_space) const { +Vector<Vector3> BulletPhysicsServer3D::space_get_contacts(RID p_space) const { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, Vector<Vector3>()); return space->get_debug_contacts(); } -int BulletPhysicsServer::space_get_contact_count(RID p_space) const { +int BulletPhysicsServer3D::space_get_contact_count(RID p_space) const { SpaceBullet *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_debug_contact_count(); } -RID BulletPhysicsServer::area_create() { +RID BulletPhysicsServer3D::area_create() { AreaBullet *area = bulletnew(AreaBullet); area->set_collision_layer(1); area->set_collision_mask(1); CreateThenReturnRID(area_owner, area) } -void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) { +void BulletPhysicsServer3D::area_set_space(RID p_area, RID p_space) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); - SpaceBullet *space = NULL; + SpaceBullet *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -260,26 +260,26 @@ void BulletPhysicsServer::area_set_space(RID p_area, RID p_space) { area->set_space(space); } -RID BulletPhysicsServer::area_get_space(RID p_area) const { +RID BulletPhysicsServer3D::area_get_space(RID p_area) const { AreaBullet *area = area_owner.getornull(p_area); return area->get_space()->get_self(); } -void BulletPhysicsServer::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { +void BulletPhysicsServer3D::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_spOv_mode(p_mode); } -PhysicsServer::AreaSpaceOverrideMode BulletPhysicsServer::area_get_space_override_mode(RID p_area) const { +PhysicsServer3D::AreaSpaceOverrideMode BulletPhysicsServer3D::area_get_space_override_mode(RID p_area) const { AreaBullet *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED); + ERR_FAIL_COND_V(!area, PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED); return area->get_spOv_mode(); } -void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) { +void BulletPhysicsServer3D::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -289,7 +289,7 @@ void BulletPhysicsServer::area_add_shape(RID p_area, RID p_shape, const Transfor area->add_shape(shape, p_transform, p_disabled); } -void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { +void BulletPhysicsServer3D::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -299,41 +299,41 @@ void BulletPhysicsServer::area_set_shape(RID p_area, int p_shape_idx, RID p_shap area->set_shape(p_shape_idx, shape); } -void BulletPhysicsServer::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) { +void BulletPhysicsServer3D::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_shape_transform(p_shape_idx, p_transform); } -int BulletPhysicsServer::area_get_shape_count(RID p_area) const { +int BulletPhysicsServer3D::area_get_shape_count(RID p_area) const { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, 0); return area->get_shape_count(); } -RID BulletPhysicsServer::area_get_shape(RID p_area, int p_shape_idx) const { +RID BulletPhysicsServer3D::area_get_shape(RID p_area, int p_shape_idx) const { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, RID()); return area->get_shape(p_shape_idx)->get_self(); } -Transform BulletPhysicsServer::area_get_shape_transform(RID p_area, int p_shape_idx) const { +Transform BulletPhysicsServer3D::area_get_shape_transform(RID p_area, int p_shape_idx) const { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Transform()); return area->get_shape_transform(p_shape_idx); } -void BulletPhysicsServer::area_remove_shape(RID p_area, int p_shape_idx) { +void BulletPhysicsServer3D::area_remove_shape(RID p_area, int p_shape_idx) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); return area->remove_shape_full(p_shape_idx); } -void BulletPhysicsServer::area_clear_shapes(RID p_area) { +void BulletPhysicsServer3D::area_clear_shapes(RID p_area) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -341,14 +341,14 @@ void BulletPhysicsServer::area_clear_shapes(RID p_area) { area->remove_shape_full(0); } -void BulletPhysicsServer::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { +void BulletPhysicsServer3D::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_shape_disabled(p_shape_idx, p_disabled); } -void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_id) { +void BulletPhysicsServer3D::area_attach_object_instance_id(RID p_area, ObjectID p_id) { if (space_owner.owns(p_area)) { return; } @@ -357,7 +357,7 @@ void BulletPhysicsServer::area_attach_object_instance_id(RID p_area, ObjectID p_ area->set_instance_id(p_id); } -ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const { +ObjectID BulletPhysicsServer3D::area_get_object_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { return ObjectID(); } @@ -366,7 +366,7 @@ ObjectID BulletPhysicsServer::area_get_object_instance_id(RID p_area) const { return area->get_instance_id(); } -void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { +void BulletPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { if (space_owner.owns(p_area)) { SpaceBullet *space = space_owner.getornull(p_area); if (space) { @@ -381,7 +381,7 @@ void BulletPhysicsServer::area_set_param(RID p_area, AreaParameter p_param, cons } } -Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) const { +Variant BulletPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const { if (space_owner.owns(p_area)) { SpaceBullet *space = space_owner.getornull(p_area); return space->get_param(p_param); @@ -393,64 +393,64 @@ Variant BulletPhysicsServer::area_get_param(RID p_area, AreaParameter p_param) c } } -void BulletPhysicsServer::area_set_transform(RID p_area, const Transform &p_transform) { +void BulletPhysicsServer3D::area_set_transform(RID p_area, const Transform &p_transform) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_transform(p_transform); } -Transform BulletPhysicsServer::area_get_transform(RID p_area) const { +Transform BulletPhysicsServer3D::area_get_transform(RID p_area) const { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Transform()); return area->get_transform(); } -void BulletPhysicsServer::area_set_collision_mask(RID p_area, uint32_t p_mask) { +void BulletPhysicsServer3D::area_set_collision_mask(RID p_area, uint32_t p_mask) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_collision_mask(p_mask); } -void BulletPhysicsServer::area_set_collision_layer(RID p_area, uint32_t p_layer) { +void BulletPhysicsServer3D::area_set_collision_layer(RID p_area, uint32_t p_layer) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_collision_layer(p_layer); } -void BulletPhysicsServer::area_set_monitorable(RID p_area, bool p_monitorable) { +void BulletPhysicsServer3D::area_set_monitorable(RID p_area, bool p_monitorable) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_monitorable(p_monitorable); } -void BulletPhysicsServer::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { +void BulletPhysicsServer3D::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_event_callback(CollisionObjectBullet::TYPE_RIGID_BODY, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); } -void BulletPhysicsServer::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { +void BulletPhysicsServer3D::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_event_callback(CollisionObjectBullet::TYPE_AREA, p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); } -void BulletPhysicsServer::area_set_ray_pickable(RID p_area, bool p_enable) { +void BulletPhysicsServer3D::area_set_ray_pickable(RID p_area, bool p_enable) { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_ray_pickable(p_enable); } -bool BulletPhysicsServer::area_is_ray_pickable(RID p_area) const { +bool BulletPhysicsServer3D::area_is_ray_pickable(RID p_area) const { AreaBullet *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, false); return area->is_ray_pickable(); } -RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) { +RID BulletPhysicsServer3D::body_create(BodyMode p_mode, bool p_init_sleeping) { RigidBodyBullet *body = bulletnew(RigidBodyBullet); body->set_mode(p_mode); body->set_collision_layer(1); @@ -460,10 +460,10 @@ RID BulletPhysicsServer::body_create(BodyMode p_mode, bool p_init_sleeping) { CreateThenReturnRID(rigid_body_owner, body); } -void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) { +void BulletPhysicsServer3D::body_set_space(RID p_body, RID p_space) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - SpaceBullet *space = NULL; + SpaceBullet *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); @@ -476,7 +476,7 @@ void BulletPhysicsServer::body_set_space(RID p_body, RID p_space) { body->set_space(space); } -RID BulletPhysicsServer::body_get_space(RID p_body) const { +RID BulletPhysicsServer3D::body_get_space(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); @@ -486,19 +486,19 @@ RID BulletPhysicsServer::body_get_space(RID p_body) const { return space->get_self(); } -void BulletPhysicsServer::body_set_mode(RID p_body, PhysicsServer::BodyMode p_mode) { +void BulletPhysicsServer3D::body_set_mode(RID p_body, PhysicsServer3D::BodyMode p_mode) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_mode(p_mode); } -PhysicsServer::BodyMode BulletPhysicsServer::body_get_mode(RID p_body) const { +PhysicsServer3D::BodyMode BulletPhysicsServer3D::body_get_mode(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, BODY_MODE_STATIC); return body->get_mode(); } -void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { +void BulletPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -509,7 +509,7 @@ void BulletPhysicsServer::body_add_shape(RID p_body, RID p_shape, const Transfor body->add_shape(shape, p_transform, p_disabled); } -void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { +void BulletPhysicsServer3D::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -519,20 +519,20 @@ void BulletPhysicsServer::body_set_shape(RID p_body, int p_shape_idx, RID p_shap body->set_shape(p_shape_idx, shape); } -void BulletPhysicsServer::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) { +void BulletPhysicsServer3D::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_shape_transform(p_shape_idx, p_transform); } -int BulletPhysicsServer::body_get_shape_count(RID p_body) const { +int BulletPhysicsServer3D::body_get_shape_count(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_shape_count(); } -RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const { +RID BulletPhysicsServer3D::body_get_shape(RID p_body, int p_shape_idx) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); @@ -542,113 +542,113 @@ RID BulletPhysicsServer::body_get_shape(RID p_body, int p_shape_idx) const { return shape->get_self(); } -Transform BulletPhysicsServer::body_get_shape_transform(RID p_body, int p_shape_idx) const { +Transform BulletPhysicsServer3D::body_get_shape_transform(RID p_body, int p_shape_idx) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Transform()); return body->get_shape_transform(p_shape_idx); } -void BulletPhysicsServer::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { +void BulletPhysicsServer3D::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_shape_disabled(p_shape_idx, p_disabled); } -void BulletPhysicsServer::body_remove_shape(RID p_body, int p_shape_idx) { +void BulletPhysicsServer3D::body_remove_shape(RID p_body, int p_shape_idx) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->remove_shape_full(p_shape_idx); } -void BulletPhysicsServer::body_clear_shapes(RID p_body) { +void BulletPhysicsServer3D::body_clear_shapes(RID p_body) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->remove_all_shapes(); } -void BulletPhysicsServer::body_attach_object_instance_id(RID p_body, ObjectID p_id) { +void BulletPhysicsServer3D::body_attach_object_instance_id(RID p_body, ObjectID p_id) { CollisionObjectBullet *body = get_collisin_object(p_body); ERR_FAIL_COND(!body); body->set_instance_id(p_id); } -ObjectID BulletPhysicsServer::body_get_object_instance_id(RID p_body) const { +ObjectID BulletPhysicsServer3D::body_get_object_instance_id(RID p_body) const { CollisionObjectBullet *body = get_collisin_object(p_body); ERR_FAIL_COND_V(!body, ObjectID()); return body->get_instance_id(); } -void BulletPhysicsServer::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) { +void BulletPhysicsServer3D::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_continuous_collision_detection(p_enable); } -bool BulletPhysicsServer::body_is_continuous_collision_detection_enabled(RID p_body) const { +bool BulletPhysicsServer3D::body_is_continuous_collision_detection_enabled(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->is_continuous_collision_detection_enabled(); } -void BulletPhysicsServer::body_set_collision_layer(RID p_body, uint32_t p_layer) { +void BulletPhysicsServer3D::body_set_collision_layer(RID p_body, uint32_t p_layer) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_layer(p_layer); } -uint32_t BulletPhysicsServer::body_get_collision_layer(RID p_body) const { +uint32_t BulletPhysicsServer3D::body_get_collision_layer(RID p_body) const { const RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_layer(); } -void BulletPhysicsServer::body_set_collision_mask(RID p_body, uint32_t p_mask) { +void BulletPhysicsServer3D::body_set_collision_mask(RID p_body, uint32_t p_mask) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_mask(p_mask); } -uint32_t BulletPhysicsServer::body_get_collision_mask(RID p_body) const { +uint32_t BulletPhysicsServer3D::body_get_collision_mask(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_mask(); } -void BulletPhysicsServer::body_set_user_flags(RID p_body, uint32_t p_flags) { +void BulletPhysicsServer3D::body_set_user_flags(RID p_body, uint32_t p_flags) { // This function si not currently supported } -uint32_t BulletPhysicsServer::body_get_user_flags(RID p_body) const { +uint32_t BulletPhysicsServer3D::body_get_user_flags(RID p_body) const { // This function si not currently supported return 0; } -void BulletPhysicsServer::body_set_param(RID p_body, BodyParameter p_param, float p_value) { +void BulletPhysicsServer3D::body_set_param(RID p_body, BodyParameter p_param, float p_value) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_param(p_param, p_value); } -float BulletPhysicsServer::body_get_param(RID p_body, BodyParameter p_param) const { +float BulletPhysicsServer3D::body_get_param(RID p_body, BodyParameter p_param) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_param(p_param); } -void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { +void BulletPhysicsServer3D::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -658,7 +658,7 @@ void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_ma } } -real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const { +real_t BulletPhysicsServer3D::body_get_kinematic_safe_margin(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); @@ -670,90 +670,90 @@ real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const { return 0; } -void BulletPhysicsServer::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { +void BulletPhysicsServer3D::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_state(p_state, p_variant); } -Variant BulletPhysicsServer::body_get_state(RID p_body, BodyState p_state) const { +Variant BulletPhysicsServer3D::body_get_state(RID p_body, BodyState p_state) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Variant()); return body->get_state(p_state); } -void BulletPhysicsServer::body_set_applied_force(RID p_body, const Vector3 &p_force) { +void BulletPhysicsServer3D::body_set_applied_force(RID p_body, const Vector3 &p_force) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_applied_force(p_force); } -Vector3 BulletPhysicsServer::body_get_applied_force(RID p_body) const { +Vector3 BulletPhysicsServer3D::body_get_applied_force(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3()); return body->get_applied_force(); } -void BulletPhysicsServer::body_set_applied_torque(RID p_body, const Vector3 &p_torque) { +void BulletPhysicsServer3D::body_set_applied_torque(RID p_body, const Vector3 &p_torque) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_applied_torque(p_torque); } -Vector3 BulletPhysicsServer::body_get_applied_torque(RID p_body) const { +Vector3 BulletPhysicsServer3D::body_get_applied_torque(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3()); return body->get_applied_torque(); } -void BulletPhysicsServer::body_add_central_force(RID p_body, const Vector3 &p_force) { +void BulletPhysicsServer3D::body_add_central_force(RID p_body, const Vector3 &p_force) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_central_force(p_force); } -void BulletPhysicsServer::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) { +void BulletPhysicsServer3D::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_force(p_force, p_pos); } -void BulletPhysicsServer::body_add_torque(RID p_body, const Vector3 &p_torque) { +void BulletPhysicsServer3D::body_add_torque(RID p_body, const Vector3 &p_torque) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_torque(p_torque); } -void BulletPhysicsServer::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) { +void BulletPhysicsServer3D::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_central_impulse(p_impulse); } -void BulletPhysicsServer::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) { +void BulletPhysicsServer3D::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_impulse(p_pos, p_impulse); } -void BulletPhysicsServer::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) { +void BulletPhysicsServer3D::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->apply_torque_impulse(p_impulse); } -void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) { +void BulletPhysicsServer3D::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -764,19 +764,19 @@ void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_ax body->set_linear_velocity(v); } -void BulletPhysicsServer::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) { +void BulletPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_axis_lock(p_axis, p_lock); } -bool BulletPhysicsServer::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { +bool BulletPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { const RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->is_axis_locked(p_axis); } -void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) { +void BulletPhysicsServer3D::body_add_collision_exception(RID p_body, RID p_body_b) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -786,7 +786,7 @@ void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) body->add_collision_exception(other_body); } -void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body_b) { +void BulletPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_body_b) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -796,7 +796,7 @@ void BulletPhysicsServer::body_remove_collision_exception(RID p_body, RID p_body body->remove_collision_exception(other_body); } -void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { +void BulletPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); for (int i = 0; i < body->get_exceptions().size(); i++) { @@ -804,68 +804,68 @@ void BulletPhysicsServer::body_get_collision_exceptions(RID p_body, List<RID> *p } } -void BulletPhysicsServer::body_set_max_contacts_reported(RID p_body, int p_contacts) { +void BulletPhysicsServer3D::body_set_max_contacts_reported(RID p_body, int p_contacts) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_max_collisions_detection(p_contacts); } -int BulletPhysicsServer::body_get_max_contacts_reported(RID p_body) const { +int BulletPhysicsServer3D::body_get_max_contacts_reported(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_max_collisions_detection(); } -void BulletPhysicsServer::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) { +void BulletPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) { // Not supported by bullet and even Godot } -float BulletPhysicsServer::body_get_contacts_reported_depth_threshold(RID p_body) const { +float BulletPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const { // Not supported by bullet and even Godot return 0.; } -void BulletPhysicsServer::body_set_omit_force_integration(RID p_body, bool p_omit) { +void BulletPhysicsServer3D::body_set_omit_force_integration(RID p_body, bool p_omit) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_omit_forces_integration(p_omit); } -bool BulletPhysicsServer::body_is_omitting_force_integration(RID p_body) const { +bool BulletPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->get_omit_forces_integration(); } -void BulletPhysicsServer::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { +void BulletPhysicsServer3D::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata); } -void BulletPhysicsServer::body_set_ray_pickable(RID p_body, bool p_enable) { +void BulletPhysicsServer3D::body_set_ray_pickable(RID p_body, bool p_enable) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_ray_pickable(p_enable); } -bool BulletPhysicsServer::body_is_ray_pickable(RID p_body) const { +bool BulletPhysicsServer3D::body_is_ray_pickable(RID p_body) const { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->is_ray_pickable(); } -PhysicsDirectBodyState *BulletPhysicsServer::body_get_direct_state(RID p_body) { +PhysicsDirectBodyState3D *BulletPhysicsServer3D::body_get_direct_state(RID p_body) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, NULL); - return BulletPhysicsDirectBodyState::get_singleton(body); + ERR_FAIL_COND_V(!body, nullptr); + return BulletPhysicsDirectBodyState3D::get_singleton(body); } -bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool BulletPhysicsServer3D::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); ERR_FAIL_COND_V(!body->get_space(), false); @@ -873,7 +873,7 @@ bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, r_result, p_exclude_raycast_shapes); } -int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { +int BulletPhysicsServer3D::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { RigidBodyBullet *body = rigid_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); ERR_FAIL_COND_V(!body->get_space(), 0); @@ -881,7 +881,7 @@ int BulletPhysicsServer::body_test_ray_separation(RID p_body, const Transform &p return body->get_space()->test_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin); } -RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) { +RID BulletPhysicsServer3D::soft_body_create(bool p_init_sleeping) { SoftBodyBullet *body = bulletnew(SoftBodyBullet); body->set_collision_layer(1); body->set_collision_mask(1); @@ -890,17 +890,17 @@ RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) { CreateThenReturnRID(soft_body_owner, body); } -void BulletPhysicsServer::soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) { +void BulletPhysicsServer3D::soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - body->update_visual_server(p_visual_server_handler); + body->update_rendering_server(p_rendering_server_handler); } -void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) { +void BulletPhysicsServer3D::soft_body_set_space(RID p_body, RID p_space) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); - SpaceBullet *space = NULL; + SpaceBullet *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); @@ -913,7 +913,7 @@ void BulletPhysicsServer::soft_body_set_space(RID p_body, RID p_space) { body->set_space(space); } -RID BulletPhysicsServer::soft_body_get_space(RID p_body) const { +RID BulletPhysicsServer3D::soft_body_get_space(RID p_body) const { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); @@ -923,42 +923,42 @@ RID BulletPhysicsServer::soft_body_get_space(RID p_body) const { return space->get_self(); } -void BulletPhysicsServer::soft_body_set_mesh(RID p_body, const REF &p_mesh) { +void BulletPhysicsServer3D::soft_body_set_mesh(RID p_body, const REF &p_mesh) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_soft_mesh(p_mesh); } -void BulletPhysicsServer::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) { +void BulletPhysicsServer3D::soft_body_set_collision_layer(RID p_body, uint32_t p_layer) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_layer(p_layer); } -uint32_t BulletPhysicsServer::soft_body_get_collision_layer(RID p_body) const { +uint32_t BulletPhysicsServer3D::soft_body_get_collision_layer(RID p_body) const { const SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_layer(); } -void BulletPhysicsServer::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) { +void BulletPhysicsServer3D::soft_body_set_collision_mask(RID p_body, uint32_t p_mask) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_mask(p_mask); } -uint32_t BulletPhysicsServer::soft_body_get_collision_mask(RID p_body) const { +uint32_t BulletPhysicsServer3D::soft_body_get_collision_mask(RID p_body) const { const SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_mask(); } -void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_body_b) { +void BulletPhysicsServer3D::soft_body_add_collision_exception(RID p_body, RID p_body_b) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -971,7 +971,7 @@ void BulletPhysicsServer::soft_body_add_collision_exception(RID p_body, RID p_bo body->add_collision_exception(other_body); } -void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p_body_b) { +void BulletPhysicsServer3D::soft_body_remove_collision_exception(RID p_body, RID p_body_b) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -984,7 +984,7 @@ void BulletPhysicsServer::soft_body_remove_collision_exception(RID p_body, RID p body->remove_collision_exception(other_body); } -void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { +void BulletPhysicsServer3D::soft_body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); for (int i = 0; i < body->get_exceptions().size(); i++) { @@ -992,25 +992,25 @@ void BulletPhysicsServer::soft_body_get_collision_exceptions(RID p_body, List<RI } } -void BulletPhysicsServer::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { +void BulletPhysicsServer3D::soft_body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { // FIXME: Must be implemented. WARN_PRINT("soft_body_state is not implemented yet in Bullet backend."); } -Variant BulletPhysicsServer::soft_body_get_state(RID p_body, BodyState p_state) const { +Variant BulletPhysicsServer3D::soft_body_get_state(RID p_body, BodyState p_state) const { // FIXME: Must be implemented. WARN_PRINT("soft_body_state is not implemented yet in Bullet backend."); return Variant(); } -void BulletPhysicsServer::soft_body_set_transform(RID p_body, const Transform &p_transform) { +void BulletPhysicsServer3D::soft_body_set_transform(RID p_body, const Transform &p_transform) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_soft_transform(p_transform); } -Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int vertex_index) const { +Vector3 BulletPhysicsServer3D::soft_body_get_vertex_position(RID p_body, int vertex_index) const { const SoftBodyBullet *body = soft_body_owner.getornull(p_body); Vector3 pos; ERR_FAIL_COND_V(!body, pos); @@ -1019,133 +1019,133 @@ Vector3 BulletPhysicsServer::soft_body_get_vertex_position(RID p_body, int verte return pos; } -void BulletPhysicsServer::soft_body_set_ray_pickable(RID p_body, bool p_enable) { +void BulletPhysicsServer3D::soft_body_set_ray_pickable(RID p_body, bool p_enable) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_ray_pickable(p_enable); } -bool BulletPhysicsServer::soft_body_is_ray_pickable(RID p_body) const { +bool BulletPhysicsServer3D::soft_body_is_ray_pickable(RID p_body) const { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->is_ray_pickable(); } -void BulletPhysicsServer::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) { +void BulletPhysicsServer3D::soft_body_set_simulation_precision(RID p_body, int p_simulation_precision) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_simulation_precision(p_simulation_precision); } -int BulletPhysicsServer::soft_body_get_simulation_precision(RID p_body) { +int BulletPhysicsServer3D::soft_body_get_simulation_precision(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_simulation_precision(); } -void BulletPhysicsServer::soft_body_set_total_mass(RID p_body, real_t p_total_mass) { +void BulletPhysicsServer3D::soft_body_set_total_mass(RID p_body, real_t p_total_mass) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_total_mass(p_total_mass); } -real_t BulletPhysicsServer::soft_body_get_total_mass(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_total_mass(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_total_mass(); } -void BulletPhysicsServer::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) { +void BulletPhysicsServer3D::soft_body_set_linear_stiffness(RID p_body, real_t p_stiffness) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_linear_stiffness(p_stiffness); } -real_t BulletPhysicsServer::soft_body_get_linear_stiffness(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_linear_stiffness(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_linear_stiffness(); } -void BulletPhysicsServer::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) { +void BulletPhysicsServer3D::soft_body_set_areaAngular_stiffness(RID p_body, real_t p_stiffness) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_areaAngular_stiffness(p_stiffness); } -real_t BulletPhysicsServer::soft_body_get_areaAngular_stiffness(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_areaAngular_stiffness(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_areaAngular_stiffness(); } -void BulletPhysicsServer::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) { +void BulletPhysicsServer3D::soft_body_set_volume_stiffness(RID p_body, real_t p_stiffness) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_volume_stiffness(p_stiffness); } -real_t BulletPhysicsServer::soft_body_get_volume_stiffness(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_volume_stiffness(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_volume_stiffness(); } -void BulletPhysicsServer::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) { +void BulletPhysicsServer3D::soft_body_set_pressure_coefficient(RID p_body, real_t p_pressure_coefficient) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_pressure_coefficient(p_pressure_coefficient); } -real_t BulletPhysicsServer::soft_body_get_pressure_coefficient(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_pressure_coefficient(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_pressure_coefficient(); } -void BulletPhysicsServer::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) { +void BulletPhysicsServer3D::soft_body_set_pose_matching_coefficient(RID p_body, real_t p_pose_matching_coefficient) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); return body->set_pose_matching_coefficient(p_pose_matching_coefficient); } -real_t BulletPhysicsServer::soft_body_get_pose_matching_coefficient(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_pose_matching_coefficient(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_pose_matching_coefficient(); } -void BulletPhysicsServer::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) { +void BulletPhysicsServer3D::soft_body_set_damping_coefficient(RID p_body, real_t p_damping_coefficient) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_damping_coefficient(p_damping_coefficient); } -real_t BulletPhysicsServer::soft_body_get_damping_coefficient(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_damping_coefficient(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_damping_coefficient(); } -void BulletPhysicsServer::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) { +void BulletPhysicsServer3D::soft_body_set_drag_coefficient(RID p_body, real_t p_drag_coefficient) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_drag_coefficient(p_drag_coefficient); } -real_t BulletPhysicsServer::soft_body_get_drag_coefficient(RID p_body) { +real_t BulletPhysicsServer3D::soft_body_get_drag_coefficient(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_drag_coefficient(); } -void BulletPhysicsServer::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) { +void BulletPhysicsServer3D::soft_body_move_point(RID p_body, int p_point_index, const Vector3 &p_global_position) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_node_position(p_point_index, p_global_position); } -Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int p_point_index) { +Vector3 BulletPhysicsServer3D::soft_body_get_point_global_position(RID p_body, int p_point_index) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3(0., 0., 0.)); Vector3 pos; @@ -1153,7 +1153,7 @@ Vector3 BulletPhysicsServer::soft_body_get_point_global_position(RID p_body, int return pos; } -Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_index) const { +Vector3 BulletPhysicsServer3D::soft_body_get_point_offset(RID p_body, int p_point_index) const { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector3()); Vector3 res; @@ -1161,60 +1161,60 @@ Vector3 BulletPhysicsServer::soft_body_get_point_offset(RID p_body, int p_point_ return res; } -void BulletPhysicsServer::soft_body_remove_all_pinned_points(RID p_body) { +void BulletPhysicsServer3D::soft_body_remove_all_pinned_points(RID p_body) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->reset_all_node_mass(); } -void BulletPhysicsServer::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) { +void BulletPhysicsServer3D::soft_body_pin_point(RID p_body, int p_point_index, bool p_pin) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_node_mass(p_point_index, p_pin ? 0 : 1); } -bool BulletPhysicsServer::soft_body_is_point_pinned(RID p_body, int p_point_index) { +bool BulletPhysicsServer3D::soft_body_is_point_pinned(RID p_body, int p_point_index) { SoftBodyBullet *body = soft_body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0.f); return body->get_node_mass(p_point_index); } -PhysicsServer::JointType BulletPhysicsServer::joint_get_type(RID p_joint) const { +PhysicsServer3D::JointType BulletPhysicsServer3D::joint_get_type(RID p_joint) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, JOINT_PIN); return joint->get_type(); } -void BulletPhysicsServer::joint_set_solver_priority(RID p_joint, int p_priority) { +void BulletPhysicsServer3D::joint_set_solver_priority(RID p_joint, int p_priority) { // Joint priority not supported by bullet } -int BulletPhysicsServer::joint_get_solver_priority(RID p_joint) const { +int BulletPhysicsServer3D::joint_get_solver_priority(RID p_joint) const { // Joint priority not supported by bullet return 0; } -void BulletPhysicsServer::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { +void BulletPhysicsServer3D::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); joint->disable_collisions_between_bodies(p_disable); } -bool BulletPhysicsServer::joint_is_disabled_collisions_between_bodies(RID p_joint) const { +bool BulletPhysicsServer3D::joint_is_disabled_collisions_between_bodies(RID p_joint) const { JointBullet *joint(joint_owner.getornull(p_joint)); ERR_FAIL_COND_V(!joint, false); return joint->is_disabled_collisions_between_bodies(); } -RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) { +RID BulletPhysicsServer3D::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) { RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1229,7 +1229,7 @@ RID BulletPhysicsServer::joint_create_pin(RID p_body_A, const Vector3 &p_local_A CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) { +void BulletPhysicsServer3D::pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); @@ -1237,7 +1237,7 @@ void BulletPhysicsServer::pin_joint_set_param(RID p_joint, PinJointParam p_param pin_joint->set_param(p_param, p_value); } -float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { +float BulletPhysicsServer3D::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0); @@ -1245,7 +1245,7 @@ float BulletPhysicsServer::pin_joint_get_param(RID p_joint, PinJointParam p_para return pin_joint->get_param(p_param); } -void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) { +void BulletPhysicsServer3D::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); @@ -1253,7 +1253,7 @@ void BulletPhysicsServer::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) pin_joint->setPivotInA(p_A); } -Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const { +Vector3 BulletPhysicsServer3D::pin_joint_get_local_a(RID p_joint) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, Vector3()); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); @@ -1261,7 +1261,7 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_a(RID p_joint) const { return pin_joint->getPivotInA(); } -void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) { +void BulletPhysicsServer3D::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); @@ -1269,7 +1269,7 @@ void BulletPhysicsServer::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) pin_joint->setPivotInB(p_B); } -Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const { +Vector3 BulletPhysicsServer3D::pin_joint_get_local_b(RID p_joint) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, Vector3()); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); @@ -1277,12 +1277,12 @@ Vector3 BulletPhysicsServer::pin_joint_get_local_b(RID p_joint) const { return pin_joint->getPivotInB(); } -RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) { +RID BulletPhysicsServer3D::joint_create_hinge(RID p_body_A, const Transform &p_hinge_A, RID p_body_B, const Transform &p_hinge_B) { RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1297,12 +1297,12 @@ RID BulletPhysicsServer::joint_create_hinge(RID p_body_A, const Transform &p_hin CreateThenReturnRID(joint_owner, joint); } -RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) { +RID BulletPhysicsServer3D::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) { RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1317,7 +1317,7 @@ RID BulletPhysicsServer::joint_create_hinge_simple(RID p_body_A, const Vector3 & CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) { +void BulletPhysicsServer3D::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, float p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); @@ -1325,7 +1325,7 @@ void BulletPhysicsServer::hinge_joint_set_param(RID p_joint, HingeJointParam p_p hinge_joint->set_param(p_param, p_value); } -float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { +float BulletPhysicsServer3D::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0); @@ -1333,7 +1333,7 @@ float BulletPhysicsServer::hinge_joint_get_param(RID p_joint, HingeJointParam p_ return hinge_joint->get_param(p_param); } -void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) { +void BulletPhysicsServer3D::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); @@ -1341,7 +1341,7 @@ void BulletPhysicsServer::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_fla hinge_joint->set_flag(p_flag, p_value); } -bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const { +bool BulletPhysicsServer3D::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, false); ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false); @@ -1349,12 +1349,12 @@ bool BulletPhysicsServer::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_fla return hinge_joint->get_flag(p_flag); } -RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { +RID BulletPhysicsServer3D::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1369,7 +1369,7 @@ RID BulletPhysicsServer::joint_create_slider(RID p_body_A, const Transform &p_lo CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) { +void BulletPhysicsServer3D::slider_joint_set_param(RID p_joint, SliderJointParam p_param, float p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER); @@ -1377,7 +1377,7 @@ void BulletPhysicsServer::slider_joint_set_param(RID p_joint, SliderJointParam p slider_joint->set_param(p_param, p_value); } -float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { +float BulletPhysicsServer3D::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_SLIDER, 0); @@ -1385,12 +1385,12 @@ float BulletPhysicsServer::slider_joint_get_param(RID p_joint, SliderJointParam return slider_joint->get_param(p_param); } -RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { +RID BulletPhysicsServer3D::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1403,7 +1403,7 @@ RID BulletPhysicsServer::joint_create_cone_twist(RID p_body_A, const Transform & CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) { +void BulletPhysicsServer3D::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, float p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST); @@ -1411,7 +1411,7 @@ void BulletPhysicsServer::cone_twist_joint_set_param(RID p_joint, ConeTwistJoint coneTwist_joint->set_param(p_param, p_value); } -float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { +float BulletPhysicsServer3D::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0.); ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0.); @@ -1419,12 +1419,12 @@ float BulletPhysicsServer::cone_twist_joint_get_param(RID p_joint, ConeTwistJoin return coneTwist_joint->get_param(p_param); } -RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { +RID BulletPhysicsServer3D::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { RigidBodyBullet *body_A = rigid_body_owner.getornull(p_body_A); ERR_FAIL_COND_V(!body_A, RID()); JointAssertSpace(body_A, "A", RID()); - RigidBodyBullet *body_B = NULL; + RigidBodyBullet *body_B = nullptr; if (p_body_B.is_valid()) { body_B = rigid_body_owner.getornull(p_body_B); JointAssertSpace(body_B, "B", RID()); @@ -1439,7 +1439,7 @@ RID BulletPhysicsServer::joint_create_generic_6dof(RID p_body_A, const Transform CreateThenReturnRID(joint_owner, joint); } -void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) { +void BulletPhysicsServer3D::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, float p_value) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); @@ -1447,7 +1447,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_param(RID p_joint, Vector3::Axi generic_6dof_joint->set_param(p_axis, p_param, p_value); } -float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { +float BulletPhysicsServer3D::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); @@ -1455,7 +1455,7 @@ float BulletPhysicsServer::generic_6dof_joint_get_param(RID p_joint, Vector3::Ax return generic_6dof_joint->get_param(p_axis, p_param); } -void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) { +void BulletPhysicsServer3D::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); @@ -1463,7 +1463,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis generic_6dof_joint->set_flag(p_axis, p_flag, p_enable); } -bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) { +bool BulletPhysicsServer3D::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, false); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false); @@ -1471,7 +1471,7 @@ bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis return generic_6dof_joint->get_flag(p_axis, p_flag); } -void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_precision) { +void BulletPhysicsServer3D::generic_6dof_joint_set_precision(RID p_joint, int p_precision) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); @@ -1479,7 +1479,7 @@ void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_pr generic_6dof_joint->set_precision(p_precision); } -int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) { +int BulletPhysicsServer3D::generic_6dof_joint_get_precision(RID p_joint) { JointBullet *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); @@ -1487,7 +1487,7 @@ int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) { return generic_6dof_joint->get_precision(); } -void BulletPhysicsServer::free(RID p_rid) { +void BulletPhysicsServer3D::free(RID p_rid) { if (shape_owner.owns(p_rid)) { ShapeBullet *shape = shape_owner.getornull(p_rid); @@ -1503,7 +1503,7 @@ void BulletPhysicsServer::free(RID p_rid) { RigidBodyBullet *body = rigid_body_owner.getornull(p_rid); - body->set_space(NULL); + body->set_space(nullptr); body->remove_all_shapes(true, true); @@ -1514,7 +1514,7 @@ void BulletPhysicsServer::free(RID p_rid) { SoftBodyBullet *body = soft_body_owner.getornull(p_rid); - body->set_space(NULL); + body->set_space(nullptr); soft_body_owner.free(p_rid); bulletdelete(body); @@ -1523,7 +1523,7 @@ void BulletPhysicsServer::free(RID p_rid) { AreaBullet *area = area_owner.getornull(p_rid); - area->set_space(NULL); + area->set_space(nullptr); area->remove_all_shapes(true, true); @@ -1552,15 +1552,15 @@ void BulletPhysicsServer::free(RID p_rid) { } } -void BulletPhysicsServer::init() { - BulletPhysicsDirectBodyState::initSingleton(); +void BulletPhysicsServer3D::init() { + BulletPhysicsDirectBodyState3D::initSingleton(); } -void BulletPhysicsServer::step(float p_deltaTime) { +void BulletPhysicsServer3D::step(float p_deltaTime) { if (!active) return; - BulletPhysicsDirectBodyState::singleton_setDeltaTime(p_deltaTime); + BulletPhysicsDirectBodyState3D::singleton_setDeltaTime(p_deltaTime); for (int i = 0; i < active_spaces_count; ++i) { @@ -1568,21 +1568,21 @@ void BulletPhysicsServer::step(float p_deltaTime) { } } -void BulletPhysicsServer::sync() { +void BulletPhysicsServer3D::sync() { } -void BulletPhysicsServer::flush_queries() { +void BulletPhysicsServer3D::flush_queries() { } -void BulletPhysicsServer::finish() { - BulletPhysicsDirectBodyState::destroySingleton(); +void BulletPhysicsServer3D::finish() { + BulletPhysicsDirectBodyState3D::destroySingleton(); } -int BulletPhysicsServer::get_process_info(ProcessInfo p_info) { +int BulletPhysicsServer3D::get_process_info(ProcessInfo p_info) { return 0; } -CollisionObjectBullet *BulletPhysicsServer::get_collisin_object(RID p_object) const { +CollisionObjectBullet *BulletPhysicsServer3D::get_collisin_object(RID p_object) const { if (rigid_body_owner.owns(p_object)) { return rigid_body_owner.getornull(p_object); } @@ -1592,15 +1592,15 @@ CollisionObjectBullet *BulletPhysicsServer::get_collisin_object(RID p_object) co if (soft_body_owner.owns(p_object)) { return soft_body_owner.getornull(p_object); } - return NULL; + return nullptr; } -RigidCollisionObjectBullet *BulletPhysicsServer::get_rigid_collisin_object(RID p_object) const { +RigidCollisionObjectBullet *BulletPhysicsServer3D::get_rigid_collisin_object(RID p_object) const { if (rigid_body_owner.owns(p_object)) { return rigid_body_owner.getornull(p_object); } if (area_owner.owns(p_object)) { return area_owner.getornull(p_object); } - return NULL; + return nullptr; } diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 6ea9a7a974..ea9c5e589e 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -36,7 +36,7 @@ #include "core/rid_owner.h" #include "joint_bullet.h" #include "rigid_body_bullet.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include "shape_bullet.h" #include "soft_body_bullet.h" #include "space_bullet.h" @@ -44,8 +44,8 @@ @author AndreaCatania */ -class BulletPhysicsServer : public PhysicsServer { - GDCLASS(BulletPhysicsServer, PhysicsServer); +class BulletPhysicsServer3D : public PhysicsServer3D { + GDCLASS(BulletPhysicsServer3D, PhysicsServer3D); friend class BulletPhysicsDirectSpaceState; @@ -64,8 +64,8 @@ protected: static void _bind_methods(); public: - BulletPhysicsServer(); - ~BulletPhysicsServer(); + BulletPhysicsServer3D(); + ~BulletPhysicsServer3D(); _FORCE_INLINE_ RID_PtrOwner<SpaceBullet> *get_space_owner() { return &space_owner; @@ -111,7 +111,7 @@ public: /// Not supported virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const; - virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space); + virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space); virtual void space_set_debug_contacts(RID p_space, int p_max_contacts); virtual Vector<Vector3> space_get_contacts(RID p_space) const; @@ -252,16 +252,16 @@ public: virtual bool body_is_ray_pickable(RID p_body) const; // this function only works on physics process, errors and returns null otherwise - virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body); + virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body); - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true); + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true); virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001); /* SOFT BODY API */ virtual RID soft_body_create(bool p_init_sleeping = false); - virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler); + virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler); virtual void soft_body_set_space(RID p_body, RID p_space); virtual RID soft_body_get_space(RID p_body) const; @@ -387,7 +387,7 @@ public: } static bool singleton_isActive() { - return static_cast<BulletPhysicsServer *>(get_singleton())->active; + return static_cast<BulletPhysicsServer3D *>(get_singleton())->active; } bool isActive() { diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h index 968cb38ba2..a5e33d9829 100644 --- a/modules/bullet/bullet_utilities.h +++ b/modules/bullet/bullet_utilities.h @@ -41,6 +41,6 @@ #define bulletdelete(cl) \ { \ delete cl; \ - cl = NULL; \ + cl = nullptr; \ } #endif diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 5b7e7281e4..1b72c2f577 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -60,7 +60,7 @@ void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_tra } btTransform CollisionObjectBullet::ShapeWrapper::get_adjusted_transform() const { - if (shape->get_type() == PhysicsServer::SHAPE_HEIGHTMAP) { + if (shape->get_type() == PhysicsServer3D::SHAPE_HEIGHTMAP) { const HeightMapShapeBullet *hm_shape = (const HeightMapShapeBullet *)shape; // should be safe to cast now btTransform adjusted_transform; @@ -96,10 +96,10 @@ CollisionObjectBullet::CollisionObjectBullet(Type p_type) : collisionsEnabled(true), m_isStatic(false), ray_pickable(false), - bt_collision_object(NULL), + bt_collision_object(nullptr), body_scale(1., 1., 1.), force_shape_reset(false), - space(NULL), + space(nullptr), isTransformChanged(false) {} CollisionObjectBullet::~CollisionObjectBullet() { @@ -227,7 +227,7 @@ void CollisionObjectBullet::notify_transform_changed() { RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) : CollisionObjectBullet(p_type), - mainShape(NULL) { + mainShape(nullptr) { } RigidCollisionObjectBullet::~RigidCollisionObjectBullet() { @@ -332,7 +332,7 @@ bool RigidCollisionObjectBullet::is_shape_disabled(int p_index) { void RigidCollisionObjectBullet::shape_changed(int p_shape_index) { ShapeWrapper &shp = shapes.write[p_shape_index]; if (shp.bt_shape == mainShape) { - mainShape = NULL; + mainShape = nullptr; } bulletdelete(shp.bt_shape); reload_shapes(); @@ -345,7 +345,7 @@ void RigidCollisionObjectBullet::reload_shapes() { bulletdelete(mainShape); } - mainShape = NULL; + mainShape = nullptr; ShapeWrapper *shpWrapper; const int shape_count = shapes.size(); @@ -398,7 +398,7 @@ void RigidCollisionObjectBullet::internal_shape_destroy(int p_index, bool p_perm ShapeWrapper &shp = shapes.write[p_index]; shp.shape->remove_owner(this, p_permanentlyFromThisBody); if (shp.bt_shape == mainShape) { - mainShape = NULL; + mainShape = nullptr; } bulletdelete(shp.bt_shape); } diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h index 42ba4aa907..25176458a7 100644 --- a/modules/bullet/collision_object_bullet.h +++ b/modules/bullet/collision_object_bullet.h @@ -76,20 +76,20 @@ public: bool active; ShapeWrapper() : - shape(NULL), - bt_shape(NULL), + shape(nullptr), + bt_shape(nullptr), active(true) {} ShapeWrapper(ShapeBullet *p_shape, const btTransform &p_transform, bool p_active) : shape(p_shape), - bt_shape(NULL), + bt_shape(nullptr), active(p_active) { set_transform(p_transform); } ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) : shape(p_shape), - bt_shape(NULL), + bt_shape(nullptr), active(p_active) { set_transform(p_transform); } diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp index 23eb39fe7e..aac51034b8 100644 --- a/modules/bullet/cone_twist_joint_bullet.cpp +++ b/modules/bullet/cone_twist_joint_bullet.cpp @@ -64,43 +64,43 @@ ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet setup(coneConstraint); } -void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) { +void ConeTwistJointBullet::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: + case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: coneConstraint->setLimit(5, p_value); coneConstraint->setLimit(4, p_value); break; - case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN: + case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: coneConstraint->setLimit(3, p_value); break; - case PhysicsServer::CONE_TWIST_JOINT_BIAS: + case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), p_value, coneConstraint->getRelaxationFactor()); break; - case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS: + case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), p_value, coneConstraint->getBiasFactor(), coneConstraint->getRelaxationFactor()); break; - case PhysicsServer::CONE_TWIST_JOINT_RELAXATION: + case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), coneConstraint->getBiasFactor(), p_value); break; - case PhysicsServer::CONE_TWIST_MAX: + case PhysicsServer3D::CONE_TWIST_MAX: // Internal size value, nothing to do. break; } } -real_t ConeTwistJointBullet::get_param(PhysicsServer::ConeTwistJointParam p_param) const { +real_t ConeTwistJointBullet::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const { switch (p_param) { - case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: + case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: return coneConstraint->getSwingSpan1(); - case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN: + case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: return coneConstraint->getTwistSpan(); - case PhysicsServer::CONE_TWIST_JOINT_BIAS: + case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: return coneConstraint->getBiasFactor(); - case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS: + case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: return coneConstraint->getLimitSoftness(); - case PhysicsServer::CONE_TWIST_JOINT_RELAXATION: + case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: return coneConstraint->getRelaxationFactor(); - case PhysicsServer::CONE_TWIST_MAX: + case PhysicsServer3D::CONE_TWIST_MAX: // Internal size value, nothing to do. return 0; } diff --git a/modules/bullet/cone_twist_joint_bullet.h b/modules/bullet/cone_twist_joint_bullet.h index 134706f8bb..ed4baa9d1b 100644 --- a/modules/bullet/cone_twist_joint_bullet.h +++ b/modules/bullet/cone_twist_joint_bullet.h @@ -45,9 +45,9 @@ class ConeTwistJointBullet : public JointBullet { public: ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; } - void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const; + void set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::ConeTwistJointParam p_param) const; }; #endif diff --git a/modules/bullet/config.py b/modules/bullet/config.py index 92dbcf5cb0..e8ca273f61 100644 --- a/modules/bullet/config.py +++ b/modules/bullet/config.py @@ -1,14 +1,17 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ - "BulletPhysicsDirectBodyState", - "BulletPhysicsServer", + "BulletPhysicsDirectBodyState3D", + "BulletPhysicsServer3D", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/bullet/constraint_bullet.cpp b/modules/bullet/constraint_bullet.cpp index 7e90e2b488..469b58521e 100644 --- a/modules/bullet/constraint_bullet.cpp +++ b/modules/bullet/constraint_bullet.cpp @@ -38,8 +38,8 @@ */ ConstraintBullet::ConstraintBullet() : - space(NULL), - constraint(NULL), + space(nullptr), + constraint(nullptr), disabled_collisions_between_bodies(true) {} void ConstraintBullet::setup(btTypedConstraint *p_constraint) { diff --git a/modules/bullet/constraint_bullet.h b/modules/bullet/constraint_bullet.h index 89ad150257..1946807bad 100644 --- a/modules/bullet/constraint_bullet.h +++ b/modules/bullet/constraint_bullet.h @@ -64,7 +64,7 @@ public: public: virtual ~ConstraintBullet() { bulletdelete(constraint); - constraint = NULL; + constraint = nullptr; } _FORCE_INLINE_ btTypedConstraint *get_bt_constraint() { return constraint; } diff --git a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState3D.xml index 5ea1b810a1..1c0181bd9c 100644 --- a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml +++ b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BulletPhysicsDirectBodyState" inherits="PhysicsDirectBodyState" version="4.0"> +<class name="BulletPhysicsDirectBodyState3D" inherits="PhysicsDirectBodyState3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/modules/bullet/doc_classes/BulletPhysicsServer.xml b/modules/bullet/doc_classes/BulletPhysicsServer3D.xml index af8fb3c02c..b20595b4f6 100644 --- a/modules/bullet/doc_classes/BulletPhysicsServer.xml +++ b/modules/bullet/doc_classes/BulletPhysicsServer3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BulletPhysicsServer" inherits="PhysicsServer" version="4.0"> +<class name="BulletPhysicsServer3D" inherits="PhysicsServer3D" version="4.0"> <brief_description> </brief_description> <description> diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp index 45ab3d3bb2..638944df76 100644 --- a/modules/bullet/generic_6dof_joint_bullet.cpp +++ b/modules/bullet/generic_6dof_joint_bullet.cpp @@ -43,6 +43,12 @@ Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : JointBullet() { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) { + flags[i][j] = false; + } + } + Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale())); scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); @@ -118,62 +124,62 @@ void Generic6DOFJointBullet::set_angular_upper_limit(const Vector3 &angularUpper sixDOFConstraint->setAngularUpperLimit(btVec); } -void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) { +void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) { ERR_FAIL_INDEX(p_axis, 3); switch (p_param) { - case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: limits_lower[0][p_axis] = p_value; - set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter + set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter break; - case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: limits_upper[0][p_axis] = p_value; - set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter + set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter break; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis] = p_value; break; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis] = p_value; break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis] = p_value; break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis] = p_value; break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis] = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: limits_lower[1][p_axis] = p_value; - set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter + set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: limits_upper[1][p_axis] = p_value; - set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter + set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping = p_value; break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint = p_value; break; - case PhysicsServer::G6DOF_JOINT_MAX: + case PhysicsServer3D::G6DOF_JOINT_MAX: // Internal size value, nothing to do. break; default: @@ -182,42 +188,42 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO } } -real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const { +real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const { ERR_FAIL_INDEX_V(p_axis, 3, 0.); switch (p_param) { - case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: return limits_lower[0][p_axis]; - case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: return limits_upper[0][p_axis]; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: return sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis]; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: return sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis]; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: return sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis]; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: return sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis]; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: return sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis]; - case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: return limits_lower[1][p_axis]; - case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: return limits_upper[1][p_axis]; - case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce; - case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint; - case PhysicsServer::G6DOF_JOINT_MAX: + case PhysicsServer3D::G6DOF_JOINT_MAX: // Internal size value, nothing to do. return 0; default: @@ -226,45 +232,45 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6 } } -void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value) { +void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) { ERR_FAIL_INDEX(p_axis, 3); flags[p_axis][p_flag] = p_value; switch (p_flag) { - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: if (flags[p_axis][p_flag]) { sixDOFConstraint->setLimit(p_axis, limits_lower[0][p_axis], limits_upper[0][p_axis]); } else { sixDOFConstraint->setLimit(p_axis, 0, -1); // Free } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: if (flags[p_axis][p_flag]) { sixDOFConstraint->setLimit(p_axis + 3, limits_lower[1][p_axis], limits_upper[1][p_axis]); } else { sixDOFConstraint->setLimit(p_axis + 3, 0, -1); // Free } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value; break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: sixDOFConstraint->getTranslationalLimitMotor()->m_enableSpring[p_axis] = p_value; break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = flags[p_axis][p_flag]; break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = flags[p_axis][p_flag]; break; - case PhysicsServer::G6DOF_JOINT_FLAG_MAX: + case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX: // Internal size value, nothing to do. break; } } -bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const { +bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const { ERR_FAIL_INDEX_V(p_axis, 3, false); return flags[p_axis][p_flag]; } diff --git a/modules/bullet/generic_6dof_joint_bullet.h b/modules/bullet/generic_6dof_joint_bullet.h index 75c8005811..316708bb11 100644 --- a/modules/bullet/generic_6dof_joint_bullet.h +++ b/modules/bullet/generic_6dof_joint_bullet.h @@ -45,12 +45,12 @@ class Generic6DOFJointBullet : public JointBullet { // First is linear second is angular Vector3 limits_lower[2]; Vector3 limits_upper[2]; - bool flags[3][PhysicsServer::G6DOF_JOINT_FLAG_MAX]; + bool flags[3][PhysicsServer3D::G6DOF_JOINT_FLAG_MAX]; public: Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; } Transform getFrameOffsetA() const; Transform getFrameOffsetB() const; @@ -63,11 +63,11 @@ public: void set_angular_lower_limit(const Vector3 &angularLower); void set_angular_upper_limit(const Vector3 &angularUpper); - void set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value); - real_t get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const; + void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value); + real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const; - void set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value); - bool get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const; + void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value); + bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const; void set_precision(int p_precision); int get_precision() const; diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp index f3e3a01a52..8e29845a36 100644 --- a/modules/bullet/godot_collision_configuration.cpp +++ b/modules/bullet/godot_collision_configuration.cpp @@ -42,7 +42,7 @@ GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : btDefaultCollisionConfiguration(constructionInfo) { - void *mem = NULL; + void *mem = nullptr; mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16); m_rayWorldCF = new (mem) GodotRayWorldAlgorithm::CreateFunc(world); @@ -98,7 +98,7 @@ btCollisionAlgorithmCreateFunc *GodotCollisionConfiguration::getClosestPointsAlg GodotSoftCollisionConfiguration::GodotSoftCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : btSoftBodyRigidBodyCollisionConfiguration(constructionInfo) { - void *mem = NULL; + void *mem = nullptr; mem = btAlignedAlloc(sizeof(GodotRayWorldAlgorithm::CreateFunc), 16); m_rayWorldCF = new (mem) GodotRayWorldAlgorithm::CreateFunc(world); diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index 20467e3ef3..ad20a7e451 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -107,12 +107,12 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(convexResult.m_hitCollisionObject->getUserPointer()); - PhysicsDirectSpaceState::ShapeResult &result = m_results[count]; + PhysicsDirectSpaceState3D::ShapeResult &result = m_results[count]; result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID result.rid = gObj->get_self(); result.collider_id = gObj->get_instance_id(); - result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id); + result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id); ++count; return 1; // not used by bullet @@ -207,7 +207,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con if (cp.getDistance() <= 0) { - PhysicsDirectSpaceState::ShapeResult &result = m_results[m_count]; + PhysicsDirectSpaceState3D::ShapeResult &result = m_results[m_count]; // Penetrated CollisionObjectBullet *colObj; @@ -220,7 +220,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con } result.collider_id = colObj->get_instance_id(); - result.collider = result.collider_id.is_null() ? NULL : ObjectDB::get_instance(result.collider_id); + result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id); result.rid = colObj->get_self(); ++m_count; } diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index 4f634ed6f0..7e74a2b22e 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -31,7 +31,7 @@ #ifndef GODOT_RESULT_CALLBACKS_H #define GODOT_RESULT_CALLBACKS_H -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h> #include <btBulletDynamicsCommon.h> @@ -85,12 +85,12 @@ public: // store all colliding object struct GodotAllConvexResultCallback : public btCollisionWorld::ConvexResultCallback { public: - PhysicsDirectSpaceState::ShapeResult *m_results; + PhysicsDirectSpaceState3D::ShapeResult *m_results; int m_resultMax; const Set<RID> *m_exclude; int count; - GodotAllConvexResultCallback(PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) : + GodotAllConvexResultCallback(PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) : m_results(p_results), m_resultMax(p_resultMax), m_exclude(p_exclude), @@ -137,7 +137,7 @@ public: struct GodotAllContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - PhysicsDirectSpaceState::ShapeResult *m_results; + PhysicsDirectSpaceState3D::ShapeResult *m_results; int m_resultMax; const Set<RID> *m_exclude; int m_count; @@ -145,7 +145,7 @@ public: bool collide_with_bodies; bool collide_with_areas; - GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : + GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), m_results(p_results), m_resultMax(p_resultMax), @@ -188,7 +188,7 @@ public: struct GodotRestInfoContactResultCallback : public btCollisionWorld::ContactResultCallback { public: const btCollisionObject *m_self_object; - PhysicsDirectSpaceState::ShapeRestInfo *m_result; + PhysicsDirectSpaceState3D::ShapeRestInfo *m_result; const Set<RID> *m_exclude; bool m_collided; real_t m_min_distance; @@ -197,7 +197,7 @@ public: bool collide_with_bodies; bool collide_with_areas; - GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : + GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState3D::ShapeRestInfo *p_result, const Set<RID> *p_exclude, bool p_collide_with_bodies, bool p_collide_with_areas) : m_self_object(p_self_object), m_result(p_result), m_exclude(p_exclude), diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp index 970732688a..4bea9f87c0 100644 --- a/modules/bullet/hinge_joint_bullet.cpp +++ b/modules/bullet/hinge_joint_bullet.cpp @@ -93,58 +93,58 @@ real_t HingeJointBullet::get_hinge_angle() { return hingeConstraint->getHingeAngle(); } -void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) { +void HingeJointBullet::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::HINGE_JOINT_BIAS: - WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated."); + case PhysicsServer3D::HINGE_JOINT_BIAS: + WARN_DEPRECATED_MSG("The HingeJoint3D parameter \"bias\" is deprecated."); break; - case PhysicsServer::HINGE_JOINT_LIMIT_UPPER: + case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), p_value, hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor()); break; - case PhysicsServer::HINGE_JOINT_LIMIT_LOWER: + case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: hingeConstraint->setLimit(p_value, hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor()); break; - case PhysicsServer::HINGE_JOINT_LIMIT_BIAS: + case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), p_value, hingeConstraint->getLimitRelaxationFactor()); break; - case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS: + case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), p_value, hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor()); break; - case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: + case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), hingeConstraint->getUpperLimit(), hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), p_value); break; - case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: + case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: hingeConstraint->setMotorTargetVelocity(p_value); break; - case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: + case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: hingeConstraint->setMaxMotorImpulse(p_value); break; - case PhysicsServer::HINGE_JOINT_MAX: + case PhysicsServer3D::HINGE_JOINT_MAX: // Internal size value, nothing to do. break; } } -real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const { +real_t HingeJointBullet::get_param(PhysicsServer3D::HingeJointParam p_param) const { switch (p_param) { - case PhysicsServer::HINGE_JOINT_BIAS: - WARN_DEPRECATED_MSG("The HingeJoint parameter \"bias\" is deprecated."); + case PhysicsServer3D::HINGE_JOINT_BIAS: + WARN_DEPRECATED_MSG("The HingeJoint3D parameter \"bias\" is deprecated."); return 0; - case PhysicsServer::HINGE_JOINT_LIMIT_UPPER: + case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: return hingeConstraint->getUpperLimit(); - case PhysicsServer::HINGE_JOINT_LIMIT_LOWER: + case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: return hingeConstraint->getLowerLimit(); - case PhysicsServer::HINGE_JOINT_LIMIT_BIAS: + case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: return hingeConstraint->getLimitBiasFactor(); - case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS: + case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: return hingeConstraint->getLimitSoftness(); - case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: + case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: return hingeConstraint->getLimitRelaxationFactor(); - case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: + case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: return hingeConstraint->getMotorTargetVelocity(); - case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: + case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: return hingeConstraint->getMaxMotorImpulse(); - case PhysicsServer::HINGE_JOINT_MAX: + case PhysicsServer3D::HINGE_JOINT_MAX: // Internal size value, nothing to do. return 0; } @@ -152,25 +152,25 @@ real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const return 0; } -void HingeJointBullet::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) { +void HingeJointBullet::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) { switch (p_flag) { - case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: + case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: if (!p_value) { hingeConstraint->setLimit(-Math_PI, Math_PI); } break; - case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: + case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: hingeConstraint->enableMotor(p_value); break; - case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } } -bool HingeJointBullet::get_flag(PhysicsServer::HingeJointFlag p_flag) const { +bool HingeJointBullet::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const { switch (p_flag) { - case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: + case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: return true; - case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: + case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: return hingeConstraint->getEnableAngularMotor(); default: return false; diff --git a/modules/bullet/hinge_joint_bullet.h b/modules/bullet/hinge_joint_bullet.h index d1061fe52f..120c40e5c0 100644 --- a/modules/bullet/hinge_joint_bullet.h +++ b/modules/bullet/hinge_joint_bullet.h @@ -44,14 +44,14 @@ public: HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB); HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; } real_t get_hinge_angle(); - void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::HingeJointParam p_param) const; + void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::HingeJointParam p_param) const; - void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value); - bool get_flag(PhysicsServer::HingeJointFlag p_flag) const; + void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value); + bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const; }; #endif diff --git a/modules/bullet/joint_bullet.h b/modules/bullet/joint_bullet.h index c840eb8f14..9cb8aab276 100644 --- a/modules/bullet/joint_bullet.h +++ b/modules/bullet/joint_bullet.h @@ -32,7 +32,7 @@ #define JOINT_BULLET_H #include "constraint_bullet.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" /** @author AndreaCatania @@ -47,6 +47,6 @@ public: JointBullet(); virtual ~JointBullet(); - virtual PhysicsServer::JointType get_type() const = 0; + virtual PhysicsServer3D::JointType get_type() const = 0; }; #endif diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp index 8d109f1866..68b40d7405 100644 --- a/modules/bullet/pin_joint_bullet.cpp +++ b/modules/bullet/pin_joint_bullet.cpp @@ -62,27 +62,27 @@ PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a PinJointBullet::~PinJointBullet() {} -void PinJointBullet::set_param(PhysicsServer::PinJointParam p_param, real_t p_value) { +void PinJointBullet::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::PIN_JOINT_BIAS: + case PhysicsServer3D::PIN_JOINT_BIAS: p2pConstraint->m_setting.m_tau = p_value; break; - case PhysicsServer::PIN_JOINT_DAMPING: + case PhysicsServer3D::PIN_JOINT_DAMPING: p2pConstraint->m_setting.m_damping = p_value; break; - case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP: + case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: p2pConstraint->m_setting.m_impulseClamp = p_value; break; } } -real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const { +real_t PinJointBullet::get_param(PhysicsServer3D::PinJointParam p_param) const { switch (p_param) { - case PhysicsServer::PIN_JOINT_BIAS: + case PhysicsServer3D::PIN_JOINT_BIAS: return p2pConstraint->m_setting.m_tau; - case PhysicsServer::PIN_JOINT_DAMPING: + case PhysicsServer3D::PIN_JOINT_DAMPING: return p2pConstraint->m_setting.m_damping; - case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP: + case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: return p2pConstraint->m_setting.m_impulseClamp; } // Compiler doesn't seem to notice that all code paths are fulfilled... diff --git a/modules/bullet/pin_joint_bullet.h b/modules/bullet/pin_joint_bullet.h index d6e7a945b5..e7d05f34d4 100644 --- a/modules/bullet/pin_joint_bullet.h +++ b/modules/bullet/pin_joint_bullet.h @@ -46,10 +46,10 @@ public: PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b); ~PinJointBullet(); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_PIN; } - void set_param(PhysicsServer::PinJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::PinJointParam p_param) const; + void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::PinJointParam p_param) const; void setPivotInA(const Vector3 &p_pos); void setPivotInB(const Vector3 &p_pos); diff --git a/modules/bullet/register_types.cpp b/modules/bullet/register_types.cpp index 7819b67cad..009d0dff63 100644 --- a/modules/bullet/register_types.cpp +++ b/modules/bullet/register_types.cpp @@ -39,15 +39,15 @@ */ #ifndef _3D_DISABLED -PhysicsServer *_createBulletPhysicsCallback() { - return memnew(BulletPhysicsServer); +PhysicsServer3D *_createBulletPhysicsCallback() { + return memnew(BulletPhysicsServer3D); } #endif void register_bullet_types() { #ifndef _3D_DISABLED - PhysicsServerManager::register_server("Bullet", &_createBulletPhysicsCallback); - PhysicsServerManager::set_default_server("Bullet", 1); + PhysicsServer3DManager::register_server("Bullet", &_createBulletPhysicsCallback); + PhysicsServer3DManager::set_default_server("Bullet", 1); GLOBAL_DEF("physics/3d/active_soft_world", true); ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/active_soft_world", PropertyInfo(Variant::BOOL, "physics/3d/active_soft_world")); diff --git a/modules/bullet/rid_bullet.h b/modules/bullet/rid_bullet.h index b76641ca54..3551ca05f9 100644 --- a/modules/bullet/rid_bullet.h +++ b/modules/bullet/rid_bullet.h @@ -37,17 +37,17 @@ @author AndreaCatania */ -class BulletPhysicsServer; +class BulletPhysicsServer3D; class RIDBullet { RID self; - BulletPhysicsServer *physicsServer; + BulletPhysicsServer3D *physicsServer; public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } _FORCE_INLINE_ RID get_self() const { return self; } - _FORCE_INLINE_ void _set_physics_server(BulletPhysicsServer *p_physicsServer) { physicsServer = p_physicsServer; } - _FORCE_INLINE_ BulletPhysicsServer *get_physics_server() const { return physicsServer; } + _FORCE_INLINE_ void _set_physics_server(BulletPhysicsServer3D *p_physicsServer) { physicsServer = p_physicsServer; } + _FORCE_INLINE_ BulletPhysicsServer3D *get_physics_server() const { return physicsServer; } }; #endif diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 80f42c8441..fc4e1d57de 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -48,141 +48,141 @@ @author AndreaCatania */ -BulletPhysicsDirectBodyState *BulletPhysicsDirectBodyState::singleton = NULL; +BulletPhysicsDirectBodyState3D *BulletPhysicsDirectBodyState3D::singleton = nullptr; -Vector3 BulletPhysicsDirectBodyState::get_total_gravity() const { +Vector3 BulletPhysicsDirectBodyState3D::get_total_gravity() const { Vector3 gVec; B_TO_G(body->btBody->getGravity(), gVec); return gVec; } -float BulletPhysicsDirectBodyState::get_total_angular_damp() const { +float BulletPhysicsDirectBodyState3D::get_total_angular_damp() const { return body->btBody->getAngularDamping(); } -float BulletPhysicsDirectBodyState::get_total_linear_damp() const { +float BulletPhysicsDirectBodyState3D::get_total_linear_damp() const { return body->btBody->getLinearDamping(); } -Vector3 BulletPhysicsDirectBodyState::get_center_of_mass() const { +Vector3 BulletPhysicsDirectBodyState3D::get_center_of_mass() const { Vector3 gVec; B_TO_G(body->btBody->getCenterOfMassPosition(), gVec); return gVec; } -Basis BulletPhysicsDirectBodyState::get_principal_inertia_axes() const { +Basis BulletPhysicsDirectBodyState3D::get_principal_inertia_axes() const { return Basis(); } -float BulletPhysicsDirectBodyState::get_inverse_mass() const { +float BulletPhysicsDirectBodyState3D::get_inverse_mass() const { return body->btBody->getInvMass(); } -Vector3 BulletPhysicsDirectBodyState::get_inverse_inertia() const { +Vector3 BulletPhysicsDirectBodyState3D::get_inverse_inertia() const { Vector3 gVec; B_TO_G(body->btBody->getInvInertiaDiagLocal(), gVec); return gVec; } -Basis BulletPhysicsDirectBodyState::get_inverse_inertia_tensor() const { +Basis BulletPhysicsDirectBodyState3D::get_inverse_inertia_tensor() const { Basis gInertia; B_TO_G(body->btBody->getInvInertiaTensorWorld(), gInertia); return gInertia; } -void BulletPhysicsDirectBodyState::set_linear_velocity(const Vector3 &p_velocity) { +void BulletPhysicsDirectBodyState3D::set_linear_velocity(const Vector3 &p_velocity) { body->set_linear_velocity(p_velocity); } -Vector3 BulletPhysicsDirectBodyState::get_linear_velocity() const { +Vector3 BulletPhysicsDirectBodyState3D::get_linear_velocity() const { return body->get_linear_velocity(); } -void BulletPhysicsDirectBodyState::set_angular_velocity(const Vector3 &p_velocity) { +void BulletPhysicsDirectBodyState3D::set_angular_velocity(const Vector3 &p_velocity) { body->set_angular_velocity(p_velocity); } -Vector3 BulletPhysicsDirectBodyState::get_angular_velocity() const { +Vector3 BulletPhysicsDirectBodyState3D::get_angular_velocity() const { return body->get_angular_velocity(); } -void BulletPhysicsDirectBodyState::set_transform(const Transform &p_transform) { +void BulletPhysicsDirectBodyState3D::set_transform(const Transform &p_transform) { body->set_transform(p_transform); } -Transform BulletPhysicsDirectBodyState::get_transform() const { +Transform BulletPhysicsDirectBodyState3D::get_transform() const { return body->get_transform(); } -void BulletPhysicsDirectBodyState::add_central_force(const Vector3 &p_force) { +void BulletPhysicsDirectBodyState3D::add_central_force(const Vector3 &p_force) { body->apply_central_force(p_force); } -void BulletPhysicsDirectBodyState::add_force(const Vector3 &p_force, const Vector3 &p_pos) { +void BulletPhysicsDirectBodyState3D::add_force(const Vector3 &p_force, const Vector3 &p_pos) { body->apply_force(p_force, p_pos); } -void BulletPhysicsDirectBodyState::add_torque(const Vector3 &p_torque) { +void BulletPhysicsDirectBodyState3D::add_torque(const Vector3 &p_torque) { body->apply_torque(p_torque); } -void BulletPhysicsDirectBodyState::apply_central_impulse(const Vector3 &p_impulse) { +void BulletPhysicsDirectBodyState3D::apply_central_impulse(const Vector3 &p_impulse) { body->apply_central_impulse(p_impulse); } -void BulletPhysicsDirectBodyState::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { +void BulletPhysicsDirectBodyState3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { body->apply_impulse(p_pos, p_impulse); } -void BulletPhysicsDirectBodyState::apply_torque_impulse(const Vector3 &p_impulse) { +void BulletPhysicsDirectBodyState3D::apply_torque_impulse(const Vector3 &p_impulse) { body->apply_torque_impulse(p_impulse); } -void BulletPhysicsDirectBodyState::set_sleep_state(bool p_enable) { +void BulletPhysicsDirectBodyState3D::set_sleep_state(bool p_enable) { body->set_activation_state(p_enable); } -bool BulletPhysicsDirectBodyState::is_sleeping() const { +bool BulletPhysicsDirectBodyState3D::is_sleeping() const { return !body->is_active(); } -int BulletPhysicsDirectBodyState::get_contact_count() const { +int BulletPhysicsDirectBodyState3D::get_contact_count() const { return body->collisionsCount; } -Vector3 BulletPhysicsDirectBodyState::get_contact_local_position(int p_contact_idx) const { +Vector3 BulletPhysicsDirectBodyState3D::get_contact_local_position(int p_contact_idx) const { return body->collisions[p_contact_idx].hitLocalLocation; } -Vector3 BulletPhysicsDirectBodyState::get_contact_local_normal(int p_contact_idx) const { +Vector3 BulletPhysicsDirectBodyState3D::get_contact_local_normal(int p_contact_idx) const { return body->collisions[p_contact_idx].hitNormal; } -float BulletPhysicsDirectBodyState::get_contact_impulse(int p_contact_idx) const { +float BulletPhysicsDirectBodyState3D::get_contact_impulse(int p_contact_idx) const { return body->collisions[p_contact_idx].appliedImpulse; } -int BulletPhysicsDirectBodyState::get_contact_local_shape(int p_contact_idx) const { +int BulletPhysicsDirectBodyState3D::get_contact_local_shape(int p_contact_idx) const { return body->collisions[p_contact_idx].local_shape; } -RID BulletPhysicsDirectBodyState::get_contact_collider(int p_contact_idx) const { +RID BulletPhysicsDirectBodyState3D::get_contact_collider(int p_contact_idx) const { return body->collisions[p_contact_idx].otherObject->get_self(); } -Vector3 BulletPhysicsDirectBodyState::get_contact_collider_position(int p_contact_idx) const { +Vector3 BulletPhysicsDirectBodyState3D::get_contact_collider_position(int p_contact_idx) const { return body->collisions[p_contact_idx].hitWorldLocation; } -ObjectID BulletPhysicsDirectBodyState::get_contact_collider_id(int p_contact_idx) const { +ObjectID BulletPhysicsDirectBodyState3D::get_contact_collider_id(int p_contact_idx) const { return body->collisions[p_contact_idx].otherObject->get_instance_id(); } -int BulletPhysicsDirectBodyState::get_contact_collider_shape(int p_contact_idx) const { +int BulletPhysicsDirectBodyState3D::get_contact_collider_shape(int p_contact_idx) const { return body->collisions[p_contact_idx].other_object_shape; } -Vector3 BulletPhysicsDirectBodyState::get_contact_collider_velocity_at_position(int p_contact_idx) const { +Vector3 BulletPhysicsDirectBodyState3D::get_contact_collider_velocity_at_position(int p_contact_idx) const { RigidBodyBullet::CollisionData &colDat = body->collisions.write[p_contact_idx]; btVector3 hitLocation; @@ -194,7 +194,7 @@ Vector3 BulletPhysicsDirectBodyState::get_contact_collider_velocity_at_position( return velocityAtPoint; } -PhysicsDirectSpaceState *BulletPhysicsDirectBodyState::get_space_state() { +PhysicsDirectSpaceState3D *BulletPhysicsDirectBodyState3D::get_space_state() { return body->get_space()->get_direct_state(); } @@ -231,17 +231,17 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { shapes.write[i].transform = shape_wrapper->transform; shapes.write[i].transform.getOrigin() *= owner_scale; switch (shape_wrapper->shape->get_type()) { - case PhysicsServer::SHAPE_SPHERE: - case PhysicsServer::SHAPE_BOX: - case PhysicsServer::SHAPE_CAPSULE: - case PhysicsServer::SHAPE_CYLINDER: - case PhysicsServer::SHAPE_CONVEX_POLYGON: - case PhysicsServer::SHAPE_RAY: { + case PhysicsServer3D::SHAPE_SPHERE: + case PhysicsServer3D::SHAPE_BOX: + case PhysicsServer3D::SHAPE_CAPSULE: + case PhysicsServer3D::SHAPE_CYLINDER: + case PhysicsServer3D::SHAPE_CONVEX_POLYGON: + case PhysicsServer3D::SHAPE_RAY: { shapes.write[i].shape = static_cast<btConvexShape *>(shape_wrapper->shape->create_bt_shape(owner_scale * shape_wrapper->scale, safe_margin)); } break; default: WARN_PRINT("This shape is not supported for kinematic collision."); - shapes.write[i].shape = NULL; + shapes.write[i].shape = nullptr; } } } @@ -257,7 +257,7 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) { RigidBodyBullet::RigidBodyBullet() : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY), - kinematic_utilities(NULL), + kinematic_utilities(nullptr), locked_axis(0), mass(1), gravity_scale(1), @@ -274,24 +274,24 @@ RigidBodyBullet::RigidBodyBullet() : countGravityPointSpaces(0), isScratchedSpaceOverrideModificator(false), previousActiveState(true), - force_integration_callback(NULL) { + force_integration_callback(nullptr) { godotMotionState = bulletnew(GodotMotionState(this)); // Initial properties const btVector3 localInertia(0, 0, 0); - btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, NULL, localInertia); + btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, nullptr, localInertia); btBody = bulletnew(btRigidBody(cInfo)); reload_shapes(); setupBulletCollisionObject(btBody); - set_mode(PhysicsServer::BODY_MODE_RIGID); + set_mode(PhysicsServer3D::BODY_MODE_RIGID); reload_axis_lock(); areasWhereIam.resize(maxAreasWhereIam); for (int i = areasWhereIam.size() - 1; 0 <= i; --i) { - areasWhereIam.write[i] = NULL; + areasWhereIam.write[i] = nullptr; } btBody->setSleepingThresholds(0.2, 0.2); @@ -315,7 +315,7 @@ void RigidBodyBullet::init_kinematic_utilities() { void RigidBodyBullet::destroy_kinematic_utilities() { if (kinematic_utilities) { memdelete(kinematic_utilities); - kinematic_utilities = NULL; + kinematic_utilities = nullptr; } } @@ -359,7 +359,7 @@ void RigidBodyBullet::dispatch_callbacks() { if (omit_forces_integration) btBody->clearForces(); - BulletPhysicsDirectBodyState *bodyDirect = BulletPhysicsDirectBodyState::get_singleton(this); + BulletPhysicsDirectBodyState3D *bodyDirect = BulletPhysicsDirectBodyState3D::get_singleton(this); Variant variantBodyDirect = bodyDirect; @@ -392,7 +392,7 @@ void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const String if (force_integration_callback) { memdelete(force_integration_callback); - force_integration_callback = NULL; + force_integration_callback = nullptr; } if (p_id.is_valid()) { @@ -487,29 +487,29 @@ void RigidBodyBullet::set_omit_forces_integration(bool p_omit) { omit_forces_integration = p_omit; } -void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) { +void RigidBodyBullet::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::BODY_PARAM_BOUNCE: + case PhysicsServer3D::BODY_PARAM_BOUNCE: btBody->setRestitution(p_value); break; - case PhysicsServer::BODY_PARAM_FRICTION: + case PhysicsServer3D::BODY_PARAM_FRICTION: btBody->setFriction(p_value); break; - case PhysicsServer::BODY_PARAM_MASS: { + case PhysicsServer3D::BODY_PARAM_MASS: { ERR_FAIL_COND(p_value < 0); mass = p_value; _internal_set_mass(p_value); break; } - case PhysicsServer::BODY_PARAM_LINEAR_DAMP: + case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: linearDamp = p_value; btBody->setDamping(linearDamp, angularDamp); break; - case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: angularDamp = p_value; btBody->setDamping(linearDamp, angularDamp); break; - case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: + case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: gravity_scale = p_value; /// The Bullet gravity will be is set by reload_space_override_modificator scratch_space_override_modificator(); @@ -519,21 +519,21 @@ void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_v } } -real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const { +real_t RigidBodyBullet::get_param(PhysicsServer3D::BodyParameter p_param) const { switch (p_param) { - case PhysicsServer::BODY_PARAM_BOUNCE: + case PhysicsServer3D::BODY_PARAM_BOUNCE: return btBody->getRestitution(); - case PhysicsServer::BODY_PARAM_FRICTION: + case PhysicsServer3D::BODY_PARAM_FRICTION: return btBody->getFriction(); - case PhysicsServer::BODY_PARAM_MASS: { + case PhysicsServer3D::BODY_PARAM_MASS: { const btScalar invMass = btBody->getInvMass(); return 0 == invMass ? 0 : 1 / invMass; } - case PhysicsServer::BODY_PARAM_LINEAR_DAMP: + case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: return linearDamp; - case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: return angularDamp; - case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: + case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: return gravity_scale; default: WARN_PRINT("Parameter " + itos(p_param) + " not supported by bullet"); @@ -541,31 +541,31 @@ real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const { } } -void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) { +void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) { // This is necessary to block force_integration untile next move can_integrate_forces = false; destroy_kinematic_utilities(); // The mode change is relevant to its mass switch (p_mode) { - case PhysicsServer::BODY_MODE_KINEMATIC: - mode = PhysicsServer::BODY_MODE_KINEMATIC; + case PhysicsServer3D::BODY_MODE_KINEMATIC: + mode = PhysicsServer3D::BODY_MODE_KINEMATIC; reload_axis_lock(); _internal_set_mass(0); init_kinematic_utilities(); break; - case PhysicsServer::BODY_MODE_STATIC: - mode = PhysicsServer::BODY_MODE_STATIC; + case PhysicsServer3D::BODY_MODE_STATIC: + mode = PhysicsServer3D::BODY_MODE_STATIC; reload_axis_lock(); _internal_set_mass(0); break; - case PhysicsServer::BODY_MODE_RIGID: - mode = PhysicsServer::BODY_MODE_RIGID; + case PhysicsServer3D::BODY_MODE_RIGID: + mode = PhysicsServer3D::BODY_MODE_RIGID; reload_axis_lock(); _internal_set_mass(0 == mass ? 1 : mass); scratch_space_override_modificator(); break; - case PhysicsServer::BODY_MODE_CHARACTER: - mode = PhysicsServer::BODY_MODE_CHARACTER; + case PhysicsServer3D::BODY_MODE_CHARACTER: + mode = PhysicsServer3D::BODY_MODE_CHARACTER; reload_axis_lock(); _internal_set_mass(0 == mass ? 1 : mass); scratch_space_override_modificator(); @@ -575,26 +575,26 @@ void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) { btBody->setAngularVelocity(btVector3(0, 0, 0)); btBody->setLinearVelocity(btVector3(0, 0, 0)); } -PhysicsServer::BodyMode RigidBodyBullet::get_mode() const { +PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const { return mode; } -void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) { +void RigidBodyBullet::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) { switch (p_state) { - case PhysicsServer::BODY_STATE_TRANSFORM: + case PhysicsServer3D::BODY_STATE_TRANSFORM: set_transform(p_variant); break; - case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: set_linear_velocity(p_variant); break; - case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: set_angular_velocity(p_variant); break; - case PhysicsServer::BODY_STATE_SLEEPING: + case PhysicsServer3D::BODY_STATE_SLEEPING: set_activation_state(!bool(p_variant)); break; - case PhysicsServer::BODY_STATE_CAN_SLEEP: + case PhysicsServer3D::BODY_STATE_CAN_SLEEP: can_sleep = bool(p_variant); if (!can_sleep) { // Can't sleep @@ -606,17 +606,17 @@ void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant } } -Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const { +Variant RigidBodyBullet::get_state(PhysicsServer3D::BodyState p_state) const { switch (p_state) { - case PhysicsServer::BODY_STATE_TRANSFORM: + case PhysicsServer3D::BODY_STATE_TRANSFORM: return get_transform(); - case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: return get_linear_velocity(); - case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: return get_angular_velocity(); - case PhysicsServer::BODY_STATE_SLEEPING: + case PhysicsServer3D::BODY_STATE_SLEEPING: return !is_active(); - case PhysicsServer::BODY_STATE_CAN_SLEEP: + case PhysicsServer3D::BODY_STATE_CAN_SLEEP: return can_sleep; default: WARN_PRINT("This state " + itos(p_state) + " is not supported by Bullet"); @@ -714,7 +714,7 @@ Vector3 RigidBodyBullet::get_applied_torque() const { return gTotTorq; } -void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) { +void RigidBodyBullet::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) { if (lock) { locked_axis |= p_axis; } else { @@ -724,18 +724,18 @@ void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) { reload_axis_lock(); } -bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const { +bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const { return locked_axis & p_axis; } void RigidBodyBullet::reload_axis_lock() { - btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z)))); - if (PhysicsServer::BODY_MODE_CHARACTER == mode) { + btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)))); + if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) { /// When character angular is always locked btBody->setAngularFactor(btVector3(0., 0., 0.)); } else { - btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z)))); + btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z)))); } } @@ -794,7 +794,7 @@ Vector3 RigidBodyBullet::get_angular_velocity() const { } void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) { - if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) { if (space && space->get_delta_time() != 0) btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time()); // The kinematic use MotionState class @@ -847,7 +847,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) { } for (int i = 0; i < areaWhereIamCount; ++i) { - if (NULL == areasWhereIam[i]) { + if (nullptr == areasWhereIam[i]) { // This area has the highest priority areasWhereIam.write[i] = p_area; break; @@ -862,7 +862,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) { } } } - if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { + if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { scratch_space_override_modificator(); } @@ -894,8 +894,8 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { } --areaWhereIamCount; - areasWhereIam.write[areaWhereIamCount] = NULL; // Even if this is not required, I clear the last element to be safe - if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { + areasWhereIam.write[areaWhereIamCount] = nullptr; // Even if this is not required, I clear the last element to be safe + if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { scratch_space_override_modificator(); } } @@ -904,7 +904,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { void RigidBodyBullet::reload_space_override_modificator() { // Make sure that kinematic bodies have their total gravity calculated - if (!is_active() && PhysicsServer::BODY_MODE_KINEMATIC != mode) + if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) return; Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude()); @@ -920,7 +920,7 @@ void RigidBodyBullet::reload_space_override_modificator() { currentArea = areasWhereIam[i]; - if (!currentArea || PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) { + if (!currentArea || PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) { continue; } @@ -954,11 +954,11 @@ void RigidBodyBullet::reload_space_override_modificator() { } switch (currentArea->get_spOv_mode()) { - case PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED: /// This area does not affect gravity/damp. These are generally areas /// that exist only to detect collisions, and objects entering or exiting them. break; - case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE: /// This area adds its gravity/damp values to whatever has been /// calculated so far. This way, many overlapping areas can combine /// their physics to make interesting @@ -967,7 +967,7 @@ void RigidBodyBullet::reload_space_override_modificator() { newAngularDamp += currentArea->get_spOv_angularDamp(); ++countCombined; break; - case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: /// This area adds its gravity/damp values to whatever has been calculated /// so far. Then stops taking into account the rest of the areas, even the /// default one. @@ -976,7 +976,7 @@ void RigidBodyBullet::reload_space_override_modificator() { newAngularDamp += currentArea->get_spOv_angularDamp(); ++countCombined; goto endAreasCycle; - case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: /// This area replaces any gravity/damp, even the default one, and /// stops taking into account the rest of the areas. newGravity = support_gravity; @@ -984,7 +984,7 @@ void RigidBodyBullet::reload_space_override_modificator() { newAngularDamp = currentArea->get_spOv_angularDamp(); countCombined = 1; goto endAreasCycle; - case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: /// This area replaces any gravity/damp calculated so far, but keeps /// calculating the rest of the areas, down to the default one. newGravity = support_gravity; @@ -1032,14 +1032,14 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { const bool isDynamic = p_mass != 0.f; if (isDynamic) { - if (PhysicsServer::BODY_MODE_RIGID != mode && PhysicsServer::BODY_MODE_CHARACTER != mode) + if (PhysicsServer3D::BODY_MODE_RIGID != mode && PhysicsServer3D::BODY_MODE_CHARACTER != mode) return; m_isStatic = false; if (mainShape) mainShape->calculateLocalInertia(p_mass, localInertia); - if (PhysicsServer::BODY_MODE_RIGID == mode) { + if (PhysicsServer3D::BODY_MODE_RIGID == mode) { btBody->setCollisionFlags(clearedCurrentFlags); // Just set the flags without Kin and Static } else { @@ -1054,11 +1054,11 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { } } else { - if (PhysicsServer::BODY_MODE_STATIC != mode && PhysicsServer::BODY_MODE_KINEMATIC != mode) + if (PhysicsServer3D::BODY_MODE_STATIC != mode && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) return; m_isStatic = true; - if (PhysicsServer::BODY_MODE_STATIC == mode) { + if (PhysicsServer3D::BODY_MODE_STATIC == mode) { btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_STATIC_OBJECT); } else { diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index ca599f7a77..95491b1e62 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -45,37 +45,37 @@ class AreaBullet; class SpaceBullet; class btRigidBody; class GodotMotionState; -class BulletPhysicsDirectBodyState; +class BulletPhysicsDirectBodyState3D; /// This class could be used in multi thread with few changes but currently /// is set to be only in one single thread. /// /// In the system there is only one object at a time that manage all bodies and is -/// created by BulletPhysicsServer and is held by the "singleton" variable of this class +/// created by BulletPhysicsServer3D and is held by the "singleton" variable of this class /// Each time something require it, the body must be set again. -class BulletPhysicsDirectBodyState : public PhysicsDirectBodyState { - GDCLASS(BulletPhysicsDirectBodyState, PhysicsDirectBodyState); +class BulletPhysicsDirectBodyState3D : public PhysicsDirectBodyState3D { + GDCLASS(BulletPhysicsDirectBodyState3D, PhysicsDirectBodyState3D); - static BulletPhysicsDirectBodyState *singleton; + static BulletPhysicsDirectBodyState3D *singleton; public: /// This class avoid the creation of more object of this class static void initSingleton() { if (!singleton) { - singleton = memnew(BulletPhysicsDirectBodyState); + singleton = memnew(BulletPhysicsDirectBodyState3D); } } static void destroySingleton() { memdelete(singleton); - singleton = NULL; + singleton = nullptr; } static void singleton_setDeltaTime(real_t p_deltaTime) { singleton->deltaTime = p_deltaTime; } - static BulletPhysicsDirectBodyState *get_singleton(RigidBodyBullet *p_body) { + static BulletPhysicsDirectBodyState3D *get_singleton(RigidBodyBullet *p_body) { singleton->body = p_body; return singleton; } @@ -85,7 +85,7 @@ public: real_t deltaTime; private: - BulletPhysicsDirectBodyState() {} + BulletPhysicsDirectBodyState3D() {} public: virtual Vector3 get_total_gravity() const; @@ -138,7 +138,7 @@ public: // Skip the execution of this function } - virtual PhysicsDirectSpaceState *get_space_state(); + virtual PhysicsDirectSpaceState3D *get_space_state(); }; class RigidBodyBullet : public RigidCollisionObjectBullet { @@ -166,7 +166,7 @@ public: btTransform transform; KinematicShape() : - shape(NULL) {} + shape(nullptr) {} bool is_active() const { return shape; } }; @@ -187,12 +187,12 @@ public: }; private: - friend class BulletPhysicsDirectBodyState; + friend class BulletPhysicsDirectBodyState3D; // This is required only for Kinematic movement KinematicUtilities *kinematic_utilities; - PhysicsServer::BodyMode mode; + PhysicsServer3D::BodyMode mode; GodotMotionState *godotMotionState; btRigidBody *btBody; uint16_t locked_axis; @@ -278,14 +278,14 @@ public: void set_omit_forces_integration(bool p_omit); _FORCE_INLINE_ bool get_omit_forces_integration() const { return omit_forces_integration; } - void set_param(PhysicsServer::BodyParameter p_param, real_t); - real_t get_param(PhysicsServer::BodyParameter p_param) const; + void set_param(PhysicsServer3D::BodyParameter p_param, real_t); + real_t get_param(PhysicsServer3D::BodyParameter p_param) const; - void set_mode(PhysicsServer::BodyMode p_mode); - PhysicsServer::BodyMode get_mode() const; + void set_mode(PhysicsServer3D::BodyMode p_mode); + PhysicsServer3D::BodyMode get_mode() const; - void set_state(PhysicsServer::BodyState p_state, const Variant &p_variant); - Variant get_state(PhysicsServer::BodyState p_state) const; + void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant); + Variant get_state(PhysicsServer3D::BodyState p_state) const; void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse); void apply_central_impulse(const Vector3 &p_impulse); @@ -300,8 +300,8 @@ public: void set_applied_torque(const Vector3 &p_torque); Vector3 get_applied_torque() const; - void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock); - bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const; + void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock); + bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const; void reload_axis_lock(); /// Doc: diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index 6780f89d9e..8ac26a0fdb 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -138,7 +138,7 @@ btScaledBvhTriangleMeshShape *ShapeBullet::create_shape_concave(btBvhTriangleMes if (p_mesh_shape) { return bulletnew(btScaledBvhTriangleMeshShape(p_mesh_shape, p_local_scaling)); } else { - return NULL; + return nullptr; } } @@ -150,7 +150,7 @@ btHeightfieldTerrainShape *ShapeBullet::create_shape_height_field(Vector<real_t> btHeightfieldTerrainShape *heightfield = bulletnew(btHeightfieldTerrainShape(p_width, p_depth, heightsPtr, ignoredHeightScale, p_min_height, p_max_height, YAxis, PHY_FLOAT, flipQuadEdges)); - // The shape can be created without params when you do PhysicsServer.shape_create(PhysicsServer.SHAPE_HEIGHTMAP) + // The shape can be created without params when you do PhysicsServer3D.shape_create(PhysicsServer3D.SHAPE_HEIGHTMAP) if (heightsPtr) heightfield->buildAccelerator(16); @@ -176,8 +176,8 @@ Variant PlaneShapeBullet::get_data() const { return plane; } -PhysicsServer::ShapeType PlaneShapeBullet::get_type() const { - return PhysicsServer::SHAPE_PLANE; +PhysicsServer3D::ShapeType PlaneShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_PLANE; } void PlaneShapeBullet::setup(const Plane &p_plane) { @@ -204,8 +204,8 @@ Variant SphereShapeBullet::get_data() const { return radius; } -PhysicsServer::ShapeType SphereShapeBullet::get_type() const { - return PhysicsServer::SHAPE_SPHERE; +PhysicsServer3D::ShapeType SphereShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_SPHERE; } void SphereShapeBullet::setup(real_t p_radius) { @@ -231,8 +231,8 @@ Variant BoxShapeBullet::get_data() const { return g_half_extents; } -PhysicsServer::ShapeType BoxShapeBullet::get_type() const { - return PhysicsServer::SHAPE_BOX; +PhysicsServer3D::ShapeType BoxShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_BOX; } void BoxShapeBullet::setup(const Vector3 &p_half_extents) { @@ -263,8 +263,8 @@ Variant CapsuleShapeBullet::get_data() const { return d; } -PhysicsServer::ShapeType CapsuleShapeBullet::get_type() const { - return PhysicsServer::SHAPE_CAPSULE; +PhysicsServer3D::ShapeType CapsuleShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_CAPSULE; } void CapsuleShapeBullet::setup(real_t p_height, real_t p_radius) { @@ -296,8 +296,8 @@ Variant CylinderShapeBullet::get_data() const { return d; } -PhysicsServer::ShapeType CylinderShapeBullet::get_type() const { - return PhysicsServer::SHAPE_CYLINDER; +PhysicsServer3D::ShapeType CylinderShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_CYLINDER; } void CylinderShapeBullet::setup(real_t p_height, real_t p_radius) { @@ -334,8 +334,8 @@ Variant ConvexPolygonShapeBullet::get_data() const { return out_vertices; } -PhysicsServer::ShapeType ConvexPolygonShapeBullet::get_type() const { - return PhysicsServer::SHAPE_CONVEX_POLYGON; +PhysicsServer3D::ShapeType ConvexPolygonShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_CONVEX_POLYGON; } void ConvexPolygonShapeBullet::setup(const Vector<Vector3> &p_vertices) { @@ -362,7 +362,7 @@ btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape(const btVector3 &p_i ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() : ShapeBullet(), - meshShape(NULL) {} + meshShape(nullptr) {} ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() { if (meshShape) { @@ -381,8 +381,8 @@ Variant ConcavePolygonShapeBullet::get_data() const { return faces; } -PhysicsServer::ShapeType ConcavePolygonShapeBullet::get_type() const { - return PhysicsServer::SHAPE_CONCAVE_POLYGON; +PhysicsServer3D::ShapeType ConcavePolygonShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; } void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) { @@ -425,7 +425,7 @@ void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) { btGenerateInternalEdgeInfo(meshShape, triangleInfoMap); } } else { - meshShape = NULL; + meshShape = nullptr; ERR_PRINT("The faces count are 0, the mesh shape cannot be created"); } notifyShapeChanged(); @@ -434,7 +434,7 @@ void ConcavePolygonShapeBullet::setup(Vector<Vector3> p_faces) { btCollisionShape *ConcavePolygonShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) { btCollisionShape *cs = ShapeBullet::create_shape_concave(meshShape); if (!cs) - // This is necessary since if 0 faces the creation of concave return NULL + // This is necessary since if 0 faces the creation of concave return null cs = ShapeBullet::create_shape_empty(); cs->setLocalScaling(p_implicit_scale); prepare(cs); @@ -536,8 +536,8 @@ Variant HeightMapShapeBullet::get_data() const { ERR_FAIL_V(Variant()); } -PhysicsServer::ShapeType HeightMapShapeBullet::get_type() const { - return PhysicsServer::SHAPE_HEIGHTMAP; +PhysicsServer3D::ShapeType HeightMapShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_HEIGHTMAP; } void HeightMapShapeBullet::setup(Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) { @@ -580,8 +580,8 @@ Variant RayShapeBullet::get_data() const { return d; } -PhysicsServer::ShapeType RayShapeBullet::get_type() const { - return PhysicsServer::SHAPE_RAY; +PhysicsServer3D::ShapeType RayShapeBullet::get_type() const { + return PhysicsServer3D::SHAPE_RAY; } void RayShapeBullet::setup(real_t p_length, bool p_slips_on_slope) { diff --git a/modules/bullet/shape_bullet.h b/modules/bullet/shape_bullet.h index c8b5ca102a..0dbc616fe5 100644 --- a/modules/bullet/shape_bullet.h +++ b/modules/bullet/shape_bullet.h @@ -34,7 +34,7 @@ #include "core/math/geometry.h" #include "core/variant.h" #include "rid_bullet.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include <LinearMath/btAlignedObjectArray.h> #include <LinearMath/btScalar.h> @@ -78,7 +78,7 @@ public: virtual void set_data(const Variant &p_data) = 0; virtual Variant get_data() const = 0; - virtual PhysicsServer::ShapeType get_type() const = 0; + virtual PhysicsServer3D::ShapeType get_type() const = 0; public: static class btEmptyShape *create_shape_empty(); @@ -103,7 +103,7 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -120,7 +120,7 @@ public: _FORCE_INLINE_ real_t get_radius() { return radius; } virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -137,7 +137,7 @@ public: _FORCE_INLINE_ const btVector3 &get_half_extents() { return half_extents; } virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -156,7 +156,7 @@ public: _FORCE_INLINE_ real_t get_radius() { return radius; } virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -175,7 +175,7 @@ public: _FORCE_INLINE_ real_t get_radius() { return radius; } virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_margin = 0); private: @@ -192,7 +192,7 @@ public: virtual void set_data(const Variant &p_data); void get_vertices(Vector<Vector3> &out_vertices); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -210,7 +210,7 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -230,7 +230,7 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: @@ -247,7 +247,7 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - virtual PhysicsServer::ShapeType get_type() const; + virtual PhysicsServer3D::ShapeType get_type() const; virtual btCollisionShape *create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge = 0); private: diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index d9ebb9d580..f193daef39 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -342,58 +342,58 @@ real_t SliderJointBullet::getLinearPos() { ; } -void SliderJointBullet::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) { +void SliderJointBullet::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: setUpperLinLimit(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: setLowerLinLimit(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: setSoftnessLimLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: setRestitutionLimLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: setDampingLimLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: setSoftnessDirLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: setRestitutionDirLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: setDampingDirLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: setDampingOrthoLin(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: setUpperAngLimit(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: setLowerAngLimit(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: setSoftnessLimAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: setRestitutionLimAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: setDampingLimAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: setSoftnessDirAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: setRestitutionDirAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: setDampingDirAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: setDampingOrthoAng(p_value); break; - case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: setUpperLinLimit(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: setLowerLinLimit(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: setSoftnessLimLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: setRestitutionLimLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: setDampingLimLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: setSoftnessDirLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: setRestitutionDirLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: setDampingDirLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: setDampingOrthoLin(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: setUpperAngLimit(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: setLowerAngLimit(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: setSoftnessLimAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: setRestitutionLimAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: setDampingLimAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: setSoftnessDirAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: setRestitutionDirAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: setDampingDirAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: setSoftnessOrthoAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: setRestitutionOrthoAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: setDampingOrthoAng(p_value); break; + case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning } } -real_t SliderJointBullet::get_param(PhysicsServer::SliderJointParam p_param) const { +real_t SliderJointBullet::get_param(PhysicsServer3D::SliderJointParam p_param) const { switch (p_param) { - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return getUpperLinLimit(); - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return getLowerLinLimit(); - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return getSoftnessLimLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return getRestitutionLimLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return getDampingLimLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return getSoftnessDirLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return getRestitutionDirLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return getDampingDirLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoLin(); - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return getDampingOrthoLin(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return getUpperAngLimit(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return getLowerAngLimit(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return getSoftnessLimAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return getRestitutionLimAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return getDampingLimAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return getSoftnessDirAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return getRestitutionDirAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return getDampingDirAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoAng(); - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return getDampingOrthoAng(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return getUpperLinLimit(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return getLowerLinLimit(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return getSoftnessLimLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return getRestitutionLimLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return getDampingLimLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return getSoftnessDirLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return getRestitutionDirLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return getDampingDirLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoLin(); + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return getDampingOrthoLin(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return getUpperAngLimit(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return getLowerAngLimit(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return getSoftnessLimAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return getRestitutionLimAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return getDampingLimAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return getSoftnessDirAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return getRestitutionDirAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return getDampingDirAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return getSoftnessOrthoAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return getRestitutionOrthoAng(); + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return getDampingOrthoAng(); default: return 0; } diff --git a/modules/bullet/slider_joint_bullet.h b/modules/bullet/slider_joint_bullet.h index d98a1b8c95..6410b952ed 100644 --- a/modules/bullet/slider_joint_bullet.h +++ b/modules/bullet/slider_joint_bullet.h @@ -46,7 +46,7 @@ public: /// Reference frame is A SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; } const RigidBodyBullet *getRigidBodyA() const; const RigidBodyBullet *getRigidBodyB() const; @@ -115,7 +115,7 @@ public: real_t getMaxAngMotorForce(); real_t getLinearPos(); - void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::SliderJointParam p_param) const; + void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::SliderJointParam p_param) const; }; #endif diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp index fb36a0d3e1..236bdc7c8a 100644 --- a/modules/bullet/soft_body_bullet.cpp +++ b/modules/bullet/soft_body_bullet.cpp @@ -37,7 +37,7 @@ SoftBodyBullet::SoftBodyBullet() : CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY), - bt_soft_body(NULL), + bt_soft_body(nullptr), isScratched(false), simulation_precision(5), total_mass(1.), @@ -76,7 +76,7 @@ void SoftBodyBullet::on_enter_area(AreaBullet *p_area) {} void SoftBodyBullet::on_exit_area(AreaBullet *p_area) {} -void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_server_handler) { +void SoftBodyBullet::update_rendering_server(SoftBodyRenderingServerHandler *p_rendering_server_handler) { if (!bt_soft_body) return; @@ -96,8 +96,8 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_ const int vs_indices_size(vs_indices->size()); for (int x = 0; x < vs_indices_size; ++x) { - p_visual_server_handler->set_vertex((*vs_indices)[x], vertex_position); - p_visual_server_handler->set_normal((*vs_indices)[x], vertex_normal); + p_rendering_server_handler->set_vertex((*vs_indices)[x], vertex_position); + p_rendering_server_handler->set_normal((*vs_indices)[x], vertex_normal); } } @@ -112,7 +112,7 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_ B_TO_G(aabb_min, aabb.position); B_TO_G(size, aabb.size); - p_visual_server_handler->set_aabb(aabb); + p_rendering_server_handler->set_aabb(aabb); } void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) { @@ -129,8 +129,8 @@ void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) { } Array arrays = soft_mesh->surface_get_arrays(0); - ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & VS::ARRAY_FORMAT_INDEX)); - set_trimesh_body_shape(arrays[VS::ARRAY_INDEX], arrays[VS::ARRAY_VERTEX]); + ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & RS::ARRAY_FORMAT_INDEX)); + set_trimesh_body_shape(arrays[RS::ARRAY_INDEX], arrays[RS::ARRAY_VERTEX]); } void SoftBodyBullet::destroy_soft_body() { @@ -144,7 +144,7 @@ void SoftBodyBullet::destroy_soft_body() { } destroyBulletCollisionObject(); - bt_soft_body = NULL; + bt_soft_body = nullptr; } void SoftBodyBullet::set_soft_transform(const Transform &p_transform) { @@ -184,7 +184,7 @@ void SoftBodyBullet::get_node_offset(int p_node_index, Vector3 &r_offset) const return; Array arrays = soft_mesh->surface_get_arrays(0); - Vector<Vector3> vertices(arrays[VS::ARRAY_VERTEX]); + Vector<Vector3> vertices(arrays[RS::ARRAY_VERTEX]); if (0 <= p_node_index && vertices.size() > p_node_index) { r_offset = vertices[p_node_index]; @@ -230,7 +230,7 @@ void SoftBodyBullet::reset_all_node_positions() { return; Array arrays = soft_mesh->surface_get_arrays(0); - Vector<Vector3> vs_vertices(arrays[VS::ARRAY_VERTEX]); + Vector<Vector3> vs_vertices(arrays[RS::ARRAY_VERTEX]); const Vector3 *vs_vertices_read = vs_vertices.ptr(); for (int vertex_index = bt_soft_body->m_nodes.size() - 1; 0 <= vertex_index; --vertex_index) { @@ -404,7 +404,7 @@ void SoftBodyBullet::setup_soft_body() { // Soft body setup setupBulletCollisionObject(bt_soft_body); - bt_soft_body->m_worldInfo = NULL; // Remove fake world info + bt_soft_body->m_worldInfo = nullptr; // Remove fake world info bt_soft_body->getCollisionShape()->setMargin(0.01); bt_soft_body->setCollisionFlags(bt_soft_body->getCollisionFlags() & (~(btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT))); diff --git a/modules/bullet/soft_body_bullet.h b/modules/bullet/soft_body_bullet.h index 05d7e6ce3f..3c6871e0d6 100644 --- a/modules/bullet/soft_body_bullet.h +++ b/modules/bullet/soft_body_bullet.h @@ -43,7 +43,7 @@ #include "BulletSoftBody/btSoftBodyHelpers.h" #include "collision_object_bullet.h" #include "scene/resources/mesh.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #ifdef x11_None /// This is required to re add the macro None defined by x11 compiler @@ -100,7 +100,7 @@ public: _FORCE_INLINE_ btSoftBody *get_bt_soft_body() const { return bt_soft_body; } - void update_visual_server(class SoftBodyVisualServerHandler *p_visual_server_handler); + void update_rendering_server(class SoftBodyRenderingServerHandler *p_rendering_server_handler); void set_soft_mesh(const Ref<Mesh> &p_mesh); void destroy_soft_body(); diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index f6df97f11d..1659664ff9 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -39,7 +39,7 @@ #include "godot_collision_configuration.h" #include "godot_collision_dispatcher.h" #include "rigid_body_bullet.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include "soft_body_bullet.h" #include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h> @@ -59,7 +59,7 @@ */ BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) : - PhysicsDirectSpaceState(), + PhysicsDirectSpaceState3D(), space(p_space) {} int BulletPhysicsDirectSpaceState::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { @@ -108,7 +108,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V r_result.shape = btResult.m_shapeId; r_result.rid = gObj->get_self(); r_result.collider_id = gObj->get_instance_id(); - r_result.collider = r_result.collider_id.is_null() ? NULL : ObjectDB::get_instance(r_result.collider_id); + r_result.collider = r_result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(r_result.collider_id); } else { WARN_PRINT("The raycast performed has hit a collision object that is not part of Godot scene, please check it."); } @@ -309,7 +309,7 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ btPointCollector result; btGjkPairDetector gjk_pair_detector(&point_shape, convex_shape, space->gjk_simplex_solver, space->gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(input, result, 0); + gjk_pair_detector.getClosestPoints(input, result, nullptr); if (out_distance > result.m_distance) { out_distance = result.m_distance; @@ -332,14 +332,14 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ } SpaceBullet::SpaceBullet() : - broadphase(NULL), - collisionConfiguration(NULL), - dispatcher(NULL), - solver(NULL), - dynamicsWorld(NULL), - soft_body_world_info(NULL), - ghostPairCallback(NULL), - godotFilterCallback(NULL), + broadphase(nullptr), + collisionConfiguration(nullptr), + dispatcher(nullptr), + solver(nullptr), + dynamicsWorld(nullptr), + soft_body_world_info(nullptr), + ghostPairCallback(nullptr), + godotFilterCallback(nullptr), gravityDirection(0, -1, 0), gravityMagnitude(10), contactDebugCount(0), @@ -366,27 +366,27 @@ void SpaceBullet::step(real_t p_delta_time) { dynamicsWorld->stepSimulation(p_delta_time, 0, 0); } -void SpaceBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) { +void SpaceBullet::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) { assert(dynamicsWorld); switch (p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: + case PhysicsServer3D::AREA_PARAM_GRAVITY: gravityMagnitude = p_value; update_gravity(); break; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: + case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: gravityDirection = p_value; update_gravity(); break; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: + case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: break; // No damp - case PhysicsServer::AREA_PARAM_PRIORITY: + case PhysicsServer3D::AREA_PARAM_PRIORITY: // Priority is always 0, the lower break; - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: + case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: + case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: + case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: break; default: WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it."); @@ -394,22 +394,22 @@ void SpaceBullet::set_param(PhysicsServer::AreaParameter p_param, const Variant } } -Variant SpaceBullet::get_param(PhysicsServer::AreaParameter p_param) { +Variant SpaceBullet::get_param(PhysicsServer3D::AreaParameter p_param) { switch (p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: + case PhysicsServer3D::AREA_PARAM_GRAVITY: return gravityMagnitude; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: + case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: return gravityDirection; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: + case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: return 0; // No damp - case PhysicsServer::AREA_PARAM_PRIORITY: + case PhysicsServer3D::AREA_PARAM_PRIORITY: return 0; // Priority is always 0, the lower - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: + case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: return false; - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: + case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return 0; - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: + case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return 0; default: WARN_PRINT("This get parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it."); @@ -417,32 +417,32 @@ Variant SpaceBullet::get_param(PhysicsServer::AreaParameter p_param) { } } -void SpaceBullet::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) { +void SpaceBullet::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: - case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: - case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: - case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: - case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: + case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: + case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: + case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: + case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: + case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: + case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: default: WARN_PRINT("This set parameter (" + itos(p_param) + ") is ignored, the SpaceBullet doesn't support it."); break; } } -real_t SpaceBullet::get_param(PhysicsServer::SpaceParameter p_param) { +real_t SpaceBullet::get_param(PhysicsServer3D::SpaceParameter p_param) { switch (p_param) { - case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: - case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: - case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: - case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: - case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: + case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: + case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: + case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: + case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: + case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: + case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: default: WARN_PRINT("The SpaceBullet doesn't support this get parameter (" + itos(p_param) + "), 0 is returned."); return 0.f; @@ -511,7 +511,7 @@ void SpaceBullet::remove_soft_body(SoftBodyBullet *p_body) { if (is_using_soft_world()) { if (p_body->get_bt_soft_body()) { static_cast<btSoftRigidDynamicsWorld *>(dynamicsWorld)->removeSoftBody(p_body->get_bt_soft_body()); - p_body->get_bt_soft_body()->m_worldInfo = NULL; + p_body->get_bt_soft_body()->m_worldInfo = nullptr; } } } @@ -539,7 +539,7 @@ void SpaceBullet::remove_all_collision_objects() { for (int i = dynamicsWorld->getNumCollisionObjects() - 1; 0 <= i; --i) { btCollisionObject *btObj = dynamicsWorld->getCollisionObjectArray()[i]; CollisionObjectBullet *colObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); - colObj->set_space(NULL); + colObj->set_space(nullptr); } } @@ -636,8 +636,8 @@ void SpaceBullet::destroy_world() { /// The world elements (like: Collision Objects, Constraints, Shapes) are managed by godot - dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(NULL); - dynamicsWorld->getPairCache()->setOverlapFilterCallback(NULL); + dynamicsWorld->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(nullptr); + dynamicsWorld->getPairCache()->setOverlapFilterCallback(nullptr); bulletdelete(ghostPairCallback); bulletdelete(godotFilterCallback); @@ -645,7 +645,7 @@ void SpaceBullet::destroy_world() { // Deallocate world dynamicsWorld->~btDiscreteDynamicsWorld(); free(dynamicsWorld); - dynamicsWorld = NULL; + dynamicsWorld = nullptr; bulletdelete(solver); bulletdelete(broadphase); @@ -741,7 +741,7 @@ void SpaceBullet::check_ghost_overlaps() { static_cast<btConvexShape *>(other_body_shape), gjk_simplex_solver, gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(gjk_input, result, 0); + gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr); if (0 >= result.m_distance) { hasOverlap = true; @@ -750,10 +750,10 @@ void SpaceBullet::check_ghost_overlaps() { } else { - btCollisionObjectWrapper obA(NULL, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y); - btCollisionObjectWrapper obB(NULL, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z); + btCollisionObjectWrapper obA(nullptr, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y); + btCollisionObjectWrapper obB(nullptr, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z); - btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS); + btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS); if (!algorithm) continue; @@ -885,20 +885,20 @@ void SpaceBullet::update_gravity() { #include "scene/3d/immediate_geometry.h" -static ImmediateGeometry *motionVec(NULL); -static ImmediateGeometry *normalLine(NULL); +static ImmediateGeometry3D *motionVec(nullptr); +static ImmediateGeometry3D *normalLine(nullptr); static Ref<StandardMaterial3D> red_mat; static Ref<StandardMaterial3D> blue_mat; #endif -bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) { #if debug_test_motion /// Yes I know this is not good, but I've used it as fast debugging hack. /// I'm leaving it here just for speedup the other eventual debugs if (!normalLine) { - motionVec = memnew(ImmediateGeometry); - normalLine = memnew(ImmediateGeometry); + motionVec = memnew(ImmediateGeometry3D); + normalLine = memnew(ImmediateGeometry3D); SceneTree::get_singleton()->get_current_scene()->add_child(motionVec); SceneTree::get_singleton()->get_current_scene()->add_child(normalLine); @@ -951,7 +951,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f Vector3 sup_line; B_TO_G(body_safe_position.getOrigin(), sup_line); motionVec->clear(); - motionVec->begin(Mesh::PRIMITIVE_LINES, NULL); + motionVec->begin(Mesh::PRIMITIVE_LINES, nullptr); motionVec->add_vertex(sup_line); motionVec->add_vertex(sup_line + p_motion * 10); motionVec->end(); @@ -1028,7 +1028,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f Vector3 sup_line2; B_TO_G(motion, sup_line2); normalLine->clear(); - normalLine->begin(Mesh::PRIMITIVE_LINES, NULL); + normalLine->begin(Mesh::PRIMITIVE_LINES, nullptr); normalLine->add_vertex(r_result->collision_point); normalLine->add_vertex(r_result->collision_point + r_result->collision_normal * 10); normalLine->end(); @@ -1042,7 +1042,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f return has_penetration; } -int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, float p_margin) { +int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin) { btTransform body_transform; G_TO_B(p_transform, body_transform); @@ -1054,7 +1054,7 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p int rays_found_this_round = 0; for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) { - PhysicsServer::SeparationResult *next_results = &r_results[rays_found]; + PhysicsServer3D::SeparationResult *next_results = &r_results[rays_found]; rays_found_this_round = recover_from_penetration_ray(p_body, body_transform, RECOVERING_MOVEMENT_SCALE, p_infinite_inertia, p_result_max - rays_found, recover_motion, next_results); rays_found += rays_found_this_round; @@ -1124,7 +1124,7 @@ public: if (cs->getNumChildShapes() > 1) { const btDbvt *tree = cs->getDynamicAabbTree(); - ERR_FAIL_COND_V(tree == NULL, true); + ERR_FAIL_COND_V(tree == nullptr, true); // Transform bounds into compound shape local space const btTransform other_in_compound_space = co->getWorldTransform().inverse(); @@ -1275,7 +1275,7 @@ bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const bt // Perform GJK test btPointCollector result; btGjkPairDetector gjk_pair_detector(p_shapeA, p_shapeB, gjk_simplex_solver, gjk_epa_pen_solver); - gjk_pair_detector.getClosestPoints(gjk_input, result, 0); + gjk_pair_detector.getClosestPoints(gjk_input, result, nullptr); if (0 > result.m_distance) { // Has penetration r_delta_recover_movement += result.m_normalOnBInWorld * (result.m_distance * -1 * p_recover_movement_scale); @@ -1302,10 +1302,10 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC btTransform tA(p_transformA); - btCollisionObjectWrapper obA(NULL, p_shapeA, p_objectA, tA, -1, p_shapeId_A); - btCollisionObjectWrapper obB(NULL, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B); + btCollisionObjectWrapper obA(nullptr, p_shapeA, p_objectA, tA, -1, p_shapeId_A); + btCollisionObjectWrapper obB(nullptr, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B); - btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS); + btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, nullptr, BT_CONTACT_POINT_ALGORITHMS); if (algorithm) { GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB); //discrete collision detection query @@ -1333,7 +1333,7 @@ bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btC return false; } -int SpaceBullet::add_separation_result(PhysicsServer::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const { +int SpaceBullet::add_separation_result(PhysicsServer3D::SeparationResult *r_result, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const { // optimize results (ignore non-colliding) if (p_recover_result.penetration_distance < 0.0) { @@ -1355,7 +1355,7 @@ int SpaceBullet::add_separation_result(PhysicsServer::SeparationResult *r_result } } -int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer::SeparationResult *r_results) { +int SpaceBullet::recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results) { // Calculate the cumulative AABB of all shapes of the kinematic body btVector3 aabb_min, aabb_max; diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index 32372f1630..f9a8c063fd 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -35,7 +35,7 @@ #include "core/vector.h" #include "godot_result_callbacks.h" #include "rid_bullet.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include <BulletCollision/BroadphaseCollision/btBroadphaseProxy.h> #include <BulletCollision/BroadphaseCollision/btOverlappingPairCache.h> @@ -67,8 +67,8 @@ class btGjkEpaPenetrationDepthSolver; extern ContactAddedCallback gContactAddedCallback; -class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState { - GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState); +class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState3D { + GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState3D); private: SpaceBullet *space; @@ -79,7 +79,7 @@ public: virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false); virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = NULL); + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &r_closest_safe, float &r_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr); /// Returns the list of contacts pairs in this order: Local contact, other body contact virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); @@ -131,15 +131,15 @@ public: /// @param p_param: /// AREA_PARAM_GRAVITY to set the gravity magnitude of entire world /// AREA_PARAM_GRAVITY_VECTOR to set the gravity direction of entire world - void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value); + void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value); /// Used to get some parameters to Bullet world /// @param p_param: /// AREA_PARAM_GRAVITY to get the gravity magnitude of entire world /// AREA_PARAM_GRAVITY_VECTOR to get the gravity direction of entire world - Variant get_param(PhysicsServer::AreaParameter p_param); + Variant get_param(PhysicsServer3D::AreaParameter p_param); - void set_param(PhysicsServer::SpaceParameter p_param, real_t p_value); - real_t get_param(PhysicsServer::SpaceParameter p_param); + void set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value); + real_t get_param(PhysicsServer3D::SpaceParameter p_param); void add_area(AreaBullet *p_area); void remove_area(AreaBullet *p_area); @@ -177,8 +177,8 @@ public: void update_gravity(); - bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes); - int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, float p_margin); + bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes); + int test_ray_separation(RigidBodyBullet *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, float p_margin); private: void create_empty_world(bool p_create_soft_world); @@ -201,19 +201,19 @@ private: pointWorld(0, 0, 0), penetration_distance(1e20), other_compound_shape_index(0), - other_collision_object(NULL), + other_collision_object(nullptr), local_shape_most_recovered(0) {} }; - bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL); + bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr); /// This is an API that recover a kinematic object from penetration /// This allow only Convex Convex test and it always use GJK algorithm, With this API we don't benefit of Bullet special accelerated functions - bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL); + bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr); /// This is an API that recover a kinematic object from penetration /// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm - bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = NULL); + bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btScalar p_recover_movement_scale, btVector3 &r_delta_recover_movement, RecoverResult *r_recover_result = nullptr); - int add_separation_result(PhysicsServer::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const; - int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer::SeparationResult *r_results); + int add_separation_result(PhysicsServer3D::SeparationResult *r_results, const SpaceBullet::RecoverResult &p_recover_result, int p_shape_id, const btCollisionObject *p_other_object) const; + int recover_from_penetration_ray(RigidBodyBullet *p_body, const btTransform &p_body_position, btScalar p_recover_movement_scale, bool p_infinite_inertia, int p_result_max, btVector3 &r_delta_recover_movement, PhysicsServer3D::SeparationResult *r_results); }; #endif diff --git a/modules/camera/SCsub b/modules/camera/SCsub index 23f031f06e..63c4e9fbab 100644 --- a/modules/camera/SCsub +++ b/modules/camera/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_camera = env_modules.Clone() @@ -10,7 +10,7 @@ if env["platform"] == "iphone": modules_sources = [] env_camera.add_source_files(modules_sources, "register_types.cpp") env_camera.add_source_files(modules_sources, "camera_ios.mm") - mod_lib = env_modules.add_library('#bin/libgodot_camera_module' + env['LIBSUFFIX'], modules_sources) + mod_lib = env_modules.add_library("#bin/libgodot_camera_module" + env["LIBSUFFIX"], modules_sources) elif env["platform"] == "windows": env_camera.add_source_files(env.modules_sources, "register_types.cpp") @@ -19,4 +19,3 @@ elif env["platform"] == "windows": elif env["platform"] == "osx": env_camera.add_source_files(env.modules_sources, "register_types.cpp") env_camera.add_source_files(env.modules_sources, "camera_osx.mm") - diff --git a/modules/camera/config.py b/modules/camera/config.py index d308c04195..87d7542741 100644 --- a/modules/camera/config.py +++ b/modules/camera/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return platform == 'iphone' or platform == 'osx' or platform == 'windows' + return platform == "iphone" or platform == "osx" or platform == "windows" + def configure(env): pass diff --git a/modules/csg/SCsub b/modules/csg/SCsub index 57c504efd8..641a42c187 100644 --- a/modules/csg/SCsub +++ b/modules/csg/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_csg = env_modules.Clone() diff --git a/modules/csg/config.py b/modules/csg/config.py index 38ccc66d91..9106cbceca 100644 --- a/modules/csg/config.py +++ b/modules/csg/config.py @@ -1,21 +1,24 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ - "CSGBox", - "CSGCombiner", - "CSGCylinder", - "CSGMesh", - "CSGPolygon", - "CSGPrimitive", - "CSGShape", - "CSGSphere", - "CSGTorus", + "CSGBox3D", + "CSGCombiner3D", + "CSGCylinder3D", + "CSGMesh3D", + "CSGPolygon3D", + "CSGPrimitive3D", + "CSGShape3D", + "CSGSphere3D", + "CSGTorus3D", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index d052eba41c..5557da3014 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -43,16 +43,16 @@ void CSGShape3D::set_use_collision(bool p_enable) { if (use_collision) { root_collision_shape.instance(); - root_collision_instance = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC); - PhysicsServer::get_singleton()->body_set_state(root_collision_instance, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); - PhysicsServer::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space()); - PhysicsServer::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); + root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); + PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); set_collision_layer(collision_layer); set_collision_mask(collision_mask); _make_dirty(); //force update } else { - PhysicsServer::get_singleton()->free(root_collision_instance); + PhysicsServer3D::get_singleton()->free(root_collision_instance); root_collision_instance = RID(); root_collision_shape.unref(); } @@ -66,7 +66,7 @@ bool CSGShape3D::is_using_collision() const { void CSGShape3D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; if (root_collision_instance.is_valid()) { - PhysicsServer::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer); + PhysicsServer3D::get_singleton()->body_set_collision_layer(root_collision_instance, p_layer); } } @@ -79,7 +79,7 @@ void CSGShape3D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; if (root_collision_instance.is_valid()) { - PhysicsServer::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask); + PhysicsServer3D::get_singleton()->body_set_collision_mask(root_collision_instance, p_mask); } } @@ -156,7 +156,7 @@ CSGBrush *CSGShape3D::_get_brush() { if (brush) { memdelete(brush); } - brush = NULL; + brush = nullptr; CSGBrush *n = _build_brush(); @@ -427,7 +427,7 @@ void CSGShape3D::_update_shape() { mkif.m_getPosition = mikktGetPosition; mkif.m_getTexCoord = mikktGetTexCoord; mkif.m_setTSpace = mikktSetTSpaceDefault; - mkif.m_setTSpaceBasic = NULL; + mkif.m_setTSpaceBasic = nullptr; SMikkTSpaceContext msc; msc.m_pInterface = &mkif; @@ -506,11 +506,11 @@ void CSGShape3D::_notification(int p_what) { if (use_collision && is_root_shape()) { root_collision_shape.instance(); - root_collision_instance = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC); - PhysicsServer::get_singleton()->body_set_state(root_collision_instance, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); - PhysicsServer::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space()); - PhysicsServer::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); + root_collision_instance = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_state(root_collision_instance, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_add_shape(root_collision_instance, root_collision_shape->get_rid()); + PhysicsServer3D::get_singleton()->body_set_space(root_collision_instance, get_world()->get_space()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(root_collision_instance, get_instance_id()); set_collision_layer(collision_layer); set_collision_mask(collision_mask); } @@ -536,10 +536,10 @@ void CSGShape3D::_notification(int p_what) { if (parent) parent->_make_dirty(); - parent = NULL; + parent = nullptr; if (use_collision && is_root_shape() && root_collision_instance.is_valid()) { - PhysicsServer::get_singleton()->free(root_collision_instance); + PhysicsServer3D::get_singleton()->free(root_collision_instance); root_collision_instance = RID(); root_collision_shape.unref(); } @@ -636,8 +636,8 @@ void CSGShape3D::_bind_methods() { CSGShape3D::CSGShape3D() { operation = OPERATION_UNION; - parent = NULL; - brush = NULL; + parent = nullptr; + brush = nullptr; dirty = false; snap = 0.001; use_collision = false; @@ -650,14 +650,14 @@ CSGShape3D::CSGShape3D() { CSGShape3D::~CSGShape3D() { if (brush) { memdelete(brush); - brush = NULL; + brush = nullptr; } } ////////////////////////////////// CSGBrush *CSGCombiner3D::_build_brush() { - return NULL; //does not build anything + return nullptr; //does not build anything } CSGCombiner3D::CSGCombiner3D() { @@ -713,7 +713,7 @@ CSGPrimitive3D::CSGPrimitive3D() { CSGBrush *CSGMesh3D::_build_brush() { if (!mesh.is_valid()) - return NULL; + return nullptr; Vector<Vector3> vertices; Vector<bool> smooth; @@ -731,7 +731,7 @@ CSGBrush *CSGMesh3D::_build_brush() { if (arrays.size() == 0) { _make_dirty(); - ERR_FAIL_COND_V(arrays.size() == 0, NULL); + ERR_FAIL_COND_V(arrays.size() == 0, nullptr); } Vector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX]; @@ -741,19 +741,15 @@ CSGBrush *CSGMesh3D::_build_brush() { const Vector3 *vr = avertices.ptr(); Vector<Vector3> anormals = arrays[Mesh::ARRAY_NORMAL]; - const Vector3 *nr = NULL; - bool nr_used = false; + const Vector3 *nr = nullptr; if (anormals.size()) { nr = anormals.ptr(); - nr_used = true; } Vector<Vector2> auvs = arrays[Mesh::ARRAY_TEX_UV]; - const Vector2 *uvr = NULL; - bool uvr_used = false; + const Vector2 *uvr = nullptr; if (auvs.size()) { uvr = auvs.ptr(); - uvr_used = true; } Ref<Material> mat; @@ -789,10 +785,10 @@ CSGBrush *CSGMesh3D::_build_brush() { for (int k = 0; k < 3; k++) { int idx = ir[j + k]; vertex[k] = vr[idx]; - if (nr_used) { + if (nr) { normal[k] = nr[idx]; } - if (uvr_used) { + if (uvr) { uv[k] = uvr[idx]; } } @@ -832,10 +828,10 @@ CSGBrush *CSGMesh3D::_build_brush() { for (int k = 0; k < 3; k++) { vertex[k] = vr[j + k]; - if (nr_used) { + if (nr) { normal[k] = nr[j + k]; } - if (uvr_used) { + if (uvr) { uv[k] = uvr[j + k]; } } @@ -857,7 +853,7 @@ CSGBrush *CSGMesh3D::_build_brush() { } if (vertices.size() == 0) - return NULL; + return nullptr; return _create_brush_from_arrays(vertices, uvs, smooth, materials); } @@ -1539,7 +1535,7 @@ CSGBrush *CSGTorus3D::_build_brush() { float max_radius = outer_radius; if (min_radius == max_radius) - return NULL; //sorry, can't + return nullptr; //sorry, can't if (min_radius > max_radius) { SWAP(min_radius, max_radius); @@ -1764,7 +1760,7 @@ CSGBrush *CSGPolygon3D::_build_brush() { // set our bounding box if (polygon.size() < 3) - return NULL; + return nullptr; Vector<Point2> final_polygon = polygon; @@ -1775,9 +1771,9 @@ CSGBrush *CSGPolygon3D::_build_brush() { Vector<int> triangles = Geometry::triangulate_polygon(final_polygon); if (triangles.size() < 3) - return NULL; + return nullptr; - Path3D *path = NULL; + Path3D *path = nullptr; Ref<Curve3D> curve; // get bounds for our polygon @@ -1800,32 +1796,32 @@ CSGBrush *CSGPolygon3D::_build_brush() { if (mode == MODE_PATH) { if (!has_node(path_node)) - return NULL; + return nullptr; Node *n = get_node(path_node); if (!n) - return NULL; + return nullptr; path = Object::cast_to<Path3D>(n); if (!path) - return NULL; + return nullptr; if (path != path_cache) { if (path_cache) { path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited)); path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed)); - path_cache = NULL; + path_cache = nullptr; } path_cache = path; path_cache->connect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited)); path_cache->connect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed)); - path_cache = NULL; + path_cache = nullptr; } curve = path->get_curve(); if (curve.is_null()) - return NULL; + return nullptr; if (curve->get_baked_length() <= 0) - return NULL; + return nullptr; } CSGBrush *brush = memnew(CSGBrush); @@ -2236,7 +2232,7 @@ void CSGPolygon3D::_notification(int p_what) { if (path_cache) { path_cache->disconnect("tree_exited", callable_mp(this, &CSGPolygon3D::_path_exited)); path_cache->disconnect("curve_changed", callable_mp(this, &CSGPolygon3D::_path_changed)); - path_cache = NULL; + path_cache = nullptr; } } } @@ -2261,7 +2257,7 @@ void CSGPolygon3D::_path_changed() { } void CSGPolygon3D::_path_exited() { - path_cache = NULL; + path_cache = nullptr; } void CSGPolygon3D::_bind_methods() { @@ -2487,5 +2483,5 @@ CSGPolygon3D::CSGPolygon3D() { path_local = false; path_continuous_u = false; path_joined = false; - path_cache = NULL; + path_cache = nullptr; } diff --git a/modules/csg/doc_classes/CSGBox.xml b/modules/csg/doc_classes/CSGBox3D.xml index e2f0f8488a..492bf68c44 100644 --- a/modules/csg/doc_classes/CSGBox.xml +++ b/modules/csg/doc_classes/CSGBox3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGBox" inherits="CSGPrimitive" version="4.0"> +<class name="CSGBox3D" inherits="CSGPrimitive3D" version="4.0"> <brief_description> A CSG Box shape. </brief_description> diff --git a/modules/csg/doc_classes/CSGCombiner.xml b/modules/csg/doc_classes/CSGCombiner.xml deleted file mode 100644 index ab95d3c3ee..0000000000 --- a/modules/csg/doc_classes/CSGCombiner.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGCombiner" inherits="CSGShape" version="4.0"> - <brief_description> - A CSG node that allows you to combine other CSG modifiers. - </brief_description> - <description> - For complex arrangements of shapes, it is sometimes needed to add structure to your CSG nodes. The CSGCombiner node allows you to create this structure. The node encapsulates the result of the CSG operations of its children. In this way, it is possible to do operations on one set of shapes that are children of one CSGCombiner node, and a set of separate operations on a second set of shapes that are children of a second CSGCombiner node, and then do an operation that takes the two end results as its input to create the final shape. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <constants> - </constants> -</class> diff --git a/modules/csg/doc_classes/CSGCombiner3D.xml b/modules/csg/doc_classes/CSGCombiner3D.xml new file mode 100644 index 0000000000..b55111eee4 --- /dev/null +++ b/modules/csg/doc_classes/CSGCombiner3D.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="CSGCombiner3D" inherits="CSGShape3D" version="4.0"> + <brief_description> + A CSG node that allows you to combine other CSG modifiers. + </brief_description> + <description> + For complex arrangements of shapes, it is sometimes needed to add structure to your CSG nodes. The CSGCombiner3D node allows you to create this structure. The node encapsulates the result of the CSG operations of its children. In this way, it is possible to do operations on one set of shapes that are children of one CSGCombiner3D node, and a set of separate operations on a second set of shapes that are children of a second CSGCombiner3D node, and then do an operation that takes the two end results as its input to create the final shape. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/modules/csg/doc_classes/CSGCylinder.xml b/modules/csg/doc_classes/CSGCylinder3D.xml index 2dd8c6a8d0..bfd2a5d5f2 100644 --- a/modules/csg/doc_classes/CSGCylinder.xml +++ b/modules/csg/doc_classes/CSGCylinder3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGCylinder" inherits="CSGPrimitive" version="4.0"> +<class name="CSGCylinder3D" inherits="CSGPrimitive3D" version="4.0"> <brief_description> A CSG Cylinder shape. </brief_description> diff --git a/modules/csg/doc_classes/CSGMesh.xml b/modules/csg/doc_classes/CSGMesh3D.xml index f1fe2c286b..1bab8f4ee9 100644 --- a/modules/csg/doc_classes/CSGMesh.xml +++ b/modules/csg/doc_classes/CSGMesh3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGMesh" inherits="CSGPrimitive" version="4.0"> +<class name="CSGMesh3D" inherits="CSGPrimitive3D" version="4.0"> <brief_description> A CSG Mesh shape that uses a mesh resource. </brief_description> diff --git a/modules/csg/doc_classes/CSGPolygon.xml b/modules/csg/doc_classes/CSGPolygon3D.xml index 02b2e8b03f..c55fa0983e 100644 --- a/modules/csg/doc_classes/CSGPolygon.xml +++ b/modules/csg/doc_classes/CSGPolygon3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGPolygon" inherits="CSGPrimitive" version="4.0"> +<class name="CSGPolygon3D" inherits="CSGPrimitive3D" version="4.0"> <brief_description> Extrudes a 2D polygon shape to create a 3D mesh. </brief_description> @@ -17,7 +17,7 @@ <member name="material" type="Material" setter="set_material" getter="get_material"> Material to use for the resulting mesh. </member> - <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon.Mode" default="0"> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="CSGPolygon3D.Mode" default="0"> Extrusion mode. </member> <member name="path_continuous_u" type="bool" setter="set_path_continuous_u" getter="is_path_continuous_u"> @@ -30,12 +30,12 @@ If [code]true[/code] the start and end of our path are joined together ensuring there is no seam when [member mode] is [constant MODE_PATH]. </member> <member name="path_local" type="bool" setter="set_path_local" getter="is_path_local"> - If [code]false[/code] we extrude centered on our path, if [code]true[/code] we extrude in relation to the position of our CSGPolygon when [member mode] is [constant MODE_PATH]. + If [code]false[/code] we extrude centered on our path, if [code]true[/code] we extrude in relation to the position of our CSGPolygon3D when [member mode] is [constant MODE_PATH]. </member> <member name="path_node" type="NodePath" setter="set_path_node" getter="get_path_node"> - The [Shape] object containing the path along which we extrude when [member mode] is [constant MODE_PATH]. + The [Shape3D] object containing the path along which we extrude when [member mode] is [constant MODE_PATH]. </member> - <member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon.PathRotation"> + <member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon3D.PathRotation"> The method by which each slice is rotated along the path when [member mode] is [constant MODE_PATH]. </member> <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )"> @@ -53,13 +53,13 @@ </members> <constants> <constant name="MODE_DEPTH" value="0" enum="Mode"> - Shape is extruded to [member depth]. + Shape3D is extruded to [member depth]. </constant> <constant name="MODE_SPIN" value="1" enum="Mode"> - Shape is extruded by rotating it around an axis. + Shape3D is extruded by rotating it around an axis. </constant> <constant name="MODE_PATH" value="2" enum="Mode"> - Shape is extruded along a path set by a [Shape] set in [member path_node]. + Shape3D is extruded along a path set by a [Shape3D] set in [member path_node]. </constant> <constant name="PATH_ROTATION_POLYGON" value="0" enum="PathRotation"> Slice is not rotated. diff --git a/modules/csg/doc_classes/CSGPrimitive.xml b/modules/csg/doc_classes/CSGPrimitive3D.xml index ba395b7edd..31b7360fac 100644 --- a/modules/csg/doc_classes/CSGPrimitive.xml +++ b/modules/csg/doc_classes/CSGPrimitive3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGPrimitive" inherits="CSGShape" version="4.0"> +<class name="CSGPrimitive3D" inherits="CSGShape3D" version="4.0"> <brief_description> Base class for CSG primitives. </brief_description> diff --git a/modules/csg/doc_classes/CSGShape.xml b/modules/csg/doc_classes/CSGShape3D.xml index 64a2fb1840..43ce988c30 100644 --- a/modules/csg/doc_classes/CSGShape.xml +++ b/modules/csg/doc_classes/CSGShape3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGShape" inherits="GeometryInstance" version="4.0"> +<class name="CSGShape3D" inherits="GeometryInstance3D" version="4.0"> <brief_description> The CSG base class. </brief_description> @@ -76,7 +76,7 @@ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The physics layers this CSG shape scans for collisions. </member> - <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape.Operation" default="0"> + <member name="operation" type="int" setter="set_operation" getter="get_operation" enum="CSGShape3D.Operation" default="0"> The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent. </member> <member name="snap" type="float" setter="set_snap" getter="get_snap" default="0.001"> diff --git a/modules/csg/doc_classes/CSGSphere.xml b/modules/csg/doc_classes/CSGSphere3D.xml index 847cc63586..4d5b3be099 100644 --- a/modules/csg/doc_classes/CSGSphere.xml +++ b/modules/csg/doc_classes/CSGSphere3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGSphere" inherits="CSGPrimitive" version="4.0"> +<class name="CSGSphere3D" inherits="CSGPrimitive3D" version="4.0"> <brief_description> A CSG Sphere shape. </brief_description> diff --git a/modules/csg/doc_classes/CSGTorus.xml b/modules/csg/doc_classes/CSGTorus3D.xml index 84a08edaf5..abe3eab913 100644 --- a/modules/csg/doc_classes/CSGTorus.xml +++ b/modules/csg/doc_classes/CSGTorus3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSGTorus" inherits="CSGPrimitive" version="4.0"> +<class name="CSGTorus3D" inherits="CSGPrimitive3D" version="4.0"> <brief_description> A CSG Torus shape. </brief_description> diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp index 1a12a6706d..40eef84b1b 100644 --- a/modules/csg/register_types.cpp +++ b/modules/csg/register_types.cpp @@ -47,15 +47,6 @@ void register_csg_types() { ClassDB::register_class<CSGPolygon3D>(); ClassDB::register_class<CSGCombiner3D>(); - ClassDB::add_compatibility_class("CSGShape", "CSGShape3D"); - ClassDB::add_compatibility_class("CSGMesh", "CSGMesh3D"); - ClassDB::add_compatibility_class("CSGSphere", "CSGSphere3D"); - ClassDB::add_compatibility_class("CSGBox", "CSGBox3D"); - ClassDB::add_compatibility_class("CSGCylinder", "CSGCylinder3D"); - ClassDB::add_compatibility_class("CSGTorus", "CSGTorus3D"); - ClassDB::add_compatibility_class("CSGPolygon", "CSGPolygon3D"); - ClassDB::add_compatibility_class("CSGCombiner", "CSGCombiner3D"); - #ifdef TOOLS_ENABLED EditorPlugins::add_by_type<EditorPluginCSG>(); #endif diff --git a/modules/cvtt/SCsub b/modules/cvtt/SCsub index 746b23ca28..5438f7ebac 100644 --- a/modules/cvtt/SCsub +++ b/modules/cvtt/SCsub @@ -1,14 +1,14 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_cvtt = env_modules.Clone() # Thirdparty source files thirdparty_dir = "#thirdparty/cvtt/" thirdparty_sources = [ - "ConvectionKernels.cpp" + "ConvectionKernels.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/cvtt/config.py b/modules/cvtt/config.py index 098f1eafa9..53b8f2f2e3 100644 --- a/modules/cvtt/config.py +++ b/modules/cvtt/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return env['tools'] + return env["tools"] + def configure(env): pass diff --git a/modules/dds/SCsub b/modules/dds/SCsub index 3d92ff02d6..06980bd670 100644 --- a/modules/dds/SCsub +++ b/modules/dds/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_dds = env_modules.Clone() diff --git a/modules/dds/config.py b/modules/dds/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/dds/config.py +++ b/modules/dds/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h index de8088af90..5b89f16277 100644 --- a/modules/dds/texture_loader_dds.h +++ b/modules/dds/texture_loader_dds.h @@ -36,7 +36,7 @@ class ResourceFormatDDS : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/enet/SCsub b/modules/enet/SCsub index 485c33b1a8..c8f4b3885e 100644 --- a/modules/enet/SCsub +++ b/modules/enet/SCsub @@ -1,13 +1,13 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_enet = env_modules.Clone() # Thirdparty source files -if env['builtin_enet']: +if env["builtin_enet"]: thirdparty_dir = "#thirdparty/enet/" thirdparty_sources = [ "godot.cpp", diff --git a/modules/enet/config.py b/modules/enet/config.py index 3e30bbe778..5fd343c75d 100644 --- a/modules/enet/config.py +++ b/modules/enet/config.py @@ -1,13 +1,16 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "NetworkedMultiplayerENet", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 406eb467f0..444ffae713 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -154,7 +154,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por p_in_bandwidth /* limit incoming bandwidth if > 0 */, p_out_bandwidth /* limit outgoing bandwidth if > 0 */); } else { - host = enet_host_create(NULL /* create a client host */, + host = enet_host_create(nullptr /* create a client host */, 1 /* only allow 1 outgoing connection */, channel_count /* allow up to channel_count to be used */, p_in_bandwidth /* limit incoming bandwidth if > 0 */, @@ -197,7 +197,7 @@ Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_por // Initiate connection, allocating enough channels ENetPeer *peer = enet_host_connect(host, &address, channel_count, unique_id); - if (peer == NULL) { + if (peer == nullptr) { enet_host_destroy(host); ERR_FAIL_COND_V_MSG(!peer, ERR_CANT_CREATE, "Couldn't connect to the ENet multiplayer server."); } @@ -276,12 +276,12 @@ void NetworkedMultiplayerENet::poll() { if (E->key() == *new_id) continue; // Send existing peers to new peer - ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE); + ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]); encode_uint32(E->key(), &packet->data[4]); enet_peer_send(event.peer, SYSCH_CONFIG, packet); // Send the new peer to existing peers - packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE); + packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); encode_uint32(SYSMSG_ADD_PEER, &packet->data[0]); encode_uint32(*new_id, &packet->data[4]); enet_peer_send(E->get(), SYSCH_CONFIG, packet); @@ -320,7 +320,7 @@ void NetworkedMultiplayerENet::poll() { if (E->key() == *id) continue; - ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE); + ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); encode_uint32(*id, &packet->data[4]); enet_peer_send(E->get(), SYSCH_CONFIG, packet); @@ -346,7 +346,7 @@ void NetworkedMultiplayerENet::poll() { switch (msg) { case SYSMSG_ADD_PEER: { - peer_map[id] = NULL; + peer_map[id] = nullptr; emit_signal("peer_connected", id); } break; @@ -502,7 +502,7 @@ void NetworkedMultiplayerENet::disconnect_peer(int p_peer, bool now) { continue; } - ENetPacket *packet = enet_packet_create(NULL, 8, ENET_PACKET_FLAG_RELIABLE); + ENetPacket *packet = enet_packet_create(nullptr, 8, ENET_PACKET_FLAG_RELIABLE); encode_uint32(SYSMSG_REMOVE_PEER, &packet->data[0]); encode_uint32(p_peer, &packet->data[4]); enet_peer_send(E->get(), SYSCH_CONFIG, packet); @@ -568,7 +568,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer if (transfer_channel > SYSCH_CONFIG) channel = transfer_channel; - Map<int, ENetPeer *>::Element *E = NULL; + Map<int, ENetPeer *>::Element *E = nullptr; if (target_peer != 0) { @@ -576,7 +576,7 @@ Error NetworkedMultiplayerENet::put_packet(const uint8_t *p_buffer, int p_buffer ERR_FAIL_COND_V_MSG(!E, ERR_INVALID_PARAMETER, vformat("Invalid target peer: %d", target_peer)); } - ENetPacket *packet = enet_packet_create(NULL, p_buffer_size + 8, packet_flags); + ENetPacket *packet = enet_packet_create(nullptr, p_buffer_size + 8, packet_flags); encode_uint32(unique_id, &packet->data[0]); // Source ID encode_uint32(target_peer, &packet->data[4]); // Dest ID copymem(&packet->data[8], p_buffer, p_buffer_size); @@ -625,7 +625,7 @@ void NetworkedMultiplayerENet::_pop_current_packet() { if (current_packet.packet) { enet_packet_destroy(current_packet.packet); - current_packet.packet = NULL; + current_packet.packet = nullptr; current_packet.from = 0; current_packet.channel = -1; } @@ -771,7 +771,7 @@ void NetworkedMultiplayerENet::_setup_compressor() { case COMPRESS_NONE: { - enet_host_compress(host, NULL); + enet_host_compress(host, nullptr); } break; case COMPRESS_RANGE_CODER: { enet_host_compress_with_range_coder(host); @@ -794,7 +794,7 @@ IP_Address NetworkedMultiplayerENet::get_peer_address(int p_peer_id) const { ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), IP_Address(), vformat("Peer ID %d not found in the list of peers.", p_peer_id)); ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, IP_Address(), "Can't get the address of peers other than the server (ID -1) when acting as a client."); - ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == NULL, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); + ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, IP_Address(), vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); IP_Address out; #ifdef GODOT_ENET @@ -810,7 +810,7 @@ int NetworkedMultiplayerENet::get_peer_port(int p_peer_id) const { ERR_FAIL_COND_V_MSG(!peer_map.has(p_peer_id), 0, vformat("Peer ID %d not found in the list of peers.", p_peer_id)); ERR_FAIL_COND_V_MSG(!is_server() && p_peer_id != 1, 0, "Can't get the address of peers other than the server (ID -1) when acting as a client."); - ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == NULL, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); + ERR_FAIL_COND_V_MSG(peer_map[p_peer_id] == nullptr, 0, vformat("Peer ID %d found in the list of peers, but is null.", p_peer_id)); #ifdef GODOT_ENET return peer_map[p_peer_id]->address.port; #else @@ -910,7 +910,7 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() { server_relay = true; unique_id = 0; target_peer = 0; - current_packet.packet = NULL; + current_packet.packet = nullptr; transfer_mode = TRANSFER_MODE_RELIABLE; channel_count = SYSCH_MAX; transfer_channel = -1; diff --git a/modules/etc/SCsub b/modules/etc/SCsub index 1742d3534f..383bbf83c3 100644 --- a/modules/etc/SCsub +++ b/modules/etc/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_etc = env_modules.Clone() @@ -9,21 +9,21 @@ env_etc = env_modules.Clone() # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/etc2comp/" thirdparty_sources = [ - "EtcBlock4x4.cpp", - "EtcBlock4x4Encoding.cpp", - "EtcBlock4x4Encoding_ETC1.cpp", - "EtcBlock4x4Encoding_R11.cpp", - "EtcBlock4x4Encoding_RG11.cpp", - "EtcBlock4x4Encoding_RGB8A1.cpp", - "EtcBlock4x4Encoding_RGB8.cpp", - "EtcBlock4x4Encoding_RGBA8.cpp", - "Etc.cpp", - "EtcDifferentialTrys.cpp", - "EtcFilter.cpp", - "EtcImage.cpp", - "EtcIndividualTrys.cpp", - "EtcMath.cpp", - "EtcSortedBlockList.cpp", + "EtcBlock4x4.cpp", + "EtcBlock4x4Encoding.cpp", + "EtcBlock4x4Encoding_ETC1.cpp", + "EtcBlock4x4Encoding_R11.cpp", + "EtcBlock4x4Encoding_RG11.cpp", + "EtcBlock4x4Encoding_RGB8A1.cpp", + "EtcBlock4x4Encoding_RGB8.cpp", + "EtcBlock4x4Encoding_RGBA8.cpp", + "Etc.cpp", + "EtcDifferentialTrys.cpp", + "EtcFilter.cpp", + "EtcImage.cpp", + "EtcIndividualTrys.cpp", + "EtcMath.cpp", + "EtcSortedBlockList.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/etc/config.py b/modules/etc/config.py index 098f1eafa9..53b8f2f2e3 100644 --- a/modules/etc/config.py +++ b/modules/etc/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return env['tools'] + return env["tools"] + def configure(env): pass diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index b3f7b1d94f..223830f445 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -192,7 +192,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f src_rgba_f[j] = Etc::ColorFloatRGBA::ConvertFromRGBA8(src[si], src[si + 1], src[si + 2], src[si + 3]); } - unsigned char *etc_data = NULL; + unsigned char *etc_data = nullptr; unsigned int etc_data_len = 0; unsigned int extended_width = 0, extended_height = 0; Etc::Encode((float *)src_rgba_f, mipmap_w, mipmap_h, etc2comp_etc_format, error_metric, effort, num_cpus, num_cpus, &etc_data, &etc_data_len, &extended_width, &extended_height, &encoding_time); diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h index d6011993e3..989e203994 100644 --- a/modules/etc/texture_loader_pkm.h +++ b/modules/etc/texture_loader_pkm.h @@ -36,7 +36,7 @@ class ResourceFormatPKM : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 9e1853c4cd..bfc1658bb4 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -1,12 +1,12 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_freetype = env_modules.Clone() # Thirdparty source files -if env['builtin_freetype']: +if env["builtin_freetype"]: thirdparty_dir = "#thirdparty/freetype/" thirdparty_sources = [ "src/autofit/autofit.c", @@ -53,31 +53,31 @@ if env['builtin_freetype']: ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - if env['platform'] == 'uwp': + if env["platform"] == "uwp": # Include header for UWP to fix build issues - env_freetype.Append(CCFLAGS=['/FI', '"modules/freetype/uwpdef.h"']) + env_freetype.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"']) # Globally too, as freetype is used in scene (see bottom) - env.Append(CCFLAGS=['/FI', '"modules/freetype/uwpdef.h"']) + env.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"']) env_freetype.Prepend(CPPPATH=[thirdparty_dir + "/include"]) # Also needed in main env for scene/ env.Prepend(CPPPATH=[thirdparty_dir + "/include"]) - env_freetype.Append(CPPDEFINES=['FT2_BUILD_LIBRARY', 'FT_CONFIG_OPTION_USE_PNG']) - if (env['target'] == 'debug'): - env_freetype.Append(CPPDEFINES=['ZLIB_DEBUG']) + env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG"]) + if env["target"] == "debug": + env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"]) # Also requires libpng headers - if env['builtin_libpng']: + if env["builtin_libpng"]: env_freetype.Prepend(CPPPATH=["#thirdparty/libpng"]) - sfnt = thirdparty_dir + 'src/sfnt/sfnt.c' + sfnt = thirdparty_dir + "src/sfnt/sfnt.c" # Must be done after all CPPDEFINES are being set so we can copy them. - if env['platform'] == 'javascript': + if env["platform"] == "javascript": # Forcibly undefine this macro so SIMD is not used in this file, # since currently unsupported in WASM tmp_env = env_freetype.Clone() - tmp_env.Append(CPPFLAGS=['-U__OPTIMIZE__']) + tmp_env.Append(CPPFLAGS=["-U__OPTIMIZE__"]) sfnt = tmp_env.Object(sfnt) thirdparty_sources += [sfnt] @@ -91,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 isinstance(linklib, (str, bytes)): # 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/freetype/config.py b/modules/freetype/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/freetype/config.py +++ b/modules/freetype/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index a18c75fa27..a788175b07 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_gdnative = env_modules.Clone() env_gdnative.add_source_files(env.modules_sources, "gdnative.cpp") @@ -12,9 +12,9 @@ env_gdnative.add_source_files(env.modules_sources, "nativescript/*.cpp") env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp") env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp") -env_gdnative.Prepend(CPPPATH=['#modules/gdnative/include/']) +env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"]) -Export('env_gdnative') +Export("env_gdnative") SConscript("net/SCsub") SConscript("arvr/SCsub") @@ -25,8 +25,11 @@ SConscript("videodecoder/SCsub") from platform_methods import run_in_subprocess import gdnative_builders -_, gensource = env_gdnative.CommandNoCache(['include/gdnative_api_struct.gen.h', 'gdnative_api_struct.gen.cpp'], - 'gdnative_api.json', run_in_subprocess(gdnative_builders.build_gdnative_api_struct)) +_, gensource = env_gdnative.CommandNoCache( + ["include/gdnative_api_struct.gen.h", "gdnative_api_struct.gen.cpp"], + "gdnative_api.json", + run_in_subprocess(gdnative_builders.build_gdnative_api_struct), +) env_gdnative.add_source_files(env.modules_sources, [gensource]) env.use_ptrcall = True diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp index 6e0358342f..bc39be1813 100644 --- a/modules/gdnative/android/android_gdn.cpp +++ b/modules/gdnative/android/android_gdn.cpp @@ -50,7 +50,7 @@ JNIEnv *GDAPI godot_android_get_env() { #ifdef __ANDROID__ return ThreadAndroid::get_env(); #else - return NULL; + return nullptr; #endif } @@ -59,7 +59,7 @@ jobject GDAPI godot_android_get_activity() { OS_Android *os_android = (OS_Android *)OS::get_singleton(); return os_android->get_godot_java()->get_activity(); #else - return NULL; + return nullptr; #endif } @@ -68,7 +68,7 @@ jobject GDAPI godot_android_get_surface() { OS_Android *os_android = (OS_Android *)OS::get_singleton(); return os_android->get_godot_java()->get_surface(); #else - return NULL; + return nullptr; #endif } diff --git a/modules/gdnative/arvr/SCsub b/modules/gdnative/arvr/SCsub index 20eaa99592..0b2db3b504 100644 --- a/modules/gdnative/arvr/SCsub +++ b/modules/gdnative/arvr/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') -Import('env_gdnative') +Import("env") +Import("env_gdnative") -env_gdnative.add_source_files(env.modules_sources, '*.cpp') +env_gdnative.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index 0f0c864df2..f14691027a 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -31,7 +31,7 @@ #include "arvr_interface_gdnative.h" #include "core/input/input_filter.h" #include "servers/arvr/arvr_positional_tracker.h" -#include "servers/visual/visual_server_globals.h" +#include "servers/rendering/rendering_server_globals.h" void ARVRInterfaceGDNative::_bind_methods() { ADD_PROPERTY_DEFAULT("interface_is_initialized", false); @@ -42,15 +42,15 @@ ARVRInterfaceGDNative::ARVRInterfaceGDNative() { print_verbose("Construct gdnative interface\n"); // we won't have our data pointer until our library gets set - data = NULL; + data = nullptr; - interface = NULL; + interface = nullptr; } ARVRInterfaceGDNative::~ARVRInterfaceGDNative() { print_verbose("Destruct gdnative interface\n"); - if (interface != NULL && is_initialized()) { + if (interface != nullptr && is_initialized()) { uninitialize(); }; @@ -59,10 +59,10 @@ ARVRInterfaceGDNative::~ARVRInterfaceGDNative() { } void ARVRInterfaceGDNative::cleanup() { - if (interface != NULL) { + if (interface != nullptr) { interface->destructor(data); - data = NULL; - interface = NULL; + data = nullptr; + interface = nullptr; } } @@ -81,7 +81,7 @@ void ARVRInterfaceGDNative::set_interface(const godot_arvr_interface_gdnative *p StringName ARVRInterfaceGDNative::get_name() const { - ERR_FAIL_COND_V(interface == NULL, StringName()); + ERR_FAIL_COND_V(interface == nullptr, StringName()); godot_string result = interface->get_name(data); @@ -95,7 +95,7 @@ StringName ARVRInterfaceGDNative::get_name() const { int ARVRInterfaceGDNative::get_capabilities() const { int capabilities; - ERR_FAIL_COND_V(interface == NULL, 0); // 0 = None + ERR_FAIL_COND_V(interface == nullptr, 0); // 0 = None capabilities = interface->get_capabilities(data); @@ -104,21 +104,21 @@ int ARVRInterfaceGDNative::get_capabilities() const { bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->get_anchor_detection_is_enabled(data); } void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_anchor_detection_is_enabled(data, p_enable); } int ARVRInterfaceGDNative::get_camera_feed_id() { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) { return (unsigned int)interface->get_camera_feed_id(data); @@ -130,7 +130,7 @@ int ARVRInterfaceGDNative::get_camera_feed_id() { bool ARVRInterfaceGDNative::is_stereo() { bool stereo; - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); stereo = interface->is_stereo(data); @@ -139,13 +139,13 @@ bool ARVRInterfaceGDNative::is_stereo() { bool ARVRInterfaceGDNative::is_initialized() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_initialized(data); } bool ARVRInterfaceGDNative::initialize() { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); bool initialized = interface->initialize(data); @@ -153,7 +153,7 @@ bool ARVRInterfaceGDNative::initialize() { // if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface ARVRServer *arvr_server = ARVRServer::get_singleton(); - if ((arvr_server != NULL) && (arvr_server->get_primary_interface() == NULL)) { + if ((arvr_server != nullptr) && (arvr_server->get_primary_interface() == nullptr)) { arvr_server->set_primary_interface(this); }; }; @@ -162,10 +162,10 @@ bool ARVRInterfaceGDNative::initialize() { } void ARVRInterfaceGDNative::uninitialize() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); ARVRServer *arvr_server = ARVRServer::get_singleton(); - if (arvr_server != NULL) { + if (arvr_server != nullptr) { // Whatever happens, make sure this is no longer our primary interface arvr_server->clear_primary_interface_if(this); } @@ -175,7 +175,7 @@ void ARVRInterfaceGDNative::uninitialize() { Size2 ARVRInterfaceGDNative::get_render_targetsize() { - ERR_FAIL_COND_V(interface == NULL, Size2()); + ERR_FAIL_COND_V(interface == nullptr, Size2()); godot_vector2 result = interface->get_render_targetsize(data); Vector2 *vec = (Vector2 *)&result; @@ -186,7 +186,7 @@ Size2 ARVRInterfaceGDNative::get_render_targetsize() { Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) { Transform *ret; - ERR_FAIL_COND_V(interface == NULL, Transform()); + ERR_FAIL_COND_V(interface == nullptr, Transform()); godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform); @@ -198,7 +198,7 @@ Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) { CameraMatrix cm; - ERR_FAIL_COND_V(interface == NULL, CameraMatrix()); + ERR_FAIL_COND_V(interface == nullptr, CameraMatrix()); interface->fill_projection_for_eye(data, (godot_real *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far); @@ -207,7 +207,7 @@ CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface::Eyes p_eye) { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) { return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye); @@ -218,19 +218,19 @@ unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface:: void ARVRInterfaceGDNative::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect); } void ARVRInterfaceGDNative::process() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->process(data); } void ARVRInterfaceGDNative::notification(int p_what) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); // this is only available in interfaces that implement 1.1 or later if ((interface->version.major > 1) || ((interface->version.major == 1) && (interface->version.minor > 0))) { @@ -265,7 +265,7 @@ godot_transform GDAPI godot_arvr_get_reference_frame() { Transform *reference_frame_ptr = (Transform *)&reference_frame; ARVRServer *arvr_server = ARVRServer::get_singleton(); - if (arvr_server != NULL) { + if (arvr_server != nullptr) { *reference_frame_ptr = arvr_server->get_reference_frame(); } else { godot_transform_new_identity(&reference_frame); @@ -292,7 +292,7 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re #warning this needs to be redone #endif #if 0 - VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0); + RSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0); #endif } @@ -302,13 +302,13 @@ godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) { #if 0 RID *render_target = (RID *)p_render_target; - RID eye_texture = VSG::storage->render_target_get_texture(*render_target); + RID eye_texture = RSG::storage->render_target_get_texture(*render_target); #endif #ifndef _MSC_VER #warning need to obtain this ID again #endif - uint32_t texid = 0; //VS::get_singleton()->texture_get_texid(eye_texture); + uint32_t texid = 0; //RS::get_singleton()->texture_get_texid(eye_texture); return texid; } @@ -360,7 +360,7 @@ void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) { ERR_FAIL_NULL(input); ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (remove_tracker != NULL) { + if (remove_tracker != nullptr) { // unset our joystick if applicable int joyid = remove_tracker->get_joy_id(); if (joyid != -1) { @@ -379,7 +379,7 @@ void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_ ERR_FAIL_NULL(arvr_server); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { Transform *transform = (Transform *)p_transform; if (p_tracks_orientation) { tracker->set_orientation(transform->basis); @@ -398,7 +398,7 @@ void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int ERR_FAIL_NULL(input); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { int joyid = tracker->get_joy_id(); if (joyid != -1) { input->joy_button(joyid, p_button, p_is_pressed); @@ -414,7 +414,7 @@ void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p ERR_FAIL_NULL(input); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { int joyid = tracker->get_joy_id(); if (joyid != -1) { InputFilter::JoyAxis jx; @@ -430,7 +430,7 @@ godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id) { ERR_FAIL_NULL_V(arvr_server, 0.0); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { return tracker->get_rumble(); } diff --git a/modules/gdnative/arvr/config.py b/modules/gdnative/arvr/config.py index 53bc827027..d22f9454ed 100644 --- a/modules/gdnative/arvr/config.py +++ b/modules/gdnative/arvr/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py index b9e5afcdf3..37e25a46d4 100644 --- a/modules/gdnative/config.py +++ b/modules/gdnative/config.py @@ -1,9 +1,11 @@ def can_build(env, platform): return True + def configure(env): env.use_ptrcall = True + def get_doc_classes(): return [ "@NativeScript", @@ -20,5 +22,6 @@ def get_doc_classes(): "WebRTCDataChannelGDNative", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 0457a42f30..d3426044ec 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -248,7 +248,7 @@ void GDNativeLibrary::_bind_methods() { } GDNative::GDNative() { - native_handle = NULL; + native_handle = nullptr; initialized = false; } @@ -338,7 +338,7 @@ bool GDNative::initialize() { if (err || !library_init) { OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = NULL; + native_handle = nullptr; ERR_PRINT("Failed to obtain " + library->get_symbol_prefix() + "gdnative_init symbol"); return false; } @@ -408,7 +408,7 @@ bool GDNative::terminate() { Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate); if (error || !library_terminate) { OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = NULL; + native_handle = nullptr; initialized = false; return true; } @@ -426,7 +426,7 @@ bool GDNative::terminate() { // GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); OS::get_singleton()->close_dynamic_library(native_handle); - native_handle = NULL; + native_handle = nullptr; return true; } @@ -466,7 +466,7 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced p_procedure_name, procedure_handle); - if (err != OK || procedure_handle == NULL) { + if (err != OK || procedure_handle == nullptr) { return Variant(); } @@ -544,11 +544,11 @@ Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_reso } bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const { - return Object::cast_to<GDNativeLibrary>(*p_resource) != NULL; + return Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr; } void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { - if (Object::cast_to<GDNativeLibrary>(*p_resource) != NULL) { + if (Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr) { p_extensions->push_back("gdnlib"); } } diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index d996b006a5..3175340448 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -95,7 +95,7 @@ godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classnam ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); if (class_info) return (godot_class_constructor)class_info->creation_func; - return NULL; + return nullptr; } godot_dictionary GDAPI godot_get_global_constants() { @@ -173,14 +173,14 @@ godot_object GDAPI *godot_instance_from_id(godot_int p_instance_id) { void *godot_get_class_tag(const godot_string_name *p_class) { StringName class_name = *(StringName *)p_class; ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name); - return class_info ? class_info->class_ptr : NULL; + return class_info ? class_info->class_ptr : nullptr; } godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) { - if (!p_object) return NULL; + if (!p_object) return nullptr; Object *o = (Object *)p_object; - return o->is_class_ptr(p_class_tag) ? (godot_object *)o : NULL; + return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr; } #ifdef __cplusplus diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py index 0d95a65b7e..2d84f93d87 100644 --- a/modules/gdnative/gdnative_builders.py +++ b/modules/gdnative/gdnative_builders.py @@ -8,209 +8,249 @@ from platform_methods import subprocess_main def _spaced(e): - return e if e[-1] == '*' else e + ' ' + return e if e[-1] == "*" else e + " " def _build_gdnative_api_struct_header(api): out = [ - '/* THIS FILE IS GENERATED DO NOT EDIT */', - '#ifndef GODOT_GDNATIVE_API_STRUCT_H', - '#define GODOT_GDNATIVE_API_STRUCT_H', - '', - '#include <gdnative/gdnative.h>', - '#include <android/godot_android.h>', - '#include <arvr/godot_arvr.h>', - '#include <nativescript/godot_nativescript.h>', - '#include <net/godot_net.h>', - '#include <pluginscript/godot_pluginscript.h>', - '#include <videodecoder/godot_videodecoder.h>', - '', - '#ifdef __cplusplus', + "/* THIS FILE IS GENERATED DO NOT EDIT */", + "#ifndef GODOT_GDNATIVE_API_STRUCT_H", + "#define GODOT_GDNATIVE_API_STRUCT_H", + "", + "#include <gdnative/gdnative.h>", + "#include <android/godot_android.h>", + "#include <arvr/godot_arvr.h>", + "#include <nativescript/godot_nativescript.h>", + "#include <net/godot_net.h>", + "#include <pluginscript/godot_pluginscript.h>", + "#include <videodecoder/godot_videodecoder.h>", + "", + "#ifdef __cplusplus", 'extern "C" {', - '#endif', - '', - 'enum GDNATIVE_API_TYPES {', - '\tGDNATIVE_' + api['core']['type'] + ',' + "#endif", + "", + "enum GDNATIVE_API_TYPES {", + "\tGDNATIVE_" + api["core"]["type"] + ",", ] - for ext in api['extensions']: - out += ['\tGDNATIVE_EXT_' + ext['type'] + ','] + for ext in api["extensions"]: + out += ["\tGDNATIVE_EXT_" + ext["type"] + ","] - out += ['};', ''] + out += ["};", ""] def generate_extension_struct(name, ext, include_version=True): ret_val = [] - if ext['next']: - ret_val += generate_extension_struct(name, ext['next']) + if ext["next"]: + ret_val += generate_extension_struct(name, ext["next"]) ret_val += [ - 'typedef struct godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct {', - '\tunsigned int type;', - '\tgodot_gdnative_api_version version;', - '\tconst godot_gdnative_api_struct *next;' + "typedef struct godot_gdnative_ext_" + + name + + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) + + "_api_struct {", + "\tunsigned int type;", + "\tgodot_gdnative_api_version version;", + "\tconst godot_gdnative_api_struct *next;", ] - for funcdef in ext['api']: - args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) - ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) + for funcdef in ext["api"]: + args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]]) + ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args)) - ret_val += ['} godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct;', ''] + ret_val += [ + "} godot_gdnative_ext_" + + name + + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) + + "_api_struct;", + "", + ] return ret_val - def generate_core_extension_struct(core): ret_val = [] - if core['next']: - ret_val += generate_core_extension_struct(core['next']) + if core["next"]: + ret_val += generate_core_extension_struct(core["next"]) ret_val += [ - 'typedef struct godot_gdnative_core_' + ('{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + '_api_struct {', - '\tunsigned int type;', - '\tgodot_gdnative_api_version version;', - '\tconst godot_gdnative_api_struct *next;', + "typedef struct godot_gdnative_core_" + + ("{0}_{1}".format(core["version"]["major"], core["version"]["minor"])) + + "_api_struct {", + "\tunsigned int type;", + "\tgodot_gdnative_api_version version;", + "\tconst godot_gdnative_api_struct *next;", ] - for funcdef in core['api']: - args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) - ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) + for funcdef in core["api"]: + args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]]) + ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args)) - ret_val += ['} godot_gdnative_core_' + '{0}_{1}'.format(core['version']['major'], core['version']['minor']) + '_api_struct;', ''] + ret_val += [ + "} godot_gdnative_core_" + + "{0}_{1}".format(core["version"]["major"], core["version"]["minor"]) + + "_api_struct;", + "", + ] return ret_val - - for ext in api['extensions']: - name = ext['name'] + for ext in api["extensions"]: + name = ext["name"] out += generate_extension_struct(name, ext, False) - if api['core']['next']: - out += generate_core_extension_struct(api['core']['next']) + if api["core"]["next"]: + out += generate_core_extension_struct(api["core"]["next"]) out += [ - 'typedef struct godot_gdnative_core_api_struct {', - '\tunsigned int type;', - '\tgodot_gdnative_api_version version;', - '\tconst godot_gdnative_api_struct *next;', - '\tunsigned int num_extensions;', - '\tconst godot_gdnative_api_struct **extensions;', + "typedef struct godot_gdnative_core_api_struct {", + "\tunsigned int type;", + "\tgodot_gdnative_api_version version;", + "\tconst godot_gdnative_api_struct *next;", + "\tunsigned int num_extensions;", + "\tconst godot_gdnative_api_struct **extensions;", ] - for funcdef in api['core']['api']: - args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) - out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) + for funcdef in api["core"]["api"]: + args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]]) + out.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args)) out += [ - '} godot_gdnative_core_api_struct;', - '', - '#ifdef __cplusplus', - '}', - '#endif', - '', - '#endif // GODOT_GDNATIVE_API_STRUCT_H', - '' + "} godot_gdnative_core_api_struct;", + "", + "#ifdef __cplusplus", + "}", + "#endif", + "", + "#endif // GODOT_GDNATIVE_API_STRUCT_H", + "", ] - return '\n'.join(out) + return "\n".join(out) def _build_gdnative_api_struct_source(api): - out = [ - '/* THIS FILE IS GENERATED DO NOT EDIT */', - '', - '#include <gdnative_api_struct.gen.h>', - '' - ] + out = ["/* THIS FILE IS GENERATED DO NOT EDIT */", "", "#include <gdnative_api_struct.gen.h>", ""] def get_extension_struct_name(name, ext, include_version=True): - return 'godot_gdnative_ext_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_api_struct' + return ( + "godot_gdnative_ext_" + + name + + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) + + "_api_struct" + ) def get_extension_struct_instance_name(name, ext, include_version=True): - return 'api_extension_' + name + ('' if not include_version else ('_{0}_{1}'.format(ext['version']['major'], ext['version']['minor']))) + '_struct' + return ( + "api_extension_" + + name + + ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"]))) + + "_struct" + ) def get_extension_struct_definition(name, ext, include_version=True): ret_val = [] - if ext['next']: - ret_val += get_extension_struct_definition(name, ext['next']) + if ext["next"]: + ret_val += get_extension_struct_definition(name, ext["next"]) ret_val += [ - 'extern const ' + get_extension_struct_name(name, ext, include_version) + ' ' + get_extension_struct_instance_name(name, ext, include_version) + ' = {', - '\tGDNATIVE_EXT_' + ext['type'] + ',', - '\t{' + str(ext['version']['major']) + ', ' + str(ext['version']['minor']) + '},', - '\t' + ('NULL' if not ext['next'] else ('(const godot_gdnative_api_struct *)&' + get_extension_struct_instance_name(name, ext['next']))) + ',' + "extern const " + + get_extension_struct_name(name, ext, include_version) + + " " + + get_extension_struct_instance_name(name, ext, include_version) + + " = {", + "\tGDNATIVE_EXT_" + ext["type"] + ",", + "\t{" + str(ext["version"]["major"]) + ", " + str(ext["version"]["minor"]) + "},", + "\t" + + ( + "nullptr" + if not ext["next"] + else ("(const godot_gdnative_api_struct *)&" + get_extension_struct_instance_name(name, ext["next"])) + ) + + ",", ] - for funcdef in ext['api']: - ret_val.append('\t%s,' % funcdef['name']) + for funcdef in ext["api"]: + ret_val.append("\t%s," % funcdef["name"]) - ret_val += ['};\n'] + ret_val += ["};\n"] return ret_val - def get_core_struct_definition(core): ret_val = [] - if core['next']: - ret_val += get_core_struct_definition(core['next']) + if core["next"]: + ret_val += get_core_struct_definition(core["next"]) ret_val += [ - 'extern const godot_gdnative_core_' + ('{0}_{1}_api_struct api_{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + ' = {', - '\tGDNATIVE_' + core['type'] + ',', - '\t{' + str(core['version']['major']) + ', ' + str(core['version']['minor']) + '},', - '\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['next']['version']['major'], core['next']['version']['minor']))) + ',' + "extern const godot_gdnative_core_" + + ("{0}_{1}_api_struct api_{0}_{1}".format(core["version"]["major"], core["version"]["minor"])) + + " = {", + "\tGDNATIVE_" + core["type"] + ",", + "\t{" + str(core["version"]["major"]) + ", " + str(core["version"]["minor"]) + "},", + "\t" + + ( + "nullptr" + if not core["next"] + else ( + "(const godot_gdnative_api_struct *)& api_{0}_{1}".format( + core["next"]["version"]["major"], core["next"]["version"]["minor"] + ) + ) + ) + + ",", ] - for funcdef in core['api']: - ret_val.append('\t%s,' % funcdef['name']) + for funcdef in core["api"]: + ret_val.append("\t%s," % funcdef["name"]) - ret_val += ['};\n'] + ret_val += ["};\n"] return ret_val - for ext in api['extensions']: - name = ext['name'] + for ext in api["extensions"]: + name = ext["name"] out += get_extension_struct_definition(name, ext, False) - out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {'] + out += ["", "const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {"] - for ext in api['extensions']: - name = ext['name'] - out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,'] + for ext in api["extensions"]: + name = ext["name"] + out += ["\t(godot_gdnative_api_struct *)&api_extension_" + name + "_struct,"] - out += ['};\n'] + out += ["};\n"] - if api['core']['next']: - out += get_core_struct_definition(api['core']['next']) + if api["core"]["next"]: + out += get_core_struct_definition(api["core"]["next"]) out += [ - 'extern const godot_gdnative_core_api_struct api_struct = {', - '\tGDNATIVE_' + api['core']['type'] + ',', - '\t{' + str(api['core']['version']['major']) + ', ' + str(api['core']['version']['minor']) + '},', - '\t(const godot_gdnative_api_struct *)&api_1_1,', - '\t' + str(len(api['extensions'])) + ',', - '\tgdnative_extensions_pointers,', + "extern const godot_gdnative_core_api_struct api_struct = {", + "\tGDNATIVE_" + api["core"]["type"] + ",", + "\t{" + str(api["core"]["version"]["major"]) + ", " + str(api["core"]["version"]["minor"]) + "},", + "\t(const godot_gdnative_api_struct *)&api_1_1,", + "\t" + str(len(api["extensions"])) + ",", + "\tgdnative_extensions_pointers,", ] - for funcdef in api['core']['api']: - out.append('\t%s,' % funcdef['name']) - out.append('};\n') + for funcdef in api["core"]["api"]: + out.append("\t%s," % funcdef["name"]) + out.append("};\n") - return '\n'.join(out) + return "\n".join(out) def build_gdnative_api_struct(target, source, env): - with open(source[0], 'r') as fd: + with open(source[0], "r") as fd: api = json.load(fd) header, source = target - with open(header, 'w') as fd: + with open(header, "w") as fd: fd.write(_build_gdnative_api_struct_header(api)) - with open(source, 'w') as fd: + with open(source, "w") as fd: fd.write(_build_gdnative_api_struct_source(api)) -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp index 9b4c3c794e..10ddd79d3a 100644 --- a/modules/gdnative/gdnative_library_editor_plugin.cpp +++ b/modules/gdnative/gdnative_library_editor_plugin.cpp @@ -119,7 +119,7 @@ void GDNativeLibraryEditor::_update_tree() { new_arch->set_expand_right(0, true); new_arch->set_metadata(1, E->key()); - platform->set_collapsed(collapsed_items.find(E->get().name) != NULL); + platform->set_collapsed(collapsed_items.find(E->get().name) != nullptr); } filter->set_text(text); } diff --git a/modules/gdnative/include/pluginscript/godot_pluginscript.h b/modules/gdnative/include/pluginscript/godot_pluginscript.h index 341e7f9e2b..406c3ba663 100644 --- a/modules/gdnative/include/pluginscript/godot_pluginscript.h +++ b/modules/gdnative/include/pluginscript/godot_pluginscript.h @@ -60,7 +60,7 @@ typedef struct { //this is used by script languages that keep a reference counter of their own //you can make make Ref<> not die when it reaches zero, so deleting the reference //depends entirely from the script. - // Note: You can set those function pointer to NULL if not needed. + // Note: You can set those function pointer to nullptr if not needed. void (*refcount_incremented)(godot_pluginscript_instance_data *p_data); bool (*refcount_decremented)(godot_pluginscript_instance_data *p_data); // return true if it can die } godot_pluginscript_instance_desc; @@ -119,18 +119,18 @@ typedef struct { const char *name; const char *type; const char *extension; - const char **recognized_extensions; // NULL terminated array + const char **recognized_extensions; // nullptr terminated array godot_pluginscript_language_data *(*init)(); void (*finish)(godot_pluginscript_language_data *p_data); - const char **reserved_words; // NULL terminated array - const char **comment_delimiters; // NULL terminated array - const char **string_delimiters; // NULL terminated array + const char **reserved_words; // nullptr terminated array + const char **comment_delimiters; // nullptr terminated array + const char **string_delimiters; // nullptr terminated array godot_bool has_named_classes; godot_bool supports_builtin_mode; godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name); godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, int *r_line_error, int *r_col_error, godot_string *r_test_error, const godot_string *p_path, godot_packed_string_array *r_functions); - int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be NULL + int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be nullptr godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args); godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint); void (*auto_indent_code)(godot_pluginscript_language_data *p_data, godot_string *p_code, int p_from_line, int p_to_line); diff --git a/modules/gdnative/nativescript/SCsub b/modules/gdnative/nativescript/SCsub index c28a1c8659..4212e87a87 100644 --- a/modules/gdnative/nativescript/SCsub +++ b/modules/gdnative/nativescript/SCsub @@ -1,9 +1,9 @@ #!/usr/bin/env python -Import('env') -Import('env_gdnative') +Import("env") +Import("env_gdnative") -env_gdnative.add_source_files(env.modules_sources, '*.cpp') +env_gdnative.add_source_files(env.modules_sources, "*.cpp") if "platform" in env and env["platform"] in ["linuxbsd", "iphone"]: env.Append(LINKFLAGS=["-rdynamic"]) diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 11fe746e90..3c0cfd0484 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -46,7 +46,7 @@ static Error save_file(const String &p_path, const List<String> &p_content) { ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); - for (const List<String>::Element *e = p_content.front(); e != NULL; e = e->next()) { + for (const List<String>::Element *e = p_content.front(); e != nullptr; e = e->next()) { file->store_string(e->get()); } @@ -197,7 +197,7 @@ List<ClassAPI> generate_c_api_classes() { api.push_back(global_constants_api); } - for (List<StringName>::Element *e = classes.front(); e != NULL; e = e->next()) { + for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) { StringName class_name = e->get(); ClassAPI class_api; @@ -229,7 +229,7 @@ List<ClassAPI> generate_c_api_classes() { List<String> constant; ClassDB::get_integer_constant_list(class_name, &constant, true); constant.sort_custom<NoCaseComparator>(); - for (List<String>::Element *c = constant.front(); c != NULL; c = c->next()) { + for (List<String>::Element *c = constant.front(); c != nullptr; c = c->next()) { ConstantAPI constant_api; constant_api.constant_name = c->get(); constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get()); @@ -284,7 +284,7 @@ List<ClassAPI> generate_c_api_classes() { ClassDB::get_property_list(class_name, &properties, true); properties.sort_custom<PropertyInfoComparator>(); - for (List<PropertyInfo>::Element *p = properties.front(); p != NULL; p = p->next()) { + for (List<PropertyInfo>::Element *p = properties.front(); p != nullptr; p = p->next()) { PropertyAPI property_api; property_api.name = p->get().name; @@ -312,7 +312,7 @@ List<ClassAPI> generate_c_api_classes() { ClassDB::get_method_list(class_name, &methods, true); methods.sort_custom<MethodInfoComparator>(); - for (List<MethodInfo>::Element *m = methods.front(); m != NULL; m = m->next()) { + for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; m = m->next()) { MethodAPI method_api; MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name); MethodInfo &method_info = m->get(); @@ -392,7 +392,7 @@ List<ClassAPI> generate_c_api_classes() { enum_api.name = E->get(); ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { - int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL); + int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr); enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); } enum_api.values.sort_custom<PairSort<int, String>>(); @@ -417,7 +417,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back("[\n"); - for (const List<ClassAPI>::Element *c = p_api.front(); c != NULL; c = c->next()) { + for (const List<ClassAPI>::Element *c = p_api.front(); c != nullptr; c = c->next()) { ClassAPI api = c->get(); source.push_back("\t{\n"); diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp index f953206a34..0502458b4f 100644 --- a/modules/gdnative/nativescript/godot_nativescript.cpp +++ b/modules/gdnative/nativescript/godot_nativescript.cpp @@ -77,7 +77,7 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char } } else { - desc.base_data = NULL; + desc.base_data = nullptr; desc.base_native_type = p_base; } @@ -111,7 +111,7 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const } } else { - desc.base_data = NULL; + desc.base_data = nullptr; desc.base_native_type = p_base; } @@ -210,11 +210,11 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) { Object *instance = (Object *)p_instance; if (!instance) - return NULL; + return nullptr; if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) { return ((NativeScriptInstance *)instance->get_script_instance())->userdata; } - return NULL; + return nullptr; } /* @@ -319,18 +319,18 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) const Object *o = (Object *)p_object; if (!o->get_script_instance()) { - return NULL; + return nullptr; } else { NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr()); if (!script) { - return NULL; + return nullptr; } if (script->get_script_desc()) return script->get_script_desc()->type_tag; } - return NULL; + return nullptr; } int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_instance_binding_functions p_binding_functions) { diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 80aebaccd1..bf458c15ee 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -204,7 +204,7 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) { NativeScriptDesc *script_data = get_script_desc(); if (!script_data) { - return NULL; + return nullptr; } NativeScriptInstance *nsi = memnew(NativeScriptInstance); @@ -214,7 +214,7 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) { #ifndef TOOLS_ENABLED if (!ScriptServer::is_scripting_enabled()) { - nsi->userdata = NULL; + nsi->userdata = nullptr; } else { nsi->userdata = script_data->create_func.create_func((godot_object *)p_this, script_data->create_func.method_data); } @@ -240,7 +240,7 @@ PlaceHolderScriptInstance *NativeScript::placeholder_instance_create(Object *p_t return sins; #else - return NULL; + return nullptr; #endif } @@ -738,7 +738,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::Cal r_error.error = Callable::CallError::CALL_OK; REF ref; - Object *owner = NULL; + Object *owner = nullptr; if (!(script_data->base_native_type == "")) { owner = ClassDB::instance(script_data->base_native_type); @@ -886,7 +886,7 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c E->get().method.method_data, userdata, 0, - NULL); + nullptr); Variant res = *(Variant *)&result; godot_variant_destroy(&result); @@ -1007,7 +1007,7 @@ void NativeScriptInstance::notification(int p_notification) { String NativeScriptInstance::to_string(bool *r_valid) { if (has_method(CoreStringNames::get_singleton()->_to_string)) { Callable::CallError ce; - Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce); + Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) { if (ret.get_type() != Variant::STRING) { if (r_valid) @@ -1026,7 +1026,7 @@ String NativeScriptInstance::to_string(bool *r_valid) { void NativeScriptInstance::refcount_incremented() { Callable::CallError err; - call("_refcount_incremented", NULL, 0, err); + call("_refcount_incremented", nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) { ERR_PRINT("Failed to invoke _refcount_incremented - should not happen"); } @@ -1034,7 +1034,7 @@ void NativeScriptInstance::refcount_incremented() { bool NativeScriptInstance::refcount_decremented() { Callable::CallError err; - Variant ret = call("_refcount_decremented", NULL, 0, err); + Variant ret = call("_refcount_decremented", nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK && err.error != Callable::CallError::CALL_ERROR_INVALID_METHOD) { ERR_PRINT("Failed to invoke _refcount_decremented - should not happen"); return true; // assume we can destroy the object @@ -1525,14 +1525,14 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) { } void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) { - ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, binding_functions.size(), nullptr); - ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, NULL, "Tried to get binding data for a nativescript binding that does not exist."); + ERR_FAIL_COND_V_MSG(!binding_functions[p_idx].first, nullptr, "Tried to get binding data for a nativescript binding that does not exist."); Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx); if (!binding_data) - return NULL; // should never happen. + return nullptr; // should never happen. if (binding_data->size() <= p_idx) { // okay, add new elements here. @@ -1541,7 +1541,7 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec binding_data->resize(p_idx + 1); for (int i = old_size; i <= p_idx; i++) { - (*binding_data).write[i] = NULL; + (*binding_data).write[i] = nullptr; } } @@ -1563,7 +1563,7 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) { binding_data->resize(binding_functions.size()); for (int i = 0; i < binding_functions.size(); i++) { - (*binding_data).write[i] = NULL; + (*binding_data).write[i] = nullptr; } binding_instances.insert(binding_data); @@ -1652,12 +1652,12 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const { if (!global_type_tags.has(p_idx)) - return NULL; + return nullptr; const HashMap<StringName, const void *> &tags = global_type_tags[p_idx]; if (!tags.has(p_class_name)) - return NULL; + return nullptr; const void *tag = tags.get(p_class_name); @@ -1956,7 +1956,7 @@ Error ResourceFormatSaverNativeScript::save(const String &p_path, const RES &p_r } bool ResourceFormatSaverNativeScript::recognize(const RES &p_resource) const { - return Object::cast_to<NativeScript>(*p_resource) != NULL; + return Object::cast_to<NativeScript>(*p_resource) != nullptr; } void ResourceFormatSaverNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index aba3f6b2d0..75bbb42664 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -95,7 +95,7 @@ struct NativeScriptDesc { base(), base_native_type(), documentation(), - type_tag(NULL) { + type_tag(nullptr) { zeromem(&create_func, sizeof(godot_instance_create_func)); zeromem(&destroy_func, sizeof(godot_instance_destroy_func)); } @@ -341,7 +341,7 @@ public: virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; @@ -389,7 +389,7 @@ public: inline NativeScriptDesc *NativeScript::get_script_desc() const { Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name); - return E ? &E->get() : NULL; + return E ? &E->get() : nullptr; } class NativeReloadNode : public Node { @@ -406,7 +406,7 @@ public: class ResourceFormatLoaderNativeScript : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub index 18ab9986b0..b76500c003 100644 --- a/modules/gdnative/net/SCsub +++ b/modules/gdnative/net/SCsub @@ -1,13 +1,12 @@ #!/usr/bin/env python -Import('env') -Import('env_gdnative') +Import("env") +Import("env_gdnative") env_net = env_gdnative.Clone() has_webrtc = env_net["module_webrtc_enabled"] if has_webrtc: - env_net.Append(CPPDEFINES=['WEBRTC_GDNATIVE_ENABLED']) - -env_net.add_source_files(env.modules_sources, '*.cpp') + env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"]) +env_net.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp index 8c43a79cc5..a95697ea65 100644 --- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp +++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp @@ -31,7 +31,7 @@ #include "multiplayer_peer_gdnative.h" MultiplayerPeerGDNative::MultiplayerPeerGDNative() { - interface = NULL; + interface = nullptr; } MultiplayerPeerGDNative::~MultiplayerPeerGDNative() { @@ -42,73 +42,73 @@ void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multip } Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); } int MultiplayerPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_max_packet_size(interface->data); } int MultiplayerPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_packet_count(interface->data); } /* NetworkedMultiplayerPeer */ void MultiplayerPeerGDNative::set_transfer_mode(TransferMode p_mode) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_transfer_mode(interface->data, (godot_int)p_mode); } NetworkedMultiplayerPeer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const { - ERR_FAIL_COND_V(interface == NULL, TRANSFER_MODE_UNRELIABLE); + ERR_FAIL_COND_V(interface == nullptr, TRANSFER_MODE_UNRELIABLE); return (TransferMode)interface->get_transfer_mode(interface->data); } void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_target_peer(interface->data, p_peer_id); } int MultiplayerPeerGDNative::get_packet_peer() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_packet_peer(interface->data); } bool MultiplayerPeerGDNative::is_server() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_server(interface->data); } void MultiplayerPeerGDNative::poll() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->poll(interface->data); } int MultiplayerPeerGDNative::get_unique_id() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_unique_id(interface->data); } void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_refuse_new_connections(interface->data, p_enable); } bool MultiplayerPeerGDNative::is_refusing_new_connections() const { - ERR_FAIL_COND_V(interface == NULL, true); + ERR_FAIL_COND_V(interface == nullptr, true); return interface->is_refusing_new_connections(interface->data); } NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const { - ERR_FAIL_COND_V(interface == NULL, CONNECTION_DISCONNECTED); + ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED); return (ConnectionStatus)interface->get_connection_status(interface->data); } diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp index 75e1e0b824..28135df3b6 100644 --- a/modules/gdnative/net/packet_peer_gdnative.cpp +++ b/modules/gdnative/net/packet_peer_gdnative.cpp @@ -31,7 +31,7 @@ #include "packet_peer_gdnative.h" PacketPeerGDNative::PacketPeerGDNative() { - interface = NULL; + interface = nullptr; } PacketPeerGDNative::~PacketPeerGDNative() { @@ -45,22 +45,22 @@ void PacketPeerGDNative::_bind_methods() { } Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); } int PacketPeerGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_max_packet_size(interface->data); } int PacketPeerGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_packet_count(interface->data); } diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp index 22634daf5f..9dcb184115 100644 --- a/modules/gdnative/net/stream_peer_gdnative.cpp +++ b/modules/gdnative/net/stream_peer_gdnative.cpp @@ -31,7 +31,7 @@ #include "stream_peer_gdnative.h" StreamPeerGDNative::StreamPeerGDNative() { - interface = NULL; + interface = nullptr; } StreamPeerGDNative::~StreamPeerGDNative() { @@ -45,27 +45,27 @@ void StreamPeerGDNative::_bind_methods() { } Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->put_data(interface->data, p_data, p_bytes)); } Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent)); } Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->get_data(interface->data, p_buffer, p_bytes)); } Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received)); } int StreamPeerGDNative::get_available_bytes() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_bytes(interface->data); } diff --git a/modules/gdnative/pluginscript/SCsub b/modules/gdnative/pluginscript/SCsub index 20eaa99592..0b2db3b504 100644 --- a/modules/gdnative/pluginscript/SCsub +++ b/modules/gdnative/pluginscript/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') -Import('env_gdnative') +Import("env") +Import("env_gdnative") -env_gdnative.add_source_files(env.modules_sources, '*.cpp') +env_gdnative.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/pluginscript/pluginscript_instance.cpp b/modules/gdnative/pluginscript/pluginscript_instance.cpp index 22e8372130..7d17a7d5ab 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.cpp +++ b/modules/gdnative/pluginscript/pluginscript_instance.cpp @@ -156,7 +156,7 @@ bool PluginScriptInstance::init(PluginScript *p_script, Object *p_owner) { _script = Ref<PluginScript>(p_script); _desc = &p_script->_desc->instance_desc; _data = _desc->init(p_script->_data, (godot_object *)p_owner); - ERR_FAIL_COND_V(_data == NULL, false); + ERR_FAIL_COND_V(_data == nullptr, false); p_owner->set_script_instance(this); return true; } diff --git a/modules/gdnative/pluginscript/pluginscript_instance.h b/modules/gdnative/pluginscript/pluginscript_instance.h index c91ad643a7..6309b6fde3 100644 --- a/modules/gdnative/pluginscript/pluginscript_instance.h +++ b/modules/gdnative/pluginscript/pluginscript_instance.h @@ -55,7 +55,7 @@ public: virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; - virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const; + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const; virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName &p_method) const; diff --git a/modules/gdnative/pluginscript/pluginscript_language.h b/modules/gdnative/pluginscript/pluginscript_language.h index 809034744a..dd6758713f 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.h +++ b/modules/gdnative/pluginscript/pluginscript_language.h @@ -74,7 +74,7 @@ public: virtual void get_comment_delimiters(List<String> *p_delimiters) const; virtual void get_string_delimiters(List<String> *p_delimiters) const; virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp index 46db20b6c2..3fb22b3f8d 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.cpp +++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp @@ -109,5 +109,5 @@ void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_res bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const { - return Object::cast_to<PluginScript>(*p_resource) != NULL; + return Object::cast_to<PluginScript>(*p_resource) != nullptr; } diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h index a039072fdc..c929be53bd 100644 --- a/modules/gdnative/pluginscript/pluginscript_loader.h +++ b/modules/gdnative/pluginscript/pluginscript_loader.h @@ -44,7 +44,7 @@ class ResourceFormatLoaderPluginScript : public ResourceFormatLoader { public: ResourceFormatLoaderPluginScript(PluginScriptLanguage *language); - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index b7cbedc51a..a4c84dc0ca 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -69,7 +69,7 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int } else { r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; memdelete(instance); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } // Construct @@ -93,7 +93,7 @@ Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::Cal } REF ref; - Object *owner = NULL; + Object *owner = nullptr; if (get_instance_base_type() == "") { owner = memnew(Reference); @@ -175,7 +175,7 @@ void PluginScript::update_exports() { // TODO: rename p_this "p_owner" ? ScriptInstance *PluginScript::instance_create(Object *p_this) { - ASSERT_SCRIPT_VALID_V(NULL); + ASSERT_SCRIPT_VALID_V(nullptr); // TODO check script validity ? if (!_tool && !ScriptServer::is_scripting_enabled()) { #ifdef TOOLS_ENABLED @@ -185,7 +185,7 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) { update_exports(); return si; #else - return NULL; + return nullptr; #endif } @@ -197,12 +197,12 @@ ScriptInstance *PluginScript::instance_create(Object *p_this) { // if (EngineDebugger::is_active()) { // _language->debug_break_parse(get_path(), 0, msg); // } - ERR_FAIL_V_MSG(NULL, msg); + ERR_FAIL_V_MSG(nullptr, msg); } } Callable::CallError unchecked_error; - return _create_instance(NULL, 0, p_this, unchecked_error); + return _create_instance(nullptr, 0, p_this, unchecked_error); } bool PluginScript::instance_has(const Object *p_this) const { @@ -296,7 +296,7 @@ Error PluginScript::reload(bool p_keep_state) { _tool = manifest.is_tool; Dictionary *members = (Dictionary *)&manifest.member_lines; - for (const Variant *key = members->next(); key != NULL; key = members->next(key)) { + for (const Variant *key = members->next(); key != nullptr; key = members->next(key)) { _member_lines[*key] = (*members)[*key]; } Array *methods = (Array *)&manifest.methods; @@ -366,14 +366,14 @@ Error PluginScript::reload(bool p_keep_state) { void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const { ASSERT_SCRIPT_VALID(); - for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != NULL; e = e->next()) { + for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) { r_methods->push_back(e->get()); } } void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const { ASSERT_SCRIPT_VALID(); - for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != NULL; e = e->next()) { + for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) { r_properties->push_back(e->get()); } } @@ -386,7 +386,7 @@ bool PluginScript::has_method(const StringName &p_method) const { MethodInfo PluginScript::get_method_info(const StringName &p_method) const { ASSERT_SCRIPT_VALID_V(MethodInfo()); const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method); - if (e != NULL) { + if (e != nullptr) { return e->get(); } else { return MethodInfo(); @@ -401,7 +401,7 @@ bool PluginScript::has_property(const StringName &p_method) const { PropertyInfo PluginScript::get_property_info(const StringName &p_property) const { ASSERT_SCRIPT_VALID_V(PropertyInfo()); const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property); - if (e != NULL) { + if (e != nullptr) { return e->get(); } else { return PropertyInfo(); @@ -412,7 +412,7 @@ bool PluginScript::get_property_default_value(const StringName &p_property, Vari ASSERT_SCRIPT_VALID_V(false); #ifdef TOOLS_ENABLED const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property); - if (e != NULL) { + if (e != nullptr) { r_value = e->get(); return true; } else { @@ -462,7 +462,7 @@ bool PluginScript::has_script_signal(const StringName &p_signal) const { void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const { ASSERT_SCRIPT_VALID(); - for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != NULL; e = e->next()) { + for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) { r_signals->push_back(e->get()); } } @@ -543,9 +543,9 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable } PluginScript::PluginScript() : - _data(NULL), - _desc(NULL), - _language(NULL), + _data(nullptr), + _desc(nullptr), + _language(nullptr), _tool(false), _valid(false), _script_list(this) { diff --git a/modules/gdnative/videodecoder/SCsub b/modules/gdnative/videodecoder/SCsub index 04cc8ed604..5948b9a3dd 100644 --- a/modules/gdnative/videodecoder/SCsub +++ b/modules/gdnative/videodecoder/SCsub @@ -1,9 +1,9 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_vsdecoder_gdnative = env_modules.Clone() -env_vsdecoder_gdnative.Prepend(CPPPATH=['#modules/gdnative/include/']) -env_vsdecoder_gdnative.add_source_files(env.modules_sources, '*.cpp') +env_vsdecoder_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"]) +env_vsdecoder_gdnative.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index f6e2bad739..fa9f6be5c1 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -33,7 +33,7 @@ #include "core/project_settings.h" #include "servers/audio_server.h" -VideoDecoderServer *VideoDecoderServer::instance = NULL; +VideoDecoderServer *VideoDecoderServer::instance = nullptr; static VideoDecoderServer decoder_server; @@ -113,7 +113,7 @@ void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interfac // VideoStreamPlaybackGDNative starts here. bool VideoStreamPlaybackGDNative::open_file(const String &p_file) { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); file = FileAccess::open(p_file, FileAccess::READ); bool file_opened = interface->open_file(data_struct, file); @@ -150,7 +150,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) { return; } time += p_delta; - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->update(data_struct, p_delta); // Don't mix if there's no audio (num_channels == 0). @@ -189,7 +189,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) { void VideoStreamPlaybackGDNative::update_texture() { PackedByteArray *pba = (PackedByteArray *)interface->get_videoframe(data_struct); - if (pba == NULL) { + if (pba == nullptr) { playing = false; return; } @@ -205,19 +205,19 @@ VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() : texture(Ref<ImageTexture>(memnew(ImageTexture))), playing(false), paused(false), - mix_udata(NULL), - mix_callback(NULL), + mix_udata(nullptr), + mix_callback(nullptr), num_channels(-1), time(0), seek_backward(false), mix_rate(0), delay_compensation(0), - pcm(NULL), + pcm(nullptr), pcm_write_idx(0), samples_decoded(0), - file(NULL), - interface(NULL), - data_struct(NULL) {} + file(nullptr), + interface(nullptr), + data_struct(nullptr) {} VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() { cleanup(); @@ -228,16 +228,16 @@ void VideoStreamPlaybackGDNative::cleanup() { interface->destructor(data_struct); if (pcm) memfree(pcm); - pcm = NULL; + pcm = nullptr; time = 0; num_channels = -1; - interface = NULL; - data_struct = NULL; + interface = nullptr; + data_struct = nullptr; } void VideoStreamPlaybackGDNative::set_interface(const godot_videodecoder_interface_gdnative *p_interface) { - ERR_FAIL_COND(p_interface == NULL); - if (interface != NULL) { + ERR_FAIL_COND(p_interface == nullptr); + if (interface != nullptr) { cleanup(); } interface = p_interface; @@ -272,7 +272,7 @@ void VideoStreamPlaybackGDNative::stop() { } void VideoStreamPlaybackGDNative::seek(float p_time) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->seek(data_struct, p_time); if (p_time < time) seek_backward = true; @@ -292,13 +292,13 @@ Ref<Texture2D> VideoStreamPlaybackGDNative::get_texture() const { } float VideoStreamPlaybackGDNative::get_length() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_length(data_struct); } float VideoStreamPlaybackGDNative::get_playback_position() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_playback_position(data_struct); } @@ -312,7 +312,7 @@ void VideoStreamPlaybackGDNative::set_loop(bool p_enable) { } void VideoStreamPlaybackGDNative::set_audio_track(int p_idx) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_audio_track(data_struct, p_idx); } @@ -323,13 +323,13 @@ void VideoStreamPlaybackGDNative::set_mix_callback(AudioMixCallback p_callback, } int VideoStreamPlaybackGDNative::get_channels() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return (num_channels > 0) ? num_channels : 0; } int VideoStreamPlaybackGDNative::get_mix_rate() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return mix_rate; } @@ -339,13 +339,13 @@ int VideoStreamPlaybackGDNative::get_mix_rate() const { Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() { Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative); VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower()); - if (decoder == NULL) - return NULL; + if (decoder == nullptr) + return nullptr; pb->set_interface(decoder->interface); pb->set_audio_track(audio_track); if (pb->open_file(file)) return pb; - return NULL; + return nullptr; } void VideoStreamGDNative::set_file(const String &p_file) { diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h index 21b5245a16..fbc0d4016f 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.h +++ b/modules/gdnative/videodecoder/video_stream_gdnative.h @@ -42,7 +42,7 @@ struct VideoDecoderGDNative { Vector<String> supported_extensions; VideoDecoderGDNative() : - interface(NULL), + interface(nullptr), plugin_name("none") {} VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) : @@ -89,7 +89,7 @@ public: VideoDecoderGDNative *get_decoder(const String &extension) { if (extensions.size() == 0 || !extensions.has(extension)) - return NULL; + return nullptr; return decoders[extensions[extension]]; } @@ -102,7 +102,7 @@ public: memdelete(decoders[i]); } decoders.clear(); - instance = NULL; + instance = nullptr; } }; @@ -194,12 +194,12 @@ public: virtual void set_audio_track(int p_track); virtual Ref<VideoStreamPlayback> instance_playback(); - VideoStreamGDNative() {} + VideoStreamGDNative() { audio_track = 0; } }; class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdnavigation/SCsub b/modules/gdnavigation/SCsub index 9d462f92a7..877d601c6a 100644 --- a/modules/gdnavigation/SCsub +++ b/modules/gdnavigation/SCsub @@ -1,25 +1,25 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_navigation = env_modules.Clone() # Recast Thirdparty source files -if env['builtin_recast']: +if env["builtin_recast"]: thirdparty_dir = "#thirdparty/recastnavigation/Recast/" thirdparty_sources = [ - "Source/Recast.cpp", - "Source/RecastAlloc.cpp", - "Source/RecastArea.cpp", - "Source/RecastAssert.cpp", - "Source/RecastContour.cpp", - "Source/RecastFilter.cpp", - "Source/RecastLayers.cpp", - "Source/RecastMesh.cpp", - "Source/RecastMeshDetail.cpp", - "Source/RecastRasterization.cpp", - "Source/RecastRegion.cpp", + "Source/Recast.cpp", + "Source/RecastAlloc.cpp", + "Source/RecastArea.cpp", + "Source/RecastAssert.cpp", + "Source/RecastContour.cpp", + "Source/RecastFilter.cpp", + "Source/RecastLayers.cpp", + "Source/RecastMesh.cpp", + "Source/RecastMeshDetail.cpp", + "Source/RecastRasterization.cpp", + "Source/RecastRegion.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] @@ -31,11 +31,11 @@ if env['builtin_recast']: # RVO Thirdparty source files -if env['builtin_rvo2']: +if env["builtin_rvo2"]: thirdparty_dir = "#thirdparty/rvo2" thirdparty_sources = [ - "/src/Agent.cpp", - "/src/KdTree.cpp", + "/src/Agent.cpp", + "/src/KdTree.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/gdnavigation/config.py b/modules/gdnavigation/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/gdnavigation/config.py +++ b/modules/gdnavigation/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/gdnavigation/gd_navigation_server.cpp b/modules/gdnavigation/gd_navigation_server.cpp index a1f6ddfedc..278c27ae22 100644 --- a/modules/gdnavigation/gd_navigation_server.cpp +++ b/modules/gdnavigation/gd_navigation_server.cpp @@ -114,7 +114,7 @@ void GdNavigationServer::MERGE(_cmd_, F_NAME)(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) GdNavigationServer::GdNavigationServer() : - NavigationServer(), + NavigationServer3D(), active(true) { } @@ -141,7 +141,7 @@ RID GdNavigationServer::map_create() const { COMMAND_2(map_set_active, RID, p_map, bool, p_active) { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND(map == NULL); + ERR_FAIL_COND(map == nullptr); if (p_active) { if (!map_is_active(p_map)) { @@ -154,84 +154,84 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) { bool GdNavigationServer::map_is_active(RID p_map) const { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, false); + ERR_FAIL_COND_V(map == nullptr, false); return active_maps.find(map) >= 0; } COMMAND_2(map_set_up, RID, p_map, Vector3, p_up) { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND(map == NULL); + ERR_FAIL_COND(map == nullptr); map->set_up(p_up); } Vector3 GdNavigationServer::map_get_up(RID p_map) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, Vector3()); + ERR_FAIL_COND_V(map == nullptr, Vector3()); return map->get_up(); } COMMAND_2(map_set_cell_size, RID, p_map, real_t, p_cell_size) { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND(map == NULL); + ERR_FAIL_COND(map == nullptr); map->set_cell_size(p_cell_size); } real_t GdNavigationServer::map_get_cell_size(RID p_map) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, 0); + ERR_FAIL_COND_V(map == nullptr, 0); return map->get_cell_size(); } COMMAND_2(map_set_edge_connection_margin, RID, p_map, real_t, p_connection_margin) { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND(map == NULL); + ERR_FAIL_COND(map == nullptr); map->set_edge_connection_margin(p_connection_margin); } real_t GdNavigationServer::map_get_edge_connection_margin(RID p_map) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, 0); + ERR_FAIL_COND_V(map == nullptr, 0); return map->get_edge_connection_margin(); } Vector<Vector3> GdNavigationServer::map_get_path(RID p_map, Vector3 p_origin, Vector3 p_destination, bool p_optimize) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, Vector<Vector3>()); + ERR_FAIL_COND_V(map == nullptr, Vector<Vector3>()); return map->get_path(p_origin, p_destination, p_optimize); } Vector3 GdNavigationServer::map_get_closest_point_to_segment(RID p_map, const Vector3 &p_from, const Vector3 &p_to, const bool p_use_collision) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, Vector3()); + ERR_FAIL_COND_V(map == nullptr, Vector3()); return map->get_closest_point_to_segment(p_from, p_to, p_use_collision); } Vector3 GdNavigationServer::map_get_closest_point(RID p_map, const Vector3 &p_point) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, Vector3()); + ERR_FAIL_COND_V(map == nullptr, Vector3()); return map->get_closest_point(p_point); } Vector3 GdNavigationServer::map_get_closest_point_normal(RID p_map, const Vector3 &p_point) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, Vector3()); + ERR_FAIL_COND_V(map == nullptr, Vector3()); return map->get_closest_point_normal(p_point); } RID GdNavigationServer::map_get_closest_point_owner(RID p_map, const Vector3 &p_point) const { const NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND_V(map == NULL, RID()); + ERR_FAIL_COND_V(map == nullptr, RID()); return map->get_closest_point_owner(p_point); } @@ -247,20 +247,20 @@ RID GdNavigationServer::region_create() const { COMMAND_2(region_set_map, RID, p_region, RID, p_map) { NavRegion *region = region_owner.getornull(p_region); - ERR_FAIL_COND(region == NULL); + ERR_FAIL_COND(region == nullptr); - if (region->get_map() != NULL) { + if (region->get_map() != nullptr) { if (region->get_map()->get_self() == p_map) return; // Pointless region->get_map()->remove_region(region); - region->set_map(NULL); + region->set_map(nullptr); } if (p_map.is_valid()) { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND(map == NULL); + ERR_FAIL_COND(map == nullptr); map->add_region(region); region->set_map(map); @@ -269,21 +269,21 @@ COMMAND_2(region_set_map, RID, p_region, RID, p_map) { COMMAND_2(region_set_transform, RID, p_region, Transform, p_transform) { NavRegion *region = region_owner.getornull(p_region); - ERR_FAIL_COND(region == NULL); + ERR_FAIL_COND(region == nullptr); region->set_transform(p_transform); } COMMAND_2(region_set_navmesh, RID, p_region, Ref<NavigationMesh>, p_nav_mesh) { NavRegion *region = region_owner.getornull(p_region); - ERR_FAIL_COND(region == NULL); + ERR_FAIL_COND(region == nullptr); region->set_mesh(p_nav_mesh); } void GdNavigationServer::region_bake_navmesh(Ref<NavigationMesh> r_mesh, Node *p_node) const { ERR_FAIL_COND(r_mesh.is_null()); - ERR_FAIL_COND(p_node == NULL); + ERR_FAIL_COND(p_node == nullptr); #ifndef _3D_DISABLED NavigationMeshGenerator::get_singleton()->clear(r_mesh); @@ -302,7 +302,7 @@ RID GdNavigationServer::agent_create() const { COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); if (agent->get_map()) { if (agent->get_map()->get_self() == p_map) @@ -311,11 +311,11 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) { agent->get_map()->remove_agent(agent); } - agent->set_map(NULL); + agent->set_map(nullptr); if (p_map.is_valid()) { NavMap *map = map_owner.getornull(p_map); - ERR_FAIL_COND(map == NULL); + ERR_FAIL_COND(map == nullptr); agent->set_map(map); map->add_agent(agent); @@ -328,82 +328,82 @@ COMMAND_2(agent_set_map, RID, p_agent, RID, p_map) { COMMAND_2(agent_set_neighbor_dist, RID, p_agent, real_t, p_dist) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->neighborDist_ = p_dist; } COMMAND_2(agent_set_max_neighbors, RID, p_agent, int, p_count) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->maxNeighbors_ = p_count; } COMMAND_2(agent_set_time_horizon, RID, p_agent, real_t, p_time) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->timeHorizon_ = p_time; } COMMAND_2(agent_set_radius, RID, p_agent, real_t, p_radius) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->radius_ = p_radius; } COMMAND_2(agent_set_max_speed, RID, p_agent, real_t, p_max_speed) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->maxSpeed_ = p_max_speed; } COMMAND_2(agent_set_velocity, RID, p_agent, Vector3, p_velocity) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->velocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z); } COMMAND_2(agent_set_target_velocity, RID, p_agent, Vector3, p_velocity) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->prefVelocity_ = RVO::Vector3(p_velocity.x, p_velocity.y, p_velocity.z); } COMMAND_2(agent_set_position, RID, p_agent, Vector3, p_position) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->position_ = RVO::Vector3(p_position.x, p_position.y, p_position.z); } COMMAND_2(agent_set_ignore_y, RID, p_agent, bool, p_ignore) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); agent->get_agent()->ignore_y_ = p_ignore; } bool GdNavigationServer::agent_is_map_changed(RID p_agent) const { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND_V(agent == NULL, false); + ERR_FAIL_COND_V(agent == nullptr, false); return agent->is_map_changed(); } COMMAND_4(agent_set_callback, RID, p_agent, Object *, p_receiver, StringName, p_method, Variant, p_udata) { RvoAgent *agent = agent_owner.getornull(p_agent); - ERR_FAIL_COND(agent == NULL); + ERR_FAIL_COND(agent == nullptr); - agent->set_callback(p_receiver == NULL ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata); + agent->set_callback(p_receiver == nullptr ? ObjectID() : p_receiver->get_instance_id(), p_method, p_udata); if (agent->get_map()) { - if (p_receiver == NULL) { + if (p_receiver == nullptr) { agent->get_map()->remove_agent_as_controlled(agent); } else { agent->get_map()->set_agent_as_controlled(agent); @@ -419,14 +419,14 @@ COMMAND_1(free, RID, p_object) { std::vector<NavRegion *> regions = map->get_regions(); for (size_t i(0); i < regions.size(); i++) { map->remove_region(regions[i]); - regions[i]->set_map(NULL); + regions[i]->set_map(nullptr); } // Remove any assigned agent std::vector<RvoAgent *> agents = map->get_agents(); for (size_t i(0); i < agents.size(); i++) { map->remove_agent(agents[i]); - agents[i]->set_map(NULL); + agents[i]->set_map(nullptr); } active_maps.erase(map); @@ -437,9 +437,9 @@ COMMAND_1(free, RID, p_object) { NavRegion *region = region_owner.getornull(p_object); // Removes this region from the map if assigned - if (region->get_map() != NULL) { + if (region->get_map() != nullptr) { region->get_map()->remove_region(region); - region->set_map(NULL); + region->set_map(nullptr); } region_owner.free(p_object); @@ -449,9 +449,9 @@ COMMAND_1(free, RID, p_object) { RvoAgent *agent = agent_owner.getornull(p_object); // Removes this agent from the map if assigned - if (agent->get_map() != NULL) { + if (agent->get_map() != nullptr) { agent->get_map()->remove_agent(agent); - agent->set_map(NULL); + agent->set_map(nullptr); } agent_owner.free(p_object); diff --git a/modules/gdnavigation/gd_navigation_server.h b/modules/gdnavigation/gd_navigation_server.h index e9f5c1ffe6..01d1a4fba9 100644 --- a/modules/gdnavigation/gd_navigation_server.h +++ b/modules/gdnavigation/gd_navigation_server.h @@ -33,7 +33,7 @@ #include "core/rid.h" #include "core/rid_owner.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" #include "nav_map.h" #include "nav_region.h" @@ -67,7 +67,7 @@ struct SetCommand { virtual void exec(GdNavigationServer *server) = 0; }; -class GdNavigationServer : public NavigationServer { +class GdNavigationServer : public NavigationServer3D { Mutex commands_mutex; /// Mutex used to make any operation threadsafe. Mutex operations_mutex; diff --git a/modules/gdnavigation/nav_map.cpp b/modules/gdnavigation/nav_map.cpp index 338e49eb9f..7e6a3f7a26 100644 --- a/modules/gdnavigation/nav_map.cpp +++ b/modules/gdnavigation/nav_map.cpp @@ -81,8 +81,8 @@ gd::PointKey NavMap::get_point_key(const Vector3 &p_pos) const { Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p_optimize) const { - const gd::Polygon *begin_poly = NULL; - const gd::Polygon *end_poly = NULL; + const gd::Polygon *begin_poly = nullptr; + const gd::Polygon *end_poly = nullptr; Vector3 begin_point; Vector3 end_point; float begin_d = 1e20; @@ -146,7 +146,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p open_list.push_back(0); - const gd::Polygon *reachable_end = NULL; + const gd::Polygon *reachable_end = nullptr; float reachable_d = 1e30; bool is_reachable = true; @@ -215,7 +215,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p // so use the further reachable polygon ERR_BREAK_MSG(is_reachable == false, "It's not expect to not find the most reachable polygons"); is_reachable = false; - if (reachable_end == NULL) { + if (reachable_end == nullptr) { // The path is not found and there is not a way out. break; } @@ -240,7 +240,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p open_list.clear(); open_list.push_back(0); - reachable_end = NULL; + reachable_end = nullptr; continue; } @@ -249,7 +249,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p least_cost_id = -1; float least_cost = 1e30; - for (auto element = open_list.front(); element != NULL; element = element->next()) { + for (auto element = open_list.front(); element != nullptr; element = element->next()) { gd::NavigationPoly *np = &navigation_polys[element->get()]; float cost = np->traveled_distance; #ifdef USE_ENTRY_POINT @@ -366,7 +366,7 @@ Vector<Vector3> NavMap::get_path(Vector3 p_origin, Vector3 p_destination, bool p p = &navigation_polys[p->prev_navigation_poly_id]; else // The end - p = NULL; + p = nullptr; } if (path[path.size() - 1] != begin_point) @@ -637,12 +637,12 @@ void NavMap::sync() { gd::Connection c; c.A = &poly; c.A_edge = p; - c.B = NULL; + c.B = nullptr; c.B_edge = -1; connections[ek] = c; - } else if (connection->get().B == NULL) { - CRASH_COND(connection->get().A == NULL); // Unreachable + } else if (connection->get().B == nullptr) { + CRASH_COND(connection->get().A == nullptr); // Unreachable // Connect the two Polygons by this edge connection->get().B = &poly; @@ -657,7 +657,7 @@ void NavMap::sync() { connection->get().B->edges[connection->get().B_edge].other_edge = connection->get().A_edge; } else { // The edge is already connected with another edge, skip. - ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem."); + ERR_PRINT("Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the Navigation3D's `cell_size` is different from the one used to generate the navigation mesh. This will cause navigation problem."); } } } @@ -667,8 +667,8 @@ void NavMap::sync() { free_edges.reserve(connections.size()); for (auto connection_element = connections.front(); connection_element; connection_element = connection_element->next()) { - if (connection_element->get().B == NULL) { - CRASH_COND(connection_element->get().A == NULL); // Unreachable + if (connection_element->get().B == nullptr) { + CRASH_COND(connection_element->get().A == nullptr); // Unreachable CRASH_COND(connection_element->get().A_edge < 0); // Unreachable // This is a free edge diff --git a/modules/gdnavigation/nav_region.cpp b/modules/gdnavigation/nav_region.cpp index 0215821305..b91376f761 100644 --- a/modules/gdnavigation/nav_region.cpp +++ b/modules/gdnavigation/nav_region.cpp @@ -37,7 +37,7 @@ */ NavRegion::NavRegion() : - map(NULL), + map(nullptr), polygons_dirty(true) { } @@ -71,7 +71,7 @@ void NavRegion::update_polygons() { polygons.clear(); polygons_dirty = false; - if (map == NULL) { + if (map == nullptr) { return; } diff --git a/modules/gdnavigation/nav_utils.h b/modules/gdnavigation/nav_utils.h index bdf9eb34a8..3401284c31 100644 --- a/modules/gdnavigation/nav_utils.h +++ b/modules/gdnavigation/nav_utils.h @@ -90,7 +90,7 @@ struct Edge { Edge() { this_edge = -1; - other_polygon = NULL; + other_polygon = nullptr; other_edge = -1; } }; @@ -119,8 +119,8 @@ struct Connection { int B_edge; Connection() { - A = NULL; - B = NULL; + A = nullptr; + B = nullptr; A_edge = -1; B_edge = -1; } diff --git a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp index 6238acfdc5..abaf73ba6a 100644 --- a/modules/gdnavigation/navigation_mesh_editor_plugin.cpp +++ b/modules/gdnavigation/navigation_mesh_editor_plugin.cpp @@ -40,7 +40,7 @@ void NavigationMeshEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } @@ -86,7 +86,7 @@ void NavigationMeshEditor::_clear_pressed() { void NavigationMeshEditor::edit(NavigationRegion3D *p_nav_region) { - if (p_nav_region == NULL || node == p_nav_region) { + if (p_nav_region == nullptr || node == p_nav_region) { return; } @@ -117,7 +117,7 @@ NavigationMeshEditor::NavigationMeshEditor() { err_dialog = memnew(AcceptDialog); add_child(err_dialog); - node = NULL; + node = nullptr; } NavigationMeshEditor::~NavigationMeshEditor() { @@ -142,7 +142,7 @@ void NavigationMeshEditorPlugin::make_visible(bool p_visible) { navigation_mesh_editor->hide(); navigation_mesh_editor->bake_hbox->hide(); - navigation_mesh_editor->edit(NULL); + navigation_mesh_editor->edit(nullptr); } } diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index ec19c7b8a3..acb4f0461f 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -60,7 +60,7 @@ #include "modules/gridmap/grid_map.h" #endif -NavigationMeshGenerator *NavigationMeshGenerator::singleton = NULL; +NavigationMeshGenerator *NavigationMeshGenerator::singleton = nullptr; void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) { p_verticies.push_back(p_vec3.x); @@ -405,7 +405,7 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( ERR_FAIL_COND(!rcBuildCompactHeightfield(&ctx, cfg.walkableHeight, cfg.walkableClimb, *hf, *chf)); rcFreeHeightField(hf); - hf = 0; + hf = nullptr; #ifdef TOOLS_ENABLED if (ep) @@ -452,9 +452,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( ERR_FAIL_COND(!rcBuildPolyMeshDetail(&ctx, *poly_mesh, *chf, cfg.detailSampleDist, cfg.detailSampleMaxError, *detail_mesh)); rcFreeCompactHeightfield(chf); - chf = 0; + chf = nullptr; rcFreeContourSet(cset); - cset = 0; + cset = nullptr; #ifdef TOOLS_ENABLED if (ep) @@ -464,9 +464,9 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh( _convert_detail_mesh_to_native_navigation_mesh(detail_mesh, p_nav_mesh); rcFreePolyMesh(poly_mesh); - poly_mesh = 0; + poly_mesh = nullptr; rcFreePolyMeshDetail(detail_mesh); - detail_mesh = 0; + detail_mesh = nullptr; } NavigationMeshGenerator *NavigationMeshGenerator::get_singleton() { @@ -485,7 +485,7 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) ERR_FAIL_COND(!p_nav_mesh.is_valid()); #ifdef TOOLS_ENABLED - EditorProgress *ep(NULL); + EditorProgress *ep(nullptr); if (Engine::get_singleton()->is_editor_hint()) { ep = memnew(EditorProgress("bake", TTR("Navigation Mesh Generator Setup:"), 11)); } @@ -515,11 +515,11 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) if (vertices.size() > 0 && indices.size() > 0) { - rcHeightfield *hf = NULL; - rcCompactHeightfield *chf = NULL; - rcContourSet *cset = NULL; - rcPolyMesh *poly_mesh = NULL; - rcPolyMeshDetail *detail_mesh = NULL; + rcHeightfield *hf = nullptr; + rcCompactHeightfield *chf = nullptr; + rcContourSet *cset = nullptr; + rcPolyMesh *poly_mesh = nullptr; + rcPolyMeshDetail *detail_mesh = nullptr; _build_recast_navigation_mesh( p_nav_mesh, @@ -535,19 +535,19 @@ void NavigationMeshGenerator::bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node) indices); rcFreeHeightField(hf); - hf = 0; + hf = nullptr; rcFreeCompactHeightfield(chf); - chf = 0; + chf = nullptr; rcFreeContourSet(cset); - cset = 0; + cset = nullptr; rcFreePolyMesh(poly_mesh); - poly_mesh = 0; + poly_mesh = nullptr; rcFreePolyMeshDetail(detail_mesh); - detail_mesh = 0; + detail_mesh = nullptr; } #ifdef TOOLS_ENABLED diff --git a/modules/gdnavigation/register_types.cpp b/modules/gdnavigation/register_types.cpp index d717733787..088b26bf17 100644 --- a/modules/gdnavigation/register_types.cpp +++ b/modules/gdnavigation/register_types.cpp @@ -32,7 +32,7 @@ #include "core/engine.h" #include "gd_navigation_server.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" #ifndef _3D_DISABLED #include "navigation_mesh_generator.h" @@ -47,15 +47,15 @@ */ #ifndef _3D_DISABLED -NavigationMeshGenerator *_nav_mesh_generator = NULL; +NavigationMeshGenerator *_nav_mesh_generator = nullptr; #endif -NavigationServer *new_server() { +NavigationServer3D *new_server() { return memnew(GdNavigationServer); } void register_gdnavigation_types() { - NavigationServerManager::set_default_server(new_server); + NavigationServer3DManager::set_default_server(new_server); #ifndef _3D_DISABLED _nav_mesh_generator = memnew(NavigationMeshGenerator); diff --git a/modules/gdnavigation/rvo_agent.cpp b/modules/gdnavigation/rvo_agent.cpp index 677e525bbf..3c39f02c26 100644 --- a/modules/gdnavigation/rvo_agent.cpp +++ b/modules/gdnavigation/rvo_agent.cpp @@ -37,7 +37,7 @@ */ RvoAgent::RvoAgent() : - map(NULL) { + map(nullptr) { callback.id = ObjectID(); } @@ -70,7 +70,7 @@ void RvoAgent::dispatch_callback() { return; } Object *obj = ObjectDB::get_instance(callback.id); - if (obj == NULL) { + if (obj == nullptr) { callback.id = ObjectID(); } diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub index 74e653ce43..e58a1d8edc 100644 --- a/modules/gdscript/SCsub +++ b/modules/gdscript/SCsub @@ -1,19 +1,19 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_gdscript = env_modules.Clone() env_gdscript.add_source_files(env.modules_sources, "*.cpp") -if env['tools']: +if env["tools"]: env_gdscript.add_source_files(env.modules_sources, "./editor/*.cpp") # Those two modules are required for the language server protocol - if env['module_jsonrpc_enabled'] and env['module_websocket_enabled']: + if env["module_jsonrpc_enabled"] and env["module_websocket_enabled"]: env_gdscript.add_source_files(env.modules_sources, "./language_server/*.cpp") else: # Using a define in the disabled case, to avoid having an extra define # in regular builds where all modules are enabled. - env_gdscript.Append(CPPDEFINES=['GDSCRIPT_NO_LSP']) + env_gdscript.Append(CPPDEFINES=["GDSCRIPT_NO_LSP"]) diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py index a525eedaaa..185a10bcb2 100644 --- a/modules/gdscript/config.py +++ b/modules/gdscript/config.py @@ -1,9 +1,11 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "@GDScript", @@ -12,5 +14,6 @@ def get_doc_classes(): "GDScriptNativeClass", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 2f6f9f30a4..9324691df5 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -90,14 +90,18 @@ </return> <argument index="0" name="condition" type="bool"> </argument> + <argument index="1" name="message" type="String" default=""""> + </argument> <description> - Asserts that the [code]condition[/code] is [code]true[/code] . If the [code]condition[/code] is [code]false[/code], an error is generated and the program is halted until you resume it. Only executes in debug builds, or when running the game from the editor. Use it for debugging purposes, to make sure a statement is [code]true[/code] during development. + Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated and the program is halted until you resume it. Only executes in debug builds, or when running the game from the editor. Use it for debugging purposes, to make sure a statement is [code]true[/code] during development. + The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed. [codeblock] # Imagine we always want speed to be between 0 and 20 speed = -10 assert(speed < 20) # True, the program will continue assert(speed >= 0) # False, the program will stop assert(speed >= 0 && speed < 20) # You can also combine the two conditional statements in one check + assert(speed < 20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details [/codeblock] </description> </method> @@ -1216,7 +1220,7 @@ <description> Returns whether the given class exists in [ClassDB]. [codeblock] - type_exists("Sprite") # Returns true + type_exists("Sprite2D") # Returns true type_exists("Variant") # Returns false [/codeblock] </description> diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 05e9f8652e..9a4fa5cc86 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -114,13 +114,13 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco if (r_error.error != Callable::CallError::CALL_OK) { instance->script = Ref<GDScript>(); - instance->owner->set_script_instance(NULL); + instance->owner->set_script_instance(nullptr); { MutexLock lock(GDScriptLanguage::singleton->lock); instances.erase(p_owner); } - ERR_FAIL_COND_V(r_error.error != Callable::CallError::CALL_OK, NULL); //error constructing + ERR_FAIL_COND_V(r_error.error != Callable::CallError::CALL_OK, nullptr); //error constructing } //@TODO make thread safe @@ -138,7 +138,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr r_error.error = Callable::CallError::CALL_OK; REF ref; - Object *owner = NULL; + Object *owner = nullptr; GDScript *_baseptr = this; while (_baseptr->_base) { @@ -158,7 +158,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Callable::CallErr ref = REF(r); } - GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); + GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != nullptr, r_error); if (!instance) { if (ref.is_null()) { memdelete(owner); //no owner, sorry @@ -318,12 +318,12 @@ ScriptInstance *GDScript::instance_create(Object *p_this) { if (EngineDebugger::is_active()) { GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"); } - ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + "."); + ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + "."); } } Callable::CallError unchecked_error; - return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error); + return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error); } PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) { @@ -333,7 +333,7 @@ PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) _update_exports(); return si; #else - return NULL; + return nullptr; #endif } @@ -688,7 +688,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p ERR_FAIL_COND_V_MSG(!E->get()->is_static(), Variant(), "Can't call non-static function '" + String(p_method) + "' in script."); - return E->get()->call(NULL, p_args, p_argcount, r_error); + return E->get()->call(nullptr, p_args, p_argcount, r_error); } top = top->_base; } @@ -938,9 +938,9 @@ GDScript::GDScript() : valid = false; subclass_count = 0; - initializer = NULL; - _base = NULL; - _owner = NULL; + initializer = nullptr; + _base = nullptr; + _owner = nullptr; tool = false; #ifdef TOOLS_ENABLED source_changed_cache = false; @@ -964,7 +964,7 @@ void GDScript::_save_orphaned_subclasses() { Vector<ClassRefWithName> weak_subclasses; // collect subclasses ObjectID and name for (Map<StringName, Ref<GDScript>>::Element *E = subclasses.front(); E; E = E->next()) { - E->get()->_owner = NULL; //bye, you are no longer owned cause I died + E->get()->_owner = nullptr; //bye, you are no longer owned cause I died ClassRefWithName subclass; subclass.id = E->get()->get_instance_id(); subclass.fully_qualified_name = E->get()->fully_qualified_name; @@ -1028,7 +1028,7 @@ void GDScript::_init_rpc_methods_properties() { if (sub_E) cscript = sub_E->get().ptr(); else - cscript = NULL; + cscript = nullptr; } // Sort so we are 100% that they are always the same. @@ -1120,7 +1120,7 @@ bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { if (E) { if (E->get().getter) { Callable::CallError err; - r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, NULL, 0, err); + r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, nullptr, 0, err); if (err.error == Callable::CallError::CALL_OK) { return true; } @@ -1194,7 +1194,7 @@ void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const if (E) { Callable::CallError err; - Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err); + Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), nullptr, 0, err); if (err.error == Callable::CallError::CALL_OK) { ERR_FAIL_COND_MSG(ret.get_type() != Variant::ARRAY, "Wrong type for _get_property_list, must be an array of dictionaries."); @@ -1351,7 +1351,7 @@ void GDScriptInstance::notification(int p_notification) { String GDScriptInstance::to_string(bool *r_valid) { if (has_method(CoreStringNames::get_singleton()->_to_string)) { Callable::CallError ce; - Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce); + Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) { if (ret.get_type() != Variant::STRING) { if (r_valid) @@ -1450,7 +1450,7 @@ void GDScriptInstance::reload_members() { } GDScriptInstance::GDScriptInstance() { - owner = NULL; + owner = nullptr; base_ref = false; } @@ -1464,7 +1464,7 @@ GDScriptInstance::~GDScriptInstance() { /************* SCRIPT LANGUAGE **************/ -GDScriptLanguage *GDScriptLanguage::singleton = NULL; +GDScriptLanguage *GDScriptLanguage::singleton = nullptr; String GDScriptLanguage::get_name() const { @@ -1900,7 +1900,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { "remotesync", "mastersync", "puppetsync", - 0 + nullptr }; const char **w = _reserved_words; @@ -1933,7 +1933,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b String source = f->get_as_utf8_string(); GDScriptParser parser; - parser.parse(source, p_path.get_base_dir(), true, p_path, false, NULL, true); + parser.parse(source, p_path.get_base_dir(), true, p_path, false, nullptr, true); if (parser.get_parse_tree() && parser.get_parse_tree()->type == GDScriptParser::Node::TYPE_CLASS) { @@ -1954,7 +1954,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b if (subclass->extends_file) { if (subclass->extends_class.size() == 0) { get_global_class_name(subclass->extends_file, r_base_type); - subclass = NULL; + subclass = nullptr; break; } else { Vector<StringName> extend_classes = subclass->extends_class; @@ -1973,7 +1973,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b subpath = path.get_base_dir().plus_file(subpath).simplify_path(); } - if (OK != subparser.parse(subsource, subpath.get_base_dir(), true, subpath, false, NULL, true)) { + if (OK != subparser.parse(subsource, subpath.get_base_dir(), true, subpath, false, nullptr, true)) { break; } path = subpath; @@ -1994,20 +1994,20 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b } } if (!found) { - subclass = NULL; + subclass = nullptr; break; } } } } else if (subclass->extends_class.size() == 1) { *r_base_type = subclass->extends_class[0]; - subclass = NULL; + subclass = nullptr; } else { break; } } else { *r_base_type = "Reference"; - subclass = NULL; + subclass = nullptr; } } } @@ -2168,7 +2168,7 @@ String GDScriptWarning::get_name_from_code(Code p_code) { "UNSAFE_CALL_ARGUMENT", "DEPRECATED_KEYWORD", "STANDALONE_TERNARY", - NULL + nullptr }; return names[(int)p_code]; @@ -2215,7 +2215,7 @@ GDScriptLanguage::GDScriptLanguage() { } else { _debug_max_call_stack = 0; - _call_stack = NULL; + _call_stack = nullptr; } #ifdef DEBUG_ENABLED @@ -2236,7 +2236,7 @@ GDScriptLanguage::~GDScriptLanguage() { if (_call_stack) { memdelete_arr(_call_stack); } - singleton = NULL; + singleton = nullptr; } void GDScriptLanguage::add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass) { @@ -2319,7 +2319,7 @@ void ResourceFormatLoaderGDScript::get_dependencies(const String &p_path, List<S } GDScriptParser parser; - if (OK != parser.parse(source, p_path.get_base_dir(), true, p_path, false, NULL, true)) { + if (OK != parser.parse(source, p_path.get_base_dir(), true, p_path, false, nullptr, true)) { return; } @@ -2363,5 +2363,5 @@ void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resourc } bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const { - return Object::cast_to<GDScript>(*p_resource) != NULL; + return Object::cast_to<GDScript>(*p_resource) != nullptr; } diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index 3fedc604bf..2c5876372b 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -260,7 +260,7 @@ public: virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; - virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const; + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const; virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName &p_method) const; @@ -483,7 +483,7 @@ public: virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; virtual bool is_using_templates(); virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script); - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; @@ -534,7 +534,7 @@ public: /* GLOBAL CLASSES */ virtual bool handles_global_class_type(const String &p_type) const; - virtual String get_global_class_name(const String &p_path, String *r_base_type = NULL, String *r_icon_path = NULL) const; + virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const; void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass); Ref<GDScript> get_orphan_subclass(const String &p_qualified_name); @@ -545,7 +545,7 @@ public: class ResourceFormatLoaderGDScript : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index fb514aab0c..2bbec29043 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -46,7 +46,7 @@ bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringN bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) { GDScript *scr = owner; - GDScriptNativeClass *nc = NULL; + GDScriptNativeClass *nc = nullptr; while (scr) { if (scr->native.is_valid()) @@ -265,7 +265,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: while (owner) { GDScript *scr = owner; - GDScriptNativeClass *nc = NULL; + GDScriptNativeClass *nc = nullptr; while (scr) { if (scr->constants.has(identifier)) { @@ -1700,14 +1700,14 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser gdfunc->_constant_count = codegen.constant_map.size(); gdfunc->constants.resize(codegen.constant_map.size()); gdfunc->_constants_ptr = gdfunc->constants.ptrw(); - const Variant *K = NULL; + const Variant *K = nullptr; while ((K = codegen.constant_map.next(K))) { int idx = codegen.constant_map[*K]; gdfunc->constants.write[idx] = *K; } } else { - gdfunc->_constants_ptr = NULL; + gdfunc->_constants_ptr = nullptr; gdfunc->_constant_count = 0; } //global names @@ -1722,7 +1722,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser gdfunc->_global_names_count = gdfunc->global_names.size(); } else { - gdfunc->_global_names_ptr = NULL; + gdfunc->_global_names_ptr = nullptr; gdfunc->_global_names_count = 0; } @@ -1746,7 +1746,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser } else { - gdfunc->_code_ptr = NULL; + gdfunc->_code_ptr = nullptr; gdfunc->_code_size = 0; } @@ -1757,7 +1757,7 @@ Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser gdfunc->_default_arg_ptr = &gdfunc->default_arguments[0]; } else { gdfunc->_default_arg_count = 0; - gdfunc->_default_arg_ptr = NULL; + gdfunc->_default_arg_ptr = nullptr; } gdfunc->_argument_count = p_func ? p_func->arguments.size() : 0; @@ -1838,7 +1838,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar p_script->native = Ref<GDScriptNativeClass>(); p_script->base = Ref<GDScript>(); - p_script->_base = NULL; + p_script->_base = nullptr; p_script->members.clear(); p_script->constants.clear(); for (Map<StringName, GDScriptFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) { @@ -1848,7 +1848,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar p_script->member_indices.clear(); p_script->member_info.clear(); p_script->_signals.clear(); - p_script->initializer = NULL; + p_script->initializer = nullptr; p_script->tool = p_class->tool; p_script->name = p_class->name; @@ -1962,7 +1962,7 @@ Error GDScriptCompiler::_parse_class_level(GDScript *p_script, const GDScriptPar if (c->base.is_valid()) { c = c->base.ptr(); } else { - c = NULL; + c = nullptr; } } @@ -2032,14 +2032,14 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa if (!has_initializer) { //create a constructor - Error err = _parse_function(p_script, p_class, NULL); + Error err = _parse_function(p_script, p_class, nullptr); if (err) return err; } if (!has_ready && p_class->ready->statements.size()) { //create a constructor - Error err = _parse_function(p_script, p_class, NULL, true); + Error err = _parse_function(p_script, p_class, nullptr, true); if (err) return err; } @@ -2077,7 +2077,7 @@ Error GDScriptCompiler::_parse_class_blocks(GDScript *p_script, const GDScriptPa /* STEP 2, INITIALIZE AND CONSTRUCT */ Callable::CallError ce; - p_script->initializer->call(instance, NULL, 0, ce); + p_script->initializer->call(instance, nullptr, 0, ce); if (ce.error != Callable::CallError::CALL_OK) { //well, tough luck, not goinna do anything here @@ -2162,7 +2162,7 @@ Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_scri // Create scripts for subclasses beforehand so they can be referenced _make_scripts(p_script, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state); - p_script->_owner = NULL; + p_script->_owner = nullptr; Error err = _parse_class_level(p_script, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state); if (err) diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 98e09159ec..1e3cbd661e 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -336,9 +336,9 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> * ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) { if (_debug_parse_err_line >= 0) - return NULL; + return nullptr; - ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, NULL); + ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, nullptr); int l = _debug_call_stack_pos - p_level - 1; ScriptInstance *instance = _call_stack[l].instance; @@ -430,6 +430,8 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const mi.name = "assert"; mi.return_val.type = Variant::NIL; mi.arguments.push_back(PropertyInfo(Variant::BOOL, "condition")); + mi.arguments.push_back(PropertyInfo(Variant::STRING, "message")); + mi.default_arguments.push_back(String()); p_functions->push_back(mi); } } @@ -499,10 +501,10 @@ struct GDScriptCompletionContext { uint32_t depth; GDScriptCompletionContext() : - _class(NULL), - function(NULL), - block(NULL), - base(NULL), + _class(nullptr), + function(nullptr), + block(nullptr), + base(nullptr), line(0), depth(0) {} }; @@ -514,7 +516,7 @@ struct GDScriptCompletionIdentifier { const GDScriptParser::Node *assigned_expression; GDScriptCompletionIdentifier() : - assigned_expression(NULL) {} + assigned_expression(nullptr) {} }; static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) { @@ -909,7 +911,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G Variant ret = mb->call(baseptr, (const Variant **)argptr.ptr(), argptr.size(), ce); if (ce.error == Callable::CallError::CALL_OK && ret.get_type() != Variant::NIL) { - if (ret.get_type() != Variant::OBJECT || ret.operator Object *() != NULL) { + if (ret.get_type() != Variant::OBJECT || ret.operator Object *() != nullptr) { r_type = _type_from_variant(ret); found = true; } @@ -963,7 +965,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G break; } - const GDScriptParser::DictionaryNode *dn = NULL; + const GDScriptParser::DictionaryNode *dn = nullptr; if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) { dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]); } else if (base.assigned_expression && base.assigned_expression->type == GDScriptParser::Node::TYPE_DICTIONARY) { @@ -1017,7 +1019,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G } // Look if it is a dictionary node - const GDScriptParser::DictionaryNode *dn = NULL; + const GDScriptParser::DictionaryNode *dn = nullptr; if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) { dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]); } else if (base.assigned_expression && base.assigned_expression->type == GDScriptParser::Node::TYPE_DICTIONARY) { @@ -1041,7 +1043,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G // Look if it is an array node if (!found && index.value.is_num()) { int idx = index.value; - const GDScriptParser::ArrayNode *an = NULL; + const GDScriptParser::ArrayNode *an = nullptr; if (op->arguments[0]->type == GDScriptParser::Node::TYPE_ARRAY) { an = static_cast<const GDScriptParser::ArrayNode *>(op->arguments[0]); } else if (base.assigned_expression && base.assigned_expression->type == GDScriptParser::Node::TYPE_ARRAY) { @@ -1061,7 +1063,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G found = _guess_identifier_type_from_base(c, base, id, r_type); } else if (!found && index.type.kind == GDScriptParser::DataType::BUILTIN) { Callable::CallError err; - Variant base_val = Variant::construct(base.type.builtin_type, NULL, 0, err); + Variant base_val = Variant::construct(base.type.builtin_type, nullptr, 0, err); bool valid = false; Variant res = base_val.get(index.value, &valid); if (valid) { @@ -1116,9 +1118,9 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G Callable::CallError ce; bool v1_use_value = p1.value.get_type() != Variant::NIL && p1.value.get_type() != Variant::OBJECT; - Variant v1 = (v1_use_value) ? p1.value : Variant::construct(p1.type.builtin_type, NULL, 0, ce); + Variant v1 = (v1_use_value) ? p1.value : Variant::construct(p1.type.builtin_type, nullptr, 0, ce); bool v2_use_value = p2.value.get_type() != Variant::NIL && p2.value.get_type() != Variant::OBJECT; - Variant v2 = (v2_use_value) ? p2.value : Variant::construct(p2.type.builtin_type, NULL, 0, ce); + Variant v2 = (v2_use_value) ? p2.value : Variant::construct(p2.type.builtin_type, nullptr, 0, ce); // avoid potential invalid ops if ((vop == Variant::OP_DIVIDE || vop == Variant::OP_MODULE) && v2.get_type() == Variant::INT) { v2 = 1; @@ -1173,7 +1175,7 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S // Look in blocks first const GDScriptParser::BlockNode *blk = p_context.block; int last_assign_line = -1; - const GDScriptParser::Node *last_assigned_expression = NULL; + const GDScriptParser::Node *last_assigned_expression = nullptr; GDScriptParser::DataType var_type; while (blk) { if (blk->variables.has(p_identifier)) { @@ -1227,7 +1229,7 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S r_type.type.is_meta_type = false; // Right-hand of `is` will be a meta type, but the left-hand value is not // Not an assignment, it shouldn't carry any value r_type.value = Variant(); - r_type.assigned_expression = NULL; + r_type.assigned_expression = nullptr; return true; } @@ -1271,8 +1273,8 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S return false; } GDScriptCompletionContext c = p_context; - c.function = NULL; - c.block = NULL; + c.function = nullptr; + c.block = nullptr; return _guess_expression_type(c, op->arguments[1], r_type); } } @@ -1534,7 +1536,7 @@ static bool _guess_identifier_type_from_base(GDScriptCompletionContext &p_contex } break; case GDScriptParser::DataType::BUILTIN: { Callable::CallError err; - Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err); + Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { return false; @@ -1612,7 +1614,7 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con for (int i = 0; i < base_type.class_type->static_functions.size(); i++) { if (base_type.class_type->static_functions[i]->name == p_method) { int last_return_line = -1; - const GDScriptParser::Node *last_returned_value = NULL; + const GDScriptParser::Node *last_returned_value = nullptr; GDScriptCompletionContext c = p_context; c._class = base_type.class_type; c.function = base_type.class_type->static_functions[i]; @@ -1629,7 +1631,7 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con for (int i = 0; i < base_type.class_type->functions.size(); i++) { if (base_type.class_type->functions[i]->name == p_method) { int last_return_line = -1; - const GDScriptParser::Node *last_returned_value = NULL; + const GDScriptParser::Node *last_returned_value = nullptr; GDScriptCompletionContext c = p_context; c._class = base_type.class_type; c.function = base_type.class_type->functions[i]; @@ -1704,7 +1706,7 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con } break; case GDScriptParser::DataType::BUILTIN: { Callable::CallError err; - Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err); + Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { return false; } @@ -1911,8 +1913,8 @@ static void _find_identifiers_in_class(const GDScriptCompletionContext &p_contex base_type.value = p_context.base; GDScriptCompletionContext c = p_context; - c.block = NULL; - c.function = NULL; + c.block = nullptr; + c.function = nullptr; _find_identifiers_in_base(c, base_type, p_only_functions, r_result); } @@ -1932,8 +1934,8 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context case GDScriptParser::DataType::CLASS: { GDScriptCompletionContext c = p_context; c._class = base_type.class_type; - c.block = NULL; - c.function = NULL; + c.block = nullptr; + c.function = nullptr; _find_identifiers_in_class(c, _static, p_only_functions, false, r_result); base_type = base_type.class_type->base_type; } break; @@ -2089,7 +2091,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context } break; case GDScriptParser::DataType::BUILTIN: { Callable::CallError err; - Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err); + Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { return; } @@ -2153,8 +2155,8 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p while (clss) { GDScriptCompletionContext c = p_context; c._class = clss; - c.block = NULL; - c.function = NULL; + c.block = nullptr; + c.function = nullptr; _find_identifiers_in_class(c, _static, p_only_functions, false, r_result); _static = true; clss = clss->owner; @@ -2188,7 +2190,7 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p "const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif", "else", "for", "pass", "return", "match", "while", "remote", "master", "puppet", "remotesync", "mastersync", "puppetsync", - 0 + nullptr }; const char **kw = _keywords; @@ -2373,7 +2375,7 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con case GDScriptParser::DataType::BUILTIN: { if (base.get_type() == Variant::NIL) { Callable::CallError err; - base = Variant::construct(base_type.builtin_type, NULL, 0, err); + base = Variant::construct(base_type.builtin_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { return; } @@ -2542,7 +2544,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path context.function = parser.get_completion_function(); context.line = parser.get_completion_line(); - if (!context._class || context._class->owner == NULL) { + if (!context._class || context._class->owner == nullptr) { context.base = p_owner; context.base_path = p_path.get_base_dir(); } @@ -2626,13 +2628,13 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path } GDScriptCompletionContext c = context; - c.function = NULL; - c.block = NULL; - c.base = base.value.get_type() == Variant::OBJECT ? base.value.operator Object *() : NULL; + c.function = nullptr; + c.block = nullptr; + c.base = base.value.get_type() == Variant::OBJECT ? base.value.operator Object *() : nullptr; if (base.type.kind == GDScriptParser::DataType::CLASS) { c._class = base.type.class_type; } else { - c._class = NULL; + c._class = nullptr; } _find_identifiers_in_base(c, base, is_function, options); @@ -2818,8 +2820,8 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path for (Map<StringName, GDScriptParser::ClassNode::Constant>::Element *E = clss->constant_expressions.front(); E; E = E->next()) { GDScriptCompletionIdentifier constant; GDScriptCompletionContext c = context; - c.function = NULL; - c.block = NULL; + c.function = nullptr; + c.block = nullptr; c.line = E->value().expression->line; if (_guess_expression_type(c, E->value().expression, constant)) { if (constant.type.has_type && constant.type.is_meta_type) { @@ -2887,9 +2889,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path } GDScriptCompletionContext c = context; - c._class = NULL; - c.function = NULL; - c.block = NULL; + c._class = nullptr; + c.function = nullptr; + c.block = nullptr; bool finding = true; index = index.right(index.find(".") + 1); while (index.find(".") != -1) { @@ -2917,8 +2919,8 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path GDScriptCompletionIdentifier constant; GDScriptCompletionContext c2 = context; c2._class = base_type.class_type; - c2.function = NULL; - c2.block = NULL; + c2.function = nullptr; + c2.block = nullptr; c2.line = E->value().expression->line; if (_guess_expression_type(c2, E->value().expression, constant)) { if (constant.type.has_type && constant.type.is_meta_type) { @@ -3220,7 +3222,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co v = v_ref; } else { Callable::CallError err; - v = Variant::construct(base_type.builtin_type, NULL, 0, err); + v = Variant::construct(base_type.builtin_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { break; } @@ -3440,7 +3442,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol // We cannot determine the exact nature of the identifier here // Otherwise these codes would work StringName enumName = ClassDB::get_integer_constant_enum("@GlobalScope", p_symbol, true); - if (enumName != NULL) { + if (enumName != nullptr) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM; r_result.class_name = "@GlobalScope"; r_result.class_member = enumName; diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 0721c25388..ca4d6f6de9 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -45,7 +45,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta #ifdef DEBUG_ENABLED if (unlikely(!p_instance)) { r_error = "Cannot access self without instance."; - return NULL; + return nullptr; } #endif return &self; @@ -58,7 +58,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta #ifdef DEBUG_ENABLED if (unlikely(!p_instance)) { r_error = "Cannot access member without instance."; - return NULL; + return nullptr; } #endif //member indexing is O(1) @@ -69,7 +69,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta //todo change to index! GDScript *s = p_script; #ifdef DEBUG_ENABLED - ERR_FAIL_INDEX_V(address, _global_names_count, NULL); + ERR_FAIL_INDEX_V(address, _global_names_count, nullptr); #endif const StringName *sn = &_global_names_ptr[address]; @@ -86,31 +86,31 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta s = s->_base; } - ERR_FAIL_V_MSG(NULL, "GDScriptCompiler bug."); + ERR_FAIL_V_MSG(nullptr, "GDScriptCompiler bug."); } break; case ADDR_TYPE_LOCAL_CONSTANT: { #ifdef DEBUG_ENABLED - ERR_FAIL_INDEX_V(address, _constant_count, NULL); + ERR_FAIL_INDEX_V(address, _constant_count, nullptr); #endif return &_constants_ptr[address]; } break; case ADDR_TYPE_STACK: case ADDR_TYPE_STACK_VARIABLE: { #ifdef DEBUG_ENABLED - ERR_FAIL_INDEX_V(address, _stack_size, NULL); + ERR_FAIL_INDEX_V(address, _stack_size, nullptr); #endif return &p_stack[address]; } break; case ADDR_TYPE_GLOBAL: { #ifdef DEBUG_ENABLED - ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), NULL); + ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), nullptr); #endif return &GDScriptLanguage::get_singleton()->get_global_array()[address]; } break; #ifdef TOOLS_ENABLED case ADDR_TYPE_NAMED_GLOBAL: { #ifdef DEBUG_ENABLED - ERR_FAIL_INDEX_V(address, _named_globals_count, NULL); + ERR_FAIL_INDEX_V(address, _named_globals_count, nullptr); #endif StringName id = _named_globals_ptr[address]; @@ -118,7 +118,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta return (Variant *)&GDScriptLanguage::get_singleton()->get_named_globals_map()[id]; } else { r_error = "Autoload singleton '" + String(id) + "' has been removed."; - return NULL; + return nullptr; } } break; #endif @@ -127,8 +127,8 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta } break; } - ERR_FAIL_V_MSG(NULL, "Bad code! (unknown addressing mode)."); - return NULL; + ERR_FAIL_V_MSG(nullptr, "Bad code! (unknown addressing mode)."); + return nullptr; } #ifdef DEBUG_ENABLED @@ -272,7 +272,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a Variant self; Variant static_ref; Variant retvalue; - Variant *stack = NULL; + Variant *stack = nullptr; Variant **call_args; int defarg = 0; @@ -358,7 +358,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a memnew_placement(&stack[i], Variant); } } else { - stack = NULL; + stack = nullptr; } if (_call_size) { @@ -366,12 +366,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a call_args = (Variant **)&aptr[sizeof(Variant) * _stack_size]; } else { - call_args = NULL; + call_args = nullptr; } } else { - stack = NULL; - call_args = NULL; + stack = nullptr; + call_args = nullptr; } if (p_instance) { @@ -490,7 +490,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a GET_VARIANT_PTR(dst, 3); #ifdef DEBUG_ENABLED - if (b->get_type() != Variant::OBJECT || b->operator Object *() == NULL) { + if (b->get_type() != Variant::OBJECT || b->operator Object *() == nullptr) { err_text = "Right operand of 'is' is not a class."; OPCODE_BREAK; @@ -498,7 +498,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #endif bool extends_ok = false; - if (a->get_type() == Variant::OBJECT && a->operator Object *() != NULL) { + if (a->get_type() == Variant::OBJECT && a->operator Object *() != nullptr) { #ifdef DEBUG_ENABLED bool was_freed; @@ -855,7 +855,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a OPCODE_BREAK; } - if (src->get_type() != Variant::NIL && src->operator Object *() != NULL) { + if (src->get_type() != Variant::NIL && src->operator Object *() != nullptr) { ScriptInstance *scr_inst = src->operator Object *()->get_script_instance(); if (!scr_inst) { @@ -960,7 +960,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a bool valid = false; - if (src->get_type() != Variant::NIL && src->operator Object *() != NULL) { + if (src->get_type() != Variant::NIL && src->operator Object *() != nullptr) { ScriptInstance *scr_inst = src->operator Object *()->get_script_instance(); @@ -1099,7 +1099,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a base->call_ptr(*methodname, (const Variant **)argptrs, argc, ret, err); } else { - base->call_ptr(*methodname, (const Variant **)argptrs, argc, NULL, err); + base->call_ptr(*methodname, (const Variant **)argptrs, argc, nullptr, err); } #ifdef DEBUG_ENABLED if (GDScriptLanguage::get_singleton()->profiling) { @@ -1137,7 +1137,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } #endif - //_call_func(NULL,base,*methodname,ip,argc,p_instance,stack); + //_call_func(nullptr,base,*methodname,ip,argc,p_instance,stack); ip += argc + 1; } DISPATCH_OPCODE; @@ -1216,7 +1216,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a const GDScript *gds = _script; - const Map<StringName, GDScriptFunction *>::Element *E = NULL; + const Map<StringName, GDScriptFunction *>::Element *E = nullptr; while (gds->base.ptr()) { gds = gds->base.ptr(); E = gds->member_functions.find(*methodname); @@ -1767,7 +1767,7 @@ GDScriptFunction::GDScriptFunction() : rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; name = "<anonymous>"; #ifdef DEBUG_ENABLED - _func_cname = NULL; + _func_cname = nullptr; { MutexLock lock(GDScriptLanguage::get_singleton()->lock); @@ -1834,7 +1834,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar bool GDScriptFunctionState::is_valid(bool p_extended_check) const { - if (function == NULL) + if (function == nullptr) return false; if (p_extended_check) { @@ -1859,7 +1859,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) { state.result = p_arg; Callable::CallError err; - Variant ret = function->call(NULL, NULL, 0, err, &state); + Variant ret = function->call(nullptr, nullptr, 0, err, &state); bool completed = true; @@ -1873,7 +1873,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) { } } - function = NULL; //cleaned up; + function = nullptr; //cleaned up; state.result = Variant(); if (completed) { @@ -1909,12 +1909,12 @@ void GDScriptFunctionState::_bind_methods() { GDScriptFunctionState::GDScriptFunctionState() { - function = NULL; + function = nullptr; } GDScriptFunctionState::~GDScriptFunctionState() { - if (function != NULL) { + if (function != nullptr) { //never called, deinitialize stack for (int i = 0; i < state.stack_size; i++) { Variant *v = (Variant *)&state.stack[sizeof(Variant) * i]; diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 0afffcac73..acfc0a95b4 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -105,7 +105,7 @@ struct GDScriptDataType { return false; } - Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : NULL; + Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : nullptr; bool valid = false; while (base.is_valid()) { if (base == script_type) { @@ -339,7 +339,7 @@ public: return default_arguments[p_idx]; } - Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = NULL); + Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = nullptr); _FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; } GDScriptFunction(); diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index aaa308f40f..9154d6eb89 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -858,7 +858,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ PackedByteArray barr; int len; - Error err = encode_variant(*p_args[0], NULL, len, full_objects); + Error err = encode_variant(*p_args[0], nullptr, len, full_objects); if (err) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; @@ -908,7 +908,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ Variant ret; { const uint8_t *r = varr.ptr(); - Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects); + Error err = decode_variant(ret, r, varr.size(), nullptr, allow_objects); if (err != OK) { r_ret = RTR("Not enough bytes for decoding bytes, or invalid format."); r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; @@ -1198,7 +1198,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ } } - r_ret = gdscr->_new(NULL, 0, r_error); + r_ret = gdscr->_new(nullptr, 0, r_error); GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance()); Ref<GDScript> gd_ref = ins->get_script(); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 7fcb2cc423..a99d4b96f7 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -242,7 +242,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s Vector<Expression> expression; - Node *expr = NULL; + Node *expr = nullptr; int op_line = tokenizer->get_token_line(); // when operators are created at the bottom, the line might have been changed (\n found) @@ -276,12 +276,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s Node *subexpr = _parse_expression(p_parent, p_static, p_allow_assign, p_parsing_constant); parenthesis--; if (!subexpr) - return NULL; + return nullptr; if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in expression"); - return NULL; + return nullptr; } tokenizer->advance(); @@ -318,7 +318,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (tokenizer->get_token_constant().get_type() != Variant::STRING) { _set_error("Expected string constant or identifier after '$' or '/'."); - return NULL; + return nullptr; } path += String(tokenizer->get_token_constant()); @@ -355,7 +355,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (path == "") { _set_error("Path expected after $."); - return NULL; + return nullptr; } OperatorNode *op = alloc_node<OperatorNode>(); @@ -427,7 +427,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s tokenizer->advance(); if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { _set_error("Expected '(' after 'preload'"); - return NULL; + return nullptr; } tokenizer->advance(); @@ -476,7 +476,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (!valid) { _set_error("expected string constant as 'preload' argument."); - return NULL; + return nullptr; } if (!path.is_abs_path() && base_path != "") @@ -485,7 +485,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (path == self_path) { _set_error("Can't preload itself (use 'get_script()')."); - return NULL; + return nullptr; } Ref<Resource> res; @@ -503,26 +503,26 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (!FileAccess::exists(path)) { _set_error("Can't preload resource at path: " + path); - return NULL; + return nullptr; } else if (ScriptCodeCompletionCache::get_singleton()) { res = ScriptCodeCompletionCache::get_singleton()->get_cached_resource(path); } } if (!res.is_valid()) { _set_error("Can't preload resource at path: " + path); - return NULL; + return nullptr; } } if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' after 'preload' path"); - return NULL; + return nullptr; } Ref<GDScript> gds = res; if (gds.is_valid() && !gds->is_valid()) { _set_error("Couldn't fully preload the script, possible cyclic reference or compilation error. Use \"load()\" instead if a cyclic reference is intended."); - return NULL; + return nullptr; } tokenizer->advance(); @@ -536,7 +536,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (!current_function) { _set_error("\"yield()\" can only be used inside function blocks."); - return NULL; + return nullptr; } current_function->has_yield = true; @@ -544,7 +544,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s tokenizer->advance(); if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { _set_error("Expected \"(\" after \"yield\"."); - return NULL; + return nullptr; } tokenizer->advance(); @@ -565,12 +565,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s Node *object = _parse_and_reduce_expression(p_parent, p_static); if (!object) - return NULL; + return nullptr; yield->arguments.push_back(object); if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { _set_error("Expected \",\" after the first argument of \"yield\"."); - return NULL; + return nullptr; } tokenizer->advance(); @@ -591,12 +591,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s Node *signal = _parse_and_reduce_expression(p_parent, p_static); if (!signal) - return NULL; + return nullptr; yield->arguments.push_back(signal); if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected \")\" after the second argument of \"yield\"."); - return NULL; + return nullptr; } parenthesis--; @@ -610,7 +610,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (p_static) { _set_error("\"self\" isn't allowed in a static function or constant expression."); - return NULL; + return nullptr; } //constant defined by tokenizer SelfNode *self = alloc_node<SelfNode>(); @@ -631,7 +631,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (identifier == StringName()) { _set_error("Built-in type constant or static function expected after \".\"."); - return NULL; + return nullptr; } if (!Variant::has_constant(bi_type, identifier)) { @@ -657,7 +657,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s op->arguments.push_back(id); if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant)) - return NULL; + return nullptr; expr = op; } else { @@ -674,7 +674,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s } if (!valid) { _set_error("Static constant '" + identifier.operator String() + "' not present in built-in type " + Variant::get_type_name(bi_type) + "."); - return NULL; + return nullptr; } } } else { @@ -749,7 +749,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s } if (!replaced) { if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant)) - return NULL; + return nullptr; expr = op; } } else if (tokenizer->is_token_literal(0, true)) { @@ -789,7 +789,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (lv->assignments == 0) { if (!lv->datatype.has_type) { _set_error("Using assignment with operation on a variable that was never assigned."); - return NULL; + return nullptr; } _add_warning(GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, -1, identifier.operator String()); } @@ -912,7 +912,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT) { _set_error("Misplaced 'not'."); - return NULL; + return nullptr; } expression.push_back(e); @@ -921,7 +921,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s /* Node *subexpr=_parse_expression(op,p_static); if (!subexpr) - return NULL; + return nullptr; op->arguments.push_back(subexpr); expr=op;*/ @@ -929,7 +929,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s // 'is' operator with built-in type if (!expr) { _set_error("Expected identifier before 'is' operator"); - return NULL; + return nullptr; } OperatorNode *op = alloc_node<OperatorNode>(); op->op = OperatorNode::OP_IS_BUILTIN; @@ -955,7 +955,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { _set_error("Unterminated array"); - return NULL; + return nullptr; } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) { tokenizer->advance(); @@ -966,7 +966,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { if (!expecting_comma) { _set_error("expression or ']' expected"); - return NULL; + return nullptr; } expecting_comma = false; @@ -975,11 +975,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s //parse expression if (expecting_comma) { _set_error("',' or ']' expected"); - return NULL; + return nullptr; } Node *n = _parse_expression(arr, p_static, p_allow_assign, p_parsing_constant); if (!n) - return NULL; + return nullptr; arr->elements.push_back(n); expecting_comma = true; } @@ -1001,7 +1001,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s }; - Node *key = NULL; + Node *key = nullptr; Set<Variant> keys; DictExpect expecting = DICT_EXPECT_KEY; @@ -1011,17 +1011,17 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { _set_error("Unterminated dictionary"); - return NULL; + return nullptr; } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { if (expecting == DICT_EXPECT_COLON) { _set_error("':' expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_VALUE) { _set_error("value expected"); - return NULL; + return nullptr; } tokenizer->advance(); break; @@ -1032,15 +1032,15 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expecting == DICT_EXPECT_KEY) { _set_error("key or '}' expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_VALUE) { _set_error("value expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_COLON) { _set_error("':' expected"); - return NULL; + return nullptr; } expecting = DICT_EXPECT_KEY; @@ -1050,15 +1050,15 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expecting == DICT_EXPECT_KEY) { _set_error("key or '}' expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_VALUE) { _set_error("value expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_COMMA) { _set_error("',' or '}' expected"); - return NULL; + return nullptr; } expecting = DICT_EXPECT_VALUE; @@ -1067,11 +1067,11 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expecting == DICT_EXPECT_COMMA) { _set_error("',' or '}' expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_COLON) { _set_error("':' expected"); - return NULL; + return nullptr; } if (expecting == DICT_EXPECT_KEY) { @@ -1089,7 +1089,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s //python/js style more flexible key = _parse_expression(dict, p_static, p_allow_assign, p_parsing_constant); if (!key) - return NULL; + return nullptr; expecting = DICT_EXPECT_COLON; } } @@ -1097,7 +1097,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expecting == DICT_EXPECT_VALUE) { Node *value = _parse_expression(dict, p_static, p_allow_assign, p_parsing_constant); if (!value) - return NULL; + return nullptr; expecting = DICT_EXPECT_COMMA; if (key->type == GDScriptParser::Node::TYPE_CONSTANT) { @@ -1105,7 +1105,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (keys.has(keyName)) { _set_error("Duplicate key found in Dictionary literal"); - return NULL; + return nullptr; } keys.insert(keyName); } @@ -1114,7 +1114,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s pair.key = key; pair.value = value; dict->elements.push_back(pair); - key = NULL; + key = nullptr; } } } @@ -1142,12 +1142,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { if (!is_completion) { _set_error("Expected '(' for parent function call."); - return NULL; + return nullptr; } } else { tokenizer->advance(); if (!_parse_arguments(op, op->arguments, p_static, false, p_parsing_constant)) { - return NULL; + return nullptr; } } @@ -1166,10 +1166,10 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s //find list [ or find dictionary { _set_error("Error parsing expression, misplaced: " + String(tokenizer->get_token_name(tokenizer->get_token()))); - return NULL; //nothing + return nullptr; //nothing } - ERR_FAIL_COND_V_MSG(!expr, NULL, "GDScriptParser bug, couldn't figure out what expression is."); + ERR_FAIL_COND_V_MSG(!expr, nullptr, "GDScriptParser bug, couldn't figure out what expression is."); /******************/ /* Parse Indexing */ @@ -1186,7 +1186,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (tokenizer->get_token(1) != GDScriptTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) { // We check with is_token_literal, as this allows us to use match/sync/etc. as a name _set_error("Expected identifier as member"); - return NULL; + return nullptr; } else if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { //call!! OperatorNode *op = alloc_node<OperatorNode>(); @@ -1212,7 +1212,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s completion_node = op; } if (!_parse_arguments(op, op->arguments, p_static, true, p_parsing_constant)) - return NULL; + return nullptr; expr = op; } else { @@ -1251,12 +1251,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s Node *subexpr = _parse_expression(op, p_static, p_allow_assign, p_parsing_constant); if (!subexpr) { - return NULL; + return nullptr; } if (tokenizer->get_token() != GDScriptTokenizer::TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } op->arguments.push_back(expr); @@ -1276,12 +1276,12 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_AS) { if (has_casting) { _set_error("Unexpected 'as'."); - return NULL; + return nullptr; } CastNode *cn = alloc_node<CastNode>(); if (!_parse_type(cn->cast_type)) { _set_error("Expected type after 'as'."); - return NULL; + return nullptr; } has_casting = true; cn->source_node = expr; @@ -1313,7 +1313,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s #define _VALIDATE_ASSIGN \ if (!p_allow_assign || has_casting) { \ _set_error("Unexpected assign."); \ - return NULL; \ + return nullptr; \ } \ p_allow_assign = false; @@ -1479,7 +1479,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s default: { _set_error("GDScriptParser bug, invalid operator in expression: " + itos(expression[i].op)); - return NULL; + return nullptr; } } @@ -1488,7 +1488,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s // <= is used for right to left if (error) { _set_error("Unexpected operator"); - return NULL; + return nullptr; } next_op = i; min_priority = priority; @@ -1500,7 +1500,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (next_op == -1) { _set_error("Yet another parser bug...."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } // OK! create operator.. @@ -1513,7 +1513,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expr_pos == expression.size()) { //can happen.. _set_error("Unexpected end of expression..."); - return NULL; + return nullptr; } } @@ -1532,16 +1532,16 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s } else if (is_ternary) { if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (next_op >= (expression.size() - 2) || expression[next_op + 2].op != OperatorNode::OP_TERNARY_ELSE) { _set_error("Expected else after ternary if."); - return NULL; + return nullptr; } if (next_op >= (expression.size() - 3)) { _set_error("Expected value after ternary else."); - return NULL; + return nullptr; } OperatorNode *op = alloc_node<OperatorNode>(); @@ -1551,7 +1551,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expression[next_op - 1].is_op) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (expression[next_op + 1].is_op) { @@ -1561,7 +1561,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s // due to how precedence works, unaries will always disappear first _set_error("Unexpected two consecutive operators after ternary if."); - return NULL; + return nullptr; } if (expression[next_op + 3].is_op) { @@ -1571,7 +1571,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s // due to how precedence works, unaries will always disappear first _set_error("Unexpected two consecutive operators after ternary else."); - return NULL; + return nullptr; } op->arguments.push_back(expression[next_op + 1].node); //next expression goes as first @@ -1588,7 +1588,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } OperatorNode *op = alloc_node<OperatorNode>(); @@ -1598,7 +1598,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s if (expression[next_op - 1].is_op) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (expression[next_op + 1].is_op) { @@ -1608,7 +1608,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s // due to how precedence works, unaries will always disappear first _set_error("Unexpected two consecutive operators."); - return NULL; + return nullptr; } op->arguments.push_back(expression[next_op - 1].node); //expression goes as left @@ -1725,7 +1725,7 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDScriptFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) { //native type constructor or intrinsic function - const Variant **vptr = NULL; + const Variant **vptr = nullptr; Vector<Variant *> ptrs; if (op->arguments.size() > 1) { @@ -2015,10 +2015,10 @@ GDScriptParser::Node *GDScriptParser::_parse_and_reduce_expression(Node *p_paren Node *expr = _parse_expression(p_parent, p_static, p_allow_assign, p_reduce_const); if (!expr || error_set) - return NULL; + return nullptr; expr = _reduce_expression(expr, p_reduce_const); if (!expr || error_set) - return NULL; + return nullptr; return expr; } @@ -2046,10 +2046,10 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { GDScriptTokenizer::Token token = tokenizer->get_token(); if (error_set) - return NULL; + return nullptr; if (token == GDScriptTokenizer::TK_EOF) { - return NULL; + return nullptr; } switch (token) { @@ -2078,13 +2078,13 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { break; } else { _set_error("'..' pattern only allowed at the end of an array pattern"); - return NULL; + return nullptr; } } PatternNode *sub_pattern = _parse_pattern(p_static); if (!sub_pattern) { - return NULL; + return nullptr; } pattern->array.push_back(sub_pattern); @@ -2097,7 +2097,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { break; } else { _set_error("Not a valid pattern"); - return NULL; + return nullptr; } } } break; @@ -2106,7 +2106,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { tokenizer->advance(); if (!tokenizer->is_token_literal()) { _set_error("Expected identifier for binding variable name."); - return NULL; + return nullptr; } pattern->pt_type = GDScriptParser::PatternNode::PT_BIND; pattern->bind = tokenizer->get_token_literal(); @@ -2115,7 +2115,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { while (bl) { if (bl->variables.has(pattern->bind)) { _set_error("Binding name of '" + pattern->bind.operator String() + "' is already declared in this scope."); - return NULL; + return nullptr; } bl = bl->parent_block; } @@ -2150,19 +2150,19 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { break; } else { _set_error("'..' pattern only allowed at the end of a dictionary pattern"); - return NULL; + return nullptr; } } Node *key = _parse_and_reduce_expression(pattern, p_static); if (!key) { _set_error("Not a valid key in pattern"); - return NULL; + return nullptr; } if (key->type != GDScriptParser::Node::TYPE_CONSTANT) { _set_error("Not a constant expression as key"); - return NULL; + return nullptr; } if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) { @@ -2171,12 +2171,12 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { PatternNode *value = _parse_pattern(p_static); if (!value) { _set_error("Expected pattern in dictionary value"); - return NULL; + return nullptr; } pattern->dictionary.insert(static_cast<ConstantNode *>(key), value); } else { - pattern->dictionary.insert(static_cast<ConstantNode *>(key), NULL); + pattern->dictionary.insert(static_cast<ConstantNode *>(key), nullptr); } if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { @@ -2187,7 +2187,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { break; } else { _set_error("Not a valid pattern"); - return NULL; + return nullptr; } } } break; @@ -2200,7 +2200,7 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { Node *value = _parse_and_reduce_expression(pattern, p_static); if (!value) { _set_error("Expect constant expression or variables in a pattern"); - return NULL; + return nullptr; } if (value->type == Node::TYPE_OPERATOR) { @@ -2212,19 +2212,19 @@ GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { if (op_node->op != OperatorNode::OP_INDEX_NAMED) { _set_error("Invalid operator in pattern. Only index (`A.B`) is allowed"); - return NULL; + return nullptr; } current_value = op_node->arguments[0]; } if (current_value->type != Node::TYPE_IDENTIFIER) { _set_error("Only constant expression or variables allowed in a pattern"); - return NULL; + return nullptr; } } else if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { _set_error("Only constant expressions or variables allowed in a pattern"); - return NULL; + return nullptr; } pattern->pt_type = PatternNode::PT_CONSTANT; @@ -2332,7 +2332,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m return; } - OperatorNode *type_comp = NULL; + OperatorNode *type_comp = nullptr; // static type check if possible if (pattern_type.has_type && to_match_type.has_type) { @@ -2402,7 +2402,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m // typeof(value_to_match) == TYPE_ARRAY && value_to_match.size() == length { - OperatorNode *type_comp = NULL; + OperatorNode *type_comp = nullptr; // static type check if possible if (to_match_type.has_type) { // must be an array @@ -2461,7 +2461,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m for (int i = 0; i < p_pattern->array.size(); i++) { PatternNode *pattern = p_pattern->array[i]; - Node *condition = NULL; + Node *condition = nullptr; ConstantNode *index = alloc_node<ConstantNode>(); index->value = Variant(i); @@ -2495,7 +2495,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m // typeof(value_to_match) == TYPE_DICTIONARY && value_to_match.size() == length { - OperatorNode *type_comp = NULL; + OperatorNode *type_comp = nullptr; // static type check if possible if (to_match_type.has_type) { // must be an dictionary @@ -2553,7 +2553,7 @@ void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_m for (Map<ConstantNode *, PatternNode *>::Element *e = p_pattern->dictionary.front(); e; e = e->next()) { - Node *condition = NULL; + Node *condition = nullptr; // check for has, then for pattern @@ -2629,7 +2629,7 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) { PatternBranchNode *branch = p_match_statement->branches[i]; MatchNode::CompiledPatternBranch compiled_branch; - compiled_branch.compiled_pattern = NULL; + compiled_branch.compiled_pattern = nullptr; Map<StringName, Node *> binding; @@ -2638,7 +2638,7 @@ void GDScriptParser::_transform_match_statment(MatchNode *p_match_statement) { _mark_line_as_safe(pattern->line); Map<StringName, Node *> bindings; - Node *resulting_node = NULL; + Node *resulting_node = nullptr; _generate_pattern(pattern, id, resulting_node, bindings); if (!resulting_node) { @@ -2838,7 +2838,7 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) { lv->line = var_line; p_block->statements.push_back(lv); - Node *assigned = NULL; + Node *assigned = nullptr; if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) { if (tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) { @@ -3113,7 +3113,6 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) { } } else { constant = false; - break; } } @@ -3935,7 +3934,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { current_function = function; Node *arg = _parse_and_reduce_expression(p_class, _static); - current_function = NULL; + current_function = nullptr; cparent->arguments.push_back(arg); if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { @@ -3990,7 +3989,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { function->body = block; current_block = block; _parse_block(block, _static); - current_block = NULL; + current_block = nullptr; //arguments } break; @@ -4736,7 +4735,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { } member.identifier = tokenizer->get_token_literal(); - member.expression = NULL; + member.expression = nullptr; member._export.name = member.identifier; member.line = tokenizer->get_token_line(); member.usages = 0; @@ -4816,7 +4815,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { #ifdef TOOLS_ENABLED Callable::CallError ce; - member.default_value = Variant::construct(member._export.type, NULL, 0, ce); + member.default_value = Variant::construct(member._export.type, nullptr, 0, ce); #endif if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) { @@ -4869,7 +4868,7 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { if (cn->value.get_type() == Variant::OBJECT) { Object *obj = cn->value; Resource *res = Object::cast_to<Resource>(obj); - if (res == NULL) { + if (res == nullptr) { _set_error("The exported constant isn't a type or resource."); return; } @@ -5257,7 +5256,7 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive Ref<GDScript> script; StringName native; - ClassNode *base_class = NULL; + ClassNode *base_class = nullptr; if (path != "") { //path (and optionally subclasses) @@ -5319,7 +5318,7 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive _set_error("The class \"" + base + "\" couldn't be fully loaded (script error or cyclic dependency).", p_class->line); return; } - p = NULL; + p = nullptr; } else { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); @@ -5342,7 +5341,7 @@ void GDScriptParser::_determine_inheritance(ClassNode *p_class, bool p_recursive _set_error("Class '" + base + "' could not be fully loaded (script error or cyclic inheritance).", p_class->line); return; } - p = NULL; + p = nullptr; } } } @@ -5662,7 +5661,7 @@ GDScriptParser::DataType GDScriptParser::_resolve_type(const DataType &p_source, StringName id = full_name[name_part]; DataType base_type = result; - ClassNode *p = NULL; + ClassNode *p = nullptr; if (name_part == 0) { if (ScriptServer::is_global_class(id)) { String script_path = ScriptServer::get_global_class_path(id); @@ -5944,7 +5943,7 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper a = a_ref; } else { Callable::CallError err; - a = Variant::construct(a_type, NULL, 0, err); + a = Variant::construct(a_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { r_valid = false; return DataType(); @@ -5957,7 +5956,7 @@ GDScriptParser::DataType GDScriptParser::_get_operation_type(const Variant::Oper b = b_ref; } else { Callable::CallError err; - b = Variant::construct(b_type, NULL, 0, err); + b = Variant::construct(b_type, nullptr, 0, err); if (err.error != Callable::CallError::CALL_OK) { r_valid = false; return DataType(); @@ -6118,7 +6117,7 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data StringName expr_native; Ref<Script> expr_script; - ClassNode *expr_class = NULL; + ClassNode *expr_class = nullptr; switch (p_expression.kind) { case DataType::NATIVE: { @@ -6229,7 +6228,7 @@ GDScriptParser::Node *GDScriptParser::_get_default_value_for_type(const DataType } else { ConstantNode *c = alloc_node<ConstantNode>(); Callable::CallError err; - c->value = Variant::construct(p_type.builtin_type, NULL, 0, err); + c->value = Variant::construct(p_type.builtin_type, nullptr, 0, err); result = c; } } else { @@ -6308,7 +6307,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { int idx = current_function->arguments.find(id->name); node_type = current_function->argument_types[idx]; } else { - node_type = _reduce_identifier_type(NULL, id->name, id->line, false); + node_type = _reduce_identifier_type(nullptr, id->name, id->line, false); } } break; case Node::TYPE_CAST: { @@ -6542,7 +6541,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { } break; default: { Callable::CallError err; - Variant temp = Variant::construct(base_type.builtin_type, NULL, 0, err); + Variant temp = Variant::construct(base_type.builtin_type, nullptr, 0, err); bool valid = false; Variant res = temp.get(member_id->name.operator String(), &valid); @@ -6671,7 +6670,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { } default: { Callable::CallError err; - Variant temp = Variant::construct(base_type.builtin_type, NULL, 0, err); + Variant temp = Variant::construct(base_type.builtin_type, nullptr, 0, err); bool valid = false; Variant res = temp.get(cn->value, &valid); @@ -6778,8 +6777,8 @@ bool GDScriptParser::_get_function_signature(DataType &p_base_type, const String r_default_arg_count = 0; DataType original_type = p_base_type; - ClassNode *base = NULL; - FunctionNode *callee = NULL; + ClassNode *base = nullptr; + FunctionNode *callee = nullptr; if (p_base_type.kind == DataType::CLASS) { base = p_base_type.class_type; @@ -7112,7 +7111,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_function_call_type(const Operat if (base_type.kind == DataType::BUILTIN) { Callable::CallError err; - Variant tmp = Variant::construct(base_type.builtin_type, NULL, 0, err); + Variant tmp = Variant::construct(base_type.builtin_type, nullptr, 0, err); if (check_types) { if (!tmp.has_method(callee_name)) { @@ -7276,7 +7275,7 @@ bool GDScriptParser::_get_member_type(const DataType &p_base_type, const StringN DataType base_type = p_base_type; // Check classes in current file - ClassNode *base = NULL; + ClassNode *base = nullptr; if (base_type.kind == DataType::CLASS) { base = base_type.class_type; } @@ -7994,8 +7993,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) { current_block = current_function->body; _mark_line_as_safe(current_function->line); _check_block_types(current_block); - current_block = NULL; - current_function = NULL; + current_block = nullptr; + current_function = nullptr; if (error_set) return; } @@ -8004,8 +8003,8 @@ void GDScriptParser::_check_class_blocks_types(ClassNode *p_class) { current_block = current_function->body; _mark_line_as_safe(current_function->line); _check_block_types(current_block); - current_block = NULL; - current_function = NULL; + current_block = nullptr; + current_function = nullptr; if (error_set) return; } @@ -8054,7 +8053,7 @@ static String _find_function_name(const GDScriptParser::OperatorNode *p_call) { void GDScriptParser::_check_block_types(BlockNode *p_block) { - Node *last_var_assign = NULL; + Node *last_var_assign = nullptr; // Check each statement for (List<Node *>::Element *E = p_block->statements.front(); E; E = E->next()) { @@ -8445,7 +8444,7 @@ void GDScriptParser::_add_warning(int p_code, int p_line, const Vector<String> & warn.symbols = p_symbols; warn.line = p_line == -1 ? tokenizer->get_token_line() : p_line; - List<GDScriptWarning>::Element *before = NULL; + List<GDScriptWarning>::Element *before = nullptr; for (List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) { if (E->get().line > warn.line) { break; @@ -8512,8 +8511,8 @@ Error GDScriptParser::_parse(const String &p_base_path) { } current_class = main_class; - current_function = NULL; - current_block = NULL; + current_function = nullptr; + current_block = nullptr; if (for_completion) check_types = false; @@ -8576,7 +8575,7 @@ Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const St tokenizer = tb; Error ret = _parse(p_base_path); memdelete(tb); - tokenizer = NULL; + tokenizer = nullptr; return ret; } @@ -8597,7 +8596,7 @@ Error GDScriptParser::parse(const String &p_code, const String &p_base_path, boo tokenizer = tt; Error ret = _parse(p_base_path); memdelete(tt); - tokenizer = NULL; + tokenizer = nullptr; return ret; } @@ -8620,21 +8619,21 @@ void GDScriptParser::clear() { memdelete(l); } - head = NULL; - list = NULL; + head = nullptr; + list = nullptr; completion_type = COMPLETION_NONE; - completion_node = NULL; - completion_class = NULL; - completion_function = NULL; - completion_block = NULL; - current_block = NULL; - current_class = NULL; + completion_node = nullptr; + completion_class = nullptr; + completion_function = nullptr; + completion_block = nullptr; + current_block = nullptr; + current_class = nullptr; completion_found = false; rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED; - current_function = NULL; + current_function = nullptr; validating = false; for_completion = false; @@ -8651,7 +8650,7 @@ void GDScriptParser::clear() { dependencies.clear(); error = ""; #ifdef DEBUG_ENABLED - safe_lines = NULL; + safe_lines = nullptr; #endif // DEBUG_ENABLED } @@ -8707,9 +8706,9 @@ int GDScriptParser::get_completion_identifier_is_function() { GDScriptParser::GDScriptParser() { - head = NULL; - list = NULL; - tokenizer = NULL; + head = nullptr; + list = nullptr; + tokenizer = nullptr; pending_newline = -1; clear(); } diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index c74d7dd856..eca5f83f7a 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -102,7 +102,7 @@ public: infer_type(false), may_yield(false), builtin_type(Variant::NIL), - class_type(NULL) {} + class_type(nullptr) {} }; struct Node { @@ -201,7 +201,7 @@ public: extends_used = false; classname_used = false; end_line = -1; - owner = NULL; + owner = nullptr; } }; @@ -248,11 +248,11 @@ public: List<BlockNode *> sub_blocks; int end_line; BlockNode() { - if_condition = NULL; + if_condition = nullptr; type = TYPE_BLOCK; end_line = -1; - parent_block = NULL; - parent_class = NULL; + parent_block = nullptr; + parent_class = nullptr; has_return = false; } }; @@ -276,7 +276,7 @@ public: virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; } IdentifierNode() { type = TYPE_IDENTIFIER; - declared_block = NULL; + declared_block = nullptr; } }; @@ -292,8 +292,8 @@ public: virtual void set_datatype(const DataType &p_datatype) { datatype = p_datatype; } LocalVarNode() { type = TYPE_LOCAL_VAR; - assign = NULL; - assign_op = NULL; + assign = nullptr; + assign_op = nullptr; assignments = 0; usages = 0; } @@ -465,8 +465,8 @@ public: ControlFlowNode() { type = TYPE_CONTROL_FLOW; cf_type = CF_IF; - body = NULL; - body_else = NULL; + body = nullptr; + body_else = nullptr; } }; @@ -608,7 +608,7 @@ private: bool _recover_from_completion(); bool _parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete = false, bool p_parsing_constant = false); - bool _enter_indent_block(BlockNode *p_block = NULL); + bool _enter_indent_block(BlockNode *p_block = nullptr); bool _parse_newline(); Node *_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign = false, bool p_parsing_constant = false); Node *_reduce_expression(Node *p_node, bool p_to_const = false); @@ -665,7 +665,7 @@ public: #ifdef DEBUG_ENABLED const List<GDScriptWarning> &get_warnings() const { return warnings; } #endif // DEBUG_ENABLED - Error parse(const String &p_code, const String &p_base_path = "", bool p_just_validate = false, const String &p_self_path = "", bool p_for_completion = false, Set<int> *r_safe_lines = NULL, bool p_dependencies_only = false); + Error parse(const String &p_code, const String &p_base_path = "", bool p_just_validate = false, const String &p_self_path = "", bool p_for_completion = false, Set<int> *r_safe_lines = nullptr, bool p_dependencies_only = false); Error parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path = "", const String &p_self_path = ""); bool is_tool_script() const; diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 9064998d32..d42ca52731 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -178,7 +178,7 @@ static const _bit _type_list[] = { { Variant::PACKED_VECTOR2_ARRAY, "PackedVector2Array" }, { Variant::PACKED_VECTOR3_ARRAY, "PackedVector3Array" }, { Variant::PACKED_COLOR_ARRAY, "PackedColorArray" }, - { Variant::VARIANT_MAX, NULL }, + { Variant::VARIANT_MAX, nullptr }, }; struct _kws { @@ -236,7 +236,7 @@ static const _kws _keyword_list[] = { { GDScriptTokenizer::TK_WILDCARD, "_" }, { GDScriptTokenizer::TK_CONST_INF, "INF" }, { GDScriptTokenizer::TK_CONST_NAN, "NAN" }, - { GDScriptTokenizer::TK_ERROR, NULL } + { GDScriptTokenizer::TK_ERROR, nullptr } }; const char *GDScriptTokenizer::get_token_name(Token p_token) { @@ -1075,7 +1075,7 @@ void GDScriptTokenizerText::set_code(const String &p_code) { if (len) { _code = &code[0]; } else { - _code = NULL; + _code = nullptr; } code_pos = 0; line = 1; //it is stand-ar-ized that lines begin in 1 in code.. @@ -1358,7 +1358,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) } Map<int, Variant> rev_constant_map; - const Variant *K = NULL; + const Variant *K = nullptr; while ((K = constant_map.next(K))) { rev_constant_map[constant_map[*K]] = *K; } @@ -1407,7 +1407,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) int len; // Objects cannot be constant, never encode objects - Error err = encode_variant(E->get(), NULL, len, false); + Error err = encode_variant(E->get(), nullptr, len, false); ERR_FAIL_COND_V_MSG(err != OK, Vector<uint8_t>(), "Error when trying to encode Variant."); int pos = buf.size(); buf.resize(pos + len); diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index 0f6f13944b..b2c6b0e1ab 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -327,7 +327,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN int default_value_idx = i - (p_func->arguments.size() - p_func->default_values.size()); if (default_value_idx >= 0) { const GDScriptParser::ConstantNode *const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(p_func->default_values[default_value_idx]); - if (const_node == NULL) { + if (const_node == nullptr) { const GDScriptParser::OperatorNode *operator_node = dynamic_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[default_value_idx]); if (operator_node) { const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(operator_node->next); @@ -507,7 +507,7 @@ String ExtendGDScriptParser::get_uri() const { } const lsp::DocumentSymbol *ExtendGDScriptParser::search_symbol_defined_at_line(int p_line, const lsp::DocumentSymbol &p_parent) const { - const lsp::DocumentSymbol *ret = NULL; + const lsp::DocumentSymbol *ret = nullptr; if (p_line < p_parent.range.start.line) { return ret; } else if (p_parent.range.start.line == p_line) { @@ -591,7 +591,7 @@ const lsp::DocumentSymbol *ExtendGDScriptParser::get_member_symbol(const String } } - return NULL; + return nullptr; } const List<lsp::DocumentLink> &ExtendGDScriptParser::get_document_links() const { @@ -602,7 +602,7 @@ const Array &ExtendGDScriptParser::get_member_completions() { if (member_completions.empty()) { - const String *name = members.next(NULL); + const String *name = members.next(nullptr); while (name) { const lsp::DocumentSymbol *symbol = members.get(*name); @@ -613,11 +613,11 @@ const Array &ExtendGDScriptParser::get_member_completions() { name = members.next(name); } - const String *_class = inner_classes.next(NULL); + const String *_class = inner_classes.next(nullptr); while (_class) { const ClassMembers *inner_class = inner_classes.getptr(*_class); - const String *member_name = inner_class->next(NULL); + const String *member_name = inner_class->next(nullptr); while (member_name) { const lsp::DocumentSymbol *symbol = inner_class->get(*member_name); lsp::CompletionItem item = symbol->make_completion_item(); @@ -648,7 +648,7 @@ Dictionary ExtendGDScriptParser::dump_function_api(const GDScriptParser::Functio int default_value_idx = i - (p_func->arguments.size() - p_func->default_values.size()); if (default_value_idx >= 0) { const GDScriptParser::ConstantNode *const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(p_func->default_values[default_value_idx]); - if (const_node == NULL) { + if (const_node == nullptr) { const GDScriptParser::OperatorNode *operator_node = dynamic_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[default_value_idx]); if (operator_node) { const_node = dynamic_cast<const GDScriptParser::ConstantNode *>(operator_node->next); @@ -778,7 +778,7 @@ Error ExtendGDScriptParser::parse(const String &p_code, const String &p_path) { path = p_path; lines = p_code.split("\n"); - Error err = GDScriptParser::parse(p_code, p_path.get_base_dir(), false, p_path, false, NULL, false); + Error err = GDScriptParser::parse(p_code, p_path.get_base_dir(), false, p_path, false, nullptr, false); update_diagnostics(); update_symbols(); update_document_links(p_code); diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 2243a7b81d..69662e96f7 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -35,7 +35,7 @@ #include "editor/editor_log.h" #include "editor/editor_node.h" -GDScriptLanguageProtocol *GDScriptLanguageProtocol::singleton = NULL; +GDScriptLanguageProtocol *GDScriptLanguageProtocol::singleton = nullptr; Error GDScriptLanguageProtocol::LSPeer::handle_data() { int read = 0; @@ -191,7 +191,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { Dictionary request = make_notification("gdscrip_client/changeWorkspace", params); Ref<LSPeer> peer = clients.get(latest_client_id); - if (peer != NULL) { + if (peer != nullptr) { String msg = JSON::print(request); msg = format_output(msg); (*peer)->res_queue.push_back(msg.utf8()); @@ -230,26 +230,26 @@ void GDScriptLanguageProtocol::poll() { if (server->is_connection_available()) { on_client_connected(); } - const int *id = NULL; + const int *id = nullptr; while ((id = clients.next(id))) { Ref<LSPeer> peer = clients.get(*id); StreamPeerTCP::Status status = peer->connection->get_status(); if (status == StreamPeerTCP::STATUS_NONE || status == StreamPeerTCP::STATUS_ERROR) { on_client_disconnected(*id); - id = NULL; + id = nullptr; } else { if (peer->connection->get_available_bytes() > 0) { latest_client_id = *id; Error err = peer->handle_data(); if (err != OK && err != ERR_BUSY) { on_client_disconnected(*id); - id = NULL; + id = nullptr; } } Error err = peer->send_data(); if (err != OK && err != ERR_BUSY) { on_client_disconnected(*id); - id = NULL; + id = nullptr; } } } @@ -260,7 +260,7 @@ Error GDScriptLanguageProtocol::start(int p_port, const IP_Address &p_bind_ip) { } void GDScriptLanguageProtocol::stop() { - const int *id = NULL; + const int *id = nullptr; while ((id = clients.next(id))) { Ref<LSPeer> peer = clients.get(*id); peer->connection->disconnect_from_host(); @@ -274,7 +274,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia p_client_id = latest_client_id; } Ref<LSPeer> peer = clients.get(p_client_id); - ERR_FAIL_COND(peer == NULL); + ERR_FAIL_COND(peer == nullptr); Dictionary message = make_notification(p_method, p_params); String msg = JSON::print(message); diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp index 7170c63058..e1d86ecdd4 100644 --- a/modules/gdscript/language_server/gdscript_language_server.cpp +++ b/modules/gdscript/language_server/gdscript_language_server.cpp @@ -35,7 +35,7 @@ #include "editor/editor_node.h" GDScriptLanguageServer::GDScriptLanguageServer() { - thread = NULL; + thread = nullptr; thread_running = false; started = false; @@ -87,7 +87,7 @@ void GDScriptLanguageServer::start() { if (protocol.start(port, IP_Address("127.0.0.1")) == OK) { EditorNode::get_log()->add_message("--- GDScript language server started ---", EditorLog::MSG_TYPE_EDITOR); if (use_thread) { - ERR_FAIL_COND(thread != NULL); + ERR_FAIL_COND(thread != nullptr); thread_running = true; thread = Thread::create(GDScriptLanguageServer::thread_main, this); } @@ -98,11 +98,11 @@ void GDScriptLanguageServer::start() { void GDScriptLanguageServer::stop() { if (use_thread) { - ERR_FAIL_COND(NULL == thread); + ERR_FAIL_COND(nullptr == thread); thread_running = false; Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } protocol.stop(); started = false; diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index fbf8ef2f8f..f065b33570 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -90,12 +90,12 @@ void GDScriptTextDocument::initialize() { const HashMap<StringName, ClassMembers> &native_members = GDScriptLanguageProtocol::get_singleton()->get_workspace()->native_members; - const StringName *class_ptr = native_members.next(NULL); + const StringName *class_ptr = native_members.next(nullptr); while (class_ptr) { const ClassMembers &members = native_members.get(*class_ptr); - const String *name = members.next(NULL); + const String *name = members.next(nullptr); while (name) { const lsp::DocumentSymbol *symbol = members.get(*name); @@ -227,7 +227,7 @@ Dictionary GDScriptTextDocument::resolve(const Dictionary &p_params) { lsp::CompletionParams params; Variant data = p_params["data"]; - const lsp::DocumentSymbol *symbol = NULL; + const lsp::DocumentSymbol *symbol = nullptr; if (data.get_type() == Variant::DICTIONARY) { diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 205257b8f2..32fc8f36f0 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -93,7 +93,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_native_symbol(const String &p_ class_name = ClassDB::get_parent_class(class_name); } - return NULL; + return nullptr; } const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_path) const { @@ -101,7 +101,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_ if (S) { return &(S->get()->get_symbols()); } - return NULL; + return nullptr; } void GDScriptWorkspace::reload_all_workspace_scripts() { @@ -152,7 +152,7 @@ ExtendGDScriptParser *GDScriptWorkspace::get_parse_successed_script(const String if (S) { return S->get(); } - return NULL; + return nullptr; } ExtendGDScriptParser *GDScriptWorkspace::get_parse_result(const String &p_path) { @@ -164,7 +164,7 @@ ExtendGDScriptParser *GDScriptWorkspace::get_parse_result(const String &p_path) if (S) { return S->get(); } - return NULL; + return nullptr; } Array GDScriptWorkspace::symbol(const Dictionary &p_params) { @@ -402,7 +402,7 @@ void GDScriptWorkspace::_get_owners(EditorFileSystemDirectory *efsd, String p_pa } Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) { - Node *owner_scene_node = NULL; + Node *owner_scene_node = nullptr; List<String> owners; _get_owners(EditorFileSystem::get_singleton()->get_filesystem(), p_path, owners); @@ -438,7 +438,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name, bool p_func_requred) { - const lsp::DocumentSymbol *symbol = NULL; + const lsp::DocumentSymbol *symbol = nullptr; String path = get_file_path(p_doc_pos.textDocument.uri); if (const ExtendGDScriptParser *parser = get_parse_result(path)) { @@ -466,7 +466,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu } else { ScriptLanguage::LookupResult ret; - if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_requred), symbol_identifier, path, NULL, ret)) { + if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_requred), symbol_identifier, path, nullptr, ret)) { if (ret.type == ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION) { @@ -506,7 +506,7 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP Vector2i offset; symbol_identifier = parser->get_identifier_under_position(p_doc_pos.position, offset); - const StringName *class_ptr = native_members.next(NULL); + const StringName *class_ptr = native_members.next(nullptr); while (class_ptr) { const ClassMembers &members = native_members.get(*class_ptr); if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) { @@ -523,7 +523,7 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP } const HashMap<String, ClassMembers> &inner_classes = script->get_inner_classes(); - const String *_class = inner_classes.next(NULL); + const String *_class = inner_classes.next(nullptr); while (_class) { const ClassMembers *inner_class = inner_classes.getptr(*_class); @@ -552,7 +552,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::N } } - return NULL; + return nullptr; } void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list) { diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp index 914c9742e1..124fcbfed8 100644 --- a/modules/gdscript/language_server/lsp.hpp +++ b/modules/gdscript/language_server/lsp.hpp @@ -156,7 +156,7 @@ struct LocationLink { * Used as the underlined span for mouse interaction. Defaults to the word range at * the mouse position. */ - Range *originSelectionRange = NULL; + Range *originSelectionRange = nullptr; /** * The target resource identifier of this link. @@ -1686,8 +1686,8 @@ struct InitializeResult { struct GodotNativeClassInfo { String name; - const DocData::ClassDoc *class_doc = NULL; - const ClassDB::ClassInfo *class_info = NULL; + const DocData::ClassDoc *class_doc = nullptr; + const ClassDB::ClassInfo *class_info = nullptr; Dictionary to_json() { Dictionary dict; diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index b5eb09d6ba..62b9d94d6c 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -37,7 +37,7 @@ #include "gdscript.h" #include "gdscript_tokenizer.h" -GDScriptLanguage *script_language_gd = NULL; +GDScriptLanguage *script_language_gd = nullptr; Ref<ResourceFormatLoaderGDScript> resource_loader_gd; Ref<ResourceFormatSaverGDScript> resource_saver_gd; diff --git a/modules/glslang/SCsub b/modules/glslang/SCsub index ae102238f2..c1d23a138b 100644 --- a/modules/glslang/SCsub +++ b/modules/glslang/SCsub @@ -1,12 +1,12 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_glslang = env_modules.Clone() # Thirdparty source files -if env['builtin_glslang']: +if env["builtin_glslang"]: thirdparty_dir = "#thirdparty/glslang/" thirdparty_sources = [ "glslang/MachineIndependent/RemoveTree.cpp", @@ -48,10 +48,10 @@ if env['builtin_glslang']: "SPIRV/doc.cpp", "SPIRV/SPVRemapper.cpp", "SPIRV/SpvPostProcess.cpp", - "SPIRV/Logger.cpp" + "SPIRV/Logger.cpp", ] - if (env["platform"]=="windows"): + if env["platform"] == "windows": thirdparty_sources.append("glslang/OSDependent/Windows/ossource.cpp") else: thirdparty_sources.append("glslang/OSDependent/Unix/ossource.cpp") @@ -60,7 +60,7 @@ if env['builtin_glslang']: # Treat glslang headers as system headers to avoid raising warnings. Not supported on MSVC. if not env.msvc: - env_glslang.Append(CPPFLAGS=['-isystem', Dir(thirdparty_dir).path]) + env_glslang.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path]) else: env_glslang.Prepend(CPPPATH=[thirdparty_dir]) diff --git a/modules/glslang/config.py b/modules/glslang/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/glslang/config.py +++ b/modules/glslang/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/glslang/register_types.cpp b/modules/glslang/register_types.cpp index d2b4a18fc7..2540ba476c 100644 --- a/modules/glslang/register_types.cpp +++ b/modules/glslang/register_types.cpp @@ -30,7 +30,7 @@ #include "register_types.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rendering_device.h" #include <SPIRV/GlslangToSpv.h> #include <glslang/Include/Types.h> diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub index 62b8a0ff93..970ce534f0 100644 --- a/modules/gridmap/SCsub +++ b/modules/gridmap/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_gridmap = env_modules.Clone() diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py index 5022116c9b..a6319fe1ea 100644 --- a/modules/gridmap/config.py +++ b/modules/gridmap/config.py @@ -1,13 +1,16 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "GridMap", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index 37ebb3e5d5..a213069e19 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GridMap" inherits="Spatial" version="4.0"> +<class name="GridMap" inherits="Node3D" version="4.0"> <brief_description> Node for 3D tile-based maps. </brief_description> diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 61f18fbfee..df7c2f397f 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -36,8 +36,8 @@ #include "scene/resources/mesh_library.h" #include "scene/resources/surface_tool.h" #include "scene/scene_string_names.h" -#include "servers/navigation_server.h" -#include "servers/visual_server.h" +#include "servers/navigation_server_3d.h" +#include "servers/rendering_server.h" bool GridMap::_set(const StringName &p_name, const Variant &p_value) { @@ -76,12 +76,12 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) { BakedMesh bm; bm.mesh = meshes[i]; ERR_CONTINUE(!bm.mesh.is_valid()); - bm.instance = VS::get_singleton()->instance_create(); - VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid()); - VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id()); + bm.instance = RS::get_singleton()->instance_create(); + RS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid()); + RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id()); if (is_inside_tree()) { - VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform()); + RS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario()); + RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform()); } baked_meshes.push_back(bm); } @@ -306,17 +306,17 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) { //create octant because it does not exist Octant *g = memnew(Octant); g->dirty = true; - g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC); - PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id()); - PhysicsServer::get_singleton()->body_set_collision_layer(g->static_body, collision_layer); - PhysicsServer::get_singleton()->body_set_collision_mask(g->static_body, collision_mask); + g->static_body = PhysicsServer3D::get_singleton()->body_create(PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id()); + PhysicsServer3D::get_singleton()->body_set_collision_layer(g->static_body, collision_layer); + PhysicsServer3D::get_singleton()->body_set_collision_mask(g->static_body, collision_mask); SceneTree *st = SceneTree::get_singleton(); if (st && st->is_debugging_collisions_hint()) { - g->collision_debug = VisualServer::get_singleton()->mesh_create(); - g->collision_debug_instance = VisualServer::get_singleton()->instance_create(); - VisualServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug); + g->collision_debug = RenderingServer::get_singleton()->mesh_create(); + g->collision_debug_instance = RenderingServer::get_singleton()->instance_create(); + RenderingServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug); } octant_map[octantkey] = g; @@ -392,14 +392,14 @@ void GridMap::_octant_transform(const OctantKey &p_key) { ERR_FAIL_COND(!octant_map.has(p_key)); Octant &g = *octant_map[p_key]; - PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); if (g.collision_debug_instance.is_valid()) { - VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); + RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); } for (int i = 0; i < g.multimesh_instances.size(); i++) { - VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); + RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); } } @@ -410,17 +410,17 @@ bool GridMap::_octant_update(const OctantKey &p_key) { return false; //erase body shapes - PhysicsServer::get_singleton()->body_clear_shapes(g.static_body); + PhysicsServer3D::get_singleton()->body_clear_shapes(g.static_body); //erase body shapes debug if (g.collision_debug.is_valid()) { - VS::get_singleton()->mesh_clear(g.collision_debug); + RS::get_singleton()->mesh_clear(g.collision_debug); } //erase navigation for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) { - NavigationServer::get_singleton()->free(E->get().region); + NavigationServer3D::get_singleton()->free(E->get().region); } g.navmesh_ids.clear(); @@ -428,8 +428,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) { for (int i = 0; i < g.multimesh_instances.size(); i++) { - VS::get_singleton()->free(g.multimesh_instances[i].instance); - VS::get_singleton()->free(g.multimesh_instances[i].multimesh); + RS::get_singleton()->free(g.multimesh_instances[i].instance); + RS::get_singleton()->free(g.multimesh_instances[i].multimesh); } g.multimesh_instances.clear(); @@ -484,7 +484,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) { // add the item's shape if (!shapes[i].shape.is_valid()) continue; - PhysicsServer::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform); + PhysicsServer3D::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform); if (g.collision_debug.is_valid()) { shapes.write[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform); } @@ -497,10 +497,10 @@ bool GridMap::_octant_update(const OctantKey &p_key) { nm.xform = xform * mesh_library->get_item_navmesh_transform(c.item); if (navigation) { - RID region = NavigationServer::get_singleton()->region_create(); - NavigationServer::get_singleton()->region_set_navmesh(region, navmesh); - NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform); - NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid()); + RID region = NavigationServer3D::get_singleton()->region_create(); + NavigationServer3D::get_singleton()->region_set_navmesh(region, navmesh); + NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * nm.xform); + NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); nm.region = region; } g.navmesh_ids[E->get()] = nm; @@ -513,13 +513,13 @@ bool GridMap::_octant_update(const OctantKey &p_key) { for (Map<int, List<Pair<Transform, IndexKey>>>::Element *E = multimesh_items.front(); E; E = E->next()) { Octant::MultimeshInstance mmi; - RID mm = VS::get_singleton()->multimesh_create(); - VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D); - VS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); + RID mm = RS::get_singleton()->multimesh_create(); + RS::get_singleton()->multimesh_allocate(mm, E->get().size(), RS::MULTIMESH_TRANSFORM_3D); + RS::get_singleton()->multimesh_set_mesh(mm, mesh_library->get_item_mesh(E->key())->get_rid()); int idx = 0; for (List<Pair<Transform, IndexKey>>::Element *F = E->get().front(); F; F = F->next()) { - VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first); + RS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first); #ifdef TOOLS_ENABLED Octant::MultimeshInstance::Item it; @@ -532,12 +532,12 @@ bool GridMap::_octant_update(const OctantKey &p_key) { idx++; } - RID instance = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(instance, mm); + RID instance = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(instance, mm); if (is_inside_tree()) { - VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(instance, get_global_transform()); + RS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario()); + RS::get_singleton()->instance_set_transform(instance, get_global_transform()); } mmi.multimesh = mm; @@ -550,13 +550,13 @@ bool GridMap::_octant_update(const OctantKey &p_key) { if (col_debug.size()) { Array arr; - arr.resize(VS::ARRAY_MAX); - arr[VS::ARRAY_VERTEX] = col_debug; + arr.resize(RS::ARRAY_MAX); + arr[RS::ARRAY_VERTEX] = col_debug; - VS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, VS::PRIMITIVE_LINES, arr); + RS::get_singleton()->mesh_add_surface_from_arrays(g.collision_debug, RS::PRIMITIVE_LINES, arr); SceneTree *st = SceneTree::get_singleton(); if (st) { - VS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid()); + RS::get_singleton()->mesh_surface_set_material(g.collision_debug, 0, st->get_debug_collision_material()->get_rid()); } } @@ -567,8 +567,8 @@ bool GridMap::_octant_update(const OctantKey &p_key) { void GridMap::_reset_physic_bodies_collision_filters() { for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - PhysicsServer::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer); - PhysicsServer::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask); + PhysicsServer3D::get_singleton()->body_set_collision_layer(E->get()->static_body, collision_layer); + PhysicsServer3D::get_singleton()->body_set_collision_mask(E->get()->static_body, collision_mask); } } @@ -576,17 +576,17 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) { ERR_FAIL_COND(!octant_map.has(p_key)); Octant &g = *octant_map[p_key]; - PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space()); + PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_set_space(g.static_body, get_world()->get_space()); if (g.collision_debug_instance.is_valid()) { - VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); + RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario()); + RS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); } for (int i = 0; i < g.multimesh_instances.size(); i++) { - VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); + RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario()); + RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); } if (navigation && mesh_library.is_valid()) { @@ -595,10 +595,10 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) { if (cell_map.has(F->key()) && F->get().region.is_valid() == false) { Ref<NavigationMesh> nm = mesh_library->get_item_navmesh(cell_map[F->key()].item); if (nm.is_valid()) { - RID region = NavigationServer::get_singleton()->region_create(); - NavigationServer::get_singleton()->region_set_navmesh(region, nm); - NavigationServer::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform); - NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid()); + RID region = NavigationServer3D::get_singleton()->region_create(); + NavigationServer3D::get_singleton()->region_set_navmesh(region, nm); + NavigationServer3D::get_singleton()->region_set_transform(region, navigation->get_global_transform() * F->get().xform); + NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); F->get().region = region; } } @@ -610,23 +610,23 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { ERR_FAIL_COND(!octant_map.has(p_key)); Octant &g = *octant_map[p_key]; - PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer::get_singleton()->body_set_space(g.static_body, RID()); + PhysicsServer3D::get_singleton()->body_set_state(g.static_body, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_set_space(g.static_body, RID()); if (g.collision_debug_instance.is_valid()) { - VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID()); + RS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID()); } for (int i = 0; i < g.multimesh_instances.size(); i++) { - VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID()); + RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID()); } if (navigation) { for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { if (F->get().region.is_valid()) { - NavigationServer::get_singleton()->free(F->get().region); + NavigationServer3D::get_singleton()->free(F->get().region); F->get().region = RID(); } } @@ -639,15 +639,15 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) { Octant &g = *octant_map[p_key]; if (g.collision_debug.is_valid()) - VS::get_singleton()->free(g.collision_debug); + RS::get_singleton()->free(g.collision_debug); if (g.collision_debug_instance.is_valid()) - VS::get_singleton()->free(g.collision_debug_instance); + RS::get_singleton()->free(g.collision_debug_instance); - PhysicsServer::get_singleton()->free(g.static_body); + PhysicsServer3D::get_singleton()->free(g.static_body); // Erase navigation for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) { - NavigationServer::get_singleton()->free(E->get().region); + NavigationServer3D::get_singleton()->free(E->get().region); } g.navmesh_ids.clear(); @@ -655,8 +655,8 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) { for (int i = 0; i < g.multimesh_instances.size(); i++) { - VS::get_singleton()->free(g.multimesh_instances[i].instance); - VS::get_singleton()->free(g.multimesh_instances[i].multimesh); + RS::get_singleton()->free(g.multimesh_instances[i].instance); + RS::get_singleton()->free(g.multimesh_instances[i].multimesh); } g.multimesh_instances.clear(); } @@ -684,8 +684,8 @@ void GridMap::_notification(int p_what) { } for (int i = 0; i < baked_meshes.size(); i++) { - VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform()); + RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, get_world()->get_scenario()); + RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform()); } } break; @@ -702,7 +702,7 @@ void GridMap::_notification(int p_what) { last_transform = new_xform; for (int i = 0; i < baked_meshes.size(); i++) { - VS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform()); + RS::get_singleton()->instance_set_transform(baked_meshes[i].instance, get_global_transform()); } } break; @@ -712,13 +712,13 @@ void GridMap::_notification(int p_what) { _octant_exit_world(E->key()); } - navigation = NULL; + navigation = nullptr; //_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS); //_update_octants_callback(); //_update_area_instances(); for (int i = 0; i < baked_meshes.size(); i++) { - VS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID()); + RS::get_singleton()->instance_set_scenario(baked_meshes[i].instance, RID()); } } break; @@ -738,7 +738,7 @@ void GridMap::_update_visibility() { Octant *octant = e->value(); for (int i = 0; i < octant->multimesh_instances.size(); i++) { const Octant::MultimeshInstance &mi = octant->multimesh_instances[i]; - VS::get_singleton()->instance_set_visible(mi.instance, is_visible()); + RS::get_singleton()->instance_set_visible(mi.instance, is_visible()); } } } @@ -975,7 +975,7 @@ Vector3 GridMap::_get_offset() const { void GridMap::clear_baked_meshes() { for (int i = 0; i < baked_meshes.size(); i++) { - VS::get_singleton()->free(baked_meshes[i].instance); + RS::get_singleton()->free(baked_meshes[i].instance); } baked_meshes.clear(); @@ -1050,12 +1050,12 @@ void GridMap::make_baked_meshes(bool p_gen_lightmap_uv, float p_lightmap_uv_texe BakedMesh bm; bm.mesh = mesh; - bm.instance = VS::get_singleton()->instance_create(); - VS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid()); - VS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id()); + bm.instance = RS::get_singleton()->instance_create(); + RS::get_singleton()->get_singleton()->instance_set_base(bm.instance, bm.mesh->get_rid()); + RS::get_singleton()->instance_attach_object_instance_id(bm.instance, get_instance_id()); if (is_inside_tree()) { - VS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario()); - VS::get_singleton()->instance_set_transform(bm.instance, get_global_transform()); + RS::get_singleton()->instance_set_scenario(bm.instance, get_world()->get_scenario()); + RS::get_singleton()->instance_set_transform(bm.instance, get_global_transform()); } if (p_gen_lightmap_uv) { @@ -1107,7 +1107,7 @@ GridMap::GridMap() { clip_above = true; cell_scale = 1.0; - navigation = NULL; + navigation = nullptr; set_notify_transform(true); recreating_octants = false; } diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 43f4c09715..3f3da09fe9 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -166,10 +166,10 @@ class GridMap : public Node3D { struct BakeLight { - VS::LightType type; + RS::LightType type; Vector3 pos; Vector3 dir; - float param[VS::LIGHT_PARAM_MAX]; + float param[RS::LIGHT_PARAM_MAX]; }; _FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const { diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index a2479e764f..eb8feb5bc7 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -42,7 +42,7 @@ void GridMapEditor::_node_removed(Node *p_node) { if (p_node == node) - node = NULL; + node = nullptr; } void GridMapEditor::_configure() { @@ -281,8 +281,8 @@ void GridMapEditor::_update_cursor_transform() { cursor_transform = node->get_global_transform() * cursor_transform; if (cursor_instance.is_valid()) { - VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform); - VisualServer::get_singleton()->instance_set_visible(cursor_instance, cursor_visible); + RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform); + RenderingServer::get_singleton()->instance_set_visible(cursor_instance, cursor_visible); } } @@ -292,9 +292,9 @@ void GridMapEditor::_update_selection_transform() { if (!selection.active) { - VisualServer::get_singleton()->instance_set_transform(selection_instance, xf_zero); + RenderingServer::get_singleton()->instance_set_transform(selection_instance, xf_zero); for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero); + RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero); } return; } @@ -303,11 +303,11 @@ void GridMapEditor::_update_selection_transform() { xf.scale((Vector3(1, 1, 1) + (selection.end - selection.begin)) * node->get_cell_size()); xf.origin = selection.begin * node->get_cell_size(); - VisualServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf); + RenderingServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf); for (int i = 0; i < 3; i++) { if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) { - VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero); + RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero); } else { Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1)); @@ -322,7 +322,7 @@ void GridMapEditor::_update_selection_transform() { xf2.basis.scale(scale); xf2.origin = pos; - VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2); + RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2); } } } @@ -416,7 +416,7 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b } } - VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform); + RS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform); if (cursor_instance.is_valid()) { @@ -528,7 +528,7 @@ void GridMapEditor::_clear_clipboard_data() { for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { - VisualServer::get_singleton()->free(E->get().instance); + RenderingServer::get_singleton()->free(E->get().instance); } clipboard_items.clear(); @@ -556,7 +556,7 @@ void GridMapEditor::_set_clipboard_data() { item.cell_item = itm; item.grid_offset = Vector3(i, j, k) - selection.begin; item.orientation = node->get_cell_item_orientation(i, j, k); - item.instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario()); + item.instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario()); clipboard_items.push_back(item); } @@ -570,7 +570,7 @@ void GridMapEditor::_update_paste_indicator() { Transform xf; xf.basis.set_zero(); - VisualServer::get_singleton()->instance_set_transform(paste_instance, xf); + RenderingServer::get_singleton()->instance_set_transform(paste_instance, xf); return; } @@ -584,7 +584,7 @@ void GridMapEditor::_update_paste_indicator() { xf.basis = rot * xf.basis; xf.translate((-center * node->get_cell_size()) / scale); - VisualServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf); + RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf); for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) { @@ -599,7 +599,7 @@ void GridMapEditor::_update_paste_indicator() { item_rot.set_orthogonal_index(item.orientation); xf.basis = item_rot * xf.basis * node->get_cell_scale(); - VisualServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf); + RenderingServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf); } } @@ -896,7 +896,7 @@ void GridMapEditor::update_palette() { Ref<MeshLibrary> mesh_library = node->get_mesh_library(); if (mesh_library.is_null()) { - last_mesh_library = NULL; + last_mesh_library = nullptr; search_box->set_text(""); search_box->set_editable(false); info_message->show(); @@ -969,11 +969,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) { if (!node) { set_process(false); for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], false); } if (cursor_instance.is_valid()) { - VisualServer::get_singleton()->instance_set_visible(cursor_instance, false); + RenderingServer::get_singleton()->instance_set_visible(cursor_instance, false); } return; @@ -1011,7 +1011,7 @@ void GridMapEditor::update_grid() { edit_grid_xform.basis = Basis(); for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], i == edit_axis); } updating = true; @@ -1023,7 +1023,7 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) { Vector3 edited_floor = node->has_meta("_editor_floor_") ? node->get_meta("_editor_floor_") : Variant(); for (int i = 0; i < 3; i++) { - VS::get_singleton()->mesh_clear(grid[i]); + RS::get_singleton()->mesh_clear(grid[i]); edit_floor[i] = edited_floor[i]; } @@ -1065,11 +1065,11 @@ void GridMapEditor::_draw_grids(const Vector3 &cell_size) { } Array d; - d.resize(VS::ARRAY_MAX); - d[VS::ARRAY_VERTEX] = grid_points[i]; - d[VS::ARRAY_COLOR] = grid_colors[i]; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid()); + d.resize(RS::ARRAY_MAX); + d[RS::ARRAY_VERTEX] = grid_points[i]; + d[RS::ARRAY_COLOR] = grid_colors[i]; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid()); } } @@ -1082,13 +1082,13 @@ void GridMapEditor::_notification(int p_what) { mesh_library_palette->connect("item_selected", callable_mp(this, &GridMapEditor::_item_selected_cbk)); for (int i = 0; i < 3; i++) { - grid[i] = VS::get_singleton()->mesh_create(); - grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); - selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario()); + grid[i] = RS::get_singleton()->mesh_create(); + grid_instance[i] = RS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); + selection_level_instance[i] = RenderingServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario()); } - selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario()); - paste_instance = VisualServer::get_singleton()->instance_create2(paste_mesh, get_tree()->get_root()->get_world()->get_scenario()); + selection_instance = RenderingServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario()); + paste_instance = RenderingServer::get_singleton()->instance_create2(paste_mesh, get_tree()->get_root()->get_world()->get_scenario()); _update_selection_transform(); _update_paste_indicator(); @@ -1100,15 +1100,15 @@ void GridMapEditor::_notification(int p_what) { for (int i = 0; i < 3; i++) { - VS::get_singleton()->free(grid_instance[i]); - VS::get_singleton()->free(grid[i]); + RS::get_singleton()->free(grid_instance[i]); + RS::get_singleton()->free(grid[i]); grid_instance[i] = RID(); grid[i] = RID(); - VisualServer::get_singleton()->free(selection_level_instance[i]); + RenderingServer::get_singleton()->free(selection_level_instance[i]); } - VisualServer::get_singleton()->free(selection_instance); - VisualServer::get_singleton()->free(paste_instance); + RenderingServer::get_singleton()->free(selection_instance); + RenderingServer::get_singleton()->free(paste_instance); selection_instance = RID(); paste_instance = RID(); } break; @@ -1123,7 +1123,7 @@ void GridMapEditor::_notification(int p_what) { if (xf != grid_xform) { for (int i = 0; i < 3; i++) { - VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform); + RS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform); } grid_xform = xf; } @@ -1159,7 +1159,7 @@ void GridMapEditor::_update_cursor_instance() { } if (cursor_instance.is_valid()) - VisualServer::get_singleton()->free(cursor_instance); + RenderingServer::get_singleton()->free(cursor_instance); cursor_instance = RID(); if (selected_palette >= 0) { @@ -1168,8 +1168,8 @@ void GridMapEditor::_update_cursor_instance() { Ref<Mesh> mesh = node->get_mesh_library()->get_item_mesh(selected_palette); if (!mesh.is_null() && mesh->get_rid().is_valid()) { - cursor_instance = VisualServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario()); - VisualServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform); + cursor_instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world()->get_scenario()); + RenderingServer::get_singleton()->instance_set_transform(cursor_instance, cursor_transform); } } } @@ -1353,8 +1353,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { lock_view = false; cursor_rot = 0; - selection_mesh = VisualServer::get_singleton()->mesh_create(); - paste_mesh = VisualServer::get_singleton()->mesh_create(); + selection_mesh = RenderingServer::get_singleton()->mesh_create(); + paste_mesh = RenderingServer::get_singleton()->mesh_create(); { // Selection mesh create. @@ -1431,16 +1431,16 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { } Array d; - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); inner_mat.instance(); inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2)); inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - d[VS::ARRAY_VERTEX] = triangles; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid()); + d[RS::ARRAY_VERTEX] = triangles; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_TRIANGLES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid()); outer_mat.instance(); outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8)); @@ -1454,23 +1454,23 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { selection_floor_mat->set_on_top_of_alpha(); selection_floor_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - d[VS::ARRAY_VERTEX] = lines; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid()); + d[RS::ARRAY_VERTEX] = lines; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, RS::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid()); - d[VS::ARRAY_VERTEX] = triangles; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, VS::PRIMITIVE_TRIANGLES, d); - VisualServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid()); + d[RS::ARRAY_VERTEX] = triangles; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_TRIANGLES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 0, inner_mat->get_rid()); - d[VS::ARRAY_VERTEX] = lines; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, VS::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid()); + d[RS::ARRAY_VERTEX] = lines; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(paste_mesh, RS::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(paste_mesh, 1, outer_mat->get_rid()); for (int i = 0; i < 3; i++) { - d[VS::ARRAY_VERTEX] = square[i]; - selection_level_mesh[i] = VS::get_singleton()->mesh_create(); - VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], VS::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid()); + d[RS::ARRAY_VERTEX] = square[i]; + selection_level_mesh[i] = RS::get_singleton()->mesh_create(); + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], RS::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid()); } } @@ -1493,24 +1493,24 @@ GridMapEditor::~GridMapEditor() { for (int i = 0; i < 3; i++) { if (grid[i].is_valid()) - VisualServer::get_singleton()->free(grid[i]); + RenderingServer::get_singleton()->free(grid[i]); if (grid_instance[i].is_valid()) - VisualServer::get_singleton()->free(grid_instance[i]); + RenderingServer::get_singleton()->free(grid_instance[i]); if (cursor_instance.is_valid()) - VisualServer::get_singleton()->free(cursor_instance); + RenderingServer::get_singleton()->free(cursor_instance); if (selection_level_instance[i].is_valid()) - VisualServer::get_singleton()->free(selection_level_instance[i]); + RenderingServer::get_singleton()->free(selection_level_instance[i]); if (selection_level_mesh[i].is_valid()) - VisualServer::get_singleton()->free(selection_level_mesh[i]); + RenderingServer::get_singleton()->free(selection_level_mesh[i]); } - VisualServer::get_singleton()->free(selection_mesh); + RenderingServer::get_singleton()->free(selection_mesh); if (selection_instance.is_valid()) - VisualServer::get_singleton()->free(selection_instance); + RenderingServer::get_singleton()->free(selection_instance); - VisualServer::get_singleton()->free(paste_mesh); + RenderingServer::get_singleton()->free(paste_mesh); if (paste_instance.is_valid()) - VisualServer::get_singleton()->free(paste_instance); + RenderingServer::get_singleton()->free(paste_instance); } void GridMapEditorPlugin::_notification(int p_what) { @@ -1548,7 +1548,7 @@ void GridMapEditorPlugin::make_visible(bool p_visible) { grid_map_editor->spatial_editor_hb->hide(); grid_map_editor->hide(); - grid_map_editor->edit(NULL); + grid_map_editor->edit(nullptr); grid_map_editor->set_process(false); } } diff --git a/modules/hdr/SCsub b/modules/hdr/SCsub index c960e8126b..a709397c9a 100644 --- a/modules/hdr/SCsub +++ b/modules/hdr/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_hdr = env_modules.Clone() diff --git a/modules/hdr/config.py b/modules/hdr/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/hdr/config.py +++ b/modules/hdr/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp index 2ef6b7cd07..5f2d1578c5 100644 --- a/modules/hdr/register_types.cpp +++ b/modules/hdr/register_types.cpp @@ -32,7 +32,7 @@ #include "image_loader_hdr.h" -static ImageLoaderHDR *image_loader_hdr = NULL; +static ImageLoaderHDR *image_loader_hdr = nullptr; void register_hdr_types() { diff --git a/modules/jpg/SCsub b/modules/jpg/SCsub index 96e8e704dd..8ee8e6dd6e 100644 --- a/modules/jpg/SCsub +++ b/modules/jpg/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_jpg = env_modules.Clone() diff --git a/modules/jpg/config.py b/modules/jpg/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/jpg/config.py +++ b/modules/jpg/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp index f6077d5c68..61375fef10 100644 --- a/modules/jpg/register_types.cpp +++ b/modules/jpg/register_types.cpp @@ -32,7 +32,7 @@ #include "image_loader_jpegd.h" -static ImageLoaderJPG *image_loader_jpg = NULL; +static ImageLoaderJPG *image_loader_jpg = nullptr; void register_jpg_types() { diff --git a/modules/jsonrpc/SCsub b/modules/jsonrpc/SCsub index 13c9ffb253..fe5312670a 100644 --- a/modules/jsonrpc/SCsub +++ b/modules/jsonrpc/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_jsonrpc = env_modules.Clone() env_jsonrpc.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/jsonrpc/config.py b/modules/jsonrpc/config.py index 53bc827027..d22f9454ed 100644 --- a/modules/jsonrpc/config.py +++ b/modules/jsonrpc/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return True + return True + def configure(env): - pass + pass diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp index 014b65e3e2..393269d422 100644 --- a/modules/jsonrpc/jsonrpc.cpp +++ b/modules/jsonrpc/jsonrpc.cpp @@ -119,7 +119,7 @@ Variant JSONRPC::process_action(const Variant &p_action, bool p_process_arr_elem id = dict["id"]; } - if (object == NULL || !object->has_method(method)) { + if (object == nullptr || !object->has_method(method)) { ret = make_response_error(JSONRPC::METHOD_NOT_FOUND, "Method not found", id); } else { Variant call_ret = object->callv(method, args); diff --git a/modules/mbedtls/SCsub b/modules/mbedtls/SCsub index 0c6c703e16..5f5d25a3ee 100755 --- a/modules/mbedtls/SCsub +++ b/modules/mbedtls/SCsub @@ -1,11 +1,11 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_mbed_tls = env_modules.Clone() -if env['builtin_mbedtls']: +if env["builtin_mbedtls"]: # Thirdparty source files thirdparty_sources = [ "aes.c", @@ -86,7 +86,7 @@ if env['builtin_mbedtls']: "x509_csr.c", "x509write_crt.c", "x509write_csr.c", - "xtea.c" + "xtea.c", ] thirdparty_dir = "#thirdparty/mbedtls/library/" diff --git a/modules/mbedtls/config.py b/modules/mbedtls/config.py index 1c8cd12a2d..d22f9454ed 100755 --- a/modules/mbedtls/config.py +++ b/modules/mbedtls/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp index c8a8240a19..a47a4503a5 100644 --- a/modules/mbedtls/crypto_mbedtls.cpp +++ b/modules/mbedtls/crypto_mbedtls.cpp @@ -66,7 +66,7 @@ Error CryptoKeyMbedTLS::load(String p_path) { } memdelete(f); - int ret = mbedtls_pk_parse_key(&pkey, out.ptr(), out.size(), NULL, 0); + int ret = mbedtls_pk_parse_key(&pkey, out.ptr(), out.size(), nullptr, 0); // We MUST zeroize the memory for safety! mbedtls_platform_zeroize(out.ptrw(), out.size()); ERR_FAIL_COND_V_MSG(ret, FAILED, "Error parsing private key '" + itos(ret) + "'."); @@ -167,11 +167,11 @@ void CryptoMbedTLS::initialize_crypto() { } void CryptoMbedTLS::finalize_crypto() { - Crypto::_create = NULL; - Crypto::_load_default_certificates = NULL; + Crypto::_create = nullptr; + Crypto::_load_default_certificates = nullptr; if (default_certs) { memdelete(default_certs); - default_certs = NULL; + default_certs = nullptr; } X509CertificateMbedTLS::finalize(); CryptoKeyMbedTLS::finalize(); @@ -180,7 +180,7 @@ void CryptoMbedTLS::finalize_crypto() { CryptoMbedTLS::CryptoMbedTLS() { mbedtls_ctr_drbg_init(&ctr_drbg); mbedtls_entropy_init(&entropy); - int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0); + int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, nullptr, 0); if (ret != 0) { ERR_PRINT(" failed\n ! mbedtls_ctr_drbg_seed returned an error" + itos(ret)); } @@ -191,17 +191,17 @@ CryptoMbedTLS::~CryptoMbedTLS() { mbedtls_entropy_free(&entropy); } -X509CertificateMbedTLS *CryptoMbedTLS::default_certs = NULL; +X509CertificateMbedTLS *CryptoMbedTLS::default_certs = nullptr; X509CertificateMbedTLS *CryptoMbedTLS::get_default_certificates() { return default_certs; } void CryptoMbedTLS::load_default_certificates(String p_path) { - ERR_FAIL_COND(default_certs != NULL); + ERR_FAIL_COND(default_certs != nullptr); default_certs = memnew(X509CertificateMbedTLS); - ERR_FAIL_COND(default_certs == NULL); + ERR_FAIL_COND(default_certs == nullptr); if (p_path != "") { // Use certs defined in project settings. @@ -227,15 +227,15 @@ Ref<CryptoKey> CryptoMbedTLS::generate_rsa(int p_bytes) { Ref<CryptoKeyMbedTLS> out; out.instance(); int ret = mbedtls_pk_setup(&(out->pkey), mbedtls_pk_info_from_type(MBEDTLS_PK_RSA)); - ERR_FAIL_COND_V(ret != 0, NULL); + ERR_FAIL_COND_V(ret != 0, nullptr); ret = mbedtls_rsa_gen_key(mbedtls_pk_rsa(out->pkey), mbedtls_ctr_drbg_random, &ctr_drbg, p_bytes, 65537); - ERR_FAIL_COND_V(ret != 0, NULL); + ERR_FAIL_COND_V(ret != 0, nullptr); return out; } Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoKey> p_key, String p_issuer_name, String p_not_before, String p_not_after) { Ref<CryptoKeyMbedTLS> key = static_cast<Ref<CryptoKeyMbedTLS>>(p_key); - ERR_FAIL_COND_V_MSG(key.is_null(), NULL, "Invalid private key argument."); + ERR_FAIL_COND_V_MSG(key.is_null(), nullptr, "Invalid private key argument."); mbedtls_x509write_cert crt; mbedtls_x509write_crt_init(&crt); @@ -250,7 +250,7 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK mbedtls_mpi_init(&serial); uint8_t rand_serial[20]; mbedtls_ctr_drbg_random(&ctr_drbg, rand_serial, 20); - ERR_FAIL_COND_V(mbedtls_mpi_read_binary(&serial, rand_serial, 20), NULL); + ERR_FAIL_COND_V(mbedtls_mpi_read_binary(&serial, rand_serial, 20), nullptr); mbedtls_x509write_crt_set_serial(&crt, &serial); mbedtls_x509write_crt_set_validity(&crt, p_not_before.utf8().get_data(), p_not_after.utf8().get_data()); @@ -268,7 +268,7 @@ Ref<X509Certificate> CryptoMbedTLS::generate_self_signed_certificate(Ref<CryptoK mbedtls_mpi_free(&serial); mbedtls_x509write_crt_free(&crt); ERR_PRINT("Generated invalid certificate: " + itos(err)); - return NULL; + return nullptr; } mbedtls_mpi_free(&serial); diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h index 6c1c0e255d..db3d00a5e3 100644 --- a/modules/mbedtls/crypto_mbedtls.h +++ b/modules/mbedtls/crypto_mbedtls.h @@ -49,7 +49,7 @@ private: public: static CryptoKey *create(); static void make_default() { CryptoKey::_create = create; } - static void finalize() { CryptoKey::_create = NULL; } + static void finalize() { CryptoKey::_create = nullptr; } virtual Error load(String p_path); virtual Error save(String p_path); @@ -78,7 +78,7 @@ private: public: static X509Certificate *create(); static void make_default() { X509Certificate::_create = create; } - static void finalize() { X509Certificate::_create = NULL; } + static void finalize() { X509Certificate::_create = nullptr; } virtual Error load(String p_path); virtual Error load_from_memory(const uint8_t *p_buffer, int p_len); diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp index 215b511758..f31f067f4e 100644 --- a/modules/mbedtls/dtls_server_mbedtls.cpp +++ b/modules/mbedtls/dtls_server_mbedtls.cpp @@ -65,7 +65,7 @@ void DTLSServerMbedTLS::initialize() { } void DTLSServerMbedTLS::finalize() { - _create = NULL; + _create = nullptr; available = false; } diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp index bdf36ad1b1..b2aa5f5827 100755 --- a/modules/mbedtls/packet_peer_mbed_dtls.cpp +++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp @@ -36,11 +36,11 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) { - if (buf == NULL || len <= 0) return 0; + if (buf == nullptr || len <= 0) return 0; PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx; - ERR_FAIL_COND_V(sp == NULL, 0); + ERR_FAIL_COND_V(sp == nullptr, 0); Error err = sp->base->put_packet((const uint8_t *)buf, len); if (err == ERR_BUSY) { @@ -53,11 +53,11 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) { - if (buf == NULL || len <= 0) return 0; + if (buf == nullptr || len <= 0) return 0; PacketPeerMbedDTLS *sp = (PacketPeerMbedDTLS *)ctx; - ERR_FAIL_COND_V(sp == NULL, 0); + ERR_FAIL_COND_V(sp == nullptr, 0); int pc = sp->base->get_available_packet_count(); if (pc == 0) { @@ -125,7 +125,7 @@ Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_vali ERR_FAIL_COND_V(err != OK, err); mbedtls_ssl_set_hostname(ssl_ctx->get_context(), p_for_hostname.utf8().get_data()); - mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL); + mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr); mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay); status = STATUS_HANDSHAKING; @@ -154,7 +154,7 @@ Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> ERR_FAIL_V_MSG(FAILED, "Error setting DTLS client cookie"); } - mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL); + mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr); mbedtls_ssl_set_timer_cb(ssl_ctx->get_context(), &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay); status = STATUS_HANDSHAKING; @@ -223,7 +223,7 @@ void PacketPeerMbedDTLS::poll() { ERR_FAIL_COND(!base.is_valid()); - int ret = mbedtls_ssl_read(ssl_ctx->get_context(), NULL, 0); + int ret = mbedtls_ssl_read(ssl_ctx->get_context(), nullptr, 0); if (ret < 0 && ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { @@ -292,6 +292,6 @@ void PacketPeerMbedDTLS::initialize_dtls() { } void PacketPeerMbedDTLS::finalize_dtls() { - _create = NULL; + _create = nullptr; available = false; } diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp index 52630bd98c..1ffb9bda05 100644 --- a/modules/mbedtls/ssl_context_mbedtls.cpp +++ b/modules/mbedtls/ssl_context_mbedtls.cpp @@ -53,7 +53,7 @@ Error CookieContextMbedTLS::setup() { mbedtls_ssl_cookie_init(&cookie_ctx); inited = true; - int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0); + int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, nullptr, 0); if (ret != 0) { clear(); // Never leave unusable resources around. ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret)); @@ -94,7 +94,7 @@ Error SSLContextMbedTLS::_setup(int p_endpoint, int p_transport, int p_authmode) mbedtls_entropy_init(&entropy); inited = true; - int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0); + int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, nullptr, 0); if (ret != 0) { clear(); // Never leave unusable resources around. ERR_FAIL_V_MSG(FAILED, "mbedtls_ctr_drbg_seed returned an error " + itos(ret)); @@ -134,7 +134,7 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto } // Adding CA chain if available. if (certs->cert.next) { - mbedtls_ssl_conf_ca_chain(&conf, certs->cert.next, NULL); + mbedtls_ssl_conf_ca_chain(&conf, certs->cert.next, nullptr); } // DTLS Cookies if (p_transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) { @@ -153,7 +153,7 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce Error err = _setup(MBEDTLS_SSL_IS_CLIENT, p_transport, p_authmode); ERR_FAIL_COND_V(err != OK, err); - X509CertificateMbedTLS *cas = NULL; + X509CertificateMbedTLS *cas = nullptr; if (p_valid_cas.is_valid()) { // Locking CA certificates @@ -163,14 +163,14 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce } else { // Fall back to default certificates (no need to lock those). cas = CryptoMbedTLS::get_default_certificates(); - if (cas == NULL) { + if (cas == nullptr) { clear(); ERR_FAIL_V_MSG(ERR_UNCONFIGURED, "SSL module failed to initialize!"); } } // Set valid CAs - mbedtls_ssl_conf_ca_chain(&conf, &(cas->cert), NULL); + mbedtls_ssl_conf_ca_chain(&conf, &(cas->cert), nullptr); mbedtls_ssl_setup(&ssl, &conf); return OK; } @@ -195,7 +195,7 @@ void SSLContextMbedTLS::clear() { } mbedtls_ssl_context *SSLContextMbedTLS::get_context() { - ERR_FAIL_COND_V(!inited, NULL); + ERR_FAIL_COND_V(!inited, nullptr); return &ssl; } diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp index 03c5922267..983095c536 100755 --- a/modules/mbedtls/stream_peer_mbedtls.cpp +++ b/modules/mbedtls/stream_peer_mbedtls.cpp @@ -35,11 +35,11 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) { - if (buf == NULL || len <= 0) return 0; + if (buf == nullptr || len <= 0) return 0; StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx; - ERR_FAIL_COND_V(sp == NULL, 0); + ERR_FAIL_COND_V(sp == nullptr, 0); int sent; Error err = sp->base->put_partial_data((const uint8_t *)buf, len, sent); @@ -54,11 +54,11 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) { - if (buf == NULL || len <= 0) return 0; + if (buf == nullptr || len <= 0) return 0; StreamPeerMbedTLS *sp = (StreamPeerMbedTLS *)ctx; - ERR_FAIL_COND_V(sp == NULL, 0); + ERR_FAIL_COND_V(sp == nullptr, 0); int got; Error err = sp->base->get_partial_data((uint8_t *)buf, len, got); @@ -112,7 +112,7 @@ Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida ERR_FAIL_COND_V(err != OK, err); mbedtls_ssl_set_hostname(ssl_ctx->get_context(), p_for_hostname.utf8().get_data()); - mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL); + mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr); status = STATUS_HANDSHAKING; @@ -133,7 +133,7 @@ Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base, Ref<CryptoKey> p_ base = p_base; - mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, NULL); + mbedtls_ssl_set_bio(ssl_ctx->get_context(), this, bio_send, bio_recv, nullptr); status = STATUS_HANDSHAKING; @@ -320,5 +320,5 @@ void StreamPeerMbedTLS::initialize_ssl() { void StreamPeerMbedTLS::finalize_ssl() { available = false; - _create = NULL; + _create = nullptr; } diff --git a/modules/mobile_vr/SCsub b/modules/mobile_vr/SCsub index 4bd184f025..e6c43228b4 100644 --- a/modules/mobile_vr/SCsub +++ b/modules/mobile_vr/SCsub @@ -1,8 +1,8 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_mobile_vr = env_modules.Clone() -env_mobile_vr.add_source_files(env.modules_sources, '*.cpp') +env_mobile_vr.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/mobile_vr/config.py b/modules/mobile_vr/config.py index e85fa631dd..ee401c1a2a 100644 --- a/modules/mobile_vr/config.py +++ b/modules/mobile_vr/config.py @@ -1,13 +1,16 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "MobileVRInterface", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index 1b253d3699..6b5a70435d 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -32,7 +32,7 @@ #include "core/input/input_filter.h" #include "core/os/os.h" #include "servers/display_server.h" -#include "servers/visual/visual_server_globals.h" +#include "servers/rendering/rendering_server_globals.h" StringName MobileVRInterface::get_name() const { return "Native mobile"; @@ -327,7 +327,7 @@ bool MobileVRInterface::initialize() { void MobileVRInterface::uninitialize() { if (initialized) { ARVRServer *arvr_server = ARVRServer::get_singleton(); - if (arvr_server != NULL) { + if (arvr_server != nullptr) { // no longer our primary interface arvr_server->clear_primary_interface_if(this); } diff --git a/modules/modules_builders.py b/modules/modules_builders.py index 0e9cba2b0b..e7be6380d1 100644 --- a/modules/modules_builders.py +++ b/modules/modules_builders.py @@ -7,10 +7,10 @@ from platform_methods import subprocess_main def generate_modules_enabled(target, source, env): - with open(target[0].path, 'w') as f: + with open(target[0].path, "w") as f: for module in env.module_list: - f.write('#define %s\n' % ("MODULE_" + module.upper() + "_ENABLED")) + f.write("#define %s\n" % ("MODULE_" + module.upper() + "_ENABLED")) -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/modules/mono/SCsub b/modules/mono/SCsub index 5f03fafdcf..c723b210cb 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -2,46 +2,56 @@ import build_scripts.mono_configure as mono_configure -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_mono = env_modules.Clone() -if env_mono['tools']: +if env_mono["tools"]: # NOTE: It is safe to generate this file here, since this is still executed serially import build_scripts.gen_cs_glue_version as gen_cs_glue_version - gen_cs_glue_version.generate_header('glue/GodotSharp', 'glue/cs_glue_version.gen.h') + + gen_cs_glue_version.generate_header("glue/GodotSharp", "glue/cs_glue_version.gen.h") # Glue sources -if env_mono['mono_glue']: - env_mono.Append(CPPDEFINES=['MONO_GLUE_ENABLED']) +if env_mono["mono_glue"]: + env_mono.Append(CPPDEFINES=["MONO_GLUE_ENABLED"]) import os.path - if not os.path.isfile('glue/mono_glue.gen.cpp'): + + if not os.path.isfile("glue/mono_glue.gen.cpp"): raise RuntimeError("Mono glue sources not found. Did you forget to run '--generate-mono-glue'?") -if env_mono['tools'] or env_mono['target'] != 'release': - env_mono.Append(CPPDEFINES=['GD_MONO_HOT_RELOAD']) +if env_mono["tools"] or env_mono["target"] != "release": + env_mono.Append(CPPDEFINES=["GD_MONO_HOT_RELOAD"]) # Configure Mono mono_configure.configure(env, env_mono) -if env_mono['tools'] and env_mono['mono_glue']: +if env_mono["tools"] and env_mono["mono_glue"]: # Build Godot API solution import build_scripts.api_solution_build as api_solution_build + api_sln_cmd = api_solution_build.build(env_mono) # Build GodotTools import build_scripts.godot_tools_build as godot_tools_build + godot_tools_build.build(env_mono, api_sln_cmd) # Add sources -env_mono.add_source_files(env.modules_sources, '*.cpp') -env_mono.add_source_files(env.modules_sources, 'glue/*.cpp') -env_mono.add_source_files(env.modules_sources, 'mono_gd/*.cpp') -env_mono.add_source_files(env.modules_sources, 'utils/*.cpp') +env_mono.add_source_files(env.modules_sources, "*.cpp") +env_mono.add_source_files(env.modules_sources, "glue/*.cpp") +env_mono.add_source_files(env.modules_sources, "mono_gd/*.cpp") +env_mono.add_source_files(env.modules_sources, "utils/*.cpp") + +env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.cpp") + +if env["platform"] in ["osx", "iphone"]: + env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.mm") + env_mono.add_source_files(env.modules_sources, "mono_gd/support/*.m") -if env['tools']: - env_mono.add_source_files(env.modules_sources, 'editor/*.cpp') +if env["tools"]: + env_mono.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/mono/build_scripts/api_solution_build.py b/modules/mono/build_scripts/api_solution_build.py index 639197c285..9abac22df6 100644 --- a/modules/mono/build_scripts/api_solution_build.py +++ b/modules/mono/build_scripts/api_solution_build.py @@ -8,21 +8,22 @@ from SCons.Script import Dir def build_api_solution(source, target, env): # source and target elements are of type SCons.Node.FS.File, hence why we convert them to str - module_dir = env['module_dir'] + module_dir = env["module_dir"] - solution_path = os.path.join(module_dir, 'glue/GodotSharp/GodotSharp.sln') + solution_path = os.path.join(module_dir, "glue/GodotSharp/GodotSharp.sln") - build_config = env['solution_build_config'] + build_config = env["solution_build_config"] - extra_msbuild_args = ['/p:NoWarn=1591'] # Ignore missing documentation warnings + extra_msbuild_args = ["/p:NoWarn=1591"] # Ignore missing documentation warnings from .solution_builder import build_solution + build_solution(env, solution_path, build_config, extra_msbuild_args=extra_msbuild_args) # Copy targets - core_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, 'GodotSharp', 'bin', build_config)) - editor_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, 'GodotSharpEditor', 'bin', build_config)) + core_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharp", "bin", build_config)) + editor_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharpEditor", "bin", build_config)) dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir)) @@ -32,6 +33,7 @@ def build_api_solution(source, target, env): def copy_target(target_path): from shutil import copy + filename = os.path.basename(target_path) src_path = os.path.join(core_src_dir, filename) @@ -45,23 +47,28 @@ def build_api_solution(source, target, env): def build(env_mono): - assert env_mono['tools'] + assert env_mono["tools"] target_filenames = [ - 'GodotSharp.dll', 'GodotSharp.pdb', 'GodotSharp.xml', - 'GodotSharpEditor.dll', 'GodotSharpEditor.pdb', 'GodotSharpEditor.xml' + "GodotSharp.dll", + "GodotSharp.pdb", + "GodotSharp.xml", + "GodotSharpEditor.dll", + "GodotSharpEditor.pdb", + "GodotSharpEditor.xml", ] depend_cmd = [] - for build_config in ['Debug', 'Release']: - output_dir = Dir('#bin').abspath - editor_api_dir = os.path.join(output_dir, 'GodotSharp', 'Api', build_config) + for build_config in ["Debug", "Release"]: + output_dir = Dir("#bin").abspath + editor_api_dir = os.path.join(output_dir, "GodotSharp", "Api", build_config) targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames] - cmd = env_mono.CommandNoCache(targets, depend_cmd, build_api_solution, - module_dir=os.getcwd(), solution_build_config=build_config) + cmd = env_mono.CommandNoCache( + targets, depend_cmd, build_api_solution, module_dir=os.getcwd(), solution_build_config=build_config + ) env_mono.AlwaysBuild(cmd) # Make the Release build of the API solution depend on the Debug build. diff --git a/modules/mono/build_scripts/gen_cs_glue_version.py b/modules/mono/build_scripts/gen_cs_glue_version.py index 5d1056c2fc..98bbb4d9be 100644 --- a/modules/mono/build_scripts/gen_cs_glue_version.py +++ b/modules/mono/build_scripts/gen_cs_glue_version.py @@ -1,20 +1,20 @@ - def generate_header(solution_dir, version_header_dst): import os + latest_mtime = 0 for root, dirs, files in os.walk(solution_dir, topdown=True): - dirs[:] = [d for d in dirs if d not in ['Generated']] # Ignored generated files - files = [f for f in files if f.endswith('.cs')] + dirs[:] = [d for d in dirs if d not in ["Generated"]] # Ignored generated files + files = [f for f in files if f.endswith(".cs")] for file in files: filepath = os.path.join(root, file) mtime = os.path.getmtime(filepath) latest_mtime = mtime if mtime > latest_mtime else latest_mtime - glue_version = int(latest_mtime) # The latest modified time will do for now + glue_version = int(latest_mtime) # The latest modified time will do for now - with open(version_header_dst, 'w') as version_header: - version_header.write('/* THIS FILE IS GENERATED DO NOT EDIT */\n') - version_header.write('#ifndef CS_GLUE_VERSION_H\n') - version_header.write('#define CS_GLUE_VERSION_H\n\n') - version_header.write('#define CS_GLUE_VERSION UINT32_C(' + str(glue_version) + ')\n') - version_header.write('\n#endif // CS_GLUE_VERSION_H\n') + with open(version_header_dst, "w") as version_header: + version_header.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + version_header.write("#ifndef CS_GLUE_VERSION_H\n") + version_header.write("#define CS_GLUE_VERSION_H\n\n") + version_header.write("#define CS_GLUE_VERSION UINT32_C(" + str(glue_version) + ")\n") + version_header.write("\n#endif // CS_GLUE_VERSION_H\n") diff --git a/modules/mono/build_scripts/godot_tools_build.py b/modules/mono/build_scripts/godot_tools_build.py index 99341c631e..cffacf2577 100644 --- a/modules/mono/build_scripts/godot_tools_build.py +++ b/modules/mono/build_scripts/godot_tools_build.py @@ -8,30 +8,31 @@ from SCons.Script import Dir def build_godot_tools(source, target, env): # source and target elements are of type SCons.Node.FS.File, hence why we convert them to str - module_dir = env['module_dir'] + module_dir = env["module_dir"] - solution_path = os.path.join(module_dir, 'editor/GodotTools/GodotTools.sln') - build_config = 'Debug' if env['target'] == 'debug' else 'Release' + solution_path = os.path.join(module_dir, "editor/GodotTools/GodotTools.sln") + build_config = "Debug" if env["target"] == "debug" else "Release" # Custom build target to make sure output is always copied to the data dir. - extra_build_args = ['/Target:Build;GodotTools:BuildAlwaysCopyToDataDir'] + extra_build_args = ["/Target:Build;GodotTools:BuildAlwaysCopyToDataDir"] + + from .solution_builder import build_solution, nuget_restore - from . solution_builder import build_solution, nuget_restore nuget_restore(env, solution_path) build_solution(env, solution_path, build_config, extra_build_args) # No need to copy targets. The GodotTools csproj takes care of copying them. def build(env_mono, api_sln_cmd): - assert env_mono['tools'] + assert env_mono["tools"] - output_dir = Dir('#bin').abspath - editor_tools_dir = os.path.join(output_dir, 'GodotSharp', 'Tools') + output_dir = Dir("#bin").abspath + editor_tools_dir = os.path.join(output_dir, "GodotSharp", "Tools") - target_filenames = ['GodotTools.dll'] + target_filenames = ["GodotTools.dll"] - if env_mono['target'] == 'debug': - target_filenames += ['GodotTools.pdb'] + if env_mono["target"] == "debug": + target_filenames += ["GodotTools.pdb"] targets = [os.path.join(editor_tools_dir, filename) for filename in target_filenames] diff --git a/modules/mono/build_scripts/make_android_mono_config.py b/modules/mono/build_scripts/make_android_mono_config.py index 4f5a496891..d276d7d886 100644 --- a/modules/mono/build_scripts/make_android_mono_config.py +++ b/modules/mono/build_scripts/make_android_mono_config.py @@ -1,23 +1,24 @@ - def generate_compressed_config(config_src, output_dir): import os.path # Source file - with open(os.path.join(output_dir, 'android_mono_config.gen.cpp'), 'w') as cpp: - with open(config_src, 'rb') as f: + with open(os.path.join(output_dir, "android_mono_config.gen.cpp"), "w") as cpp: + with open(config_src, "rb") as f: buf = f.read() decompr_size = len(buf) import zlib + buf = zlib.compress(buf) compr_size = len(buf) - bytes_seq_str = '' + bytes_seq_str = "" for i, buf_idx in enumerate(range(compr_size)): if i > 0: - bytes_seq_str += ', ' + bytes_seq_str += ", " bytes_seq_str += str(buf[buf_idx]) - cpp.write('''/* THIS FILE IS GENERATED DO NOT EDIT */ + cpp.write( + """/* THIS FILE IS GENERATED DO NOT EDIT */ #include "android_mono_config.h" #ifdef ANDROID_ENABLED @@ -48,4 +49,6 @@ String get_godot_android_mono_config() { } #endif // ANDROID_ENABLED -''' % (compr_size, decompr_size, bytes_seq_str)) +""" + % (compr_size, decompr_size, bytes_seq_str) + ) diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index 4e101583ef..23f01b3cca 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -5,178 +5,230 @@ import subprocess from SCons.Script import Dir, Environment -if os.name == 'nt': +if os.name == "nt": from . import mono_reg_utils as monoreg android_arch_dirs = { - 'armv7': 'armeabi-v7a', - 'arm64v8': 'arm64-v8a', - 'x86': 'x86', - 'x86_64': 'x86_64' + "armv7": "armeabi-v7a", + "arm64v8": "arm64-v8a", + "x86": "x86", + "x86_64": "x86_64", } def get_android_out_dir(env): - return os.path.join(Dir('#platform/android/java/lib/libs').abspath, - 'release' if env['target'] == 'release' else 'debug', - android_arch_dirs[env['android_arch']]) - - -def find_file_in_dir(directory, files, prefix='', extension=''): - if not extension.startswith('.'): - extension = '.' + extension - for curfile in files: - if os.path.isfile(os.path.join(directory, prefix + curfile + extension)): - return curfile - return '' - - -def copy_file(src_dir, dst_dir, name): + return os.path.join( + Dir("#platform/android/java/lib/libs").abspath, + "release" if env["target"] == "release" else "debug", + android_arch_dirs[env["android_arch"]], + ) + + +def find_name_in_dir_files(directory, names, prefixes=[""], extensions=[""]): + for extension in extensions: + if extension and not extension.startswith("."): + extension = "." + extension + for prefix in prefixes: + for curname in names: + if os.path.isfile(os.path.join(directory, prefix + curname + extension)): + return curname + return "" + + +def find_file_in_dir(directory, names, prefixes=[""], extensions=[""]): + for extension in extensions: + if extension and not extension.startswith("."): + extension = "." + extension + for prefix in prefixes: + for curname in names: + filename = prefix + curname + extension + if os.path.isfile(os.path.join(directory, filename)): + return filename + return "" + + +def copy_file(src_dir, dst_dir, src_name, dst_name=""): from shutil import copy - src_path = os.path.join(Dir(src_dir).abspath, name) + src_path = os.path.join(Dir(src_dir).abspath, src_name) dst_dir = Dir(dst_dir).abspath if not os.path.isdir(dst_dir): os.makedirs(dst_dir) - copy(src_path, dst_dir) + if dst_name: + copy(src_path, os.path.join(dst_dir, dst_name)) + else: + copy(src_path, dst_dir) def is_desktop(platform): - return platform in ['windows', 'osx', 'linuxbsd', 'server', 'uwp', 'haiku'] + return platform in ["windows", "osx", "linuxbsd", "server", "uwp", "haiku"] def is_unix_like(platform): - return platform in ['osx', 'linuxbsd', 'server', 'android', 'haiku'] + return platform in ["osx", "linuxbsd", "server", "android", "haiku", "iphone"] def module_supports_tools_on(platform): - return platform not in ['android', 'javascript'] + return platform not in ["android", "javascript", "iphone"] def find_wasm_src_dir(mono_root): hint_dirs = [ - os.path.join(mono_root, 'src'), - os.path.join(mono_root, '../src'), + os.path.join(mono_root, "src"), + os.path.join(mono_root, "../src"), ] for hint_dir in hint_dirs: - if os.path.isfile(os.path.join(hint_dir, 'driver.c')): + if os.path.isfile(os.path.join(hint_dir, "driver.c")): return hint_dir - return '' + return "" def configure(env, env_mono): - bits = env['bits'] - is_android = env['platform'] == 'android' - is_javascript = env['platform'] == 'javascript' + bits = env["bits"] + is_android = env["platform"] == "android" + is_javascript = env["platform"] == "javascript" + is_ios = env["platform"] == "iphone" + is_ios_sim = is_ios and env["arch"] in ["x86", "x86_64"] - tools_enabled = env['tools'] - mono_static = env['mono_static'] - copy_mono_root = env['copy_mono_root'] + tools_enabled = env["tools"] + mono_static = env["mono_static"] + copy_mono_root = env["copy_mono_root"] - mono_prefix = env['mono_prefix'] + mono_prefix = env["mono_prefix"] - mono_lib_names = ['mono-2.0-sgen', 'monosgen-2.0'] + mono_lib_names = ["mono-2.0-sgen", "monosgen-2.0"] - is_travis = os.environ.get('TRAVIS') == 'true' + is_travis = os.environ.get("TRAVIS") == "true" if is_travis: # Travis CI may have a Mono version lower than 5.12 - env_mono.Append(CPPDEFINES=['NO_PENDING_EXCEPTIONS']) + env_mono.Append(CPPDEFINES=["NO_PENDING_EXCEPTIONS"]) - if is_android and not env['android_arch'] in android_arch_dirs: - raise RuntimeError('This module does not support the specified \'android_arch\': ' + env['android_arch']) + if is_android and not env["android_arch"] in android_arch_dirs: + raise RuntimeError("This module does not support the specified 'android_arch': " + env["android_arch"]) - if tools_enabled and not module_supports_tools_on(env['platform']): + if tools_enabled and not module_supports_tools_on(env["platform"]): # TODO: # Android: We have to add the data directory to the apk, concretely the Api and Tools folders. - raise RuntimeError('This module does not currently support building for this platform with tools enabled') + raise RuntimeError("This module does not currently support building for this platform with tools enabled") if is_android and mono_static: - # Android: When static linking and doing something that requires libmono-native, we get a dlopen error as libmono-native seems to depend on libmonosgen-2.0 - raise RuntimeError('Statically linking Mono is not currently supported on this platform') + # FIXME: When static linking and doing something that requires libmono-native, we get a dlopen error as 'libmono-native' + # seems to depend on 'libmonosgen-2.0'. Could be fixed by re-directing to '__Internal' with a dllmap or in the dlopen hook. + raise RuntimeError("Statically linking Mono is not currently supported for this platform") + + if not mono_static and (is_javascript or is_ios): + raise RuntimeError("Dynamically linking Mono is not currently supported for this platform") + + if not mono_prefix and (os.getenv("MONO32_PREFIX") or os.getenv("MONO64_PREFIX")): + print( + "WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead" + ) + + # Although we don't support building with tools for any platform where we currently use static AOT, + # if these are supported in the future, we won't be using static AOT for them as that would be + # too restrictive for the editor. These builds would probably be made to only use the interpreter. + mono_aot_static = (is_ios and not is_ios_sim) and not env["tools"] - if is_javascript: - mono_static = True + # Static AOT is only supported on the root domain + mono_single_appdomain = mono_aot_static - if not mono_prefix and (os.getenv('MONO32_PREFIX') or os.getenv('MONO64_PREFIX')): - print("WARNING: The environment variables 'MONO32_PREFIX' and 'MONO64_PREFIX' are deprecated; use the 'mono_prefix' SCons parameter instead") + if mono_single_appdomain: + env_mono.Append(CPPDEFINES=["GD_MONO_SINGLE_APPDOMAIN"]) - if env['platform'] == 'windows': + if (env["tools"] or env["target"] != "release") and not mono_single_appdomain: + env_mono.Append(CPPDEFINES=["GD_MONO_HOT_RELOAD"]) + + if env["platform"] == "windows": mono_root = mono_prefix - if not mono_root and os.name == 'nt': + if not mono_root and os.name == "nt": mono_root = monoreg.find_mono_root_dir(bits) if not mono_root: - raise RuntimeError("Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter") + raise RuntimeError( + "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter" + ) - print('Found Mono root directory: ' + mono_root) + print("Found Mono root directory: " + mono_root) - mono_lib_path = os.path.join(mono_root, 'lib') + mono_lib_path = os.path.join(mono_root, "lib") env.Append(LIBPATH=mono_lib_path) - env_mono.Prepend(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) + env_mono.Prepend(CPPPATH=os.path.join(mono_root, "include", "mono-2.0")) + + lib_suffixes = [".lib"] - lib_suffix = Environment()['LIBSUFFIX'] + if not env.msvc: + # MingW supports both '.a' and '.lib' + lib_suffixes.insert(0, ".a") if mono_static: if env.msvc: - mono_static_lib_name = 'libmono-static-sgen' + mono_static_lib_name = "libmono-static-sgen" else: - mono_static_lib_name = 'libmonosgen-2.0' + mono_static_lib_name = "libmonosgen-2.0" - if not os.path.isfile(os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)): - raise RuntimeError('Could not find static mono library in: ' + mono_lib_path) + mono_static_lib_file = find_file_in_dir(mono_lib_path, [mono_static_lib_name], extensions=lib_suffixes) + + if not mono_static_lib_file: + raise RuntimeError("Could not find static mono library in: " + mono_lib_path) if env.msvc: - env.Append(LINKFLAGS=mono_static_lib_name + lib_suffix) + env.Append(LINKFLAGS=mono_static_lib_file) - env.Append(LINKFLAGS='Mincore' + lib_suffix) - env.Append(LINKFLAGS='msvcrt' + lib_suffix) - env.Append(LINKFLAGS='LIBCMT' + lib_suffix) - env.Append(LINKFLAGS='Psapi' + lib_suffix) + env.Append(LINKFLAGS="Mincore.lib") + env.Append(LINKFLAGS="msvcrt.lib") + env.Append(LINKFLAGS="LIBCMT.lib") + env.Append(LINKFLAGS="Psapi.lib") else: - env.Append(LINKFLAGS=os.path.join(mono_lib_path, mono_static_lib_name + lib_suffix)) + mono_static_lib_file_path = os.path.join(mono_lib_path, mono_static_lib_file) + env.Append(LINKFLAGS=["-Wl,-whole-archive", mono_static_lib_file_path, "-Wl,-no-whole-archive"]) - env.Append(LIBS=['psapi']) - env.Append(LIBS=['version']) + env.Append(LIBS=["psapi"]) + env.Append(LIBS=["version"]) else: - mono_lib_name = find_file_in_dir(mono_lib_path, mono_lib_names, extension=lib_suffix) + mono_lib_name = find_name_in_dir_files( + mono_lib_path, mono_lib_names, prefixes=["", "lib"], extensions=lib_suffixes + ) if not mono_lib_name: - raise RuntimeError('Could not find mono library in: ' + mono_lib_path) + raise RuntimeError("Could not find mono library in: " + mono_lib_path) if env.msvc: - env.Append(LINKFLAGS=mono_lib_name + lib_suffix) + env.Append(LINKFLAGS=mono_lib_name + ".lib") else: env.Append(LIBS=[mono_lib_name]) - mono_bin_path = os.path.join(mono_root, 'bin') + mono_bin_path = os.path.join(mono_root, "bin") - mono_dll_name = find_file_in_dir(mono_bin_path, mono_lib_names, extension='.dll') + mono_dll_file = find_file_in_dir(mono_bin_path, mono_lib_names, prefixes=["", "lib"], extensions=[".dll"]) - if not mono_dll_name: - raise RuntimeError('Could not find mono shared library in: ' + mono_bin_path) + if not mono_dll_file: + raise RuntimeError("Could not find mono shared library in: " + mono_bin_path) - copy_file(mono_bin_path, '#bin', mono_dll_name + '.dll') + copy_file(mono_bin_path, "#bin", mono_dll_file) else: - is_apple = env['platform'] in ['osx', 'iphone'] + is_apple = env["platform"] in ["osx", "iphone"] + is_macos = is_apple and not is_ios - sharedlib_ext = '.dylib' if is_apple else '.so' + sharedlib_ext = ".dylib" if is_apple else ".so" mono_root = mono_prefix - mono_lib_path = '' - mono_so_name = '' + mono_lib_path = "" + mono_so_file = "" - if not mono_root and (is_android or is_javascript): - raise RuntimeError("Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter") + if not mono_root and (is_android or is_javascript or is_ios): + raise RuntimeError( + "Mono installation directory not found; specify one manually with the 'mono_prefix' SCons parameter" + ) - if not mono_root and is_apple: + if not mono_root and is_macos: # Try with some known directories under OSX - hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current', '/usr/local/var/homebrew/linked/mono'] + hint_dirs = ["/Library/Frameworks/Mono.framework/Versions/Current", "/usr/local/var/homebrew/linked/mono"] for hint_dir in hint_dirs: if os.path.isdir(hint_dir): mono_root = hint_dir @@ -187,126 +239,165 @@ def configure(env, env_mono): if not mono_root and mono_static: mono_root = pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext) if not mono_root: - raise RuntimeError("Building with mono_static=yes, but failed to find the mono prefix with pkg-config; " + \ - "specify one manually with the 'mono_prefix' SCons parameter") + raise RuntimeError( + "Building with mono_static=yes, but failed to find the mono prefix with pkg-config; " + + "specify one manually with the 'mono_prefix' SCons parameter" + ) + + if is_ios and not is_ios_sim: + env_mono.Append(CPPDEFINES=["IOS_DEVICE"]) if mono_root: - print('Found Mono root directory: ' + mono_root) + print("Found Mono root directory: " + mono_root) - mono_lib_path = os.path.join(mono_root, 'lib') + mono_lib_path = os.path.join(mono_root, "lib") env.Append(LIBPATH=[mono_lib_path]) - env_mono.Prepend(CPPPATH=os.path.join(mono_root, 'include', 'mono-2.0')) + env_mono.Prepend(CPPPATH=os.path.join(mono_root, "include", "mono-2.0")) - mono_lib = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension='.a') + mono_lib = find_name_in_dir_files(mono_lib_path, mono_lib_names, prefixes=["lib"], extensions=[".a"]) if not mono_lib: - raise RuntimeError('Could not find mono library in: ' + mono_lib_path) + raise RuntimeError("Could not find mono library in: " + mono_lib_path) - env_mono.Append(CPPDEFINES=['_REENTRANT']) + env_mono.Append(CPPDEFINES=["_REENTRANT"]) if mono_static: - env.Append(LINKFLAGS=['-rdynamic']) + env.Append(LINKFLAGS=["-rdynamic"]) - mono_lib_file = os.path.join(mono_lib_path, 'lib' + mono_lib + '.a') + mono_lib_file = os.path.join(mono_lib_path, "lib" + mono_lib + ".a") if is_apple: - env.Append(LINKFLAGS=['-Wl,-force_load,' + mono_lib_file]) + if is_macos: + env.Append(LINKFLAGS=["-Wl,-force_load," + mono_lib_file]) + else: + arch = env["arch"] + + def copy_mono_lib(libname_wo_ext): + copy_file( + mono_lib_path, "#bin", libname_wo_ext + ".a", "%s.iphone.%s.a" % (libname_wo_ext, arch) + ) + + # Copy Mono libraries to the output folder. These are meant to be bundled with + # the export templates and added to the Xcode project when exporting a game. + copy_mono_lib("lib" + mono_lib) + copy_mono_lib("libmono-native") + copy_mono_lib("libmono-profiler-log") + + if not is_ios_sim: + copy_mono_lib("libmono-ee-interp") + copy_mono_lib("libmono-icall-table") + copy_mono_lib("libmono-ilgen") else: - assert is_desktop(env['platform']) or is_android or is_javascript - env.Append(LINKFLAGS=['-Wl,-whole-archive', mono_lib_file, '-Wl,-no-whole-archive']) + assert is_desktop(env["platform"]) or is_android or is_javascript + env.Append(LINKFLAGS=["-Wl,-whole-archive", mono_lib_file, "-Wl,-no-whole-archive"]) if is_javascript: - env.Append(LIBS=['mono-icall-table', 'mono-native', 'mono-ilgen', 'mono-ee-interp']) + env.Append(LIBS=["mono-icall-table", "mono-native", "mono-ilgen", "mono-ee-interp"]) - wasm_src_dir = os.path.join(mono_root, 'src') + wasm_src_dir = os.path.join(mono_root, "src") if not os.path.isdir(wasm_src_dir): - raise RuntimeError('Could not find mono wasm src directory') + raise RuntimeError("Could not find mono wasm src directory") # Ideally this should be defined only for 'driver.c', but I can't fight scons for another 2 hours - env_mono.Append(CPPDEFINES=['CORE_BINDINGS']) - - env_mono.add_source_files(env.modules_sources, [ - os.path.join(wasm_src_dir, 'driver.c'), - os.path.join(wasm_src_dir, 'zlib-helper.c'), - os.path.join(wasm_src_dir, 'corebindings.c') - ]) - - env.Append(LINKFLAGS=[ - '--js-library', os.path.join(wasm_src_dir, 'library_mono.js'), - '--js-library', os.path.join(wasm_src_dir, 'binding_support.js'), - '--js-library', os.path.join(wasm_src_dir, 'dotnet_support.js') - ]) + env_mono.Append(CPPDEFINES=["CORE_BINDINGS"]) + + env_mono.add_source_files( + env.modules_sources, + [ + os.path.join(wasm_src_dir, "driver.c"), + os.path.join(wasm_src_dir, "zlib-helper.c"), + os.path.join(wasm_src_dir, "corebindings.c"), + ], + ) + + env.Append( + LINKFLAGS=[ + "--js-library", + os.path.join(wasm_src_dir, "library_mono.js"), + "--js-library", + os.path.join(wasm_src_dir, "binding_support.js"), + "--js-library", + os.path.join(wasm_src_dir, "dotnet_support.js"), + ] + ) else: env.Append(LIBS=[mono_lib]) - if is_apple: - env.Append(LIBS=['iconv', 'pthread']) + if is_macos: + env.Append(LIBS=["iconv", "pthread"]) elif is_android: - pass # Nothing + pass # Nothing + elif is_ios: + pass # Nothing, linking is delegated to the exported Xcode project elif is_javascript: - env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) + env.Append(LIBS=["m", "rt", "dl", "pthread"]) else: - env.Append(LIBS=['m', 'rt', 'dl', 'pthread']) + env.Append(LIBS=["m", "rt", "dl", "pthread"]) if not mono_static: - mono_so_name = find_file_in_dir(mono_lib_path, mono_lib_names, prefix='lib', extension=sharedlib_ext) + mono_so_file = find_file_in_dir( + mono_lib_path, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext] + ) - if not mono_so_name: - raise RuntimeError('Could not find mono shared library in: ' + mono_lib_path) - - copy_file(mono_lib_path, '#bin', 'lib' + mono_so_name + sharedlib_ext) + if not mono_so_file: + raise RuntimeError("Could not find mono shared library in: " + mono_lib_path) else: assert not mono_static # TODO: Add option to force using pkg-config - print('Mono root directory not found. Using pkg-config instead') + print("Mono root directory not found. Using pkg-config instead") - env.ParseConfig('pkg-config monosgen-2 --libs') - env_mono.ParseConfig('pkg-config monosgen-2 --cflags') + env.ParseConfig("pkg-config monosgen-2 --libs") + env_mono.ParseConfig("pkg-config monosgen-2 --cflags") tmpenv = Environment() - tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) - tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L') + tmpenv.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) + tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L") - for hint_dir in tmpenv['LIBPATH']: - name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext) - if name_found: + for hint_dir in tmpenv["LIBPATH"]: + file_found = find_file_in_dir(hint_dir, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext]) + if file_found: mono_lib_path = hint_dir - mono_so_name = name_found + mono_so_file = file_found break - if not mono_so_name: - raise RuntimeError('Could not find mono shared library in: ' + str(tmpenv['LIBPATH'])) + if not mono_so_file: + raise RuntimeError("Could not find mono shared library in: " + str(tmpenv["LIBPATH"])) if not mono_static: - libs_output_dir = get_android_out_dir(env) if is_android else '#bin' - copy_file(mono_lib_path, libs_output_dir, 'lib' + mono_so_name + sharedlib_ext) + libs_output_dir = get_android_out_dir(env) if is_android else "#bin" + copy_file(mono_lib_path, libs_output_dir, mono_so_file) if not tools_enabled: - if is_desktop(env['platform']): + if is_desktop(env["platform"]): if not mono_root: - mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() + mono_root = ( + subprocess.check_output(["pkg-config", "mono-2", "--variable=prefix"]).decode("utf8").strip() + ) make_template_dir(env, mono_root) elif is_android: # Compress Android Mono Config from . import make_android_mono_config + module_dir = os.getcwd() - config_file_path = os.path.join(module_dir, 'build_scripts', 'mono_android_config.xml') - make_android_mono_config.generate_compressed_config(config_file_path, 'mono_gd/') + config_file_path = os.path.join(module_dir, "build_scripts", "mono_android_config.xml") + make_android_mono_config.generate_compressed_config(config_file_path, "mono_gd/") # Copy the required shared libraries copy_mono_shared_libs(env, mono_root, None) elif is_javascript: - pass # No data directory for this platform + pass # No data directory for this platform + elif is_ios: + pass # No data directory for this platform if copy_mono_root: if not mono_root: - mono_root = subprocess.check_output(['pkg-config', 'mono-2', '--variable=prefix']).decode('utf8').strip() + mono_root = subprocess.check_output(["pkg-config", "mono-2", "--variable=prefix"]).decode("utf8").strip() if tools_enabled: - copy_mono_root_files(env, mono_root) + copy_mono_root_files(env, mono_root) else: print("Ignoring option: 'copy_mono_root'; only available for builds with 'tools' enabled.") @@ -314,26 +405,26 @@ def configure(env, env_mono): def make_template_dir(env, mono_root): from shutil import rmtree - platform = env['platform'] - target = env['target'] + platform = env["platform"] + target = env["target"] - template_dir_name = '' + template_dir_name = "" assert is_desktop(platform) - template_dir_name = 'data.mono.%s.%s.%s' % (platform, env['bits'], target) + template_dir_name = "data.mono.%s.%s.%s" % (platform, env["bits"], target) - output_dir = Dir('#bin').abspath + output_dir = Dir("#bin").abspath template_dir = os.path.join(output_dir, template_dir_name) - template_mono_root_dir = os.path.join(template_dir, 'Mono') + template_mono_root_dir = os.path.join(template_dir, "Mono") if os.path.isdir(template_mono_root_dir): - rmtree(template_mono_root_dir) # Clean first + rmtree(template_mono_root_dir) # Clean first # Copy etc/mono/ - template_mono_config_dir = os.path.join(template_mono_root_dir, 'etc', 'mono') + template_mono_config_dir = os.path.join(template_mono_root_dir, "etc", "mono") copy_mono_etc_dir(mono_root, template_mono_config_dir, platform) # Copy the required shared libraries @@ -347,18 +438,18 @@ def copy_mono_root_files(env, mono_root): from shutil import rmtree if not mono_root: - raise RuntimeError('Mono installation directory not found') + raise RuntimeError("Mono installation directory not found") - output_dir = Dir('#bin').abspath - editor_mono_root_dir = os.path.join(output_dir, 'GodotSharp', 'Mono') + output_dir = Dir("#bin").abspath + editor_mono_root_dir = os.path.join(output_dir, "GodotSharp", "Mono") if os.path.isdir(editor_mono_root_dir): - rmtree(editor_mono_root_dir) # Clean first + rmtree(editor_mono_root_dir) # Clean first # Copy etc/mono/ - editor_mono_config_dir = os.path.join(editor_mono_root_dir, 'etc', 'mono') - copy_mono_etc_dir(mono_root, editor_mono_config_dir, env['platform']) + editor_mono_config_dir = os.path.join(editor_mono_root_dir, "etc", "mono") + copy_mono_etc_dir(mono_root, editor_mono_config_dir, env["platform"]) # Copy the required shared libraries @@ -366,20 +457,20 @@ def copy_mono_root_files(env, mono_root): # Copy framework assemblies - mono_framework_dir = os.path.join(mono_root, 'lib', 'mono', '4.5') - mono_framework_facades_dir = os.path.join(mono_framework_dir, 'Facades') + mono_framework_dir = os.path.join(mono_root, "lib", "mono", "4.5") + mono_framework_facades_dir = os.path.join(mono_framework_dir, "Facades") - editor_mono_framework_dir = os.path.join(editor_mono_root_dir, 'lib', 'mono', '4.5') - editor_mono_framework_facades_dir = os.path.join(editor_mono_framework_dir, 'Facades') + editor_mono_framework_dir = os.path.join(editor_mono_root_dir, "lib", "mono", "4.5") + editor_mono_framework_facades_dir = os.path.join(editor_mono_framework_dir, "Facades") if not os.path.isdir(editor_mono_framework_dir): os.makedirs(editor_mono_framework_dir) if not os.path.isdir(editor_mono_framework_facades_dir): os.makedirs(editor_mono_framework_facades_dir) - for assembly in glob(os.path.join(mono_framework_dir, '*.dll')): + for assembly in glob(os.path.join(mono_framework_dir, "*.dll")): copy(assembly, editor_mono_framework_dir) - for assembly in glob(os.path.join(mono_framework_facades_dir, '*.dll')): + for assembly in glob(os.path.join(mono_framework_facades_dir, "*.dll")): copy(assembly, editor_mono_framework_facades_dir) @@ -391,28 +482,28 @@ def copy_mono_etc_dir(mono_root, target_mono_config_dir, platform): if not os.path.isdir(target_mono_config_dir): os.makedirs(target_mono_config_dir) - mono_etc_dir = os.path.join(mono_root, 'etc', 'mono') + mono_etc_dir = os.path.join(mono_root, "etc", "mono") if not os.path.isdir(mono_etc_dir): - mono_etc_dir = '' + mono_etc_dir = "" etc_hint_dirs = [] - if platform != 'windows': - etc_hint_dirs += ['/etc/mono', '/usr/local/etc/mono'] - if 'MONO_CFG_DIR' in os.environ: - etc_hint_dirs += [os.path.join(os.environ['MONO_CFG_DIR'], 'mono')] + if platform != "windows": + etc_hint_dirs += ["/etc/mono", "/usr/local/etc/mono"] + if "MONO_CFG_DIR" in os.environ: + etc_hint_dirs += [os.path.join(os.environ["MONO_CFG_DIR"], "mono")] for etc_hint_dir in etc_hint_dirs: if os.path.isdir(etc_hint_dir): mono_etc_dir = etc_hint_dir break if not mono_etc_dir: - raise RuntimeError('Mono installation etc directory not found') + raise RuntimeError("Mono installation etc directory not found") - copy_tree(os.path.join(mono_etc_dir, '2.0'), os.path.join(target_mono_config_dir, '2.0')) - copy_tree(os.path.join(mono_etc_dir, '4.0'), os.path.join(target_mono_config_dir, '4.0')) - copy_tree(os.path.join(mono_etc_dir, '4.5'), os.path.join(target_mono_config_dir, '4.5')) - if os.path.isdir(os.path.join(mono_etc_dir, 'mconfig')): - copy_tree(os.path.join(mono_etc_dir, 'mconfig'), os.path.join(target_mono_config_dir, 'mconfig')) + copy_tree(os.path.join(mono_etc_dir, "2.0"), os.path.join(target_mono_config_dir, "2.0")) + copy_tree(os.path.join(mono_etc_dir, "4.0"), os.path.join(target_mono_config_dir, "4.0")) + copy_tree(os.path.join(mono_etc_dir, "4.5"), os.path.join(target_mono_config_dir, "4.5")) + if os.path.isdir(os.path.join(mono_etc_dir, "mconfig")): + copy_tree(os.path.join(mono_etc_dir, "mconfig"), os.path.join(target_mono_config_dir, "mconfig")) - for file in glob(os.path.join(mono_etc_dir, '*')): + for file in glob(os.path.join(mono_etc_dir, "*")): if os.path.isfile(file): copy(file, target_mono_config_dir) @@ -424,48 +515,66 @@ def copy_mono_shared_libs(env, mono_root, target_mono_root_dir): if os.path.isfile(src): copy(src, dst) - platform = env['platform'] + platform = env["platform"] - if platform == 'windows': - src_mono_bin_dir = os.path.join(mono_root, 'bin') - target_mono_bin_dir = os.path.join(target_mono_root_dir, 'bin') + if platform == "windows": + src_mono_bin_dir = os.path.join(mono_root, "bin") + target_mono_bin_dir = os.path.join(target_mono_root_dir, "bin") if not os.path.isdir(target_mono_bin_dir): os.makedirs(target_mono_bin_dir) - mono_posix_helper_name = find_file_in_dir(src_mono_bin_dir, ['MonoPosixHelper', 'libMonoPosixHelper'], extension='.dll') - copy(os.path.join(src_mono_bin_dir, mono_posix_helper_name + '.dll'), os.path.join(target_mono_bin_dir, 'MonoPosixHelper.dll')) + mono_posix_helper_file = find_file_in_dir( + src_mono_bin_dir, ["MonoPosixHelper"], prefixes=["", "lib"], extensions=[".dll"] + ) + copy( + os.path.join(src_mono_bin_dir, mono_posix_helper_file), + os.path.join(target_mono_bin_dir, "MonoPosixHelper.dll"), + ) # For newer versions - btls_dll_path = os.path.join(src_mono_bin_dir, 'libmono-btls-shared.dll') + btls_dll_path = os.path.join(src_mono_bin_dir, "libmono-btls-shared.dll") if os.path.isfile(btls_dll_path): copy(btls_dll_path, target_mono_bin_dir) else: - target_mono_lib_dir = get_android_out_dir(env) if platform == 'android' else os.path.join(target_mono_root_dir, 'lib') + target_mono_lib_dir = ( + get_android_out_dir(env) if platform == "android" else os.path.join(target_mono_root_dir, "lib") + ) if not os.path.isdir(target_mono_lib_dir): os.makedirs(target_mono_lib_dir) lib_file_names = [] - if platform == 'osx': - lib_file_names = [lib_name + '.dylib' for lib_name in [ - 'libmono-btls-shared', 'libmono-native-compat', 'libMonoPosixHelper' - ]] + if platform == "osx": + lib_file_names = [ + lib_name + ".dylib" + for lib_name in ["libmono-btls-shared", "libmono-native-compat", "libMonoPosixHelper"] + ] elif is_unix_like(platform): - lib_file_names = [lib_name + '.so' for lib_name in [ - 'libmono-btls-shared', 'libmono-ee-interp', 'libmono-native', 'libMonoPosixHelper', - 'libmono-profiler-aot', 'libmono-profiler-coverage', 'libmono-profiler-log', 'libMonoSupportW' - ]] + lib_file_names = [ + lib_name + ".so" + for lib_name in [ + "libmono-btls-shared", + "libmono-ee-interp", + "libmono-native", + "libMonoPosixHelper", + "libmono-profiler-aot", + "libmono-profiler-coverage", + "libmono-profiler-log", + "libMonoSupportW", + ] + ] for lib_file_name in lib_file_names: - copy_if_exists(os.path.join(mono_root, 'lib', lib_file_name), target_mono_lib_dir) + copy_if_exists(os.path.join(mono_root, "lib", lib_file_name), target_mono_lib_dir) + def pkgconfig_try_find_mono_root(mono_lib_names, sharedlib_ext): tmpenv = Environment() - tmpenv.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) - tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L') - for hint_dir in tmpenv['LIBPATH']: - name_found = find_file_in_dir(hint_dir, mono_lib_names, prefix='lib', extension=sharedlib_ext) - if name_found and os.path.isdir(os.path.join(hint_dir, '..', 'include', 'mono-2.0')): - return os.path.join(hint_dir, '..') - return '' + tmpenv.AppendENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) + tmpenv.ParseConfig("pkg-config monosgen-2 --libs-only-L") + for hint_dir in tmpenv["LIBPATH"]: + name_found = find_name_in_dir_files(hint_dir, mono_lib_names, prefixes=["lib"], extensions=[sharedlib_ext]) + if name_found and os.path.isdir(os.path.join(hint_dir, "..", "include", "mono-2.0")): + return os.path.join(hint_dir, "..") + return "" diff --git a/modules/mono/build_scripts/mono_reg_utils.py b/modules/mono/build_scripts/mono_reg_utils.py index 3bae11b167..3090a4759a 100644 --- a/modules/mono/build_scripts/mono_reg_utils.py +++ b/modules/mono/build_scripts/mono_reg_utils.py @@ -1,7 +1,7 @@ import os import platform -if os.name == 'nt': +if os.name == "nt": import sys import winreg @@ -10,7 +10,7 @@ def _reg_open_key(key, subkey): try: return winreg.OpenKey(key, subkey) except (WindowsError, OSError): - if platform.architecture()[0] == '32bit': + if platform.architecture()[0] == "32bit": bitness_sam = winreg.KEY_WOW64_64KEY else: bitness_sam = winreg.KEY_WOW64_32KEY @@ -20,12 +20,12 @@ def _reg_open_key(key, subkey): def _reg_open_key_bits(key, subkey, bits): sam = winreg.KEY_READ - if platform.architecture()[0] == '32bit': - if bits == '64': + if platform.architecture()[0] == "32bit": + if bits == "64": # Force 32bit process to search in 64bit registry sam |= winreg.KEY_WOW64_64KEY else: - if bits == '32': + if bits == "32": # Force 64bit process to search in 32bit registry sam |= winreg.KEY_WOW64_32KEY @@ -35,7 +35,7 @@ def _reg_open_key_bits(key, subkey, bits): def _find_mono_in_reg(subkey, bits): try: with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey: - value = winreg.QueryValueEx(hKey, 'SdkInstallRoot')[0] + value = winreg.QueryValueEx(hKey, "SdkInstallRoot")[0] return value except (WindowsError, OSError): return None @@ -44,70 +44,70 @@ def _find_mono_in_reg(subkey, bits): def _find_mono_in_reg_old(subkey, bits): try: with _reg_open_key_bits(winreg.HKEY_LOCAL_MACHINE, subkey, bits) as hKey: - default_clr = winreg.QueryValueEx(hKey, 'DefaultCLR')[0] + default_clr = winreg.QueryValueEx(hKey, "DefaultCLR")[0] if default_clr: - return _find_mono_in_reg(subkey + '\\' + default_clr, bits) + return _find_mono_in_reg(subkey + "\\" + default_clr, bits) return None except (WindowsError, EnvironmentError): return None def find_mono_root_dir(bits): - root_dir = _find_mono_in_reg(r'SOFTWARE\Mono', bits) + root_dir = _find_mono_in_reg(r"SOFTWARE\Mono", bits) if root_dir is not None: return str(root_dir) - root_dir = _find_mono_in_reg_old(r'SOFTWARE\Novell\Mono', bits) + root_dir = _find_mono_in_reg_old(r"SOFTWARE\Novell\Mono", bits) if root_dir is not None: return str(root_dir) - return '' + return "" def find_msbuild_tools_path_reg(): import subprocess - vswhere = os.getenv('PROGRAMFILES(X86)') + vswhere = os.getenv("PROGRAMFILES(X86)") if not vswhere: - vswhere = os.getenv('PROGRAMFILES') - vswhere += r'\Microsoft Visual Studio\Installer\vswhere.exe' + vswhere = os.getenv("PROGRAMFILES") + vswhere += r"\Microsoft Visual Studio\Installer\vswhere.exe" - vswhere_args = ['-latest', '-products', '*', '-requires', 'Microsoft.Component.MSBuild'] + vswhere_args = ["-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild"] try: lines = subprocess.check_output([vswhere] + vswhere_args).splitlines() for line in lines: - parts = line.decode("utf-8").split(':', 1) + parts = line.decode("utf-8").split(":", 1) - if len(parts) < 2 or parts[0] != 'installationPath': + if len(parts) < 2 or parts[0] != "installationPath": continue val = parts[1].strip() if not val: - raise ValueError('Value of `installationPath` entry is empty') + raise ValueError("Value of `installationPath` entry is empty") # Since VS2019, the directory is simply named "Current" - msbuild_dir = os.path.join(val, 'MSBuild\\Current\\Bin') + msbuild_dir = os.path.join(val, "MSBuild\\Current\\Bin") if os.path.isdir(msbuild_dir): return msbuild_dir # Directory name "15.0" is used in VS 2017 - return os.path.join(val, 'MSBuild\\15.0\\Bin') + return os.path.join(val, "MSBuild\\15.0\\Bin") - raise ValueError('Cannot find `installationPath` entry') + raise ValueError("Cannot find `installationPath` entry") except ValueError as e: - print('Error reading output from vswhere: ' + e.message) + print("Error reading output from vswhere: " + e.message) except WindowsError: - pass # Fine, vswhere not found + pass # Fine, vswhere not found except (subprocess.CalledProcessError, OSError): pass # Try to find 14.0 in the Registry try: - subkey = r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0' + subkey = r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0" with _reg_open_key(winreg.HKEY_LOCAL_MACHINE, subkey) as hKey: - value = winreg.QueryValueEx(hKey, 'MSBuildToolsPath')[0] + value = winreg.QueryValueEx(hKey, "MSBuildToolsPath")[0] return value except (WindowsError, OSError): - return '' + return "" diff --git a/modules/mono/build_scripts/solution_builder.py b/modules/mono/build_scripts/solution_builder.py index d1529a64d2..db6b4ff7aa 100644 --- a/modules/mono/build_scripts/solution_builder.py +++ b/modules/mono/build_scripts/solution_builder.py @@ -1,4 +1,3 @@ - import os @@ -8,35 +7,38 @@ verbose = False def find_nuget_unix(): import os - if 'NUGET_PATH' in os.environ: - hint_path = os.environ['NUGET_PATH'] + if "NUGET_PATH" in os.environ: + hint_path = os.environ["NUGET_PATH"] if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path - hint_path = os.path.join(hint_path, 'nuget') + hint_path = os.path.join(hint_path, "nuget") if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path import os.path import sys - hint_dirs = ['/opt/novell/mono/bin'] - if sys.platform == 'darwin': - hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current/bin', '/usr/local/var/homebrew/linked/mono/bin'] + hint_dirs + hint_dirs = ["/opt/novell/mono/bin"] + if sys.platform == "darwin": + hint_dirs = [ + "/Library/Frameworks/Mono.framework/Versions/Current/bin", + "/usr/local/var/homebrew/linked/mono/bin", + ] + hint_dirs for hint_dir in hint_dirs: - hint_path = os.path.join(hint_dir, 'nuget') + hint_path = os.path.join(hint_dir, "nuget") if os.path.isfile(hint_path): return hint_path - elif os.path.isfile(hint_path + '.exe'): - return hint_path + '.exe' + elif os.path.isfile(hint_path + ".exe"): + return hint_path + ".exe" - for hint_dir in os.environ['PATH'].split(os.pathsep): + for hint_dir in os.environ["PATH"].split(os.pathsep): hint_dir = hint_dir.strip('"') - hint_path = os.path.join(hint_dir, 'nuget') + hint_path = os.path.join(hint_dir, "nuget") if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path - if os.path.isfile(hint_path + '.exe') and os.access(hint_path + '.exe', os.X_OK): - return hint_path + '.exe' + if os.path.isfile(hint_path + ".exe") and os.access(hint_path + ".exe", os.X_OK): + return hint_path + ".exe" return None @@ -44,30 +46,30 @@ def find_nuget_unix(): def find_nuget_windows(env): import os - if 'NUGET_PATH' in os.environ: - hint_path = os.environ['NUGET_PATH'] + if "NUGET_PATH" in os.environ: + hint_path = os.environ["NUGET_PATH"] if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path - hint_path = os.path.join(hint_path, 'nuget.exe') + hint_path = os.path.join(hint_path, "nuget.exe") if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path - from . mono_reg_utils import find_mono_root_dir + from .mono_reg_utils import find_mono_root_dir - mono_root = env['mono_prefix'] or find_mono_root_dir(env['bits']) + mono_root = env["mono_prefix"] or find_mono_root_dir(env["bits"]) if mono_root: - mono_bin_dir = os.path.join(mono_root, 'bin') - nuget_mono = os.path.join(mono_bin_dir, 'nuget.bat') + mono_bin_dir = os.path.join(mono_root, "bin") + nuget_mono = os.path.join(mono_bin_dir, "nuget.bat") if os.path.isfile(nuget_mono): return nuget_mono # Standalone NuGet - for hint_dir in os.environ['PATH'].split(os.pathsep): + for hint_dir in os.environ["PATH"].split(os.pathsep): hint_dir = hint_dir.strip('"') - hint_path = os.path.join(hint_dir, 'nuget.exe') + hint_path = os.path.join(hint_dir, "nuget.exe") if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path @@ -78,52 +80,55 @@ def find_msbuild_unix(filename): import os.path import sys - hint_dirs = ['/opt/novell/mono/bin'] - if sys.platform == 'darwin': - hint_dirs = ['/Library/Frameworks/Mono.framework/Versions/Current/bin', '/usr/local/var/homebrew/linked/mono/bin'] + hint_dirs + hint_dirs = ["/opt/novell/mono/bin"] + if sys.platform == "darwin": + hint_dirs = [ + "/Library/Frameworks/Mono.framework/Versions/Current/bin", + "/usr/local/var/homebrew/linked/mono/bin", + ] + hint_dirs for hint_dir in hint_dirs: hint_path = os.path.join(hint_dir, filename) if os.path.isfile(hint_path): return hint_path - elif os.path.isfile(hint_path + '.exe'): - return hint_path + '.exe' + elif os.path.isfile(hint_path + ".exe"): + return hint_path + ".exe" - for hint_dir in os.environ['PATH'].split(os.pathsep): + for hint_dir in os.environ["PATH"].split(os.pathsep): hint_dir = hint_dir.strip('"') hint_path = os.path.join(hint_dir, filename) if os.path.isfile(hint_path) and os.access(hint_path, os.X_OK): return hint_path - if os.path.isfile(hint_path + '.exe') and os.access(hint_path + '.exe', os.X_OK): - return hint_path + '.exe' + if os.path.isfile(hint_path + ".exe") and os.access(hint_path + ".exe", os.X_OK): + return hint_path + ".exe" return None def find_msbuild_windows(env): - from . mono_reg_utils import find_mono_root_dir, find_msbuild_tools_path_reg + from .mono_reg_utils import find_mono_root_dir, find_msbuild_tools_path_reg - mono_root = env['mono_prefix'] or find_mono_root_dir(env['bits']) + mono_root = env["mono_prefix"] or find_mono_root_dir(env["bits"]) if not mono_root: - raise RuntimeError('Cannot find mono root directory') + raise RuntimeError("Cannot find mono root directory") - mono_bin_dir = os.path.join(mono_root, 'bin') - msbuild_mono = os.path.join(mono_bin_dir, 'msbuild.bat') + mono_bin_dir = os.path.join(mono_root, "bin") + msbuild_mono = os.path.join(mono_bin_dir, "msbuild.bat") msbuild_tools_path = find_msbuild_tools_path_reg() if msbuild_tools_path: - return (os.path.join(msbuild_tools_path, 'MSBuild.exe'), {}) + return (os.path.join(msbuild_tools_path, "MSBuild.exe"), {}) if os.path.isfile(msbuild_mono): # The (Csc/Vbc/Fsc)ToolExe environment variables are required when # building with Mono's MSBuild. They must point to the batch files # in Mono's bin directory to make sure they are executed with Mono. mono_msbuild_env = { - 'CscToolExe': os.path.join(mono_bin_dir, 'csc.bat'), - 'VbcToolExe': os.path.join(mono_bin_dir, 'vbc.bat'), - 'FscToolExe': os.path.join(mono_bin_dir, 'fsharpc.bat') + "CscToolExe": os.path.join(mono_bin_dir, "csc.bat"), + "VbcToolExe": os.path.join(mono_bin_dir, "vbc.bat"), + "FscToolExe": os.path.join(mono_bin_dir, "fsharpc.bat"), } return (msbuild_mono, mono_msbuild_env) @@ -132,7 +137,7 @@ def find_msbuild_windows(env): def run_command(command, args, env_override=None, name=None): def cmd_args_to_str(cmd_args): - return ' '.join([arg if not ' ' in arg else '"%s"' % arg for arg in cmd_args]) + return " ".join([arg if not " " in arg else '"%s"' % arg for arg in cmd_args]) args = [command] + args @@ -143,6 +148,7 @@ def run_command(command, args, env_override=None, name=None): print("Running '%s': %s" % (name, cmd_args_to_str(args))) import subprocess + try: if env_override is None: subprocess.check_call(args) @@ -154,61 +160,61 @@ def run_command(command, args, env_override=None, name=None): def nuget_restore(env, *args): global verbose - verbose = env['verbose'] + verbose = env["verbose"] # Find NuGet - nuget_path = find_nuget_windows(env) if os.name == 'nt' else find_nuget_unix() + nuget_path = find_nuget_windows(env) if os.name == "nt" else find_nuget_unix() if nuget_path is None: - raise RuntimeError('Cannot find NuGet executable') + raise RuntimeError("Cannot find NuGet executable") - print('NuGet path: ' + nuget_path) + print("NuGet path: " + nuget_path) # Do NuGet restore - run_command(nuget_path, ['restore'] + list(args), name='nuget restore') + run_command(nuget_path, ["restore"] + list(args), name="nuget restore") def build_solution(env, solution_path, build_config, extra_msbuild_args=[]): global verbose - verbose = env['verbose'] + verbose = env["verbose"] msbuild_env = os.environ.copy() # Needed when running from Developer Command Prompt for VS - if 'PLATFORM' in msbuild_env: - del msbuild_env['PLATFORM'] + if "PLATFORM" in msbuild_env: + del msbuild_env["PLATFORM"] # Find MSBuild - if os.name == 'nt': + if os.name == "nt": msbuild_info = find_msbuild_windows(env) if msbuild_info is None: - raise RuntimeError('Cannot find MSBuild executable') + raise RuntimeError("Cannot find MSBuild executable") msbuild_path = msbuild_info[0] msbuild_env.update(msbuild_info[1]) else: - msbuild_path = find_msbuild_unix('msbuild') + msbuild_path = find_msbuild_unix("msbuild") if msbuild_path is None: - xbuild_fallback = env['xbuild_fallback'] + xbuild_fallback = env["xbuild_fallback"] - if xbuild_fallback and os.name == 'nt': - print('Option \'xbuild_fallback\' not supported on Windows') + if xbuild_fallback and os.name == "nt": + print("Option 'xbuild_fallback' not supported on Windows") xbuild_fallback = False if xbuild_fallback: - print('Cannot find MSBuild executable, trying with xbuild') - print('Warning: xbuild is deprecated') + print("Cannot find MSBuild executable, trying with xbuild") + print("Warning: xbuild is deprecated") - msbuild_path = find_msbuild_unix('xbuild') + msbuild_path = find_msbuild_unix("xbuild") if msbuild_path is None: - raise RuntimeError('Cannot find xbuild executable') + raise RuntimeError("Cannot find xbuild executable") else: - raise RuntimeError('Cannot find MSBuild executable') + raise RuntimeError("Cannot find MSBuild executable") - print('MSBuild path: ' + msbuild_path) + print("MSBuild path: " + msbuild_path) # Build solution - msbuild_args = [solution_path, '/p:Configuration=' + build_config] + msbuild_args = [solution_path, "/p:Configuration=" + build_config] msbuild_args += extra_msbuild_args - run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name='msbuild') + run_command(msbuild_path, msbuild_args, env_override=msbuild_env, name="msbuild") diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index b04e53bd81..384685d04b 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -42,7 +42,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> names; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = ClassDB::classes.next(k))) { @@ -67,7 +67,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->method_map.next(k))) { @@ -132,7 +132,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->constant_map.next(k))) { @@ -160,7 +160,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->signal_map.next(k))) { @@ -196,7 +196,7 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { List<StringName> snames; - k = NULL; + k = nullptr; while ((k = t->property_setget.next(k))) { diff --git a/modules/mono/config.py b/modules/mono/config.py index 3ee1618366..106ca6e028 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -1,43 +1,70 @@ +supported_platforms = ["windows", "osx", "linuxbsd", "server", "android", "haiku", "javascript", "iphone"] + + def can_build(env, platform): return True def configure(env): - if env['platform'] not in ['windows', 'osx', 'linuxbsd', 'server', 'android', 'haiku', 'javascript']: - raise RuntimeError('This module does not currently support building for this platform') + platform = env["platform"] + + if platform not in supported_platforms: + raise RuntimeError("This module does not currently support building for this platform") env.use_ptrcall = True - env.add_module_version_string('mono') + env.add_module_version_string("mono") from SCons.Script import BoolVariable, PathVariable, Variables, Help + default_mono_static = platform in ["iphone", "javascript"] + default_mono_bundles_zlib = platform in ["javascript"] + envvars = Variables() - envvars.Add(PathVariable('mono_prefix', 'Path to the mono installation directory for the target platform and architecture', '', PathVariable.PathAccept)) - envvars.Add(BoolVariable('mono_static', 'Statically link mono', False)) - envvars.Add(BoolVariable('mono_glue', 'Build with the mono glue sources', True)) - envvars.Add(BoolVariable('copy_mono_root', 'Make a copy of the mono installation directory to bundle with the editor', False)) - envvars.Add(BoolVariable('xbuild_fallback', 'If MSBuild is not found, fallback to xbuild', False)) + envvars.Add( + PathVariable( + "mono_prefix", + "Path to the mono installation directory for the target platform and architecture", + "", + PathVariable.PathAccept, + ) + ) + envvars.Add(BoolVariable("mono_static", "Statically link mono", default_mono_static)) + envvars.Add(BoolVariable("mono_glue", "Build with the mono glue sources", True)) + envvars.Add( + BoolVariable( + "copy_mono_root", "Make a copy of the mono installation directory to bundle with the editor", False + ) + ) + envvars.Add(BoolVariable("xbuild_fallback", "If MSBuild is not found, fallback to xbuild", False)) + + # TODO: It would be great if this could be detected automatically instead + envvars.Add( + BoolVariable( + "mono_bundles_zlib", "Specify if the Mono runtime was built with bundled zlib", default_mono_bundles_zlib + ) + ) + envvars.Update(env) Help(envvars.GenerateHelpText(env)) - if env['platform'] == 'javascript': - # Mono wasm already has zlib builtin, so we need this workaround to avoid symbol collisions - print('Compiling with Mono wasm disables \'builtin_zlib\'') - env['builtin_zlib'] = False + if env["mono_bundles_zlib"]: + # Mono may come with zlib bundled for WASM or on newer version when built with MinGW. + print("This Mono runtime comes with zlib bundled. Disabling 'builtin_zlib'...") + env["builtin_zlib"] = False thirdparty_zlib_dir = "#thirdparty/zlib/" env.Prepend(CPPPATH=[thirdparty_zlib_dir]) def get_doc_classes(): return [ - '@C#', - 'CSharpScript', - 'GodotSharp', + "@C#", + "CSharpScript", + "GodotSharp", ] def get_doc_path(): - return 'doc_classes' + return "doc_classes" def is_enabled(): diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 28bacbd0f0..0b5d3c8dbc 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -158,7 +158,7 @@ void CSharpLanguage::finish() { if (gdmono) { memdelete(gdmono); - gdmono = NULL; + gdmono = nullptr; } // Clear here, after finalizing all domains to make sure there is nothing else referencing the elements. @@ -316,7 +316,8 @@ void CSharpLanguage::get_string_delimiters(List<String> *p_delimiters) const { p_delimiters->push_back("' '"); // character literal p_delimiters->push_back("\" \""); // regular string literal - p_delimiters->push_back("@\" \""); // verbatim string literal + // Verbatim string literals (`@" "`) don't render correctly, so don't highlight them. + // Generic string highlighting suffices as a workaround for now. } static String get_base_class_name(const String &p_base_class_name, const String p_class_name) { @@ -613,7 +614,7 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::stack_trace_get_info(MonoObjec GD_MONO_SCOPE_THREAD_ATTACH; - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoArray *frames = CACHED_METHOD_THUNK(System_Diagnostics_StackTrace, GetFrames).invoke(p_stack_trace, &exc); @@ -678,14 +679,14 @@ void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) { void CSharpLanguage::frame() { - if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != NULL) { + if (gdmono && gdmono->is_runtime_initialized() && gdmono->get_core_api_assembly() != nullptr) { const Ref<MonoGCHandleRef> &task_scheduler_handle = GDMonoCache::cached_data.task_scheduler_handle; if (task_scheduler_handle.is_valid()) { MonoObject *task_scheduler = task_scheduler_handle->get_target(); if (task_scheduler) { - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(GodotTaskScheduler, Activate).invoke(task_scheduler, &exc); if (exc) { @@ -763,7 +764,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() { if (proj_assembly) { String proj_asm_path = proj_assembly->get_path(); - if (!FileAccess::exists(proj_assembly->get_path())) { + if (!FileAccess::exists(proj_asm_path)) { // Maybe it wasn't loaded from the default path, so check this as well proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(appname_safe); if (!FileAccess::exists(proj_asm_path)) @@ -812,7 +813,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { Array serialized_data; MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TrySerializeDelegate).invoke(delegate, managed_serialized_data, &exc); if (exc) { @@ -945,7 +946,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { // Restore Variant properties state, it will be kept by the placeholder until the next script reloading for (List<Pair<StringName, Variant>>::Element *G = scr->pending_reload_state[obj_id].properties.front(); G; G = G->next()) { - placeholder->property_set_fallback(G->get().first, G->get().second, NULL); + placeholder->property_set_fallback(G->get().first, G->get().second, nullptr); } scr->pending_reload_state.erase(obj_id); @@ -979,12 +980,12 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { GDMonoAssembly *project_assembly = gdmono->get_project_assembly(); // Search in project and tools assemblies first as those are the most likely to have the class - GDMonoClass *script_class = (project_assembly ? project_assembly->get_class(class_namespace, class_name) : NULL); + GDMonoClass *script_class = (project_assembly ? project_assembly->get_class(class_namespace, class_name) : nullptr); #ifdef TOOLS_ENABLED if (!script_class) { GDMonoAssembly *tools_assembly = gdmono->get_tools_assembly(); - script_class = (tools_assembly ? tools_assembly->get_class(class_namespace, class_name) : NULL); + script_class = (tools_assembly ? tools_assembly->get_class(class_namespace, class_name) : nullptr); } #endif @@ -1055,7 +1056,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { continue; } #else - CRASH_COND(si != NULL); + CRASH_COND(si != nullptr); #endif // Re-create script instance obj->set_script(script); // will create the script instance as well @@ -1104,9 +1105,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { const CSharpScript::EventSignal &event_signal = match->value(); MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoDelegate *delegate = NULL; + MonoDelegate *delegate = nullptr; - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TryDeserializeDelegate).invoke(managed_serialized_data, &delegate, &exc); if (exc) { @@ -1115,7 +1116,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } if (success) { - ERR_CONTINUE(delegate == NULL); + ERR_CONTINUE(delegate == nullptr); event_signal.field->set_value(csi->get_mono_object(), (MonoObject *)delegate); } else if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Failed to deserialize event signal delegate\n"); @@ -1140,9 +1141,9 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { const Array &serialized_data = elem->value(); MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoDelegate *delegate = NULL; + MonoDelegate *delegate = nullptr; - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TryDeserializeDelegate).invoke(managed_serialized_data, &delegate, &exc); if (exc) { @@ -1151,7 +1152,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { } if (success) { - ERR_CONTINUE(delegate == NULL); + ERR_CONTINUE(delegate == nullptr); managed_callable->set_delegate(delegate); } else if (OS::get_singleton()->is_stdout_verbose()) { OS::get_singleton()->print("Failed to deserialize delegate\n"); @@ -1291,7 +1292,7 @@ void CSharpLanguage::_on_scripts_domain_unloaded() { for (SelfList<ManagedCallable> *elem = ManagedCallable::instances.first(); elem; elem = elem->next()) { ManagedCallable *managed_callable = elem->self(); managed_callable->delegate_handle.release(); - managed_callable->delegate_invoke = NULL; + managed_callable->delegate_invoke = nullptr; } } @@ -1306,17 +1307,17 @@ void CSharpLanguage::_editor_init_callback() { // Initialize GodotSharpEditor GDMonoClass *editor_klass = GDMono::get_singleton()->get_tools_assembly()->get_class("GodotTools", "GodotSharpEditor"); - CRASH_COND(editor_klass == NULL); + CRASH_COND(editor_klass == nullptr); MonoObject *mono_object = mono_object_new(mono_domain_get(), editor_klass->get_mono_ptr()); - CRASH_COND(mono_object == NULL); + CRASH_COND(mono_object == nullptr); - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_object_init(mono_object, editor_klass, &exc); UNHANDLED_EXCEPTION(exc); EditorPlugin *godotsharp_editor = Object::cast_to<EditorPlugin>(GDMonoMarshal::mono_object_to_variant(mono_object)); - CRASH_COND(godotsharp_editor == NULL); + CRASH_COND(godotsharp_editor == nullptr); // Enable it as a plugin EditorNode::add_editor_plugin(godotsharp_editor); @@ -1353,7 +1354,7 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, MonoGCH // already released and could have been replaced) or if we can't get its target MonoObject* // (which doesn't necessarily mean it was released, and we want it released in order to // avoid locking other threads unnecessarily). - if (target == p_expected_obj || target == NULL) { + if (target == p_expected_obj || target == nullptr) { p_gchandle.release(); } } @@ -1379,7 +1380,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b // I don't trust you if (p_object->get_script_instance()) { CSharpInstance *csharp_instance = CAST_CSHARP_INSTANCE(p_object->get_script_instance()); - CRASH_COND(csharp_instance != NULL && !csharp_instance->is_destructing_script_instance()); + CRASH_COND(csharp_instance != nullptr && !csharp_instance->is_destructing_script_instance()); } #endif @@ -1433,7 +1434,7 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) { CSharpScriptBinding script_binding; if (!setup_csharp_script_binding(script_binding, p_object)) - return NULL; + return nullptr; return (void *)insert_script_binding(p_object, script_binding); } @@ -1445,7 +1446,7 @@ Map<Object *, CSharpScriptBinding>::Element *CSharpLanguage::insert_script_bindi void CSharpLanguage::free_instance_binding_data(void *p_data) { - if (GDMono::get_singleton() == NULL) { + if (GDMono::get_singleton() == nullptr) { #ifdef DEBUG_ENABLED CRASH_COND(!script_bindings.empty()); #endif @@ -1470,7 +1471,7 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) { // This is done to avoid trying to dispose the native instance from Dispose(bool). MonoObject *mono_object = script_binding.gchandle.get_target(); if (mono_object) { - CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, NULL); + CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, nullptr); } script_binding.gchandle.release(); } @@ -1562,7 +1563,7 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS Reference *ref = Object::cast_to<Reference>(p_owner); - instance->base_ref = ref != NULL; + instance->base_ref = ref != nullptr; instance->owner = p_owner; instance->gchandle = p_gchandle; @@ -1576,7 +1577,7 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS MonoObject *CSharpInstance::get_mono_object() const { - ERR_FAIL_COND_V(gchandle.is_released(), NULL); + ERR_FAIL_COND_V(gchandle.is_released(), nullptr); return gchandle.get_target(); } @@ -1661,7 +1662,7 @@ bool CSharpInstance::get(const StringName &p_name, Variant &r_ret) const { GDMonoProperty *property = top->get_property(p_name); if (property) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *value = property->get_value(mono_object, &exc); if (exc) { r_ret = Variant(); @@ -1742,7 +1743,7 @@ void CSharpInstance::get_event_signals_state_for_reloading(List<Pair<StringName, Array serialized_data; MonoObject *managed_serialized_data = GDMonoMarshal::variant_to_mono_object(serialized_data); - MonoException *exc = NULL; + MonoException *exc = nullptr; bool success = (bool)CACHED_METHOD_THUNK(DelegateUtils, TrySerializeDelegate).invoke(delegate_field_value, managed_serialized_data, &exc); if (exc) { @@ -1909,7 +1910,7 @@ bool CSharpInstance::_reference_owner_unsafe() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); CRASH_COND(unsafe_referenced); // already referenced #endif @@ -1931,7 +1932,7 @@ bool CSharpInstance::_unreference_owner_unsafe() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); #endif if (!unsafe_referenced) @@ -1952,13 +1953,13 @@ bool CSharpInstance::_unreference_owner_unsafe() { MonoObject *CSharpInstance::_internal_new_managed() { // Search the constructor first, to fail with an error if it's not found before allocating anything else. GDMonoMethod *ctor = script->script_class->get_method(CACHED_STRING_NAME(dotctor), 0); - ERR_FAIL_NULL_V_MSG(ctor, NULL, + ERR_FAIL_NULL_V_MSG(ctor, nullptr, "Cannot create script instance because the class does not define a parameterless constructor: '" + script->get_path() + "'."); CSharpLanguage::get_singleton()->release_script_gchandle(gchandle); - ERR_FAIL_NULL_V(owner, NULL); - ERR_FAIL_COND_V(script.is_null(), NULL); + ERR_FAIL_NULL_V(owner, nullptr); + ERR_FAIL_COND_V(script.is_null(), nullptr); MonoObject *mono_object = mono_object_new(mono_domain_get(), script->script_class->get_mono_ptr()); @@ -1970,9 +1971,9 @@ MonoObject *CSharpInstance::_internal_new_managed() { // Not ok for the owner to die here. If there is a situation where this can happen, it will be considered a bug. CRASH_COND(die == true); - owner = NULL; + owner = nullptr; - ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object."); + ERR_FAIL_V_MSG(nullptr, "Failed to allocate memory for the object."); } // Tie managed to unmanaged @@ -1984,7 +1985,7 @@ MonoObject *CSharpInstance::_internal_new_managed() { CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, owner); // Construct - ctor->invoke_raw(mono_object, NULL); + ctor->invoke_raw(mono_object, nullptr); return mono_object; } @@ -2065,7 +2066,7 @@ void CSharpInstance::refcount_incremented() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); #endif Reference *ref_owner = Object::cast_to<Reference>(owner); @@ -2088,7 +2089,7 @@ bool CSharpInstance::refcount_decremented() { #ifdef DEBUG_ENABLED CRASH_COND(!base_ref); - CRASH_COND(owner == NULL); + CRASH_COND(owner == nullptr); #endif Reference *ref_owner = Object::cast_to<Reference>(owner); @@ -2180,7 +2181,7 @@ void CSharpInstance::notification(int p_notification) { MonoObject *mono_object = get_mono_object(); ERR_FAIL_NULL(mono_object); - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(mono_object, &exc); if (exc) { @@ -2225,13 +2226,13 @@ String CSharpInstance::to_string(bool *r_valid) { MonoObject *mono_object = get_mono_object(); - if (mono_object == NULL) { + if (mono_object == nullptr) { if (r_valid) *r_valid = false; return String(); } - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoString *result = GDMonoUtils::object_to_string(mono_object, &exc); if (exc) { @@ -2241,7 +2242,7 @@ String CSharpInstance::to_string(bool *r_valid) { return String(); } - if (result == NULL) { + if (result == nullptr) { if (r_valid) *r_valid = false; return String(); @@ -2275,13 +2276,13 @@ CSharpInstance::~CSharpInstance() { // This destructor is not called from the owners destructor. // This could be being called from the owner's set_script_instance method, // meaning this script is being replaced with another one. If this is the case, - // we must call Dispose here, because Dispose calls owner->set_script_instance(NULL) + // we must call Dispose here, because Dispose calls owner->set_script_instance(nullptr) // and that would mess up with the new script instance if called later. MonoObject *mono_object = gchandle.get_target(); if (mono_object) { - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(mono_object, &exc); if (exc) { @@ -2311,7 +2312,7 @@ CSharpInstance::~CSharpInstance() { CRASH_COND(die == true); // `owner_keep_alive` holds a reference, so it can't die void *data = owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); - CRASH_COND(data == NULL); + CRASH_COND(data == nullptr); CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get(); @@ -2454,11 +2455,11 @@ bool CSharpScript::_update_exports() { GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), 0); - ERR_FAIL_NULL_V_MSG(ctor, NULL, + ERR_FAIL_NULL_V_MSG(ctor, false, "Cannot construct temporary MonoObject because the class does not define a parameterless constructor: '" + get_path() + "'."); - MonoException *ctor_exc = NULL; - ctor->invoke(tmp_object, NULL, &ctor_exc); + MonoException *ctor_exc = nullptr; + ctor->invoke(tmp_object, nullptr, &ctor_exc); Object *tmp_native = GDMonoMarshal::unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(tmp_object)); @@ -2466,7 +2467,7 @@ bool CSharpScript::_update_exports() { // TODO: Should we free 'tmp_native' if the exception was thrown after its creation? GDMonoUtils::free_gchandle(tmp_pinned_gchandle); - tmp_object = NULL; + tmp_object = nullptr; ERR_PRINT("Exception thrown from constructor of temporary MonoObject:"); GDMonoUtils::debug_print_unhandled_exception(ctor_exc); @@ -2513,7 +2514,7 @@ bool CSharpScript::_update_exports() { exported_members_cache.push_front(prop_info); if (tmp_object) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = property->get_value(tmp_object, &exc); if (exc) { exported_members_defval_cache[member_name] = Variant(); @@ -2532,11 +2533,11 @@ bool CSharpScript::_update_exports() { } // Need to check this here, before disposal - bool base_ref = Object::cast_to<Reference>(tmp_native) != NULL; + bool base_ref = Object::cast_to<Reference>(tmp_native) != nullptr; // Dispose the temporary managed instance - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(tmp_object, &exc); if (exc) { @@ -2545,7 +2546,7 @@ bool CSharpScript::_update_exports() { } GDMonoUtils::free_gchandle(tmp_pinned_gchandle); - tmp_object = NULL; + tmp_object = nullptr; if (tmp_native && !base_ref) { Node *node = Object::cast_to<Node>(tmp_native); @@ -2608,9 +2609,9 @@ void CSharpScript::load_script_signals(GDMonoClass *p_class, GDMonoClass *p_nati List<StringName> found_event_signals; - void *iter = NULL; - MonoEvent *raw_event = NULL; - while ((raw_event = mono_class_get_events(top->get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoEvent *raw_event = nullptr; + while ((raw_event = mono_class_get_events(top->get_mono_ptr(), &iter)) != nullptr) { MonoCustomAttrInfo *event_attrs = mono_custom_attrs_from_event(top->get_mono_ptr(), raw_event); if (event_attrs) { if (mono_custom_attrs_has_attr(event_attrs, CACHED_CLASS(SignalAttribute)->get_mono_ptr())) { @@ -2810,7 +2811,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage // Instead of using mono_field_get_value_object, we can do this without boxing. Check the // internal mono functions: ves_icall_System_Enum_GetEnumValuesAndNames and the get_enum_field. - MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, NULL); + MonoObject *val_obj = mono_field_get_value_object(mono_domain_get(), field, nullptr); ERR_FAIL_NULL_V_MSG(val_obj, -1, "Failed to get '" + enum_field_name + "' constant enum value."); @@ -2834,7 +2835,7 @@ int CSharpScript::_try_get_member_export_hint(IMonoClassMember *p_member, Manage } } else if (p_variant_type == Variant::OBJECT && CACHED_CLASS(GodotResource)->is_assignable_from(p_type.type_class)) { GDMonoClass *field_native_class = GDMonoUtils::get_class_native_base(p_type.type_class); - CRASH_COND(field_native_class == NULL); + CRASH_COND(field_native_class == nullptr); r_hint = PROPERTY_HINT_RESOURCE_TYPE; r_hint_string = String(NATIVE_GDMONOCLASS_NAME(field_native_class)); @@ -2876,14 +2877,14 @@ void CSharpScript::_clear() { tool = false; valid = false; - base = NULL; - native = NULL; - script_class = NULL; + base = nullptr; + native = nullptr; + script_class = nullptr; } Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (unlikely(GDMono::get_singleton() == NULL)) { + if (unlikely(GDMono::get_singleton() == nullptr)) { // Probably not the best error but eh. r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; return Variant(); @@ -2897,7 +2898,7 @@ Variant CSharpScript::call(const StringName &p_method, const Variant **p_args, i GDMonoMethod *method = top->get_method(p_method, p_argcount); if (method && method->is_static()) { - MonoObject *result = method->invoke(NULL, p_args); + MonoObject *result = method->invoke(nullptr, p_args); if (result) { return GDMonoMarshal::mono_object_to_variant(result); @@ -2959,7 +2960,7 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class, GD // This method should not fail, only assertions allowed - CRASH_COND(p_class == NULL); + CRASH_COND(p_class == nullptr); // TODO OPTIMIZE: Cache the 'CSharpScript' associated with this 'p_class' instead of allocating a new one every time Ref<CSharpScript> script = memnew(CSharpScript); @@ -2973,13 +2974,13 @@ void CSharpScript::initialize_for_managed_type(Ref<CSharpScript> p_script, GDMon // This method should not fail, only assertions allowed - CRASH_COND(p_class == NULL); + CRASH_COND(p_class == nullptr); p_script->name = p_class->get_name(); p_script->script_class = p_class; p_script->native = p_native; - CRASH_COND(p_script->native == NULL); + CRASH_COND(p_script->native == nullptr); GDMonoClass *base = p_script->script_class->get_parent_class(); @@ -3045,12 +3046,12 @@ bool CSharpScript::can_instance() const { // For tool scripts, this will never fire if the class is not found. That's because we // don't know if it's a tool script if we can't find the class to access the attributes. if (extra_cond && !script_class) { - if (GDMono::get_singleton()->get_project_assembly() == NULL) { + if (GDMono::get_singleton()->get_project_assembly() == nullptr) { // The project assembly is not loaded - ERR_FAIL_V_MSG(NULL, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'."); + ERR_FAIL_V_MSG(false, "Cannot instance script because the project assembly is not loaded. Script: '" + get_path() + "'."); } else { // The project assembly is loaded, but the class could not found - ERR_FAIL_V_MSG(NULL, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'."); + ERR_FAIL_V_MSG(false, "Cannot instance script because the class '" + name + "' could not be found. Script: '" + get_path() + "'."); } } @@ -3073,13 +3074,13 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg // Search the constructor first, to fail with an error if it's not found before allocating anything else. GDMonoMethod *ctor = script_class->get_method(CACHED_STRING_NAME(dotctor), p_argcount); - if (ctor == NULL) { - ERR_FAIL_COND_V_MSG(p_argcount == 0, NULL, + if (ctor == nullptr) { + ERR_FAIL_COND_V_MSG(p_argcount == 0, nullptr, "Cannot create script instance. The class '" + script_class->get_full_name() + "' does not define a parameterless constructor." + (get_path().empty() ? String() : " Path: '" + get_path() + "'.")); - ERR_FAIL_V_MSG(NULL, "Constructor not found."); + ERR_FAIL_V_MSG(nullptr, "Constructor not found."); } Ref<Reference> ref; @@ -3091,13 +3092,13 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg // If the object had a script instance binding, dispose it before adding the CSharpInstance if (p_owner->has_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index())) { void *data = p_owner->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); - CRASH_COND(data == NULL); + CRASH_COND(data == nullptr); CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get(); if (script_binding.inited && !script_binding.gchandle.is_released()) { MonoObject *mono_object = script_binding.gchandle.get_target(); if (mono_object) { - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::dispose(mono_object, &exc); if (exc) { @@ -3122,15 +3123,15 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg if (!mono_object) { // Important to clear this before destroying the script instance here instance->script = Ref<CSharpScript>(); - instance->owner = NULL; + instance->owner = nullptr; bool die = instance->_unreference_owner_unsafe(); // Not ok for the owner to die here. If there is a situation where this can happen, it will be considered a bug. CRASH_COND(die == true); - p_owner->set_script_instance(NULL); + p_owner->set_script_instance(nullptr); r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL; - ERR_FAIL_V_MSG(NULL, "Failed to allocate memory for the object."); + ERR_FAIL_V_MSG(nullptr, "Failed to allocate memory for the object."); } // Tie managed to unmanaged @@ -3176,7 +3177,7 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal ref = REF(r); } - CSharpInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); + CSharpInstance *instance = _create_instance(p_args, p_argcount, owner, r != nullptr, r_error); if (!instance) { if (ref.is_null()) { memdelete(owner); //no owner, sorry @@ -3205,15 +3206,15 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { "Script inherits from native type '" + String(native_name) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"); } - ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + String(native_name) + - "', so it can't be instanced in object of type: '" + p_this->get_class() + "'."); + ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(native_name) + + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'."); } } GD_MONO_SCOPE_THREAD_ATTACH; Callable::CallError unchecked_error; - return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error); + return _create_instance(nullptr, 0, p_this, Object::cast_to<Reference>(p_this) != nullptr, unchecked_error); } PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) { @@ -3224,7 +3225,7 @@ PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_t _update_exports(); return si; #else - return NULL; + return nullptr; #endif } @@ -3332,7 +3333,7 @@ Error CSharpScript::reload(bool p_keep_state) { script_class = project_assembly->get_object_derived_class(name); } - valid = script_class != NULL; + valid = script_class != nullptr; if (script_class) { #ifdef DEBUG_ENABLED @@ -3354,7 +3355,7 @@ Error CSharpScript::reload(bool p_keep_state) { native = GDMonoUtils::get_class_native_base(script_class); - CRASH_COND(native == NULL); + CRASH_COND(native == nullptr); GDMonoClass *base_class = script_class->get_parent_class(); @@ -3766,7 +3767,7 @@ void ResourceFormatSaverCSharpScript::get_recognized_extensions(const RES &p_res bool ResourceFormatSaverCSharpScript::recognize(const RES &p_resource) const { - return Object::cast_to<CSharpScript>(p_resource.ptr()) != NULL; + return Object::cast_to<CSharpScript>(p_resource.ptr()) != nullptr; } CSharpLanguage::StringNameCache::StringNameCache() { diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 53b4aa6c20..29c33b50bb 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -77,8 +77,8 @@ public: }; struct EventSignal { - GDMonoField *field = NULL; - GDMonoMethod *invoke_method = NULL; + GDMonoField *field = nullptr; + GDMonoMethod *invoke_method = nullptr; Vector<SignalParameter> parameters; }; @@ -331,8 +331,8 @@ struct CSharpScriptBinding { CSharpScriptBinding() : inited(false), - wrapper_class(NULL), - owner(NULL) { + wrapper_class(nullptr), + owner(nullptr) { } }; diff --git a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs index e4c8759802..3cf495f025 100644 --- a/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs +++ b/modules/mono/editor/GodotTools/GodotTools/BottomPanel.cs @@ -205,9 +205,9 @@ namespace GodotTools if (what == EditorSettings.NotificationEditorSettingsChanged) { var editorBaseControl = editorInterface.GetBaseControl(); - panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles")); - panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles")); - panelTabs.AddStyleboxOverride("tab_bg", editorBaseControl.GetStylebox("DebuggerTabBG", "EditorStyles")); + panelTabs.AddThemeStyleboxOverride("panel", editorBaseControl.GetThemeStylebox("DebuggerPanel", "EditorStyles")); + panelTabs.AddThemeStyleboxOverride("tab_fg", editorBaseControl.GetThemeStylebox("DebuggerTabFG", "EditorStyles")); + panelTabs.AddThemeStyleboxOverride("tab_bg", editorBaseControl.GetThemeStylebox("DebuggerTabBG", "EditorStyles")); } } @@ -258,9 +258,9 @@ namespace GodotTools RectMinSize = new Vector2(0, 228) * EditorScale, SizeFlagsVertical = (int)SizeFlags.ExpandFill }; - panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles")); - panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles")); - panelTabs.AddStyleboxOverride("tab_bg", editorBaseControl.GetStylebox("DebuggerTabBG", "EditorStyles")); + panelTabs.AddThemeStyleboxOverride("panel", editorBaseControl.GetThemeStylebox("DebuggerPanel", "EditorStyles")); + panelTabs.AddThemeStyleboxOverride("tab_fg", editorBaseControl.GetThemeStylebox("DebuggerTabFG", "EditorStyles")); + panelTabs.AddThemeStyleboxOverride("tab_bg", editorBaseControl.GetThemeStylebox("DebuggerTabBG", "EditorStyles")); AddChild(panelTabs); { diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs index b2459b69ad..938c3d8be1 100644 --- a/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs +++ b/modules/mono/editor/GodotTools/GodotTools/BuildTab.cs @@ -46,12 +46,12 @@ namespace GodotTools get { if (!BuildExited) - return GetIcon("Stop", "EditorIcons"); + return GetThemeIcon("Stop", "EditorIcons"); if (BuildResult == BuildResults.Error) - return GetIcon("StatusError", "EditorIcons"); + return GetThemeIcon("StatusError", "EditorIcons"); - return GetIcon("StatusSuccess", "EditorIcons"); + return GetThemeIcon("StatusSuccess", "EditorIcons"); } } @@ -145,8 +145,8 @@ namespace GodotTools { issuesList.Clear(); - using (var warningIcon = GetIcon("Warning", "EditorIcons")) - using (var errorIcon = GetIcon("Error", "EditorIcons")) + using (var warningIcon = GetThemeIcon("Warning", "EditorIcons")) + using (var errorIcon = GetThemeIcon("Error", "EditorIcons")) { for (int i = 0; i < issues.Count; i++) { diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs new file mode 100755 index 0000000000..f1765f7e19 --- /dev/null +++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs @@ -0,0 +1,618 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using GodotTools.Internals; +using Directory = GodotTools.Utils.Directory; +using File = GodotTools.Utils.File; +using OS = GodotTools.Utils.OS; +using Path = System.IO.Path; + +namespace GodotTools.Export +{ + public struct AotOptions + { + public bool EnableLLVM; + public bool LLVMOnly; + public string LLVMPath; + public string LLVMOutputPath; + + public bool FullAot; + + private bool _useInterpreter; + public bool UseInterpreter { get => _useInterpreter && !LLVMOnly; set => _useInterpreter = value; } + + public string[] ExtraAotOptions; + public string[] ExtraOptimizerOptions; + + public string ToolchainPath; + } + + public static class AotBuilder + { + public static void CompileAssemblies(ExportPlugin exporter, AotOptions aotOpts, string[] features, string platform, bool isDebug, string bclDir, string outputDir, string outputDataDir, IDictionary<string, string> assemblies) + { + // TODO: WASM + + string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}"); + + if (!Directory.Exists(aotTempDir)) + Directory.CreateDirectory(aotTempDir); + + var assembliesPrepared = new Dictionary<string, string>(); + + foreach (var dependency in assemblies) + { + string assemblyName = dependency.Key; + string assemblyPath = dependency.Value; + + string assemblyPathInBcl = Path.Combine(bclDir, assemblyName + ".dll"); + + if (File.Exists(assemblyPathInBcl)) + { + // Don't create teporaries for assemblies from the BCL + assembliesPrepared.Add(assemblyName, assemblyPathInBcl); + } + else + { + string tempAssemblyPath = Path.Combine(aotTempDir, assemblyName + ".dll"); + File.Copy(assemblyPath, tempAssemblyPath); + assembliesPrepared.Add(assemblyName, tempAssemblyPath); + } + } + + if (platform == OS.Platforms.iOS) + { + var architectures = GetEnablediOSArchs(features).ToArray(); + CompileAssembliesForiOS(exporter, isDebug, architectures, aotOpts, aotTempDir, assembliesPrepared, bclDir); + } + else if (platform == OS.Platforms.Android) + { + var abis = GetEnabledAndroidAbis(features).ToArray(); + CompileAssembliesForAndroid(exporter, isDebug, abis, aotOpts, aotTempDir, assembliesPrepared, bclDir); + } + else + { + string bits = features.Contains("64") ? "64" : features.Contains("32") ? "32" : null; + CompileAssembliesForDesktop(exporter, platform, isDebug, bits, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir); + } + } + + public static void CompileAssembliesForAndroid(ExportPlugin exporter, bool isDebug, string[] abis, AotOptions aotOpts, string aotTempDir, IDictionary<string, string> assemblies, string bclDir) + { + + foreach (var assembly in assemblies) + { + string assemblyName = assembly.Key; + string assemblyPath = assembly.Value; + + // Not sure if the 'lib' prefix is an Android thing or just Godot being picky, + // but we use '-aot-' as well just in case to avoid conflicts with other libs. + string outputFileName = "lib-aot-" + assemblyName + ".dll.so"; + + foreach (string abi in abis) + { + string aotAbiTempDir = Path.Combine(aotTempDir, abi); + string soFilePath = Path.Combine(aotAbiTempDir, outputFileName); + + var compilerArgs = GetAotCompilerArgs(OS.Platforms.Android, isDebug, abi, aotOpts, assemblyPath, soFilePath); + + // Make sure the output directory exists + Directory.CreateDirectory(aotAbiTempDir); + + string compilerDirPath = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", $"{OS.Platforms.Android}-{abi}"); + + ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir); + + // The Godot exporter expects us to pass the abi in the tags parameter + exporter.AddSharedObject(soFilePath, tags: new[] { abi }); + } + } + } + + public static void CompileAssembliesForDesktop(ExportPlugin exporter, string platform, bool isDebug, string bits, AotOptions aotOpts, string aotTempDir, string outputDataDir, IDictionary<string, string> assemblies, string bclDir) + { + foreach (var assembly in assemblies) + { + string assemblyName = assembly.Key; + string assemblyPath = assembly.Value; + + string outputFileExtension = platform == OS.Platforms.Windows ? ".dll" : + platform == OS.Platforms.OSX ? ".dylib" : + ".so"; + + string outputFileName = assemblyName + ".dll" + outputFileExtension; + string tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); + + var compilerArgs = GetAotCompilerArgs(platform, isDebug, bits, aotOpts, assemblyPath, tempOutputFilePath); + + string compilerDirPath = GetMonoCrossDesktopDirName(platform, bits); + + ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir); + + if (platform == OS.Platforms.OSX) + { + exporter.AddSharedObject(tempOutputFilePath, tags: null); + } + else + { + string outputDataLibDir = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib"); + File.Copy(tempOutputFilePath, Path.Combine(outputDataLibDir, outputFileName)); + } + } + } + + public static void CompileAssembliesForiOS(ExportPlugin exporter, bool isDebug, string[] architectures, AotOptions aotOpts, string aotTempDir, IDictionary<string, string> assemblies, string bclDir) + { + var cppCode = new StringBuilder(); + var aotModuleInfoSymbols = new List<string>(assemblies.Count); + + // {arch: paths} + var objFilePathsForiOSArch = architectures.ToDictionary(arch => arch, arch => new List<string>(assemblies.Count)); + + foreach (var assembly in assemblies) + { + string assemblyName = assembly.Key; + string assemblyPath = assembly.Value; + + string asmFileName = assemblyName + ".dll.S"; + string objFileName = assemblyName + ".dll.o"; + + foreach (string arch in architectures) + { + string aotArchTempDir = Path.Combine(aotTempDir, arch); + string asmFilePath = Path.Combine(aotArchTempDir, asmFileName); + + var compilerArgs = GetAotCompilerArgs(OS.Platforms.iOS, isDebug, arch, aotOpts, assemblyPath, asmFilePath); + + // Make sure the output directory exists + Directory.CreateDirectory(aotArchTempDir); + + string compilerDirPath = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", $"{OS.Platforms.iOS}-{arch}"); + + ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir); + + // Assembling + bool isSim = arch == "i386" || arch == "x86_64"; // Shouldn't really happen as we don't do AOT for the simulator + string versionMinName = isSim ? "iphonesimulator" : "iphoneos"; + string iOSPlatformName = isSim ? "iPhoneSimulator" : "iPhoneOS"; + const string versionMin = "10.0"; // TODO: Turn this hard-coded version into an exporter setting + string iOSSdkPath = Path.Combine(XcodeHelper.XcodePath, + $"Contents/Developer/Platforms/{iOSPlatformName}.platform/Developer/SDKs/{iOSPlatformName}.sdk"); + + string objFilePath = Path.Combine(aotArchTempDir, objFileName); + + var clangArgs = new List<string>() + { + "-isysroot", iOSSdkPath, + "-Qunused-arguments", + $"-m{versionMinName}-version-min={versionMin}", + "-arch", arch, + "-c", + "-o", objFilePath, + "-x", "assembler" + }; + + if (isDebug) + clangArgs.Add("-DDEBUG"); + + clangArgs.Add(asmFilePath); + + int clangExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("clang"), clangArgs); + if (clangExitCode != 0) + throw new Exception($"Command 'clang' exited with code: {clangExitCode}"); + + objFilePathsForiOSArch[arch].Add(objFilePath); + } + + aotModuleInfoSymbols.Add($"mono_aot_module_{AssemblyNameToAotSymbol(assemblyName)}_info"); + } + + // Generate driver code + cppCode.AppendLine("#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)"); + cppCode.AppendLine("#define IOS_DEVICE"); + cppCode.AppendLine("#endif"); + + cppCode.AppendLine("#ifdef IOS_DEVICE"); + cppCode.AppendLine("extern \"C\" {"); + cppCode.AppendLine("// Mono API"); + cppCode.AppendLine(@" +typedef enum { +MONO_AOT_MODE_NONE, +MONO_AOT_MODE_NORMAL, +MONO_AOT_MODE_HYBRID, +MONO_AOT_MODE_FULL, +MONO_AOT_MODE_LLVMONLY, +MONO_AOT_MODE_INTERP, +MONO_AOT_MODE_INTERP_LLVMONLY, +MONO_AOT_MODE_LLVMONLY_INTERP, +MONO_AOT_MODE_LAST = 1000, +} MonoAotMode;"); + cppCode.AppendLine("void mono_jit_set_aot_mode(MonoAotMode);"); + cppCode.AppendLine("void mono_aot_register_module(void *);"); + + if (aotOpts.UseInterpreter) + { + cppCode.AppendLine("void mono_ee_interp_init(const char *);"); + cppCode.AppendLine("void mono_icall_table_init();"); + cppCode.AppendLine("void mono_marshal_ilgen_init();"); + cppCode.AppendLine("void mono_method_builder_ilgen_init();"); + cppCode.AppendLine("void mono_sgen_mono_ilgen_init();"); + } + + foreach (string symbol in aotModuleInfoSymbols) + cppCode.AppendLine($"extern void *{symbol};"); + + cppCode.AppendLine("void gd_mono_setup_aot() {"); + + foreach (string symbol in aotModuleInfoSymbols) + cppCode.AppendLine($"\tmono_aot_register_module({symbol});"); + + if (aotOpts.UseInterpreter) + { + cppCode.AppendLine("\tmono_icall_table_init();"); + cppCode.AppendLine("\tmono_marshal_ilgen_init();"); + cppCode.AppendLine("\tmono_method_builder_ilgen_init();"); + cppCode.AppendLine("\tmono_sgen_mono_ilgen_init();"); + cppCode.AppendLine("\tmono_ee_interp_init(0);"); + } + + string aotModeStr = null; + + if (aotOpts.LLVMOnly) + { + aotModeStr = "MONO_AOT_MODE_LLVMONLY"; // --aot=llvmonly + } + else + { + if (aotOpts.UseInterpreter) + aotModeStr = "MONO_AOT_MODE_INTERP"; // --aot=interp or --aot=interp,full + else if (aotOpts.FullAot) + aotModeStr = "MONO_AOT_MODE_FULL"; // --aot=full + } + + // One of the options above is always set for iOS + Debug.Assert(aotModeStr != null); + + cppCode.AppendLine($"\tmono_jit_set_aot_mode({aotModeStr});"); + + cppCode.AppendLine("} // gd_mono_setup_aot"); + cppCode.AppendLine("} // extern \"C\""); + cppCode.AppendLine("#endif // IOS_DEVICE"); + + // Add the driver code to the Xcode project + exporter.AddIosCppCode(cppCode.ToString()); + + // Archive the AOT object files into a static library + + var arFilePathsForAllArchs = new List<string>(); + string projectAssemblyName = GodotSharpEditor.ProjectAssemblyName; + + foreach (var archPathsPair in objFilePathsForiOSArch) + { + string arch = archPathsPair.Key; + var objFilePaths = archPathsPair.Value; + + string arOutputFilePath = Path.Combine(aotTempDir, $"lib-aot-{projectAssemblyName}.{arch}.a"); + + var arArgs = new List<string>() + { + "cr", + arOutputFilePath + }; + + foreach (string objFilePath in objFilePaths) + arArgs.Add(objFilePath); + + int arExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("ar"), arArgs); + if (arExitCode != 0) + throw new Exception($"Command 'ar' exited with code: {arExitCode}"); + + arFilePathsForAllArchs.Add(arOutputFilePath); + } + + // It's lipo time + + string fatOutputFileName = $"lib-aot-{projectAssemblyName}.fat.a"; + string fatOutputFilePath = Path.Combine(aotTempDir, fatOutputFileName); + + var lipoArgs = new List<string>(); + lipoArgs.Add("-create"); + lipoArgs.AddRange(arFilePathsForAllArchs); + lipoArgs.Add("-output"); + lipoArgs.Add(fatOutputFilePath); + + int lipoExitCode = OS.ExecuteCommand(XcodeHelper.FindXcodeTool("lipo"), lipoArgs); + if (lipoExitCode != 0) + throw new Exception($"Command 'lipo' exited with code: {lipoExitCode}"); + + // TODO: Add the AOT lib and interpreter libs as device only to supress warnings when targeting the simulator + + // Add the fat AOT static library to the Xcode project + exporter.AddIosProjectStaticLib(fatOutputFilePath); + + // Add the required Mono libraries to the Xcode project + + string MonoLibFile(string libFileName) => libFileName + ".iphone.fat.a"; + + string MonoLibFromTemplate(string libFileName) => + Path.Combine(Internal.FullTemplatesDir, "iphone-mono-libs", MonoLibFile(libFileName)); + + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmonosgen-2.0")); + + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-native")); + + if (aotOpts.UseInterpreter) + { + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-ee-interp")); + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-icall-table")); + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-ilgen")); + } + + // TODO: Turn into an exporter option + bool enableProfiling = false; + if (enableProfiling) + exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-profiler-log")); + + // Add frameworks required by Mono to the Xcode project + exporter.AddIosFramework("libiconv.tbd"); + exporter.AddIosFramework("GSS.framework"); + exporter.AddIosFramework("CFNetwork.framework"); + + // Force load and export dynamic are needed for the linker to not strip required symbols. + // In theory we shouldn't be relying on this for P/Invoked functions (as is the case with + // functions in System.Native/libmono-native). Instead, we should use cecil to search for + // DllImports in assemblies and pass them to 'ld' as '-u/--undefined {pinvoke_symbol}'. + exporter.AddIosLinkerFlags("-rdynamic"); + exporter.AddIosLinkerFlags($"-force_load \"$(SRCROOT)/{MonoLibFile("libmono-native")}\""); + } + + /// Converts an assembly name to a valid symbol name in the same way the AOT compiler does + private static string AssemblyNameToAotSymbol(string assemblyName) + { + var builder = new StringBuilder(); + + foreach (var charByte in Encoding.UTF8.GetBytes(assemblyName)) + { + char @char = (char)charByte; + builder.Append(Char.IsLetterOrDigit(@char) || @char == '_' ? @char : '_'); + } + + return builder.ToString(); + } + + private static IEnumerable<string> GetAotCompilerArgs(string platform, bool isDebug, string target, AotOptions aotOpts, string assemblyPath, string outputFilePath) + { + // TODO: LLVM + + bool aotSoftDebug = isDebug && !aotOpts.EnableLLVM; + bool aotDwarfDebug = platform == OS.Platforms.iOS; + + var aotOptions = new List<string>(); + var optimizerOptions = new List<string>(); + + if (aotOpts.LLVMOnly) + { + aotOptions.Add("llvmonly"); + } + else + { + // Can be both 'interp' and 'full' + if (aotOpts.UseInterpreter) + aotOptions.Add("interp"); + if (aotOpts.FullAot) + aotOptions.Add("full"); + } + + aotOptions.Add(aotSoftDebug ? "soft-debug" : "nodebug"); + + if (aotDwarfDebug) + aotOptions.Add("dwarfdebug"); + + if (platform == OS.Platforms.Android) + { + string abi = target; + + string androidToolchain = aotOpts.ToolchainPath; + + if (string.IsNullOrEmpty(androidToolchain)) + { + androidToolchain = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "android-toolchains", $"{abi}"); // TODO: $"{abi}-{apiLevel}{(clang?"clang":"")}" + + if (!Directory.Exists(androidToolchain)) + throw new FileNotFoundException("Missing android toolchain. Specify one in the AOT export settings."); + } + else if (!Directory.Exists(androidToolchain)) + { + throw new FileNotFoundException("Android toolchain not found: " + androidToolchain); + } + + var androidToolPrefixes = new Dictionary<string, string> + { + ["armeabi-v7a"] = "arm-linux-androideabi-", + ["arm64-v8a"] = "aarch64-linux-android-", + ["x86"] = "i686-linux-android-", + ["x86_64"] = "x86_64-linux-android-" + }; + + aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi])); + + string triple = GetAndroidTriple(abi); + aotOptions.Add($"mtriple={triple}"); + } + else if (platform == OS.Platforms.iOS) + { + if (!aotOpts.LLVMOnly && !aotOpts.UseInterpreter) + optimizerOptions.Add("gsharedvt"); + + aotOptions.Add("static"); + + // I couldn't get the Mono cross-compiler to do assembling, so we'll have to do it ourselves + aotOptions.Add("asmonly"); + + aotOptions.Add("direct-icalls"); + + if (aotSoftDebug) + aotOptions.Add("no-direct-calls"); + + if (aotOpts.LLVMOnly || !aotOpts.UseInterpreter) + aotOptions.Add("direct-pinvoke"); + + string arch = target; + aotOptions.Add($"mtriple={arch}-ios"); + } + + aotOptions.Add($"outfile={outputFilePath}"); + + if (aotOpts.EnableLLVM) + { + aotOptions.Add($"llvm-path={aotOpts.LLVMPath}"); + aotOptions.Add($"llvm-outfile={aotOpts.LLVMOutputPath}"); + } + + if (aotOpts.ExtraAotOptions.Length > 0) + aotOptions.AddRange(aotOpts.ExtraAotOptions); + + if (aotOpts.ExtraOptimizerOptions.Length > 0) + optimizerOptions.AddRange(aotOpts.ExtraOptimizerOptions); + + string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option; + string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption)); + + var runtimeArgs = new List<string>(); + + // The '--debug' runtime option is required when using the 'soft-debug' and 'dwarfdebug' AOT options + if (aotSoftDebug || aotDwarfDebug) + runtimeArgs.Add("--debug"); + + if (aotOpts.EnableLLVM) + runtimeArgs.Add("--llvm"); + + runtimeArgs.Add(aotOptions.Count > 0 ? $"--aot={OptionsToString(aotOptions)}" : "--aot"); + + if (optimizerOptions.Count > 0) + runtimeArgs.Add($"-O={OptionsToString(optimizerOptions)}"); + + runtimeArgs.Add(assemblyPath); + + return runtimeArgs; + } + + private static void ExecuteCompiler(string compiler, IEnumerable<string> compilerArgs, string bclDir) + { + // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead + string CmdLineArgsToString(IEnumerable<string> args) + { + // Not perfect, but as long as we are careful... + return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg)); + } + + using (var process = new Process()) + { + process.StartInfo = new ProcessStartInfo(compiler, CmdLineArgsToString(compilerArgs)) + { + UseShellExecute = false + }; + + process.StartInfo.EnvironmentVariables.Remove("MONO_ENV_OPTIONS"); + process.StartInfo.EnvironmentVariables.Remove("MONO_THREADS_SUSPEND"); + process.StartInfo.EnvironmentVariables.Add("MONO_PATH", bclDir); + + Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}"); + + if (!process.Start()) + throw new Exception("Failed to start process for Mono AOT compiler"); + + process.WaitForExit(); + + if (process.ExitCode != 0) + throw new Exception($"Mono AOT compiler exited with code: {process.ExitCode}"); + } + } + + private static IEnumerable<string> GetEnablediOSArchs(string[] features) + { + var iosArchs = new[] + { + "armv7", + "arm64" + }; + + return iosArchs.Where(features.Contains); + } + + private static IEnumerable<string> GetEnabledAndroidAbis(string[] features) + { + var androidAbis = new[] + { + "armeabi-v7a", + "arm64-v8a", + "x86", + "x86_64" + }; + + return androidAbis.Where(features.Contains); + } + + private static string GetAndroidTriple(string abi) + { + var abiArchs = new Dictionary<string, string> + { + ["armeabi-v7a"] = "armv7", + ["arm64-v8a"] = "aarch64-v8a", + ["x86"] = "i686", + ["x86_64"] = "x86_64" + }; + + string arch = abiArchs[abi]; + + return $"{arch}-linux-android"; + } + + private static string GetMonoCrossDesktopDirName(string platform, string bits) + { + switch (platform) + { + case OS.Platforms.Windows: + case OS.Platforms.UWP: + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"windows-{arch}"; + } + case OS.Platforms.OSX: + { + Debug.Assert(bits == null || bits == "64"); + string arch = "x86_64"; + return $"{platform}-{arch}"; + } + case OS.Platforms.X11: + case OS.Platforms.Server: + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"linux-{arch}"; + } + case OS.Platforms.Haiku: + { + string arch = bits == "64" ? "x86_64" : "i686"; + return $"{platform}-{arch}"; + } + default: + throw new NotSupportedException($"Platform not supported: {platform}"); + } + } + + // TODO: Replace this for a specific path for each platform + private static string FindCrossCompiler(string monoCrossBin) + { + string exeExt = OS.IsWindows ? ".exe" : string.Empty; + + var files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono-sgen{exeExt}", SearchOption.TopDirectoryOnly); + if (files.Length > 0) + return Path.Combine(monoCrossBin, files[0].Name); + + throw new FileNotFoundException($"Cannot find the mono runtime executable in {monoCrossBin}"); + } + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index 022005ad0b..d782d4e61b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -29,15 +29,13 @@ namespace GodotTools.Export All = CJK | MidEast | Other | Rare | West } - private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string platform) + private void AddI18NAssemblies(Godot.Collections.Dictionary<string, string> assemblies, string bclDir) { - var codesets = (I18NCodesets) ProjectSettings.GetSetting("mono/export/i18n_codesets"); + var codesets = (I18NCodesets)ProjectSettings.GetSetting("mono/export/i18n_codesets"); if (codesets == I18NCodesets.None) return; - string bclDir = DeterminePlatformBclDir(platform) ?? typeof(object).Assembly.Location.GetBaseDir(); - void AddI18NAssembly(string name) => assemblies.Add(name, Path.Combine(bclDir, $"{name}.dll")); AddI18NAssembly("I18N"); @@ -73,6 +71,7 @@ namespace GodotTools.Export GlobalDef("mono/export/aot/enabled", false); GlobalDef("mono/export/aot/full_aot", false); + GlobalDef("mono/export/aot/use_interpreter", true); // --aot or --aot=opt1,opt2 (use 'mono --aot=help AuxAssembly.dll' to list AOT options) GlobalDef("mono/export/aot/extra_aot_options", new string[] { }); @@ -86,9 +85,11 @@ namespace GodotTools.Export private void AddFile(string srcPath, string dstPath, bool remap = false) { + // Add file to the PCK AddFile(dstPath.Replace("\\", "/"), File.ReadAllBytes(srcPath), remap); } + // With this method we can override how a file is exported in the PCK public override void _ExportFile(string path, string type, string[] features) { base._ExportFile(path, type, features); @@ -110,6 +111,8 @@ namespace GodotTools.Export // Sadly, Godot prints errors when adding an empty file (nothing goes wrong, it's just noise). // Because of this, we add a file which contains a line break. AddFile(path, System.Text.Encoding.UTF8.GetBytes("\n"), remap: false); + + // Tell the Godot exporter that we already took care of the file Skip(); } } @@ -167,12 +170,7 @@ namespace GodotTools.Export var dependencies = new Godot.Collections.Dictionary<string, string>(); - var projectDllName = (string)ProjectSettings.GetSetting("application/config/name"); - if (projectDllName.Empty()) - { - projectDllName = "UnnamedProject"; - } - + string projectDllName = GodotSharpEditor.ProjectAssemblyName; string projectDllSrcDir = Path.Combine(GodotSharpDirs.ResTempAssembliesBaseDir, buildConfig); string projectDllSrcPath = Path.Combine(projectDllSrcDir, $"{projectDllName}.dll"); @@ -189,10 +187,12 @@ namespace GodotTools.Export dependencies["Mono.Android"] = monoAndroidAssemblyPath; } + string bclDir = DeterminePlatformBclDir(platform); + var initialDependencies = dependencies.Duplicate(); - internal_GetExportedAssemblyDependencies(initialDependencies, buildConfig, DeterminePlatformBclDir(platform), dependencies); + internal_GetExportedAssemblyDependencies(initialDependencies, buildConfig, bclDir, dependencies); - AddI18NAssemblies(dependencies, platform); + AddI18NAssemblies(dependencies, bclDir); string outputDataDir = null; @@ -227,11 +227,34 @@ namespace GodotTools.Export } } - // AOT + // AOT compilation + bool aotEnabled = platform == OS.Platforms.iOS || (bool)ProjectSettings.GetSetting("mono/export/aot/enabled"); - if ((bool)ProjectSettings.GetSetting("mono/export/aot/enabled")) + if (aotEnabled) { - AotCompileDependencies(features, platform, isDebug, outputDir, outputDataDir, dependencies); + string aotToolchainPath = null; + + if (platform == OS.Platforms.Android) + aotToolchainPath = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path"); + + if (aotToolchainPath == string.Empty) + aotToolchainPath = null; // Don't risk it being used as current working dir + + // TODO: LLVM settings are hard-coded and disabled for now + var aotOpts = new AotOptions + { + EnableLLVM = false, + LLVMOnly = false, + LLVMPath = "", + LLVMOutputPath = "", + FullAot = platform == OS.Platforms.iOS || (bool)(ProjectSettings.GetSetting("mono/export/aot/full_aot") ?? false), + UseInterpreter = (bool)ProjectSettings.GetSetting("mono/export/aot/use_interpreter"), + ExtraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options") ?? new string[] { }, + ExtraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options") ?? new string[] { }, + ToolchainPath = aotToolchainPath + }; + + AotBuilder.CompileAssemblies(this, aotOpts, features, platform, isDebug, bclDir, outputDir, outputDataDir, dependencies); } } @@ -258,7 +281,8 @@ namespace GodotTools.Export { string target = isDebug ? "release_debug" : "release"; - // NOTE: Bits is ok for now as all platforms with a data directory have it, but that may change in the future. + // NOTE: Bits is ok for now as all platforms with a data directory only have one or two architectures. + // However, this may change in the future if we add arm linux or windows desktop templates. string bits = features.Contains("64") ? "64" : "32"; string TemplateDirName() => $"data.mono.{platform}.{bits}.{target}"; @@ -284,7 +308,7 @@ namespace GodotTools.Export if (!validTemplatePathFound) throw new FileNotFoundException("Data template directory not found", templateDirPath); - string outputDataDir = Path.Combine(outputDir, DataDirName); + string outputDataDir = Path.Combine(outputDir, DetermineDataDirNameForProject()); if (Directory.Exists(outputDataDir)) Directory.Delete(outputDataDir, recursive: true); // Clean first @@ -304,333 +328,10 @@ namespace GodotTools.Export return outputDataDir; } - private void AotCompileDependencies(string[] features, string platform, bool isDebug, string outputDir, string outputDataDir, IDictionary<string, string> dependencies) - { - // TODO: WASM - - string bclDir = DeterminePlatformBclDir(platform) ?? typeof(object).Assembly.Location.GetBaseDir(); - - string aotTempDir = Path.Combine(Path.GetTempPath(), $"godot-aot-{Process.GetCurrentProcess().Id}"); - - if (!Directory.Exists(aotTempDir)) - Directory.CreateDirectory(aotTempDir); - - var assemblies = new Dictionary<string, string>(); - - foreach (var dependency in dependencies) - { - string assemblyName = dependency.Key; - string assemblyPath = dependency.Value; - - string assemblyPathInBcl = Path.Combine(bclDir, assemblyName + ".dll"); - - if (File.Exists(assemblyPathInBcl)) - { - // Don't create teporaries for assemblies from the BCL - assemblies.Add(assemblyName, assemblyPathInBcl); - } - else - { - string tempAssemblyPath = Path.Combine(aotTempDir, assemblyName + ".dll"); - File.Copy(assemblyPath, tempAssemblyPath); - assemblies.Add(assemblyName, tempAssemblyPath); - } - } - - foreach (var assembly in assemblies) - { - string assemblyName = assembly.Key; - string assemblyPath = assembly.Value; - - string sharedLibExtension = platform == OS.Platforms.Windows ? ".dll" : - platform == OS.Platforms.OSX ? ".dylib" : - platform == OS.Platforms.HTML5 ? ".wasm" : - ".so"; - - string outputFileName = assemblyName + ".dll" + sharedLibExtension; - - if (platform == OS.Platforms.Android) - { - // Not sure if the 'lib' prefix is an Android thing or just Godot being picky, - // but we use '-aot-' as well just in case to avoid conflicts with other libs. - outputFileName = "lib-aot-" + outputFileName; - } - - string outputFilePath = null; - string tempOutputFilePath; - - switch (platform) - { - case OS.Platforms.OSX: - tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); - break; - case OS.Platforms.Android: - tempOutputFilePath = Path.Combine(aotTempDir, "%%ANDROID_ABI%%", outputFileName); - break; - case OS.Platforms.HTML5: - tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); - outputFilePath = Path.Combine(outputDir, outputFileName); - break; - default: - tempOutputFilePath = Path.Combine(aotTempDir, outputFileName); - outputFilePath = Path.Combine(outputDataDir, "Mono", platform == OS.Platforms.Windows ? "bin" : "lib", outputFileName); - break; - } - - var data = new Dictionary<string, string>(); - var enabledAndroidAbis = platform == OS.Platforms.Android ? GetEnabledAndroidAbis(features).ToArray() : null; - - if (platform == OS.Platforms.Android) - { - Debug.Assert(enabledAndroidAbis != null); - - foreach (var abi in enabledAndroidAbis) - { - data["abi"] = abi; - var outputFilePathForThisAbi = tempOutputFilePath.Replace("%%ANDROID_ABI%%", abi); - - AotCompileAssembly(platform, isDebug, data, assemblyPath, outputFilePathForThisAbi); - - AddSharedObject(outputFilePathForThisAbi, tags: new[] { abi }); - } - } - else - { - string bits = features.Contains("64") ? "64" : features.Contains("64") ? "32" : null; - - if (bits != null) - data["bits"] = bits; - - AotCompileAssembly(platform, isDebug, data, assemblyPath, tempOutputFilePath); - - if (platform == OS.Platforms.OSX) - { - AddSharedObject(tempOutputFilePath, tags: null); - } - else - { - Debug.Assert(outputFilePath != null); - File.Copy(tempOutputFilePath, outputFilePath); - } - } - } - } - - private static void AotCompileAssembly(string platform, bool isDebug, Dictionary<string, string> data, string assemblyPath, string outputFilePath) - { - // Make sure the output directory exists - Directory.CreateDirectory(outputFilePath.GetBaseDir()); - - string exeExt = OS.IsWindows ? ".exe" : string.Empty; - - string monoCrossDirName = DetermineMonoCrossDirName(platform, data); - string monoCrossRoot = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "aot-compilers", monoCrossDirName); - string monoCrossBin = Path.Combine(monoCrossRoot, "bin"); - - string toolPrefix = DetermineToolPrefix(monoCrossBin); - string monoExeName = System.IO.File.Exists(Path.Combine(monoCrossBin, $"{toolPrefix}mono{exeExt}")) ? "mono" : "mono-sgen"; - - string compilerCommand = Path.Combine(monoCrossBin, $"{toolPrefix}{monoExeName}{exeExt}"); - - bool fullAot = (bool)ProjectSettings.GetSetting("mono/export/aot/full_aot"); - - string EscapeOption(string option) => option.Contains(',') ? $"\"{option}\"" : option; - string OptionsToString(IEnumerable<string> options) => string.Join(",", options.Select(EscapeOption)); - - var aotOptions = new List<string>(); - var optimizerOptions = new List<string>(); - - if (fullAot) - aotOptions.Add("full"); - - aotOptions.Add(isDebug ? "soft-debug" : "nodebug"); - - if (platform == OS.Platforms.Android) - { - string abi = data["abi"]; - - string androidToolchain = (string)ProjectSettings.GetSetting("mono/export/aot/android_toolchain_path"); - - if (string.IsNullOrEmpty(androidToolchain)) - { - androidToolchain = Path.Combine(GodotSharpDirs.DataEditorToolsDir, "android-toolchains", $"{abi}"); // TODO: $"{abi}-{apiLevel}{(clang?"clang":"")}" - - if (!Directory.Exists(androidToolchain)) - throw new FileNotFoundException("Missing android toolchain. Specify one in the AOT export settings."); - } - else if (!Directory.Exists(androidToolchain)) - { - throw new FileNotFoundException("Android toolchain not found: " + androidToolchain); - } - - var androidToolPrefixes = new Dictionary<string, string> - { - ["armeabi-v7a"] = "arm-linux-androideabi-", - ["arm64-v8a"] = "aarch64-linux-android-", - ["x86"] = "i686-linux-android-", - ["x86_64"] = "x86_64-linux-android-" - }; - - aotOptions.Add("tool-prefix=" + Path.Combine(androidToolchain, "bin", androidToolPrefixes[abi])); - - string triple = GetAndroidTriple(abi); - aotOptions.Add($"mtriple={triple}"); - } - - aotOptions.Add($"outfile={outputFilePath}"); - - var extraAotOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_aot_options"); - var extraOptimizerOptions = (string[])ProjectSettings.GetSetting("mono/export/aot/extra_optimizer_options"); - - if (extraAotOptions.Length > 0) - aotOptions.AddRange(extraAotOptions); - - if (extraOptimizerOptions.Length > 0) - optimizerOptions.AddRange(extraOptimizerOptions); - - var compilerArgs = new List<string>(); - - if (isDebug) - compilerArgs.Add("--debug"); // Required for --aot=soft-debug - - compilerArgs.Add(aotOptions.Count > 0 ? $"--aot={OptionsToString(aotOptions)}" : "--aot"); - - if (optimizerOptions.Count > 0) - compilerArgs.Add($"-O={OptionsToString(optimizerOptions)}"); - - compilerArgs.Add(ProjectSettings.GlobalizePath(assemblyPath)); - - // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead - string CmdLineArgsToString(IEnumerable<string> args) - { - // Not perfect, but as long as we are careful... - return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg)); - } - - using (var process = new Process()) - { - process.StartInfo = new ProcessStartInfo(compilerCommand, CmdLineArgsToString(compilerArgs)) - { - UseShellExecute = false - }; - - string platformBclDir = DeterminePlatformBclDir(platform); - process.StartInfo.EnvironmentVariables.Add("MONO_PATH", string.IsNullOrEmpty(platformBclDir) ? - typeof(object).Assembly.Location.GetBaseDir() : - platformBclDir); - - Console.WriteLine($"Running: \"{process.StartInfo.FileName}\" {process.StartInfo.Arguments}"); - - if (!process.Start()) - throw new Exception("Failed to start process for Mono AOT compiler"); - - process.WaitForExit(); - - if (process.ExitCode != 0) - throw new Exception($"Mono AOT compiler exited with error code: {process.ExitCode}"); - - if (!System.IO.File.Exists(outputFilePath)) - throw new Exception("Mono AOT compiler finished successfully but the output file is missing"); - } - } - - private static string DetermineMonoCrossDirName(string platform, IReadOnlyDictionary<string, string> data) - { - switch (platform) - { - case OS.Platforms.Windows: - case OS.Platforms.UWP: - { - string arch = data["bits"] == "64" ? "x86_64" : "i686"; - return $"windows-{arch}"; - } - case OS.Platforms.OSX: - { - string arch = "x86_64"; - return $"{platform}-{arch}"; - } - case OS.Platforms.X11: - case OS.Platforms.Server: - { - string arch = data["bits"] == "64" ? "x86_64" : "i686"; - return $"linux-{arch}"; - } - case OS.Platforms.Haiku: - { - string arch = data["bits"] == "64" ? "x86_64" : "i686"; - return $"{platform}-{arch}"; - } - case OS.Platforms.Android: - { - string abi = data["abi"]; - return $"{platform}-{abi}"; - } - case OS.Platforms.HTML5: - return "wasm-wasm32"; - default: - throw new NotSupportedException($"Platform not supported: {platform}"); - } - } - - private static string DetermineToolPrefix(string monoCrossBin) - { - string exeExt = OS.IsWindows ? ".exe" : string.Empty; - - if (System.IO.File.Exists(Path.Combine(monoCrossBin, $"mono{exeExt}"))) - return string.Empty; - - if (System.IO.File.Exists(Path.Combine(monoCrossBin, $"mono-sgen{exeExt}" + exeExt))) - return string.Empty; - - var files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono{exeExt}" + exeExt, SearchOption.TopDirectoryOnly); - if (files.Length > 0) - { - string fileName = files[0].Name; - return fileName.Substring(0, fileName.Length - $"mono{exeExt}".Length); - } - - files = new DirectoryInfo(monoCrossBin).GetFiles($"*mono-sgen{exeExt}" + exeExt, SearchOption.TopDirectoryOnly); - if (files.Length > 0) - { - string fileName = files[0].Name; - return fileName.Substring(0, fileName.Length - $"mono-sgen{exeExt}".Length); - } - - throw new FileNotFoundException($"Cannot find the mono runtime executable in {monoCrossBin}"); - } - - private static IEnumerable<string> GetEnabledAndroidAbis(string[] features) - { - var androidAbis = new[] - { - "armeabi-v7a", - "arm64-v8a", - "x86", - "x86_64" - }; - - return androidAbis.Where(features.Contains); - } - - private static string GetAndroidTriple(string abi) - { - var abiArchs = new Dictionary<string, string> - { - ["armeabi-v7a"] = "armv7", - ["arm64-v8a"] = "aarch64-v8a", - ["x86"] = "i686", - ["x86_64"] = "x86_64" - }; - - string arch = abiArchs[abi]; - - return $"{arch}-linux-android"; - } - private static bool PlatformHasTemplateDir(string platform) { // OSX export templates are contained in a zip, so we place our custom template inside it and let Godot do the rest. - return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform); + return !new[] { OS.Platforms.OSX, OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform); } private static string DeterminePlatformFromFeatures(IEnumerable<string> features) @@ -665,7 +366,7 @@ namespace GodotTools.Export if (PlatformRequiresCustomBcl(platform)) throw new FileNotFoundException($"Missing BCL (Base Class Library) for platform: {platform}"); - platformBclDir = null; // Use the one we're running on + platformBclDir = typeof(object).Assembly.Location; // Use the one we're running on } } @@ -678,7 +379,7 @@ namespace GodotTools.Export /// </summary> private static bool PlatformRequiresCustomBcl(string platform) { - if (new[] { OS.Platforms.Android, OS.Platforms.HTML5 }.Contains(platform)) + if (new[] { OS.Platforms.Android, OS.Platforms.iOS, OS.Platforms.HTML5 }.Contains(platform)) return true; // The 'net_4_x' BCL is not compatible between Windows and the other platforms. @@ -707,6 +408,8 @@ namespace GodotTools.Export return "net_4_x"; case OS.Platforms.Android: return "monodroid"; + case OS.Platforms.iOS: + return "monotouch"; case OS.Platforms.HTML5: return "wasm"; default: @@ -714,14 +417,11 @@ namespace GodotTools.Export } } - private static string DataDirName + private static string DetermineDataDirNameForProject() { - get - { - var appName = (string)ProjectSettings.GetSetting("application/config/name"); - string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false); - return $"data_{appNameSafe}"; - } + var appName = (string)ProjectSettings.GetSetting("application/config/name"); + string appNameSafe = appName.ToSafeDirName(allowDirSeparator: false); + return $"data_{appNameSafe}"; } [MethodImpl(MethodImplOptions.InternalCall)] diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs new file mode 100755 index 0000000000..219b7a698a --- /dev/null +++ b/modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs @@ -0,0 +1,93 @@ +using System; +using System.IO; + +namespace GodotTools.Export +{ + public static class XcodeHelper + { + private static string _XcodePath = null; + + public static string XcodePath + { + get + { + if (_XcodePath == null) + { + _XcodePath = FindXcode(); + + if (_XcodePath == null) + throw new Exception("Could not find Xcode"); + } + + return _XcodePath; + } + } + + private static string FindSelectedXcode() + { + var outputWrapper = new Godot.Collections.Array(); + + int exitCode = Godot.OS.Execute("xcode-select", new string[] { "--print-path" }, blocking: true, output: outputWrapper); + + if (exitCode == 0) + { + string output = (string)outputWrapper[0]; + return output.Trim(); + } + + Console.Error.WriteLine($"'xcode-select --print-path' exited with code: {exitCode}"); + + return null; + } + + public static string FindXcode() + { + string selectedXcode = FindSelectedXcode(); + if (selectedXcode != null) + { + if (Directory.Exists(Path.Combine(selectedXcode, "Contents", "Developer"))) + return selectedXcode; + + // The path already pointed to Contents/Developer + var dirInfo = new DirectoryInfo(selectedXcode); + if (dirInfo.Name != "Developer" || dirInfo.Parent.Name != "Contents") + { + Console.WriteLine(Path.GetDirectoryName(selectedXcode)); + Console.WriteLine(System.IO.Directory.GetParent(selectedXcode).Name); + Console.Error.WriteLine("Unrecognized path for selected Xcode"); + } + else + { + return System.IO.Path.GetFullPath($"{selectedXcode}/../.."); + } + } + else + { + Console.Error.WriteLine("Could not find the selected Xcode; trying with a hint path"); + } + + const string XcodeHintPath = "/Applications/Xcode.app"; + + if (Directory.Exists(XcodeHintPath)) + { + if (Directory.Exists(Path.Combine(XcodeHintPath, "Contents", "Developer"))) + return XcodeHintPath; + + Console.Error.WriteLine($"Found Xcode at '{XcodeHintPath}' but it's missing the 'Contents/Developer' sub-directory"); + } + + return null; + } + + public static string FindXcodeTool(string toolName) + { + string XcodeDefaultToolchain = Path.Combine(XcodePath, "Contents", "Developer", "Toolchains", "XcodeDefault.xctoolchain"); + + string path = Path.Combine(XcodeDefaultToolchain, "usr", "bin", toolName); + if (File.Exists(path)) + return path; + + throw new FileNotFoundException($"Cannot find Xcode tool: {toolName}"); + } + } +} diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index e6d5dd9895..c9d7dd26f8 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -36,6 +36,17 @@ namespace GodotTools public BottomPanel BottomPanel { get; private set; } + public static string ProjectAssemblyName + { + get + { + var projectAssemblyName = (string)ProjectSettings.GetSetting("application/config/name"); + if (string.IsNullOrEmpty(projectAssemblyName)) + projectAssemblyName = "UnnamedProject"; + return projectAssemblyName; + } + } + private bool CreateProjectSolution() { using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 3)) @@ -45,9 +56,7 @@ namespace GodotTools string resourceDir = ProjectSettings.GlobalizePath("res://"); string path = resourceDir; - string name = (string)ProjectSettings.GetSetting("application/config/name"); - if (name.Empty()) - name = "UnnamedProject"; + string name = ProjectAssemblyName; string guid = CsProjOperations.GenerateGameProject(path, name); @@ -119,7 +128,7 @@ namespace GodotTools { bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); aboutDialogCheckBox.Pressed = showOnStart; - aboutDialog.PopupCenteredMinsize(); + aboutDialog.PopupCentered(); } private void _MenuOptionPressed(int id) @@ -157,10 +166,10 @@ namespace GodotTools bool showInfoDialog = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start"); if (showInfoDialog) { - aboutDialog.PopupExclusive = true; + aboutDialog.Exclusive = true; _ShowAboutDialog(); // Once shown a first time, it can be seen again via the Mono menu - it doesn't have to be exclusive from that time on. - aboutDialog.PopupExclusive = false; + aboutDialog.Exclusive = false; } var fileSystemDock = GetEditorInterface().GetFileSystemDock(); @@ -203,9 +212,9 @@ namespace GodotTools public void ShowErrorDialog(string message, string title = "Error") { - errorDialog.WindowTitle = title; + errorDialog.Title = title; errorDialog.DialogText = message; - errorDialog.PopupCenteredMinsize(); + errorDialog.PopupCentered(); } private static string _vsCodePath = string.Empty; @@ -374,7 +383,6 @@ namespace GodotTools menuPopup = new PopupMenu(); menuPopup.Hide(); - menuPopup.SetAsToplevel(true); AddToolSubmenuItem("Mono", menuPopup); @@ -383,7 +391,7 @@ namespace GodotTools menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp); aboutDialog = new AcceptDialog(); editorBaseControl.AddChild(aboutDialog); - aboutDialog.WindowTitle = "Important: C# support is not feature-complete"; + aboutDialog.Title = "Important: C# support is not feature-complete"; // We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox // we'll add. Instead we add containers and a new autowrapped Label inside. @@ -397,7 +405,7 @@ namespace GodotTools aboutVBox.AddChild(aboutHBox); var aboutIcon = new TextureRect(); - aboutIcon.Texture = aboutIcon.GetIcon("NodeWarning", "EditorIcons"); + aboutIcon.Texture = aboutIcon.GetThemeIcon("NodeWarning", "EditorIcons"); aboutHBox.AddChild(aboutIcon); var aboutLabel = new Label(); diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index 379dfd9f7d..ac9379adf8 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -51,7 +51,9 @@ </ItemGroup> <ItemGroup> <Compile Include="Build\MsBuildFinder.cs" /> + <Compile Include="Export\AotBuilder.cs" /> <Compile Include="Export\ExportPlugin.cs" /> + <Compile Include="Export\XcodeHelper.cs" /> <Compile Include="ExternalEditorId.cs" /> <Compile Include="Ides\GodotIdeManager.cs" /> <Compile Include="Ides\GodotIdeServer.cs" /> diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs index 1d19fab706..ae05710f4f 100644 --- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs +++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs @@ -10,7 +10,7 @@ namespace GodotTools public override void _Notification(int what) { - if (what == MainLoop.NotificationWmFocusIn) + if (what == Node.NotificationWmFocusIn) { RestartTimer(); diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs index 11a4109d97..b057ac12c6 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using JetBrains.Annotations; namespace GodotTools.Utils { @@ -26,6 +27,7 @@ namespace GodotTools.Utils public const string UWP = "UWP"; public const string Haiku = "Haiku"; public const string Android = "Android"; + public const string iOS = "iOS"; public const string HTML5 = "HTML5"; } @@ -38,6 +40,7 @@ namespace GodotTools.Utils public const string UWP = "uwp"; public const string Haiku = "haiku"; public const string Android = "android"; + public const string iOS = "iphone"; public const string HTML5 = "javascript"; } @@ -50,6 +53,7 @@ namespace GodotTools.Utils [Names.UWP] = Platforms.UWP, [Names.Haiku] = Platforms.Haiku, [Names.Android] = Platforms.Android, + [Names.iOS] = Platforms.iOS, [Names.HTML5] = Platforms.HTML5 }; @@ -65,6 +69,7 @@ namespace GodotTools.Utils private static readonly Lazy<bool> _isUWP = new Lazy<bool>(() => IsOS(Names.UWP)); private static readonly Lazy<bool> _isHaiku = new Lazy<bool>(() => IsOS(Names.Haiku)); private static readonly Lazy<bool> _isAndroid = new Lazy<bool>(() => IsOS(Names.Android)); + private static readonly Lazy<bool> _isiOS = new Lazy<bool>(() => IsOS(Names.iOS)); private static readonly Lazy<bool> _isHTML5 = new Lazy<bool>(() => IsOS(Names.HTML5)); public static bool IsWindows => _isWindows.Value || IsUWP; @@ -74,10 +79,11 @@ namespace GodotTools.Utils public static bool IsUWP => _isUWP.Value; public static bool IsHaiku => _isHaiku.Value; public static bool IsAndroid => _isAndroid.Value; + public static bool IsiOS => _isiOS.Value; public static bool IsHTML5 => _isHTML5.Value; private static bool? _isUnixCache; - private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android }; + private static readonly string[] UnixLikePlatforms = { Names.OSX, Names.X11, Names.Server, Names.Haiku, Names.Android, Names.iOS }; public static bool IsUnixLike() { @@ -91,12 +97,12 @@ namespace GodotTools.Utils public static char PathSep => IsWindows ? ';' : ':'; - public static string PathWhich(string name) + public static string PathWhich([NotNull] string name) { return IsWindows ? PathWhichWindows(name) : PathWhichUnix(name); } - private static string PathWhichWindows(string name) + private static string PathWhichWindows([NotNull] string name) { string[] windowsExts = Environment.GetEnvironmentVariable("PATHEXT")?.Split(PathSep) ?? new string[] { }; string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); @@ -121,7 +127,7 @@ namespace GodotTools.Utils select path + ext).FirstOrDefault(File.Exists); } - private static string PathWhichUnix(string name) + private static string PathWhichUnix([NotNull] string name) { string[] pathDirs = Environment.GetEnvironmentVariable("PATH")?.Split(PathSep); @@ -163,5 +169,33 @@ namespace GodotTools.Utils User32Dll.AllowSetForegroundWindow(process.Id); // allows application to focus itself } } + + public static int ExecuteCommand(string command, IEnumerable<string> arguments) + { + // TODO: Once we move to .NET Standard 2.1 we can use ProcessStartInfo.ArgumentList instead + string CmdLineArgsToString(IEnumerable<string> args) + { + // Not perfect, but as long as we are careful... + return string.Join(" ", args.Select(arg => arg.Contains(" ") ? $@"""{arg}""" : arg)); + } + + var startInfo = new ProcessStartInfo(command, CmdLineArgsToString(arguments)); + + Console.WriteLine($"Executing: \"{startInfo.FileName}\" {startInfo.Arguments}"); + + // Print the output + startInfo.RedirectStandardOutput = false; + startInfo.RedirectStandardError = false; + + startInfo.UseShellExecute = false; + + using (var process = new Process { StartInfo = startInfo }) + { + process.Start(); + process.WaitForExit(); + + return process.ExitCode; + } + } } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 9a5de6db16..71bb8ff851 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -411,7 +411,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("\"/>"); } else { // Try to find as global enum constant - const EnumInterface *target_ienum = NULL; + const EnumInterface *target_ienum = nullptr; for (const List<EnumInterface>::Element *E = global_enums.front(); E; E = E->next()) { target_ienum = &E->get(); @@ -449,7 +449,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("\"/>"); } else { // Try to find as enum constant in the current class - const EnumInterface *target_ienum = NULL; + const EnumInterface *target_ienum = nullptr; for (const List<EnumInterface>::Element *E = target_itype->enums.front(); E; E = E->next()) { target_ienum = &E->get(); @@ -782,7 +782,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { const ConstantInterface &iconstant = E->get(); if (iconstant.const_doc && iconstant.const_doc->description.size()) { - String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), NULL); + String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); if (summary_lines.size()) { @@ -843,7 +843,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { const ConstantInterface &iconstant = F->get(); if (iconstant.const_doc && iconstant.const_doc->description.size()) { - String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), NULL); + String xml_summary = bbcode_to_xml(fix_doc_description(iconstant.const_doc->description), nullptr); Vector<String> summary_lines = xml_summary.length() ? xml_summary.split("\n") : Vector<String>(); if (summary_lines.size()) { @@ -1406,7 +1406,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte const TypeInterface *current_type = &p_itype; while (!setter && current_type->base_name != StringName()) { OrderedHashMap<StringName, TypeInterface>::Element base_match = obj_types.find(current_type->base_name); - ERR_FAIL_COND_V(!base_match, ERR_BUG); + ERR_FAIL_COND_V_MSG(!base_match, ERR_BUG, "Type not found '" + current_type->base_name + "'. Inherited by '" + current_type->name + "'."); current_type = &base_match.get(); setter = current_type->find_method_by_name(p_iprop.setter); } @@ -1417,7 +1417,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte current_type = &p_itype; while (!getter && current_type->base_name != StringName()) { OrderedHashMap<StringName, TypeInterface>::Element base_match = obj_types.find(current_type->base_name); - ERR_FAIL_COND_V(!base_match, ERR_BUG); + ERR_FAIL_COND_V_MSG(!base_match, ERR_BUG, "Type not found '" + current_type->base_name + "'. Inherited by '" + current_type->name + "'."); current_type = &base_match.get(); getter = current_type->find_method_by_name(p_iprop.getter); } @@ -1494,7 +1494,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte if (idx_arg.type.cname != name_cache.type_int) { // Assume the index parameter is an enum const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type); - CRASH_COND(idx_arg_type == NULL); + CRASH_COND(idx_arg_type == nullptr); p_output.append("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index)); } else { p_output.append(itos(p_iprop.index)); @@ -1522,7 +1522,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte if (idx_arg.type.cname != name_cache.type_int) { // Assume the index parameter is an enum const TypeInterface *idx_arg_type = _get_type_or_null(idx_arg.type); - CRASH_COND(idx_arg_type == NULL); + CRASH_COND(idx_arg_type == nullptr); p_output.append("(" + idx_arg_type->proxy_name + ")" + itos(p_iprop.index) + ", "); } else { p_output.append(itos(p_iprop.index) + ", "); @@ -1631,7 +1631,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf // Generate method { if (!p_imethod.is_virtual && !p_imethod.requires_object_call) { - p_output.append(MEMBER_BEGIN "[DebuggerBrowsable(DebuggerBrowsableState.Never)]" MEMBER_BEGIN "private static IntPtr "); + p_output.append(MEMBER_BEGIN "[DebuggerBrowsable(DebuggerBrowsableState.Never)]" MEMBER_BEGIN "private static readonly IntPtr "); p_output.append(method_bind_field); p_output.append(" = Object." ICALL_GET_METHODBIND "(" BINDINGS_NATIVE_NAME_FIELD ", \""); p_output.append(p_imethod.name); @@ -2121,7 +2121,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte if (return_type->is_object_type) { ptrcall_return_type = return_type->is_reference ? "Ref<Reference>" : return_type->c_type; - initialization = return_type->is_reference ? "" : " = NULL"; + initialization = return_type->is_reference ? "" : " = nullptr"; } else { ptrcall_return_type = return_type->c_type; } @@ -2130,10 +2130,10 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte p_output.append(" " C_LOCAL_RET); p_output.append(initialization + ";\n"); - String fail_ret = return_type->c_type_out.ends_with("*") && !return_type->ret_as_byref_arg ? "NULL" : return_type->c_type_out + "()"; + String fail_ret = return_type->c_type_out.ends_with("*") && !return_type->ret_as_byref_arg ? "nullptr" : return_type->c_type_out + "()"; if (return_type->ret_as_byref_arg) { - p_output.append("\tif (" CS_PARAM_INSTANCE " == NULL) { *arg_ret = "); + p_output.append("\tif (" CS_PARAM_INSTANCE " == nullptr) { *arg_ret = "); p_output.append(fail_ret); p_output.append("; ERR_FAIL_MSG(\"Parameter ' arg_ret ' is null.\"); }\n"); } else { @@ -2187,7 +2187,7 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte } p_output.append(CS_PARAM_METHODBIND "->call(" CS_PARAM_INSTANCE ", "); - p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ".ptr()" : "NULL"); + p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ".ptr()" : "nullptr"); p_output.append(", total_length, vcall_error);\n"); if (!ret_void) { @@ -2198,8 +2198,8 @@ Error BindingsGenerator::_generate_glue_method(const BindingsGenerator::TypeInte } } else { p_output.append("\t" CS_PARAM_METHODBIND "->ptrcall(" CS_PARAM_INSTANCE ", "); - p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ", " : "NULL, "); - p_output.append(!ret_void ? "&" C_LOCAL_RET ");\n" : "NULL);\n"); + p_output.append(p_imethod.arguments.size() ? C_LOCAL_PTRCALL_ARGS ", " : "nullptr, "); + p_output.append(!ret_void ? "&" C_LOCAL_RET ");\n" : "nullptr);\n"); } if (!ret_void) { @@ -2241,11 +2241,11 @@ const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_null(con // Enum not found. Most likely because none of its constants were bound, so it's empty. That's fine. Use int instead. const Map<StringName, TypeInterface>::Element *int_match = builtin_types.find(name_cache.type_int); - ERR_FAIL_NULL_V(int_match, NULL); + ERR_FAIL_NULL_V(int_match, nullptr); return &int_match->get(); } - return NULL; + return nullptr; } const BindingsGenerator::TypeInterface *BindingsGenerator::_get_type_or_placeholder(const TypeReference &p_typeref) { @@ -2412,7 +2412,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { iprop.proxy_name = iprop.proxy_name.replace("/", "__"); // Some members have a slash... - iprop.prop_doc = NULL; + iprop.prop_doc = nullptr; for (int i = 0; i < itype.class_doc->properties.size(); i++) { const DocData::PropertyDoc &prop_doc = itype.class_doc->properties[i]; @@ -2457,7 +2457,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { PropertyInfo return_info = method_info.return_val; - MethodBind *m = imethod.is_virtual ? NULL : ClassDB::get_method(type_cname, method_info.name); + MethodBind *m = imethod.is_virtual ? nullptr : ClassDB::get_method(type_cname, method_info.name); imethod.is_vararg = m && m->is_vararg(); @@ -2603,7 +2603,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { // Populate signals const HashMap<StringName, MethodInfo> &signal_map = class_info->signal_map; - const StringName *k = NULL; + const StringName *k = nullptr; while ((k = signal_map.next(k))) { SignalInterface isignal; @@ -2685,7 +2685,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ClassDB::get_integer_constant_list(type_cname, &constants, true); const HashMap<StringName, List<StringName>> &enum_map = class_info->enum_map; - k = NULL; + k = nullptr; while ((k = enum_map.next(k))) { StringName enum_proxy_cname = *k; @@ -2707,7 +2707,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); - iconstant.const_doc = NULL; + iconstant.const_doc = nullptr; for (int i = 0; i < itype.class_doc->constants.size(); i++) { const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i]; @@ -2742,7 +2742,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); - iconstant.const_doc = NULL; + iconstant.const_doc = nullptr; for (int i = 0; i < itype.class_doc->constants.size(); i++) { const DocData::ConstantDoc &const_doc = itype.class_doc->constants[i]; @@ -3262,7 +3262,7 @@ void BindingsGenerator::_populate_global_constants() { String constant_name = GlobalConstants::get_global_constant_name(i); - const DocData::ConstantDoc *const_doc = NULL; + const DocData::ConstantDoc *const_doc = nullptr; for (int j = 0; j < global_scope_doc.constants.size(); j++) { const DocData::ConstantDoc &curr_const_doc = global_scope_doc.constants[j]; diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index bebe489d02..7c87c688db 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -176,7 +176,7 @@ class BindingsGenerator { is_virtual = false; requires_object_call = false; is_internal = false; - method_doc = NULL; + method_doc = nullptr; is_deprecated = false; } }; @@ -202,7 +202,7 @@ class BindingsGenerator { } SignalInterface() { - method_doc = NULL; + method_doc = nullptr; is_deprecated = false; } }; @@ -376,7 +376,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } const PropertyInterface *find_property_by_name(const StringName &p_cname) const { @@ -385,7 +385,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } const PropertyInterface *find_property_by_proxy_name(const String &p_proxy_name) const { @@ -394,7 +394,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } const MethodInterface *find_method_by_proxy_name(const String &p_proxy_name) const { @@ -403,7 +403,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } private: @@ -498,7 +498,7 @@ class BindingsGenerator { c_arg_in = "%s"; - class_doc = NULL; + class_doc = nullptr; } }; @@ -622,7 +622,7 @@ class BindingsGenerator { if (it->get().name == p_name) return it; it = it->next(); } - return NULL; + return nullptr; } const ConstantInterface *find_constant_by_name(const String &p_name, const List<ConstantInterface> &p_constants) const { @@ -631,7 +631,7 @@ class BindingsGenerator { return &E->get(); } - return NULL; + return nullptr; } inline String get_unique_sig(const TypeInterface &p_type) { diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp index 872f45ba91..e5c2d023d3 100644 --- a/modules/mono/editor/csharp_project.cpp +++ b/modules/mono/editor/csharp_project.cpp @@ -57,8 +57,8 @@ void add_item(const String &p_project_path, const String &p_item_type, const Str Variant item_type = p_item_type; Variant include = p_include; const Variant *args[3] = { &project_path, &item_type, &include }; - MonoException *exc = NULL; - klass->get_method("AddItemToProjectChecked", 3)->invoke(NULL, args, &exc); + MonoException *exc = nullptr; + klass->get_method("AddItemToProjectChecked", 3)->invoke(nullptr, args, &exc); if (exc) { GDMonoUtils::debug_print_unhandled_exception(exc); diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 31996a03d0..283d4beb8e 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -95,7 +95,7 @@ MonoString *godot_icall_GodotSharpDirs_MonoSolutionsDir() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_mono_solutions_dir()); #else - return NULL; + return nullptr; #endif } @@ -103,7 +103,7 @@ MonoString *godot_icall_GodotSharpDirs_BuildLogsDirs() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_build_logs_dir()); #else - return NULL; + return nullptr; #endif } @@ -111,7 +111,7 @@ MonoString *godot_icall_GodotSharpDirs_ProjectSlnPath() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_project_sln_path()); #else - return NULL; + return nullptr; #endif } @@ -119,7 +119,7 @@ MonoString *godot_icall_GodotSharpDirs_ProjectCsProjPath() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_project_csproj_path()); #else - return NULL; + return nullptr; #endif } @@ -127,7 +127,7 @@ MonoString *godot_icall_GodotSharpDirs_DataEditorToolsDir() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_editor_tools_dir()); #else - return NULL; + return nullptr; #endif } @@ -135,7 +135,7 @@ MonoString *godot_icall_GodotSharpDirs_DataEditorPrebuiltApiDir() { #ifdef TOOLS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_editor_prebuilt_api_dir()); #else - return NULL; + return nullptr; #endif } @@ -151,7 +151,7 @@ MonoString *godot_icall_GodotSharpDirs_DataMonoBinDir() { #ifdef WINDOWS_ENABLED return GDMonoMarshal::mono_string_from_godot(GodotSharpDirs::get_data_mono_bin_dir()); #else - return NULL; + return nullptr; #endif } @@ -202,7 +202,7 @@ uint32_t godot_icall_BindingsGenerator_CsGlueVersion() { } int32_t godot_icall_ScriptClassParser_ParseFile(MonoString *p_filepath, MonoObject *p_classes, MonoString **r_error_str) { - *r_error_str = NULL; + *r_error_str = nullptr; String filepath = GDMonoMarshal::mono_string_to_godot(p_filepath); @@ -335,7 +335,7 @@ MonoString *godot_icall_Internal_MonoWindowsInstallRoot() { String install_root_dir = GDMono::get_singleton()->get_mono_reg_info().install_root_dir; return GDMonoMarshal::mono_string_from_godot(install_root_dir); #else - return NULL; + return nullptr; #endif } diff --git a/modules/mono/editor/godotsharp_export.cpp b/modules/mono/editor/godotsharp_export.cpp index ce0b6ad0e6..324013e5e2 100644 --- a/modules/mono/editor/godotsharp_export.cpp +++ b/modules/mono/editor/godotsharp_export.cpp @@ -59,7 +59,7 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> if (r_dependencies.has(ref_name)) continue; - GDMonoAssembly *ref_assembly = NULL; + GDMonoAssembly *ref_assembly = nullptr; String path; bool has_extension = ref_name.ends_with(".dll") || ref_name.ends_with(".exe"); @@ -70,21 +70,21 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> path = search_dir.plus_file(ref_name); if (FileAccess::exists(path)) { GDMono::get_singleton()->load_assembly_from(ref_name.get_basename(), path, &ref_assembly, true); - if (ref_assembly != NULL) + if (ref_assembly != nullptr) break; } } else { path = search_dir.plus_file(ref_name + ".dll"); if (FileAccess::exists(path)) { GDMono::get_singleton()->load_assembly_from(ref_name, path, &ref_assembly, true); - if (ref_assembly != NULL) + if (ref_assembly != nullptr) break; } path = search_dir.plus_file(ref_name + ".exe"); if (FileAccess::exists(path)) { GDMono::get_singleton()->load_assembly_from(ref_name, path, &ref_assembly, true); - if (ref_assembly != NULL) + if (ref_assembly != nullptr) break; } } @@ -92,7 +92,8 @@ Error get_assembly_dependencies(GDMonoAssembly *p_assembly, const Vector<String> ERR_FAIL_COND_V_MSG(!ref_assembly, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + ref_name + "'."); - r_dependencies[ref_name] = ref_assembly->get_path(); + // Use the path we got from the search. Don't try to get the path from the loaded assembly as we can't trust it will be from the selected BCL dir. + r_dependencies[ref_name] = path; Error err = get_assembly_dependencies(ref_assembly, p_search_dirs, r_dependencies); ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot load one of the dependencies for the assembly: '" + ref_name + "'."); @@ -116,7 +117,7 @@ Error get_exported_assembly_dependencies(const Dictionary &p_initial_dependencie String assembly_name = *key; String assembly_path = p_initial_dependencies[*key]; - GDMonoAssembly *assembly = NULL; + GDMonoAssembly *assembly = nullptr; bool load_success = GDMono::get_singleton()->load_assembly_from(assembly_name, assembly_path, &assembly, /* refonly: */ true); ERR_FAIL_COND_V_MSG(!load_success, ERR_CANT_RESOLVE, "Cannot load assembly (refonly): '" + assembly_name + "'."); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs index a0f105d55e..c4c911b863 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DynamicObject.cs @@ -23,7 +23,7 @@ namespace Godot /// <example> /// This sample shows how to use <see cref="Godot.DynamicGodotObject"/> to dynamically access the engine members of a <see cref="Godot.Object"/>. /// <code> - /// dynamic sprite = GetNode("Sprite").DynamicGodotObject; + /// dynamic sprite = GetNode("Sprite2D").DynamicGodotObject; /// sprite.add_child(this); /// /// if ((sprite.hframes * sprite.vframes) > 0) diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 120668d1ef..f370883320 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -51,7 +51,7 @@ Object *godot_icall_Object_Ctor(MonoObject *p_obj) { void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { #ifdef DEBUG_ENABLED - CRASH_COND(p_ptr == NULL); + CRASH_COND(p_ptr == nullptr); #endif if (p_ptr->get_script_instance()) { @@ -59,7 +59,7 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { if (cs_instance) { if (!cs_instance->is_destructing_script_instance()) { cs_instance->mono_object_disposed(p_obj); - p_ptr->set_script_instance(NULL); + p_ptr->set_script_instance(nullptr); } return; } @@ -80,7 +80,7 @@ void godot_icall_Object_Disposed(MonoObject *p_obj, Object *p_ptr) { void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolean p_is_finalizer) { #ifdef DEBUG_ENABLED - CRASH_COND(p_ptr == NULL); + CRASH_COND(p_ptr == nullptr); // This is only called with Reference derived classes CRASH_COND(!Object::cast_to<Reference>(p_ptr)); #endif @@ -99,7 +99,7 @@ void godot_icall_Reference_Disposed(MonoObject *p_obj, Object *p_ptr, MonoBoolea if (delete_owner) { memdelete(ref); } else if (remove_script_instance) { - ref->set_script_instance(NULL); + ref->set_script_instance(nullptr); } } return; @@ -141,7 +141,7 @@ MethodBind *godot_icall_Object_ClassDB_get_method(StringName *p_type, MonoString MonoObject *godot_icall_Object_weakref(Object *p_ptr) { if (!p_ptr) - return NULL; + return nullptr; Ref<WeakRef> wref; Reference *ref = Object::cast_to<Reference>(p_ptr); @@ -149,7 +149,7 @@ MonoObject *godot_icall_Object_weakref(Object *p_ptr) { if (ref) { REF r = ref; if (!r.is_valid()) - return NULL; + return nullptr; wref.instance(); wref->set_ref(r); @@ -230,7 +230,7 @@ MonoBoolean godot_icall_DynamicGodotObject_SetMember(Object *p_ptr, MonoString * MonoString *godot_icall_Object_ToString(Object *p_ptr) { #ifdef DEBUG_ENABLED // Cannot happen in C#; would get an ObjectDisposedException instead. - CRASH_COND(p_ptr == NULL); + CRASH_COND(p_ptr == nullptr); #endif // Can't call 'Object::to_string()' here, as that can end up calling 'ToString' again resulting in an endless circular loop. String result = "[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]"; diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index b7fa7fcab2..4e3dc9c4ea 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -49,7 +49,7 @@ void godot_icall_Array_Dtor(Array *ptr) { MonoObject *godot_icall_Array_At(Array *ptr, int index) { if (index < 0 || index >= ptr->size()) { GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index)); } @@ -57,7 +57,7 @@ MonoObject *godot_icall_Array_At(Array *ptr, int index) { MonoObject *godot_icall_Array_At_Generic(Array *ptr, int index, uint32_t type_encoding, GDMonoClass *type_class) { if (index < 0 || index >= ptr->size()) { GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ptr->operator[](index), ManagedType(type_encoding, type_class)); } @@ -162,28 +162,28 @@ void godot_icall_Dictionary_Dtor(Dictionary *ptr) { MonoObject *godot_icall_Dictionary_GetValue(Dictionary *ptr, MonoObject *key) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { + if (ret == nullptr) { MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr()); #ifdef DEBUG_ENABLED CRASH_COND(!exc); #endif GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException)); GDMonoUtils::set_pending_exception((MonoException *)exc); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ret); } MonoObject *godot_icall_Dictionary_GetValue_Generic(Dictionary *ptr, MonoObject *key, uint32_t type_encoding, GDMonoClass *type_class) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { + if (ret == nullptr) { MonoObject *exc = mono_object_new(mono_domain_get(), CACHED_CLASS(KeyNotFoundException)->get_mono_ptr()); #ifdef DEBUG_ENABLED CRASH_COND(!exc); #endif GDMonoUtils::runtime_object_init(exc, CACHED_CLASS(KeyNotFoundException)); GDMonoUtils::set_pending_exception((MonoException *)exc); - return NULL; + return nullptr; } return GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class)); } @@ -207,7 +207,7 @@ int godot_icall_Dictionary_Count(Dictionary *ptr) { void godot_icall_Dictionary_Add(Dictionary *ptr, MonoObject *key, MonoObject *value) { Variant varKey = GDMonoMarshal::mono_object_to_variant(key); Variant *ret = ptr->getptr(varKey); - if (ret != NULL) { + if (ret != nullptr) { GDMonoUtils::set_pending_exception(mono_get_exception_argument("key", "An element with the same key already exists")); return; } @@ -221,7 +221,7 @@ void godot_icall_Dictionary_Clear(Dictionary *ptr) { MonoBoolean godot_icall_Dictionary_Contains(Dictionary *ptr, MonoObject *key, MonoObject *value) { // no dupes Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - return ret != NULL && *ret == GDMonoMarshal::mono_object_to_variant(value); + return ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value); } MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key) { @@ -241,7 +241,7 @@ MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, Mono // no dupes Variant *ret = ptr->getptr(varKey); - if (ret != NULL && *ret == GDMonoMarshal::mono_object_to_variant(value)) { + if (ret != nullptr && *ret == GDMonoMarshal::mono_object_to_variant(value)) { ptr->erase(varKey); return true; } @@ -251,8 +251,8 @@ MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, Mono MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key, MonoObject **value) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { - *value = NULL; + if (ret == nullptr) { + *value = nullptr; return false; } *value = GDMonoMarshal::variant_to_mono_object(ret); @@ -261,8 +261,8 @@ MonoBoolean godot_icall_Dictionary_TryGetValue(Dictionary *ptr, MonoObject *key, MonoBoolean godot_icall_Dictionary_TryGetValue_Generic(Dictionary *ptr, MonoObject *key, MonoObject **value, uint32_t type_encoding, GDMonoClass *type_class) { Variant *ret = ptr->getptr(GDMonoMarshal::mono_object_to_variant(key)); - if (ret == NULL) { - *value = NULL; + if (ret == nullptr) { + *value = nullptr; return false; } *value = GDMonoMarshal::variant_to_mono_object(ret, ManagedType(type_encoding, type_class)); diff --git a/modules/mono/glue/gd_glue.cpp b/modules/mono/glue/gd_glue.cpp index 1576d31a3b..2da39a916a 100644 --- a/modules/mono/glue/gd_glue.cpp +++ b/modules/mono/glue/gd_glue.cpp @@ -45,7 +45,7 @@ MonoObject *godot_icall_GD_bytes2var(MonoArray *p_bytes, MonoBoolean p_allow_objects) { Variant ret; PackedByteArray varr = GDMonoMarshal::mono_array_to_PackedByteArray(p_bytes); - Error err = decode_variant(ret, varr.ptr(), varr.size(), NULL, p_allow_objects); + Error err = decode_variant(ret, varr.ptr(), varr.size(), nullptr, p_allow_objects); if (err != OK) { ret = RTR("Not enough bytes for decoding bytes, or invalid format."); } @@ -57,7 +57,7 @@ MonoObject *godot_icall_GD_convert(MonoObject *p_what, int32_t p_type) { const Variant *args[1] = { &what }; Callable::CallError ce; Variant ret = Variant::construct(Variant::Type(p_type), args, 1, ce); - ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, NULL); + ERR_FAIL_COND_V(ce.error != Callable::CallError::CALL_OK, nullptr); return GDMonoMarshal::variant_to_mono_object(ret); } @@ -76,7 +76,7 @@ void godot_icall_GD_print(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -98,7 +98,7 @@ void godot_icall_GD_printerr(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -119,7 +119,7 @@ void godot_icall_GD_printraw(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -140,7 +140,7 @@ void godot_icall_GD_prints(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -164,7 +164,7 @@ void godot_icall_GD_printt(MonoArray *p_what) { for (int i = 0; i < length; i++) { MonoObject *elem = mono_array_get(p_what, MonoObject *, i); - MonoException *exc = NULL; + MonoException *exc = nullptr; String elem_str = GDMonoMarshal::mono_object_to_variant_string(elem, &exc); if (exc) { @@ -259,8 +259,8 @@ MonoArray *godot_icall_GD_var2bytes(MonoObject *p_var, MonoBoolean p_full_object PackedByteArray barr; int len; - Error err = encode_variant(var, NULL, len, p_full_objects); - ERR_FAIL_COND_V_MSG(err != OK, NULL, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."); + Error err = encode_variant(var, nullptr, len, p_full_objects); + ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID)."); barr.resize(len); encode_variant(var, barr.ptrw(), len, p_full_objects); diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h index 8130b0cc39..ee99a300b9 100644 --- a/modules/mono/glue/glue_header.h +++ b/modules/mono/glue/glue_header.h @@ -70,7 +70,7 @@ void godot_register_glue_header_icalls() { #include "../mono_gd/gd_mono_utils.h" #define GODOTSHARP_INSTANCE_OBJECT(m_instance, m_type) \ - static ClassDB::ClassInfo *ci = NULL; \ + static ClassDB::ClassInfo *ci = nullptr; \ if (!ci) { \ ci = ClassDB::classes.getptr(m_type); \ } \ diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 828ab73c82..fe8b925257 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -40,7 +40,7 @@ #endif #ifdef ANDROID_ENABLED -#include "mono_gd/gd_mono_android.h" +#include "mono_gd/support/mono-support.h" #endif #include "mono_gd/gd_mono.h" @@ -169,7 +169,7 @@ private: data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); #ifdef ANDROID_ENABLED - data_mono_lib_dir = GDMonoAndroid::get_app_native_lib_dir(); + data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); #endif @@ -206,7 +206,7 @@ private: data_mono_etc_dir = data_mono_root_dir.plus_file("etc"); #ifdef ANDROID_ENABLED - data_mono_lib_dir = GDMonoAndroid::get_app_native_lib_dir(); + data_mono_lib_dir = gdmono::android::support::get_app_native_lib_dir(); #else data_mono_lib_dir = data_mono_root_dir.plus_file("lib"); data_game_assemblies_dir = data_dir_root.plus_file("Assemblies"); diff --git a/modules/mono/managed_callable.cpp b/modules/mono/managed_callable.cpp index a9cf64d1cc..dfd78a8244 100644 --- a/modules/mono/managed_callable.cpp +++ b/modules/mono/managed_callable.cpp @@ -99,7 +99,7 @@ void ManagedCallable::call(const Variant **p_arguments, int p_argcount, Variant MonoObject *delegate = delegate_handle.get_target(); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = delegate_invoke->invoke(delegate, p_arguments, &exc); if (exc) { @@ -119,7 +119,7 @@ void ManagedCallable::set_delegate(MonoDelegate *p_delegate) { ManagedCallable::ManagedCallable(MonoDelegate *p_delegate) { #ifdef DEBUG_ENABLED - CRASH_COND(p_delegate == NULL); + CRASH_COND(p_delegate == nullptr); #endif set_delegate(p_delegate); diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp index 4b6d7269e9..e362d5affb 100644 --- a/modules/mono/mono_gc_handle.cpp +++ b/modules/mono/mono_gc_handle.cpp @@ -34,7 +34,7 @@ void MonoGCHandleData::release() { #ifdef DEBUG_ENABLED - CRASH_COND(handle && GDMono::get_singleton() == NULL); + CRASH_COND(handle && GDMono::get_singleton() == nullptr); #endif if (handle && GDMono::get_singleton()->is_runtime_initialized()) { diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h index 705b2265ba..fbcb405b0d 100644 --- a/modules/mono/mono_gc_handle.h +++ b/modules/mono/mono_gc_handle.h @@ -53,7 +53,7 @@ struct MonoGCHandleData { _FORCE_INLINE_ bool is_released() const { return !handle; } _FORCE_INLINE_ bool is_weak() const { return type == gdmono::GCHandleType::WEAK_HANDLE; } - _FORCE_INLINE_ MonoObject *get_target() const { return handle ? mono_gchandle_get_target(handle) : NULL; } + _FORCE_INLINE_ MonoObject *get_target() const { return handle ? mono_gchandle_get_target(handle) : nullptr; } void release(); diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index eb4c263745..306a1997ab 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -58,14 +58,25 @@ #ifdef ANDROID_ENABLED #include "android_mono_config.h" -#include "gd_mono_android.h" +#include "support/android_support.h" +#elif defined(IPHONE_ENABLED) +#include "support/ios_support.h" +#endif + +#if defined(TOOL_ENABLED) && defined(GD_MONO_SINGLE_APPDOMAIN) +// This will no longer be the case if we replace appdomains with AssemblyLoadContext +#error "Editor build requires support for multiple appdomains" +#endif + +#if defined(GD_MONO_HOT_RELOAD) && defined(GD_MONO_SINGLE_APPDOMAIN) +#error "Hot reloading requires multiple appdomains" #endif // TODO: // This has turn into a gigantic mess. There's too much going on here. Too much #ifdef as well. // It's just painful to read... It needs to be re-structured. Please, clean this up, future me. -GDMono *GDMono::singleton = NULL; +GDMono *GDMono::singleton = nullptr; namespace { @@ -178,7 +189,14 @@ MonoDomain *gd_initialize_mono_runtime() { gd_mono_debug_init(); #endif - return mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319"); +#if defined(IPHONE_ENABLED) || defined(ANDROID_ENABLED) + // I don't know whether this actually matters or not + const char *runtime_version = "mobile"; +#else + const char *runtime_version = "v4.0.30319"; +#endif + + return mono_jit_init_version("GodotEngine.RootDomain", runtime_version); } #endif @@ -314,14 +332,22 @@ void GDMono::initialize() { determine_mono_dirs(assembly_rootdir, config_dir); // Leak if we call mono_set_dirs more than once - mono_set_dirs(assembly_rootdir.length() ? assembly_rootdir.utf8().get_data() : NULL, - config_dir.length() ? config_dir.utf8().get_data() : NULL); + mono_set_dirs(assembly_rootdir.length() ? assembly_rootdir.utf8().get_data() : nullptr, + config_dir.length() ? config_dir.utf8().get_data() : nullptr); add_mono_shared_libs_dir_to_path(); #endif +#ifdef ANDROID_ENABLED + mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data()); +#else + mono_config_parse(nullptr); +#endif + #if defined(ANDROID_ENABLED) - GDMonoAndroid::initialize(); + gdmono::android::support::initialize(); +#elif defined(IPHONE_ENABLED) + gdmono::ios::support::initialize(); #endif GDMonoAssembly::initialize(); @@ -330,13 +356,7 @@ void GDMono::initialize() { gd_mono_profiler_init(); #endif -#ifdef ANDROID_ENABLED - mono_config_parse_memory(get_godot_android_mono_config().utf8().get_data()); -#else - mono_config_parse(NULL); -#endif - - mono_install_unhandled_exception_hook(&unhandled_exception_hook, NULL); + mono_install_unhandled_exception_hook(&unhandled_exception_hook, nullptr); #ifndef TOOLS_ENABLED // Exported games that don't use C# must still work. They likely don't ship with mscorlib. @@ -355,7 +375,7 @@ void GDMono::initialize() { #endif // NOTE: Internal calls must be registered after the Mono runtime initialization. - // Otherwise registration fails with the error: 'assertion 'hash != NULL' failed'. + // Otherwise registration fails with the error: 'assertion 'hash != nullptr' failed'. root_domain = gd_initialize_mono_runtime(); ERR_FAIL_NULL_MSG(root_domain, "Mono: Failed to initialize runtime."); @@ -371,15 +391,19 @@ void GDMono::initialize() { print_verbose("Mono: Runtime initialized"); #if defined(ANDROID_ENABLED) - GDMonoAndroid::register_internal_calls(); + gdmono::android::support::register_internal_calls(); #endif // mscorlib assembly MUST be present at initialization bool corlib_loaded = _load_corlib_assembly(); ERR_FAIL_COND_MSG(!corlib_loaded, "Mono: Failed to load mscorlib assembly."); +#ifndef GD_MONO_SINGLE_APPDOMAIN Error domain_load_err = _load_scripts_domain(); ERR_FAIL_COND_MSG(domain_load_err != OK, "Mono: Failed to load scripts domain."); +#else + scripts_domain = root_domain; +#endif _register_internal_calls(); @@ -491,11 +515,15 @@ void GDMono::add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly) { assemblies[p_domain_id][p_assembly->get_name()] = p_assembly; } -GDMonoAssembly **GDMono::get_loaded_assembly(const String &p_name) { +GDMonoAssembly *GDMono::get_loaded_assembly(const String &p_name) { + + if (p_name == "mscorlib") + return get_corlib_assembly(); MonoDomain *domain = mono_domain_get(); uint32_t domain_id = domain ? mono_domain_get_id(domain) : 0; - return assemblies[domain_id].getptr(p_name); + GDMonoAssembly **result = assemblies[domain_id].getptr(p_name); + return result ? *result : nullptr; } bool GDMono::load_assembly(const String &p_name, GDMonoAssembly **r_assembly, bool p_refonly) { @@ -517,7 +545,7 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo print_verbose("Mono: Loading assembly " + p_name + (p_refonly ? " (refonly)" : "") + "..."); MonoImageOpenStatus status = MONO_IMAGE_OK; - MonoAssembly *assembly = mono_assembly_load_full(p_aname, NULL, &status, p_refonly); + MonoAssembly *assembly = mono_assembly_load_full(p_aname, nullptr, &status, p_refonly); if (!assembly) return false; @@ -528,7 +556,7 @@ bool GDMono::load_assembly(const String &p_name, MonoAssemblyName *p_aname, GDMo GDMonoAssembly **stored_assembly = assemblies[domain_id].getptr(p_name); - ERR_FAIL_COND_V(stored_assembly == NULL, false); + ERR_FAIL_COND_V(stored_assembly == nullptr, false); ERR_FAIL_COND_V((*stored_assembly)->get_assembly() != assembly, false); *r_assembly = *stored_assembly; @@ -549,14 +577,6 @@ bool GDMono::load_assembly_from(const String &p_name, const String &p_path, GDMo if (!assembly) return false; -#ifdef DEBUG_ENABLED - uint32_t domain_id = mono_domain_get_id(mono_domain_get()); - GDMonoAssembly **stored_assembly = assemblies[domain_id].getptr(p_name); - - ERR_FAIL_COND_V(stored_assembly == NULL, false); - ERR_FAIL_COND_V(*stored_assembly != assembly, false); -#endif - *r_assembly = assembly; print_verbose("Mono: Assembly " + p_name + (p_refonly ? " (refonly)" : "") + " loaded from path: " + (*r_assembly)->get_path()); @@ -576,15 +596,15 @@ ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMo if (nativecalls_klass) { GDMonoField *api_hash_field = nativecalls_klass->get_field("godot_api_hash"); if (api_hash_field) - api_assembly_version.godot_api_hash = GDMonoMarshal::unbox<uint64_t>(api_hash_field->get_value(NULL)); + api_assembly_version.godot_api_hash = GDMonoMarshal::unbox<uint64_t>(api_hash_field->get_value(nullptr)); GDMonoField *binds_ver_field = nativecalls_klass->get_field("bindings_version"); if (binds_ver_field) - api_assembly_version.bindings_version = GDMonoMarshal::unbox<uint32_t>(binds_ver_field->get_value(NULL)); + api_assembly_version.bindings_version = GDMonoMarshal::unbox<uint32_t>(binds_ver_field->get_value(nullptr)); GDMonoField *cs_glue_ver_field = nativecalls_klass->get_field("cs_glue_version"); if (cs_glue_ver_field) - api_assembly_version.cs_glue_version = GDMonoMarshal::unbox<uint32_t>(cs_glue_ver_field->get_value(NULL)); + api_assembly_version.cs_glue_version = GDMonoMarshal::unbox<uint32_t>(cs_glue_ver_field->get_value(nullptr)); } return api_assembly_version; @@ -715,7 +735,7 @@ bool GDMono::_temp_domain_load_are_assemblies_out_of_sync(const String &p_config GDMono::LoadedApiAssembly temp_editor_api_assembly; if (!_try_load_api_assemblies(temp_core_api_assembly, temp_editor_api_assembly, - p_config, /* refonly: */ true, /* loaded_callback: */ NULL)) { + p_config, /* refonly: */ true, /* loaded_callback: */ nullptr)) { return temp_core_api_assembly.out_of_sync || temp_editor_api_assembly.out_of_sync; } @@ -894,8 +914,8 @@ void GDMono::_load_api_assemblies() { bool api_assemblies_loaded = _try_load_api_assemblies_preset(); +#if defined(TOOLS_ENABLED) && !defined(GD_MONO_SINGLE_APPDOMAIN) if (!api_assemblies_loaded) { -#ifdef TOOLS_ENABLED // The API assemblies are out of sync or some other error happened. Fine, try one more time, but // this time update them from the prebuilt assemblies directory before trying to load them again. @@ -916,8 +936,8 @@ void GDMono::_load_api_assemblies() { // 4. Try loading the updated assemblies api_assemblies_loaded = _try_load_api_assemblies_preset(); -#endif } +#endif if (!api_assemblies_loaded) { // welp... too bad @@ -982,8 +1002,8 @@ void GDMono::_install_trace_listener() { GDMonoClass *debug_utils = get_core_api_assembly()->get_class(BINDINGS_NAMESPACE, "DebuggingUtils"); GDMonoMethod *install_func = debug_utils->get_method("InstallTraceListener"); - MonoException *exc = NULL; - install_func->invoke_raw(NULL, NULL, &exc); + MonoException *exc = nullptr; + install_func->invoke_raw(nullptr, nullptr, &exc); if (exc) { GDMonoUtils::debug_print_unhandled_exception(exc); ERR_PRINT("Failed to install 'System.Diagnostics.Trace' listener."); @@ -991,9 +1011,10 @@ void GDMono::_install_trace_listener() { #endif } +#ifndef GD_MONO_SINGLE_APPDOMAIN Error GDMono::_load_scripts_domain() { - ERR_FAIL_COND_V(scripts_domain != NULL, ERR_BUG); + ERR_FAIL_COND_V(scripts_domain != nullptr, ERR_BUG); print_verbose("Mono: Loading scripts domain..."); @@ -1010,7 +1031,7 @@ Error GDMono::_unload_scripts_domain() { ERR_FAIL_NULL_V(scripts_domain, ERR_BUG); - print_verbose("Mono: Unloading scripts domain..."); + print_verbose("Mono: Finalizing scripts domain..."); if (mono_domain_get() != root_domain) mono_domain_set(root_domain, true); @@ -1029,21 +1050,23 @@ Error GDMono::_unload_scripts_domain() { _domain_assemblies_cleanup(mono_domain_get_id(scripts_domain)); - core_api_assembly.assembly = NULL; + core_api_assembly.assembly = nullptr; #ifdef TOOLS_ENABLED - editor_api_assembly.assembly = NULL; + editor_api_assembly.assembly = nullptr; #endif - project_assembly = NULL; + project_assembly = nullptr; #ifdef TOOLS_ENABLED - tools_assembly = NULL; - tools_project_editor_assembly = NULL; + tools_assembly = nullptr; + tools_project_editor_assembly = nullptr; #endif MonoDomain *domain = scripts_domain; - scripts_domain = NULL; + scripts_domain = nullptr; + + print_verbose("Mono: Unloading scripts domain..."); - MonoException *exc = NULL; + MonoException *exc = nullptr; mono_domain_try_unload(domain, (MonoObject **)&exc); if (exc) { @@ -1054,6 +1077,7 @@ Error GDMono::_unload_scripts_domain() { return OK; } +#endif #ifdef GD_MONO_HOT_RELOAD Error GDMono::reload_scripts_domain() { @@ -1092,9 +1116,10 @@ Error GDMono::reload_scripts_domain() { } #endif +#ifndef GD_MONO_SINGLE_APPDOMAIN Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { - CRASH_COND(p_domain == NULL); + CRASH_COND(p_domain == nullptr); CRASH_COND(p_domain == GDMono::get_singleton()->get_scripts_domain()); // Should use _unload_scripts_domain() instead String domain_name = mono_domain_get_friendly_name(p_domain); @@ -1112,7 +1137,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { _domain_assemblies_cleanup(mono_domain_get_id(p_domain)); - MonoException *exc = NULL; + MonoException *exc = nullptr; mono_domain_try_unload(p_domain, (MonoObject **)&exc); if (exc) { @@ -1123,6 +1148,7 @@ Error GDMono::finalize_and_unload_domain(MonoDomain *p_domain) { return OK; } +#endif GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { @@ -1134,7 +1160,7 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { uint32_t domain_id = mono_domain_get_id(mono_domain_get()); HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id]; - const String *k = NULL; + const String *k = nullptr; while ((k = domain_assemblies.next(k))) { GDMonoAssembly *assembly = domain_assemblies.get(*k); if (assembly->get_image() == image) { @@ -1145,30 +1171,34 @@ GDMonoClass *GDMono::get_class(MonoClass *p_raw_class) { } } - return NULL; + return nullptr; } GDMonoClass *GDMono::get_class(const StringName &p_namespace, const StringName &p_name) { + GDMonoClass *klass = corlib_assembly->get_class(p_namespace, p_name); + if (klass) + return klass; + uint32_t domain_id = mono_domain_get_id(mono_domain_get()); HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[domain_id]; - const String *k = NULL; + const String *k = nullptr; while ((k = domain_assemblies.next(k))) { GDMonoAssembly *assembly = domain_assemblies.get(*k); - GDMonoClass *klass = assembly->get_class(p_namespace, p_name); + klass = assembly->get_class(p_namespace, p_name); if (klass) return klass; } - return NULL; + return nullptr; } void GDMono::_domain_assemblies_cleanup(uint32_t p_domain_id) { HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies[p_domain_id]; - const String *k = NULL; + const String *k = nullptr; while ((k = domain_assemblies.next(k))) { memdelete(domain_assemblies.get(*k)); } @@ -1202,14 +1232,14 @@ GDMono::GDMono() { runtime_initialized = false; finalizing_scripts_domain = false; - root_domain = NULL; - scripts_domain = NULL; + root_domain = nullptr; + scripts_domain = nullptr; - corlib_assembly = NULL; - project_assembly = NULL; + corlib_assembly = nullptr; + project_assembly = nullptr; #ifdef TOOLS_ENABLED - tools_assembly = NULL; - tools_project_editor_assembly = NULL; + tools_assembly = nullptr; + tools_project_editor_assembly = nullptr; #endif api_core_hash = 0; @@ -1223,18 +1253,50 @@ GDMono::GDMono() { GDMono::~GDMono() { if (is_runtime_initialized()) { +#ifndef GD_MONO_SINGLE_APPDOMAIN if (scripts_domain) { Error err = _unload_scripts_domain(); if (err != OK) { ERR_PRINT("Mono: Failed to unload scripts domain."); } } +#else + CRASH_COND(scripts_domain != root_domain); + + print_verbose("Mono: Finalizing scripts domain..."); + + if (mono_domain_get() != root_domain) + mono_domain_set(root_domain, true); + + finalizing_scripts_domain = true; + + if (!mono_domain_finalize(root_domain, 2000)) { + ERR_PRINT("Mono: Domain finalization timeout."); + } + + finalizing_scripts_domain = false; - const uint32_t *k = NULL; + mono_gc_collect(mono_gc_max_generation()); + + GDMonoCache::clear_godot_api_cache(); + + _domain_assemblies_cleanup(mono_domain_get_id(root_domain)); + + core_api_assembly.assembly = nullptr; + + project_assembly = nullptr; + + root_domain = nullptr; + scripts_domain = nullptr; + + // Leave the rest to 'mono_jit_cleanup' +#endif + + const uint32_t *k = nullptr; while ((k = assemblies.next(k))) { HashMap<String, GDMonoAssembly *> &domain_assemblies = assemblies.get(*k); - const String *kk = NULL; + const String *kk = nullptr; while ((kk = domain_assemblies.next(kk))) { memdelete(domain_assemblies.get(*kk)); } @@ -1245,22 +1307,22 @@ GDMono::~GDMono() { mono_jit_cleanup(root_domain); -#if defined(ANDROID_ENABLED) - GDMonoAndroid::cleanup(); -#endif - print_verbose("Mono: Finalized"); runtime_initialized = false; } +#if defined(ANDROID_ENABLED) + gdmono::android::support::cleanup(); +#endif + if (gdmono_log) memdelete(gdmono_log); - singleton = NULL; + singleton = nullptr; } -_GodotSharp *_GodotSharp::singleton = NULL; +_GodotSharp *_GodotSharp::singleton = nullptr; void _GodotSharp::attach_thread() { @@ -1288,7 +1350,7 @@ int32_t _GodotSharp::get_scripts_domain_id() { bool _GodotSharp::is_scripts_domain_loaded() { - return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != NULL; + return GDMono::get_singleton()->is_runtime_initialized() && GDMono::get_singleton()->get_scripts_domain() != nullptr; } bool _GodotSharp::_is_domain_finalizing_for_unload(int32_t p_domain_id) { @@ -1353,5 +1415,5 @@ _GodotSharp::_GodotSharp() { _GodotSharp::~_GodotSharp() { - singleton = NULL; + singleton = nullptr; } diff --git a/modules/mono/mono_gd/gd_mono.h b/modules/mono/mono_gd/gd_mono.h index 9528c64f8d..4898833e8e 100644 --- a/modules/mono/mono_gd/gd_mono.h +++ b/modules/mono/mono_gd/gd_mono.h @@ -91,7 +91,7 @@ public: bool out_of_sync; LoadedApiAssembly() : - assembly(NULL), + assembly(nullptr), out_of_sync(false) { } }; @@ -144,8 +144,10 @@ private: void _register_internal_calls(); +#ifndef GD_MONO_SINGLE_APPDOMAIN Error _load_scripts_domain(); Error _unload_scripts_domain(); +#endif void _domain_assemblies_cleanup(uint32_t p_domain_id); @@ -198,7 +200,7 @@ public: #ifdef TOOLS_ENABLED bool copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const String &p_config); - String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = NULL, const bool *p_editor_api_out_of_sync = NULL); + String update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync = nullptr, const bool *p_editor_api_out_of_sync = nullptr); #endif static GDMono *get_singleton() { return singleton; } @@ -209,7 +211,7 @@ public: // Do not use these, unless you know what you're doing void add_assembly(uint32_t p_domain_id, GDMonoAssembly *p_assembly); - GDMonoAssembly **get_loaded_assembly(const String &p_name); + GDMonoAssembly *get_loaded_assembly(const String &p_name); _FORCE_INLINE_ bool is_runtime_initialized() const { return runtime_initialized && !mono_runtime_is_shutting_down() /* stays true after shutdown finished */; } @@ -263,7 +265,7 @@ public: this->prev_domain = prev_domain; mono_domain_set(p_domain, false); } else { - this->prev_domain = NULL; + this->prev_domain = nullptr; } } diff --git a/modules/mono/mono_gd/gd_mono_assembly.cpp b/modules/mono/mono_gd/gd_mono_assembly.cpp index 6da1db249c..8439769d84 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.cpp +++ b/modules/mono/mono_gd/gd_mono_assembly.cpp @@ -42,9 +42,6 @@ #include "gd_mono_cache.h" #include "gd_mono_class.h" -bool GDMonoAssembly::no_search = false; -bool GDMonoAssembly::in_preload = false; - Vector<String> GDMonoAssembly::search_dirs; void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const String &p_custom_config, const String &p_custom_bcl_dir) { @@ -94,19 +91,30 @@ void GDMonoAssembly::fill_search_dirs(Vector<String> &r_search_dirs, const Strin #endif } +// This is how these assembly loading hooks work: +// +// - The 'search' hook checks if the assembly has already been loaded, to avoid loading again. +// - The 'preload' hook does the actual loading and is only called if the +// 'search' hook didn't find the assembly in the list of loaded assemblies. +// - The 'load' hook is called after the assembly has been loaded. Its job is to add the +// assembly to the list of loaded assemblies so that the 'search' hook can look it up. + void GDMonoAssembly::assembly_load_hook(MonoAssembly *assembly, void *user_data) { - if (no_search) - return; - - // If our search and preload hooks fail to load the assembly themselves, the mono runtime still might. - // Just do Assembly.LoadFrom("/Full/Path/On/Disk.dll"); - // In this case, we wouldn't have the assembly known in GDMono, which causes crashes - // if any class inside the assembly is looked up by Godot. - // And causing a lookup like that is as easy as throwing an exception defined in it... - // No, we can't make the assembly load hooks smart enough because they get passed a MonoAssemblyName* only, - // not the disk path passed to say Assembly.LoadFrom(). - _wrap_mono_assembly(assembly); + String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly))); + + MonoImage *image = mono_assembly_get_image(assembly); + + GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, image, assembly)); + +#ifdef GD_MONO_HOT_RELOAD + const char *path = mono_image_get_filename(image); + if (FileAccess::exists(path)) + gdassembly->modified_time = FileAccess::get_modified_time(path); +#endif + + MonoDomain *domain = mono_domain_get(); + GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly); } MonoAssembly *GDMonoAssembly::assembly_search_hook(MonoAssemblyName *aname, void *user_data) { @@ -132,71 +140,24 @@ MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_d String name = String::utf8(mono_assembly_name_get_name(aname)); bool has_extension = name.ends_with(".dll") || name.ends_with(".exe"); - if (no_search) - return NULL; - - GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); + GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); if (loaded_asm) - return (*loaded_asm)->get_assembly(); - - no_search = true; // Avoid the recursion madness - - GDMonoAssembly *res = _load_assembly_search(name, search_dirs, refonly); - - no_search = false; + return loaded_asm->get_assembly(); - return res ? res->get_assembly() : NULL; + return nullptr; } -static thread_local MonoImage *image_corlib_loading = NULL; - MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **, void *user_data, bool refonly) { (void)user_data; // UNUSED - { - // If we find the assembly here, we load it with 'mono_assembly_load_from_full', - // which in turn invokes load hooks before returning the MonoAssembly to us. - // One of the load hooks is 'load_aot_module'. This hook can end up calling preload hooks - // again for the same assembly in certain in certain circumstances (the 'do_load_image' part). - // If this is the case and we return NULL due to the no_search condition below, - // it will result in an internal crash later on. Therefore we need to return the assembly we didn't - // get yet from 'mono_assembly_load_from_full'. Luckily we have the image, which already got it. - // This must be done here. If done in search hooks, it would cause 'mono_assembly_load_from_full' - // to think another MonoAssembly for this assembly was already loaded, making it delete its own, - // when in fact both pointers were the same... This hooks thing is confusing. - if (image_corlib_loading) { - return mono_image_get_assembly(image_corlib_loading); - } - } - - if (no_search) - return NULL; - - no_search = true; - in_preload = true; - String name = String::utf8(mono_assembly_name_get_name(aname)); - bool has_extension = name.ends_with(".dll"); - - GDMonoAssembly *res = NULL; - if (has_extension ? name == "mscorlib.dll" : name == "mscorlib") { - GDMonoAssembly **stored_assembly = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name); - if (stored_assembly) - return (*stored_assembly)->get_assembly(); - - res = _load_assembly_search("mscorlib.dll", search_dirs, refonly); - } - - no_search = false; - in_preload = false; - - return res ? res->get_assembly() : NULL; + return _load_assembly_search(name, search_dirs, refonly); } -GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) { +MonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly) { - GDMonoAssembly *res = NULL; + MonoAssembly *res = nullptr; String path; bool has_extension = p_name.ends_with(".dll") || p_name.ends_with(".exe"); @@ -207,28 +168,28 @@ GDMonoAssembly *GDMonoAssembly::_load_assembly_search(const String &p_name, cons if (has_extension) { path = search_dir.plus_file(p_name); if (FileAccess::exists(path)) { - res = _load_assembly_from(p_name.get_basename(), path, p_refonly); - if (res != NULL) + res = _real_load_assembly_from(path, p_refonly); + if (res != nullptr) return res; } } else { path = search_dir.plus_file(p_name + ".dll"); if (FileAccess::exists(path)) { - res = _load_assembly_from(p_name, path, p_refonly); - if (res != NULL) + res = _real_load_assembly_from(path, p_refonly); + if (res != nullptr) return res; } path = search_dir.plus_file(p_name + ".exe"); if (FileAccess::exists(path)) { - res = _load_assembly_from(p_name, path, p_refonly); - if (res != NULL) + res = _real_load_assembly_from(path, p_refonly); + if (res != nullptr) return res; } } } - return NULL; + return nullptr; } String GDMonoAssembly::find_assembly(const String &p_name) { @@ -258,91 +219,50 @@ String GDMonoAssembly::find_assembly(const String &p_name) { return String(); } -GDMonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly) { - - GDMonoAssembly *assembly = memnew(GDMonoAssembly(p_name, p_path)); - - Error err = assembly->load(p_refonly); - - if (err != OK) { - memdelete(assembly); - ERR_FAIL_V(NULL); - } - - MonoDomain *domain = mono_domain_get(); - GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, assembly); - - return assembly; -} - -void GDMonoAssembly::_wrap_mono_assembly(MonoAssembly *assembly) { - String name = String::utf8(mono_assembly_name_get_name(mono_assembly_get_name(assembly))); - - MonoImage *image = mono_assembly_get_image(assembly); - - GDMonoAssembly *gdassembly = memnew(GDMonoAssembly(name, mono_image_get_filename(image))); - Error err = gdassembly->wrapper_for_image(image); - - if (err != OK) { - memdelete(gdassembly); - ERR_FAIL(); - } - - MonoDomain *domain = mono_domain_get(); - GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, gdassembly); -} - void GDMonoAssembly::initialize() { fill_search_dirs(search_dirs); - mono_install_assembly_search_hook(&assembly_search_hook, NULL); - mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, NULL); - mono_install_assembly_preload_hook(&assembly_preload_hook, NULL); - mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, NULL); - mono_install_assembly_load_hook(&assembly_load_hook, NULL); + mono_install_assembly_search_hook(&assembly_search_hook, nullptr); + mono_install_assembly_refonly_search_hook(&assembly_refonly_search_hook, nullptr); + mono_install_assembly_preload_hook(&assembly_preload_hook, nullptr); + mono_install_assembly_refonly_preload_hook(&assembly_refonly_preload_hook, nullptr); + mono_install_assembly_load_hook(&assembly_load_hook, nullptr); } -Error GDMonoAssembly::load(bool p_refonly) { - - ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE); - - refonly = p_refonly; +MonoAssembly *GDMonoAssembly::_real_load_assembly_from(const String &p_path, bool p_refonly) { - uint64_t last_modified_time = FileAccess::get_modified_time(path); - - Vector<uint8_t> data = FileAccess::get_file_as_array(path); - ERR_FAIL_COND_V(data.empty(), ERR_FILE_CANT_READ); + Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); + ERR_FAIL_COND_V_MSG(data.empty(), nullptr, "Could read the assembly in the specified location"); String image_filename; #ifdef ANDROID_ENABLED - if (path.begins_with("res://")) { - image_filename = path.substr(6, path.length()); + if (p_path.begins_with("res://")) { + image_filename = p_path.substr(6, p_path.length()); } else { - image_filename = ProjectSettings::get_singleton()->globalize_path(path); + image_filename = ProjectSettings::get_singleton()->globalize_path(p_path); } #else // FIXME: globalize_path does not work on exported games - image_filename = ProjectSettings::get_singleton()->globalize_path(path); + image_filename = ProjectSettings::get_singleton()->globalize_path(p_path); #endif MonoImageOpenStatus status = MONO_IMAGE_OK; - image = mono_image_open_from_data_with_name( + MonoImage *image = mono_image_open_from_data_with_name( (char *)&data[0], data.size(), - true, &status, refonly, - image_filename.utf8().get_data()); + true, &status, p_refonly, + image_filename.utf8()); - ERR_FAIL_COND_V(status != MONO_IMAGE_OK, ERR_FILE_CANT_OPEN); - ERR_FAIL_NULL_V(image, ERR_FILE_CANT_OPEN); + ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !image, nullptr, "Failed to open assembly image from the loaded data"); #ifdef DEBUG_ENABLED Vector<uint8_t> pdb_data; - String pdb_path(path + ".pdb"); + String pdb_path(p_path + ".pdb"); if (!FileAccess::exists(pdb_path)) { - pdb_path = path.get_basename() + ".pdb"; // without .dll + pdb_path = p_path.get_basename() + ".pdb"; // without .dll if (!FileAccess::exists(pdb_path)) goto no_pdb; @@ -357,44 +277,21 @@ no_pdb: #endif - bool is_corlib_preload = in_preload && name == "mscorlib"; - - if (is_corlib_preload) - image_corlib_loading = image; + status = MONO_IMAGE_OK; - assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, refonly); + MonoAssembly *assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, p_refonly); - if (is_corlib_preload) - image_corlib_loading = NULL; - - ERR_FAIL_COND_V(status != MONO_IMAGE_OK || assembly == NULL, ERR_FILE_CANT_OPEN); + ERR_FAIL_COND_V_MSG(status != MONO_IMAGE_OK || !assembly, nullptr, "Failed to load assembly for image"); // Decrement refcount which was previously incremented by mono_image_open_from_data_with_name mono_image_close(image); - loaded = true; - modified_time = last_modified_time; - - return OK; -} - -Error GDMonoAssembly::wrapper_for_image(MonoImage *p_image) { - - ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE); - - assembly = mono_image_get_assembly(p_image); - ERR_FAIL_NULL_V(assembly, FAILED); - - image = p_image; - - loaded = true; - - return OK; + return assembly; } void GDMonoAssembly::unload() { - ERR_FAIL_COND(!loaded); + ERR_FAIL_NULL(image); // Should not be called if already unloaded for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) { memdelete(E->value()); @@ -403,14 +300,17 @@ void GDMonoAssembly::unload() { cached_classes.clear(); cached_raw.clear(); - assembly = NULL; - image = NULL; - loaded = false; + assembly = nullptr; + image = nullptr; +} + +String GDMonoAssembly::get_path() const { + return String::utf8(mono_image_get_filename(image)); } GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) { - ERR_FAIL_COND_V(!loaded, NULL); + ERR_FAIL_NULL_V(image, nullptr); ClassKey key(p_namespace, p_name); @@ -422,7 +322,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri MonoClass *mono_class = mono_class_from_name(image, String(p_namespace).utf8(), String(p_name).utf8()); if (!mono_class) - return NULL; + return nullptr; GDMonoClass *wrapped_class = memnew(GDMonoClass(p_namespace, p_name, mono_class, this)); @@ -434,7 +334,7 @@ GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const Stri GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { - ERR_FAIL_COND_V(!loaded, NULL); + ERR_FAIL_NULL_V(image, nullptr); Map<MonoClass *, GDMonoClass *>::Element *match = cached_raw.find(p_mono_class); @@ -454,7 +354,7 @@ GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) { GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) { - GDMonoClass *match = NULL; + GDMonoClass *match = nullptr; if (gdobject_class_cache_updated) { Map<StringName, GDMonoClass *>::Element *result = gdobject_class_cache.find(p_class); @@ -486,7 +386,7 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) GDMonoClass *current_nested = nested_classes.front()->get(); nested_classes.pop_back(); - void *iter = NULL; + void *iter = nullptr; while (true) { MonoClass *raw_nested = mono_class_get_nested_types(current_nested->get_mono_ptr(), &iter); @@ -514,32 +414,38 @@ GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) GDMonoAssembly *GDMonoAssembly::load_from(const String &p_name, const String &p_path, bool p_refonly) { - GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name); - if (loaded_asm) - return *loaded_asm; -#ifdef DEBUG_ENABLED - CRASH_COND(!FileAccess::exists(p_path)); -#endif - no_search = true; - GDMonoAssembly *res = _load_assembly_from(p_name, p_path, p_refonly); - no_search = false; - return res; -} + if (p_name == "mscorlib" || p_name == "mscorlib.dll") + return GDMono::get_singleton()->get_corlib_assembly(); -GDMonoAssembly::GDMonoAssembly(const String &p_name, const String &p_path) { + // We need to manually call the search hook in this case, as it won't be called in the next step + MonoAssemblyName *aname = mono_assembly_name_new(p_name.utf8()); + MonoAssembly *assembly = mono_assembly_invoke_search_hook(aname); + mono_assembly_name_free(aname); + mono_free(aname); + + if (!assembly) { + assembly = _real_load_assembly_from(p_path, p_refonly); + ERR_FAIL_NULL_V(assembly, nullptr); + } - loaded = false; - gdobject_class_cache_updated = false; - name = p_name; - path = p_path; - refonly = false; - modified_time = 0; - assembly = NULL; - image = NULL; + GDMonoAssembly *loaded_asm = GDMono::get_singleton()->get_loaded_assembly(p_name); + ERR_FAIL_NULL_V_MSG(loaded_asm, nullptr, "Loaded assembly missing from table. Did we not receive the load hook?"); + + return loaded_asm; +} + +GDMonoAssembly::GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly) : + name(p_name), + image(p_image), + assembly(p_assembly), +#ifdef GD_MONO_HOT_RELOAD + modified_time(0), +#endif + gdobject_class_cache_updated(false) { } GDMonoAssembly::~GDMonoAssembly() { - if (loaded) + if (image) unload(); } diff --git a/modules/mono/mono_gd/gd_mono_assembly.h b/modules/mono/mono_gd/gd_mono_assembly.h index 4740e10339..43c8225b74 100644 --- a/modules/mono/mono_gd/gd_mono_assembly.h +++ b/modules/mono/mono_gd/gd_mono_assembly.h @@ -68,24 +68,20 @@ class GDMonoAssembly { StringName class_name; }; - MonoAssembly *assembly; + String name; MonoImage *image; + MonoAssembly *assembly; - bool refonly; - bool loaded; - - String name; - String path; +#ifdef GD_MONO_HOT_RELOAD uint64_t modified_time; - - HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes; - Map<MonoClass *, GDMonoClass *> cached_raw; +#endif bool gdobject_class_cache_updated; Map<StringName, GDMonoClass *> gdobject_class_cache; - static bool no_search; - static bool in_preload; + HashMap<ClassKey, GDMonoClass *, ClassKey::Hasher> cached_classes; + Map<MonoClass *, GDMonoClass *> cached_raw; + static Vector<String> search_dirs; static void assembly_load_hook(MonoAssembly *assembly, void *user_data); @@ -97,25 +93,24 @@ class GDMonoAssembly { static MonoAssembly *_search_hook(MonoAssemblyName *aname, void *user_data, bool refonly); static MonoAssembly *_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data, bool refonly); - static GDMonoAssembly *_load_assembly_from(const String &p_name, const String &p_path, bool p_refonly); - static GDMonoAssembly *_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly); - static void _wrap_mono_assembly(MonoAssembly *assembly); + static MonoAssembly *_real_load_assembly_from(const String &p_path, bool p_refonly); + static MonoAssembly *_load_assembly_search(const String &p_name, const Vector<String> &p_search_dirs, bool p_refonly); friend class GDMono; static void initialize(); public: - Error load(bool p_refonly); - Error wrapper_for_image(MonoImage *p_image); void unload(); - _FORCE_INLINE_ bool is_refonly() const { return refonly; } - _FORCE_INLINE_ bool is_loaded() const { return loaded; } _FORCE_INLINE_ MonoImage *get_image() const { return image; } _FORCE_INLINE_ MonoAssembly *get_assembly() const { return assembly; } _FORCE_INLINE_ String get_name() const { return name; } - _FORCE_INLINE_ String get_path() const { return path; } + +#ifdef GD_MONO_HOT_RELOAD _FORCE_INLINE_ uint64_t get_modified_time() const { return modified_time; } +#endif + + String get_path() const; GDMonoClass *get_class(const StringName &p_namespace, const StringName &p_name); GDMonoClass *get_class(MonoClass *p_mono_class); @@ -128,7 +123,7 @@ public: static GDMonoAssembly *load_from(const String &p_name, const String &p_path, bool p_refonly); - GDMonoAssembly(const String &p_name, const String &p_path = String()); + GDMonoAssembly(const String &p_name, MonoImage *p_image, MonoAssembly *p_assembly); ~GDMonoAssembly(); }; diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp index e493098211..facc0da780 100644 --- a/modules/mono/mono_gd/gd_mono_cache.cpp +++ b/modules/mono/mono_gd/gd_mono_cache.cpp @@ -40,11 +40,11 @@ namespace GDMonoCache { CachedData cached_data; -#define CACHE_AND_CHECK(m_var, m_val) \ - { \ - CRASH_COND(m_var != NULL); \ - m_var = m_val; \ - ERR_FAIL_COND_MSG(m_var == NULL, "Mono Cache: Member " #m_var " is null."); \ +#define CACHE_AND_CHECK(m_var, m_val) \ + { \ + CRASH_COND(m_var != nullptr); \ + m_var = m_val; \ + ERR_FAIL_COND_MSG(m_var == nullptr, "Mono Cache: Member " #m_var " is null."); \ } #define CACHE_CLASS_AND_CHECK(m_class, m_val) CACHE_AND_CHECK(cached_data.class_##m_class, m_val) @@ -54,12 +54,12 @@ CachedData cached_data; #define CACHE_METHOD_AND_CHECK(m_class, m_method, m_val) CACHE_AND_CHECK(cached_data.method_##m_class##_##m_method, m_val) #define CACHE_PROPERTY_AND_CHECK(m_class, m_property, m_val) CACHE_AND_CHECK(cached_data.property_##m_class##_##m_property, m_val) -#define CACHE_METHOD_THUNK_AND_CHECK_IMPL(m_var, m_val) \ - { \ - CRASH_COND(!m_var.is_null()); \ - ERR_FAIL_COND_MSG(m_val == NULL, "Mono Cache: Method for member " #m_var " is null."); \ - m_var.set_from_method(m_val); \ - ERR_FAIL_COND_MSG(m_var.is_null(), "Mono Cache: Member " #m_var " is null."); \ +#define CACHE_METHOD_THUNK_AND_CHECK_IMPL(m_var, m_val) \ + { \ + CRASH_COND(!m_var.is_null()); \ + ERR_FAIL_COND_MSG(m_val == nullptr, "Mono Cache: Method for member " #m_var " is null."); \ + m_var.set_from_method(m_val); \ + ERR_FAIL_COND_MSG(m_var.is_null(), "Mono Cache: Member " #m_var " is null."); \ } #define CACHE_METHOD_THUNK_AND_CHECK(m_class, m_method, m_val) CACHE_METHOD_THUNK_AND_CHECK_IMPL(cached_data.methodthunk_##m_class##_##m_method, m_val) @@ -68,93 +68,93 @@ void CachedData::clear_corlib_cache() { corlib_cache_updated = false; - class_MonoObject = NULL; - class_bool = NULL; - class_int8_t = NULL; - class_int16_t = NULL; - class_int32_t = NULL; - class_int64_t = NULL; - class_uint8_t = NULL; - class_uint16_t = NULL; - class_uint32_t = NULL; - class_uint64_t = NULL; - class_float = NULL; - class_double = NULL; - class_String = NULL; - class_IntPtr = NULL; - - class_System_Collections_IEnumerable = NULL; - class_System_Collections_IDictionary = NULL; + class_MonoObject = nullptr; + class_bool = nullptr; + class_int8_t = nullptr; + class_int16_t = nullptr; + class_int32_t = nullptr; + class_int64_t = nullptr; + class_uint8_t = nullptr; + class_uint16_t = nullptr; + class_uint32_t = nullptr; + class_uint64_t = nullptr; + class_float = nullptr; + class_double = nullptr; + class_String = nullptr; + class_IntPtr = nullptr; + + class_System_Collections_IEnumerable = nullptr; + class_System_Collections_IDictionary = nullptr; #ifdef DEBUG_ENABLED - class_System_Diagnostics_StackTrace = NULL; + class_System_Diagnostics_StackTrace = nullptr; methodthunk_System_Diagnostics_StackTrace_GetFrames.nullify(); - method_System_Diagnostics_StackTrace_ctor_bool = NULL; - method_System_Diagnostics_StackTrace_ctor_Exception_bool = NULL; + method_System_Diagnostics_StackTrace_ctor_bool = nullptr; + method_System_Diagnostics_StackTrace_ctor_Exception_bool = nullptr; #endif - class_KeyNotFoundException = NULL; + class_KeyNotFoundException = nullptr; } void CachedData::clear_godot_api_cache() { godot_api_cache_updated = false; - rawclass_Dictionary = NULL; - - class_Vector2 = NULL; - class_Vector2i = NULL; - class_Rect2 = NULL; - class_Rect2i = NULL; - class_Transform2D = NULL; - class_Vector3 = NULL; - class_Vector3i = NULL; - class_Basis = NULL; - class_Quat = NULL; - class_Transform = NULL; - class_AABB = NULL; - class_Color = NULL; - class_Plane = NULL; - class_StringName = NULL; - class_NodePath = NULL; - class_RID = NULL; - class_GodotObject = NULL; - class_GodotResource = NULL; - class_Node = NULL; - class_Control = NULL; - class_Node3D = NULL; - class_WeakRef = NULL; - class_Callable = NULL; - class_SignalInfo = NULL; - class_Array = NULL; - class_Dictionary = NULL; - class_MarshalUtils = NULL; - class_ISerializationListener = NULL; + rawclass_Dictionary = nullptr; + + class_Vector2 = nullptr; + class_Vector2i = nullptr; + class_Rect2 = nullptr; + class_Rect2i = nullptr; + class_Transform2D = nullptr; + class_Vector3 = nullptr; + class_Vector3i = nullptr; + class_Basis = nullptr; + class_Quat = nullptr; + class_Transform = nullptr; + class_AABB = nullptr; + class_Color = nullptr; + class_Plane = nullptr; + class_StringName = nullptr; + class_NodePath = nullptr; + class_RID = nullptr; + class_GodotObject = nullptr; + class_GodotResource = nullptr; + class_Node = nullptr; + class_Control = nullptr; + class_Node3D = nullptr; + class_WeakRef = nullptr; + class_Callable = nullptr; + class_SignalInfo = nullptr; + class_Array = nullptr; + class_Dictionary = nullptr; + class_MarshalUtils = nullptr; + class_ISerializationListener = nullptr; #ifdef DEBUG_ENABLED - class_DebuggingUtils = NULL; + class_DebuggingUtils = nullptr; methodthunk_DebuggingUtils_GetStackFrameInfo.nullify(); #endif - class_ExportAttribute = NULL; - field_ExportAttribute_hint = NULL; - field_ExportAttribute_hintString = NULL; - class_SignalAttribute = NULL; - class_ToolAttribute = NULL; - class_RemoteAttribute = NULL; - class_MasterAttribute = NULL; - class_PuppetAttribute = NULL; - class_RemoteSyncAttribute = NULL; - class_MasterSyncAttribute = NULL; - class_PuppetSyncAttribute = NULL; - class_GodotMethodAttribute = NULL; - field_GodotMethodAttribute_methodName = NULL; - - field_GodotObject_ptr = NULL; - field_StringName_ptr = NULL; - field_NodePath_ptr = NULL; - field_Image_ptr = NULL; - field_RID_ptr = NULL; + class_ExportAttribute = nullptr; + field_ExportAttribute_hint = nullptr; + field_ExportAttribute_hintString = nullptr; + class_SignalAttribute = nullptr; + class_ToolAttribute = nullptr; + class_RemoteAttribute = nullptr; + class_MasterAttribute = nullptr; + class_PuppetAttribute = nullptr; + class_RemoteSyncAttribute = nullptr; + class_MasterSyncAttribute = nullptr; + class_PuppetSyncAttribute = nullptr; + class_GodotMethodAttribute = nullptr; + field_GodotMethodAttribute_methodName = nullptr; + + field_GodotObject_ptr = nullptr; + field_StringName_ptr = nullptr; + field_NodePath_ptr = nullptr; + field_Image_ptr = nullptr; + field_RID_ptr = nullptr; methodthunk_GodotObject_Dispose.nullify(); methodthunk_Array_GetPtr.nullify(); @@ -251,7 +251,7 @@ void update_godot_api_cache() { CACHE_CLASS_AND_CHECK(GodotResource, GODOT_API_CLASS(Resource)); CACHE_CLASS_AND_CHECK(Node, GODOT_API_CLASS(Node)); CACHE_CLASS_AND_CHECK(Control, GODOT_API_CLASS(Control)); - CACHE_CLASS_AND_CHECK(Node3D, GODOT_API_CLASS(Node3Dshou)); + CACHE_CLASS_AND_CHECK(Node3D, GODOT_API_CLASS(Node3D)); CACHE_CLASS_AND_CHECK(WeakRef, GODOT_API_CLASS(WeakRef)); CACHE_CLASS_AND_CHECK(Callable, GODOT_API_CLASS(Callable)); CACHE_CLASS_AND_CHECK(SignalInfo, GODOT_API_CLASS(SignalInfo)); diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index 648f5f6c6b..ede4203e35 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -40,7 +40,7 @@ String GDMonoClass::get_full_name(MonoClass *p_mono_class) { // mono_type_get_full_name is not exposed to embedders, but this seems to do the job MonoReflectionType *type_obj = mono_type_get_object(mono_domain_get(), get_mono_type(p_mono_class)); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoString *str = GDMonoUtils::object_to_string((MonoObject *)type_obj, &exc); UNHANDLED_EXCEPTION(exc); @@ -76,12 +76,12 @@ bool GDMonoClass::is_assignable_from(GDMonoClass *p_from) const { GDMonoClass *GDMonoClass::get_parent_class() { MonoClass *parent_mono_class = mono_class_get_parent(mono_class); - return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : NULL; + return parent_mono_class ? GDMono::get_singleton()->get_class(parent_mono_class) : nullptr; } GDMonoClass *GDMonoClass::get_nesting_class() { MonoClass *nesting_type = mono_class_get_nesting_type(mono_class); - return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : NULL; + return nesting_type ? GDMono::get_singleton()->get_class(nesting_type) : nullptr; } #ifdef TOOLS_ENABLED @@ -92,9 +92,9 @@ Vector<MonoClassField *> GDMonoClass::get_enum_fields() { Vector<MonoClassField *> enum_fields; - void *iter = NULL; - MonoClassField *raw_field = NULL; - while ((raw_field = mono_class_get_fields(get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoClassField *raw_field = nullptr; + while ((raw_field = mono_class_get_fields(get_mono_ptr(), &iter)) != nullptr) { uint32_t field_flags = mono_field_get_flags(raw_field); // Enums have an instance field named value__ which holds the value of the enum. @@ -126,21 +126,21 @@ bool GDMonoClass::has_attribute(GDMonoClass *p_attr_class) { MonoObject *GDMonoClass::get_attribute(GDMonoClass *p_attr_class) { #ifdef DEBUG_ENABLED - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); #endif if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoClass::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_class(get_mono_ptr()); attrs_fetched = true; @@ -153,9 +153,9 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base if (methods_fetched) return; - void *iter = NULL; - MonoMethod *raw_method = NULL; - while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoMethod *raw_method = nullptr; + while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { StringName name = mono_method_get_name(raw_method); // get_method implicitly fetches methods and adds them to this->methods @@ -198,7 +198,7 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base } #endif - uint32_t flags = mono_method_get_flags(method->mono_method, NULL); + uint32_t flags = mono_method_get_flags(method->mono_method, nullptr); if (!(flags & MONO_METHOD_ATTR_VIRTUAL)) continue; @@ -242,21 +242,21 @@ void GDMonoClass::fetch_methods_with_godot_api_checks(GDMonoClass *p_native_base GDMonoMethod *GDMonoClass::get_fetched_method_unknown_params(const StringName &p_name) { - ERR_FAIL_COND_V(!methods_fetched, NULL); + ERR_FAIL_COND_V(!methods_fetched, nullptr); - const MethodKey *k = NULL; + const MethodKey *k = nullptr; while ((k = methods.next(k))) { if (k->name == p_name) return methods.get(*k); } - return NULL; + return nullptr; } bool GDMonoClass::has_fetched_method_unknown_params(const StringName &p_name) { - return get_fetched_method_unknown_params(p_name) != NULL; + return get_fetched_method_unknown_params(p_name) != nullptr; } bool GDMonoClass::implements_interface(GDMonoClass *p_interface) { @@ -274,7 +274,7 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou return *match; if (methods_fetched) - return NULL; + return nullptr; MonoMethod *raw_method = mono_class_get_method_from_name(mono_class, String(p_name).utf8().get_data(), p_params_count); @@ -285,7 +285,7 @@ GDMonoMethod *GDMonoClass::get_method(const StringName &p_name, int p_params_cou return method; } - return NULL; + return nullptr; } GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method) { @@ -307,7 +307,7 @@ GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName GDMonoMethod *GDMonoClass::get_method(MonoMethod *p_raw_method, const StringName &p_name, int p_params_count) { - ERR_FAIL_NULL_V(p_raw_method, NULL); + ERR_FAIL_NULL_V(p_raw_method, nullptr); MethodKey key = MethodKey(p_name, p_params_count); @@ -328,7 +328,7 @@ GDMonoMethod *GDMonoClass::get_method_with_desc(const String &p_description, boo MonoMethod *method = mono_method_desc_search_in_class(desc, mono_class); mono_method_desc_free(desc); - ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, NULL); + ERR_FAIL_COND_V(mono_method_get_class(method) != mono_class, nullptr); return get_method(method); } @@ -341,7 +341,7 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) { return result->value(); if (fields_fetched) - return NULL; + return nullptr; MonoClassField *raw_field = mono_class_get_field_from_name(mono_class, String(p_name).utf8().get_data()); @@ -352,7 +352,7 @@ GDMonoField *GDMonoClass::get_field(const StringName &p_name) { return field; } - return NULL; + return nullptr; } const Vector<GDMonoField *> &GDMonoClass::get_all_fields() { @@ -360,9 +360,9 @@ const Vector<GDMonoField *> &GDMonoClass::get_all_fields() { if (fields_fetched) return fields_list; - void *iter = NULL; - MonoClassField *raw_field = NULL; - while ((raw_field = mono_class_get_fields(mono_class, &iter)) != NULL) { + void *iter = nullptr; + MonoClassField *raw_field = nullptr; + while ((raw_field = mono_class_get_fields(mono_class, &iter)) != nullptr) { StringName name = mono_field_get_name(raw_field); Map<StringName, GDMonoField *>::Element *match = fields.find(name); @@ -389,7 +389,7 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) { return result->value(); if (properties_fetched) - return NULL; + return nullptr; MonoProperty *raw_property = mono_class_get_property_from_name(mono_class, String(p_name).utf8().get_data()); @@ -400,7 +400,7 @@ GDMonoProperty *GDMonoClass::get_property(const StringName &p_name) { return property; } - return NULL; + return nullptr; } const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() { @@ -408,9 +408,9 @@ const Vector<GDMonoProperty *> &GDMonoClass::get_all_properties() { if (properties_fetched) return properties_list; - void *iter = NULL; - MonoProperty *raw_property = NULL; - while ((raw_property = mono_class_get_properties(mono_class, &iter)) != NULL) { + void *iter = nullptr; + MonoProperty *raw_property = nullptr; + while ((raw_property = mono_class_get_properties(mono_class, &iter)) != nullptr) { StringName name = mono_property_get_name(raw_property); Map<StringName, GDMonoProperty *>::Element *match = properties.find(name); @@ -433,9 +433,9 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { if (delegates_fetched) return delegates_list; - void *iter = NULL; - MonoClass *raw_class = NULL; - while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != NULL) { + void *iter = nullptr; + MonoClass *raw_class = nullptr; + while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != nullptr) { if (mono_class_is_delegate(raw_class)) { StringName name = mono_class_get_name(raw_class); @@ -459,9 +459,9 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { const Vector<GDMonoMethod *> &GDMonoClass::get_all_methods() { if (!method_list_fetched) { - void *iter = NULL; - MonoMethod *raw_method = NULL; - while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != NULL) { + void *iter = nullptr; + MonoMethod *raw_method = nullptr; + while ((raw_method = mono_class_get_methods(get_mono_ptr(), &iter)) != nullptr) { method_list.push_back(memnew(GDMonoMethod(mono_method_get_name(raw_method), raw_method))); } @@ -479,7 +479,7 @@ GDMonoClass::GDMonoClass(const StringName &p_namespace, const StringName &p_name assembly = p_assembly; attrs_fetched = false; - attributes = NULL; + attributes = nullptr; methods_fetched = false; method_list_fetched = false; @@ -512,7 +512,7 @@ GDMonoClass::~GDMonoClass() { Vector<GDMonoMethod *> deleted_methods; deleted_methods.resize(methods.size()); - const MethodKey *k = NULL; + const MethodKey *k = nullptr; while ((k = methods.next(k))) { GDMonoMethod *method = methods.get(*k); diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index 11942c47d9..3f4e5fe5ac 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -116,7 +116,7 @@ void GDMonoField::set_value_from_variant(MonoObject *p_object, const Variant &p_ case MONO_TYPE_STRING: { if (p_value.get_type() == Variant::NIL) { // Otherwise, Variant -> String would return the string "Null" - MonoString *mono_string = NULL; + MonoString *mono_string = nullptr; mono_field_set_value(p_object, mono_field, mono_string); } else { MonoString *mono_string = GDMonoMarshal::mono_string_from_godot(p_value); @@ -623,19 +623,19 @@ bool GDMonoField::has_attribute(GDMonoClass *p_attr_class) { } MonoObject *GDMonoField::get_attribute(GDMonoClass *p_attr_class) { - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoField::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_field(owner->get_mono_ptr(), mono_field); attrs_fetched = true; } @@ -671,7 +671,7 @@ GDMonoField::GDMonoField(MonoClassField *p_mono_field, GDMonoClass *p_owner) { type.type_class = GDMono::get_singleton()->get_class(field_type_class); attrs_fetched = false; - attributes = NULL; + attributes = nullptr; } GDMonoField::~GDMonoField() { diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 53e642f317..1898785699 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -61,7 +61,7 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { GDMonoClass *native = GDMonoUtils::get_class_native_base(klass); - CRASH_COND(native == NULL); + CRASH_COND(native == nullptr); if (native == klass) { // If it's just a wrapper Godot class and not a custom inheriting class, then attach a @@ -119,7 +119,7 @@ void unhandled_exception(MonoException *p_exc) { if (GDMono::get_singleton()->get_unhandled_exception_policy() == GDMono::POLICY_TERMINATE_APP) { // Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders - GDMono::unhandled_exception_hook((MonoObject *)p_exc, NULL); + GDMono::unhandled_exception_hook((MonoObject *)p_exc, nullptr); GD_UNREACHABLE(); } else { #ifdef DEBUG_ENABLED diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index 76828a66e0..ca16c2b76a 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -46,13 +46,13 @@ static CharString get_default_log_level() { #endif } -GDMonoLog *GDMonoLog::singleton = NULL; +GDMonoLog *GDMonoLog::singleton = nullptr; -#if !defined(JAVASCRIPT_ENABLED) +#ifdef GD_MONO_LOG_ENABLED static int get_log_level_id(const char *p_log_level) { - const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", NULL }; + const char *valid_log_levels[] = { "error", "critical", "warning", "message", "info", "debug", nullptr }; int i = 0; while (valid_log_levels[i]) { @@ -191,7 +191,7 @@ GDMonoLog::GDMonoLog() { GDMonoLog::~GDMonoLog() { - singleton = NULL; + singleton = nullptr; if (log_file) { log_file->close(); @@ -213,7 +213,7 @@ GDMonoLog::GDMonoLog() { GDMonoLog::~GDMonoLog() { - singleton = NULL; + singleton = nullptr; } #endif // !defined(JAVASCRIPT_ENABLED) diff --git a/modules/mono/mono_gd/gd_mono_log.h b/modules/mono/mono_gd/gd_mono_log.h index ecf4c78b1a..1fc21f7df5 100644 --- a/modules/mono/mono_gd/gd_mono_log.h +++ b/modules/mono/mono_gd/gd_mono_log.h @@ -35,13 +35,18 @@ #include "core/typedefs.h" -#if !defined(JAVASCRIPT_ENABLED) +#if !defined(JAVASCRIPT_ENABLED) && !defined(IPHONE_ENABLED) +// We have custom mono log callbacks for WASM and iOS +#define GD_MONO_LOG_ENABLED +#endif + +#ifdef GD_MONO_LOG_ENABLED #include "core/os/file_access.h" #endif class GDMonoLog { -#if !defined(JAVASCRIPT_ENABLED) +#ifdef GD_MONO_LOG_ENABLED int log_level_id; FileAccess *log_file; diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 0de5352752..1878038f44 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -410,7 +410,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty case MONO_TYPE_STRING: { if (p_var->get_type() == Variant::NIL) - return NULL; // Otherwise, Variant -> String would return the string "Null" + return nullptr; // Otherwise, Variant -> String would return the string "Null" return (MonoObject *)mono_string_from_godot(p_var->operator String()); } break; @@ -537,7 +537,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty return BOX_ENUM(enum_baseclass, val); } default: { - ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed enum value of unmarshallable base type."); + ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to a managed enum value of unmarshallable base type."); } } } @@ -577,7 +577,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty if (array_type->eklass == CACHED_CLASS_RAW(Color)) return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray()); - ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to a managed array of unmarshallable element type."); + ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to a managed array of unmarshallable element type."); } break; case MONO_TYPE_CLASS: { @@ -749,7 +749,7 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty case Variant::PACKED_COLOR_ARRAY: return (MonoObject *)PackedColorArray_to_mono_array(p_var->operator PackedColorArray()); default: - return NULL; + return nullptr; } break; case MONO_TYPE_GENERICINST: { @@ -792,8 +792,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty } break; } - ERR_FAIL_V_MSG(NULL, "Attempted to convert Variant to an unmarshallable managed type. Name: '" + - p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + "."); + ERR_FAIL_V_MSG(nullptr, "Attempted to convert Variant to an unmarshallable managed type. Name: '" + + p_type.type_class->get_name() + "' Encoding: " + itos(p_type.type_encoding) + "."); } Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type, bool p_fail_with_err = true) { @@ -831,7 +831,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type return unbox<double>(p_obj); case MONO_TYPE_STRING: { - if (p_obj == NULL) + if (p_obj == nullptr) return Variant(); // NIL return mono_string_to_godot_not_null((MonoString *)p_obj); } break; @@ -935,7 +935,7 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type // GodotObject if (CACHED_CLASS(GodotObject)->is_assignable_from(type_class)) { Object *ptr = unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_obj)); - if (ptr != NULL) { + if (ptr != nullptr) { Reference *ref = Object::cast_to<Reference>(ptr); return ref ? Variant(Ref<Reference>(ref)) : Variant(ptr); } @@ -958,14 +958,14 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type } if (CACHED_CLASS(Array) == type_class) { - MonoException *exc = NULL; + MonoException *exc = nullptr; Array *ptr = CACHED_METHOD_THUNK(Array, GetPtr).invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return ptr ? Variant(*ptr) : Variant(); } if (CACHED_CLASS(Dictionary) == type_class) { - MonoException *exc = NULL; + MonoException *exc = nullptr; Dictionary *ptr = CACHED_METHOD_THUNK(Dictionary, GetPtr).invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return ptr ? Variant(*ptr) : Variant(); @@ -996,14 +996,14 @@ Variant mono_object_to_variant_impl(MonoObject *p_obj, const ManagedType &p_type MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), p_type.type_class->get_mono_type()); if (GDMonoUtils::Marshal::type_is_generic_dictionary(reftype)) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = p_type.type_class->get_method("GetPtr")->invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return *unbox<Dictionary *>(ret); } if (GDMonoUtils::Marshal::type_is_generic_array(reftype)) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = p_type.type_class->get_method("GetPtr")->invoke(p_obj, &exc); UNHANDLED_EXCEPTION(exc); return *unbox<Array *>(ret); @@ -1064,9 +1064,9 @@ String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) { ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj)); Variant var = GDMonoMarshal::mono_object_to_variant_no_err(p_obj, type); - if (var.get_type() == Variant::NIL && p_obj != NULL) { + if (var.get_type() == Variant::NIL && p_obj != nullptr) { // Cannot convert MonoObject* to Variant; fallback to 'ToString()'. - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoString *mono_str = GDMonoUtils::object_to_string(p_obj, &exc); if (exc) { @@ -1393,7 +1393,7 @@ Callable managed_to_callable(const M_Callable &p_managed_callable) { } else { Object *target = p_managed_callable.target ? unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) : - NULL; + nullptr; StringName *method_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name)); StringName method = method_ptr ? *method_ptr : StringName(); return Callable(target, method); @@ -1408,7 +1408,7 @@ M_Callable callable_to_managed(const Callable &p_callable) { if (compare_equal_func == ManagedCallable::compare_equal_func_ptr) { ManagedCallable *managed_callable = static_cast<ManagedCallable *>(custom); return { - NULL, NULL, + nullptr, nullptr, managed_callable->get_delegate() }; } else if (compare_equal_func == SignalAwaiterCallable::compare_equal_func_ptr) { @@ -1416,30 +1416,30 @@ M_Callable callable_to_managed(const Callable &p_callable) { return { GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(signal_awaiter_callable->get_object())), GDMonoUtils::create_managed_from(signal_awaiter_callable->get_signal()), - NULL + nullptr }; } else if (compare_equal_func == EventSignalCallable::compare_equal_func_ptr) { EventSignalCallable *event_signal_callable = static_cast<EventSignalCallable *>(custom); return { GDMonoUtils::unmanaged_get_managed(ObjectDB::get_instance(event_signal_callable->get_object())), GDMonoUtils::create_managed_from(event_signal_callable->get_signal()), - NULL + nullptr }; } // Some other CallableCustom. We only support ManagedCallable. - return { NULL, NULL, NULL }; + return { nullptr, nullptr, nullptr }; } else { MonoObject *target_managed = GDMonoUtils::unmanaged_get_managed(p_callable.get_object()); MonoObject *method_string_name_managed = GDMonoUtils::create_managed_from(p_callable.get_method()); - return { target_managed, method_string_name_managed, NULL }; + return { target_managed, method_string_name_managed, nullptr }; } } Signal managed_to_signal_info(const M_SignalInfo &p_managed_signal) { Object *owner = p_managed_signal.owner ? unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) : - NULL; + nullptr; StringName *name_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name)); StringName name = name_ptr ? *name_ptr : StringName(); return Signal(owner, name); diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index 7d09f46b00..8b405291a7 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -63,7 +63,7 @@ T *unbox_addr(MonoObject *p_obj) { #define BOX_PTR(x) mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(IntPtr), x) #define BOX_ENUM(m_enum_class, x) mono_value_box(mono_domain_get(), m_enum_class, &x) -Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_variant = NULL); +Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_variant = nullptr); bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_elem_type); bool try_get_dictionary_key_value_types(const ManagedType &p_dictionary_type, ManagedType &r_key_type, ManagedType &r_value_type); @@ -81,7 +81,7 @@ _FORCE_INLINE_ String mono_string_to_godot_not_null(MonoString *p_mono_string) { } _FORCE_INLINE_ String mono_string_to_godot(MonoString *p_mono_string) { - if (p_mono_string == NULL) + if (p_mono_string == nullptr) return String(); return mono_string_to_godot_not_null(p_mono_string); diff --git a/modules/mono/mono_gd/gd_mono_method.cpp b/modules/mono/mono_gd/gd_mono_method.cpp index e6a1ec2697..c8cc5247c6 100644 --- a/modules/mono/mono_gd/gd_mono_method.cpp +++ b/modules/mono/mono_gd/gd_mono_method.cpp @@ -58,9 +58,9 @@ void GDMonoMethod::_update_signature(MonoMethodSignature *p_method_sig) { } } - void *iter = NULL; + void *iter = nullptr; MonoType *param_raw_type; - while ((param_raw_type = mono_signature_get_params(p_method_sig, &iter)) != NULL) { + while ((param_raw_type = mono_signature_get_params(p_method_sig, &iter)) != nullptr) { ManagedType param_type; param_type.type_encoding = mono_type_get_type(param_raw_type); @@ -81,11 +81,11 @@ GDMonoClass *GDMonoMethod::get_enclosing_class() const { } bool GDMonoMethod::is_static() { - return mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_STATIC; + return mono_method_get_flags(mono_method, nullptr) & MONO_METHOD_ATTR_STATIC; } IMonoClassMember::Visibility GDMonoMethod::get_visibility() { - switch (mono_method_get_flags(mono_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) { + switch (mono_method_get_flags(mono_method, nullptr) & MONO_METHOD_ATTR_ACCESS_MASK) { case MONO_METHOD_ATTR_PRIVATE: return IMonoClassMember::PRIVATE; case MONO_METHOD_ATTR_FAM_AND_ASSEM: @@ -102,7 +102,7 @@ IMonoClassMember::Visibility GDMonoMethod::get_visibility() { } MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc) const { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret; if (params_count > 0) { @@ -115,11 +115,11 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, ret = GDMonoUtils::runtime_invoke_array(mono_method, p_object, params, &exc); } else { - ret = GDMonoUtils::runtime_invoke(mono_method, p_object, NULL, &exc); + ret = GDMonoUtils::runtime_invoke(mono_method, p_object, nullptr, &exc); } if (exc) { - ret = NULL; + ret = nullptr; if (r_exc) { *r_exc = exc; } else { @@ -131,16 +131,16 @@ MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, } MonoObject *GDMonoMethod::invoke(MonoObject *p_object, MonoException **r_exc) const { - ERR_FAIL_COND_V(get_parameters_count() > 0, NULL); - return invoke_raw(p_object, NULL, r_exc); + ERR_FAIL_COND_V(get_parameters_count() > 0, nullptr); + return invoke_raw(p_object, nullptr, r_exc); } MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc) const { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoObject *ret = GDMonoUtils::runtime_invoke(mono_method, p_object, p_params, &exc); if (exc) { - ret = NULL; + ret = nullptr; if (r_exc) { *r_exc = exc; } else { @@ -164,19 +164,19 @@ bool GDMonoMethod::has_attribute(GDMonoClass *p_attr_class) { } MonoObject *GDMonoMethod::get_attribute(GDMonoClass *p_attr_class) { - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoMethod::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_method(mono_method); attrs_fetched = true; } @@ -281,7 +281,7 @@ GDMonoMethod::GDMonoMethod(StringName p_name, MonoMethod *p_method) { method_info_fetched = false; attrs_fetched = false; - attributes = NULL; + attributes = nullptr; _update_signature(); } diff --git a/modules/mono/mono_gd/gd_mono_method.h b/modules/mono/mono_gd/gd_mono_method.h index d4379f41fe..54b2eba3e8 100644 --- a/modules/mono/mono_gd/gd_mono_method.h +++ b/modules/mono/mono_gd/gd_mono_method.h @@ -76,9 +76,9 @@ public: _FORCE_INLINE_ int get_parameters_count() const { return params_count; } _FORCE_INLINE_ ManagedType get_return_type() const { return return_type; } - MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = NULL) const; - MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = NULL) const; - MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = NULL) const; + MonoObject *invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc = nullptr) const; + MonoObject *invoke(MonoObject *p_object, MonoException **r_exc = nullptr) const; + MonoObject *invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr) const; String get_full_name(bool p_signature = false) const; String get_full_name_no_class() const; diff --git a/modules/mono/mono_gd/gd_mono_method_thunk.h b/modules/mono/mono_gd/gd_mono_method_thunk.h index d8c9a5eb02..0e05e974e9 100644 --- a/modules/mono/mono_gd/gd_mono_method_thunk.h +++ b/modules/mono/mono_gd/gd_mono_method_thunk.h @@ -39,7 +39,7 @@ #include "gd_mono_method.h" #include "gd_mono_utils.h" -#if !defined(JAVASCRIPT_ENABLED) +#if !defined(JAVASCRIPT_ENABLED) && !defined(IPHONE_ENABLED) #define HAVE_METHOD_THUNKS #endif @@ -60,16 +60,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method_thunk == NULL; + return mono_method_thunk == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method_thunk = NULL; + mono_method_thunk = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding != MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -82,7 +82,7 @@ public: } GDMonoMethodThunk() : - mono_method_thunk(NULL) { + mono_method_thunk(nullptr) { } explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) { @@ -106,16 +106,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method_thunk == NULL; + return mono_method_thunk == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method_thunk = NULL; + mono_method_thunk = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding == MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -128,12 +128,12 @@ public: } GDMonoMethodThunkR() : - mono_method_thunk(NULL) { + mono_method_thunk(nullptr) { } explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); #endif mono_method_thunk = (M)mono_method_get_unmanaged_thunk(p_mono_method->get_mono_ptr()); } @@ -146,7 +146,7 @@ struct VariadicInvokeMonoMethodImpl { static void invoke(GDMonoMethod *p_mono_method, P1 p_arg1, ParamTypes... p_args, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[ThunkParamCount] = { p_arg1, p_args... }; - p_mono_method->invoke_raw(NULL, args, r_exc); + p_mono_method->invoke_raw(nullptr, args, r_exc); } else { void *args[ThunkParamCount] = { p_args... }; p_mono_method->invoke_raw((MonoObject *)p_arg1, args, r_exc); @@ -167,7 +167,7 @@ struct VariadicInvokeMonoMethod<0> { #ifdef DEBUG_ENABLED CRASH_COND(!p_mono_method->is_static()); #endif - p_mono_method->invoke_raw(NULL, NULL, r_exc); + p_mono_method->invoke_raw(nullptr, nullptr, r_exc); } }; @@ -176,9 +176,9 @@ struct VariadicInvokeMonoMethod<1, P1> { static void invoke(GDMonoMethod *p_mono_method, P1 p_arg1, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[1] = { p_arg1 }; - p_mono_method->invoke_raw(NULL, args, r_exc); + p_mono_method->invoke_raw(nullptr, args, r_exc); } else { - p_mono_method->invoke_raw((MonoObject *)p_arg1, NULL, r_exc); + p_mono_method->invoke_raw((MonoObject *)p_arg1, nullptr, r_exc); } } }; @@ -203,7 +203,7 @@ struct VariadicInvokeMonoMethodRImpl { static R invoke(GDMonoMethod *p_mono_method, P1 p_arg1, ParamTypes... p_args, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[ThunkParamCount] = { p_arg1, p_args... }; - MonoObject *r = p_mono_method->invoke_raw(NULL, args, r_exc); + MonoObject *r = p_mono_method->invoke_raw(nullptr, args, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } else { void *args[ThunkParamCount] = { p_args... }; @@ -226,7 +226,7 @@ struct VariadicInvokeMonoMethodR<0, R> { #ifdef DEBUG_ENABLED CRASH_COND(!p_mono_method->is_static()); #endif - MonoObject *r = p_mono_method->invoke_raw(NULL, NULL, r_exc); + MonoObject *r = p_mono_method->invoke_raw(nullptr, nullptr, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } }; @@ -236,10 +236,10 @@ struct VariadicInvokeMonoMethodR<1, R, P1> { static R invoke(GDMonoMethod *p_mono_method, P1 p_arg1, MonoException **r_exc) { if (p_mono_method->is_static()) { void *args[1] = { p_arg1 }; - MonoObject *r = p_mono_method->invoke_raw(NULL, args, r_exc); + MonoObject *r = p_mono_method->invoke_raw(nullptr, args, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } else { - MonoObject *r = p_mono_method->invoke_raw((MonoObject *)p_arg1, NULL, r_exc); + MonoObject *r = p_mono_method->invoke_raw((MonoObject *)p_arg1, nullptr, r_exc); return unbox_if_needed<R>(r, p_mono_method->get_return_type()); } } @@ -256,16 +256,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method == NULL; + return mono_method == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method = NULL; + mono_method = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding != MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -278,7 +278,7 @@ public: } GDMonoMethodThunk() : - mono_method(NULL) { + mono_method(nullptr) { } explicit GDMonoMethodThunk(GDMonoMethod *p_mono_method) { @@ -297,16 +297,16 @@ public: } _FORCE_INLINE_ bool is_null() { - return mono_method == NULL; + return mono_method == nullptr; } _FORCE_INLINE_ void nullify() { - mono_method = NULL; + mono_method = nullptr; } _FORCE_INLINE_ void set_from_method(GDMonoMethod *p_mono_method) { #ifdef DEBUG_ENABLED - CRASH_COND(p_mono_method == NULL); + CRASH_COND(p_mono_method == nullptr); CRASH_COND(p_mono_method->get_return_type().type_encoding == MONO_TYPE_VOID); if (p_mono_method->is_static()) { @@ -319,7 +319,7 @@ public: } GDMonoMethodThunkR() : - mono_method(NULL) { + mono_method(nullptr) { } explicit GDMonoMethodThunkR(GDMonoMethod *p_mono_method) { diff --git a/modules/mono/mono_gd/gd_mono_property.cpp b/modules/mono/mono_gd/gd_mono_property.cpp index 3b5ce58d80..c3e7598f2d 100644 --- a/modules/mono/mono_gd/gd_mono_property.cpp +++ b/modules/mono/mono_gd/gd_mono_property.cpp @@ -57,7 +57,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own MonoMethodSignature *setter_sig = mono_method_signature(prop_method); - void *iter = NULL; + void *iter = nullptr; MonoType *param_raw_type = mono_signature_get_params(setter_sig, &iter); type.type_encoding = mono_type_get_type(param_raw_type); @@ -66,7 +66,7 @@ GDMonoProperty::GDMonoProperty(MonoProperty *p_mono_property, GDMonoClass *p_own } attrs_fetched = false; - attributes = NULL; + attributes = nullptr; } GDMonoProperty::~GDMonoProperty() { @@ -77,17 +77,17 @@ GDMonoProperty::~GDMonoProperty() { bool GDMonoProperty::is_static() { MonoMethod *prop_method = mono_property_get_get_method(mono_property); - if (prop_method == NULL) + if (prop_method == nullptr) prop_method = mono_property_get_set_method(mono_property); - return mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_STATIC; + return mono_method_get_flags(prop_method, nullptr) & MONO_METHOD_ATTR_STATIC; } IMonoClassMember::Visibility GDMonoProperty::get_visibility() { MonoMethod *prop_method = mono_property_get_get_method(mono_property); - if (prop_method == NULL) + if (prop_method == nullptr) prop_method = mono_property_get_set_method(mono_property); - switch (mono_method_get_flags(prop_method, NULL) & MONO_METHOD_ATTR_ACCESS_MASK) { + switch (mono_method_get_flags(prop_method, nullptr) & MONO_METHOD_ATTR_ACCESS_MASK) { case MONO_METHOD_ATTR_PRIVATE: return IMonoClassMember::PRIVATE; case MONO_METHOD_ATTR_FAM_AND_ASSEM: @@ -116,36 +116,36 @@ bool GDMonoProperty::has_attribute(GDMonoClass *p_attr_class) { } MonoObject *GDMonoProperty::get_attribute(GDMonoClass *p_attr_class) { - ERR_FAIL_NULL_V(p_attr_class, NULL); + ERR_FAIL_NULL_V(p_attr_class, nullptr); if (!attrs_fetched) fetch_attributes(); if (!attributes) - return NULL; + return nullptr; return mono_custom_attrs_get_attr(attributes, p_attr_class->get_mono_ptr()); } void GDMonoProperty::fetch_attributes() { - ERR_FAIL_COND(attributes != NULL); + ERR_FAIL_COND(attributes != nullptr); attributes = mono_custom_attrs_from_property(owner->get_mono_ptr(), mono_property); attrs_fetched = true; } bool GDMonoProperty::has_getter() { - return mono_property_get_get_method(mono_property) != NULL; + return mono_property_get_get_method(mono_property) != nullptr; } bool GDMonoProperty::has_setter() { - return mono_property_get_set_method(mono_property) != NULL; + return mono_property_get_set_method(mono_property) != nullptr; } void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc) { MonoMethod *prop_method = mono_property_get_set_method(mono_property); MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), 1); mono_array_setref(params, 0, p_value); - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_invoke_array(prop_method, p_object, params, &exc); if (exc) { if (r_exc) { @@ -157,7 +157,7 @@ void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoEx } void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoException **r_exc) { - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::property_set_value(mono_property, p_object, p_params, &exc); if (exc) { @@ -170,11 +170,11 @@ void GDMonoProperty::set_value(MonoObject *p_object, void **p_params, MonoExcept } MonoObject *GDMonoProperty::get_value(MonoObject *p_object, MonoException **r_exc) { - MonoException *exc = NULL; - MonoObject *ret = GDMonoUtils::property_get_value(mono_property, p_object, NULL, &exc); + MonoException *exc = nullptr; + MonoObject *ret = GDMonoUtils::property_get_value(mono_property, p_object, nullptr, &exc); if (exc) { - ret = NULL; + ret = nullptr; if (r_exc) { *r_exc = exc; } else { diff --git a/modules/mono/mono_gd/gd_mono_property.h b/modules/mono/mono_gd/gd_mono_property.h index 2aec64f565..4653758a86 100644 --- a/modules/mono/mono_gd/gd_mono_property.h +++ b/modules/mono/mono_gd/gd_mono_property.h @@ -65,9 +65,9 @@ public: _FORCE_INLINE_ ManagedType get_type() const { return type; } - void set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc = NULL); - void set_value(MonoObject *p_object, void **p_params, MonoException **r_exc = NULL); - MonoObject *get_value(MonoObject *p_object, MonoException **r_exc = NULL); + void set_value(MonoObject *p_object, MonoObject *p_value, MonoException **r_exc = nullptr); + void set_value(MonoObject *p_object, void **p_params, MonoException **r_exc = nullptr); + MonoObject *get_value(MonoObject *p_object, MonoException **r_exc = nullptr); bool get_bool_value(MonoObject *p_object); int get_int_value(MonoObject *p_object); diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index cdb26ae61b..00119ced88 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -57,7 +57,7 @@ namespace GDMonoUtils { MonoObject *unmanaged_get_managed(Object *unmanaged) { if (!unmanaged) - return NULL; + return nullptr; if (unmanaged->get_script_instance()) { CSharpInstance *cs_instance = CAST_CSHARP_INSTANCE(unmanaged->get_script_instance()); @@ -71,7 +71,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { void *data = unmanaged->get_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index()); - ERR_FAIL_NULL_V(data, NULL); + ERR_FAIL_NULL_V(data, nullptr); CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->value(); @@ -82,7 +82,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { // Already had a binding that needs to be setup CSharpLanguage::get_singleton()->setup_csharp_script_binding(script_binding, unmanaged); - ERR_FAIL_COND_V(!script_binding.inited, NULL); + ERR_FAIL_COND_V(!script_binding.inited, nullptr); } } @@ -99,11 +99,11 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { #ifdef DEBUG_ENABLED CRASH_COND(script_binding.type_name == StringName()); - CRASH_COND(script_binding.wrapper_class == NULL); + CRASH_COND(script_binding.wrapper_class == nullptr); #endif MonoObject *mono_object = GDMonoUtils::create_managed_for_godot_object(script_binding.wrapper_class, script_binding.type_name, unmanaged); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); gchandle = MonoGCHandleData::new_strong_handle(mono_object); @@ -127,10 +127,15 @@ void set_main_thread(MonoThread *p_thread) { } MonoThread *attach_current_thread() { - ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), NULL); + ERR_FAIL_COND_V(!GDMono::get_singleton()->is_runtime_initialized(), nullptr); MonoDomain *scripts_domain = GDMono::get_singleton()->get_scripts_domain(); +#ifndef GD_MONO_SINGLE_APPDOMAIN MonoThread *mono_thread = mono_thread_attach(scripts_domain ? scripts_domain : mono_get_root_domain()); - ERR_FAIL_NULL_V(mono_thread, NULL); +#else + // The scripts domain is the root domain + MonoThread *mono_thread = mono_thread_attach(scripts_domain); +#endif + ERR_FAIL_NULL_V(mono_thread, nullptr); return mono_thread; } @@ -152,7 +157,7 @@ MonoThread *get_current_thread() { } bool is_thread_attached() { - return mono_domain_get() != NULL; + return mono_domain_get() != nullptr; } uint32_t new_strong_gchandle(MonoObject *p_object) { @@ -174,11 +179,11 @@ void free_gchandle(uint32_t p_gchandle) { void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc) { GDMonoMethod *ctor = p_class->get_method(".ctor", 0); ERR_FAIL_NULL(ctor); - ctor->invoke_raw(p_this_obj, NULL, r_exc); + ctor->invoke_raw(p_this_obj, nullptr, r_exc); } bool mono_delegate_equal(MonoDelegate *p_a, MonoDelegate *p_b) { - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(Delegate, Equals).invoke((MonoObject *)p_a, (MonoObject *)p_b, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -221,18 +226,18 @@ GDMonoClass *get_class_native_base(GDMonoClass *p_class) { if (assembly == GDMono::get_singleton()->get_editor_api_assembly()) return klass; #endif - } while ((klass = klass->get_parent_class()) != NULL); + } while ((klass = klass->get_parent_class()) != nullptr); - return NULL; + return nullptr; } MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringName &p_native, Object *p_object) { bool parent_is_object_class = ClassDB::is_parent_class(p_object->get_class_name(), p_native); - ERR_FAIL_COND_V_MSG(!parent_is_object_class, NULL, + ERR_FAIL_COND_V_MSG(!parent_is_object_class, nullptr, "Type inherits from native type '" + p_native + "', so it can't be instanced in object of type: '" + p_object->get_class() + "'."); MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); CACHED_FIELD(GodotObject, ptr)->set_value_raw(mono_object, p_object); @@ -244,7 +249,7 @@ MonoObject *create_managed_for_godot_object(GDMonoClass *p_class, const StringNa MonoObject *create_managed_from(const StringName &p_from) { MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(StringName)); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Construct GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(StringName)); @@ -256,7 +261,7 @@ MonoObject *create_managed_from(const StringName &p_from) { MonoObject *create_managed_from(const NodePath &p_from) { MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(NodePath)); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Construct GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(NodePath)); @@ -268,7 +273,7 @@ MonoObject *create_managed_from(const NodePath &p_from) { MonoObject *create_managed_from(const RID &p_from) { MonoObject *mono_object = mono_object_new(mono_domain_get(), CACHED_CLASS_RAW(RID)); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Construct GDMonoUtils::runtime_object_init(mono_object, CACHED_CLASS(RID)); @@ -280,15 +285,15 @@ MonoObject *create_managed_from(const RID &p_from) { MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) { MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Search constructor that takes a pointer as parameter MonoMethod *m; - void *iter = NULL; + void *iter = nullptr; while ((m = mono_class_get_methods(p_class->get_mono_ptr(), &iter))) { if (strcmp(mono_method_get_name(m), ".ctor") == 0) { MonoMethodSignature *sig = mono_method_signature(m); - void *front = NULL; + void *front = nullptr; if (mono_signature_get_param_count(sig) == 1 && mono_class_from_mono_type(mono_signature_get_params(sig, &front)) == CACHED_CLASS(IntPtr)->get_mono_ptr()) { break; @@ -296,12 +301,12 @@ MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) { } } - CRASH_COND(m == NULL); + CRASH_COND(m == nullptr); Array *new_array = memnew(Array(p_from)); void *args[1] = { &new_array }; - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_invoke(m, mono_object, args, &exc); UNHANDLED_EXCEPTION(exc); @@ -310,15 +315,15 @@ MonoObject *create_managed_from(const Array &p_from, GDMonoClass *p_class) { MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) { MonoObject *mono_object = mono_object_new(mono_domain_get(), p_class->get_mono_ptr()); - ERR_FAIL_NULL_V(mono_object, NULL); + ERR_FAIL_NULL_V(mono_object, nullptr); // Search constructor that takes a pointer as parameter MonoMethod *m; - void *iter = NULL; + void *iter = nullptr; while ((m = mono_class_get_methods(p_class->get_mono_ptr(), &iter))) { if (strcmp(mono_method_get_name(m), ".ctor") == 0) { MonoMethodSignature *sig = mono_method_signature(m); - void *front = NULL; + void *front = nullptr; if (mono_signature_get_param_count(sig) == 1 && mono_class_from_mono_type(mono_signature_get_params(sig, &front)) == CACHED_CLASS(IntPtr)->get_mono_ptr()) { break; @@ -326,12 +331,12 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) } } - CRASH_COND(m == NULL); + CRASH_COND(m == nullptr); Dictionary *new_dict = memnew(Dictionary(p_from)); void *args[1] = { &new_dict }; - MonoException *exc = NULL; + MonoException *exc = nullptr; GDMonoUtils::runtime_invoke(m, mono_object, args, &exc); UNHANDLED_EXCEPTION(exc); @@ -341,7 +346,7 @@ MonoObject *create_managed_from(const Dictionary &p_from, GDMonoClass *p_class) MonoDomain *create_domain(const String &p_friendly_name) { print_verbose("Mono: Creating domain '" + p_friendly_name + "'..."); - MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), NULL); + MonoDomain *domain = mono_domain_create_appdomain((char *)p_friendly_name.utf8().get_data(), nullptr); if (domain) { // Workaround to avoid this exception: @@ -366,7 +371,7 @@ String get_exception_name_and_message(MonoException *p_exc) { res += ": "; MonoProperty *prop = mono_class_get_property_from_name(klass, "Message"); - MonoString *msg = (MonoString *)property_get_value(prop, (MonoObject *)p_exc, NULL, NULL); + MonoString *msg = (MonoString *)property_get_value(prop, (MonoObject *)p_exc, nullptr, nullptr); res += GDMonoMarshal::mono_string_to_godot(msg); return res; @@ -377,7 +382,7 @@ void set_exception_message(MonoException *p_exc, String message) { MonoProperty *prop = mono_class_get_property_from_name(klass, "Message"); MonoString *msg = GDMonoMarshal::mono_string_from_godot(message); void *params[1] = { msg }; - property_set_value(prop, (MonoObject *)p_exc, params, NULL); + property_set_value(prop, (MonoObject *)p_exc, params, nullptr); } void debug_print_unhandled_exception(MonoException *p_exc) { @@ -410,14 +415,14 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { Vector<ScriptLanguage::StackInfo> si; String exc_msg; - while (p_exc != NULL) { + while (p_exc != nullptr) { GDMonoClass *st_klass = CACHED_CLASS(System_Diagnostics_StackTrace); MonoObject *stack_trace = mono_object_new(mono_domain_get(), st_klass->get_mono_ptr()); MonoBoolean need_file_info = true; void *ctor_args[2] = { p_exc, &need_file_info }; - MonoException *unexpected_exc = NULL; + MonoException *unexpected_exc = nullptr; CACHED_METHOD(System_Diagnostics_StackTrace, ctor_Exception_bool)->invoke_raw(stack_trace, ctor_args, &unexpected_exc); if (unexpected_exc) { @@ -426,7 +431,7 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { } Vector<ScriptLanguage::StackInfo> _si; - if (stack_trace != NULL) { + if (stack_trace != nullptr) { _si = CSharpLanguage::get_singleton()->stack_trace_get_info(stack_trace); for (int i = _si.size() - 1; i >= 0; i--) si.insert(0, _si[i]); @@ -436,10 +441,10 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { GDMonoClass *exc_class = GDMono::get_singleton()->get_class(mono_get_exception_class()); GDMonoProperty *inner_exc_prop = exc_class->get_property("InnerException"); - CRASH_COND(inner_exc_prop == NULL); + CRASH_COND(inner_exc_prop == nullptr); MonoObject *inner_exc = inner_exc_prop->get_value((MonoObject *)p_exc); - if (inner_exc != NULL) + if (inner_exc != nullptr) si.insert(0, separator); p_exc = (MonoException *)inner_exc; @@ -565,7 +570,7 @@ namespace Marshal { bool type_is_generic_array(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericArray).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -573,27 +578,27 @@ bool type_is_generic_array(MonoReflectionType *p_reftype) { bool type_is_generic_dictionary(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, TypeIsGenericDictionary).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; } void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype) { - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, ArrayGetElementType).invoke(p_array_reftype, r_elem_reftype, &exc); UNHANDLED_EXCEPTION(exc); } void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) { - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, DictionaryGetKeyValueTypes).invoke(p_dict_reftype, r_key_reftype, r_value_reftype, &exc); UNHANDLED_EXCEPTION(exc); } bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIEnumerableIsAssignableFromType).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -601,7 +606,7 @@ bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype) { bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryIsAssignableFromType).invoke(p_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -609,7 +614,7 @@ bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype) { bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_elem_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIEnumerableIsAssignableFromType_with_info).invoke(p_reftype, r_elem_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -617,7 +622,7 @@ bool generic_ienumerable_is_assignable_from(MonoReflectionType *p_reftype, MonoR bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype) { NO_GLUE_RET(false); - MonoException *exc = NULL; + MonoException *exc = nullptr; MonoBoolean res = CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryIsAssignableFromType_with_info).invoke(p_reftype, r_key_reftype, r_value_reftype, &exc); UNHANDLED_EXCEPTION(exc); return (bool)res; @@ -626,7 +631,7 @@ bool generic_idictionary_is_assignable_from(MonoReflectionType *p_reftype, MonoR Array enumerable_to_array(MonoObject *p_enumerable) { NO_GLUE_RET(Array()); Array result; - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, EnumerableToArray).invoke(p_enumerable, &result, &exc); UNHANDLED_EXCEPTION(exc); return result; @@ -635,7 +640,7 @@ Array enumerable_to_array(MonoObject *p_enumerable) { Dictionary idictionary_to_dictionary(MonoObject *p_idictionary) { NO_GLUE_RET(Dictionary()); Dictionary result; - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, IDictionaryToDictionary).invoke(p_idictionary, &result, &exc); UNHANDLED_EXCEPTION(exc); return result; @@ -644,23 +649,23 @@ Dictionary idictionary_to_dictionary(MonoObject *p_idictionary) { Dictionary generic_idictionary_to_dictionary(MonoObject *p_generic_idictionary) { NO_GLUE_RET(Dictionary()); Dictionary result; - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, GenericIDictionaryToDictionary).invoke(p_generic_idictionary, &result, &exc); UNHANDLED_EXCEPTION(exc); return result; } GDMonoClass *make_generic_array_type(MonoReflectionType *p_elem_reftype) { - NO_GLUE_RET(NULL); - MonoException *exc = NULL; + NO_GLUE_RET(nullptr); + MonoException *exc = nullptr; MonoReflectionType *reftype = CACHED_METHOD_THUNK(MarshalUtils, MakeGenericArrayType).invoke(p_elem_reftype, &exc); UNHANDLED_EXCEPTION(exc); return GDMono::get_singleton()->get_class(mono_class_from_mono_type(mono_reflection_type_get_type(reftype))); } GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, MonoReflectionType *p_value_reftype) { - NO_GLUE_RET(NULL); - MonoException *exc = NULL; + NO_GLUE_RET(nullptr); + MonoException *exc = nullptr; MonoReflectionType *reftype = CACHED_METHOD_THUNK(MarshalUtils, MakeGenericDictionaryType).invoke(p_key_reftype, p_value_reftype, &exc); UNHANDLED_EXCEPTION(exc); return GDMono::get_singleton()->get_class(mono_class_from_mono_type(mono_reflection_type_get_type(reftype))); @@ -669,7 +674,7 @@ GDMonoClass *make_generic_dictionary_type(MonoReflectionType *p_key_reftype, Mon } // namespace Marshal ScopeThreadAttach::ScopeThreadAttach() : - mono_thread(NULL) { + mono_thread(nullptr) { if (likely(GDMono::get_singleton()->is_runtime_initialized()) && unlikely(!mono_domain_get())) { mono_thread = GDMonoUtils::attach_current_thread(); } @@ -682,7 +687,7 @@ ScopeThreadAttach::~ScopeThreadAttach() { } StringName get_native_godot_class_name(GDMonoClass *p_class) { - MonoObject *native_name_obj = p_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL); + MonoObject *native_name_obj = p_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(nullptr); StringName *ptr = GDMonoMarshal::unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(native_name_obj)); return ptr ? *ptr : StringName(); } diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index fd02907d87..b850e1be9b 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -41,7 +41,7 @@ #include "core/reference.h" #define UNHANDLED_EXCEPTION(m_exc) \ - if (unlikely(m_exc != NULL)) { \ + if (unlikely(m_exc != nullptr)) { \ GDMonoUtils::debug_unhandled_exception(m_exc); \ GD_UNREACHABLE(); \ } @@ -77,7 +77,7 @@ _FORCE_INLINE_ void hash_combine(uint32_t &p_hash, const uint32_t &p_with_hash) /** * If the object has a csharp script, returns the target of the gchandle stored in the script instance * Otherwise returns a newly constructed MonoObject* which is attached to the object - * Returns NULL on error + * Returns nullptr on error */ MonoObject *unmanaged_get_managed(Object *unmanaged); @@ -89,7 +89,7 @@ MonoThread *get_current_thread(); bool is_thread_attached(); _FORCE_INLINE_ bool is_main_thread() { - return mono_domain_get() != NULL && mono_thread_get_main() == mono_thread_current(); + return mono_domain_get() != nullptr && mono_thread_get_main() == mono_thread_current(); } uint32_t new_strong_gchandle(MonoObject *p_object); @@ -97,7 +97,7 @@ uint32_t new_strong_gchandle_pinned(MonoObject *p_object); uint32_t new_weak_gchandle(MonoObject *p_object); void free_gchandle(uint32_t p_gchandle); -void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc = NULL); +void runtime_object_init(MonoObject *p_this_obj, GDMonoClass *p_class, MonoException **r_exc = nullptr); bool mono_delegate_equal(MonoDelegate *p_a, MonoDelegate *p_b); diff --git a/modules/mono/mono_gd/managed_type.h b/modules/mono/mono_gd/managed_type.h index 11b832d0cc..84d1837853 100644 --- a/modules/mono/mono_gd/managed_type.h +++ b/modules/mono/mono_gd/managed_type.h @@ -46,7 +46,7 @@ struct ManagedType { ManagedType() : type_encoding(0), - type_class(NULL) { + type_class(nullptr) { } ManagedType(int p_type_encoding, GDMonoClass *p_type_class) : diff --git a/modules/mono/mono_gd/gd_mono_android.cpp b/modules/mono/mono_gd/support/android_support.cpp index 761368878f..8bcdeec9dd 100644..100755 --- a/modules/mono/mono_gd/gd_mono_android.cpp +++ b/modules/mono/mono_gd/support/android_support.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_mono_android.cpp */ +/* android_support.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_mono_android.h" +#include "android_support.h" #if defined(ANDROID_ENABLED) @@ -49,14 +49,16 @@ #include "platform/android/os_android.h" #include "platform/android/thread_jandroid.h" -#include "../utils/path_utils.h" -#include "../utils/string_utils.h" -#include "gd_mono_cache.h" -#include "gd_mono_marshal.h" +#include "../../utils/path_utils.h" +#include "../../utils/string_utils.h" +#include "../gd_mono_cache.h" +#include "../gd_mono_marshal.h" // Warning: JNI boilerplate ahead... continue at your own risk -namespace GDMonoAndroid { +namespace gdmono { +namespace android { +namespace support { template <typename T> struct ScopedLocalRef { @@ -67,7 +69,7 @@ struct ScopedLocalRef { _FORCE_INLINE_ operator T() const { return local_ref; } _FORCE_INLINE_ operator jvalue() const { return (jvalue)local_ref; } - _FORCE_INLINE_ operator bool() const { return local_ref != NULL; } + _FORCE_INLINE_ operator bool() const { return local_ref != nullptr; } _FORCE_INLINE_ bool operator==(std::nullptr_t) const { return local_ref == nullptr; @@ -122,7 +124,7 @@ String determine_app_native_lib_dir() { String result; - const char *const nativeLibraryDirUtf8 = env->GetStringUTFChars(nativeLibraryDir, NULL); + const char *const nativeLibraryDirUtf8 = env->GetStringUTFChars(nativeLibraryDir, nullptr); if (nativeLibraryDirUtf8) { result.parse_utf8(nativeLibraryDirUtf8); env->ReleaseStringUTFChars(nativeLibraryDir, nativeLibraryDirUtf8); @@ -150,21 +152,21 @@ int gd_mono_convert_dl_flags(int flags) { return lflags; } -#ifndef GD_MONO_ANDROID_SO_NAME -#define GD_MONO_ANDROID_SO_NAME "libmonosgen-2.0.so" +#ifndef GD_MONO_SO_NAME +#define GD_MONO_SO_NAME "libmonosgen-2.0.so" #endif -const char *mono_so_name = GD_MONO_ANDROID_SO_NAME; +const char *mono_so_name = GD_MONO_SO_NAME; const char *godot_so_name = "libgodot_android.so"; -void *mono_dl_handle = NULL; -void *godot_dl_handle = NULL; +void *mono_dl_handle = nullptr; +void *godot_dl_handle = nullptr; void *try_dlopen(const String &p_so_path, int p_flags) { if (!FileAccess::exists(p_so_path)) { if (OS::get_singleton()->is_stdout_verbose()) OS::get_singleton()->print("Cannot find shared library: '%s'\n", p_so_path.utf8().get_data()); - return NULL; + return nullptr; } int lflags = gd_mono_convert_dl_flags(p_flags); @@ -174,7 +176,7 @@ void *try_dlopen(const String &p_so_path, int p_flags) { if (!handle) { if (OS::get_singleton()->is_stdout_verbose()) OS::get_singleton()->print("Failed to open shared library: '%s'. Error: '%s'\n", p_so_path.utf8().get_data(), dlerror()); - return NULL; + return nullptr; } if (OS::get_singleton()->is_stdout_verbose()) @@ -184,7 +186,7 @@ void *try_dlopen(const String &p_so_path, int p_flags) { } void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void *p_user_data) { - if (p_name == NULL) { + if (p_name == nullptr) { // __Internal if (!mono_dl_handle) { @@ -209,7 +211,7 @@ void *gd_mono_android_dlopen(const char *p_name, int p_flags, char **r_err, void return try_dlopen(so_path, p_flags); } - return NULL; + return nullptr; } void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, void *p_user_data) { @@ -230,7 +232,7 @@ void *gd_mono_android_dlsym(void *p_handle, const char *p_name, char **r_err, vo if (r_err) *r_err = str_format_new("%s\n", dlerror()); - return NULL; + return nullptr; } void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) { @@ -238,9 +240,9 @@ void *gd_mono_android_dlclose(void *p_handle, void *p_user_data) { // Not sure if this ever happens. Does Mono close the handle for the main module? if (p_handle == mono_dl_handle) - mono_dl_handle = NULL; + mono_dl_handle = nullptr; - return NULL; + return nullptr; } int32_t build_version_sdk_int = 0; @@ -265,7 +267,7 @@ int32_t get_build_version_sdk_int() { return build_version_sdk_int; } -jobject certStore = NULL; // KeyStore +jobject certStore = nullptr; // KeyStore MonoBoolean _gd_mono_init_cert_store() { // The JNI code is the equivalent of: @@ -293,7 +295,7 @@ MonoBoolean _gd_mono_init_cert_store() { if (jni_exception_check(env)) return 0; - env->CallVoidMethod(certStoreLocal, load, NULL); + env->CallVoidMethod(certStoreLocal, load, nullptr); if (jni_exception_check(env)) return 0; @@ -317,7 +319,7 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { if (!mono_error_ok(&mono_error)) { ERR_PRINT(String() + "Failed to convert MonoString* to UTF-8: '" + mono_error_get_message(&mono_error) + "'."); mono_error_cleanup(&mono_error); - return NULL; + return nullptr; } JNIEnv *env = ThreadAndroid::get_env(); @@ -326,20 +328,20 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { mono_free(alias_utf8); ScopedLocalRef<jclass> keyStoreClass(env, env->FindClass("java/security/KeyStore")); - ERR_FAIL_NULL_V(keyStoreClass, NULL); + ERR_FAIL_NULL_V(keyStoreClass, nullptr); ScopedLocalRef<jclass> certificateClass(env, env->FindClass("java/security/cert/Certificate")); - ERR_FAIL_NULL_V(certificateClass, NULL); + ERR_FAIL_NULL_V(certificateClass, nullptr); jmethodID getCertificate = env->GetMethodID(keyStoreClass, "getCertificate", "(Ljava/lang/String;)Ljava/security/cert/Certificate;"); - ERR_FAIL_NULL_V(getCertificate, NULL); + ERR_FAIL_NULL_V(getCertificate, nullptr); jmethodID getEncoded = env->GetMethodID(certificateClass, "getEncoded", "()[B"); - ERR_FAIL_NULL_V(getEncoded, NULL); + ERR_FAIL_NULL_V(getEncoded, nullptr); ScopedLocalRef<jobject> certificate(env, env->CallObjectMethod(certStore, getCertificate, js_alias.get())); if (!certificate) - return NULL; + return nullptr; ScopedLocalRef<jbyteArray> encoded(env, (jbyteArray)env->CallObjectMethod(certificate, getEncoded)); jsize encodedLength = env->GetArrayLength(encoded); @@ -352,11 +354,16 @@ MonoArray *_gd_mono_android_cert_store_lookup(MonoString *p_alias) { return encoded_ret; } +void register_internal_calls() { + mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_init_cert_store", (void *)_gd_mono_init_cert_store); + mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_android_cert_store_lookup", (void *)_gd_mono_android_cert_store_lookup); +} + void initialize() { // We need to set this environment variable to make the monodroid BCL use btls instead of legacy as the default provider OS::get_singleton()->set_environment("XA_TLS_PROVIDER", "btls"); - mono_dl_fallback_register(gd_mono_android_dlopen, gd_mono_android_dlsym, gd_mono_android_dlclose, NULL); + mono_dl_fallback_register(gd_mono_android_dlopen, gd_mono_android_dlsym, gd_mono_android_dlclose, nullptr); String app_native_lib_dir = get_app_native_lib_dir(); String so_path = path::join(app_native_lib_dir, godot_so_name); @@ -364,31 +371,28 @@ void initialize() { godot_dl_handle = try_dlopen(so_path, gd_mono_convert_dl_flags(MONO_DL_LAZY)); } -void register_internal_calls() { - mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_init_cert_store", (void *)_gd_mono_init_cert_store); - mono_add_internal_call("Android.Runtime.AndroidEnvironment::_gd_mono_android_cert_store_lookup", (void *)_gd_mono_android_cert_store_lookup); -} - void cleanup() { // This is called after shutting down the Mono runtime if (mono_dl_handle) - gd_mono_android_dlclose(mono_dl_handle, NULL); + gd_mono_android_dlclose(mono_dl_handle, nullptr); if (godot_dl_handle) - gd_mono_android_dlclose(godot_dl_handle, NULL); + gd_mono_android_dlclose(godot_dl_handle, nullptr); JNIEnv *env = ThreadAndroid::get_env(); if (certStore) { env->DeleteGlobalRef(certStore); - certStore = NULL; + certStore = nullptr; } } -} // namespace GDMonoAndroid +} // namespace support +} // namespace android +} // namespace gdmono -using namespace GDMonoAndroid; +using namespace gdmono::android::support; // The following are P/Invoke functions required by the monodroid profile of the BCL. // These are P/Invoke functions and not internal calls, hence why they use @@ -417,7 +421,7 @@ GD_PINVOKE_EXPORT int32_t monodroid_get_system_property(const char *p_name, char memcpy(*r_value, prop_value_str, len); (*r_value)[len] = '\0'; } else { - *r_value = NULL; + *r_value = nullptr; } } @@ -604,7 +608,7 @@ GD_PINVOKE_EXPORT int32_t _monodroid_get_dns_servers(void **r_dns_servers_array) if (!r_dns_servers_array) return -1; - *r_dns_servers_array = NULL; + *r_dns_servers_array = nullptr; char *dns_servers[dns_servers_len]; int dns_servers_count = 0; @@ -648,23 +652,23 @@ GD_PINVOKE_EXPORT const char *_monodroid_timezone_get_default_id() { JNIEnv *env = ThreadAndroid::get_env(); ScopedLocalRef<jclass> timeZoneClass(env, env->FindClass("java/util/TimeZone")); - ERR_FAIL_NULL_V(timeZoneClass, NULL); + ERR_FAIL_NULL_V(timeZoneClass, nullptr); jmethodID getDefault = env->GetStaticMethodID(timeZoneClass, "getDefault", "()Ljava/util/TimeZone;"); - ERR_FAIL_NULL_V(getDefault, NULL); + ERR_FAIL_NULL_V(getDefault, nullptr); jmethodID getID = env->GetMethodID(timeZoneClass, "getID", "()Ljava/lang/String;"); - ERR_FAIL_NULL_V(getID, NULL); + ERR_FAIL_NULL_V(getID, nullptr); ScopedLocalRef<jobject> defaultTimeZone(env, env->CallStaticObjectMethod(timeZoneClass, getDefault)); if (!defaultTimeZone) - return NULL; + return nullptr; ScopedLocalRef<jstring> defaultTimeZoneID(env, (jstring)env->CallObjectMethod(defaultTimeZone, getID)); if (!defaultTimeZoneID) - return NULL; + return nullptr; const char *default_time_zone_id = env->GetStringUTFChars(defaultTimeZoneID, 0); diff --git a/modules/mono/mono_gd/gd_mono_android.h b/modules/mono/mono_gd/support/android_support.h index 0e04847924..dc2e6c95ed 100644..100755 --- a/modules/mono/mono_gd/gd_mono_android.h +++ b/modules/mono/mono_gd/support/android_support.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_mono_android.h */ +/* android_support.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,25 +28,28 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_MONO_ANDROID_H -#define GD_MONO_ANDROID_H +#ifndef ANDROID_SUPPORT_H +#define ANDROID_SUPPORT_H #if defined(ANDROID_ENABLED) #include "core/ustring.h" -namespace GDMonoAndroid { +namespace gdmono { +namespace android { +namespace support { String get_app_native_lib_dir(); void initialize(); +void cleanup(); void register_internal_calls(); -void cleanup(); - -} // namespace GDMonoAndroid +} // namespace support +} // namespace android +} // namespace gdmono #endif // ANDROID_ENABLED -#endif // GD_MONO_ANDROID_H +#endif // ANDROID_SUPPORT_H diff --git a/modules/mono/mono_gd/support/ios_support.h b/modules/mono/mono_gd/support/ios_support.h new file mode 100755 index 0000000000..e28af120e3 --- /dev/null +++ b/modules/mono/mono_gd/support/ios_support.h @@ -0,0 +1,51 @@ +/*************************************************************************/ +/* ios_support.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef IOS_SUPPORT_H +#define IOS_SUPPORT_H + +#if defined(IPHONE_ENABLED) + +#include "core/ustring.h" + +namespace gdmono { +namespace ios { +namespace support { + +void initialize(); +void cleanup(); + +} // namespace support +} // namespace ios +} // namespace gdmono + +#endif // IPHONE_ENABLED + +#endif // IOS_SUPPORT_H diff --git a/modules/mono/mono_gd/support/ios_support.mm b/modules/mono/mono_gd/support/ios_support.mm new file mode 100755 index 0000000000..e3d1a647fd --- /dev/null +++ b/modules/mono/mono_gd/support/ios_support.mm @@ -0,0 +1,151 @@ +/*************************************************************************/ +/* ios_support.mm */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "ios_support.h" + +#if defined(IPHONE_ENABLED) + +#import <Foundation/Foundation.h> +#include <os/log.h> + +#include "core/ustring.h" + +#include "../gd_mono_marshal.h" + +// Implemented mostly following: https://github.com/mono/mono/blob/master/sdks/ios/app/runtime.m + +// Definition generated by the Godot exporter +extern "C" void gd_mono_setup_aot(); + +namespace gdmono { +namespace ios { +namespace support { + +void ios_mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) { + os_log_info(OS_LOG_DEFAULT, "(%s %s) %s", log_domain, log_level, message); + if (fatal) { + os_log_info(OS_LOG_DEFAULT, "Exit code: %d.", 1); + exit(1); + } +} + +void initialize() { + mono_dllmap_insert(NULL, "System.Native", NULL, "__Internal", NULL); + mono_dllmap_insert(NULL, "System.IO.Compression.Native", NULL, "__Internal", NULL); + mono_dllmap_insert(NULL, "System.Security.Cryptography.Native.Apple", NULL, "__Internal", NULL); + +#ifdef IOS_DEVICE + // This function is defined in an auto-generated source file + gd_mono_setup_aot(); +#endif + + mono_set_signal_chaining(true); + mono_set_crash_chaining(true); +} + +void cleanup() { +} + +} // namespace support +} // namespace ios +} // namespace gdmono + +// The following are P/Invoke functions required by the monotouch profile of the BCL. +// These are P/Invoke functions and not internal calls, hence why they use +// 'mono_bool' and 'const char*' instead of 'MonoBoolean' and 'MonoString*'. + +#define GD_PINVOKE_EXPORT extern "C" __attribute__((visibility("default"))) + +GD_PINVOKE_EXPORT const char *xamarin_get_locale_country_code() { + NSLocale *locale = [NSLocale currentLocale]; + NSString *countryCode = [locale objectForKey:NSLocaleCountryCode]; + if (countryCode == NULL) { + return strdup("US"); + } + return strdup([countryCode UTF8String]); +} + +GD_PINVOKE_EXPORT void xamarin_log(const uint16_t *p_unicode_message) { + int length = 0; + const uint16_t *ptr = p_unicode_message; + while (*ptr++) + length += sizeof(uint16_t); + NSString *msg = [[NSString alloc] initWithBytes:p_unicode_message length:length encoding:NSUTF16LittleEndianStringEncoding]; + + os_log_info(OS_LOG_DEFAULT, "%{public}@", msg); +} + +GD_PINVOKE_EXPORT const char *xamarin_GetFolderPath(int p_folder) { + NSSearchPathDirectory dd = (NSSearchPathDirectory)p_folder; + NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:dd inDomains:NSUserDomainMask] lastObject]; + NSString *path = [url path]; + return strdup([path UTF8String]); +} + +GD_PINVOKE_EXPORT char *xamarin_timezone_get_local_name() { + NSTimeZone *tz = nil; + tz = [NSTimeZone localTimeZone]; + NSString *name = [tz name]; + return (name != nil) ? strdup([name UTF8String]) : strdup("Local"); +} + +GD_PINVOKE_EXPORT char **xamarin_timezone_get_names(uint32_t *p_count) { + NSArray *array = [NSTimeZone knownTimeZoneNames]; + *p_count = array.count; + char **result = (char **)malloc(sizeof(char *) * (*p_count)); + for (uint32_t i = 0; i < *p_count; i++) { + NSString *s = [array objectAtIndex:i]; + result[i] = strdup(s.UTF8String); + } + return result; +} + +GD_PINVOKE_EXPORT void *xamarin_timezone_get_data(const char *p_name, uint32_t *p_size) { // FIXME: uint32_t since Dec 2019, unsigned long before + NSTimeZone *tz = nil; + if (p_name) { + NSString *n = [[NSString alloc] initWithUTF8String:p_name]; + tz = [[[NSTimeZone alloc] initWithName:n] autorelease]; + [n release]; + } else { + tz = [NSTimeZone localTimeZone]; + } + NSData *data = [tz data]; + *p_size = [data length]; + void *result = malloc(*p_size); + memcpy(result, data.bytes, *p_size); + return result; +} + +GD_PINVOKE_EXPORT void xamarin_start_wwan(const char *p_uri) { + // FIXME: What's this for? No idea how to implement. + os_log_error(OS_LOG_DEFAULT, "Not implemented: 'xamarin_start_wwan'"); +} + +#endif // IPHONE_ENABLED diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index 4823ba3679..94431e7c30 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -34,11 +34,11 @@ #include "csharp_script.h" -CSharpLanguage *script_language_cs = NULL; +CSharpLanguage *script_language_cs = nullptr; Ref<ResourceFormatLoaderCSharpScript> resource_loader_cs; Ref<ResourceFormatSaverCSharpScript> resource_saver_cs; -_GodotSharp *_godotsharp = NULL; +_GodotSharp *_godotsharp = nullptr; void register_mono_types() { ClassDB::register_class<CSharpScript>(); diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp index 25e5a41215..e77a2e98f2 100644 --- a/modules/mono/signal_awaiter_utils.cpp +++ b/modules/mono/signal_awaiter_utils.cpp @@ -121,7 +121,7 @@ void SignalAwaiterCallable::call(const Variant **p_arguments, int p_argcount, Va return; } - MonoException *exc = NULL; + MonoException *exc = nullptr; CACHED_METHOD_THUNK(SignalAwaiter, SignalCallback).invoke(awaiter, signal_args, &exc); if (exc) { @@ -210,7 +210,7 @@ void EventSignalCallable::call(const Variant **p_arguments, int p_argcount, Vari return; } - MonoException *exc = NULL; + MonoException *exc = nullptr; event_signal->invoke_method->invoke(delegate_field_value, p_arguments, &exc); if (exc) { diff --git a/modules/mono/utils/mono_reg_utils.cpp b/modules/mono/utils/mono_reg_utils.cpp index c1cd5f1db4..8f0ad8ba5e 100644 --- a/modules/mono/utils/mono_reg_utils.cpp +++ b/modules/mono/utils/mono_reg_utils.cpp @@ -73,13 +73,13 @@ LONG _RegKeyQueryString(HKEY hKey, const String &p_value_name, String &r_value) buffer.resize(512); DWORD dwBufferSize = buffer.size(); - LONG res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, NULL, (LPBYTE)buffer.ptr(), &dwBufferSize); + LONG res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize); if (res == ERROR_MORE_DATA) { // dwBufferSize now contains the actual size Vector<WCHAR> buffer; buffer.resize(dwBufferSize); - res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, NULL, (LPBYTE)buffer.ptr(), &dwBufferSize); + res = RegQueryValueExW(hKey, p_value_name.c_str(), 0, nullptr, (LPBYTE)buffer.ptr(), &dwBufferSize); } if (res == ERROR_SUCCESS) { @@ -180,7 +180,7 @@ String find_msbuild_tools_path() { String output; int exit_code; - OS::get_singleton()->execute(vswhere_path, vswhere_args, true, NULL, &output, &exit_code); + OS::get_singleton()->execute(vswhere_path, vswhere_args, true, nullptr, &output, &exit_code); if (exit_code == 0) { Vector<String> lines = output.split("\n"); diff --git a/modules/mono/utils/osx_utils.cpp b/modules/mono/utils/osx_utils.cpp index 432b306414..8fadf3c109 100644 --- a/modules/mono/utils/osx_utils.cpp +++ b/modules/mono/utils/osx_utils.cpp @@ -39,9 +39,9 @@ bool osx_is_app_bundle_installed(const String &p_bundle_id) { - CFURLRef app_url = NULL; - CFStringRef bundle_id = CFStringCreateWithCString(NULL, p_bundle_id.utf8(), kCFStringEncodingUTF8); - OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, NULL, NULL, &app_url); + CFURLRef app_url = nullptr; + CFStringRef bundle_id = CFStringCreateWithCString(nullptr, p_bundle_id.utf8(), kCFStringEncodingUTF8); + OSStatus result = LSFindApplicationForInfo(kLSUnknownCreator, bundle_id, nullptr, nullptr, &app_url); CFRelease(bundle_id); if (app_url) diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index 545da6c79e..973375a471 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -80,7 +80,7 @@ String find_executable(const String &p_name) { String cwd() { #ifdef WINDOWS_ENABLED - const DWORD expected_size = ::GetCurrentDirectoryW(0, NULL); + const DWORD expected_size = ::GetCurrentDirectoryW(0, nullptr); String buffer; buffer.resize((int)expected_size); @@ -90,7 +90,7 @@ String cwd() { return buffer.simplify_path(); #else char buffer[PATH_MAX]; - if (::getcwd(buffer, sizeof(buffer)) == NULL) + if (::getcwd(buffer, sizeof(buffer)) == nullptr) return "."; String result; @@ -114,12 +114,12 @@ String realpath(const String &p_path) { // Open file without read/write access HANDLE hFile = ::CreateFileW(p_path.c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (hFile == INVALID_HANDLE_VALUE) return p_path; - const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, NULL, 0, FILE_NAME_NORMALIZED); + const DWORD expected_size = ::GetFinalPathNameByHandleW(hFile, nullptr, 0, FILE_NAME_NORMALIZED); if (expected_size == 0) { ::CloseHandle(hFile); @@ -133,7 +133,7 @@ String realpath(const String &p_path) { ::CloseHandle(hFile); return buffer.simplify_path(); #elif UNIX_ENABLED - char *resolved_path = ::realpath(p_path.utf8().get_data(), NULL); + char *resolved_path = ::realpath(p_path.utf8().get_data(), nullptr); if (!resolved_path) return p_path; diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index 49c4fb3f73..907811355f 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -212,7 +212,7 @@ String str_format(const char *p_format, ...) { #define gd_vscprintf(m_format, m_args_copy) _vscprintf(m_format, m_args_copy) #else #define gd_vsnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf(m_buffer, m_count, m_format, m_args_copy) -#define gd_vscprintf(m_format, m_args_copy) vsnprintf(NULL, 0, p_format, m_args_copy) +#define gd_vscprintf(m_format, m_args_copy) vsnprintf(nullptr, 0, p_format, m_args_copy) #endif String str_format(const char *p_format, va_list p_list) { diff --git a/modules/ogg/SCsub b/modules/ogg/SCsub index 44c7963cd3..e768fb4ae8 100644 --- a/modules/ogg/SCsub +++ b/modules/ogg/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") # Only kept to build the thirdparty library used by the theora and webm # modules. @@ -9,7 +9,7 @@ Import('env_modules') env_ogg = env_modules.Clone() # Thirdparty source files -if env['builtin_libogg']: +if env["builtin_libogg"]: thirdparty_dir = "#thirdparty/libogg/" thirdparty_sources = [ "bitwise.c", diff --git a/modules/ogg/config.py b/modules/ogg/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/ogg/config.py +++ b/modules/ogg/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/opensimplex/SCsub b/modules/opensimplex/SCsub index 311d33b047..52d8b145ef 100644 --- a/modules/opensimplex/SCsub +++ b/modules/opensimplex/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_opensimplex = env_modules.Clone() diff --git a/modules/opensimplex/config.py b/modules/opensimplex/config.py index c1010ad433..90b85dbd70 100644 --- a/modules/opensimplex/config.py +++ b/modules/opensimplex/config.py @@ -1,14 +1,17 @@ def can_build(env, platform): - return True + return True + def configure(env): - pass + pass + def get_doc_classes(): return [ "NoiseTexture", - "OpenSimplexNoise" + "OpenSimplexNoise", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 8e5b04f995..ec67030a65 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -34,7 +34,7 @@ NoiseTexture::NoiseTexture() { update_queued = false; - noise_thread = NULL; + noise_thread = nullptr; regen_queued = false; first_time = true; @@ -50,7 +50,7 @@ NoiseTexture::NoiseTexture() { NoiseTexture::~NoiseTexture() { if (texture.is_valid()) { - VS::get_singleton()->free(texture); + RS::get_singleton()->free(texture); } if (noise_thread) { Thread::wait_to_finish(noise_thread); @@ -100,10 +100,10 @@ void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) { data = p_image; if (data.is_valid()) { if (texture.is_valid()) { - RID new_texture = VS::get_singleton()->texture_2d_create(p_image); - VS::get_singleton()->texture_replace(texture, new_texture); + RID new_texture = RS::get_singleton()->texture_2d_create(p_image); + RS::get_singleton()->texture_replace(texture, new_texture); } else { - texture = VS::get_singleton()->texture_2d_create(p_image); + texture = RS::get_singleton()->texture_2d_create(p_image); } } emit_changed(); @@ -114,7 +114,7 @@ void NoiseTexture::_thread_done(const Ref<Image> &p_image) { _set_texture_data(p_image); Thread::wait_to_finish(noise_thread); memdelete(noise_thread); - noise_thread = NULL; + noise_thread = nullptr; if (regen_queued) { noise_thread = Thread::create(_thread_function, this); regen_queued = false; @@ -254,7 +254,7 @@ int NoiseTexture::get_height() const { RID NoiseTexture::get_rid() const { if (!texture.is_valid()) { - texture = VS::get_singleton()->texture_2d_placeholder_create(); + texture = RS::get_singleton()->texture_2d_placeholder_create(); } return texture; diff --git a/modules/opus/SCsub b/modules/opus/SCsub index fec2911d6d..e51590d808 100644 --- a/modules/opus/SCsub +++ b/modules/opus/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") # Only kept to build the thirdparty library used by the webm module. # AudioStreamOpus was dropped in 3.0 due to incompatibility with the new audio @@ -10,11 +10,10 @@ Import('env_modules') env_opus = env_modules.Clone() # Thirdparty source files -if env['builtin_opus']: +if env["builtin_opus"]: thirdparty_dir = "#thirdparty/opus/" thirdparty_sources = [ - # Sync with opus_sources.mk "opus.c", "opus_decoder.c", @@ -23,17 +22,14 @@ if env['builtin_opus']: "opus_multistream_encoder.c", "opus_multistream_decoder.c", "repacketizer.c", - "analysis.c", "mlp.c", "mlp_data.c", - # Sync with libopusfile Makefile.am "info.c", "internal.c", "opusfile.c", "stream.c", - # Sync with celt_sources.mk "celt/bands.c", "celt/celt.c", @@ -53,12 +49,11 @@ if env['builtin_opus']: "celt/quant_bands.c", "celt/rate.c", "celt/vq.c", - #"celt/arm/arm_celt_map.c", - #"celt/arm/armcpu.c", - #"celt/arm/celt_ne10_fft.c", - #"celt/arm/celt_ne10_mdct.c", - #"celt/arm/celt_neon_intr.c", - + # "celt/arm/arm_celt_map.c", + # "celt/arm/armcpu.c", + # "celt/arm/celt_ne10_fft.c", + # "celt/arm/celt_ne10_mdct.c", + # "celt/arm/celt_neon_intr.c", # Sync with silk_sources.mk "silk/CNG.c", "silk/code_signs.c", @@ -207,7 +202,7 @@ if env['builtin_opus']: thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources + opus_sources_silk] # also requires libogg - if env['builtin_libogg']: + if env["builtin_libogg"]: env_opus.Prepend(CPPPATH=["#thirdparty/libogg"]) env_opus.Append(CPPDEFINES=["HAVE_CONFIG_H"]) @@ -223,14 +218,14 @@ if env['builtin_opus']: env_opus.Prepend(CPPPATH=[thirdparty_dir + "/" + dir for dir in thirdparty_include_paths]) if env["platform"] == "android": - if ("android_arch" in env and env["android_arch"] == "armv7"): + if "android_arch" in env and env["android_arch"] == "armv7": env_opus.Append(CPPDEFINES=["OPUS_ARM_OPT"]) - elif ("android_arch" in env and env["android_arch"] == "arm64v8"): + elif "android_arch" in env and env["android_arch"] == "arm64v8": env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"]) elif env["platform"] == "iphone": - if ("arch" in env and env["arch"] == "arm"): + if "arch" in env and env["arch"] == "arm": env_opus.Append(CPPDEFINES=["OPUS_ARM_OPT"]) - elif ("arch" in env and env["arch"] == "arm64"): + elif "arch" in env and env["arch"] == "arm64": env_opus.Append(CPPDEFINES=["OPUS_ARM64_OPT"]) env_thirdparty = env_opus.Clone() diff --git a/modules/opus/config.py b/modules/opus/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/opus/config.py +++ b/modules/opus/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/pvr/SCsub b/modules/pvr/SCsub index 18da38fbbd..e0baf851f1 100644 --- a/modules/pvr/SCsub +++ b/modules/pvr/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_pvr = env_modules.Clone() diff --git a/modules/pvr/config.py b/modules/pvr/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/pvr/config.py +++ b/modules/pvr/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 179c6f692b..10d4d71f5e 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -534,7 +534,7 @@ static void decompress_pvrtc(PVRTCBlock *p_comp_img, const int p_2bit, const int // local neighbourhood of blocks PVRTCBlock *p_blocks[2][2]; - PVRTCBlock *prev[2][2] = { { NULL, NULL }, { NULL, NULL } }; + PVRTCBlock *prev[2][2] = { { nullptr, nullptr }, { nullptr, nullptr } }; struct { diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h index c990c3612b..642323db35 100644 --- a/modules/pvr/texture_loader_pvr.h +++ b/modules/pvr/texture_loader_pvr.h @@ -36,7 +36,7 @@ class ResourceFormatPVR : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path, Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/regex/SCsub b/modules/regex/SCsub index 6238cd3d9f..753650adcb 100644 --- a/modules/regex/SCsub +++ b/modules/regex/SCsub @@ -1,16 +1,16 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_regex = env_modules.Clone() -if env['builtin_pcre2']: - thirdparty_dir = '#thirdparty/pcre2/src/' - thirdparty_flags = ['PCRE2_STATIC', 'HAVE_CONFIG_H'] +if env["builtin_pcre2"]: + thirdparty_dir = "#thirdparty/pcre2/src/" + thirdparty_flags = ["PCRE2_STATIC", "HAVE_CONFIG_H"] - if env['builtin_pcre2_with_jit']: - thirdparty_flags.append('SUPPORT_JIT') + if env["builtin_pcre2_with_jit"]: + thirdparty_flags.append("SUPPORT_JIT") thirdparty_sources = [ "pcre2_auto_possess.c", @@ -24,7 +24,7 @@ if env['builtin_pcre2']: "pcre2_extuni.c", "pcre2_find_bracket.c", "pcre2_jit_compile.c", - #"pcre2_jit_match.c", "pcre2_jit_misc.c", # these files are included in pcre2_jit_compile.c. + # "pcre2_jit_match.c", "pcre2_jit_misc.c", # these files are included in pcre2_jit_compile.c. "pcre2_maketables.c", "pcre2_match.c", "pcre2_match_data.c", diff --git a/modules/regex/config.py b/modules/regex/config.py index 42cfe3b43c..df9f44cb95 100644 --- a/modules/regex/config.py +++ b/modules/regex/config.py @@ -1,14 +1,17 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "RegEx", "RegExMatch", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 53d1a1dd65..25cc580591 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -80,7 +80,7 @@ Dictionary RegExMatch::get_names() const { Dictionary result; - for (const Map<String, int>::Element *i = names.front(); i != NULL; i = i->next()) { + for (const Map<String, int>::Element *i = names.front(); i != nullptr; i = i->next()) { result[i->key()] = i->value(); } @@ -180,14 +180,14 @@ void RegEx::clear() { if (code) { pcre2_code_free_16((pcre2_code_16 *)code); - code = NULL; + code = nullptr; } } else { if (code) { pcre2_code_free_32((pcre2_code_32 *)code); - code = NULL; + code = nullptr; } } } @@ -242,7 +242,7 @@ Error RegEx::compile(const String &p_pattern) { Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) const { - ERR_FAIL_COND_V(!is_valid(), NULL); + ERR_FAIL_COND_V(!is_valid(), nullptr); Ref<RegExMatch> result = memnew(RegExMatch); @@ -263,7 +263,7 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) if (res < 0) { pcre2_match_data_free_16(match); - return NULL; + return nullptr; } uint32_t size = pcre2_get_ovector_count_16(match); @@ -295,7 +295,7 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) pcre2_match_data_free_32(match); pcre2_match_context_free_32(mctx); - return NULL; + return nullptr; } uint32_t size = pcre2_get_ovector_count_32(match); @@ -431,7 +431,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a bool RegEx::is_valid() const { - return (code != NULL); + return (code != nullptr); } String RegEx::get_pattern() const { @@ -479,26 +479,26 @@ RegEx::RegEx() { if (sizeof(CharType) == 2) { - general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, NULL); + general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, nullptr); } else { - general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, NULL); + general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr); } - code = NULL; + code = nullptr; } RegEx::RegEx(const String &p_pattern) { if (sizeof(CharType) == 2) { - general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, NULL); + general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, nullptr); } else { - general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, NULL); + general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, nullptr); } - code = NULL; + code = nullptr; compile(p_pattern); } diff --git a/modules/squish/SCsub b/modules/squish/SCsub index 15320bcd0c..b31032403f 100644 --- a/modules/squish/SCsub +++ b/modules/squish/SCsub @@ -1,12 +1,12 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_squish = env_modules.Clone() # Thirdparty source files -if env['builtin_squish']: +if env["builtin_squish"]: thirdparty_dir = "#thirdparty/squish/" thirdparty_sources = [ "alpha.cpp", diff --git a/modules/squish/config.py b/modules/squish/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/squish/config.py +++ b/modules/squish/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/stb_vorbis/SCsub b/modules/stb_vorbis/SCsub index d14939a3b1..266c87c802 100644 --- a/modules/stb_vorbis/SCsub +++ b/modules/stb_vorbis/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_stb_vorbis = env_modules.Clone() diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 42f341cef7..9609c234ec 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -122,7 +122,7 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) { AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() { if (ogg_alloc.alloc_buffer) { stb_vorbis_close(ogg_stream); - AudioServer::get_singleton()->audio_data_free(ogg_alloc.alloc_buffer); + memfree(ogg_alloc.alloc_buffer); } } @@ -130,11 +130,11 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() { Ref<AudioStreamPlaybackOGGVorbis> ovs; - ERR_FAIL_COND_V(data == NULL, ovs); + ERR_FAIL_COND_V(data == nullptr, ovs); ovs.instance(); ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this); - ovs->ogg_alloc.alloc_buffer = (char *)AudioServer::get_singleton()->audio_data_alloc(decode_mem_size); + ovs->ogg_alloc.alloc_buffer = (char *)memalloc(decode_mem_size); ovs->ogg_alloc.alloc_buffer_length_in_bytes = decode_mem_size; ovs->frames_mixed = 0; ovs->active = false; @@ -143,8 +143,8 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() { ovs->ogg_stream = stb_vorbis_open_memory((const unsigned char *)data, data_len, &error, &ovs->ogg_alloc); if (!ovs->ogg_stream) { - AudioServer::get_singleton()->audio_data_free(ovs->ogg_alloc.alloc_buffer); - ovs->ogg_alloc.alloc_buffer = NULL; + memfree(ovs->ogg_alloc.alloc_buffer); + ovs->ogg_alloc.alloc_buffer = nullptr; ERR_FAIL_COND_V(!ovs->ogg_stream, Ref<AudioStreamPlaybackOGGVorbis>()); } @@ -158,8 +158,8 @@ String AudioStreamOGGVorbis::get_stream_name() const { void AudioStreamOGGVorbis::clear_data() { if (data) { - AudioServer::get_singleton()->audio_data_free(data); - data = NULL; + memfree(data); + data = nullptr; data_len = 0; } } @@ -172,7 +172,7 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) { uint32_t alloc_try = 1024; Vector<char> alloc_mem; char *w; - stb_vorbis *ogg_stream = NULL; + stb_vorbis *ogg_stream = nullptr; stb_vorbis_alloc ogg_alloc; while (alloc_try < MAX_TEST_MEM) { @@ -194,7 +194,7 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) { } else { ERR_FAIL_COND(alloc_try == MAX_TEST_MEM); - ERR_FAIL_COND(ogg_stream == NULL); + ERR_FAIL_COND(ogg_stream == nullptr); stb_vorbis_info info = stb_vorbis_get_info(ogg_stream); @@ -210,7 +210,8 @@ void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) { // free any existing data clear_data(); - data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar); + data = memalloc(src_data_len); + copymem(data, src_datar, src_data_len); data_len = src_data_len; break; @@ -273,7 +274,7 @@ void AudioStreamOGGVorbis::_bind_methods() { AudioStreamOGGVorbis::AudioStreamOGGVorbis() { - data = NULL; + data = nullptr; data_len = 0; length = 0; sample_rate = 1; diff --git a/modules/stb_vorbis/config.py b/modules/stb_vorbis/config.py index 200b8dfd50..1eb0a8cf33 100644 --- a/modules/stb_vorbis/config.py +++ b/modules/stb_vorbis/config.py @@ -1,13 +1,16 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "AudioStreamOGGVorbis", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h index 43541bcf3c..8d6f71a456 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h @@ -50,7 +50,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterOGGVorbis(); }; diff --git a/modules/svg/SCsub b/modules/svg/SCsub index 7961d1f33e..0bfba34fe5 100644 --- a/modules/svg/SCsub +++ b/modules/svg/SCsub @@ -1,14 +1,14 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_svg = env_modules.Clone() # Thirdparty source files thirdparty_dir = "#thirdparty/nanosvg/" thirdparty_sources = [ - "nanosvg.cc" + "nanosvg.cc", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/svg/config.py b/modules/svg/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/svg/config.py +++ b/modules/svg/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index e9d30d015a..3c2784f8de 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -65,7 +65,7 @@ inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, co void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image) { - for (NSVGshape *shape = p_svg_image->shapes; shape != NULL; shape = shape->next) { + for (NSVGshape *shape = p_svg_image->shapes; shape != nullptr; shape = shape->next) { for (int i = 0; i < replace_colors.old_colors.size(); i++) { change_nsvg_paint_color(&(shape->stroke), replace_colors.old_colors[i], replace_colors.new_colors[i]); @@ -98,7 +98,7 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const Vector<uint8_t> *p NSVGimage *svg_image; const uint8_t *src_r = p_data->ptr(); svg_image = nsvgParse((char *)src_r, "px", 96); - if (svg_image == NULL) { + if (svg_image == nullptr) { ERR_PRINT("SVG Corrupted"); return ERR_FILE_CORRUPT; } diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h index def2885199..0fa4a0fdf4 100644 --- a/modules/svg/image_loader_svg.h +++ b/modules/svg/image_loader_svg.h @@ -63,7 +63,7 @@ class ImageLoaderSVG : public ImageFormatLoader { static Error _create_image(Ref<Image> p_image, const Vector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors = false); public: - static void set_convert_colors(Dictionary *p_replace_color = NULL); + static void set_convert_colors(Dictionary *p_replace_color = nullptr); static Error create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, bool convert_colors = false); virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale); diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp index b0782dae88..37875313aa 100644 --- a/modules/svg/register_types.cpp +++ b/modules/svg/register_types.cpp @@ -32,7 +32,7 @@ #include "image_loader_svg.h" -static ImageLoaderSVG *image_loader_svg = NULL; +static ImageLoaderSVG *image_loader_svg = nullptr; void register_svg_types() { diff --git a/modules/tga/SCsub b/modules/tga/SCsub index 7e405f405c..067caa6ea0 100644 --- a/modules/tga/SCsub +++ b/modules/tga/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_tga = env_modules.Clone() diff --git a/modules/tga/config.py b/modules/tga/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/tga/config.py +++ b/modules/tga/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp index 0e904fdd76..fc9d727bb0 100644 --- a/modules/tga/image_loader_tga.cpp +++ b/modules/tga/image_loader_tga.cpp @@ -283,7 +283,7 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force uint8_t *uncompressed_buffer_w = uncompressed_buffer.ptrw(); const uint8_t *uncompressed_buffer_r; - const uint8_t *buffer = NULL; + const uint8_t *buffer = nullptr; if (is_encoded) { diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp index 359f4d785e..0d9268ebbf 100644 --- a/modules/tga/register_types.cpp +++ b/modules/tga/register_types.cpp @@ -32,7 +32,7 @@ #include "image_loader_tga.h" -static ImageLoaderTGA *image_loader_tga = NULL; +static ImageLoaderTGA *image_loader_tga = nullptr; void register_tga_types() { diff --git a/modules/theora/SCsub b/modules/theora/SCsub index ff65d2f8ec..a01e65b4b0 100644 --- a/modules/theora/SCsub +++ b/modules/theora/SCsub @@ -1,71 +1,71 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_theora = env_modules.Clone() # Thirdparty source files -if env['builtin_libtheora']: +if env["builtin_libtheora"]: thirdparty_dir = "#thirdparty/libtheora/" thirdparty_sources = [ - #"analyze.c", - #"apiwrapper.c", + # "analyze.c", + # "apiwrapper.c", "bitpack.c", "cpu.c", - #"decapiwrapper.c", + # "decapiwrapper.c", "decinfo.c", "decode.c", "dequant.c", - #"encapiwrapper.c", - #"encfrag.c", - #"encinfo.c", - #"encode.c", - #"encoder_disabled.c", - #"enquant.c", - #"fdct.c", + # "encapiwrapper.c", + # "encfrag.c", + # "encinfo.c", + # "encode.c", + # "encoder_disabled.c", + # "enquant.c", + # "fdct.c", "fragment.c", "huffdec.c", - #"huffenc.c", + # "huffenc.c", "idct.c", "info.c", "internal.c", - #"mathops.c", - #"mcenc.c", + # "mathops.c", + # "mcenc.c", "quant.c", - #"rate.c", + # "rate.c", "state.c", - #"tokenize.c", + # "tokenize.c", ] thirdparty_sources_x86 = [ - #"x86/mmxencfrag.c", - #"x86/mmxfdct.c", + # "x86/mmxencfrag.c", + # "x86/mmxfdct.c", "x86/mmxfrag.c", "x86/mmxidct.c", "x86/mmxstate.c", - #"x86/sse2fdct.c", - #"x86/x86enc.c", + # "x86/sse2fdct.c", + # "x86/x86enc.c", "x86/x86state.c", ] thirdparty_sources_x86_vc = [ - #"x86_vc/mmxencfrag.c", - #"x86_vc/mmxfdct.c", + # "x86_vc/mmxencfrag.c", + # "x86_vc/mmxfdct.c", "x86_vc/mmxfrag.c", "x86_vc/mmxidct.c", "x86_vc/mmxstate.c", - #"x86_vc/x86enc.c", + # "x86_vc/x86enc.c", "x86_vc/x86state.c", ] - if (env["x86_libtheora_opt_gcc"]): + if env["x86_libtheora_opt_gcc"]: thirdparty_sources += thirdparty_sources_x86 - if (env["x86_libtheora_opt_vc"]): + if env["x86_libtheora_opt_vc"]: thirdparty_sources += thirdparty_sources_x86_vc - if (env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]): + if env["x86_libtheora_opt_gcc"] or env["x86_libtheora_opt_vc"]: env_theora.Append(CPPDEFINES=["OC_X86_ASM"]) thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] @@ -73,9 +73,9 @@ if env['builtin_libtheora']: env_theora.Prepend(CPPPATH=[thirdparty_dir]) # also requires libogg and libvorbis - if env['builtin_libogg']: + if env["builtin_libogg"]: env_theora.Prepend(CPPPATH=["#thirdparty/libogg"]) - if env['builtin_libvorbis']: + if env["builtin_libvorbis"]: env_theora.Prepend(CPPPATH=["#thirdparty/libvorbis"]) env_thirdparty = env_theora.Clone() diff --git a/modules/theora/config.py b/modules/theora/config.py index c7713d7607..413acce2df 100644 --- a/modules/theora/config.py +++ b/modules/theora/config.py @@ -1,13 +1,16 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "VideoStreamTheora", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index ee44c6bf05..e5fb6f996d 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -144,7 +144,7 @@ void VideoStreamPlaybackTheora::clear() { thread_sem->post(); //just in case Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; ring_buffer.clear(); #endif @@ -159,7 +159,7 @@ void VideoStreamPlaybackTheora::clear() { if (file) { memdelete(file); } - file = NULL; + file = nullptr; playing = false; }; @@ -167,7 +167,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) { ERR_FAIL_COND(playing); ogg_packet op; - th_setup_info *ts = NULL; + th_setup_info *ts = nullptr; file_name = p_file; if (file) { @@ -674,7 +674,7 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) { VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { - file = NULL; + file = nullptr; theora_p = 0; vorbis_p = 0; videobuf_ready = 0; @@ -685,8 +685,8 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { buffering = false; texture = Ref<ImageTexture>(memnew(ImageTexture)); - mix_callback = NULL; - mix_udata = NULL; + mix_callback = nullptr; + mix_udata = nullptr; audio_track = 0; delay_compensation = 0; audio_frames_wrote = 0; @@ -696,7 +696,7 @@ VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { ring_buffer.resize(rb_power); read_buffer.resize(RB_SIZE_KB * 1024); thread_sem = Semaphore::create(); - thread = NULL; + thread = nullptr; thread_exit = false; thread_eof = false; diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index da3558ce34..cd7bff7adb 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -187,7 +187,7 @@ public: class ResourceFormatLoaderTheora : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/tinyexr/SCsub b/modules/tinyexr/SCsub index 97f9797b58..e7fd44fabd 100644 --- a/modules/tinyexr/SCsub +++ b/modules/tinyexr/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_tinyexr = env_modules.Clone() diff --git a/modules/tinyexr/config.py b/modules/tinyexr/config.py index 098f1eafa9..53b8f2f2e3 100644 --- a/modules/tinyexr/config.py +++ b/modules/tinyexr/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return env['tools'] + return env["tools"] + def configure(env): pass diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index 41938f5b42..1c0f3cd03e 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -56,7 +56,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f EXRVersion exr_version; EXRImage exr_image; EXRHeader exr_header; - const char *err = NULL; + const char *err = nullptr; InitEXRHeader(&exr_header); @@ -194,7 +194,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f const float *r_channel_start = reinterpret_cast<const float *>(tile.images[idxR]); const float *g_channel_start = reinterpret_cast<const float *>(tile.images[idxG]); const float *b_channel_start = reinterpret_cast<const float *>(tile.images[idxB]); - const float *a_channel_start = NULL; + const float *a_channel_start = nullptr; if (idxA != -1) { a_channel_start = reinterpret_cast<const float *>(tile.images[idxA]); @@ -206,7 +206,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f const float *r_channel = r_channel_start + y * tile_width; const float *g_channel = g_channel_start + y * tile_width; const float *b_channel = b_channel_start + y * tile_width; - const float *a_channel = NULL; + const float *a_channel = nullptr; if (a_channel_start) { a_channel = a_channel_start + y * tile_width; diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp index d8529fd893..af05a411e1 100644 --- a/modules/tinyexr/register_types.cpp +++ b/modules/tinyexr/register_types.cpp @@ -33,7 +33,7 @@ #include "image_loader_tinyexr.h" #include "image_saver_tinyexr.h" -static ImageLoaderTinyEXR *image_loader_tinyexr = NULL; +static ImageLoaderTinyEXR *image_loader_tinyexr = nullptr; void register_tinyexr_types() { @@ -47,5 +47,5 @@ void unregister_tinyexr_types() { memdelete(image_loader_tinyexr); - Image::save_exr_func = NULL; + Image::save_exr_func = nullptr; } diff --git a/modules/upnp/SCsub b/modules/upnp/SCsub index 3f56a69594..2e129e15ca 100644 --- a/modules/upnp/SCsub +++ b/modules/upnp/SCsub @@ -1,13 +1,13 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_upnp = env_modules.Clone() # Thirdparty source files -if env['builtin_miniupnpc']: +if env["builtin_miniupnpc"]: thirdparty_dir = "#thirdparty/miniupnpc/" thirdparty_sources = [ "miniupnpc.c", diff --git a/modules/upnp/config.py b/modules/upnp/config.py index 8724ff1a51..3e15b940a1 100644 --- a/modules/upnp/config.py +++ b/modules/upnp/config.py @@ -1,14 +1,17 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "UPNP", - "UPNPDevice" + "UPNPDevice", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 5ef7575b0c..856f4188aa 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -54,9 +54,9 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) { struct UPNPDev *devlist; if (is_common_device(device_filter)) { - devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error); + devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error); } else { - devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error); + devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error); } if (error != UPNPDISCOVER_SUCCESS) { @@ -133,7 +133,7 @@ void UPNP::parse_igd(Ref<UPNPDevice> dev, UPNPDev *devlist) { parserootdesc(xml, size, &data); free(xml); - xml = 0; + xml = nullptr; GetUPNPUrls(urls, &data, dev->get_description_url().utf8().get_data(), 0); @@ -235,20 +235,20 @@ int UPNP::get_device_count() const { } Ref<UPNPDevice> UPNP::get_device(int index) const { - ERR_FAIL_INDEX_V(index, devices.size(), NULL); + ERR_FAIL_INDEX_V(index, devices.size(), nullptr); return devices.get(index); } void UPNP::add_device(Ref<UPNPDevice> device) { - ERR_FAIL_COND(device == NULL); + ERR_FAIL_COND(device == nullptr); devices.push_back(device); } void UPNP::set_device(int index, Ref<UPNPDevice> device) { ERR_FAIL_INDEX(index, devices.size()); - ERR_FAIL_COND(device == NULL); + ERR_FAIL_COND(device == nullptr); devices.set(index, device); } @@ -264,17 +264,17 @@ void UPNP::clear_devices() { } Ref<UPNPDevice> UPNP::get_gateway() const { - ERR_FAIL_COND_V(devices.size() < 1, NULL); + ERR_FAIL_COND_V(devices.size() < 1, nullptr); for (int i = 0; i < devices.size(); i++) { Ref<UPNPDevice> dev = get_device(i); - if (dev != NULL && dev->is_valid_gateway()) { + if (dev != nullptr && dev->is_valid_gateway()) { return dev; } } - return NULL; + return nullptr; } void UPNP::set_discover_multicast_if(const String &m_if) { @@ -304,7 +304,7 @@ bool UPNP::is_discover_ipv6() const { String UPNP::query_external_address() const { Ref<UPNPDevice> dev = get_gateway(); - if (dev == NULL) { + if (dev == nullptr) { return ""; } @@ -314,7 +314,7 @@ String UPNP::query_external_address() const { int UPNP::add_port_mapping(int port, int port_internal, String desc, String proto, int duration) const { Ref<UPNPDevice> dev = get_gateway(); - if (dev == NULL) { + if (dev == nullptr) { return UPNP_RESULT_NO_GATEWAY; } @@ -326,7 +326,7 @@ int UPNP::add_port_mapping(int port, int port_internal, String desc, String prot int UPNP::delete_port_mapping(int port, String proto) const { Ref<UPNPDevice> dev = get_gateway(); - if (dev == NULL) { + if (dev == nullptr) { return UPNP_RESULT_NO_GATEWAY; } diff --git a/modules/upnp/upnp_device.cpp b/modules/upnp/upnp_device.cpp index 6edfbc2d7d..c21826d14d 100644 --- a/modules/upnp/upnp_device.cpp +++ b/modules/upnp/upnp_device.cpp @@ -65,10 +65,10 @@ int UPNPDevice::add_port_mapping(int port, int port_internal, String desc, Strin itos(port).utf8().get_data(), itos(port_internal).utf8().get_data(), igd_our_addr.utf8().get_data(), - desc.empty() ? 0 : desc.utf8().get_data(), + desc.empty() ? nullptr : desc.utf8().get_data(), proto.utf8().get_data(), - NULL, // Remote host, always NULL as IGDs don't support it - duration > 0 ? itos(duration).utf8().get_data() : 0); + nullptr, // Remote host, always nullptr as IGDs don't support it + duration > 0 ? itos(duration).utf8().get_data() : nullptr); ERR_FAIL_COND_V(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i)); @@ -84,7 +84,7 @@ int UPNPDevice::delete_port_mapping(int port, String proto) const { igd_service_type.utf8().get_data(), itos(port).utf8().get_data(), proto.utf8().get_data(), - NULL // Remote host, always NULL as IGDs don't support it + nullptr // Remote host, always nullptr as IGDs don't support it ); ERR_FAIL_COND_V(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i)); diff --git a/modules/vhacd/SCsub b/modules/vhacd/SCsub index 685976dc33..ecd432b275 100644 --- a/modules/vhacd/SCsub +++ b/modules/vhacd/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_vhacd = env_modules.Clone() @@ -19,7 +19,7 @@ thirdparty_sources = [ "src/btAlignedAllocator.cpp", "src/vhacdRaycastMesh.cpp", "src/VHACD.cpp", - "src/btConvexHullComputer.cpp" + "src/btConvexHullComputer.cpp", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] diff --git a/modules/vhacd/config.py b/modules/vhacd/config.py index 9ced70d2fb..d22f9454ed 100644 --- a/modules/vhacd/config.py +++ b/modules/vhacd/config.py @@ -1,6 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass - diff --git a/modules/vhacd/register_types.cpp b/modules/vhacd/register_types.cpp index 7deb20f6e7..c006a9deec 100644 --- a/modules/vhacd/register_types.cpp +++ b/modules/vhacd/register_types.cpp @@ -84,5 +84,5 @@ void register_vhacd_types() { } void unregister_vhacd_types() { - Mesh::convex_composition_function = NULL; + Mesh::convex_composition_function = nullptr; } diff --git a/modules/visual_script/SCsub b/modules/visual_script/SCsub index 3c3d2caa57..16faea08d7 100644 --- a/modules/visual_script/SCsub +++ b/modules/visual_script/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_vs = env_modules.Clone() diff --git a/modules/visual_script/config.py b/modules/visual_script/config.py index 087a13a200..bd459ca344 100644 --- a/modules/visual_script/config.py +++ b/modules/visual_script/config.py @@ -1,9 +1,11 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "@VisualScript", @@ -56,5 +58,6 @@ def get_doc_classes(): "VisualScriptYield", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index 63bd88ad81..5ea84a32c4 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -41,9 +41,9 @@ #include "visual_script_nodes.h" #include "visual_script_yield_nodes.h" -VisualScriptLanguage *visual_script_language = NULL; +VisualScriptLanguage *visual_script_language = nullptr; #ifdef TOOLS_ENABLED -static _VisualScriptEditor *vs_editor_singleton = NULL; +static _VisualScriptEditor *vs_editor_singleton = nullptr; #endif void register_visual_script_types() { diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index d00cc6986f..b52dfe1733 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -94,7 +94,7 @@ void VisualScriptNode::validate_input_default_values() { default_input_values[i] = Variant::construct(expected, &existingp, 1, ce, false); if (ce.error != Callable::CallError::CALL_OK) { //could not convert? force.. - default_input_values[i] = Variant::construct(expected, NULL, 0, ce, false); + default_input_values[i] = Variant::construct(expected, nullptr, 0, ce, false); } } } @@ -158,8 +158,8 @@ VisualScriptNode::VisualScriptNode() { VisualScriptNodeInstance::VisualScriptNodeInstance() { - sequence_outputs = NULL; - input_ports = NULL; + sequence_outputs = nullptr; + input_ports = nullptr; } VisualScriptNodeInstance::~VisualScriptNodeInstance() { @@ -1594,7 +1594,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int output_args[i] = &variant_stack[node->output_ports[i]]; } - Variant *working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)NULL; + Variant *working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)nullptr; node->step(input_args, output_args, VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE, working_mem, r_error, error_str); //ignore return @@ -1615,8 +1615,8 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p const Variant **input_args = (const Variant **)(sequence_bits + f->node_count); Variant **output_args = (Variant **)(input_args + max_input_args); int flow_max = f->flow_stack_size; - int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL; - int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL; + int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)nullptr; + int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)nullptr; String error_str; @@ -1624,7 +1624,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p bool error = false; int current_node_id = f->node; Variant return_value; - Variant *working_mem = NULL; + Variant *working_mem = nullptr; int flow_stack_pos = p_flow_stack_pos; @@ -1643,7 +1643,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p VSDEBUG("AT STACK POS: " + itos(flow_stack_pos)); //setup working mem - working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)NULL; + working_mem = node->working_mem_idx >= 0 ? &variant_stack[node->working_mem_idx] : (Variant *)nullptr; VSDEBUG("WORKING MEM: " + itos(node->working_mem_idx)); @@ -1817,7 +1817,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p break; //exit function requested, bye } - VisualScriptNodeInstance *next = NULL; //next node + VisualScriptNodeInstance *next = nullptr; //next node if ((ret == output || ret & VisualScriptNodeInstance::STEP_FLAG_PUSH_STACK_BIT) && node->sequence_output_count) { //if no exit bit was set, and has sequence outputs, guess next node @@ -2033,8 +2033,8 @@ Variant VisualScriptInstance::call(const StringName &p_method, const Variant **p const Variant **input_args = (const Variant **)(sequence_bits + f->node_count); Variant **output_args = (Variant **)(input_args + max_input_args); int flow_max = f->flow_stack_size; - int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)NULL; - int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)NULL; + int *flow_stack = flow_max ? (int *)(output_args + max_output_args) : (int *)nullptr; + int *pass_stack = flow_stack ? (int *)(flow_stack + flow_max) : (int *)nullptr; for (int i = 0; i < f->node_count; i++) { sequence_bits[i] = false; //all starts as false @@ -2097,7 +2097,7 @@ void VisualScriptInstance::notification(int p_notification) { String VisualScriptInstance::to_string(bool *r_valid) { if (has_method(CoreStringNames::get_singleton()->_to_string)) { Callable::CallError ce; - Variant ret = call(CoreStringNames::get_singleton()->_to_string, NULL, 0, ce); + Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) { if (ret.get_type() != Variant::STRING) { if (r_valid) @@ -2237,12 +2237,12 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o instance->id = F->key(); instance->input_port_count = node->get_input_value_port_count(); - instance->input_ports = NULL; + instance->input_ports = nullptr; instance->output_port_count = node->get_output_value_port_count(); - instance->output_ports = NULL; + instance->output_ports = nullptr; instance->sequence_output_count = node->get_output_sequence_port_count(); instance->sequence_index = function.node_count++; - instance->sequence_outputs = NULL; + instance->sequence_outputs = nullptr; instance->pass_idx = -1; if (instance->input_port_count) { @@ -2263,7 +2263,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o if (instance->sequence_output_count) { instance->sequence_outputs = memnew_arr(VisualScriptNodeInstance *, instance->sequence_output_count); for (int i = 0; i < instance->sequence_output_count; i++) { - instance->sequence_outputs[i] = NULL; //if it remains null, flow ends here + instance->sequence_outputs[i] = nullptr; //if it remains null, flow ends here } } @@ -2797,7 +2797,7 @@ int VisualScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in return 0; } -VisualScriptLanguage *VisualScriptLanguage::singleton = NULL; +VisualScriptLanguage *VisualScriptLanguage::singleton = nullptr; void VisualScriptLanguage::add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func) { @@ -2844,7 +2844,7 @@ VisualScriptLanguage::VisualScriptLanguage() { } else { _debug_max_call_stack = 0; - _call_stack = NULL; + _call_stack = nullptr; } } @@ -2853,5 +2853,5 @@ VisualScriptLanguage::~VisualScriptLanguage() { if (_call_stack) { memdelete_arr(_call_stack); } - singleton = NULL; + singleton = nullptr; } diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 20273316b4..29309aa156 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -420,7 +420,7 @@ public: virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; - virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const; + virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const; virtual void get_method_list(List<MethodInfo> *p_list) const; virtual bool has_method(const StringName &p_method) const; @@ -596,7 +596,7 @@ public: virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const; virtual bool is_using_templates(); virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script); - virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL, List<ScriptLanguage::Warning> *r_warnings = NULL, Set<int> *r_safe_lines = NULL) const; + virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const; virtual Script *create_script() const; virtual bool has_named_classes() const; virtual bool supports_builtin_mode() const; diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 07f152efd4..39d8f7c082 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -1231,7 +1231,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in PackedByteArray barr; int len; bool full_objects = *p_inputs[1]; - Error err = encode_variant(*p_inputs[0], NULL, len, full_objects); + Error err = encode_variant(*p_inputs[0], nullptr, len, full_objects); if (err) { r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument = 0; @@ -1267,7 +1267,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in Variant ret; { const uint8_t *r = varr.ptr(); - Error err = decode_variant(ret, r, varr.size(), NULL, allow_objects); + Error err = decode_variant(ret, r, varr.size(), nullptr, allow_objects); if (err != OK) { r_error_str = RTR("Not enough bytes for decoding bytes, or invalid format."); r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 19771ef373..30522930c7 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -182,7 +182,7 @@ public: _change_notify(); } - VisualScriptEditorSignalEdit() { undo_redo = NULL; } + VisualScriptEditorSignalEdit() { undo_redo = nullptr; } }; class VisualScriptEditorVariableEdit : public Object { @@ -335,7 +335,7 @@ public: _change_notify(); } - VisualScriptEditorVariableEdit() { undo_redo = NULL; } + VisualScriptEditorVariableEdit() { undo_redo = nullptr; } }; static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { @@ -1932,7 +1932,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant & static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) - return NULL; + return nullptr; Ref<Script> scr = p_current_node->get_script(); @@ -1945,7 +1945,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const return n; } - return NULL; + return nullptr; } void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { @@ -3447,7 +3447,7 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua undo_redo->create_action(TTR("Connect Node Data")); VisualScriptReturn *vnode_return = Object::cast_to<VisualScriptReturn>(vnode.ptr()); - if (vnode_return != NULL && vnode_old->get_output_value_port_count() > 0) { + if (vnode_return != nullptr && vnode_old->get_output_value_port_count() > 0) { vnode_return->set_enable_return_value(true); } if (vnode_old->get_output_value_port_count() <= 0) { @@ -3713,11 +3713,11 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id) { VisualScriptOperator *vnode_operator = Object::cast_to<VisualScriptOperator>(vnode_new.ptr()); - if (vnode_operator != NULL && !vnode_operator->has_input_sequence_port()) { + if (vnode_operator != nullptr && !vnode_operator->has_input_sequence_port()) { return; } VisualScriptConstructor *vnode_constructor = Object::cast_to<VisualScriptConstructor>(vnode_new.ptr()); - if (vnode_constructor != NULL) { + if (vnode_constructor != nullptr) { return; } if (vnode_old->get_output_sequence_port_count() <= 0) { @@ -3889,7 +3889,7 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i } } - if (default_value_edit->edit(NULL, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) { + if (default_value_edit->edit(nullptr, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) { if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT) default_value_edit->popup_centered_ratio(); else @@ -4878,10 +4878,10 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { return memnew(VisualScriptEditor); } - return NULL; + return nullptr; } -VisualScriptEditor::Clipboard *VisualScriptEditor::clipboard = NULL; +VisualScriptEditor::Clipboard *VisualScriptEditor::clipboard = nullptr; void VisualScriptEditor::free_clipboard() { if (clipboard) @@ -4917,7 +4917,7 @@ Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_na return node; } -_VisualScriptEditor *_VisualScriptEditor::singleton = NULL; +_VisualScriptEditor *_VisualScriptEditor::singleton = nullptr; Map<String, REF> _VisualScriptEditor::custom_nodes; _VisualScriptEditor::_VisualScriptEditor() { diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index c52315a477..71ed483d65 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -652,12 +652,12 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { while (true) { //keep appending stuff to expression - ENode *expr = NULL; + ENode *expr = nullptr; Token tk; _get_token(tk); if (error_set) - return NULL; + return nullptr; switch (tk.type) { case TK_CURLY_BRACKET_OPEN: { @@ -675,18 +675,18 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //parse an expression ENode *expr2 = _parse_expression(); if (!expr2) - return NULL; + return nullptr; dn->dict.push_back(expr2); _get_token(tk); if (tk.type != TK_COLON) { _set_error("Expected ':'"); - return NULL; + return nullptr; } expr2 = _parse_expression(); if (!expr2) - return NULL; + return nullptr; dn->dict.push_back(expr2); @@ -719,7 +719,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //parse an expression ENode *expr2 = _parse_expression(); if (!expr2) - return NULL; + return nullptr; an->array.push_back(expr2); cofs = str_ofs; @@ -739,11 +739,11 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //a suexpression ENode *e = _parse_expression(); if (error_set) - return NULL; + return nullptr; _get_token(tk); if (tk.type != TK_PARENTHESIS_CLOSE) { _set_error("Expected ')'"); - return NULL; + return nullptr; } expr = e; @@ -766,7 +766,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { expr = input; } else { _set_error("Invalid input identifier '" + what + "'. For script variables, use self (locals are for inputs)." + what); - return NULL; + return nullptr; } } break; case TK_SELF: { @@ -786,7 +786,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { _get_token(tk); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '('"); - return NULL; + return nullptr; } ConstructorNode *constructor = alloc_node<ConstructorNode>(); @@ -803,7 +803,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //parse an expression ENode *expr2 = _parse_expression(); if (!expr2) - return NULL; + return nullptr; constructor->arguments.push_back(expr2); @@ -827,7 +827,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { _get_token(tk); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '('"); - return NULL; + return nullptr; } BuiltinFuncNode *bifunc = alloc_node<BuiltinFuncNode>(); @@ -844,7 +844,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //parse an expression ENode *expr2 = _parse_expression(); if (!expr2) - return NULL; + return nullptr; bifunc->arguments.push_back(expr2); @@ -886,7 +886,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { default: { _set_error("Expected expression."); - return NULL; + return nullptr; } break; } @@ -896,7 +896,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { int cofs2 = str_ofs; _get_token(tk); if (error_set) - return NULL; + return nullptr; bool done = false; @@ -909,14 +909,14 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { ENode *what = _parse_expression(); if (!what) - return NULL; + return nullptr; index->index = what; _get_token(tk); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']' at end of index."); - return NULL; + return nullptr; } expr = index; @@ -926,7 +926,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { _get_token(tk); if (tk.type != TK_IDENTIFIER) { _set_error("Expected identifier after '.'"); - return NULL; + return nullptr; } StringName identifier = tk.value; @@ -950,7 +950,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //parse an expression ENode *expr2 = _parse_expression(); if (!expr2) - return NULL; + return nullptr; func_call->arguments.push_back(expr2); @@ -1000,7 +1000,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { int cofs = str_ofs; _get_token(tk); if (error_set) - return NULL; + return nullptr; Variant::Operator op = Variant::OP_MAX; @@ -1107,7 +1107,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { default: { _set_error("Parser bug, invalid operator in expression: " + itos(expression[i].op)); - return NULL; + return nullptr; } } @@ -1124,7 +1124,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { if (next_op == -1) { _set_error("Yet another parser bug...."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } // OK! create operator.. @@ -1137,7 +1137,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { if (expr_pos == expression.size()) { //can happen.. _set_error("Unexpected end of expression..."); - return NULL; + return nullptr; } } @@ -1147,7 +1147,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { OperatorNode *op = alloc_node<OperatorNode>(); op->op = expression[i].op; op->nodes[0] = expression[i + 1].node; - op->nodes[1] = NULL; + op->nodes[1] = nullptr; expression.write[i].is_op = false; expression.write[i].node = op; expression.remove(i + 1); @@ -1157,7 +1157,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } OperatorNode *op = alloc_node<OperatorNode>(); @@ -1166,7 +1166,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { if (expression[next_op - 1].is_op) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (expression[next_op + 1].is_op) { @@ -1176,7 +1176,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { // due to how precedence works, unaries will always disappear first _set_error("Unexpected two consecutive operators."); - return NULL; + return nullptr; } op->nodes[0] = expression[next_op - 1].node; //expression goes as left @@ -1199,8 +1199,8 @@ bool VisualScriptExpression::_compile_expression() { if (nodes) { memdelete(nodes); - nodes = NULL; - root = NULL; + nodes = nullptr; + root = nullptr; } error_str = String(); @@ -1210,11 +1210,11 @@ bool VisualScriptExpression::_compile_expression() { root = _parse_expression(); if (error_set) { - root = NULL; + root = nullptr; if (nodes) { memdelete(nodes); } - nodes = NULL; + nodes = nullptr; return true; } @@ -1478,8 +1478,8 @@ VisualScriptExpression::VisualScriptExpression() { output_type = Variant::NIL; expression_dirty = true; error_set = true; - root = NULL; - nodes = NULL; + root = nullptr; + nodes = nullptr; sequenced = false; } diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h index d131713ef0..61b50ff99d 100644 --- a/modules/visual_script/visual_script_expression.h +++ b/modules/visual_script/visual_script_expression.h @@ -138,7 +138,7 @@ class VisualScriptExpression : public VisualScriptNode { Type type; - ENode() { next = NULL; } + ENode() { next = nullptr; } virtual ~ENode() { if (next) { memdelete(next); diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 011432ef39..3b6ae369ae 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -58,7 +58,7 @@ bool VisualScriptFunctionCall::has_input_sequence_port() const { static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) - return NULL; + return nullptr; Ref<Script> scr = p_current_node->get_script(); @@ -71,7 +71,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const return n; } - return NULL; + return nullptr; } #endif @@ -80,33 +80,33 @@ Node *VisualScriptFunctionCall::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) - return NULL; + return nullptr; MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) - return NULL; + return nullptr; Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) - return NULL; + return nullptr; Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) - return NULL; + return nullptr; if (!script_node->has_node(base_path)) - return NULL; + return nullptr; Node *path_to = script_node->get_node(base_path); return path_to; #else - return NULL; + return nullptr; #endif } @@ -955,34 +955,34 @@ Node *VisualScriptPropertySet::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) - return NULL; + return nullptr; MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) - return NULL; + return nullptr; Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) - return NULL; + return nullptr; Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) - return NULL; + return nullptr; if (!script_node->has_node(base_path)) - return NULL; + return nullptr; Node *path_to = script_node->get_node(base_path); return path_to; #else - return NULL; + return nullptr; #endif } @@ -1021,7 +1021,7 @@ void VisualScriptPropertySet::_adjust_input_index(PropertyInfo &pinfo) const { Variant v; Callable::CallError ce; - v = Variant::construct(pinfo.type, NULL, 0, ce); + v = Variant::construct(pinfo.type, nullptr, 0, ce); Variant i = v.get(index); pinfo.type = i.get_type(); } @@ -1168,7 +1168,7 @@ void VisualScriptPropertySet::_update_cache() { Variant v; Callable::CallError ce; - v = Variant::construct(basic_type, NULL, 0, ce); + v = Variant::construct(basic_type, nullptr, 0, ce); List<PropertyInfo> pinfo; v.get_property_list(&pinfo); @@ -1185,7 +1185,7 @@ void VisualScriptPropertySet::_update_cache() { StringName type; Ref<Script> script; - Node *node = NULL; + Node *node = nullptr; if (call_mode == CALL_MODE_NODE_PATH) { @@ -1410,7 +1410,7 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const { if (property.name == "index") { Callable::CallError ce; - Variant v = Variant::construct(type_cache.type, NULL, 0, ce); + Variant v = Variant::construct(type_cache.type, nullptr, 0, ce); List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; @@ -1735,34 +1735,34 @@ Node *VisualScriptPropertyGet::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) - return NULL; + return nullptr; MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) - return NULL; + return nullptr; Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) - return NULL; + return nullptr; Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) - return NULL; + return nullptr; if (!script_node->has_node(base_path)) - return NULL; + return nullptr; Node *path_to = script_node->get_node(base_path); return path_to; #else - return NULL; + return nullptr; #endif } @@ -1876,7 +1876,7 @@ void VisualScriptPropertyGet::_update_cache() { Variant v; Callable::CallError ce; - v = Variant::construct(basic_type, NULL, 0, ce); + v = Variant::construct(basic_type, nullptr, 0, ce); List<PropertyInfo> pinfo; v.get_property_list(&pinfo); @@ -1894,7 +1894,7 @@ void VisualScriptPropertyGet::_update_cache() { StringName type; Ref<Script> script; - Node *node = NULL; + Node *node = nullptr; if (call_mode == CALL_MODE_NODE_PATH) { @@ -2125,7 +2125,7 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const { if (property.name == "index") { Callable::CallError ce; - Variant v = Variant::construct(type_cache, NULL, 0, ce); + Variant v = Variant::construct(type_cache, nullptr, 0, ce); List<PropertyInfo> plist; v.get_property_list(&plist); String options = ""; @@ -2501,7 +2501,7 @@ void register_visual_script_func_nodes() { Variant::Type t = Variant::Type(i); String type_name = Variant::get_type_name(t); Callable::CallError ce; - Variant vt = Variant::construct(t, NULL, 0, ce); + Variant vt = Variant::construct(t, nullptr, 0, ce); List<MethodInfo> ml; vt.get_method_list(&ml); diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 1b496dad32..97c2686cd5 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1483,7 +1483,7 @@ void VisualScriptConstant::set_constant_type(Variant::Type p_type) { type = p_type; Callable::CallError ce; - value = Variant::construct(type, NULL, 0, ce); + value = Variant::construct(type, nullptr, 0, ce); ports_changed_notify(); _change_notify(); } @@ -2548,7 +2548,7 @@ VisualScriptNodeInstance *VisualScriptSceneNode::instance(VisualScriptInstance * static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) - return NULL; + return nullptr; Ref<Script> scr = p_current_node->get_script(); @@ -2561,7 +2561,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const return n; } - return NULL; + return nullptr; } #endif @@ -4006,7 +4006,7 @@ void VisualScriptDeconstruct::_update_elements() { elements.clear(); Variant v; Callable::CallError ce; - v = Variant::construct(type, NULL, 0, ce); + v = Variant::construct(type, nullptr, 0, ce); List<PropertyInfo> pinfo; v.get_property_list(&pinfo); diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index d749e3257a..f57853078d 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -97,7 +97,7 @@ void VisualScriptPropertySelector::_update_search() { for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) { List<MethodInfo> methods; List<PropertyInfo> props; - TreeItem *category = NULL; + TreeItem *category = nullptr; Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { vbc->get_theme_icon("Variant", "EditorIcons"), vbc->get_theme_icon("bool", "EditorIcons"), @@ -196,7 +196,7 @@ void VisualScriptPropertySelector::_update_search() { if (type != Variant::NIL) { Variant v; Callable::CallError ce; - v = Variant::construct(type, NULL, 0, ce); + v = Variant::construct(type, nullptr, 0, ce); v.get_method_list(&methods); } else { @@ -264,7 +264,7 @@ void VisualScriptPropertySelector::_update_search() { item->set_metadata(2, connecting); } - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } } @@ -304,12 +304,12 @@ void VisualScriptPropertySelector::_update_search() { } TreeItem *selected_item = search_options->search_item_text(search_box->get_text()); - if (!found && selected_item != NULL) { + if (!found && selected_item != nullptr) { selected_item->select(0); found = true; } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void VisualScriptPropertySelector::create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text) { @@ -481,7 +481,7 @@ void VisualScriptPropertySelector::_item_selected() { List<String> *names = memnew(List<String>); VisualScriptLanguage::singleton->get_registered_node_names(names); - if (names->find(name) != NULL) { + if (names->find(name) != nullptr) { Ref<VisualScriptOperator> operator_node = VisualScriptLanguage::singleton->create_node_from_name(name); if (operator_node.is_valid()) { Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(operator_node->get_class_name()); @@ -536,7 +536,7 @@ void VisualScriptPropertySelector::select_method_from_base_type(const String &p_ selected = p_current; type = Variant::NIL; properties = false; - instance = NULL; + instance = nullptr; virtuals_only = p_virtuals_only; show_window(.5f); @@ -561,7 +561,7 @@ void VisualScriptPropertySelector::select_from_base_type(const String &p_base, c type = Variant::NIL; properties = true; visual_script_generic = false; - instance = NULL; + instance = nullptr; virtuals_only = p_virtuals_only; show_window(.5f); @@ -585,7 +585,7 @@ void VisualScriptPropertySelector::select_from_script(const Ref<Script> &p_scrip script = p_script->get_instance_id(); properties = true; visual_script_generic = false; - instance = NULL; + instance = nullptr; virtuals_only = false; show_window(.5f); @@ -607,7 +607,7 @@ void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type, type = p_type; properties = true; visual_script_generic = false; - instance = NULL; + instance = nullptr; virtuals_only = false; show_window(.5f); @@ -628,7 +628,7 @@ void VisualScriptPropertySelector::select_from_action(const String &p_type, cons type = Variant::NIL; properties = false; visual_script_generic = false; - instance = NULL; + instance = nullptr; virtuals_only = false; show_window(.5f); @@ -670,7 +670,7 @@ void VisualScriptPropertySelector::select_from_visual_script(const String &p_bas type = Variant::NIL; properties = true; visual_script_generic = true; - instance = NULL; + instance = nullptr; virtuals_only = false; show_window(.5f); if (clear_text) diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index 858074742e..b300aec385 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -228,7 +228,7 @@ bool VisualScriptYieldSignal::has_input_sequence_port() const { static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) - return NULL; + return nullptr; Ref<Script> scr = p_current_node->get_script(); @@ -241,7 +241,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const return n; } - return NULL; + return nullptr; } #endif @@ -250,33 +250,33 @@ Node *VisualScriptYieldSignal::_get_base_node() const { #ifdef TOOLS_ENABLED Ref<Script> script = get_visual_script(); if (!script.is_valid()) - return NULL; + return nullptr; MainLoop *main_loop = OS::get_singleton()->get_main_loop(); SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop); if (!scene_tree) - return NULL; + return nullptr; Node *edited_scene = scene_tree->get_edited_scene_root(); if (!edited_scene) - return NULL; + return nullptr; Node *script_node = _find_script_node(edited_scene, edited_scene, script); if (!script_node) - return NULL; + return nullptr; if (!script_node->has_node(base_path)) - return NULL; + return nullptr; Node *path_to = script_node->get_node(base_path); return path_to; #else - return NULL; + return nullptr; #endif } @@ -516,7 +516,7 @@ public: } else { //yield - Object *object = NULL; + Object *object = nullptr; switch (call_mode) { diff --git a/modules/vorbis/SCsub b/modules/vorbis/SCsub index bde4359595..05d46757d3 100644 --- a/modules/vorbis/SCsub +++ b/modules/vorbis/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") # Only kept to build the thirdparty library used by the theora and webm # modules. We now use stb_vorbis for AudioStreamOGGVorbis. @@ -11,11 +11,11 @@ env_vorbis = env_modules.Clone() stub = True # Thirdparty source files -if env['builtin_libvorbis']: +if env["builtin_libvorbis"]: thirdparty_dir = "#thirdparty/libvorbis/" thirdparty_sources = [ - #"analysis.c", - #"barkmel.c", + # "analysis.c", + # "barkmel.c", "bitrate.c", "block.c", "codebook.c", @@ -29,14 +29,14 @@ if env['builtin_libvorbis']: "mapping0.c", "mdct.c", "psy.c", - #"psytune.c", + # "psytune.c", "registry.c", "res0.c", "sharedbook.c", "smallft.c", "synthesis.c", - #"tone.c", - #"vorbisenc.c", + # "tone.c", + # "vorbisenc.c", "vorbisfile.c", "window.c", ] @@ -46,7 +46,7 @@ if env['builtin_libvorbis']: env_vorbis.Prepend(CPPPATH=[thirdparty_dir]) # also requires libogg - if env['builtin_libogg']: + if env["builtin_libogg"]: env_vorbis.Prepend(CPPPATH=["#thirdparty/libogg"]) env_thirdparty = env_vorbis.Clone() diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/vorbis/config.py +++ b/modules/vorbis/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/webm/SCsub b/modules/webm/SCsub index 32e6727656..247b4ead37 100644 --- a/modules/webm/SCsub +++ b/modules/webm/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_webm = env_modules.Clone() @@ -18,14 +18,14 @@ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_webm.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "libwebm/"]) # also requires libogg, libvorbis and libopus -if env['builtin_libogg']: +if env["builtin_libogg"]: env_webm.Prepend(CPPPATH=["#thirdparty/libogg"]) -if env['builtin_libvorbis']: +if env["builtin_libvorbis"]: env_webm.Prepend(CPPPATH=["#thirdparty/libvorbis"]) -if env['builtin_opus']: +if env["builtin_opus"]: env_webm.Prepend(CPPPATH=["#thirdparty/opus"]) -if env['builtin_libvpx']: +if env["builtin_libvpx"]: env_webm.Prepend(CPPPATH=["#thirdparty/libvpx"]) SConscript("libvpx/SCsub") diff --git a/modules/webm/config.py b/modules/webm/config.py index ba4dcce2f5..93b49d177a 100644 --- a/modules/webm/config.py +++ b/modules/webm/config.py @@ -1,13 +1,16 @@ def can_build(env, platform): - return platform not in ['iphone'] + return platform not in ["iphone"] + def configure(env): pass + def get_doc_classes(): return [ "VideoStreamWebm", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub index 6aed8a16f5..dd6866ad0e 100644 --- a/modules/webm/libvpx/SCsub +++ b/modules/webm/libvpx/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") # Thirdparty sources @@ -9,9 +9,7 @@ libvpx_dir = "#thirdparty/libvpx/" libvpx_sources = [ "vp8/vp8_dx_iface.c", - "vp8/common/generic/systemdependent.c", - "vp8/common/alloccommon.c", "vp8/common/blockd.c", "vp8/common/copy_c.c", @@ -37,16 +35,12 @@ libvpx_sources = [ "vp8/common/swapyv12buffer.c", "vp8/common/treecoder.c", "vp8/common/vp8_loopfilter.c", - "vp8/decoder/dboolhuff.c", "vp8/decoder/decodeframe.c", "vp8/decoder/decodemv.c", "vp8/decoder/detokenize.c", "vp8/decoder/onyxd_if.c", - - "vp9/vp9_dx_iface.c", - "vp9/common/vp9_alloccommon.c", "vp9/common/vp9_blockd.c", "vp9/common/vp9_common_data.c", @@ -69,21 +63,16 @@ libvpx_sources = [ "vp9/common/vp9_seg_common.c", "vp9/common/vp9_thread_common.c", "vp9/common/vp9_tile_common.c", - "vp9/decoder/vp9_decodeframe.c", "vp9/decoder/vp9_decodemv.c", "vp9/decoder/vp9_decoder.c", "vp9/decoder/vp9_detokenize.c", "vp9/decoder/vp9_dsubexp.c", "vp9/decoder/vp9_dthread.c", - - "vpx/src/vpx_codec.c", "vpx/src/vpx_decoder.c", "vpx/src/vpx_image.c", "vpx/src/vpx_psnr.c", - - "vpx_dsp/bitreader.c", "vpx_dsp/bitreader_buffer.c", "vpx_dsp/intrapred.c", @@ -92,18 +81,11 @@ libvpx_sources = [ "vpx_dsp/prob.c", "vpx_dsp/vpx_convolve.c", "vpx_dsp/vpx_dsp_rtcd.c", - - "vpx_mem/vpx_mem.c", - - "vpx_scale/vpx_scale_rtcd.c", - "vpx_scale/generic/yv12config.c", "vpx_scale/generic/yv12extend.c", - - - "vpx_util/vpx_thread.c" + "vpx_util/vpx_thread.c", ] libvpx_sources_mt = [ @@ -114,29 +96,23 @@ libvpx_sources_intrin_x86 = [ "vp8/common/x86/filter_x86.c", "vp8/common/x86/loopfilter_x86.c", "vp8/common/x86/vp8_asm_stubs.c", - - - "vpx_dsp/x86/vpx_asm_stubs.c" + "vpx_dsp/x86/vpx_asm_stubs.c", ] libvpx_sources_intrin_x86_mmx = [ "vp8/common/x86/idct_blk_mmx.c", ] libvpx_sources_intrin_x86_sse2 = [ "vp8/common/x86/idct_blk_sse2.c", - - "vp9/common/x86/vp9_idct_intrin_sse2.c", - - "vpx_dsp/x86/inv_txfm_sse2.c", "vpx_dsp/x86/loopfilter_sse2.c", ] libvpx_sources_intrin_x86_ssse3 = [ - "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c" + "vpx_dsp/x86/vpx_subpixel_8t_intrin_ssse3.c", ] libvpx_sources_intrin_x86_avx2 = [ "vpx_dsp/x86/loopfilter_avx2.c", - "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c" + "vpx_dsp/x86/vpx_subpixel_8t_intrin_avx2.c", ] libvpx_sources_x86asm = [ "vp8/common/x86/copy_sse2.asm", @@ -153,8 +129,6 @@ libvpx_sources_x86asm = [ "vp8/common/x86/subpixel_sse2.asm", "vp8/common/x86/subpixel_ssse3.asm", "vp8/common/x86/vp8_loopfilter_mmx.asm", - - "vpx_dsp/x86/intrapred_sse2.asm", "vpx_dsp/x86/intrapred_ssse3.asm", "vpx_dsp/x86/inv_wht_sse2.asm", @@ -163,21 +137,15 @@ libvpx_sources_x86asm = [ "vpx_dsp/x86/vpx_subpixel_8t_ssse3.asm", "vpx_dsp/x86/vpx_subpixel_bilinear_sse2.asm", "vpx_dsp/x86/vpx_subpixel_bilinear_ssse3.asm", - - - "vpx_ports/emms.asm" + "vpx_ports/emms.asm", ] libvpx_sources_x86_64asm = [ "vp8/common/x86/loopfilter_block_sse2_x86_64.asm", - - - "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm" + "vpx_dsp/x86/inv_txfm_ssse3_x86_64.asm", ] libvpx_sources_arm = [ "vpx_ports/arm_cpudetect.c", - - "vp8/common/arm/loopfilter_arm.c", ] libvpx_sources_arm_neon = [ @@ -196,12 +164,8 @@ libvpx_sources_arm_neon = [ "vp8/common/arm/neon/shortidct4x4llm_neon.c", "vp8/common/arm/neon/sixtappredict_neon.c", "vp8/common/arm/neon/vp8_loopfilter_neon.c", - - "vp9/common/arm/neon/vp9_iht4x4_add_neon.c", "vp9/common/arm/neon/vp9_iht8x8_add_neon.c", - - "vpx_dsp/arm/idct16x16_1_add_neon.c", "vpx_dsp/arm/idct16x16_add_neon.c", "vpx_dsp/arm/idct16x16_neon.c", @@ -220,22 +184,22 @@ libvpx_sources_arm_neon = [ "vpx_dsp/arm/vpx_convolve8_neon.c", "vpx_dsp/arm/vpx_convolve_avg_neon.c", "vpx_dsp/arm/vpx_convolve_copy_neon.c", - "vpx_dsp/arm/vpx_convolve_neon.c" + "vpx_dsp/arm/vpx_convolve_neon.c", ] libvpx_sources_arm_neon_gas = [ "vpx_dsp/arm/gas/intrapred_neon_asm.s", "vpx_dsp/arm/gas/loopfilter_mb_neon.s", - "vpx_dsp/arm/gas/save_reg_neon.s" + "vpx_dsp/arm/gas/save_reg_neon.s", ] libvpx_sources_arm_neon_armasm_ms = [ "vpx_dsp/arm/armasm_ms/intrapred_neon_asm.asm", "vpx_dsp/arm/armasm_ms/loopfilter_mb_neon.asm", - "vpx_dsp/arm/armasm_ms/save_reg_neon.asm" + "vpx_dsp/arm/armasm_ms/save_reg_neon.asm", ] libvpx_sources_arm_neon_gas_apple = [ "vpx_dsp/arm/gas_apple/intrapred_neon_asm.s", "vpx_dsp/arm/gas_apple/loopfilter_mb_neon.s", - "vpx_dsp/arm/gas_apple/save_reg_neon.s" + "vpx_dsp/arm/gas_apple/save_reg_neon.s", ] libvpx_sources = [libvpx_dir + file for file in libvpx_sources] @@ -258,25 +222,43 @@ env_libvpx = env_modules.Clone() env_libvpx.disable_warnings() env_libvpx.Prepend(CPPPATH=[libvpx_dir]) -webm_multithread = env["platform"] != 'javascript' +webm_multithread = env["platform"] != "javascript" cpu_bits = env["bits"] webm_cpu_x86 = False webm_cpu_arm = False -if env["platform"] == 'uwp': - if 'arm' in env["PROGSUFFIX"]: +if env["platform"] == "uwp": + if "arm" in env["PROGSUFFIX"]: webm_cpu_arm = True else: webm_cpu_x86 = True else: import platform - is_x11_or_server_arm = ((env["platform"] == 'linuxbsd' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch'))) - is_ios_x86 = (env["platform"] == 'iphone' and ("arch" in env and env["arch"].startswith('x86'))) - is_android_x86 = (env["platform"] == 'android' and env["android_arch"].startswith('x86')) + + is_x11_or_server_arm = (env["platform"] == "linuxbsd" or env["platform"] == "server") and ( + platform.machine().startswith("arm") or platform.machine().startswith("aarch") + ) + is_ios_x86 = env["platform"] == "iphone" and ("arch" in env and env["arch"].startswith("x86")) + is_android_x86 = env["platform"] == "android" and env["android_arch"].startswith("x86") if is_android_x86: - cpu_bits = '32' if env["android_arch"] == 'x86' else '64' - webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'linuxbsd' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86) - webm_cpu_arm = is_x11_or_server_arm or (not is_ios_x86 and env["platform"] == 'iphone') or (not is_android_x86 and env["platform"] == 'android') + cpu_bits = "32" if env["android_arch"] == "x86" else "64" + webm_cpu_x86 = ( + not is_x11_or_server_arm + and (cpu_bits == "32" or cpu_bits == "64") + and ( + env["platform"] == "windows" + or env["platform"] == "linuxbsd" + or env["platform"] == "osx" + or env["platform"] == "haiku" + or is_android_x86 + or is_ios_x86 + ) + ) + webm_cpu_arm = ( + is_x11_or_server_arm + or (not is_ios_x86 and env["platform"] == "iphone") + or (not is_android_x86 and env["platform"] == "android") + ) if webm_cpu_x86: import subprocess @@ -306,38 +288,43 @@ if webm_cpu_x86: webm_simd_optimizations = False if webm_cpu_x86: - if env["platform"] == 'windows' or env["platform"] == 'uwp': - env_libvpx["ASFORMAT"] = 'win' - elif env["platform"] == 'osx' or env["platform"] == "iphone": - env_libvpx["ASFORMAT"] = 'macho' + if env["platform"] == "windows" or env["platform"] == "uwp": + env_libvpx["ASFORMAT"] = "win" + elif env["platform"] == "osx" or env["platform"] == "iphone": + env_libvpx["ASFORMAT"] = "macho" else: - env_libvpx["ASFORMAT"] = 'elf' + env_libvpx["ASFORMAT"] = "elf" env_libvpx["ASFORMAT"] += cpu_bits - env_libvpx["AS"] = 'yasm' - env_libvpx["ASFLAGS"] = '-I' + libvpx_dir[1:] + ' -f $ASFORMAT -D $ASCPU' - env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' + env_libvpx["AS"] = "yasm" + env_libvpx["ASFLAGS"] = "-I" + libvpx_dir[1:] + " -f $ASFORMAT -D $ASCPU" + env_libvpx["ASCOM"] = "$AS $ASFLAGS -o $TARGET $SOURCES" - if cpu_bits == '32': - env_libvpx["ASCPU"] = 'X86_32' - elif cpu_bits == '64': - env_libvpx["ASCPU"] = 'X86_64' + if cpu_bits == "32": + env_libvpx["ASCPU"] = "X86_32" + elif cpu_bits == "64": + env_libvpx["ASCPU"] = "X86_64" - env_libvpx.Append(CPPDEFINES=['WEBM_X86ASM']) + env_libvpx.Append(CPPDEFINES=["WEBM_X86ASM"]) webm_simd_optimizations = True if webm_cpu_arm: - if env["platform"] == 'iphone': - env_libvpx["ASFLAGS"] = '-arch armv7' - elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'linuxbsd' or env["platform"] == 'server': - env_libvpx["ASFLAGS"] = '-mfpu=neon' - elif env["platform"] == 'uwp': - env_libvpx["AS"] = 'armasm' - env_libvpx["ASFLAGS"] = '' - env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES' - - env_libvpx.Append(CPPDEFINES=['WEBM_ARMASM']) + if env["platform"] == "iphone": + env_libvpx["ASFLAGS"] = "-arch armv7" + elif ( + env["platform"] == "android" + and env["android_arch"] == "armv7" + or env["platform"] == "linuxbsd" + or env["platform"] == "server" + ): + env_libvpx["ASFLAGS"] = "-mfpu=neon" + elif env["platform"] == "uwp": + env_libvpx["AS"] = "armasm" + env_libvpx["ASFLAGS"] = "" + env_libvpx["ASCOM"] = "$AS $ASFLAGS -o $TARGET $SOURCES" + + env_libvpx.Append(CPPDEFINES=["WEBM_ARMASM"]) webm_simd_optimizations = True @@ -350,45 +337,49 @@ if webm_multithread: env_libvpx.add_source_files(env.modules_sources, libvpx_sources_mt) if webm_cpu_x86: - is_clang_or_gcc = ('gcc' in os.path.basename(env["CC"])) or ('clang' in os.path.basename(env["CC"])) or ("osxcross" in env) + is_clang_or_gcc = ( + ("gcc" in os.path.basename(env["CC"])) or ("clang" in os.path.basename(env["CC"])) or ("osxcross" in env) + ) env_libvpx_mmx = env_libvpx.Clone() - if cpu_bits == '32' and is_clang_or_gcc: - env_libvpx_mmx.Append(CCFLAGS=['-mmmx']) + if cpu_bits == "32" and is_clang_or_gcc: + env_libvpx_mmx.Append(CCFLAGS=["-mmmx"]) env_libvpx_mmx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_mmx) env_libvpx_sse2 = env_libvpx.Clone() - if cpu_bits == '32' and is_clang_or_gcc: - env_libvpx_sse2.Append(CCFLAGS=['-msse2']) + if cpu_bits == "32" and is_clang_or_gcc: + env_libvpx_sse2.Append(CCFLAGS=["-msse2"]) env_libvpx_sse2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_sse2) env_libvpx_ssse3 = env_libvpx.Clone() if is_clang_or_gcc: - env_libvpx_ssse3.Append(CCFLAGS=['-mssse3']) + env_libvpx_ssse3.Append(CCFLAGS=["-mssse3"]) env_libvpx_ssse3.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_ssse3) env_libvpx_avx2 = env_libvpx.Clone() if is_clang_or_gcc: - env_libvpx_avx2.Append(CCFLAGS=['-mavx2']) + env_libvpx_avx2.Append(CCFLAGS=["-mavx2"]) env_libvpx_avx2.add_source_files(env.modules_sources, libvpx_sources_intrin_x86_avx2) env_libvpx.add_source_files(env.modules_sources, libvpx_sources_intrin_x86) env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86asm) - if cpu_bits == '64': + if cpu_bits == "64": env_libvpx.add_source_files(env.modules_sources, libvpx_sources_x86_64asm) elif webm_cpu_arm: env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm) - if env["platform"] == 'android': + if env["platform"] == "android": env_libvpx.Prepend(CPPPATH=[libvpx_dir + "third_party/android"]) env_libvpx.add_source_files(env.modules_sources, [libvpx_dir + "third_party/android/cpu-features.c"]) env_libvpx_neon = env_libvpx.Clone() env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon) - if env["platform"] == 'uwp': + if env["platform"] == "uwp": env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_armasm_ms) - elif env["platform"] == 'iphone': + elif env["platform"] == "iphone": env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas_apple) - elif (is_x11_or_server_arm and cpu_bits == '32') or (env["platform"] == 'android' and not env["android_arch"] == 'arm64v8'): + elif (is_x11_or_server_arm and cpu_bits == "32") or ( + env["platform"] == "android" and not env["android_arch"] == "arm64v8" + ): env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm_neon_gas) diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 265383831e..ca78d664f7 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -96,17 +96,17 @@ private: VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() : audio_track(0), - webm(NULL), - video(NULL), - audio(NULL), - video_frames(NULL), - audio_frame(NULL), + webm(nullptr), + video(nullptr), + audio(nullptr), + video_frames(nullptr), + audio_frame(nullptr), video_frames_pos(0), video_frames_capacity(0), num_decoded_samples(0), samples_offset(-1), - mix_callback(NULL), - mix_udata(NULL), + mix_callback(nullptr), + mix_udata(nullptr), playing(false), paused(false), delay_compensation(0.0), @@ -114,7 +114,7 @@ VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() : video_frame_delay(0.0), video_pos(0.0), texture(memnew(ImageTexture)), - pcm(NULL) {} + pcm(nullptr) {} VideoStreamPlaybackWebm::~VideoStreamPlaybackWebm() { delete_pointers(); @@ -137,7 +137,7 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) { } else { memdelete(audio); - audio = NULL; + audio = nullptr; } frame_data.resize((webm->getWidth() * webm->getHeight()) << 2); @@ -149,10 +149,10 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) { return true; } memdelete(video); - video = NULL; + video = nullptr; } memdelete(webm); - webm = NULL; + webm = nullptr; return false; } @@ -162,13 +162,13 @@ void VideoStreamPlaybackWebm::stop() { delete_pointers(); - pcm = NULL; + pcm = nullptr; - audio_frame = NULL; - video_frames = NULL; + audio_frame = nullptr; + video_frames = nullptr; - video = NULL; - audio = NULL; + video = nullptr; + audio = nullptr; open_file(file_name); //Should not fail here... @@ -447,7 +447,7 @@ Ref<VideoStreamPlayback> VideoStreamWebm::instance_playback() { pb->set_audio_track(audio_track); if (pb->open_file(file)) return pb; - return NULL; + return nullptr; } void VideoStreamWebm::set_file(const String &p_file) { diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index 3feaa1278f..bc209e0057 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -128,7 +128,7 @@ public: class ResourceFormatLoaderWebm : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/webp/SCsub b/modules/webp/SCsub index 666628bb44..58f2bb35e6 100644 --- a/modules/webp/SCsub +++ b/modules/webp/SCsub @@ -1,12 +1,12 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_webp = env_modules.Clone() # Thirdparty source files -if env['builtin_libwebp']: +if env["builtin_libwebp"]: thirdparty_dir = "#thirdparty/libwebp/" thirdparty_sources = [ "dec/alpha_dec.c", diff --git a/modules/webp/config.py b/modules/webp/config.py index 1c8cd12a2d..d22f9454ed 100644 --- a/modules/webp/config.py +++ b/modules/webp/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): return True + def configure(env): pass diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index 09a8985472..0998977bb4 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -52,7 +52,7 @@ static Vector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quali Vector<uint8_t> data = img->get_data(); const uint8_t *r = data.ptr(); - uint8_t *dst_buff = NULL; + uint8_t *dst_buff = nullptr; size_t dst_size = 0; if (img->get_format() == Image::FORMAT_RGB8) { @@ -101,9 +101,9 @@ static Ref<Image> _webp_lossy_unpack(const Vector<uint8_t> &p_buffer) { bool errdec = false; if (features.has_alpha) { - errdec = WebPDecodeRGBAInto(&r[4], size, dst_w, datasize, 4 * features.width) == NULL; + errdec = WebPDecodeRGBAInto(&r[4], size, dst_w, datasize, 4 * features.width) == nullptr; } else { - errdec = WebPDecodeRGBInto(&r[4], size, dst_w, datasize, 3 * features.width) == NULL; + errdec = WebPDecodeRGBInto(&r[4], size, dst_w, datasize, 3 * features.width) == nullptr; } ERR_FAIL_COND_V_MSG(errdec, Ref<Image>(), "Failed decoding WebP image."); @@ -128,9 +128,9 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p bool errdec = false; if (features.has_alpha) { - errdec = WebPDecodeRGBAInto(p_buffer, p_buffer_len, dst_w, datasize, 4 * features.width) == NULL; + errdec = WebPDecodeRGBAInto(p_buffer, p_buffer_len, dst_w, datasize, 4 * features.width) == nullptr; } else { - errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w, datasize, 3 * features.width) == NULL; + errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w, datasize, 3 * features.width) == nullptr; } ERR_FAIL_COND_V_MSG(errdec, ERR_FILE_CORRUPT, "Failed decoding WebP image."); diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp index 12a0c05f44..fe945b01d4 100644 --- a/modules/webp/register_types.cpp +++ b/modules/webp/register_types.cpp @@ -32,7 +32,7 @@ #include "image_loader_webp.h" -static ImageLoaderWEBP *image_loader_webp = NULL; +static ImageLoaderWEBP *image_loader_webp = nullptr; void register_webp_types() { diff --git a/modules/webrtc/SCsub b/modules/webrtc/SCsub index 868553b879..20b4c8f8d2 100644 --- a/modules/webrtc/SCsub +++ b/modules/webrtc/SCsub @@ -1,15 +1,15 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") # Thirdparty source files env_webrtc = env_modules.Clone() use_gdnative = env_webrtc["module_gdnative_enabled"] -if use_gdnative: # GDNative is retained in Javascript for export compatibility - env_webrtc.Append(CPPDEFINES=['WEBRTC_GDNATIVE_ENABLED']) +if use_gdnative: # GDNative is retained in Javascript for export compatibility + env_webrtc.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"]) env_webrtc.Prepend(CPPPATH=["#modules/gdnative/include/"]) env_webrtc.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/webrtc/config.py b/modules/webrtc/config.py index 48b4c33c5d..0a075ccef1 100644 --- a/modules/webrtc/config.py +++ b/modules/webrtc/config.py @@ -1,15 +1,18 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "WebRTCPeerConnection", "WebRTCDataChannel", - "WebRTCMultiplayer" + "WebRTCMultiplayer", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp index b0c4b473fc..67ad2c07ce 100644 --- a/modules/webrtc/webrtc_data_channel_gdnative.cpp +++ b/modules/webrtc/webrtc_data_channel_gdnative.cpp @@ -39,94 +39,94 @@ void WebRTCDataChannelGDNative::_bind_methods() { } WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() { - interface = NULL; + interface = nullptr; } WebRTCDataChannelGDNative::~WebRTCDataChannelGDNative() { } Error WebRTCDataChannelGDNative::poll() { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->poll(interface->data); } void WebRTCDataChannelGDNative::close() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->close(interface->data); } void WebRTCDataChannelGDNative::set_write_mode(WriteMode p_mode) { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->set_write_mode(interface->data, p_mode); } WebRTCDataChannel::WriteMode WebRTCDataChannelGDNative::get_write_mode() const { - ERR_FAIL_COND_V(interface == NULL, WRITE_MODE_BINARY); + ERR_FAIL_COND_V(interface == nullptr, WRITE_MODE_BINARY); return (WriteMode)interface->get_write_mode(interface->data); } bool WebRTCDataChannelGDNative::was_string_packet() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->was_string_packet(interface->data); } WebRTCDataChannel::ChannelState WebRTCDataChannelGDNative::get_ready_state() const { - ERR_FAIL_COND_V(interface == NULL, STATE_CLOSED); + ERR_FAIL_COND_V(interface == nullptr, STATE_CLOSED); return (ChannelState)interface->get_ready_state(interface->data); } String WebRTCDataChannelGDNative::get_label() const { - ERR_FAIL_COND_V(interface == NULL, ""); + ERR_FAIL_COND_V(interface == nullptr, ""); return String(interface->get_label(interface->data)); } bool WebRTCDataChannelGDNative::is_ordered() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_ordered(interface->data); } int WebRTCDataChannelGDNative::get_id() const { - ERR_FAIL_COND_V(interface == NULL, -1); + ERR_FAIL_COND_V(interface == nullptr, -1); return interface->get_id(interface->data); } int WebRTCDataChannelGDNative::get_max_packet_life_time() const { - ERR_FAIL_COND_V(interface == NULL, -1); + ERR_FAIL_COND_V(interface == nullptr, -1); return interface->get_max_packet_life_time(interface->data); } int WebRTCDataChannelGDNative::get_max_retransmits() const { - ERR_FAIL_COND_V(interface == NULL, -1); + ERR_FAIL_COND_V(interface == nullptr, -1); return interface->get_max_retransmits(interface->data); } String WebRTCDataChannelGDNative::get_protocol() const { - ERR_FAIL_COND_V(interface == NULL, ""); + ERR_FAIL_COND_V(interface == nullptr, ""); return String(interface->get_protocol(interface->data)); } bool WebRTCDataChannelGDNative::is_negotiated() const { - ERR_FAIL_COND_V(interface == NULL, false); + ERR_FAIL_COND_V(interface == nullptr, false); return interface->is_negotiated(interface->data); } Error WebRTCDataChannelGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size); } Error WebRTCDataChannelGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size); } int WebRTCDataChannelGDNative::get_max_packet_size() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_max_packet_size(interface->data); } int WebRTCDataChannelGDNative::get_available_packet_count() const { - ERR_FAIL_COND_V(interface == NULL, 0); + ERR_FAIL_COND_V(interface == nullptr, 0); return interface->get_available_packet_count(interface->data); } diff --git a/modules/webrtc/webrtc_data_channel_js.cpp b/modules/webrtc/webrtc_data_channel_js.cpp index 37203a4ec9..1b360720a2 100644 --- a/modules/webrtc/webrtc_data_channel_js.cpp +++ b/modules/webrtc/webrtc_data_channel_js.cpp @@ -334,7 +334,7 @@ WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) { stringToUTF8(str, ptr, len+1); return ptr; }, js_id); - if(str != NULL) { + if(str != nullptr) { _label.parse_utf8(str); EM_ASM({ _free($0) }, str); } @@ -347,7 +347,7 @@ WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) { stringToUTF8(str, ptr, len+1); return ptr; }, js_id); - if(str != NULL) { + if(str != nullptr) { _protocol.parse_utf8(str); EM_ASM({ _free($0) }, str); } diff --git a/modules/webrtc/webrtc_multiplayer.cpp b/modules/webrtc/webrtc_multiplayer.cpp index c24ae3468f..78a4d1e61a 100644 --- a/modules/webrtc/webrtc_multiplayer.cpp +++ b/modules/webrtc/webrtc_multiplayer.cpp @@ -316,7 +316,7 @@ Error WebRTCMultiplayer::put_packet(const uint8_t *p_buffer, int p_buffer_size) break; } - Map<int, Ref<ConnectedPeer>>::Element *E = NULL; + Map<int, Ref<ConnectedPeer>>::Element *E = nullptr; if (target_peer > 0) { @@ -371,6 +371,7 @@ WebRTCMultiplayer::WebRTCMultiplayer() { unique_id = 0; next_packet_peer = 0; target_peer = 0; + client_count = 0; transfer_mode = TRANSFER_MODE_RELIABLE; refuse_connections = false; connection_status = CONNECTION_DISCONNECTED; diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp index 90c62e2495..399e4f09ff 100644 --- a/modules/webrtc/webrtc_peer_connection.cpp +++ b/modules/webrtc/webrtc_peer_connection.cpp @@ -30,7 +30,7 @@ #include "webrtc_peer_connection.h" -WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = NULL; +WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = nullptr; Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() { @@ -40,7 +40,7 @@ Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() { WebRTCPeerConnection *WebRTCPeerConnection::create() { if (!_create) - return NULL; + return nullptr; return _create(); } diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp index 411ad50275..f082646629 100644 --- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp +++ b/modules/webrtc/webrtc_peer_connection_gdnative.cpp @@ -36,12 +36,12 @@ #include "modules/gdnative/nativescript/nativescript.h" #include "webrtc_data_channel_gdnative.h" -const godot_net_webrtc_library *WebRTCPeerConnectionGDNative::default_library = NULL; +const godot_net_webrtc_library *WebRTCPeerConnectionGDNative::default_library = nullptr; Error WebRTCPeerConnectionGDNative::set_default_library(const godot_net_webrtc_library *p_lib) { if (default_library) { const godot_net_webrtc_library *old = default_library; - default_library = NULL; + default_library = nullptr; old->unregistered(); } default_library = p_lib; @@ -64,54 +64,54 @@ void WebRTCPeerConnectionGDNative::_bind_methods() { } WebRTCPeerConnectionGDNative::WebRTCPeerConnectionGDNative() { - interface = NULL; + interface = nullptr; } WebRTCPeerConnectionGDNative::~WebRTCPeerConnectionGDNative() { } Error WebRTCPeerConnectionGDNative::initialize(Dictionary p_config) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->initialize(interface->data, (const godot_dictionary *)&p_config); } Ref<WebRTCDataChannel> WebRTCPeerConnectionGDNative::create_data_channel(String p_label, Dictionary p_options) { - ERR_FAIL_COND_V(interface == NULL, NULL); + ERR_FAIL_COND_V(interface == nullptr, nullptr); return (WebRTCDataChannel *)interface->create_data_channel(interface->data, p_label.utf8().get_data(), (const godot_dictionary *)&p_options); } Error WebRTCPeerConnectionGDNative::create_offer() { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->create_offer(interface->data); } Error WebRTCPeerConnectionGDNative::set_local_description(String p_type, String p_sdp) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->set_local_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data()); } Error WebRTCPeerConnectionGDNative::set_remote_description(String p_type, String p_sdp) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->set_remote_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data()); } Error WebRTCPeerConnectionGDNative::add_ice_candidate(String sdpMidName, int sdpMlineIndexName, String sdpName) { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->add_ice_candidate(interface->data, sdpMidName.utf8().get_data(), sdpMlineIndexName, sdpName.utf8().get_data()); } Error WebRTCPeerConnectionGDNative::poll() { - ERR_FAIL_COND_V(interface == NULL, ERR_UNCONFIGURED); + ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED); return (Error)interface->poll(interface->data); } void WebRTCPeerConnectionGDNative::close() { - ERR_FAIL_COND(interface == NULL); + ERR_FAIL_COND(interface == nullptr); interface->close(interface->data); } WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionGDNative::get_connection_state() const { - ERR_FAIL_COND_V(interface == NULL, STATE_DISCONNECTED); + ERR_FAIL_COND_V(interface == nullptr, STATE_DISCONNECTED); return (ConnectionState)interface->get_connection_state(interface->data); } diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index a84dabab72..593c3a5162 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -279,7 +279,7 @@ Ref<WebRTCDataChannel> WebRTCPeerConnectionJS::create_data_channel(String p_chan } }, _js_id, p_channel.utf8().get_data(), config.utf8().get_data()); /* clang-format on */ - ERR_FAIL_COND_V(id == 0, NULL); + ERR_FAIL_COND_V(id == 0, nullptr); return memnew(WebRTCDataChannelJS(id)); } diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub index 033169411f..af60055855 100644 --- a/modules/websocket/SCsub +++ b/modules/websocket/SCsub @@ -1,13 +1,13 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") # Thirdparty source files env_ws = env_modules.Clone() -if env['builtin_wslay'] and not env["platform"] == "javascript": # already builtin for javascript +if env["builtin_wslay"] and not env["platform"] == "javascript": # already builtin for javascript wslay_dir = "#thirdparty/wslay/" wslay_sources = [ "wslay_net.c", diff --git a/modules/websocket/config.py b/modules/websocket/config.py index f59ef432b4..9e27a1a0fe 100644 --- a/modules/websocket/config.py +++ b/modules/websocket/config.py @@ -1,16 +1,19 @@ def can_build(env, platform): return True + def configure(env): pass + def get_doc_classes(): return [ "WebSocketClient", "WebSocketMultiplayerPeer", "WebSocketPeer", - "WebSocketServer" + "WebSocketServer", ] + def get_doc_path(): return "doc_classes" diff --git a/modules/websocket/emws_server.cpp b/modules/websocket/emws_server.cpp index 8ceefa42b6..95cffb4775 100644 --- a/modules/websocket/emws_server.cpp +++ b/modules/websocket/emws_server.cpp @@ -50,7 +50,7 @@ bool EMWSServer::has_peer(int p_id) const { } Ref<WebSocketPeer> EMWSServer::get_peer(int p_id) const { - return NULL; + return nullptr; } Vector<String> EMWSServer::get_protocols() const { diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h index ea3658c827..5f5f0e20cd 100644 --- a/modules/websocket/packet_buffer.h +++ b/modules/websocket/packet_buffer.h @@ -63,7 +63,7 @@ public: ERR_FAIL_COND_V(p_info && _packets.space_left() < 1, ERR_OUT_OF_MEMORY); #endif - // If p_info is NULL, only the payload is written + // If p_info is nullptr, only the payload is written if (p_info) { _Packet p; p.size = p_size; @@ -71,7 +71,7 @@ public: _packets.write(p); } - // If p_payload is NULL, only the packet information is written. + // If p_payload is nullptr, only the packet information is written. if (p_payload) { _payload.write((const uint8_t *)p_payload, p_size); } diff --git a/modules/websocket/websocket_macros.h b/modules/websocket/websocket_macros.h index 8aa01a70ed..f7eafcff1f 100644 --- a/modules/websocket/websocket_macros.h +++ b/modules/websocket/websocket_macros.h @@ -56,13 +56,13 @@ public:\ static CNAME *create() {\ \ if (!_create)\ - return NULL;\ + return nullptr;\ return _create();\ }\ protected:\ #define GDCINULL(CNAME) \ -CNAME *(*CNAME::_create)() = NULL; +CNAME *(*CNAME::_create)() = nullptr; #define GDCIIMPL(IMPNAME, CNAME) \ public:\ diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 9eb1445b35..9b71b32e33 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -42,7 +42,7 @@ WebSocketMultiplayerPeer::WebSocketMultiplayerPeer() { _current_packet.source = 0; _current_packet.destination = 0; _current_packet.size = 0; - _current_packet.data = NULL; + _current_packet.data = nullptr; } WebSocketMultiplayerPeer::~WebSocketMultiplayerPeer() { @@ -74,12 +74,12 @@ int WebSocketMultiplayerPeer::_gen_unique_id() const { void WebSocketMultiplayerPeer::_clear() { _peer_map.clear(); - if (_current_packet.data != NULL) + if (_current_packet.data != nullptr) memfree(_current_packet.data); for (List<Packet>::Element *E = _incoming_packets.front(); E; E = E->next()) { memfree(E->get().data); - E->get().data = NULL; + E->get().data = nullptr; } _incoming_packets.clear(); @@ -109,9 +109,9 @@ Error WebSocketMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buff r_buffer_size = 0; - if (_current_packet.data != NULL) { + if (_current_packet.data != nullptr) { memfree(_current_packet.data); - _current_packet.data = NULL; + _current_packet.data = nullptr; } _current_packet = _incoming_packets.front()->get(); diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index bada750ec2..9f05500eb9 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -279,7 +279,7 @@ void WSLClient::poll() { Ref<WebSocketPeer> WSLClient::get_peer(int p_peer_id) const { - ERR_FAIL_COND_V(p_peer_id != 1, NULL); + ERR_FAIL_COND_V(p_peer_id != 1, nullptr); return _peer; } @@ -298,7 +298,7 @@ NetworkedMultiplayerPeer::ConnectionStatus WSLClient::get_connection_status() co void WSLClient::disconnect_from_host(int p_code, String p_reason) { _peer->close(p_code, p_reason); - _connection = Ref<StreamPeer>(NULL); + _connection = Ref<StreamPeer>(nullptr); _tcp = Ref<StreamPeerTCP>(memnew(StreamPeerTCP)); _key = ""; diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index ff32e83dc1..44b71f70f4 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -69,7 +69,7 @@ void WSLPeer::_wsl_destroy(struct PeerData **p_data) { } wslay_event_context_free(data->ctx); memdelete(data); - *p_data = NULL; + *p_data = nullptr; } bool WSLPeer::_wsl_poll(struct PeerData *p_data) { @@ -163,9 +163,9 @@ wslay_event_callbacks wsl_callbacks = { wsl_recv_callback, wsl_send_callback, wsl_genmask_callback, - NULL, /* on_frame_recv_start_callback */ - NULL, /* on_frame_recv_callback */ - NULL, /* on_frame_recv_end_callback */ + nullptr, /* on_frame_recv_start_callback */ + nullptr, /* on_frame_recv_callback */ + nullptr, /* on_frame_recv_end_callback */ wsl_msg_recv_callback }; @@ -199,8 +199,8 @@ Error WSLPeer::parse_message(const wslay_event_on_msg_recv_arg *arg) { } void WSLPeer::make_context(PeerData *p_data, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size, unsigned int p_out_pkt_size) { - ERR_FAIL_COND(_data != NULL); - ERR_FAIL_COND(p_data == NULL); + ERR_FAIL_COND(_data != nullptr); + ERR_FAIL_COND(p_data == nullptr); _in_buffer.resize(p_in_pkt_size, p_in_buf_size); _packet_buffer.resize((1 << MAX(p_in_buf_size, p_out_buf_size))); @@ -229,7 +229,7 @@ void WSLPeer::poll() { return; if (_wsl_poll(_data)) { - _data = NULL; + _data = nullptr; } } @@ -284,7 +284,7 @@ bool WSLPeer::was_string_packet() const { bool WSLPeer::is_connected_to_host() const { - return _data != NULL; + return _data != nullptr; } void WSLPeer::close_now() { @@ -330,7 +330,7 @@ void WSLPeer::invalidate() { } WSLPeer::WSLPeer() { - _data = NULL; + _data = nullptr; _is_string = 0; close_code = -1; write_mode = WRITE_MODE_BINARY; @@ -341,7 +341,7 @@ WSLPeer::~WSLPeer() { close(); invalidate(); _wsl_destroy(&_data); - _data = NULL; + _data = nullptr; } #endif // JAVASCRIPT_ENABLED diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index 00549cd9bc..3b0639831a 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -67,10 +67,10 @@ public: valid = false; is_server = false; id = 1; - ctx = NULL; - obj = NULL; + ctx = nullptr; + obj = nullptr; closing = false; - peer = NULL; + peer = nullptr; } }; diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index b66cdf3ea2..6f155a6ffa 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -265,7 +265,7 @@ bool WSLServer::has_peer(int p_id) const { } Ref<WebSocketPeer> WSLServer::get_peer(int p_id) const { - ERR_FAIL_COND_V(!has_peer(p_id), NULL); + ERR_FAIL_COND_V(!has_peer(p_id), nullptr); return _peer_map[p_id]; } diff --git a/modules/xatlas_unwrap/SCsub b/modules/xatlas_unwrap/SCsub index b242fd4673..c659349d05 100644 --- a/modules/xatlas_unwrap/SCsub +++ b/modules/xatlas_unwrap/SCsub @@ -1,12 +1,12 @@ #!/usr/bin/env python -Import('env') -Import('env_modules') +Import("env") +Import("env_modules") env_xatlas_unwrap = env_modules.Clone() # Thirdparty source files -if env['builtin_xatlas']: +if env["builtin_xatlas"]: thirdparty_dir = "#thirdparty/xatlas/" thirdparty_sources = [ "xatlas.cpp", diff --git a/modules/xatlas_unwrap/config.py b/modules/xatlas_unwrap/config.py index bd092bdc16..2e73c51626 100644 --- a/modules/xatlas_unwrap/config.py +++ b/modules/xatlas_unwrap/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return (env['tools'] and platform not in ["android", "ios"]) + return env["tools"] and platform not in ["android", "ios"] + def configure(env): pass diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp index c69b566525..e293dfd50c 100644 --- a/modules/xatlas_unwrap/register_types.cpp +++ b/modules/xatlas_unwrap/register_types.cpp @@ -52,7 +52,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver input_mesh.vertexPositionStride = sizeof(float) * 3; input_mesh.vertexNormalData = p_normals; input_mesh.vertexNormalStride = sizeof(uint32_t) * 3; - input_mesh.vertexUvData = NULL; + input_mesh.vertexUvData = nullptr; input_mesh.vertexUvStride = 0; xatlas::ChartOptions chart_options; @@ -68,7 +68,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver ERR_FAIL_COND_V_MSG(err != xatlas::AddMeshError::Enum::Success, false, xatlas::StringForEnum(err)); printf("Generate..\n"); - xatlas::Generate(atlas, chart_options, NULL, pack_options); + xatlas::Generate(atlas, chart_options, nullptr, pack_options); *r_size_hint_x = atlas->width; *r_size_hint_y = atlas->height; diff --git a/platform/SCsub b/platform/SCsub index 40cacce674..5194a19518 100644 --- a/platform/SCsub +++ b/platform/SCsub @@ -1,30 +1,30 @@ #!/usr/bin/env python -Import('env') +Import("env") env.platform_sources = [] # Register platform-exclusive APIs reg_apis_inc = '#include "register_platform_apis.h"\n' -reg_apis = 'void register_platform_apis() {\n' -unreg_apis = 'void unregister_platform_apis() {\n' +reg_apis = "void register_platform_apis() {\n" +unreg_apis = "void unregister_platform_apis() {\n" for platform in env.platform_apis: platform_dir = env.Dir(platform) - env.add_source_files(env.platform_sources, platform + '/api/api.cpp') - reg_apis += '\tregister_' + platform + '_api();\n' - unreg_apis += '\tunregister_' + platform + '_api();\n' + env.add_source_files(env.platform_sources, platform + "/api/api.cpp") + reg_apis += "\tregister_" + platform + "_api();\n" + unreg_apis += "\tunregister_" + platform + "_api();\n" reg_apis_inc += '#include "' + platform + '/api/api.h"\n' -reg_apis_inc += '\n' -reg_apis += '}\n\n' -unreg_apis += '}\n' +reg_apis_inc += "\n" +reg_apis += "}\n\n" +unreg_apis += "}\n" # NOTE: It is safe to generate this file here, since this is still execute serially -with open('register_platform_apis.gen.cpp', 'w', encoding="utf-8") 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) -env.add_source_files(env.platform_sources, 'register_platform_apis.gen.cpp') +env.add_source_files(env.platform_sources, "register_platform_apis.gen.cpp") -lib = env.add_library('platform', env.platform_sources) +lib = env.add_library("platform", env.platform_sources) env.Prepend(LIBS=[lib]) diff --git a/platform/android/SCsub b/platform/android/SCsub index 5ca5ce548c..f39eb8b889 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -1,24 +1,24 @@ #!/usr/bin/env python -Import('env') +Import("env") android_files = [ - 'os_android.cpp', - 'file_access_android.cpp', - 'audio_driver_opensl.cpp', - 'file_access_jandroid.cpp', - 'dir_access_jandroid.cpp', - 'thread_jandroid.cpp', - 'net_socket_android.cpp', - 'audio_driver_jandroid.cpp', - 'java_godot_lib_jni.cpp', - 'java_class_wrapper.cpp', - 'java_godot_wrapper.cpp', - 'java_godot_io_wrapper.cpp', - 'jni_utils.cpp', - 'android_keys_utils.cpp', - 'vulkan/vk_renderer_jni.cpp', - 'plugin/godot_plugin_jni.cpp' + "os_android.cpp", + "file_access_android.cpp", + "audio_driver_opensl.cpp", + "file_access_jandroid.cpp", + "dir_access_jandroid.cpp", + "thread_jandroid.cpp", + "net_socket_android.cpp", + "audio_driver_jandroid.cpp", + "java_godot_lib_jni.cpp", + "java_class_wrapper.cpp", + "java_godot_wrapper.cpp", + "java_godot_io_wrapper.cpp", + "jni_utils.cpp", + "android_keys_utils.cpp", + "vulkan/vk_renderer_jni.cpp", + "plugin/godot_plugin_jni.cpp", ] env_android = env.Clone() @@ -29,30 +29,34 @@ for x in android_files: env_thirdparty = env_android.Clone() env_thirdparty.disable_warnings() -android_objects.append(env_thirdparty.SharedObject('#thirdparty/misc/ifaddrs-android.cc')) +android_objects.append(env_thirdparty.SharedObject("#thirdparty/misc/ifaddrs-android.cc")) lib = env_android.add_shared_library("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"]) -lib_arch_dir = '' -if env['android_arch'] == 'armv7': - lib_arch_dir = 'armeabi-v7a' -elif env['android_arch'] == 'arm64v8': - lib_arch_dir = 'arm64-v8a' -elif env['android_arch'] == 'x86': - lib_arch_dir = 'x86' -elif env['android_arch'] == 'x86_64': - lib_arch_dir = 'x86_64' +lib_arch_dir = "" +if env["android_arch"] == "armv7": + lib_arch_dir = "armeabi-v7a" +elif env["android_arch"] == "arm64v8": + lib_arch_dir = "arm64-v8a" +elif env["android_arch"] == "x86": + lib_arch_dir = "x86" +elif env["android_arch"] == "x86_64": + lib_arch_dir = "x86_64" else: - print('WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin') + print("WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin") -if lib_arch_dir != '': - if env['target'] == 'release': - lib_type_dir = 'release' +if lib_arch_dir != "": + if env["target"] == "release": + lib_type_dir = "release" else: # release_debug, debug - lib_type_dir = 'debug' + lib_type_dir = "debug" - out_dir = '#platform/android/java/lib/libs/' + lib_type_dir + '/' + lib_arch_dir - env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE")) + out_dir = "#platform/android/java/lib/libs/" + lib_type_dir + "/" + lib_arch_dir + env_android.Command( + out_dir + "/libgodot_android.so", "#bin/libgodot" + env["SHLIBSUFFIX"], Move("$TARGET", "$SOURCE") + ) - stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so' - env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE")) + stl_lib_path = ( + str(env["ANDROID_NDK_ROOT"]) + "/sources/cxx-stl/llvm-libc++/libs/" + lib_arch_dir + "/libc++_shared.so" + ) + env_android.Command(out_dir + "/libc++_shared.so", stl_lib_path, Copy("$TARGET", "$SOURCE")) diff --git a/platform/android/api/api.cpp b/platform/android/api/api.cpp index 7efb545524..ef11b12971 100644 --- a/platform/android/api/api.cpp +++ b/platform/android/api/api.cpp @@ -34,7 +34,7 @@ #include "java_class_wrapper.h" #if !defined(ANDROID_ENABLED) -static JavaClassWrapper *java_class_wrapper = NULL; +static JavaClassWrapper *java_class_wrapper = nullptr; #endif void register_android_api() { @@ -73,7 +73,7 @@ Variant JavaObject::call(const StringName &, const Variant **, int, Callable::Ca return Variant(); } -JavaClassWrapper *JavaClassWrapper::singleton = NULL; +JavaClassWrapper *JavaClassWrapper::singleton = nullptr; Ref<JavaClass> JavaClassWrapper::wrap(const String &) { return Ref<JavaClass>(); diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h index d7322deb81..59fcd94b4d 100644 --- a/platform/android/api/java_class_wrapper.h +++ b/platform/android/api/java_class_wrapper.h @@ -236,7 +236,7 @@ public: Ref<JavaClass> wrap(const String &p_class); #ifdef ANDROID_ENABLED - JavaClassWrapper(jobject p_activity = NULL); + JavaClassWrapper(jobject p_activity = nullptr); #else JavaClassWrapper(); #endif diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index e94dad9ac6..802d85e7be 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -34,7 +34,7 @@ #include "core/project_settings.h" #include "thread_jandroid.h" -AudioDriverAndroid *AudioDriverAndroid::s_ad = NULL; +AudioDriverAndroid *AudioDriverAndroid::s_ad = nullptr; jobject AudioDriverAndroid::io; jmethodID AudioDriverAndroid::_init_audio; @@ -46,10 +46,10 @@ jclass AudioDriverAndroid::cls; int AudioDriverAndroid::audioBufferFrames = 0; int AudioDriverAndroid::mix_rate = 44100; bool AudioDriverAndroid::quit = false; -jobject AudioDriverAndroid::audioBuffer = NULL; -void *AudioDriverAndroid::audioBufferPinned = NULL; +jobject AudioDriverAndroid::audioBuffer = nullptr; +void *AudioDriverAndroid::audioBufferPinned = nullptr; Mutex AudioDriverAndroid::mutex; -int32_t *AudioDriverAndroid::audioBuffer32 = NULL; +int32_t *AudioDriverAndroid::audioBuffer32 = nullptr; const char *AudioDriverAndroid::get_name() const { @@ -83,7 +83,7 @@ Error AudioDriverAndroid::init() { audioBuffer = env->CallObjectMethod(io, _init_audio, mix_rate, buffer_size); - ERR_FAIL_COND_V(audioBuffer == NULL, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(audioBuffer == nullptr, ERR_INVALID_PARAMETER); audioBuffer = env->NewGlobalRef(audioBuffer); @@ -181,8 +181,8 @@ void AudioDriverAndroid::finish() { if (audioBuffer) { env->DeleteGlobalRef(audioBuffer); - audioBuffer = NULL; - audioBufferPinned = NULL; + audioBuffer = nullptr; + audioBufferPinned = nullptr; } active = false; diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index 222120f81f..e59850e016 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -83,7 +83,7 @@ void AudioDriverOpenSL::_buffer_callbacks( ad->_buffer_callback(queueItf); } -AudioDriverOpenSL *AudioDriverOpenSL::s_ad = NULL; +AudioDriverOpenSL *AudioDriverOpenSL::s_ad = nullptr; const char *AudioDriverOpenSL::get_name() const { @@ -96,7 +96,7 @@ Error AudioDriverOpenSL::init() { SLEngineOption EngineOption[] = { { (SLuint32)SL_ENGINEOPTION_THREADSAFE, (SLuint32)SL_BOOLEAN_TRUE } }; - res = slCreateEngine(&sl, 1, EngineOption, 0, NULL, NULL); + res = slCreateEngine(&sl, 1, EngineOption, 0, nullptr, nullptr); ERR_FAIL_COND_V_MSG(res != SL_RESULT_SUCCESS, ERR_INVALID_PARAMETER, "Could not initialize OpenSL."); res = (*sl)->Realize(sl, SL_BOOLEAN_FALSE); @@ -161,7 +161,7 @@ void AudioDriverOpenSL::start() { locator_outputmix.locatorType = SL_DATALOCATOR_OUTPUTMIX; locator_outputmix.outputMix = OutputMix; audioSink.pLocator = (void *)&locator_outputmix; - audioSink.pFormat = NULL; + audioSink.pFormat = nullptr; /* Initialize the context for Buffer queue callbacks */ //cntxt.pDataBase = (void*)&pcmData; //cntxt.pData = cntxt.pDataBase; @@ -228,9 +228,9 @@ Error AudioDriverOpenSL::capture_init_device() { SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT, SL_DEFAULTDEVICEID_AUDIOINPUT, - NULL + nullptr }; - SLDataSource recSource = { &loc_dev, NULL }; + SLDataSource recSource = { &loc_dev, nullptr }; SLDataLocator_AndroidSimpleBufferQueue loc_bq = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, diff --git a/platform/android/detect.py b/platform/android/detect.py index ff3ca0706c..ed0643e3b3 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -13,7 +13,7 @@ def get_name(): def can_build(): - return ("ANDROID_NDK_ROOT" in os.environ) + return "ANDROID_NDK_ROOT" in os.environ def get_platform(platform): @@ -24,33 +24,33 @@ def get_opts(): from SCons.Variables import BoolVariable, EnumVariable return [ - ('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), - ('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"), - EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'arm64v8', 'x86', 'x86_64')), - BoolVariable('android_neon', 'Enable NEON support (armv7 only)', True), + ("ANDROID_NDK_ROOT", "Path to the Android NDK", os.environ.get("ANDROID_NDK_ROOT", 0)), + ("ndk_platform", 'Target platform (android-<api>, e.g. "android-18")', "android-18"), + EnumVariable("android_arch", "Target architecture", "armv7", ("armv7", "arm64v8", "x86", "x86_64")), + BoolVariable("android_neon", "Enable NEON support (armv7 only)", True), ] def get_flags(): return [ - ('tools', False), + ("tools", False), ] def create(env): - tools = env['TOOLS'] + tools = env["TOOLS"] if "mingw" in tools: - tools.remove('mingw') + tools.remove("mingw") if "applelink" in tools: tools.remove("applelink") - env.Tool('gcc') + env.Tool("gcc") return env.Clone(tools=tools) def configure(env): # Workaround for MinGW. See: # http://www.scons.org/wiki/LongCmdLinesOnWin32 - if (os.name == "nt"): + if os.name == "nt": import subprocess @@ -58,8 +58,15 @@ def configure(env): # print("SPAWNED : " + cmdline) startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env) + proc = subprocess.Popen( + cmdline, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + startupinfo=startupinfo, + shell=False, + env=env, + ) data, err = proc.communicate() rv = proc.wait() if rv: @@ -70,7 +77,7 @@ def configure(env): def mySpawn(sh, escape, cmd, args, env): - newargs = ' '.join(args[1:]) + newargs = " ".join(args[1:]) cmdline = cmd + " " + newargs rv = 0 @@ -85,50 +92,54 @@ def configure(env): return rv - env['SPAWN'] = mySpawn + env["SPAWN"] = mySpawn # Architecture - if env['android_arch'] not in ['armv7', 'arm64v8', 'x86', 'x86_64']: - env['android_arch'] = 'armv7' + if env["android_arch"] not in ["armv7", "arm64v8", "x86", "x86_64"]: + env["android_arch"] = "armv7" neon_text = "" - if env["android_arch"] == "armv7" and env['android_neon']: + if env["android_arch"] == "armv7" and env["android_neon"]: neon_text = " (with NEON)" - print("Building for Android (" + env['android_arch'] + ")" + neon_text) + print("Building for Android (" + env["android_arch"] + ")" + neon_text) can_vectorize = True - if env['android_arch'] == 'x86': - env['ARCH'] = 'arch-x86' + if env["android_arch"] == "x86": + env["ARCH"] = "arch-x86" env.extra_suffix = ".x86" + env.extra_suffix target_subpath = "x86-4.9" abi_subpath = "i686-linux-android" arch_subpath = "x86" env["x86_libtheora_opt_gcc"] = True - if env['android_arch'] == 'x86_64': + if env["android_arch"] == "x86_64": if get_platform(env["ndk_platform"]) < 21: - print("WARNING: android_arch=x86_64 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21") + print( + "WARNING: android_arch=x86_64 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21" + ) env["ndk_platform"] = "android-21" - env['ARCH'] = 'arch-x86_64' + env["ARCH"] = "arch-x86_64" env.extra_suffix = ".x86_64" + env.extra_suffix target_subpath = "x86_64-4.9" abi_subpath = "x86_64-linux-android" arch_subpath = "x86_64" env["x86_libtheora_opt_gcc"] = True elif env["android_arch"] == "armv7": - env['ARCH'] = 'arch-arm' + env["ARCH"] = "arch-arm" target_subpath = "arm-linux-androideabi-4.9" abi_subpath = "arm-linux-androideabi" arch_subpath = "armeabi-v7a" - if env['android_neon']: + if env["android_neon"]: env.extra_suffix = ".armv7.neon" + env.extra_suffix else: env.extra_suffix = ".armv7" + env.extra_suffix elif env["android_arch"] == "arm64v8": if get_platform(env["ndk_platform"]) < 21: - print("WARNING: android_arch=arm64v8 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21") + print( + "WARNING: android_arch=arm64v8 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21" + ) env["ndk_platform"] = "android-21" - env['ARCH'] = 'arch-arm64' + env["ARCH"] = "arch-arm64" target_subpath = "aarch64-linux-android-4.9" abi_subpath = "aarch64-linux-android" arch_subpath = "arm64-v8a" @@ -136,40 +147,40 @@ def configure(env): # Build type - if (env["target"].startswith("release")): - if (env["optimize"] == "speed"): # optimize for speed (default) - env.Append(LINKFLAGS=['-O2']) - env.Append(CCFLAGS=['-O2', '-fomit-frame-pointer']) - env.Append(CPPDEFINES=['NDEBUG']) + if env["target"].startswith("release"): + if env["optimize"] == "speed": # optimize for speed (default) + env.Append(LINKFLAGS=["-O2"]) + env.Append(CCFLAGS=["-O2", "-fomit-frame-pointer"]) + env.Append(CPPDEFINES=["NDEBUG"]) else: # optimize for size - env.Append(CCFLAGS=['-Os']) - env.Append(CPPDEFINES=['NDEBUG']) - env.Append(LINKFLAGS=['-Os']) - - if (can_vectorize): - env.Append(CCFLAGS=['-ftree-vectorize']) - if (env["target"] == "release_debug"): - env.Append(CPPDEFINES=['DEBUG_ENABLED']) - elif (env["target"] == "debug"): - env.Append(LINKFLAGS=['-O0']) - env.Append(CCFLAGS=['-O0', '-g', '-fno-limit-debug-info']) - env.Append(CPPDEFINES=['_DEBUG', 'DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) - env.Append(CPPFLAGS=['-UNDEBUG']) + env.Append(CCFLAGS=["-Os"]) + env.Append(CPPDEFINES=["NDEBUG"]) + env.Append(LINKFLAGS=["-Os"]) + + if can_vectorize: + env.Append(CCFLAGS=["-ftree-vectorize"]) + if env["target"] == "release_debug": + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + elif env["target"] == "debug": + env.Append(LINKFLAGS=["-O0"]) + env.Append(CCFLAGS=["-O0", "-g", "-fno-limit-debug-info"]) + env.Append(CPPDEFINES=["_DEBUG", "DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) + env.Append(CPPFLAGS=["-UNDEBUG"]) # Compiler configuration - env['SHLIBSUFFIX'] = '.so' + env["SHLIBSUFFIX"] = ".so" - if env['PLATFORM'] == 'win32': - env.Tool('gcc') + if env["PLATFORM"] == "win32": + env.Tool("gcc") env.use_windows_spawn_fix() - if (sys.platform.startswith("linux")): + if sys.platform.startswith("linux"): host_subpath = "linux-x86_64" - elif (sys.platform.startswith("darwin")): + elif sys.platform.startswith("darwin"): host_subpath = "darwin-x86_64" - elif (sys.platform.startswith('win')): - if (platform.machine().endswith('64')): + elif sys.platform.startswith("win"): + if platform.machine().endswith("64"): host_subpath = "windows-x86_64" else: host_subpath = "windows" @@ -179,22 +190,22 @@ def configure(env): tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin" # For Clang to find NDK tools in preference of those system-wide - env.PrependENVPath('PATH', tools_path) + env.PrependENVPath("PATH", tools_path) ccache_path = os.environ.get("CCACHE") if ccache_path is None: - env['CC'] = compiler_path + '/clang' - env['CXX'] = compiler_path + '/clang++' + env["CC"] = compiler_path + "/clang" + env["CXX"] = compiler_path + "/clang++" else: # there aren't any ccache wrappers available for Android, # to enable caching we need to prepend the path to the ccache binary - env['CC'] = ccache_path + ' ' + compiler_path + '/clang' - env['CXX'] = ccache_path + ' ' + compiler_path + '/clang++' - env['AR'] = tools_path + "/ar" - env['RANLIB'] = tools_path + "/ranlib" - env['AS'] = tools_path + "/as" + env["CC"] = ccache_path + " " + compiler_path + "/clang" + env["CXX"] = ccache_path + " " + compiler_path + "/clang++" + env["AR"] = tools_path + "/ar" + env["RANLIB"] = tools_path + "/ranlib" + env["AS"] = tools_path + "/as" - common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path] + common_opts = ["-fno-integrated-as", "-gcc-toolchain", gcc_toolchain_path] # Compile flags @@ -202,14 +213,14 @@ def configure(env): env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"]) # Disable exceptions and rtti on non-tools (template) builds - if env['tools']: - env.Append(CXXFLAGS=['-frtti']) + if env["tools"]: + env.Append(CXXFLAGS=["-frtti"]) else: - env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions']) + env.Append(CXXFLAGS=["-fno-rtti", "-fno-exceptions"]) # Don't use dynamic_cast, necessary with no-rtti. - env.Append(CPPDEFINES=['NO_SAFE_CAST']) + env.Append(CPPDEFINES=["NO_SAFE_CAST"]) - lib_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env['ndk_platform'] + "/" + env['ARCH'] + lib_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env["ndk_platform"] + "/" + env["ARCH"] # Using NDK unified headers (NDK r15+) sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot" @@ -217,35 +228,37 @@ def configure(env): env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath]) env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/android/support/include"]) # For unified headers this define has to be set manually - env.Append(CPPDEFINES=[('__ANDROID_API__', str(get_platform(env['ndk_platform'])))]) + env.Append(CPPDEFINES=[("__ANDROID_API__", str(get_platform(env["ndk_platform"])))]) - env.Append(CCFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) - env.Append(CPPDEFINES=['NO_STATVFS', 'GLES_ENABLED']) + env.Append( + CCFLAGS="-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing".split() + ) + env.Append(CPPDEFINES=["NO_STATVFS", "GLES_ENABLED"]) - env['neon_enabled'] = False - if env['android_arch'] == 'x86': - target_opts = ['-target', 'i686-none-linux-android'] + env["neon_enabled"] = False + if env["android_arch"] == "x86": + target_opts = ["-target", "i686-none-linux-android"] # The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least - env.Append(CCFLAGS=['-mstackrealign']) + env.Append(CCFLAGS=["-mstackrealign"]) - elif env['android_arch'] == 'x86_64': - target_opts = ['-target', 'x86_64-none-linux-android'] + elif env["android_arch"] == "x86_64": + target_opts = ["-target", "x86_64-none-linux-android"] elif env["android_arch"] == "armv7": - target_opts = ['-target', 'armv7-none-linux-androideabi'] - env.Append(CCFLAGS='-march=armv7-a -mfloat-abi=softfp'.split()) - env.Append(CPPDEFINES=['__ARM_ARCH_7__', '__ARM_ARCH_7A__']) - if env['android_neon']: - env['neon_enabled'] = True - env.Append(CCFLAGS=['-mfpu=neon']) - env.Append(CPPDEFINES=['__ARM_NEON__']) + target_opts = ["-target", "armv7-none-linux-androideabi"] + env.Append(CCFLAGS="-march=armv7-a -mfloat-abi=softfp".split()) + env.Append(CPPDEFINES=["__ARM_ARCH_7__", "__ARM_ARCH_7A__"]) + if env["android_neon"]: + env["neon_enabled"] = True + env.Append(CCFLAGS=["-mfpu=neon"]) + env.Append(CPPDEFINES=["__ARM_NEON__"]) else: - env.Append(CCFLAGS=['-mfpu=vfpv3-d16']) + env.Append(CCFLAGS=["-mfpu=vfpv3-d16"]) elif env["android_arch"] == "arm64v8": - target_opts = ['-target', 'aarch64-none-linux-android'] - env.Append(CCFLAGS=['-mfix-cortex-a53-835769']) - env.Append(CPPDEFINES=['__ARM_ARCH_8A__']) + target_opts = ["-target", "aarch64-none-linux-android"] + env.Append(CCFLAGS=["-mfix-cortex-a53-835769"]) + env.Append(CPPDEFINES=["__ARM_ARCH_8A__"]) env.Append(CCFLAGS=target_opts) env.Append(CCFLAGS=common_opts) @@ -254,29 +267,55 @@ def configure(env): ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"): - env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a', '-Wl,--exclude-libs,libatomic.a', '-nostdlib++']) + env.Append(LINKFLAGS=["-Wl,--exclude-libs,libgcc.a", "-Wl,--exclude-libs,libatomic.a", "-nostdlib++"]) else: - env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libandroid_support.a"]) - env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) + env.Append( + LINKFLAGS=[ + env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libandroid_support.a" + ] + ) + env.Append(LINKFLAGS=["-shared", "--sysroot=" + lib_sysroot, "-Wl,--warn-shared-textrel"]) env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/"]) - env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libc++_shared.so"]) + env.Append( + LINKFLAGS=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/" + arch_subpath + "/libc++_shared.so"] + ) if env["android_arch"] == "armv7": - env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split()) - env.Append(LINKFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'.split()) - env.Append(LINKFLAGS='-Wl,-soname,libgodot_android.so -Wl,--gc-sections'.split()) + env.Append(LINKFLAGS="-Wl,--fix-cortex-a8".split()) + env.Append(LINKFLAGS="-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now".split()) + env.Append(LINKFLAGS="-Wl,-soname,libgodot_android.so -Wl,--gc-sections".split()) env.Append(LINKFLAGS=target_opts) env.Append(LINKFLAGS=common_opts) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/' + target_subpath + '/prebuilt/' + - host_subpath + '/lib/gcc/' + abi_subpath + '/4.9.x']) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + - '/toolchains/' + target_subpath + '/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib']) - - env.Prepend(CPPPATH=['#platform/android']) - env.Append(CPPDEFINES=['ANDROID_ENABLED', 'UNIX_ENABLED', 'NO_FCNTL']) - env.Append(LIBS=['OpenSLES', 'EGL', 'GLESv3', 'GLESv2', 'android', 'log', 'z', 'dl']) + env.Append( + LIBPATH=[ + env["ANDROID_NDK_ROOT"] + + "/toolchains/" + + target_subpath + + "/prebuilt/" + + host_subpath + + "/lib/gcc/" + + abi_subpath + + "/4.9.x" + ] + ) + env.Append( + LIBPATH=[ + env["ANDROID_NDK_ROOT"] + + "/toolchains/" + + target_subpath + + "/prebuilt/" + + host_subpath + + "/" + + abi_subpath + + "/lib" + ] + ) + + env.Prepend(CPPPATH=["#platform/android"]) + env.Append(CPPDEFINES=["ANDROID_ENABLED", "UNIX_ENABLED", "NO_FCNTL"]) + env.Append(LIBS=["OpenSLES", "EGL", "GLESv3", "GLESv2", "android", "log", "z", "dl"]) # Return NDK version string in source.properties (adapted from the Chromium project). diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index ebcac884db..f8571e6277 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -34,12 +34,12 @@ #include "string_android.h" #include "thread_jandroid.h" -jobject DirAccessJAndroid::io = NULL; -jclass DirAccessJAndroid::cls = NULL; -jmethodID DirAccessJAndroid::_dir_open = NULL; -jmethodID DirAccessJAndroid::_dir_next = NULL; -jmethodID DirAccessJAndroid::_dir_close = NULL; -jmethodID DirAccessJAndroid::_dir_is_dir = NULL; +jobject DirAccessJAndroid::io = nullptr; +jclass DirAccessJAndroid::cls = nullptr; +jmethodID DirAccessJAndroid::_dir_open = nullptr; +jmethodID DirAccessJAndroid::_dir_next = nullptr; +jmethodID DirAccessJAndroid::_dir_close = nullptr; +jmethodID DirAccessJAndroid::_dir_is_dir = nullptr; DirAccess *DirAccessJAndroid::create_fs() { diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index e7d4bc6c51..b6c30d120c 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -194,7 +194,7 @@ static const char *android_perms[] = { "WRITE_SOCIAL_STREAM", "WRITE_SYNC_SETTINGS", "WRITE_USER_DICTIONARY", - NULL + nullptr }; struct LauncherIcon { @@ -274,7 +274,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { List<String> args; args.push_back("devices"); int ec; - OS::get_singleton()->execute(adb, args, true, NULL, &devices, &ec); + OS::get_singleton()->execute(adb, args, true, nullptr, &devices, &ec); Vector<String> ds = devices.split("\n"); Vector<String> ldevices; @@ -332,7 +332,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { int ec2; String dp; - OS::get_singleton()->execute(adb, args, true, NULL, &dp, &ec2); + OS::get_singleton()->execute(adb, args, true, nullptr, &dp, &ec2); Vector<String> props = dp.split("\n"); String vendor; @@ -447,7 +447,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { return pname; } - bool is_package_name_valid(const String &p_package, String *r_error = NULL) const { + bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const { String pname = p_package; @@ -537,7 +537,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { ".scn", // Binary scenes are usually already compressed ".stex", // Streamable textures are usually already compressed // Trailer for easier processing - NULL + nullptr }; for (const char **ext = unconditional_compress_ext; *ext; ++ext) { @@ -591,11 +591,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { zipOpenNewFileInZip(ed->apk, p_path.utf8().get_data(), &zipfi, - NULL, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, compression_method, Z_DEFAULT_COMPRESSION); @@ -1530,7 +1530,7 @@ public: args.push_back("uninstall"); args.push_back(get_package_name(package_name)); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); } print_line("Installing to device (please wait...): " + devices[p_device].name); @@ -1545,7 +1545,7 @@ public: args.push_back("-r"); args.push_back(tmp_export_path); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); if (err || rv != 0) { EditorNode::add_io_error("Could not install to device."); CLEANUP_AND_RETURN(ERR_CANT_CREATE); @@ -1563,7 +1563,7 @@ public: args.push_back(devices[p_device].id); args.push_back("reverse"); args.push_back("--remove-all"); - OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) { @@ -1575,7 +1575,7 @@ public: args.push_back("tcp:" + itos(dbg_port)); args.push_back("tcp:" + itos(dbg_port)); - OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); print_line("Reverse result: " + itos(rv)); } @@ -1590,7 +1590,7 @@ public: args.push_back("tcp:" + itos(fs_port)); args.push_back("tcp:" + itos(fs_port)); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); print_line("Reverse result2: " + itos(rv)); } } else { @@ -1619,7 +1619,7 @@ public: args.push_back("-n"); args.push_back(get_package_name(package_name) + "/com.godot.game.GodotApp"); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + err = OS::get_singleton()->execute(adb, args, true, nullptr, nullptr, &rv); if (err || rv != 0) { EditorNode::add_io_error("Could not execute on device."); CLEANUP_AND_RETURN(ERR_CANT_CREATE); @@ -1806,7 +1806,7 @@ public: /*{ used for debug int ec; String pipe; - OS::get_singleton()->execute(build_command, cmdline, true, NULL, NULL, &ec); + OS::get_singleton()->execute(build_command, cmdline, true, nullptr, nullptr, &ec); print_line("exit code: " + itos(ec)); } */ @@ -1851,7 +1851,7 @@ public: return ERR_FILE_BAD_PATH; } - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); if (ep.step("Creating APK...", 0)) { @@ -1868,7 +1868,7 @@ public: int ret = unzGoToFirstFile(pkg); zlib_filefunc_def io2 = io; - FileAccess *dst_f = NULL; + FileAccess *dst_f = nullptr; io2.opaque = &dst_f; String tmp_unaligned_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned.apk"); @@ -1879,7 +1879,7 @@ public: return m_err; \ } - zipFile unaligned_apk = zipOpen2(tmp_unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2); + zipFile unaligned_apk = zipOpen2(tmp_unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2); bool use_32_fb = p_preset->get("graphics/32_bits_framebuffer"); bool immersive = p_preset->get("screen/immersive_mode"); @@ -1937,7 +1937,7 @@ public: //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); bool skip = false; @@ -2001,11 +2001,11 @@ public: zipOpenNewFileInZip(unaligned_apk, file.utf8().get_data(), &zipfi, - NULL, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, uncompressed ? 0 : Z_DEFLATED, Z_DEFAULT_COMPRESSION); @@ -2108,11 +2108,11 @@ public: zipOpenNewFileInZip(unaligned_apk, "assets/_cl_", &zipfi, - NULL, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, 0, // No compress (little size gain and potentially slower startup) Z_DEFAULT_COMPRESSION); @@ -2120,7 +2120,7 @@ public: zipCloseFileInZip(unaligned_apk); } - zipClose(unaligned_apk, NULL); + zipClose(unaligned_apk, nullptr); unzClose(pkg); if (err != OK) { @@ -2188,7 +2188,7 @@ public: args.push_back(tmp_unaligned_path); args.push_back(user); int retval; - OS::get_singleton()->execute(jarsigner, args, true, NULL, NULL, &retval); + OS::get_singleton()->execute(jarsigner, args, true, nullptr, nullptr, &retval); if (retval) { EditorNode::add_io_error("'jarsigner' returned with error #" + itos(retval)); CLEANUP_AND_RETURN(ERR_CANT_CREATE); @@ -2205,7 +2205,7 @@ public: args.push_back(tmp_unaligned_path); args.push_back("-verbose"); - OS::get_singleton()->execute(jarsigner, args, true, NULL, NULL, &retval); + OS::get_singleton()->execute(jarsigner, args, true, nullptr, nullptr, &retval); if (retval) { EditorNode::add_io_error("'jarsigner' verification of APK failed. Make sure to use a jarsigner from OpenJDK 8."); CLEANUP_AND_RETURN(ERR_CANT_CREATE); @@ -2230,9 +2230,9 @@ public: ret = unzGoToFirstFile(tmp_unaligned); io2 = io; - dst_f = NULL; + dst_f = nullptr; io2.opaque = &dst_f; - zipFile final_apk = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2); + zipFile final_apk = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2); // Take files from the unaligned APK and write them out to the aligned one // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed, @@ -2245,7 +2245,7 @@ public: char fname[16384]; char extra[16384]; - ret = unzGetCurrentFileInfo(tmp_unaligned, &info, fname, 16384, extra, 16384 - ZIP_ALIGNMENT, NULL, 0); + ret = unzGetCurrentFileInfo(tmp_unaligned, &info, fname, 16384, extra, 16384 - ZIP_ALIGNMENT, nullptr, 0); String file = fname; @@ -2277,9 +2277,9 @@ public: &zipfi, extra, info.size_file_extra + padding, - NULL, + nullptr, 0, - NULL, + nullptr, method, level, 1); // raw write @@ -2291,7 +2291,7 @@ public: ret = unzGoToNextFile(tmp_unaligned); } - zipClose(final_apk, NULL); + zipClose(final_apk, nullptr); unzClose(tmp_unaligned); CLEANUP_AND_RETURN(OK); diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 965342b364..fa805ec4f3 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -31,7 +31,7 @@ #include "file_access_android.h" #include "core/print_string.h" -AAssetManager *FileAccessAndroid::asset_manager = NULL; +AAssetManager *FileAccessAndroid::asset_manager = nullptr; /*void FileAccessAndroid::make_default() { @@ -68,12 +68,12 @@ void FileAccessAndroid::close() { if (!a) return; AAsset_close(a); - a = NULL; + a = nullptr; } bool FileAccessAndroid::is_open() const { - return a != NULL; + return a != nullptr; } void FileAccessAndroid::seek(size_t p_position) { @@ -175,7 +175,7 @@ bool FileAccessAndroid::file_exists(const String &p_path) { } FileAccessAndroid::FileAccessAndroid() { - a = NULL; + a = nullptr; eof = false; } diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index db3aa4255e..e088eca8ef 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -33,7 +33,7 @@ #include "thread_jandroid.h" #include <unistd.h> -jobject FileAccessJAndroid::io = NULL; +jobject FileAccessJAndroid::io = nullptr; jclass FileAccessJAndroid::cls; jmethodID FileAccessJAndroid::_file_open = 0; jmethodID FileAccessJAndroid::_file_get_size = 0; diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle index eaaefcbccb..96cfd272f2 100644 --- a/platform/android/java/app/config.gradle +++ b/platform/android/java/app/config.gradle @@ -1,5 +1,5 @@ ext.versions = [ - androidGradlePlugin: '3.6.0', + androidGradlePlugin: '3.5.3', compileSdk : 29, minSdk : 18, targetSdk : 29, diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java index e745cdd0a5..e3683704e1 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java index b6d949b7bf..e13a9c15d8 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPluginRegistry.java @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 13550c4b11..6b9105b8e5 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -40,7 +40,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, JNIEnv *env = ThreadAndroid::get_env(); - MethodInfo *method = NULL; + MethodInfo *method = nullptr; for (List<MethodInfo>::Element *E = M->get().front(); E; E = E->next()) { if (!p_instance && !E->get()._static) { @@ -160,7 +160,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, r_error.error = Callable::CallError::CALL_OK; - jvalue *argv = NULL; + jvalue *argv = nullptr; if (method->param_types.size()) { @@ -173,7 +173,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, switch (method->param_types[i]) { case ARG_TYPE_VOID: { //can't happen - argv[i].l = NULL; //I hope this works + argv[i].l = nullptr; //I hope this works } break; case ARG_TYPE_BOOLEAN: { @@ -285,7 +285,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, argv[i].l = jo->instance; } else { - argv[i].l = NULL; //I hope this works + argv[i].l = nullptr; //I hope this works } } break; @@ -386,7 +386,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, case ARG_ARRAY_BIT | ARG_TYPE_STRING: { Array arr = *p_args[i]; - jobjectArray a = env->NewObjectArray(arr.size(), env->FindClass("java/lang/String"), NULL); + jobjectArray a = env->NewObjectArray(arr.size(), env->FindClass("java/lang/String"), nullptr); for (int j = 0; j < arr.size(); j++) { String s = arr[j]; @@ -400,7 +400,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, } break; case ARG_ARRAY_BIT | ARG_TYPE_CLASS: { - argv[i].l = NULL; + argv[i].l = nullptr; } break; } } @@ -520,7 +520,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, Variant JavaClass::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { Variant ret; - bool found = _call_method(NULL, p_method, p_args, p_argcount, r_error, ret); + bool found = _call_method(nullptr, p_method, p_args, p_argcount, r_error, ret); if (found) { return ret; } @@ -1205,7 +1205,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { int mods = env->CallIntMethod(obj, Field_getModifiers); if ((mods & 0x8) && (mods & 0x10) && (mods & 0x1)) { //static final public! - jobject objc = env->CallObjectMethod(obj, Field_get, NULL); + jobject objc = env->CallObjectMethod(obj, Field_get, nullptr); if (objc) { uint32_t sig; @@ -1236,7 +1236,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { return Ref<JavaClass>(); } -JavaClassWrapper *JavaClassWrapper::singleton = NULL; +JavaClassWrapper *JavaClassWrapper::singleton = nullptr; JavaClassWrapper::JavaClassWrapper(jobject p_activity) { diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index e018ee69f0..9d44ab4619 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -52,10 +52,10 @@ #include <unistd.h> -static JavaClassWrapper *java_class_wrapper = NULL; -static OS_Android *os_android = NULL; -static GodotJavaWrapper *godot_java = NULL; -static GodotIOJavaWrapper *godot_io_java = NULL; +static JavaClassWrapper *java_class_wrapper = nullptr; +static OS_Android *os_android = nullptr; +static GodotJavaWrapper *godot_java = nullptr; +static GodotIOJavaWrapper *godot_io_java = nullptr; static bool initialized = false; static int step = 0; @@ -123,14 +123,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ondestroy(JNIEnv *env JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jclass clazz, jobjectArray p_cmdline) { ThreadAndroid::setup_thread(); - const char **cmdline = NULL; - jstring *j_cmdline = NULL; + const char **cmdline = nullptr; + jstring *j_cmdline = nullptr; int cmdlen = 0; if (p_cmdline) { cmdlen = env->GetArrayLength(p_cmdline); if (cmdlen) { cmdline = (const char **)malloc((cmdlen + 1) * sizeof(const char *)); - cmdline[cmdlen] = NULL; + cmdline[cmdlen] = nullptr; j_cmdline = (jstring *)malloc(cmdlen * sizeof(jstring)); for (int i = 0; i < cmdlen; i++) { @@ -430,7 +430,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en obj->call(str_method, (const Variant **)vptr, count, err); // something - env->PopLocalFrame(NULL); + env->PopLocalFrame(nullptr); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jclass clazz, jint ID, jstring method, jobjectArray params) { @@ -456,7 +456,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * obj->call_deferred(str_method, args[0], args[1], args[2], args[3], args[4]); // something - env->PopLocalFrame(NULL); + env->PopLocalFrame(nullptr); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) { diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index 2a540bb4a9..8ef99dfab0 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -80,13 +80,13 @@ jobject GodotJavaWrapper::get_activity() { jobject GodotJavaWrapper::get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env) { if (cls) { - if (p_env == NULL) + if (p_env == nullptr) p_env = ThreadAndroid::get_env(); jfieldID fid = p_env->GetStaticFieldID(cls, p_name, p_class); return p_env->GetStaticObjectField(cls, fid); } else { - return NULL; + return nullptr; } } @@ -96,13 +96,13 @@ jobject GodotJavaWrapper::get_class_loader() { jmethodID getClassLoader = env->GetMethodID(cls, "getClassLoader", "()Ljava/lang/ClassLoader;"); return env->CallObjectMethod(godot_instance, getClassLoader); } else { - return NULL; + return nullptr; } } void GodotJavaWrapper::on_video_init(JNIEnv *p_env) { if (_on_video_init) - if (p_env == NULL) + if (p_env == nullptr) p_env = ThreadAndroid::get_env(); p_env->CallVoidMethod(godot_instance, _on_video_init); @@ -110,7 +110,7 @@ void GodotJavaWrapper::on_video_init(JNIEnv *p_env) { void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) { if (_on_godot_main_loop_started) { - if (p_env == NULL) { + if (p_env == nullptr) { p_env = ThreadAndroid::get_env(); } } @@ -119,7 +119,7 @@ void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) { void GodotJavaWrapper::restart(JNIEnv *p_env) { if (_restart) - if (p_env == NULL) + if (p_env == nullptr) p_env = ThreadAndroid::get_env(); p_env->CallVoidMethod(godot_instance, _restart); @@ -127,7 +127,7 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) { void GodotJavaWrapper::force_quit(JNIEnv *p_env) { if (_finish) - if (p_env == NULL) + if (p_env == nullptr) p_env = ThreadAndroid::get_env(); p_env->CallVoidMethod(godot_instance, _finish); @@ -244,7 +244,7 @@ jobject GodotJavaWrapper::get_surface() { JNIEnv *env = ThreadAndroid::get_env(); return env->CallObjectMethod(godot_instance, _get_surface); } else { - return NULL; + return nullptr; } } diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h index fb77c8ba6a..89d6b6db46 100644 --- a/platform/android/java_godot_wrapper.h +++ b/platform/android/java_godot_wrapper.h @@ -68,14 +68,14 @@ public: ~GodotJavaWrapper(); jobject get_activity(); - jobject get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env = NULL); + jobject get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env = nullptr); jobject get_class_loader(); - void on_video_init(JNIEnv *p_env = NULL); - void on_godot_main_loop_started(JNIEnv *p_env = NULL); - void restart(JNIEnv *p_env = NULL); - void force_quit(JNIEnv *p_env = NULL); + void on_video_init(JNIEnv *p_env = nullptr); + void on_godot_main_loop_started(JNIEnv *p_env = nullptr); + void restart(JNIEnv *p_env = nullptr); + void force_quit(JNIEnv *p_env = nullptr); void set_keep_screen_on(bool p_enabled); void alert(const String &p_message, const String &p_title); int get_gles_version_code(); diff --git a/platform/android/jni_utils.cpp b/platform/android/jni_utils.cpp index 3fa4e80884..ded79a668f 100644 --- a/platform/android/jni_utils.cpp +++ b/platform/android/jni_utils.cpp @@ -130,7 +130,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a env->CallVoidMethodA(jdict, set_keys, &val); env->DeleteLocalRef(jkeys); - jobjectArray jvalues = env->NewObjectArray(keys.size(), env->FindClass("java/lang/Object"), NULL); + jobjectArray jvalues = env->NewObjectArray(keys.size(), env->FindClass("java/lang/Object"), nullptr); for (int j = 0; j < keys.size(); j++) { Variant var = dict[keys[j]]; @@ -211,7 +211,7 @@ String _get_class_name(JNIEnv *env, jclass cls, bool *array) { Variant _jobject_to_variant(JNIEnv *env, jobject obj) { - if (obj == NULL) { + if (obj == nullptr) { return Variant(); } @@ -384,7 +384,7 @@ Variant::Type get_jni_type(const String &p_type) { { "[F", Variant::PACKED_FLOAT32_ARRAY }, { "[Ljava.lang.String;", Variant::PACKED_STRING_ARRAY }, { "org.godotengine.godot.Dictionary", Variant::DICTIONARY }, - { NULL, Variant::NIL } + { nullptr, Variant::NIL } }; int idx = 0; @@ -417,7 +417,7 @@ const char *get_jni_sig(const String &p_type) { { "[B", "[B" }, { "[F", "[F" }, { "[Ljava.lang.String;", "[Ljava/lang/String;" }, - { NULL, "V" } + { nullptr, "V" } }; int idx = 0; diff --git a/platform/android/jni_utils.h b/platform/android/jni_utils.h index 925340a680..b9ee243308 100644 --- a/platform/android/jni_utils.h +++ b/platform/android/jni_utils.h @@ -40,7 +40,7 @@ struct jvalret { jobject obj; jvalue val; - jvalret() { obj = NULL; } + jvalret() { obj = nullptr; } }; jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_arg, bool force_jobject = false); @@ -106,7 +106,7 @@ public: } } - jvalue *v = NULL; + jvalue *v = nullptr; if (p_argcount) { @@ -201,7 +201,7 @@ public: } break; default: { - env->PopLocalFrame(NULL); + env->PopLocalFrame(nullptr); ERR_FAIL_V(Variant()); } break; } @@ -211,7 +211,7 @@ public: to_erase.pop_front(); } - env->PopLocalFrame(NULL); + env->PopLocalFrame(nullptr); return ret; } @@ -235,7 +235,7 @@ public: } JNISingleton() { - instance = NULL; + instance = nullptr; } }; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index e3792b1f31..344377d673 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -39,8 +39,8 @@ #include "drivers/unix/file_access_unix.h" #include "file_access_android.h" #include "main/main.h" -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "servers/rendering/rendering_server_raster.h" +#include "servers/rendering/rendering_server_wrap_mt.h" #include "dir_access_jandroid.h" #include "file_access_jandroid.h" @@ -71,7 +71,7 @@ const char *OS_Android::get_video_driver_name(int p_driver) const { case VIDEO_DRIVER_GLES2: return "GLES2"; } - ERR_FAIL_V_MSG(NULL, "Invalid video driver index: " + itos(p_driver) + "."); + ERR_FAIL_V_MSG(nullptr, "Invalid video driver index: " + itos(p_driver) + "."); } int OS_Android::get_audio_driver_count() const { @@ -146,12 +146,12 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int video_driver_index = p_video_driver; - visual_server = memnew(VisualServerRaster); + rendering_server = memnew(RenderingServerRaster); if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, false)); + rendering_server = memnew(RenderingServerWrapMT(rendering_server, false)); } - visual_server->init(); + rendering_server->init(); AudioDriverManager::initialize(p_audio_driver); @@ -754,12 +754,12 @@ OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_god default_videomode.fullscreen = true; default_videomode.resizable = false; - main_loop = NULL; - gl_extensions = NULL; - //rasterizer = NULL; + main_loop = nullptr; + gl_extensions = nullptr; + //rasterizer = nullptr; use_gl2 = false; - visual_server = NULL; + rendering_server = nullptr; godot_java = p_godot_java; godot_io_java = p_godot_io_java; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index d09f4e10d6..8a91412ef6 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -37,7 +37,7 @@ #include "core/os/main_loop.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/rendering/rasterizer.h" class GodotJavaWrapper; class GodotIOJavaWrapper; @@ -75,7 +75,7 @@ private: bool use_16bits_fbo; - VisualServer *visual_server; + RenderingServer *rendering_server; mutable String data_dir_cache; diff --git a/platform/android/string_android.h b/platform/android/string_android.h index 51c488c8cc..88ccd3b652 100644 --- a/platform/android/string_android.h +++ b/platform/android/string_android.h @@ -40,13 +40,13 @@ * @param env JNI environment instance. If null obtained by ThreadAndroid::get_env(). * @return Godot string instance. */ -static inline String jstring_to_string(jstring source, JNIEnv *env = NULL) { +static inline String jstring_to_string(jstring source, JNIEnv *env = nullptr) { String result; if (source) { if (!env) { env = ThreadAndroid::get_env(); } - const char *const source_utf8 = env->GetStringUTFChars(source, NULL); + const char *const source_utf8 = env->GetStringUTFChars(source, nullptr); if (source_utf8) { result.parse_utf8(source_utf8); env->ReleaseStringUTFChars(source, source_utf8); diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 98b61ad755..729327f6f0 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -66,7 +66,7 @@ void *ThreadAndroid::thread_callback(void *userdata) { pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id))); t->callback(t->user); ScriptServer::thread_exit(); - return NULL; + return nullptr; } Thread *ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback, void *p_user, const Settings &) { @@ -100,7 +100,7 @@ void ThreadAndroid::wait_to_finish_func_jandroid(Thread *p_thread) { ERR_FAIL_COND(!tp); ERR_FAIL_COND(tp->pthread == 0); - pthread_join(tp->pthread, NULL); + pthread_join(tp->pthread, nullptr); tp->pthread = 0; } @@ -108,21 +108,21 @@ void ThreadAndroid::_thread_destroyed(void *value) { /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ JNIEnv *env = (JNIEnv *)value; - if (env != NULL) { + if (env != nullptr) { java_vm->DetachCurrentThread(); - pthread_setspecific(jvm_key, NULL); + pthread_setspecific(jvm_key, nullptr); } } pthread_key_t ThreadAndroid::jvm_key; -JavaVM *ThreadAndroid::java_vm = NULL; +JavaVM *ThreadAndroid::java_vm = nullptr; void ThreadAndroid::setup_thread() { if (pthread_getspecific(jvm_key)) return; //already setup JNIEnv *env; - java_vm->AttachCurrentThread(&env, NULL); + java_vm->AttachCurrentThread(&env, nullptr); pthread_setspecific(jvm_key, (void *)env); } @@ -142,8 +142,8 @@ JNIEnv *ThreadAndroid::get_env() { setup_thread(); } - JNIEnv *env = NULL; - java_vm->AttachCurrentThread(&env, NULL); + JNIEnv *env = nullptr; + java_vm->AttachCurrentThread(&env, nullptr); return env; } diff --git a/platform/haiku/SCsub b/platform/haiku/SCsub index 592f56bbbf..dbff6c5ae9 100644 --- a/platform/haiku/SCsub +++ b/platform/haiku/SCsub @@ -1,28 +1,25 @@ #!/usr/bin/env python -Import('env') +Import("env") common_haiku = [ - 'os_haiku.cpp', - 'context_gl_haiku.cpp', - 'haiku_application.cpp', - 'haiku_direct_window.cpp', - 'haiku_gl_view.cpp', - 'key_mapping_haiku.cpp', - 'audio_driver_media_kit.cpp' + "os_haiku.cpp", + "context_gl_haiku.cpp", + "haiku_application.cpp", + "haiku_direct_window.cpp", + "haiku_gl_view.cpp", + "key_mapping_haiku.cpp", + "audio_driver_media_kit.cpp", ] -target = env.add_program( - '#bin/godot', - ['godot_haiku.cpp'] + common_haiku -) +target = env.add_program("#bin/godot", ["godot_haiku.cpp"] + common_haiku) -command = env.Command('#bin/godot.rsrc', '#platform/haiku/godot.rdef', - ['rc -o $TARGET $SOURCE']) +command = env.Command("#bin/godot.rsrc", "#platform/haiku/godot.rdef", ["rc -o $TARGET $SOURCE"]) def addResourcesAction(target=None, source=None, env=None): - return env.Execute('xres -o ' + File(target)[0].path + ' bin/godot.rsrc') + return env.Execute("xres -o " + File(target)[0].path + " bin/godot.rsrc") + env.AddPostAction(target, addResourcesAction) env.Depends(target, command) diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index 0a5df14743..94c9e83368 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -34,7 +34,7 @@ #include "core/project_settings.h" -int32_t *AudioDriverMediaKit::samples_in = NULL; +int32_t *AudioDriverMediaKit::samples_in = nullptr; Error AudioDriverMediaKit::init() { active = false; @@ -59,12 +59,12 @@ Error AudioDriverMediaKit::init() { &format, "godot_sound_server", AudioDriverMediaKit::PlayBuffer, - NULL, + nullptr, this); if (player->InitCheck() != B_OK) { fprintf(stderr, "MediaKit ERR: can not create a BSoundPlayer instance\n"); - ERR_FAIL_COND_V(player == NULL, ERR_CANT_OPEN); + ERR_FAIL_COND_V(player == nullptr, ERR_CANT_OPEN); } player->Start(); @@ -126,7 +126,7 @@ void AudioDriverMediaKit::finish() { } AudioDriverMediaKit::AudioDriverMediaKit() { - player = NULL; + player = nullptr; } AudioDriverMediaKit::~AudioDriverMediaKit() { diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index dd72294816..0b84df8f9b 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -12,7 +12,7 @@ def get_name(): def can_build(): - if (os.name != "posix" or sys.platform == "darwin"): + if os.name != "posix" or sys.platform == "darwin": return False return True @@ -22,41 +22,40 @@ def get_opts(): from SCons.Variables import EnumVariable return [ - EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), + EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")), ] def get_flags(): - return [ - ] + return [] def configure(env): ## Build type - if (env["target"] == "release"): - env.Prepend(CCFLAGS=['-O3']) - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) + if env["target"] == "release": + env.Prepend(CCFLAGS=["-O3"]) + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) - elif (env["target"] == "release_debug"): - env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) + elif env["target"] == "release_debug": + env.Prepend(CCFLAGS=["-O2", "-DDEBUG_ENABLED"]) + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) - elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) + elif env["target"] == "debug": + env.Prepend(CCFLAGS=["-g3", "-DDEBUG_ENABLED", "-DDEBUG_MEMORY_ENABLED"]) ## Architecture - is64 = sys.maxsize > 2**32 - if (env["bits"] == "default"): + is64 = sys.maxsize > 2 ** 32 + if env["bits"] == "default": env["bits"] = "64" if is64 else "32" ## Compiler configuration @@ -66,89 +65,94 @@ def configure(env): ## Dependencies - if not env['builtin_libwebp']: - env.ParseConfig('pkg-config libwebp --cflags --libs') + if not env["builtin_libwebp"]: + env.ParseConfig("pkg-config libwebp --cflags --libs") # freetype depends on libpng and zlib, so bundling one of them while keeping others # as shared libraries leads to weird issues - if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']: - env['builtin_freetype'] = True - env['builtin_libpng'] = True - env['builtin_zlib'] = True + if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]: + env["builtin_freetype"] = True + env["builtin_libpng"] = True + env["builtin_zlib"] = True - if not env['builtin_freetype']: - env.ParseConfig('pkg-config freetype2 --cflags --libs') + if not env["builtin_freetype"]: + env.ParseConfig("pkg-config freetype2 --cflags --libs") - if not env['builtin_libpng']: - env.ParseConfig('pkg-config libpng16 --cflags --libs') + if not env["builtin_libpng"]: + env.ParseConfig("pkg-config libpng16 --cflags --libs") - if not env['builtin_bullet']: + if not env["builtin_bullet"]: # We need at least version 2.88 import subprocess - bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip() + + bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip() if bullet_version < "2.88": # Abort as system bullet was requested but too old - print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88")) + print( + "Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format( + bullet_version, "2.88" + ) + ) sys.exit(255) - env.ParseConfig('pkg-config bullet --cflags --libs') + env.ParseConfig("pkg-config bullet --cflags --libs") - if not env['builtin_enet']: - env.ParseConfig('pkg-config libenet --cflags --libs') + if not env["builtin_enet"]: + env.ParseConfig("pkg-config libenet --cflags --libs") - if not env['builtin_squish']: - env.ParseConfig('pkg-config libsquish --cflags --libs') + if not env["builtin_squish"]: + env.ParseConfig("pkg-config libsquish --cflags --libs") - if not env['builtin_zstd']: - env.ParseConfig('pkg-config libzstd --cflags --libs') + if not env["builtin_zstd"]: + env.ParseConfig("pkg-config libzstd --cflags --libs") # Sound and video libraries # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - if not env['builtin_libtheora']: - env['builtin_libogg'] = False # Needed to link against system libtheora - env['builtin_libvorbis'] = False # Needed to link against system libtheora - env.ParseConfig('pkg-config theora theoradec --cflags --libs') + if not env["builtin_libtheora"]: + env["builtin_libogg"] = False # Needed to link against system libtheora + env["builtin_libvorbis"] = False # Needed to link against system libtheora + env.ParseConfig("pkg-config theora theoradec --cflags --libs") - if not env['builtin_libvpx']: - env.ParseConfig('pkg-config vpx --cflags --libs') + if not env["builtin_libvpx"]: + env.ParseConfig("pkg-config vpx --cflags --libs") - if not env['builtin_libvorbis']: - env['builtin_libogg'] = False # Needed to link against system libvorbis - env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') + if not env["builtin_libvorbis"]: + env["builtin_libogg"] = False # Needed to link against system libvorbis + env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs") - if not env['builtin_opus']: - env['builtin_libogg'] = False # Needed to link against system opus - env.ParseConfig('pkg-config opus opusfile --cflags --libs') + if not env["builtin_opus"]: + env["builtin_libogg"] = False # Needed to link against system opus + env.ParseConfig("pkg-config opus opusfile --cflags --libs") - if not env['builtin_libogg']: - env.ParseConfig('pkg-config ogg --cflags --libs') + if not env["builtin_libogg"]: + env.ParseConfig("pkg-config ogg --cflags --libs") - if env['builtin_libtheora']: - list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] + if env["builtin_libtheora"]: + list_of_x86 = ["x86_64", "x86", "i386", "i586"] if any(platform.machine() in s for s in list_of_x86): env["x86_libtheora_opt_gcc"] = True - if not env['builtin_wslay']: - env.ParseConfig('pkg-config libwslay --cflags --libs') + if not env["builtin_wslay"]: + env.ParseConfig("pkg-config libwslay --cflags --libs") - if not env['builtin_mbedtls']: + if not env["builtin_mbedtls"]: # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228 - env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509']) + env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) - if not env['builtin_miniupnpc']: + if not env["builtin_miniupnpc"]: # No pkgconfig file so far, hardcode default paths. env.Prepend(CPPPATH=["/system/develop/headers/x86/miniupnpc"]) env.Append(LIBS=["miniupnpc"]) # On Linux wchar_t should be 32-bits # 16-bit library shouldn't be required due to compiler optimisations - if not env['builtin_pcre2']: - env.ParseConfig('pkg-config libpcre2-32 --cflags --libs') + if not env["builtin_pcre2"]: + env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") ## Flags - env.Prepend(CPPPATH=['#platform/haiku']) - env.Append(CPPDEFINES=['UNIX_ENABLED', 'OPENGL_ENABLED', 'GLES_ENABLED']) - env.Append(CPPDEFINES=['MEDIA_KIT_ENABLED']) - env.Append(CPPDEFINES=['PTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np - env.Append(LIBS=['be', 'game', 'media', 'network', 'bnetapi', 'z', 'GL']) + env.Prepend(CPPPATH=["#platform/haiku"]) + env.Append(CPPDEFINES=["UNIX_ENABLED", "OPENGL_ENABLED", "GLES_ENABLED"]) + env.Append(CPPDEFINES=["MEDIA_KIT_ENABLED"]) + env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"]) # TODO: enable when we have pthread_setname_np + env.Append(LIBS=["be", "game", "media", "network", "bnetapi", "z", "GL"]) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 18e1862d33..0a40f847f4 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -42,10 +42,10 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) : last_button_mask = 0; last_key_modifier_state = 0; - view = NULL; - update_runner = NULL; - input = NULL; - main_loop = NULL; + view = nullptr; + update_runner = nullptr; + input = nullptr; + main_loop = nullptr; } HaikuDirectWindow::~HaikuDirectWindow() { @@ -278,7 +278,7 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) { event->set_echo(message->HasInt32("be:key_repeat")); event->set_unicode(0); - const char *bytes = NULL; + const char *bytes = nullptr; if (message->FindString("bytes", &bytes) == B_OK) { event->set_unicode(BUnicodeChar::FromUTF8(&bytes)); } diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index a082ba53f9..07cb18d7cd 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -32,9 +32,9 @@ #include "drivers/gles2/rasterizer_gles2.h" #include "main/main.h" -#include "servers/physics/physics_server_sw.h" -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "servers/physics_3d/physics_server_3d_sw.h" +#include "servers/rendering/rendering_server_raster.h" +#include "servers/rendering/rendering_server_wrap_mt.h" #include <Screen.h> @@ -85,7 +85,7 @@ int OS_Haiku::get_current_video_driver() const { } Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { - main_loop = NULL; + main_loop = nullptr; current_video_mode = p_desired; app = new HaikuApplication(); @@ -116,13 +116,13 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p RasterizerGLES2::make_current(); #endif - visual_server = memnew(VisualServerRaster); + rendering_server = memnew(RenderingServerRaster); // FIXME: Reimplement threaded rendering if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, false)); + rendering_server = memnew(RenderingServerWrapMT(rendering_server, false)); } - ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(!rendering_server, ERR_UNAVAILABLE); video_driver_index = p_video_driver; @@ -130,7 +130,7 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p window->SetInput(input); window->Show(); - visual_server->init(); + rendering_server->init(); AudioDriverManager::initialize(p_audio_driver); @@ -142,10 +142,10 @@ void OS_Haiku::finalize() { memdelete(main_loop); } - main_loop = NULL; + main_loop = nullptr; - visual_server->finish(); - memdelete(visual_server); + rendering_server->finish(); + memdelete(rendering_server); memdelete(input); @@ -169,8 +169,8 @@ void OS_Haiku::delete_main_loop() { memdelete(main_loop); } - main_loop = NULL; - window->SetMainLoop(NULL); + main_loop = nullptr; + window->SetMainLoop(nullptr); } void OS_Haiku::release_rendering_thread() { @@ -267,7 +267,7 @@ void OS_Haiku::set_window_position(const Point2 &p_position) { void OS_Haiku::set_window_fullscreen(bool p_enabled) { window->SetFullScreen(p_enabled); current_video_mode.fullscreen = p_enabled; - visual_server->init(); + rendering_server->init(); } bool OS_Haiku::is_window_fullscreen() const { diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 90c0abc3ef..64f5690dd1 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -38,7 +38,7 @@ #include "haiku_application.h" #include "haiku_direct_window.h" #include "servers/audio_server.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class OS_Haiku : public OS_Unix { private: @@ -46,7 +46,7 @@ private: HaikuDirectWindow *window; MainLoop *main_loop; InputDefault *input; - VisualServer *visual_server; + RenderingServer *rendering_server; VideoMode current_video_mode; int video_driver_index; diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub index 1f82f51888..a48629f720 100644 --- a/platform/iphone/SCsub +++ b/platform/iphone/SCsub @@ -1,31 +1,35 @@ #!/usr/bin/env python -Import('env') +Import("env") iphone_lib = [ - 'godot_iphone.cpp', - 'os_iphone.cpp', - 'semaphore_iphone.cpp', - 'gl_view.mm', - 'main.m', - 'app_delegate.mm', - 'view_controller.mm', - 'game_center.mm', - 'in_app_store.mm', - 'icloud.mm', - 'ios.mm', - 'vulkan_context_iphone.mm', + "godot_iphone.cpp", + "os_iphone.cpp", + "semaphore_iphone.cpp", + "gl_view.mm", + "main.m", + "app_delegate.mm", + "view_controller.mm", + "game_center.mm", + "in_app_store.mm", + "icloud.mm", + "ios.mm", + "vulkan_context_iphone.mm", ] env_ios = env.Clone() -ios_lib = env_ios.add_library('iphone', iphone_lib) +ios_lib = env_ios.add_library("iphone", iphone_lib) + def combine_libs(target=None, source=None, env=None): lib_path = target[0].srcnode().abspath if "osxcross" in env: - libtool = '$IPHONEPATH/usr/bin/${ios_triple}libtool' + libtool = "$IPHONEPATH/usr/bin/${ios_triple}libtool" else: libtool = "$IPHONEPATH/usr/bin/libtool" - env.Execute(libtool + ' -static -o "' + lib_path + '" ' + ' '.join([('"' + lib.srcnode().abspath + '"') for lib in source])) + env.Execute( + libtool + ' -static -o "' + lib_path + '" ' + " ".join([('"' + lib.srcnode().abspath + '"') for lib in source]) + ) + -combine_command = env_ios.Command('#bin/libgodot' + env_ios['LIBSUFFIX'], [ios_lib] + env_ios['LIBS'], combine_libs) +combine_command = env_ios.Command("#bin/libgodot" + env_ios["LIBSUFFIX"], [ios_lib] + env_ios["LIBS"], combine_libs) diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index e01950c1db..3e6c2f0ecf 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -2,6 +2,7 @@ import os import sys from methods import detect_darwin_sdk_path + def is_active(): return True @@ -12,7 +13,7 @@ def get_name(): def can_build(): - if sys.platform == 'darwin' or ("OSXCROSS_IOS" in os.environ): + if sys.platform == "darwin" or ("OSXCROSS_IOS" in os.environ): return True return False @@ -20,22 +21,31 @@ def can_build(): def get_opts(): from SCons.Variables import BoolVariable + return [ - ('IPHONEPATH', 'Path to iPhone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'), - ('IPHONESDK', 'Path to the iPhone SDK', ''), - BoolVariable('use_static_mvk', 'Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables validation layers)', False), - BoolVariable('game_center', 'Support for game center', True), - BoolVariable('store_kit', 'Support for in-app store', True), - BoolVariable('icloud', 'Support for iCloud', True), - BoolVariable('ios_exceptions', 'Enable exceptions', False), - ('ios_triple', 'Triple for ios toolchain', ''), + ( + "IPHONEPATH", + "Path to iPhone toolchain", + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain", + ), + ("IPHONESDK", "Path to the iPhone SDK", ""), + BoolVariable( + "use_static_mvk", + "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables validation layers)", + False, + ), + BoolVariable("game_center", "Support for game center", True), + BoolVariable("store_kit", "Support for in-app store", True), + BoolVariable("icloud", "Support for iCloud", True), + BoolVariable("ios_exceptions", "Enable exceptions", False), + ("ios_triple", "Triple for ios toolchain", ""), ] def get_flags(): return [ - ('tools', False), + ("tools", False), ] @@ -43,32 +53,32 @@ def configure(env): ## Build type - if (env["target"].startswith("release")): - env.Append(CPPDEFINES=['NDEBUG', ('NS_BLOCK_ASSERTIONS', 1)]) - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Append(CCFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer']) - env.Append(LINKFLAGS=['-O2']) - else: #optimize for size - env.Append(CCFLAGS=['-Os', '-ftree-vectorize']) - env.Append(LINKFLAGS=['-Os']) + if env["target"].startswith("release"): + env.Append(CPPDEFINES=["NDEBUG", ("NS_BLOCK_ASSERTIONS", 1)]) + if env["optimize"] == "speed": # optimize for speed (default) + env.Append(CCFLAGS=["-O2", "-ftree-vectorize", "-fomit-frame-pointer"]) + env.Append(LINKFLAGS=["-O2"]) + else: # optimize for size + env.Append(CCFLAGS=["-Os", "-ftree-vectorize"]) + env.Append(LINKFLAGS=["-Os"]) if env["target"] == "release_debug": - env.Append(CPPDEFINES=['DEBUG_ENABLED']) + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) - elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-gdwarf-2', '-O0']) - env.Append(CPPDEFINES=['_DEBUG', ('DEBUG', 1), 'DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) + elif env["target"] == "debug": + env.Append(CCFLAGS=["-gdwarf-2", "-O0"]) + env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1), "DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) - if (env["use_lto"]): - env.Append(CCFLAGS=['-flto']) - env.Append(LINKFLAGS=['-flto']) + if env["use_lto"]: + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto"]) ## Architecture if env["arch"] == "x86": # i386 env["bits"] = "32" elif env["arch"] == "x86_64": env["bits"] = "64" - elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm + elif env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32": # arm env["arch"] = "arm" env["bits"] = "32" else: # armv64 @@ -81,108 +91,145 @@ def configure(env): if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True - env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] + env["ENV"]["PATH"] = env["IPHONEPATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"] - compiler_path = '$IPHONEPATH/usr/bin/${ios_triple}' - s_compiler_path = '$IPHONEPATH/Developer/usr/bin/' + compiler_path = "$IPHONEPATH/usr/bin/${ios_triple}" + s_compiler_path = "$IPHONEPATH/Developer/usr/bin/" ccache_path = os.environ.get("CCACHE") if ccache_path is None: - env['CC'] = compiler_path + 'clang' - env['CXX'] = compiler_path + 'clang++' - env['S_compiler'] = s_compiler_path + 'gcc' + env["CC"] = compiler_path + "clang" + env["CXX"] = compiler_path + "clang++" + env["S_compiler"] = s_compiler_path + "gcc" else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary - env['CC'] = ccache_path + ' ' + compiler_path + 'clang' - env['CXX'] = ccache_path + ' ' + compiler_path + 'clang++' - env['S_compiler'] = ccache_path + ' ' + s_compiler_path + 'gcc' - env['AR'] = compiler_path + 'ar' - env['RANLIB'] = compiler_path + 'ranlib' + env["CC"] = ccache_path + " " + compiler_path + "clang" + env["CXX"] = ccache_path + " " + compiler_path + "clang++" + env["S_compiler"] = ccache_path + " " + s_compiler_path + "gcc" + env["AR"] = compiler_path + "ar" + env["RANLIB"] = compiler_path + "ranlib" ## Compile flags - if (env["arch"] == "x86" or env["arch"] == "x86_64"): - detect_darwin_sdk_path('iphonesimulator', env) - env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.9' + if env["arch"] == "x86" or env["arch"] == "x86_64": + detect_darwin_sdk_path("iphonesimulator", env) + env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9" arch_flag = "i386" if env["arch"] == "x86" else env["arch"] - env.Append(CCFLAGS=('-arch ' + arch_flag + ' -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0').split()) - elif (env["arch"] == "arm"): - detect_darwin_sdk_path('iphone', env) - env.Append(CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies'.split()) - elif (env["arch"] == "arm64"): - detect_darwin_sdk_path('iphone', env) - env.Append(CCFLAGS='-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=10.0 -isysroot $IPHONESDK'.split()) - env.Append(CPPDEFINES=['NEED_LONG_INT']) - env.Append(CPPDEFINES=['LIBYUV_DISABLE_NEON']) + env.Append( + CCFLAGS=( + "-arch " + + arch_flag + + " -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0" + ).split() + ) + elif env["arch"] == "arm": + detect_darwin_sdk_path("iphone", env) + env.Append( + CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies'.split() + ) + elif env["arch"] == "arm64": + detect_darwin_sdk_path("iphone", env) + env.Append( + CCFLAGS="-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=10.0 -isysroot $IPHONESDK".split() + ) + env.Append(CPPDEFINES=["NEED_LONG_INT"]) + env.Append(CPPDEFINES=["LIBYUV_DISABLE_NEON"]) # Disable exceptions on non-tools (template) builds - if not env['tools']: - if env['ios_exceptions']: - env.Append(CCFLAGS=['-fexceptions']) + if not env["tools"]: + if env["ios_exceptions"]: + env.Append(CCFLAGS=["-fexceptions"]) else: - env.Append(CCFLAGS=['-fno-exceptions']) + env.Append(CCFLAGS=["-fno-exceptions"]) ## Link flags - if (env["arch"] == "x86" or env["arch"] == "x86_64"): + if env["arch"] == "x86" or env["arch"] == "x86_64": arch_flag = "i386" if env["arch"] == "x86" else env["arch"] - env.Append(LINKFLAGS=['-arch', arch_flag, '-mios-simulator-version-min=10.0', - '-isysroot', '$IPHONESDK', - '-Xlinker', - '-objc_abi_version', - '-Xlinker', '2', - '-F$IPHONESDK', - ]) - elif (env["arch"] == "arm"): - env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=10.0']) - if (env["arch"] == "arm64"): - env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=10.0']) - - env.Append(LINKFLAGS=['-isysroot', '$IPHONESDK', - '-framework', 'AudioToolbox', - '-framework', 'AVFoundation', - '-framework', 'CoreAudio', - '-framework', 'CoreGraphics', - '-framework', 'CoreMedia', - '-framework', 'CoreVideo', - '-framework', 'CoreMotion', - '-framework', 'Foundation', - '-framework', 'GameController', - '-framework', 'MediaPlayer', - '-framework', 'Metal', - '-framework', 'QuartzCore', - '-framework', 'Security', - '-framework', 'SystemConfiguration', - '-framework', 'UIKit', - '-framework', 'ARKit', - ]) + env.Append( + LINKFLAGS=[ + "-arch", + arch_flag, + "-mios-simulator-version-min=10.0", + "-isysroot", + "$IPHONESDK", + "-Xlinker", + "-objc_abi_version", + "-Xlinker", + "2", + "-F$IPHONESDK", + ] + ) + elif env["arch"] == "arm": + env.Append(LINKFLAGS=["-arch", "armv7", "-Wl,-dead_strip", "-miphoneos-version-min=10.0"]) + if env["arch"] == "arm64": + env.Append(LINKFLAGS=["-arch", "arm64", "-Wl,-dead_strip", "-miphoneos-version-min=10.0"]) + + env.Append( + LINKFLAGS=[ + "-isysroot", + "$IPHONESDK", + "-framework", + "AudioToolbox", + "-framework", + "AVFoundation", + "-framework", + "CoreAudio", + "-framework", + "CoreGraphics", + "-framework", + "CoreMedia", + "-framework", + "CoreVideo", + "-framework", + "CoreMotion", + "-framework", + "Foundation", + "-framework", + "GameController", + "-framework", + "MediaPlayer", + "-framework", + "Metal", + "-framework", + "QuartzCore", + "-framework", + "Security", + "-framework", + "SystemConfiguration", + "-framework", + "UIKit", + "-framework", + "ARKit", + ] + ) # Feature options - if env['game_center']: - env.Append(CPPDEFINES=['GAME_CENTER_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'GameKit']) + if env["game_center"]: + env.Append(CPPDEFINES=["GAME_CENTER_ENABLED"]) + env.Append(LINKFLAGS=["-framework", "GameKit"]) - if env['store_kit']: - env.Append(CPPDEFINES=['STOREKIT_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'StoreKit']) + if env["store_kit"]: + env.Append(CPPDEFINES=["STOREKIT_ENABLED"]) + env.Append(LINKFLAGS=["-framework", "StoreKit"]) - if env['icloud']: - env.Append(CPPDEFINES=['ICLOUD_ENABLED']) + if env["icloud"]: + env.Append(CPPDEFINES=["ICLOUD_ENABLED"]) - env.Prepend(CPPPATH=['$IPHONESDK/usr/include', - '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers', - ]) + env.Prepend( + CPPPATH=["$IPHONESDK/usr/include", "$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers",] + ) - env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' + env["ENV"]["CODESIGN_ALLOCATE"] = "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate" - env.Prepend(CPPPATH=['#platform/iphone']) - env.Append(CPPDEFINES=['IPHONE_ENABLED', 'UNIX_ENABLED', 'COREAUDIO_ENABLED']) + env.Prepend(CPPPATH=["#platform/iphone"]) + env.Append(CPPDEFINES=["IPHONE_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) - env.Append(CPPDEFINES=['VULKAN_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'IOSurface']) - if (env['use_static_mvk']): - env.Append(LINKFLAGS=['-framework', 'MoltenVK']) - env['builtin_vulkan'] = False - elif not env['builtin_vulkan']: - env.Append(LIBS=['vulkan']) + env.Append(CPPDEFINES=["VULKAN_ENABLED"]) + env.Append(LINKFLAGS=["-framework", "IOSurface"]) + if env["use_static_mvk"]: + env.Append(LINKFLAGS=["-framework", "MoltenVK"]) + env["builtin_vulkan"] = False + elif not env["builtin_vulkan"]: + env.Append(LIBS=["vulkan"]) diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 08f3c3f91f..3efe338ac7 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -71,8 +71,8 @@ class EditorExportPlatformIOS : public EditorExportPlatform { String modules_buildphase; String modules_buildgrp; }; - struct ExportArchitecture { + String name; bool is_default; @@ -106,7 +106,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { Error _export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, Vector<IOSExportAsset> &r_exported_assets); Error _export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets); - bool is_package_name_valid(const String &p_package, String *r_error = NULL) const { + bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const { String pname = p_package; @@ -795,7 +795,7 @@ void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPrese String pbx_resources_refs; const String file_info_format = String("$build_id = {isa = PBXBuildFile; fileRef = $ref_id; };\n") + - "$ref_id = {isa = PBXFileReference; lastKnownFileType = $file_type; name = $name; path = \"$file_path\"; sourceTree = \"<group>\"; };\n"; + "$ref_id = {isa = PBXFileReference; lastKnownFileType = $file_type; name = \"$name\"; path = \"$file_path\"; sourceTree = \"<group>\"; };\n"; for (int i = 0; i < p_additional_assets.size(); ++i) { String build_id = (++current_id).str(); String ref_id = (++current_id).str(); @@ -925,6 +925,13 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir Vector<String> frameworks = export_plugins[i]->get_ios_frameworks(); Error err = _export_additional_assets(p_out_dir, frameworks, true, r_exported_assets); ERR_FAIL_COND_V(err, err); + + Vector<String> project_static_libs = export_plugins[i]->get_ios_project_static_libs(); + for (int j = 0; j < project_static_libs.size(); j++) + project_static_libs.write[j] = project_static_libs[j].get_file(); // Only the file name as it's copied to the project + err = _export_additional_assets(p_out_dir, project_static_libs, true, r_exported_assets); + ERR_FAIL_COND_V(err, err); + Vector<String> ios_bundle_files = export_plugins[i]->get_ios_bundle_files(); err = _export_additional_assets(p_out_dir, ios_bundle_files, false, r_exported_assets); ERR_FAIL_COND_V(err, err); @@ -1076,7 +1083,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p ERR_FAIL_COND_V(!tmp_app_path, ERR_CANT_CREATE); print_line("Unzipping..."); - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io); if (!src_pkg_zip) { @@ -1098,7 +1105,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0); String file = fname; @@ -1202,6 +1209,22 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p return ERR_FILE_NOT_FOUND; } + // Copy project static libs to the project + Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); + for (int i = 0; i < export_plugins.size(); i++) { + Vector<String> project_static_libs = export_plugins[i]->get_ios_project_static_libs(); + for (int j = 0; j < project_static_libs.size(); j++) { + const String &static_lib_path = project_static_libs[j]; + String dest_lib_file_path = dest_dir + static_lib_path.get_file(); + Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path); + if (lib_copy_err != OK) { + ERR_PRINT("Can't copy '" + static_lib_path + "'."); + memdelete(tmp_app_path); + return lib_copy_err; + } + } + } + String iconset_dir = dest_dir + binary_name + "/Images.xcassets/AppIcon.appiconset/"; err = OK; if (!tmp_app_path->dir_exists(iconset_dir)) { diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp index 8c3eddc5f7..3e67362e16 100644 --- a/platform/iphone/godot_iphone.cpp +++ b/platform/iphone/godot_iphone.cpp @@ -36,7 +36,7 @@ #include <string.h> #include <unistd.h> -static OSIPhone *os = NULL; +static OSIPhone *os = nullptr; extern "C" { int add_path(int p_argc, char **p_args); @@ -71,7 +71,7 @@ int iphone_main(int width, int height, int argc, char **argv, String data_dir) { for (int i = 0; i < argc; i++) { fargv[i] = argv[i]; }; - fargv[argc] = NULL; + fargv[argc] = nullptr; argc = add_path(argc, fargv); argc = add_cmdline(argc, fargv); diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 497f2f747d..3ef521a61a 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -37,13 +37,13 @@ #endif #if defined(VULKAN_ENABLED) -#include "servers/visual/rasterizer_rd/rasterizer_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_rd.h" // #import <QuartzCore/CAMetalLayer.h> #include <vulkan/vulkan_metal.h> #endif -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "servers/rendering/rendering_server_raster.h" +#include "servers/rendering/rendering_server_wrap_mt.h" #include "main/main.h" @@ -68,7 +68,7 @@ const char *OSIPhone::get_video_driver_name(int p_driver) const { case VIDEO_DRIVER_GLES2: return "GLES2"; } - ERR_FAIL_V_MSG(NULL, "Invalid video driver index: " + itos(p_driver) + "."); + ERR_FAIL_V_MSG(nullptr, "Invalid video driver index: " + itos(p_driver) + "."); }; OSIPhone *OSIPhone::get_singleton() { @@ -134,16 +134,16 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p RasterizerRD::make_current(); #endif - visual_server = memnew(VisualServerRaster); + rendering_server = memnew(RenderingServerRaster); // FIXME: Reimplement threaded rendering if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, false)); + rendering_server = memnew(RenderingServerWrapMT(rendering_server, false)); } - visual_server->init(); - //visual_server->cursor_set_visible(false, 0); + rendering_server->init(); + //rendering_server->cursor_set_visible(false, 0); #if defined(OPENGL_ENABLED) - // reset this to what it should be, it will have been set to 0 after visual_server->init() is called + // reset this to what it should be, it will have been set to 0 after rendering_server->init() is called RasterizerStorageGLES2::system_fbo = gl_view_base_fb; #endif @@ -339,7 +339,7 @@ void OSIPhone::delete_main_loop() { memdelete(main_loop); }; - main_loop = NULL; + main_loop = nullptr; }; void OSIPhone::finalize() { @@ -361,8 +361,8 @@ void OSIPhone::finalize() { memdelete(icloud); #endif - visual_server->finish(); - memdelete(visual_server); + rendering_server->finish(); + memdelete(rendering_server); // memdelete(rasterizer); // Free unhandled events before close @@ -608,7 +608,7 @@ bool OSIPhone::_check_internal_feature_support(const String &p_feature) { // so we use this as a hack to ensure certain code is called before // everything else, but after all units are initialized. typedef void (*init_callback)(); -static init_callback *ios_init_callbacks = NULL; +static init_callback *ios_init_callbacks = nullptr; static int ios_init_callbacks_count = 0; static int ios_init_callbacks_capacity = 0; @@ -631,12 +631,12 @@ OSIPhone::OSIPhone(int width, int height, String p_data_dir) { ios_init_callbacks[i](); } free(ios_init_callbacks); - ios_init_callbacks = NULL; + ios_init_callbacks = nullptr; ios_init_callbacks_count = 0; ios_init_callbacks_capacity = 0; - main_loop = NULL; - visual_server = NULL; + main_loop = nullptr; + rendering_server = nullptr; VideoMode vm; vm.fullscreen = true; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 2efb7af7c2..96cf041c37 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -41,8 +41,8 @@ #include "in_app_store.h" #include "ios.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" #if defined(VULKAN_ENABLED) #include "drivers/vulkan/rendering_device_vulkan.h" @@ -60,7 +60,7 @@ private: static HashMap<String, void *> dynamic_symbol_lookup_table; friend void register_dynamic_symbol(char *name, void *address); - VisualServer *visual_server; + RenderingServer *rendering_server; AudioDriverCoreAudio audio_driver; diff --git a/platform/iphone/vulkan_context_iphone.h b/platform/iphone/vulkan_context_iphone.h index 200057e14d..625e41f4b9 100644 --- a/platform/iphone/vulkan_context_iphone.h +++ b/platform/iphone/vulkan_context_iphone.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* vulkan_context_osx.h */ +/* vulkan_context_iphone.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/platform/iphone/vulkan_context_iphone.mm b/platform/iphone/vulkan_context_iphone.mm index f49b85c097..701ac0d9bb 100644 --- a/platform/iphone/vulkan_context_iphone.mm +++ b/platform/iphone/vulkan_context_iphone.mm @@ -1,5 +1,5 @@ /*************************************************************************/ -/* vulkan_context_osx.mm */ +/* vulkan_context_iphone.mm */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index d3cd8f76b7..7239648937 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -1,67 +1,63 @@ #!/usr/bin/env python -Import('env') +Import("env") javascript_files = [ - 'audio_driver_javascript.cpp', - 'http_client_javascript.cpp', - 'javascript_eval.cpp', - 'javascript_main.cpp', - 'os_javascript.cpp', + "audio_driver_javascript.cpp", + "http_client_javascript.cpp", + "javascript_eval.cpp", + "javascript_main.cpp", + "os_javascript.cpp", ] -build_targets = ['#bin/godot${PROGSUFFIX}.js', '#bin/godot${PROGSUFFIX}.wasm'] -if env['threads_enabled']: - build_targets.append('#bin/godot${PROGSUFFIX}.worker.js') +build_targets = ["#bin/godot${PROGSUFFIX}.js", "#bin/godot${PROGSUFFIX}.wasm"] +if env["threads_enabled"]: + build_targets.append("#bin/godot${PROGSUFFIX}.worker.js") build = env.add_program(build_targets, javascript_files) js_libraries = [ - 'http_request.js', + "http_request.js", ] for lib in js_libraries: - env.Append(LINKFLAGS=['--js-library', env.File(lib).path]) + env.Append(LINKFLAGS=["--js-library", env.File(lib).path]) env.Depends(build, js_libraries) js_modules = [ - 'id_handler.js', + "id_handler.js", ] for module in js_modules: - env.Append(LINKFLAGS=['--pre-js', env.File(module).path]) + env.Append(LINKFLAGS=["--pre-js", env.File(module).path]) env.Depends(build, js_modules) engine = [ - 'engine/preloader.js', - 'engine/loader.js', - 'engine/utils.js', - 'engine/engine.js', + "engine/preloader.js", + "engine/loader.js", + "engine/utils.js", + "engine/engine.js", ] -externs = [ - env.File('#platform/javascript/engine/externs.js') -] -js_engine = env.CreateEngineFile('#bin/godot${PROGSUFFIX}.engine.js', engine, externs) +externs = [env.File("#platform/javascript/engine/externs.js")] +js_engine = env.CreateEngineFile("#bin/godot${PROGSUFFIX}.engine.js", engine, externs) env.Depends(js_engine, externs) wrap_list = [ build[0], js_engine, ] -js_wrapped = env.Textfile('#bin/godot', [env.File(f) for f in wrap_list], TEXTFILESUFFIX='${PROGSUFFIX}.wrapped.js') +js_wrapped = env.Textfile("#bin/godot", [env.File(f) for f in wrap_list], TEXTFILESUFFIX="${PROGSUFFIX}.wrapped.js") -zip_dir = env.Dir('#bin/.javascript_zip') -out_files = [ - zip_dir.File('godot.js'), - zip_dir.File('godot.wasm'), - zip_dir.File('godot.html') -] -in_files = [ - js_wrapped, - build[1], - '#misc/dist/html/full-size.html' -] -if env['threads_enabled']: +zip_dir = env.Dir("#bin/.javascript_zip") +out_files = [zip_dir.File("godot.js"), zip_dir.File("godot.wasm"), zip_dir.File("godot.html")] +in_files = [js_wrapped, build[1], "#misc/dist/html/full-size.html"] +if env["threads_enabled"]: in_files.append(build[2]) - out_files.append(zip_dir.File('godot.worker.js')) + out_files.append(zip_dir.File("godot.worker.js")) zip_files = env.InstallAs(out_files, in_files) -env.Zip('#bin/godot', zip_files, ZIPROOT=zip_dir, ZIPSUFFIX='${PROGSUFFIX}${ZIPSUFFIX}', ZIPCOMSTR='Archving $SOURCES as $TARGET') +env.Zip( + "#bin/godot", + zip_files, + ZIPROOT=zip_dir, + ZIPSUFFIX="${PROGSUFFIX}${ZIPSUFFIX}", + ZIPCOMSTR="Archving $SOURCES as $TARGET", +) diff --git a/platform/javascript/api/api.cpp b/platform/javascript/api/api.cpp index 88de13d771..45cb82b351 100644 --- a/platform/javascript/api/api.cpp +++ b/platform/javascript/api/api.cpp @@ -46,7 +46,7 @@ void unregister_javascript_api() { memdelete(javascript_eval); } -JavaScript *JavaScript::singleton = NULL; +JavaScript *JavaScript::singleton = nullptr; JavaScript *JavaScript::get_singleton() { @@ -55,7 +55,7 @@ JavaScript *JavaScript::get_singleton() { JavaScript::JavaScript() { - ERR_FAIL_COND_MSG(singleton != NULL, "JavaScript singleton already exist."); + ERR_FAIL_COND_MSG(singleton != nullptr, "JavaScript singleton already exist."); singleton = this; } diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index d63c6a40a5..8f857478e5 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -32,7 +32,7 @@ #include <emscripten.h> -AudioDriverJavaScript *AudioDriverJavaScript::singleton = NULL; +AudioDriverJavaScript *AudioDriverJavaScript::singleton = nullptr; const char *AudioDriverJavaScript::get_name() const { @@ -200,7 +200,7 @@ void AudioDriverJavaScript::finish() { if (internal_buffer) { memdelete_arr(internal_buffer); - internal_buffer = NULL; + internal_buffer = nullptr; } _driver_id = 0; } @@ -264,7 +264,7 @@ Error AudioDriverJavaScript::capture_stop() { AudioDriverJavaScript::AudioDriverJavaScript() { _driver_id = 0; - internal_buffer = NULL; + internal_buffer = nullptr; buffer_length = 0; singleton = this; diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index fb02752aa7..9486e10717 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -2,37 +2,39 @@ import os from emscripten_helpers import parse_config, run_closure_compiler, create_engine_file + def is_active(): return True def get_name(): - return 'JavaScript' + return "JavaScript" def can_build(): - return 'EM_CONFIG' in os.environ or os.path.exists(os.path.expanduser('~/.emscripten')) + return "EM_CONFIG" in os.environ or os.path.exists(os.path.expanduser("~/.emscripten")) def get_opts(): from SCons.Variables import BoolVariable + return [ # eval() can be a security concern, so it can be disabled. - BoolVariable('javascript_eval', 'Enable JavaScript eval interface', True), - BoolVariable('threads_enabled', 'Enable WebAssembly Threads support (limited browser support)', False), - BoolVariable('use_closure_compiler', 'Use closure compiler to minimize Javascript code', False), + BoolVariable("javascript_eval", "Enable JavaScript eval interface", True), + BoolVariable("threads_enabled", "Enable WebAssembly Threads support (limited browser support)", False), + BoolVariable("use_closure_compiler", "Use closure compiler to minimize Javascript code", False), ] def get_flags(): return [ - ('tools', False), - ('builtin_pcre2_with_jit', False), + ("tools", False), + ("builtin_pcre2_with_jit", False), # Disabling the mbedtls module reduces file size. # The module has little use due to the limited networking functionality # in this platform. For the available networking methods, the browser # manages TLS. - ('module_mbedtls_enabled', False), + ("module_mbedtls_enabled", False), ] @@ -40,125 +42,125 @@ def configure(env): ## Build type - if env['target'] == 'release': + if env["target"] == "release": # Use -Os to prioritize optimizing for reduced file size. This is # particularly valuable for the web platform because it directly # decreases download time. # -Os reduces file size by around 5 MiB over -O3. -Oz only saves about # 100 KiB over -Os, which does not justify the negative impact on # run-time performance. - env.Append(CCFLAGS=['-Os']) - env.Append(LINKFLAGS=['-Os']) - elif env['target'] == 'release_debug': - env.Append(CCFLAGS=['-Os']) - env.Append(LINKFLAGS=['-Os']) - env.Append(CPPDEFINES=['DEBUG_ENABLED']) + env.Append(CCFLAGS=["-Os"]) + env.Append(LINKFLAGS=["-Os"]) + elif env["target"] == "release_debug": + env.Append(CCFLAGS=["-Os"]) + env.Append(LINKFLAGS=["-Os"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) # Retain function names for backtraces at the cost of file size. - env.Append(LINKFLAGS=['--profiling-funcs']) - else: # 'debug' - env.Append(CPPDEFINES=['DEBUG_ENABLED']) - env.Append(CCFLAGS=['-O1', '-g']) - env.Append(LINKFLAGS=['-O1', '-g']) - env.Append(LINKFLAGS=['-s', 'ASSERTIONS=1']) - - if env['tools']: - if not env['threads_enabled']: - raise RuntimeError("Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option") + env.Append(LINKFLAGS=["--profiling-funcs"]) + else: # 'debug' + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + env.Append(CCFLAGS=["-O1", "-g"]) + env.Append(LINKFLAGS=["-O1", "-g"]) + env.Append(LINKFLAGS=["-s", "ASSERTIONS=1"]) + + if env["tools"]: + if not env["threads_enabled"]: + raise RuntimeError( + "Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option" + ) # Tools need more memory. Initial stack memory in bytes. See `src/settings.js` in emscripten repository (will be renamed to INITIAL_MEMORY). - env.Append(LINKFLAGS=['-s', 'TOTAL_MEMORY=33554432']) + env.Append(LINKFLAGS=["-s", "TOTAL_MEMORY=33554432"]) else: # Disable exceptions and rtti on non-tools (template) builds # These flags help keep the file size down. - env.Append(CCFLAGS=['-fno-exceptions', '-fno-rtti']) + env.Append(CCFLAGS=["-fno-exceptions", "-fno-rtti"]) # Don't use dynamic_cast, necessary with no-rtti. - env.Append(CPPDEFINES=['NO_SAFE_CAST']) + env.Append(CPPDEFINES=["NO_SAFE_CAST"]) ## Copy env variables. - env['ENV'] = os.environ + env["ENV"] = os.environ # LTO - if env['use_lto']: - env.Append(CCFLAGS=['-s', 'WASM_OBJECT_FILES=0']) - env.Append(LINKFLAGS=['-s', 'WASM_OBJECT_FILES=0']) - env.Append(LINKFLAGS=['--llvm-lto', '1']) + if env["use_lto"]: + env.Append(CCFLAGS=["-s", "WASM_OBJECT_FILES=0"]) + env.Append(LINKFLAGS=["-s", "WASM_OBJECT_FILES=0"]) + env.Append(LINKFLAGS=["--llvm-lto", "1"]) # Closure compiler - if env['use_closure_compiler']: + if env["use_closure_compiler"]: # For emscripten support code. - env.Append(LINKFLAGS=['--closure', '1']) + env.Append(LINKFLAGS=["--closure", "1"]) # Register builder for our Engine files - jscc = env.Builder(generator=run_closure_compiler, suffix='.cc.js', src_suffix='.js') - env.Append(BUILDERS = {'BuildJS' : jscc}) + jscc = env.Builder(generator=run_closure_compiler, suffix=".cc.js", src_suffix=".js") + env.Append(BUILDERS={"BuildJS": jscc}) # Add method that joins/compiles our Engine files. env.AddMethod(create_engine_file, "CreateEngineFile") # Closure compiler extern and support for ecmascript specs (const, let, etc). - env['ENV']['EMCC_CLOSURE_ARGS'] = '--language_in ECMASCRIPT6' + env["ENV"]["EMCC_CLOSURE_ARGS"] = "--language_in ECMASCRIPT6" em_config = parse_config() - env.PrependENVPath('PATH', em_config['EMCC_ROOT']) + env.PrependENVPath("PATH", em_config["EMCC_ROOT"]) - env['CC'] = 'emcc' - env['CXX'] = 'em++' - env['LINK'] = 'emcc' + env["CC"] = "emcc" + env["CXX"] = "em++" + env["LINK"] = "emcc" - env['AR'] = 'emar' - env['RANLIB'] = 'emranlib' + env["AR"] = "emar" + env["RANLIB"] = "emranlib" # Use TempFileMunge since some AR invocations are too long for cmd.exe. # Use POSIX-style paths, required with TempFileMunge. - env['ARCOM_POSIX'] = env['ARCOM'].replace( - '$TARGET', '$TARGET.posix').replace( - '$SOURCES', '$SOURCES.posix') - env['ARCOM'] = '${TEMPFILE(ARCOM_POSIX)}' + env["ARCOM_POSIX"] = env["ARCOM"].replace("$TARGET", "$TARGET.posix").replace("$SOURCES", "$SOURCES.posix") + env["ARCOM"] = "${TEMPFILE(ARCOM_POSIX)}" # All intermediate files are just LLVM bitcode. - env['OBJPREFIX'] = '' - env['OBJSUFFIX'] = '.bc' - env['PROGPREFIX'] = '' + env["OBJPREFIX"] = "" + env["OBJSUFFIX"] = ".bc" + env["PROGPREFIX"] = "" # Program() output consists of multiple files, so specify suffixes manually at builder. - env['PROGSUFFIX'] = '' - env['LIBPREFIX'] = 'lib' - env['LIBSUFFIX'] = '.bc' - env['LIBPREFIXES'] = ['$LIBPREFIX'] - env['LIBSUFFIXES'] = ['$LIBSUFFIX'] + env["PROGSUFFIX"] = "" + env["LIBPREFIX"] = "lib" + env["LIBSUFFIX"] = ".bc" + env["LIBPREFIXES"] = ["$LIBPREFIX"] + env["LIBSUFFIXES"] = ["$LIBSUFFIX"] - env.Prepend(CPPPATH=['#platform/javascript']) - env.Append(CPPDEFINES=['JAVASCRIPT_ENABLED', 'UNIX_ENABLED']) + env.Prepend(CPPPATH=["#platform/javascript"]) + env.Append(CPPDEFINES=["JAVASCRIPT_ENABLED", "UNIX_ENABLED"]) - if env['javascript_eval']: - env.Append(CPPDEFINES=['JAVASCRIPT_EVAL_ENABLED']) + if env["javascript_eval"]: + env.Append(CPPDEFINES=["JAVASCRIPT_EVAL_ENABLED"]) # Thread support (via SharedArrayBuffer). - if env['threads_enabled']: - env.Append(CPPDEFINES=['PTHREAD_NO_RENAME']) - env.Append(CCFLAGS=['-s', 'USE_PTHREADS=1']) - env.Append(LINKFLAGS=['-s', 'USE_PTHREADS=1']) - env.Append(LINKFLAGS=['-s', 'PTHREAD_POOL_SIZE=4']) - env.Append(LINKFLAGS=['-s', 'WASM_MEM_MAX=2048MB']) + if env["threads_enabled"]: + env.Append(CPPDEFINES=["PTHREAD_NO_RENAME"]) + env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"]) + env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"]) + env.Append(LINKFLAGS=["-s", "PTHREAD_POOL_SIZE=4"]) + env.Append(LINKFLAGS=["-s", "WASM_MEM_MAX=2048MB"]) else: - env.Append(CPPDEFINES=['NO_THREADS']) + env.Append(CPPDEFINES=["NO_THREADS"]) # Reduce code size by generating less support code (e.g. skip NodeJS support). - env.Append(LINKFLAGS=['-s', 'ENVIRONMENT=web,worker']) + env.Append(LINKFLAGS=["-s", "ENVIRONMENT=web,worker"]) # We use IDBFS in javascript_main.cpp. Since Emscripten 1.39.1 it needs to # be linked explicitly. - env.Append(LIBS=['idbfs.js']) + env.Append(LIBS=["idbfs.js"]) - env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) - env.Append(LINKFLAGS=['-s', 'MODULARIZE=1', '-s', 'EXPORT_NAME="Godot"']) + env.Append(LINKFLAGS=["-s", "BINARYEN=1"]) + env.Append(LINKFLAGS=["-s", "MODULARIZE=1", "-s", 'EXPORT_NAME="Godot"']) # Allow increasing memory buffer size during runtime. This is efficient # when using WebAssembly (in comparison to asm.js) and works well for # us since we don't know requirements at compile-time. - env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) + env.Append(LINKFLAGS=["-s", "ALLOW_MEMORY_GROWTH=1"]) # This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1. - env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) + env.Append(LINKFLAGS=["-s", "USE_WEBGL2=1"]) - env.Append(LINKFLAGS=['-s', 'INVOKE_RUN=0']) + env.Append(LINKFLAGS=["-s", "INVOKE_RUN=0"]) # callMain for manual start, FS for preloading. - env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS=["callMain", "FS"]']) + env.Append(LINKFLAGS=["-s", 'EXTRA_EXPORTED_RUNTIME_METHODS=["callMain", "FS"]']) diff --git a/platform/javascript/emscripten_helpers.py b/platform/javascript/emscripten_helpers.py index bda5b40a74..a55c9d3f48 100644 --- a/platform/javascript/emscripten_helpers.py +++ b/platform/javascript/emscripten_helpers.py @@ -1,7 +1,8 @@ import os + def parse_config(): - em_config_file = os.getenv('EM_CONFIG') or os.path.expanduser('~/.emscripten') + em_config_file = os.getenv("EM_CONFIG") or os.path.expanduser("~/.emscripten") if not os.path.exists(em_config_file): raise RuntimeError("Emscripten configuration file '%s' does not exist" % em_config_file) @@ -13,25 +14,25 @@ def parse_config(): exec(f.read(), em_config) except StandardError as e: raise RuntimeError("Emscripten configuration file '%s' is invalid:\n%s" % (em_config_file, e)) - normalized['EMCC_ROOT'] = em_config.get('EMSCRIPTEN_ROOT') - normalized['NODE_JS'] = em_config.get('NODE_JS') - normalized['CLOSURE_BIN'] = os.path.join(normalized['EMCC_ROOT'], 'node_modules', '.bin', 'google-closure-compiler') + normalized["EMCC_ROOT"] = em_config.get("EMSCRIPTEN_ROOT") + normalized["NODE_JS"] = em_config.get("NODE_JS") + normalized["CLOSURE_BIN"] = os.path.join(normalized["EMCC_ROOT"], "node_modules", ".bin", "google-closure-compiler") return normalized def run_closure_compiler(target, source, env, for_signature): cfg = parse_config() - cmd = [cfg['NODE_JS'], cfg['CLOSURE_BIN']] - cmd.extend(['--compilation_level', 'ADVANCED_OPTIMIZATIONS']) - for f in env['JSEXTERNS']: - cmd.extend(['--externs', f.get_abspath()]) + cmd = [cfg["NODE_JS"], cfg["CLOSURE_BIN"]] + cmd.extend(["--compilation_level", "ADVANCED_OPTIMIZATIONS"]) + for f in env["JSEXTERNS"]: + cmd.extend(["--externs", f.get_abspath()]) for f in source: - cmd.extend(['--js', f.get_abspath()]) - cmd.extend(['--js_output_file', target[0].get_abspath()]) - return ' '.join(cmd) + cmd.extend(["--js", f.get_abspath()]) + cmd.extend(["--js_output_file", target[0].get_abspath()]) + return " ".join(cmd) def create_engine_file(env, target, source, externs): - if env['use_closure_compiler']: + if env["use_closure_compiler"]: return env.BuildJS(target, source, JSEXTERNS=externs) return env.Textfile(target, [env.File(s) for s in source]) diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index da61425747..39faae2d17 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -390,7 +390,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese return error; } - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(template_path.utf8().get_data(), &io); @@ -410,7 +410,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese //get filename unz_file_info info; char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String file = fname; diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp index 472384cf30..863c207896 100644 --- a/platform/javascript/http_client_javascript.cpp +++ b/platform/javascript/http_client_javascript.cpp @@ -88,8 +88,8 @@ Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Ve String url = (use_tls ? "https://" : "http://") + host + ":" + itos(port) + p_url; godot_xhr_reset(xhr_id); godot_xhr_open(xhr_id, _methods[p_method], url.utf8().get_data(), - username.empty() ? NULL : username.utf8().get_data(), - password.empty() ? NULL : password.utf8().get_data()); + username.empty() ? nullptr : username.utf8().get_data(), + password.empty() ? nullptr : password.utf8().get_data()); for (int i = 0; i < p_headers.size(); i++) { int header_separator = p_headers[i].find(": "); diff --git a/platform/javascript/http_request.h b/platform/javascript/http_request.h index 57dc4f0d9f..54e98c1927 100644 --- a/platform/javascript/http_request.h +++ b/platform/javascript/http_request.h @@ -49,7 +49,7 @@ extern int godot_xhr_new(); extern void godot_xhr_reset(int p_xhr_id); extern bool godot_xhr_free(int p_xhr_id); -extern int godot_xhr_open(int p_xhr_id, const char *p_method, const char *p_url, const char *p_user = NULL, const char *p_password = NULL); +extern int godot_xhr_open(int p_xhr_id, const char *p_method, const char *p_url, const char *p_user = nullptr, const char *p_password = nullptr); extern void godot_xhr_set_request_header(int p_xhr_id, const char *p_header, const char *p_value); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index b7feb5bfbd..ad06aef86e 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -36,7 +36,7 @@ #include "drivers/unix/dir_access_unix.h" #include "drivers/unix/file_access_unix.h" #include "main/main.h" -#include "servers/visual/visual_server_raster.h" +#include "servers/rendering/rendering_server_raster.h" #include <emscripten.h> #include <png.h> @@ -167,7 +167,7 @@ void OS_JavaScript::set_window_maximized(bool p_enabled) { strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; - strategy.canvasResizedCallback = NULL; + strategy.canvasResizedCallback = nullptr; emscripten_enter_soft_fullscreen(GODOT_CANVAS_SELECTOR, &strategy); window_maximized = p_enabled; } @@ -196,7 +196,7 @@ void OS_JavaScript::set_window_fullscreen(bool p_enabled) { strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; - strategy.canvasResizedCallback = NULL; + strategy.canvasResizedCallback = nullptr; EMSCRIPTEN_RESULT result = emscripten_request_fullscreen_strategy(GODOT_CANVAS_SELECTOR, false, &strategy); ERR_FAIL_COND_MSG(result == EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED, "Enabling fullscreen is only possible from an input callback for the HTML5 platform."); ERR_FAIL_COND_MSG(result != EMSCRIPTEN_RESULT_SUCCESS, "Enabling fullscreen is only possible from an input callback for the HTML5 platform."); @@ -541,10 +541,10 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s PackedByteArray png; size_t len; PackedByteArray data = image->get_data(); - ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, data.ptr(), 0, NULL)); + ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, data.ptr(), 0, nullptr)); png.resize(len); - ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, png.ptrw(), &len, 0, data.ptr(), 0, NULL)); + ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, png.ptrw(), &len, 0, data.ptr(), 0, nullptr)); char *object_url; /* clang-format off */ @@ -824,7 +824,7 @@ const char *OS_JavaScript::get_video_driver_name(int p_driver) const { case VIDEO_DRIVER_GLES2: return "GLES2"; } - ERR_FAIL_V_MSG(NULL, "Invalid video driver index: " + itos(p_driver) + "."); + ERR_FAIL_V_MSG(nullptr, "Invalid video driver index: " + itos(p_driver) + "."); } // Audio @@ -962,18 +962,18 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, setenv("LANG", locale_ptr, true); AudioDriverManager::initialize(p_audio_driver); - VisualServer *visual_server = memnew(VisualServerRaster()); + RenderingServer *rendering_server = memnew(RenderingServerRaster()); input = memnew(InputDefault); EMSCRIPTEN_RESULT result; #define EM_CHECK(ev) \ if (result != EMSCRIPTEN_RESULT_SUCCESS) \ ERR_PRINT("Error while setting " #ev " callback: Code " + itos(result)); -#define SET_EM_CALLBACK(target, ev, cb) \ - result = emscripten_set_##ev##_callback(target, NULL, true, &cb); \ +#define SET_EM_CALLBACK(target, ev, cb) \ + result = emscripten_set_##ev##_callback(target, nullptr, true, &cb); \ EM_CHECK(ev) -#define SET_EM_CALLBACK_NOTARGET(ev, cb) \ - result = emscripten_set_##ev##_callback(NULL, true, &cb); \ +#define SET_EM_CALLBACK_NOTARGET(ev, cb) \ + result = emscripten_set_##ev##_callback(nullptr, true, &cb); \ EM_CHECK(ev) // These callbacks from Emscripten's html5.h suffice to access most // JavaScript APIs. For APIs that are not (sufficiently) exposed, EM_ASM @@ -1016,7 +1016,7 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, ); /* clang-format on */ - visual_server->init(); + rendering_server->init(); return OK; } @@ -1072,7 +1072,7 @@ bool OS_JavaScript::main_loop_iterate() { strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; - strategy.canvasResizedCallback = NULL; + strategy.canvasResizedCallback = nullptr; emscripten_enter_soft_fullscreen(GODOT_CANVAS_SELECTOR, &strategy); } else { emscripten_set_canvas_element_size(GODOT_CANVAS_SELECTOR, windowed_size.width, windowed_size.height); @@ -1182,10 +1182,10 @@ void OS_JavaScript::set_icon(const Ref<Image> &p_icon) { PackedByteArray png; size_t len; PackedByteArray data = icon->get_data(); - ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, data.ptr(), 0, NULL)); + ERR_FAIL_COND(!png_image_write_get_memory_size(png_meta, len, 0, data.ptr(), 0, nullptr)); png.resize(len); - ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, png.ptrw(), &len, 0, data.ptr(), 0, NULL)); + ERR_FAIL_COND(!png_image_write_to_memory(&png_meta, png.ptrw(), &len, 0, data.ptr(), 0, nullptr)); /* clang-format off */ EM_ASM_ARGS({ @@ -1284,7 +1284,7 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) { just_exited_fullscreen = false; transparency_enabled = false; - main_loop = NULL; + main_loop = nullptr; idb_available = false; sync_wait_time = -1; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 1a3a6616b0..81fe4cf0cc 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -35,7 +35,7 @@ #include "core/input/input_filter.h" #include "drivers/unix/os_unix.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" +#include "servers/rendering/rasterizer.h" #include <emscripten/html5.h> @@ -145,7 +145,7 @@ public: void run_async(); bool main_loop_iterate(); - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; diff --git a/platform/linuxbsd/SCsub b/platform/linuxbsd/SCsub index f3f65e216e..ae75a75830 100644 --- a/platform/linuxbsd/SCsub +++ b/platform/linuxbsd/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") from platform_methods import run_in_subprocess import platform_linuxbsd_builders @@ -14,10 +14,9 @@ common_x11 = [ "display_server_x11.cpp", "vulkan_context_x11.cpp", "key_mapping_x11.cpp", - ] -prog = env.add_program('#bin/godot', ['godot_linuxbsd.cpp'] + common_x11) +prog = env.add_program("#bin/godot", ["godot_linuxbsd.cpp"] + common_x11) if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_linuxbsd_builders.make_debug_linuxbsd)) diff --git a/platform/linuxbsd/context_gl_x11.cpp b/platform/linuxbsd/context_gl_x11.cpp index 5442af3bef..308d68521a 100644 --- a/platform/linuxbsd/context_gl_x11.cpp +++ b/platform/linuxbsd/context_gl_x11.cpp @@ -52,7 +52,7 @@ struct ContextGL_X11_Private { void ContextGL_X11::release_current() { - glXMakeCurrent(x11_display, None, NULL); + glXMakeCurrent(x11_display, None, nullptr); } void ContextGL_X11::make_current() { @@ -117,7 +117,7 @@ Error ContextGL_X11::initialize() { int fbcount; GLXFBConfig fbconfig = 0; - XVisualInfo *vi = NULL; + XVisualInfo *vi = nullptr; XSetWindowAttributes swa; swa.event_mask = StructureNotifyMask; @@ -136,7 +136,7 @@ Error ContextGL_X11::initialize() { XRenderPictFormat *pict_format = XRenderFindVisualFormat(x11_display, vi->visual); if (!pict_format) { XFree(vi); - vi = NULL; + vi = nullptr; continue; } @@ -208,9 +208,9 @@ int ContextGL_X11::get_window_height() { void ContextGL_X11::set_use_vsync(bool p_use) { static bool setup = false; - static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL; - static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = NULL; - static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL; + static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; + static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = nullptr; + static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; if (!setup) { setup = true; diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp index 1b3804e3ed..dbdb15918e 100644 --- a/platform/linuxbsd/crash_handler_linuxbsd.cpp +++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp @@ -46,7 +46,7 @@ #include <stdlib.h> static void handle_crash(int sig) { - if (OS::get_singleton() == NULL) { + if (OS::get_singleton() == nullptr) { abort(); } @@ -79,7 +79,7 @@ static void handle_crash(int sig) { if (dladdr(bt_buffer[i], &info) && info.dli_sname) { if (info.dli_sname[0] == '_') { int status; - char *demangled = abi::__cxa_demangle(info.dli_sname, NULL, 0, &status); + char *demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); if (status == 0 && demangled) { snprintf(fname, 1024, "%s", demangled); @@ -102,7 +102,7 @@ static void handle_crash(int sig) { // Try to get the file/line number using addr2line int ret; - Error err = OS::get_singleton()->execute(String("addr2line"), args, true, NULL, &output, &ret); + Error err = OS::get_singleton()->execute(String("addr2line"), args, true, nullptr, &output, &ret); if (err == OK) { output.erase(output.length() - 1, 1); } @@ -132,9 +132,9 @@ void CrashHandler::disable() { return; #ifdef CRASH_HANDLER_ENABLED - signal(SIGSEGV, NULL); - signal(SIGFPE, NULL); - signal(SIGILL, NULL); + signal(SIGSEGV, nullptr); + signal(SIGFPE, nullptr); + signal(SIGILL, nullptr); #endif disabled = true; diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index 1a395efffe..5d8b4fba48 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -13,64 +13,65 @@ def get_name(): def can_build(): - if (os.name != "posix" or sys.platform == "darwin"): + if os.name != "posix" or sys.platform == "darwin": return False # Check the minimal dependencies x11_error = os.system("pkg-config --version > /dev/null") - if (x11_error): + if x11_error: return False x11_error = os.system("pkg-config x11 --modversion > /dev/null ") - if (x11_error): + if x11_error: return False x11_error = os.system("pkg-config xcursor --modversion > /dev/null ") - if (x11_error): + if x11_error: print("xcursor not found.. x11 disabled.") return False x11_error = os.system("pkg-config xinerama --modversion > /dev/null ") - if (x11_error): + if x11_error: print("xinerama not found.. x11 disabled.") return False x11_error = os.system("pkg-config xrandr --modversion > /dev/null ") - if (x11_error): + if x11_error: print("xrandr not found.. x11 disabled.") return False x11_error = os.system("pkg-config xrender --modversion > /dev/null ") - if (x11_error): + if x11_error: print("xrender not found.. x11 disabled.") return False x11_error = os.system("pkg-config xi --modversion > /dev/null ") - if (x11_error): + if x11_error: print("xi not found.. Aborting.") return False return True + def get_opts(): from SCons.Variables import BoolVariable, EnumVariable return [ - BoolVariable('use_llvm', 'Use the LLVM compiler', False), - BoolVariable('use_lld', 'Use the LLD linker', False), - BoolVariable('use_thinlto', 'Use ThinLTO', False), - BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically for better portability', False), - BoolVariable('use_coverage', 'Test Godot coverage', False), - BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False), - BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False), - BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False), - BoolVariable('use_tsan', 'Use LLVM/GCC compiler thread sanitizer (TSAN))', False), - BoolVariable('pulseaudio', 'Detect and use PulseAudio', True), - BoolVariable('udev', 'Use udev for gamepad connection callbacks', False), - EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), - BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), - BoolVariable('touch', 'Enable touch events', True), - BoolVariable('execinfo', 'Use libexecinfo on systems where glibc is not available', False), + BoolVariable("use_llvm", "Use the LLVM compiler", False), + BoolVariable("use_lld", "Use the LLD linker", False), + BoolVariable("use_thinlto", "Use ThinLTO", False), + BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", False), + BoolVariable("use_coverage", "Test Godot coverage", False), + BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), + BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), + BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), + BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), + BoolVariable("pulseaudio", "Detect and use PulseAudio", True), + BoolVariable("udev", "Use udev for gamepad connection callbacks", False), + EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")), + BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), + BoolVariable("touch", "Enable touch events", True), + BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False), ] @@ -83,286 +84,294 @@ def configure(env): ## Build type - if (env["target"] == "release"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O3']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "release_debug"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O2']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - env.Prepend(CPPDEFINES=['DEBUG_ENABLED']) - - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3']) - env.Prepend(CPPDEFINES=['DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) - env.Append(LINKFLAGS=['-rdynamic']) + if env["target"] == "release": + if env["optimize"] == "speed": # optimize for speed (default) + env.Prepend(CCFLAGS=["-O3"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "release_debug": + if env["optimize"] == "speed": # optimize for speed (default) + env.Prepend(CCFLAGS=["-O2"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) + + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "debug": + env.Prepend(CCFLAGS=["-g3"]) + env.Prepend(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) + env.Append(LINKFLAGS=["-rdynamic"]) ## Architecture - is64 = sys.maxsize > 2**32 - if (env["bits"] == "default"): + is64 = sys.maxsize > 2 ** 32 + if env["bits"] == "default": env["bits"] = "64" if is64 else "32" ## Compiler configuration - if 'CXX' in env and 'clang' in os.path.basename(env['CXX']): + if "CXX" in env and "clang" in os.path.basename(env["CXX"]): # Convenience check to enforce the use_llvm overrides when CXX is clang(++) - env['use_llvm'] = True + env["use_llvm"] = True - if env['use_llvm']: - if ('clang++' not in os.path.basename(env['CXX'])): + if env["use_llvm"]: + if "clang++" not in os.path.basename(env["CXX"]): env["CC"] = "clang" env["CXX"] = "clang++" env["LINK"] = "clang++" - env.Append(CPPDEFINES=['TYPED_METHOD_BIND']) + env.Append(CPPDEFINES=["TYPED_METHOD_BIND"]) env.extra_suffix = ".llvm" + env.extra_suffix - if env['use_lld']: - if env['use_llvm']: - env.Append(LINKFLAGS=['-fuse-ld=lld']) - if env['use_thinlto']: + if env["use_lld"]: + if env["use_llvm"]: + env.Append(LINKFLAGS=["-fuse-ld=lld"]) + if env["use_thinlto"]: # A convenience so you don't need to write use_lto too when using SCons - env['use_lto'] = True + env["use_lto"] = True else: print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.") sys.exit(255) - if env['use_coverage']: - env.Append(CCFLAGS=['-ftest-coverage', '-fprofile-arcs']) - env.Append(LINKFLAGS=['-ftest-coverage', '-fprofile-arcs']) + if env["use_coverage"]: + env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) + env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) - if env['use_ubsan'] or env['use_asan'] or env['use_lsan'] or env['use_tsan']: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: env.extra_suffix += "s" - if env['use_ubsan']: - env.Append(CCFLAGS=['-fsanitize=undefined']) - env.Append(LINKFLAGS=['-fsanitize=undefined']) + if env["use_ubsan"]: + env.Append(CCFLAGS=["-fsanitize=undefined"]) + env.Append(LINKFLAGS=["-fsanitize=undefined"]) - if env['use_asan']: - env.Append(CCFLAGS=['-fsanitize=address']) - env.Append(LINKFLAGS=['-fsanitize=address']) + if env["use_asan"]: + env.Append(CCFLAGS=["-fsanitize=address"]) + env.Append(LINKFLAGS=["-fsanitize=address"]) - if env['use_lsan']: - env.Append(CCFLAGS=['-fsanitize=leak']) - env.Append(LINKFLAGS=['-fsanitize=leak']) + if env["use_lsan"]: + env.Append(CCFLAGS=["-fsanitize=leak"]) + env.Append(LINKFLAGS=["-fsanitize=leak"]) - if env['use_tsan']: - env.Append(CCFLAGS=['-fsanitize=thread']) - env.Append(LINKFLAGS=['-fsanitize=thread']) + if env["use_tsan"]: + env.Append(CCFLAGS=["-fsanitize=thread"]) + env.Append(LINKFLAGS=["-fsanitize=thread"]) - if env['use_lto']: - if not env['use_llvm'] and env.GetOption("num_jobs") > 1: - env.Append(CCFLAGS=['-flto']) - env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))]) + if env["use_lto"]: + if not env["use_llvm"] and env.GetOption("num_jobs") > 1: + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))]) else: - if env['use_lld'] and env['use_thinlto']: - env.Append(CCFLAGS=['-flto=thin']) - env.Append(LINKFLAGS=['-flto=thin']) + if env["use_lld"] and env["use_thinlto"]: + env.Append(CCFLAGS=["-flto=thin"]) + env.Append(LINKFLAGS=["-flto=thin"]) else: - env.Append(CCFLAGS=['-flto']) - env.Append(LINKFLAGS=['-flto']) + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto"]) - if not env['use_llvm']: - env['RANLIB'] = 'gcc-ranlib' - env['AR'] = 'gcc-ar' + if not env["use_llvm"]: + env["RANLIB"] = "gcc-ranlib" + env["AR"] = "gcc-ar" - env.Append(CCFLAGS=['-pipe']) - env.Append(LINKFLAGS=['-pipe']) + env.Append(CCFLAGS=["-pipe"]) + env.Append(LINKFLAGS=["-pipe"]) # -fpie and -no-pie is supported on GCC 6+ and Clang 4+, both below our # minimal requirements. - env.Append(CCFLAGS=['-fpie']) - env.Append(LINKFLAGS=['-no-pie']) + env.Append(CCFLAGS=["-fpie"]) + env.Append(LINKFLAGS=["-no-pie"]) ## Dependencies - env.ParseConfig('pkg-config x11 --cflags --libs') - env.ParseConfig('pkg-config xcursor --cflags --libs') - env.ParseConfig('pkg-config xinerama --cflags --libs') - env.ParseConfig('pkg-config xrandr --cflags --libs') - env.ParseConfig('pkg-config xrender --cflags --libs') - env.ParseConfig('pkg-config xi --cflags --libs') + env.ParseConfig("pkg-config x11 --cflags --libs") + env.ParseConfig("pkg-config xcursor --cflags --libs") + env.ParseConfig("pkg-config xinerama --cflags --libs") + env.ParseConfig("pkg-config xrandr --cflags --libs") + env.ParseConfig("pkg-config xrender --cflags --libs") + env.ParseConfig("pkg-config xi --cflags --libs") - if (env['touch']): - env.Append(CPPDEFINES=['TOUCH_ENABLED']) + if env["touch"]: + env.Append(CPPDEFINES=["TOUCH_ENABLED"]) # FIXME: Check for existence of the libs before parsing their flags with pkg-config # freetype depends on libpng and zlib, so bundling one of them while keeping others # as shared libraries leads to weird issues - if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']: - env['builtin_freetype'] = True - env['builtin_libpng'] = True - env['builtin_zlib'] = True + if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]: + env["builtin_freetype"] = True + env["builtin_libpng"] = True + env["builtin_zlib"] = True - if not env['builtin_freetype']: - env.ParseConfig('pkg-config freetype2 --cflags --libs') + if not env["builtin_freetype"]: + env.ParseConfig("pkg-config freetype2 --cflags --libs") - if not env['builtin_libpng']: - env.ParseConfig('pkg-config libpng16 --cflags --libs') + if not env["builtin_libpng"]: + env.ParseConfig("pkg-config libpng16 --cflags --libs") - if not env['builtin_bullet']: + if not env["builtin_bullet"]: # We need at least version 2.89 import subprocess - bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip() + + bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip() if str(bullet_version) < "2.89": # Abort as system bullet was requested but too old - print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.89")) + print( + "Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format( + bullet_version, "2.89" + ) + ) sys.exit(255) - env.ParseConfig('pkg-config bullet --cflags --libs') + env.ParseConfig("pkg-config bullet --cflags --libs") if False: # not env['builtin_assimp']: # FIXME: Add min version check - env.ParseConfig('pkg-config assimp --cflags --libs') + env.ParseConfig("pkg-config assimp --cflags --libs") - if not env['builtin_enet']: - env.ParseConfig('pkg-config libenet --cflags --libs') + if not env["builtin_enet"]: + env.ParseConfig("pkg-config libenet --cflags --libs") - if not env['builtin_squish']: - env.ParseConfig('pkg-config libsquish --cflags --libs') + if not env["builtin_squish"]: + env.ParseConfig("pkg-config libsquish --cflags --libs") - if not env['builtin_zstd']: - env.ParseConfig('pkg-config libzstd --cflags --libs') + if not env["builtin_zstd"]: + env.ParseConfig("pkg-config libzstd --cflags --libs") # Sound and video libraries # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - if not env['builtin_libtheora']: - env['builtin_libogg'] = False # Needed to link against system libtheora - env['builtin_libvorbis'] = False # Needed to link against system libtheora - env.ParseConfig('pkg-config theora theoradec --cflags --libs') + if not env["builtin_libtheora"]: + env["builtin_libogg"] = False # Needed to link against system libtheora + env["builtin_libvorbis"] = False # Needed to link against system libtheora + env.ParseConfig("pkg-config theora theoradec --cflags --libs") else: - list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] + list_of_x86 = ["x86_64", "x86", "i386", "i586"] if any(platform.machine() in s for s in list_of_x86): env["x86_libtheora_opt_gcc"] = True - if not env['builtin_libvpx']: - env.ParseConfig('pkg-config vpx --cflags --libs') + if not env["builtin_libvpx"]: + env.ParseConfig("pkg-config vpx --cflags --libs") - if not env['builtin_libvorbis']: - env['builtin_libogg'] = False # Needed to link against system libvorbis - env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') + if not env["builtin_libvorbis"]: + env["builtin_libogg"] = False # Needed to link against system libvorbis + env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs") - if not env['builtin_opus']: - env['builtin_libogg'] = False # Needed to link against system opus - env.ParseConfig('pkg-config opus opusfile --cflags --libs') + if not env["builtin_opus"]: + env["builtin_libogg"] = False # Needed to link against system opus + env.ParseConfig("pkg-config opus opusfile --cflags --libs") - if not env['builtin_libogg']: - env.ParseConfig('pkg-config ogg --cflags --libs') + if not env["builtin_libogg"]: + env.ParseConfig("pkg-config ogg --cflags --libs") - if not env['builtin_libwebp']: - env.ParseConfig('pkg-config libwebp --cflags --libs') + if not env["builtin_libwebp"]: + env.ParseConfig("pkg-config libwebp --cflags --libs") - if not env['builtin_mbedtls']: + if not env["builtin_mbedtls"]: # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228 - env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509']) + env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) - if not env['builtin_wslay']: - env.ParseConfig('pkg-config libwslay --cflags --libs') + if not env["builtin_wslay"]: + env.ParseConfig("pkg-config libwslay --cflags --libs") - if not env['builtin_miniupnpc']: + if not env["builtin_miniupnpc"]: # No pkgconfig file so far, hardcode default paths. env.Prepend(CPPPATH=["/usr/include/miniupnpc"]) env.Append(LIBS=["miniupnpc"]) # On Linux wchar_t should be 32-bits # 16-bit library shouldn't be required due to compiler optimisations - if not env['builtin_pcre2']: - env.ParseConfig('pkg-config libpcre2-32 --cflags --libs') + if not env["builtin_pcre2"]: + env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") ## Flags - if (os.system("pkg-config --exists alsa") == 0): # 0 means found + if os.system("pkg-config --exists alsa") == 0: # 0 means found print("Enabling ALSA") env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"]) - # Don't parse --cflags, we don't need to add /usr/include/alsa to include path - env.ParseConfig('pkg-config alsa --libs') + # Don't parse --cflags, we don't need to add /usr/include/alsa to include path + env.ParseConfig("pkg-config alsa --libs") else: print("ALSA libraries not found, disabling driver") - if env['pulseaudio']: - if (os.system("pkg-config --exists libpulse") == 0): # 0 means found + if env["pulseaudio"]: + if os.system("pkg-config --exists libpulse") == 0: # 0 means found print("Enabling PulseAudio") env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"]) - env.ParseConfig('pkg-config --cflags --libs libpulse') + env.ParseConfig("pkg-config --cflags --libs libpulse") else: print("PulseAudio development libraries not found, disabling driver") - if (platform.system() == "Linux"): + if platform.system() == "Linux": env.Append(CPPDEFINES=["JOYDEV_ENABLED"]) - if env['udev']: - if (os.system("pkg-config --exists libudev") == 0): # 0 means found + if env["udev"]: + if os.system("pkg-config --exists libudev") == 0: # 0 means found print("Enabling udev support") env.Append(CPPDEFINES=["UDEV_ENABLED"]) - env.ParseConfig('pkg-config libudev --cflags --libs') + env.ParseConfig("pkg-config libudev --cflags --libs") else: print("libudev development libraries not found, disabling udev support") # Linkflags below this line should typically stay the last ones - if not env['builtin_zlib']: - env.ParseConfig('pkg-config zlib --cflags --libs') + if not env["builtin_zlib"]: + env.ParseConfig("pkg-config zlib --cflags --libs") - env.Prepend(CPPPATH=['#platform/linuxbsd']) - env.Append(CPPDEFINES=['X11_ENABLED', 'UNIX_ENABLED']) + env.Prepend(CPPPATH=["#platform/linuxbsd"]) + env.Append(CPPDEFINES=["X11_ENABLED", "UNIX_ENABLED"]) - env.Append(CPPDEFINES=['VULKAN_ENABLED']) - if not env['builtin_vulkan']: - env.ParseConfig('pkg-config vulkan --cflags --libs') - if not env['builtin_glslang']: + env.Append(CPPDEFINES=["VULKAN_ENABLED"]) + if not env["builtin_vulkan"]: + env.ParseConfig("pkg-config vulkan --cflags --libs") + if not env["builtin_glslang"]: # No pkgconfig file for glslang so far - env.Append(LIBS=['glslang', 'SPIRV']) + env.Append(LIBS=["glslang", "SPIRV"]) - #env.Append(CPPDEFINES=['OPENGL_ENABLED']) - env.Append(LIBS=['GL']) + # env.Append(CPPDEFINES=['OPENGL_ENABLED']) + env.Append(LIBS=["GL"]) - env.Append(LIBS=['pthread']) + env.Append(LIBS=["pthread"]) - if (platform.system() == "Linux"): - env.Append(LIBS=['dl']) + if platform.system() == "Linux": + env.Append(LIBS=["dl"]) - if (platform.system().find("BSD") >= 0): + if platform.system().find("BSD") >= 0: env["execinfo"] = True if env["execinfo"]: - env.Append(LIBS=['execinfo']) + env.Append(LIBS=["execinfo"]) - if not env['tools']: + if not env["tools"]: import subprocess import re - linker_version_str = subprocess.check_output([env.subst(env["LINK"]), '-Wl,--version']).decode("utf-8") - gnu_ld_version = re.search('^GNU ld [^$]*(\d+\.\d+)$', linker_version_str, re.MULTILINE) + + linker_version_str = subprocess.check_output([env.subst(env["LINK"]), "-Wl,--version"]).decode("utf-8") + gnu_ld_version = re.search("^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE) if not gnu_ld_version: - print("Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld") + print( + "Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld" + ) else: if float(gnu_ld_version.group(1)) >= 2.30: - env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.ld']) + env.Append(LINKFLAGS=["-T", "platform/linuxbsd/pck_embed.ld"]) else: - env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.legacy.ld']) + env.Append(LINKFLAGS=["-T", "platform/linuxbsd/pck_embed.legacy.ld"]) ## Cross-compilation - if (is64 and env["bits"] == "32"): - env.Append(CCFLAGS=['-m32']) - env.Append(LINKFLAGS=['-m32', '-L/usr/lib/i386-linux-gnu']) - elif (not is64 and env["bits"] == "64"): - env.Append(CCFLAGS=['-m64']) - env.Append(LINKFLAGS=['-m64', '-L/usr/lib/i686-linux-gnu']) + if is64 and env["bits"] == "32": + env.Append(CCFLAGS=["-m32"]) + env.Append(LINKFLAGS=["-m32", "-L/usr/lib/i386-linux-gnu"]) + elif not is64 and env["bits"] == "64": + env.Append(CCFLAGS=["-m64"]) + env.Append(LINKFLAGS=["-m64", "-L/usr/lib/i686-linux-gnu"]) # Link those statically for portability - if env['use_static_cpp']: - env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++']) + if env["use_static_cpp"]: + env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) diff --git a/platform/linuxbsd/detect_prime_x11.cpp b/platform/linuxbsd/detect_prime_x11.cpp index 69b0837e6c..1bec65ff04 100644 --- a/platform/linuxbsd/detect_prime_x11.cpp +++ b/platform/linuxbsd/detect_prime_x11.cpp @@ -67,12 +67,12 @@ vendor vendormap[] = { { "Intel", 20 }, { "nouveau", 10 }, { "Mesa Project", 0 }, - { NULL, 0 } + { nullptr, 0 } }; // Runs inside a child. Exiting will not quit the engine. void create_context() { - Display *x11_display = XOpenDisplay(NULL); + Display *x11_display = XOpenDisplay(nullptr); Window x11_window; GLXContext glx_context; @@ -91,7 +91,7 @@ void create_context() { int fbcount; GLXFBConfig fbconfig = 0; - XVisualInfo *vi = NULL; + XVisualInfo *vi = nullptr; XSetWindowAttributes swa; swa.event_mask = StructureNotifyMask; @@ -114,7 +114,7 @@ void create_context() { None }; - glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, NULL, true, context_attribs); + glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, nullptr, true, context_attribs); swa.colormap = XCreateColormap(x11_display, RootWindow(x11_display, vi->screen), vi->visual, AllocNone); x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, 10, 10, 0, vi->depth, InputOutput, vi->visual, valuemask, &swa); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 4bea458187..47497eb95f 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -44,7 +44,7 @@ #endif #if defined(VULKAN_ENABLED) -#include "servers/visual/rasterizer_rd/rasterizer_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_rd.h" #endif #include "scene/resources/texture.h" @@ -902,7 +902,7 @@ void DisplayServerX11::window_set_position(const Point2i &p_position, WindowID p int format; unsigned long len; unsigned long remaining; - unsigned char *data = NULL; + unsigned char *data = nullptr; if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) { if (format == 32 && len == 4 && data) { long *extents = (long *)data; @@ -1091,7 +1091,7 @@ Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const { int format; unsigned long len; unsigned long remaining; - unsigned char *data = NULL; + unsigned char *data = nullptr; if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, 4, False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) { if (format == 32 && len == 4 && data) { long *extents = (long *)data; @@ -1116,7 +1116,7 @@ bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const { int format; unsigned long len; unsigned long remaining; - unsigned char *data = NULL; + unsigned char *data = nullptr; int result = XGetWindowProperty( x11_display, @@ -1402,7 +1402,7 @@ DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) c int format; unsigned long len; unsigned long remaining; - unsigned char *data = NULL; + unsigned char *data = nullptr; bool retval = false; int result = XGetWindowProperty( @@ -1453,7 +1453,7 @@ DisplayServer::WindowMode DisplayServerX11::window_get_mode(WindowID p_window) c int format; unsigned long len; unsigned long remaining; - unsigned char *data = NULL; + unsigned char *data = nullptr; int result = XGetWindowProperty( x11_display, @@ -1592,7 +1592,7 @@ bool DisplayServerX11::window_get_flag(WindowFlags p_flag, WindowID p_window) co int format; unsigned long len; unsigned long remaining; - unsigned char *data = NULL; + unsigned char *data = nullptr; if (XGetWindowProperty(x11_display, wd.x11_window, prop, 0, sizeof(Hints), False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) { if (data && (format == 32) && (len >= 5)) { borderless = !((Hints *)data)->decorations; @@ -1719,8 +1719,8 @@ void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_ ::XPoint spot; spot.x = short(p_pos.x); spot.y = short(p_pos.y); - XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); - XSetICValues(wd.xic, XNPreeditAttributes, preedit_attr, NULL); + XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, nullptr); + XSetICValues(wd.xic, XNPreeditAttributes, preedit_attr, nullptr); XFree(preedit_attr); } @@ -1827,7 +1827,7 @@ void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape *(cursor_image->pixels + index) = image->get_pixel(column_index, row_index).to_argb32(); } - ERR_FAIL_COND(cursor_image->pixels == NULL); + ERR_FAIL_COND(cursor_image->pixels == nullptr); // Save it for a further usage cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image); @@ -1900,14 +1900,14 @@ DisplayServerX11::Property DisplayServerX11::_read_property(Display *p_display, int actual_format; unsigned long nitems; unsigned long bytes_after; - unsigned char *ret = 0; + unsigned char *ret = nullptr; int read_bytes = 1024; //Keep trying to read the property until there are no //bytes unread. do { - if (ret != 0) + if (ret != nullptr) XFree(ret); XGetWindowProperty(p_display, p_window, p_property, 0, read_bytes, False, AnyPropertyType, @@ -2006,8 +2006,8 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, XKeyEvent xkeyevent_no_mod = *xkeyevent; xkeyevent_no_mod.state &= ~ShiftMask; xkeyevent_no_mod.state &= ~ControlMask; - XLookupString(xkeyevent, str, 256, &keysym_unicode, NULL); - XLookupString(&xkeyevent_no_mod, NULL, 0, &keysym_keycode, NULL); + XLookupString(xkeyevent, str, 256, &keysym_unicode, nullptr); + XLookupString(&xkeyevent_no_mod, nullptr, 0, &keysym_keycode, nullptr); // Meanwhile, XLookupString returns keysyms useful for unicode. @@ -2170,7 +2170,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, #undef ABSDIFF if (peek_event.type == KeyPress && threshold < 5) { KeySym rk; - XLookupString((XKeyEvent *)&peek_event, str, 256, &rk, NULL); + XLookupString((XKeyEvent *)&peek_event, str, 256, &rk, nullptr); if (rk == keysym_keycode) { XEvent event; XNextEvent(x11_display, &event); //erase next event @@ -2232,10 +2232,10 @@ void DisplayServerX11::_xim_destroy_callback(::XIM im, ::XPointer client_data, WARN_PRINT("Input method stopped"); DisplayServerX11 *ds = reinterpret_cast<DisplayServerX11 *>(client_data); - ds->xim = NULL; + ds->xim = nullptr; for (Map<WindowID, WindowData>::Element *E = ds->windows.front(); E; E = E->next()) { - E->get().xic = NULL; + E->get().xic = nullptr; } } @@ -3222,11 +3222,11 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u if (xim && xim_style) { - wd.xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, wd.x11_window, XNFocusWindow, wd.x11_window, (char *)NULL); - if (XGetICValues(wd.xic, XNFilterEvents, &im_event_mask, NULL) != NULL) { + wd.xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, wd.x11_window, XNFocusWindow, wd.x11_window, (char *)nullptr); + if (XGetICValues(wd.xic, XNFilterEvents, &im_event_mask, nullptr) != nullptr) { WARN_PRINT("XGetICValues couldn't obtain XNFilterEvents value"); XDestroyIC(wd.xic); - wd.xic = NULL; + wd.xic = nullptr; } if (wd.xic) { XUnsetICFocus(wd.xic); @@ -3235,7 +3235,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u } } else { - wd.xic = NULL; + wd.xic = nullptr; WARN_PRINT("XCreateIC couldn't create wd.xic"); } @@ -3374,9 +3374,18 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode r_error = OK; + current_cursor = CURSOR_ARROW; + mouse_mode = MOUSE_MODE_VISIBLE; + + for (int i = 0; i < CURSOR_MAX; i++) { + + cursors[i] = None; + img[i] = nullptr; + } + last_button_state = 0; - xmbstring = NULL; + xmbstring = nullptr; last_click_ms = 0; last_click_button_index = -1; @@ -3389,7 +3398,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode XInitThreads(); //always use threads /** XLIB INITIALIZATION **/ - x11_display = XOpenDisplay(NULL); + x11_display = XOpenDisplay(nullptr); if (!x11_display) { ERR_PRINT("X11 Display is not available"); @@ -3397,10 +3406,10 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode return; } - char *modifiers = NULL; + char *modifiers = nullptr; Bool xkb_dar = False; XAutoRepeatOn(x11_display); - xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL); + xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, nullptr); // Try to support IME if detectable auto-repeat is supported if (xkb_dar == True) { @@ -3412,7 +3421,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode #endif } - if (modifiers == NULL) { + if (modifiers == nullptr) { if (OS::get_singleton()->is_stdout_verbose()) { WARN_PRINT("IME is disabled"); } @@ -3421,8 +3430,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } const char *err; - xrr_get_monitors = NULL; - xrr_free_monitors = NULL; + xrr_get_monitors = nullptr; + xrr_free_monitors = nullptr; int xrandr_major = 0; int xrandr_minor = 0; int event_base, error_base; @@ -3443,7 +3452,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (!xrr_free_monitors) { err = dlerror(); fprintf(stderr, "could not find XRRFreeMonitors\nError: %s\n", err); - xrr_get_monitors = NULL; + xrr_get_monitors = nullptr; } } } @@ -3457,9 +3466,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode return; } - xim = XOpenIM(x11_display, NULL, NULL, NULL); + xim = XOpenIM(x11_display, nullptr, nullptr, nullptr); - if (xim == NULL) { + if (xim == nullptr) { WARN_PRINT("XOpenIM failed"); xim_style = 0L; } else { @@ -3467,14 +3476,14 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode im_destroy_callback.client_data = (::XPointer)(this); im_destroy_callback.callback = (::XIMProc)(_xim_destroy_callback); if (XSetIMValues(xim, XNDestroyCallback, &im_destroy_callback, - NULL) != NULL) { + nullptr) != nullptr) { WARN_PRINT("Error setting XIM destroy callback"); } - ::XIMStyles *xim_styles = NULL; + ::XIMStyles *xim_styles = nullptr; xim_style = 0L; - char *imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); - if (imvalret != NULL || xim_styles == NULL) { + char *imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, nullptr); + if (imvalret != nullptr || xim_styles == nullptr) { fprintf(stderr, "Input method doesn't support any styles\n"); } @@ -3523,7 +3532,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode context_vulkan = memnew(VulkanContextX11); if (context_vulkan->initialize() != OK) { memdelete(context_vulkan); - context_vulkan = NULL; + context_vulkan = nullptr; r_error = ERR_CANT_CREATE; ERR_FAIL_MSG("Could not initialize Vulkan"); } @@ -3532,7 +3541,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode // Init context and rendering device #if defined(OPENGL_ENABLED) if (rendering_driver == "opengl_es") { - if (getenv("DRI_PRIME") == NULL) { + if (getenv("DRI_PRIME") == nullptr) { int use_prime = -1; if (getenv("PRIMUS_DISPLAY") || @@ -3578,7 +3587,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (context_gles2->initialize() != OK) { memdelete(context_gles2); - context_gles2 = NULL; + context_gles2 = nullptr; ERR_FAIL_V(ERR_UNAVAILABLE); } @@ -3589,7 +3598,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode RasterizerGLES2::make_current(); } else { memdelete(context_gles2); - context_gles2 = NULL; + context_gles2 = nullptr; ERR_FAIL_V(ERR_UNAVAILABLE); } } @@ -3615,9 +3624,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode #endif /* - visual_server = memnew(VisualServerRaster); + rendering_server = memnew(RenderingServerRaster); if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); + rendering_server = memnew(RenderingServerWrapMT(rendering_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } */ @@ -3652,14 +3661,6 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode for (int i = 0; i < CURSOR_MAX; i++) { - cursors[i] = None; - img[i] = NULL; - } - - current_cursor = CURSOR_ARROW; - - for (int i = 0; i < CURSOR_MAX; i++) { - static const char *cursor_file[] = { "left_ptr", "xterm", @@ -3682,7 +3683,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size); if (!img[i]) { - const char *fallback = NULL; + const char *fallback = nullptr; switch (i) { case CURSOR_POINTING_HAND: @@ -3731,7 +3732,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode fallback = "help"; break; } - if (fallback != NULL) { + if (fallback != nullptr) { img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size); } } @@ -3831,7 +3832,7 @@ DisplayServerX11::~DisplayServerX11() { for (int i = 0; i < CURSOR_MAX; i++) { if (cursors[i] != None) XFreeCursor(x11_display, cursors[i]); - if (img[i] != NULL) + if (img[i] != nullptr) XcursorImageDestroy(img[i]); }; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index d1680b0508..113e504e9b 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -43,8 +43,8 @@ #include "drivers/unix/os_unix.h" #include "joypad_linux.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" #if defined(OPENGL_ENABLED) #include "context_gl_x11.h" @@ -193,7 +193,6 @@ class DisplayServerX11 : public DisplayServer { void _handle_key_event(WindowID p_window, XKeyEvent *p_event, bool p_echo = false); - bool force_quit; bool minimized; bool window_has_focus; bool do_mouse_warp; diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index c4c793093d..381eb909ba 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -54,7 +54,7 @@ JoypadLinux::Joypad::Joypad() { dpad = 0; devpath = ""; for (int i = 0; i < MAX_ABS; i++) { - abs_info[i] = NULL; + abs_info[i] = nullptr; } } @@ -146,9 +146,9 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) { void JoypadLinux::monitor_joypads(udev *p_udev) { - udev_device *dev = NULL; + udev_device *dev = nullptr; udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev"); - udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL); + udev_monitor_filter_add_match_subsystem_devtype(mon, "input", nullptr); udev_monitor_enable_receiving(mon); int fd = udev_monitor_get_fd(mon); @@ -163,7 +163,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) { tv.tv_sec = 0; tv.tv_usec = 0; - ret = select(fd + 1, &fds, NULL, NULL, &tv); + ret = select(fd + 1, &fds, nullptr, nullptr, &tv); /* Check if our file descriptor has received data. */ if (ret > 0 && FD_ISSET(fd, &fds)) { @@ -299,7 +299,7 @@ void JoypadLinux::setup_joypad_properties(int p_id) { joy->abs_info[i] = memnew(input_absinfo); if (ioctl(joy->fd, EVIOCGABS(i), joy->abs_info[i]) < 0) { memdelete(joy->abs_info[i]); - joy->abs_info[i] = NULL; + joy->abs_info[i] = nullptr; } } } diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 084453bdc6..5b9a25bd8b 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -87,7 +87,7 @@ void OS_LinuxBSD::finalize() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; #ifdef ALSAMIDI_ENABLED driver_alsamidi.close(); @@ -107,7 +107,7 @@ void OS_LinuxBSD::delete_main_loop() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; } void OS_LinuxBSD::set_main_loop(MainLoop *p_main_loop) { @@ -230,7 +230,7 @@ String OS_LinuxBSD::get_system_dir(SystemDir p_dir) const { String pipe; List<String> arg; arg.push_back(xdgparam); - Error err = const_cast<OS_LinuxBSD *>(this)->execute("xdg-user-dir", arg, true, NULL, &pipe); + Error err = const_cast<OS_LinuxBSD *>(this)->execute("xdg-user-dir", arg, true, nullptr, &pipe); if (err != OK) return "."; return pipe.strip_edges(); @@ -351,7 +351,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { mv_args.push_back(p_path); mv_args.push_back(trash_can); int retval; - err = execute("mv", mv_args, true, NULL, NULL, &retval); + err = execute("mv", mv_args, true, nullptr, nullptr, &retval); // Issue an error if "mv" failed to move the given resource to the trash can. if (err != OK || retval != 0) { @@ -364,7 +364,7 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { OS_LinuxBSD::OS_LinuxBSD() { - main_loop = NULL; + main_loop = nullptr; force_quit = false; #ifdef PULSEAUDIO_ENABLED diff --git a/platform/linuxbsd/os_linuxbsd.h b/platform/linuxbsd/os_linuxbsd.h index 6c656c1945..100cb53ba3 100644 --- a/platform/linuxbsd/os_linuxbsd.h +++ b/platform/linuxbsd/os_linuxbsd.h @@ -39,8 +39,8 @@ #include "drivers/unix/os_unix.h" #include "joypad_linux.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" class OS_LinuxBSD : public OS_Unix { diff --git a/platform/linuxbsd/platform_linuxbsd_builders.py b/platform/linuxbsd/platform_linuxbsd_builders.py index a72306a9c0..58234f3748 100644 --- a/platform/linuxbsd/platform_linuxbsd_builders.py +++ b/platform/linuxbsd/platform_linuxbsd_builders.py @@ -8,10 +8,10 @@ from platform_methods import subprocess_main def make_debug_linuxbsd(target, source, env): - os.system('objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0])) - os.system('strip --strip-debug --strip-unneeded {0}'.format(target[0])) - os.system('objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0])) + os.system("objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0])) + os.system("strip --strip-debug --strip-unneeded {0}".format(target[0])) + os.system("objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0])) -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/platform/linuxbsd/vulkan_context_x11.cpp b/platform/linuxbsd/vulkan_context_x11.cpp index d0e1b1678c..1798a7026e 100644 --- a/platform/linuxbsd/vulkan_context_x11.cpp +++ b/platform/linuxbsd/vulkan_context_x11.cpp @@ -39,13 +39,13 @@ Error VulkanContextX11::window_create(DisplayServer::WindowID p_window_id, ::Win VkXlibSurfaceCreateInfoKHR createInfo; createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; - createInfo.pNext = NULL; + createInfo.pNext = nullptr; createInfo.flags = 0; createInfo.dpy = p_display; createInfo.window = p_window; VkSurfaceKHR surface; - VkResult err = vkCreateXlibSurfaceKHR(_get_instance(), &createInfo, NULL, &surface); + VkResult err = vkCreateXlibSurfaceKHR(_get_instance(), &createInfo, nullptr, &surface); ERR_FAIL_COND_V(err, ERR_CANT_CREATE); return _window_create(p_window_id, surface, p_width, p_height); } diff --git a/platform/osx/SCsub b/platform/osx/SCsub index 4ec8aeab6d..ad62db358b 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -1,23 +1,22 @@ #!/usr/bin/env python -Import('env') +Import("env") from platform_methods import run_in_subprocess import platform_osx_builders files = [ - 'crash_handler_osx.mm', - 'os_osx.mm', - 'display_server_osx.mm', - 'godot_main_osx.mm', - 'dir_access_osx.mm', - 'joypad_osx.cpp', - 'vulkan_context_osx.mm', - 'context_gl_osx.mm' + "crash_handler_osx.mm", + "os_osx.mm", + "display_server_osx.mm", + "godot_main_osx.mm", + "dir_access_osx.mm", + "joypad_osx.cpp", + "vulkan_context_osx.mm", + "context_gl_osx.mm", ] -prog = env.add_program('#bin/godot', files) +prog = env.add_program("#bin/godot", files) if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx)) - diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 12ca5c10dc..29aa8ece19 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -14,7 +14,7 @@ def get_name(): def can_build(): - if (sys.platform == "darwin" or ("OSXCROSS_ROOT" in os.environ)): + if sys.platform == "darwin" or ("OSXCROSS_ROOT" in os.environ): return True return False @@ -24,52 +24,55 @@ def get_opts(): from SCons.Variables import BoolVariable, EnumVariable return [ - ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), - ('MACOS_SDK_PATH', 'Path to the macOS SDK', ''), - BoolVariable('use_static_mvk', 'Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables validation layers)', False), - EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), - BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), - BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False), - BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False), - BoolVariable('use_tsan', 'Use LLVM/GCC compiler thread sanitizer (TSAN))', False), + ("osxcross_sdk", "OSXCross SDK version", "darwin14"), + ("MACOS_SDK_PATH", "Path to the macOS SDK", ""), + BoolVariable( + "use_static_mvk", + "Link MoltenVK statically as Level-0 driver (better portability) or use Vulkan ICD loader (enables validation layers)", + False, + ), + EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")), + BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), + BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), + BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), + BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), ] def get_flags(): - return [ - ] + return [] def configure(env): - ## Build type - - if (env["target"] == "release"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O3', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os','-ftree-vectorize', '-msse2']) - - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "release_debug"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O2']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - env.Prepend(CPPDEFINES=['DEBUG_ENABLED']) - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3']) - env.Prepend(CPPDEFINES=['DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) + ## Build type + + if env["target"] == "release": + if env["optimize"] == "speed": # optimize for speed (default) + env.Prepend(CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize", "-msse2"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize", "-msse2"]) + + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "release_debug": + if env["optimize"] == "speed": # optimize for speed (default) + env.Prepend(CCFLAGS=["-O2"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "debug": + env.Prepend(CCFLAGS=["-g3"]) + env.Prepend(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) ## Architecture @@ -83,86 +86,109 @@ def configure(env): if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True - if not "osxcross" in env: # regular native build - env.Append(CCFLAGS=['-arch', 'x86_64']) - env.Append(LINKFLAGS=['-arch', 'x86_64']) - if (env["macports_clang"] != 'no'): + if not "osxcross" in env: # regular native build + env.Append(CCFLAGS=["-arch", "x86_64"]) + env.Append(LINKFLAGS=["-arch", "x86_64"]) + if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang" env["LINK"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" - env['AR'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" - env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" - env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" - env.Append(CPPDEFINES=['__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define + env["AR"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" + env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" + env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" + env.Append(CPPDEFINES=["__MACPORTS__"]) # hack to fix libvpx MM256_BROADCASTSI128_SI256 define else: - env['CC'] = 'clang' - env['CXX'] = 'clang++' + env["CC"] = "clang" + env["CXX"] = "clang++" - detect_darwin_sdk_path('osx', env) - env.Append(CCFLAGS=['-isysroot', '$MACOS_SDK_PATH']) - env.Append(LINKFLAGS=['-isysroot', '$MACOS_SDK_PATH']) + detect_darwin_sdk_path("osx", env) + env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) + env.Append(LINKFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) - else: # osxcross build + else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: - env['CC'] = basecmd + "cc" - env['CXX'] = basecmd + "c++" + env["CC"] = basecmd + "cc" + env["CXX"] = basecmd + "c++" else: # there aren't any ccache wrappers available for OS X cross-compile, # to enable caching we need to prepend the path to the ccache binary - env['CC'] = ccache_path + ' ' + basecmd + "cc" - env['CXX'] = ccache_path + ' ' + basecmd + "c++" - env['AR'] = basecmd + "ar" - env['RANLIB'] = basecmd + "ranlib" - env['AS'] = basecmd + "as" - env.Append(CPPDEFINES=['__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define - - if (env["CXX"] == "clang++"): - env.Append(CPPDEFINES=['TYPED_METHOD_BIND']) + env["CC"] = ccache_path + " " + basecmd + "cc" + env["CXX"] = ccache_path + " " + basecmd + "c++" + env["AR"] = basecmd + "ar" + env["RANLIB"] = basecmd + "ranlib" + env["AS"] = basecmd + "as" + env.Append(CPPDEFINES=["__MACPORTS__"]) # hack to fix libvpx MM256_BROADCASTSI128_SI256 define + + if env["CXX"] == "clang++": + env.Append(CPPDEFINES=["TYPED_METHOD_BIND"]) env["CC"] = "clang" env["LINK"] = "clang++" - if env['use_ubsan'] or env['use_asan'] or env['use_tsan']: + if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]: env.extra_suffix += "s" - if env['use_ubsan']: - env.Append(CCFLAGS=['-fsanitize=undefined']) - env.Append(LINKFLAGS=['-fsanitize=undefined']) + if env["use_ubsan"]: + env.Append(CCFLAGS=["-fsanitize=undefined"]) + env.Append(LINKFLAGS=["-fsanitize=undefined"]) - if env['use_asan']: - env.Append(CCFLAGS=['-fsanitize=address']) - env.Append(LINKFLAGS=['-fsanitize=address']) + if env["use_asan"]: + env.Append(CCFLAGS=["-fsanitize=address"]) + env.Append(LINKFLAGS=["-fsanitize=address"]) - if env['use_tsan']: - env.Append(CCFLAGS=['-fsanitize=thread']) - env.Append(LINKFLAGS=['-fsanitize=thread']) + if env["use_tsan"]: + env.Append(CCFLAGS=["-fsanitize=thread"]) + env.Append(LINKFLAGS=["-fsanitize=thread"]) ## Dependencies - if env['builtin_libtheora']: + if env["builtin_libtheora"]: env["x86_libtheora_opt_gcc"] = True ## Flags - env.Prepend(CPPPATH=['#platform/osx']) - env.Append(CPPDEFINES=['OSX_ENABLED', 'UNIX_ENABLED', 'APPLE_STYLE_KEYS', 'COREAUDIO_ENABLED', 'COREMIDI_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreMIDI', '-framework', 'IOKit', '-framework', 'ForceFeedback', '-framework', 'CoreVideo', '-framework', 'AVFoundation', '-framework', 'CoreMedia']) - env.Append(LIBS=['pthread', 'z']) - - env.Append(CPPDEFINES=['VULKAN_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'Metal', '-framework', 'QuartzCore', '-framework', 'IOSurface']) - if (env['use_static_mvk']): - env.Append(LINKFLAGS=['-framework', 'MoltenVK']) - env['builtin_vulkan'] = False - elif not env['builtin_vulkan']: - env.Append(LIBS=['vulkan']) - - #env.Append(CPPDEFINES=['GLES_ENABLED', 'OPENGL_ENABLED']) - - env.Append(CCFLAGS=['-mmacosx-version-min=10.12']) - env.Append(LINKFLAGS=['-mmacosx-version-min=10.12']) + env.Prepend(CPPPATH=["#platform/osx"]) + env.Append(CPPDEFINES=["OSX_ENABLED", "UNIX_ENABLED", "APPLE_STYLE_KEYS", "COREAUDIO_ENABLED", "COREMIDI_ENABLED"]) + env.Append( + LINKFLAGS=[ + "-framework", + "Cocoa", + "-framework", + "Carbon", + "-framework", + "AudioUnit", + "-framework", + "CoreAudio", + "-framework", + "CoreMIDI", + "-framework", + "IOKit", + "-framework", + "ForceFeedback", + "-framework", + "CoreVideo", + "-framework", + "AVFoundation", + "-framework", + "CoreMedia", + ] + ) + env.Append(LIBS=["pthread", "z"]) + + env.Append(CPPDEFINES=["VULKAN_ENABLED"]) + env.Append(LINKFLAGS=["-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface"]) + if env["use_static_mvk"]: + env.Append(LINKFLAGS=["-framework", "MoltenVK"]) + env["builtin_vulkan"] = False + elif not env["builtin_vulkan"]: + env.Append(LIBS=["vulkan"]) + + # env.Append(CPPDEFINES=['GLES_ENABLED', 'OPENGL_ENABLED']) + + env.Append(CCFLAGS=["-mmacosx-version-min=10.12"]) + env.Append(LINKFLAGS=["-mmacosx-version-min=10.12"]) diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index 33f483bd0e..86ceb51763 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -71,8 +71,8 @@ public: const NSMenu *_get_menu_root(const String &p_menu_root) const; NSMenu *_get_menu_root(const String &p_menu_root); - NSMenu *apple_menu = NULL; - NSMenu *dock_menu = NULL; + NSMenu *apple_menu = nullptr; + NSMenu *dock_menu = nullptr; Map<String, NSMenu *> submenu; struct KeyEvent { @@ -95,7 +95,7 @@ public: id window_view; #if defined(OPENGL_ENABLED) - ContextGL_OSX *context_gles2 = NULL; + ContextGL_OSX *context_gles2 = nullptr; #endif Point2i mouse_pos; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 3bdd12ec9d..074fc3be0d 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -50,7 +50,7 @@ #endif #if defined(VULKAN_ENABLED) -#include "servers/visual/rasterizer_rd/rasterizer_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_rd.h" #include <QuartzCore/CAMetalLayer.h> #endif diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index dbe52da912..c2df9c7082 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -402,7 +402,7 @@ Error EditorExportPlatformOSX::_code_sign(const Ref<EditorExportPreset> &p_prese args.push_back(p_path); String str; - Error err = OS::get_singleton()->execute("codesign", args, true, NULL, &str, NULL, true); + Error err = OS::get_singleton()->execute("codesign", args, true, nullptr, &str, nullptr, true); ERR_FAIL_COND_V(err != OK, err); print_line("codesign (" + p_path + "): " + str); @@ -435,7 +435,7 @@ Error EditorExportPlatformOSX::_create_dmg(const String &p_dmg_path, const Strin args.push_back(p_app_path_name); String str; - Error err = OS::get_singleton()->execute("hdiutil", args, true, NULL, &str, NULL, true); + Error err = OS::get_singleton()->execute("hdiutil", args, true, nullptr, &str, nullptr, true); ERR_FAIL_COND_V(err != OK, err); print_line("hdiutil returned: " + str); @@ -476,7 +476,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p return ERR_FILE_BAD_PATH; } - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); if (ep.step("Creating app", 0)) { @@ -507,11 +507,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p Error err = OK; String tmp_app_path_name = ""; zlib_filefunc_def io2 = io; - FileAccess *dst_f = NULL; + FileAccess *dst_f = nullptr; io2.opaque = &dst_f; - zipFile dst_pkg_zip = NULL; + zipFile dst_pkg_zip = nullptr; - DirAccess *tmp_app_path = NULL; + DirAccess *tmp_app_path = nullptr; String export_format = use_dmg() && p_path.ends_with("dmg") ? "dmg" : "zip"; if (export_format == "dmg") { // We're on OSX so we can export to DMG, but first we create our application bundle @@ -539,7 +539,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p } } else { // Open our destination zip file - dst_pkg_zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2); + dst_pkg_zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2); if (!dst_pkg_zip) { err = ERR_CANT_CREATE; } @@ -555,7 +555,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(src_pkg_zip, &info, fname, 16384, nullptr, 0, nullptr, 0); String file = fname; @@ -672,11 +672,11 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p zipOpenNewFileInZip(dst_pkg_zip, file.utf8().get_data(), &fi, - NULL, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION); @@ -754,12 +754,12 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (err == OK) { zipOpenNewFileInZip(dst_pkg_zip, (pkg_name + ".app/Contents/Resources/" + pkg_name + ".pck").utf8().get_data(), - NULL, - NULL, + nullptr, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION); @@ -791,12 +791,12 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p zipOpenNewFileInZip(dst_pkg_zip, (pkg_name + ".app/Contents/Frameworks/").plus_file(shared_objects[i].path.get_file()).utf8().get_data(), - NULL, - NULL, + nullptr, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION); @@ -811,7 +811,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p } if (dst_pkg_zip) { - zipClose(dst_pkg_zip, NULL); + zipClose(dst_pkg_zip, nullptr); } return err; diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index f2d9de6fbd..643acd8944 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -34,13 +34,13 @@ #define GODOT_JOY_LOOP_RUN_MODE CFSTR("GodotJoypad") -static JoypadOSX *self = NULL; +static JoypadOSX *self = nullptr; joypad::joypad() { - device_ref = NULL; - ff_device = NULL; - ff_axes = NULL; - ff_directions = NULL; + device_ref = nullptr; + ff_device = nullptr; + ff_axes = nullptr; + ff_directions = nullptr; ffservice = 0; ff_timestamp = 0; id = 0; @@ -53,7 +53,7 @@ joypad::joypad() { ff_effect.dwTriggerButton = FFEB_NOTRIGGER; ff_effect.dwStartDelay = 0; ff_effect.dwTriggerRepeatInterval = 0; - ff_effect.lpEnvelope = NULL; + ff_effect.lpEnvelope = nullptr; ff_effect.cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); ff_effect.lpvTypeSpecificParams = &ff_constant_force; ff_effect.dwSize = sizeof(ff_effect); @@ -105,7 +105,7 @@ void joypad::add_hid_element(IOHIDElementRef p_element) { const IOHIDElementCookie cookie = IOHIDElementGetCookie(p_element); const uint32_t usagePage = IOHIDElementGetUsagePage(p_element); const uint32_t usage = IOHIDElementGetUsage(p_element); - Vector<rec_element> *list = NULL; + Vector<rec_element> *list = nullptr; switch (IOHIDElementGetType(p_element)) { case kIOHIDElementTypeInput_Misc: @@ -249,7 +249,7 @@ void JoypadOSX::_device_added(IOReturn p_res, IOHIDDeviceRef p_device) { if (is_joypad(p_device)) { configure_joypad(p_device, &new_joypad); #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 - if (IOHIDDeviceGetService != NULL) { + if (IOHIDDeviceGetService != nullptr) { #endif const io_service_t ioservice = IOHIDDeviceGetService(p_device); if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK) && new_joypad.config_force_feedback(ioservice)) { @@ -330,7 +330,7 @@ bool JoypadOSX::configure_joypad(IOHIDDeviceRef p_device_ref, joypad *p_joy) { input->joy_connection_changed(id, true, name, guid); } - CFArrayRef array = IOHIDDeviceCopyMatchingElements(p_device_ref, NULL, kIOHIDOptionsTypeNone); + CFArrayRef array = IOHIDDeviceCopyMatchingElements(p_device_ref, nullptr, kIOHIDOptionsTypeNone); if (array) { p_joy->add_hid_elements(array); CFRelease(array); @@ -531,7 +531,7 @@ bool JoypadOSX::have_device(IOHIDDeviceRef p_device) const { } static CFDictionaryRef create_match_dictionary(const UInt32 page, const UInt32 usage, int *okay) { - CFDictionaryRef retval = NULL; + CFDictionaryRef retval = nullptr; CFNumberRef pageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); CFNumberRef usageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage); const void *keys[2] = { (void *)CFSTR(kIOHIDDeviceUsagePageKey), (void *)CFSTR(kIOHIDDeviceUsageKey) }; @@ -562,8 +562,8 @@ void JoypadOSX::config_hid_manager(CFArrayRef p_matching_array) const { ERR_FAIL_COND(ret != kIOReturnSuccess); IOHIDManagerSetDeviceMatchingMultiple(hid_manager, p_matching_array); - IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, joypad_added_callback, NULL); - IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, joypad_removed_callback, NULL); + IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, joypad_added_callback, nullptr); + IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, joypad_removed_callback, nullptr); IOHIDManagerScheduleWithRunLoop(hid_manager, runloop, GODOT_JOY_LOOP_RUN_MODE); while (CFRunLoopRunInMode(GODOT_JOY_LOOP_RUN_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { @@ -582,7 +582,7 @@ JoypadOSX::JoypadOSX(InputFilter *in) { (void *)create_match_dictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController, &okay), }; const size_t n_elements = sizeof(vals) / sizeof(vals[0]); - CFArrayRef array = okay ? CFArrayCreate(kCFAllocatorDefault, vals, n_elements, &kCFTypeArrayCallBacks) : NULL; + CFArrayRef array = okay ? CFArrayCreate(kCFAllocatorDefault, vals, n_elements, &kCFTypeArrayCallBacks) : nullptr; for (size_t i = 0; i < n_elements; i++) { if (vals[i]) { @@ -592,7 +592,7 @@ JoypadOSX::JoypadOSX(InputFilter *in) { if (array) { hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); - if (hid_manager != NULL) { + if (hid_manager != nullptr) { config_hid_manager(array); } CFRelease(array); @@ -608,5 +608,5 @@ JoypadOSX::~JoypadOSX() { IOHIDManagerUnscheduleFromRunLoop(hid_manager, CFRunLoopGetCurrent(), GODOT_JOY_LOOP_RUN_MODE); IOHIDManagerClose(hid_manager, kIOHIDOptionsTypeNone); CFRelease(hid_manager); - hid_manager = NULL; + hid_manager = nullptr; } diff --git a/platform/osx/platform_osx_builders.py b/platform/osx/platform_osx_builders.py index 81997f674b..953ed479db 100644 --- a/platform/osx/platform_osx_builders.py +++ b/platform/osx/platform_osx_builders.py @@ -8,14 +8,14 @@ from platform_methods import subprocess_main def make_debug_osx(target, source, env): - if (env["macports_clang"] != 'no'): + if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] - os.system(mpprefix + '/libexec/llvm-' + mpclangver + '/bin/llvm-dsymutil {0} -o {0}.dSYM'.format(target[0])) + os.system(mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-dsymutil {0} -o {0}.dSYM".format(target[0])) else: - os.system('dsymutil {0} -o {0}.dSYM'.format(target[0])) - os.system('strip -u -r {0}'.format(target[0])) + os.system("dsymutil {0} -o {0}.dSYM".format(target[0])) + os.system("strip -u -r {0}".format(target[0])) -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/platform/server/SCsub b/platform/server/SCsub index 8364164114..15b9af4d25 100644 --- a/platform/server/SCsub +++ b/platform/server/SCsub @@ -2,15 +2,15 @@ import sys -Import('env') +Import("env") -common_server = [\ - "os_server.cpp",\ +common_server = [ + "os_server.cpp", ] if sys.platform == "darwin": - common_server.append("#platform/osx/crash_handler_osx.mm") + common_server.append("#platform/osx/crash_handler_osx.mm") else: - common_server.append("#platform/x11/crash_handler_x11.cpp") + common_server.append("#platform/x11/crash_handler_x11.cpp") -prog = env.add_program('#bin/godot_server', ['godot_server.cpp'] + common_server) +prog = env.add_program("#bin/godot_server", ["godot_server.cpp"] + common_server) diff --git a/platform/server/detect.py b/platform/server/detect.py index 4ea4bddddd..a73810cdf4 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -5,6 +5,7 @@ import sys # This file is mostly based on platform/x11/detect.py. # If editing this file, make sure to apply relevant changes here too. + def is_active(): return True @@ -14,14 +15,14 @@ def get_name(): def get_program_suffix(): - if (sys.platform == "darwin"): + if sys.platform == "darwin": return "osx" return "linuxbsd" def can_build(): - if (os.name != "posix"): + if os.name != "posix": return False return True @@ -29,17 +30,18 @@ def can_build(): def get_opts(): from SCons.Variables import BoolVariable, EnumVariable + return [ - BoolVariable('use_llvm', 'Use the LLVM compiler', False), - BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically for better portability', False), - BoolVariable('use_coverage', 'Test Godot coverage', False), - BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False), - BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False), - BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False), - BoolVariable('use_tsan', 'Use LLVM/GCC compiler thread sanitizer (TSAN))', False), - EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), - BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), - BoolVariable('execinfo', 'Use libexecinfo on systems where glibc is not available', False), + BoolVariable("use_llvm", "Use the LLVM compiler", False), + BoolVariable("use_static_cpp", "Link libgcc and libstdc++ statically for better portability", False), + BoolVariable("use_coverage", "Test Godot coverage", False), + BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), + BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), + BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), + BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), + EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")), + BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), + BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False), ] @@ -52,89 +54,89 @@ def configure(env): ## Build type - if (env["target"] == "release"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O3']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "release_debug"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Prepend(CCFLAGS=['-O2']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - env.Prepend(CPPDEFINES=['DEBUG_ENABLED']) - - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "debug"): - env.Prepend(CCFLAGS=['-g3']) - env.Prepend(CPPDEFINES=['DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) - env.Append(LINKFLAGS=['-rdynamic']) + if env["target"] == "release": + if env["optimize"] == "speed": # optimize for speed (default) + env.Prepend(CCFLAGS=["-O3"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "release_debug": + if env["optimize"] == "speed": # optimize for speed (default) + env.Prepend(CCFLAGS=["-O2"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) + + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "debug": + env.Prepend(CCFLAGS=["-g3"]) + env.Prepend(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) + env.Append(LINKFLAGS=["-rdynamic"]) ## Architecture - is64 = sys.maxsize > 2**32 - if (env["bits"] == "default"): + is64 = sys.maxsize > 2 ** 32 + if env["bits"] == "default": env["bits"] = "64" if is64 else "32" ## Compiler configuration - if 'CXX' in env and 'clang' in os.path.basename(env['CXX']): + if "CXX" in env and "clang" in os.path.basename(env["CXX"]): # Convenience check to enforce the use_llvm overrides when CXX is clang(++) - env['use_llvm'] = True + env["use_llvm"] = True - if env['use_llvm']: - if ('clang++' not in os.path.basename(env['CXX'])): + if env["use_llvm"]: + if "clang++" not in os.path.basename(env["CXX"]): env["CC"] = "clang" env["CXX"] = "clang++" env["LINK"] = "clang++" - env.Append(CPPDEFINES=['TYPED_METHOD_BIND']) + env.Append(CPPDEFINES=["TYPED_METHOD_BIND"]) env.extra_suffix = ".llvm" + env.extra_suffix - if env['use_coverage']: - env.Append(CCFLAGS=['-ftest-coverage', '-fprofile-arcs']) - env.Append(LINKFLAGS=['-ftest-coverage', '-fprofile-arcs']) + if env["use_coverage"]: + env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) + env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) - if env['use_ubsan'] or env['use_asan'] or env['use_lsan'] or env['use_tsan']: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: env.extra_suffix += "s" - if env['use_ubsan']: - env.Append(CCFLAGS=['-fsanitize=undefined']) - env.Append(LINKFLAGS=['-fsanitize=undefined']) + if env["use_ubsan"]: + env.Append(CCFLAGS=["-fsanitize=undefined"]) + env.Append(LINKFLAGS=["-fsanitize=undefined"]) - if env['use_asan']: - env.Append(CCFLAGS=['-fsanitize=address']) - env.Append(LINKFLAGS=['-fsanitize=address']) + if env["use_asan"]: + env.Append(CCFLAGS=["-fsanitize=address"]) + env.Append(LINKFLAGS=["-fsanitize=address"]) - if env['use_lsan']: - env.Append(CCFLAGS=['-fsanitize=leak']) - env.Append(LINKFLAGS=['-fsanitize=leak']) + if env["use_lsan"]: + env.Append(CCFLAGS=["-fsanitize=leak"]) + env.Append(LINKFLAGS=["-fsanitize=leak"]) - if env['use_tsan']: - env.Append(CCFLAGS=['-fsanitize=thread']) - env.Append(LINKFLAGS=['-fsanitize=thread']) + if env["use_tsan"]: + env.Append(CCFLAGS=["-fsanitize=thread"]) + env.Append(LINKFLAGS=["-fsanitize=thread"]) - if env['use_lto']: - env.Append(CCFLAGS=['-flto']) - if not env['use_llvm'] and env.GetOption("num_jobs") > 1: - env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))]) + if env["use_lto"]: + env.Append(CCFLAGS=["-flto"]) + if not env["use_llvm"] and env.GetOption("num_jobs") > 1: + env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))]) else: - env.Append(LINKFLAGS=['-flto']) - if not env['use_llvm']: - env['RANLIB'] = 'gcc-ranlib' - env['AR'] = 'gcc-ar' + env.Append(LINKFLAGS=["-flto"]) + if not env["use_llvm"]: + env["RANLIB"] = "gcc-ranlib" + env["AR"] = "gcc-ar" - env.Append(CCFLAGS=['-pipe']) - env.Append(LINKFLAGS=['-pipe']) + env.Append(CCFLAGS=["-pipe"]) + env.Append(LINKFLAGS=["-pipe"]) ## Dependencies @@ -142,109 +144,114 @@ def configure(env): # freetype depends on libpng and zlib, so bundling one of them while keeping others # as shared libraries leads to weird issues - if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']: - env['builtin_freetype'] = True - env['builtin_libpng'] = True - env['builtin_zlib'] = True + if env["builtin_freetype"] or env["builtin_libpng"] or env["builtin_zlib"]: + env["builtin_freetype"] = True + env["builtin_libpng"] = True + env["builtin_zlib"] = True - if not env['builtin_freetype']: - env.ParseConfig('pkg-config freetype2 --cflags --libs') + if not env["builtin_freetype"]: + env.ParseConfig("pkg-config freetype2 --cflags --libs") - if not env['builtin_libpng']: - env.ParseConfig('pkg-config libpng16 --cflags --libs') + if not env["builtin_libpng"]: + env.ParseConfig("pkg-config libpng16 --cflags --libs") - if not env['builtin_bullet']: + if not env["builtin_bullet"]: # We need at least version 2.89 import subprocess - bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip() + + bullet_version = subprocess.check_output(["pkg-config", "bullet", "--modversion"]).strip() if str(bullet_version) < "2.89": # Abort as system bullet was requested but too old - print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.89")) + print( + "Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format( + bullet_version, "2.89" + ) + ) sys.exit(255) - env.ParseConfig('pkg-config bullet --cflags --libs') + env.ParseConfig("pkg-config bullet --cflags --libs") if False: # not env['builtin_assimp']: # FIXME: Add min version check - env.ParseConfig('pkg-config assimp --cflags --libs') + env.ParseConfig("pkg-config assimp --cflags --libs") - if not env['builtin_enet']: - env.ParseConfig('pkg-config libenet --cflags --libs') + if not env["builtin_enet"]: + env.ParseConfig("pkg-config libenet --cflags --libs") - if not env['builtin_squish']: - env.ParseConfig('pkg-config libsquish --cflags --libs') + if not env["builtin_squish"]: + env.ParseConfig("pkg-config libsquish --cflags --libs") - if not env['builtin_zstd']: - env.ParseConfig('pkg-config libzstd --cflags --libs') + if not env["builtin_zstd"]: + env.ParseConfig("pkg-config libzstd --cflags --libs") # Sound and video libraries # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) - if not env['builtin_libtheora']: - env['builtin_libogg'] = False # Needed to link against system libtheora - env['builtin_libvorbis'] = False # Needed to link against system libtheora - env.ParseConfig('pkg-config theora theoradec --cflags --libs') + if not env["builtin_libtheora"]: + env["builtin_libogg"] = False # Needed to link against system libtheora + env["builtin_libvorbis"] = False # Needed to link against system libtheora + env.ParseConfig("pkg-config theora theoradec --cflags --libs") else: - list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] + list_of_x86 = ["x86_64", "x86", "i386", "i586"] if any(platform.machine() in s for s in list_of_x86): env["x86_libtheora_opt_gcc"] = True - if not env['builtin_libvpx']: - env.ParseConfig('pkg-config vpx --cflags --libs') + if not env["builtin_libvpx"]: + env.ParseConfig("pkg-config vpx --cflags --libs") - if not env['builtin_libvorbis']: - env['builtin_libogg'] = False # Needed to link against system libvorbis - env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') + if not env["builtin_libvorbis"]: + env["builtin_libogg"] = False # Needed to link against system libvorbis + env.ParseConfig("pkg-config vorbis vorbisfile --cflags --libs") - if not env['builtin_opus']: - env['builtin_libogg'] = False # Needed to link against system opus - env.ParseConfig('pkg-config opus opusfile --cflags --libs') + if not env["builtin_opus"]: + env["builtin_libogg"] = False # Needed to link against system opus + env.ParseConfig("pkg-config opus opusfile --cflags --libs") - if not env['builtin_libogg']: - env.ParseConfig('pkg-config ogg --cflags --libs') + if not env["builtin_libogg"]: + env.ParseConfig("pkg-config ogg --cflags --libs") - if not env['builtin_libwebp']: - env.ParseConfig('pkg-config libwebp --cflags --libs') + if not env["builtin_libwebp"]: + env.ParseConfig("pkg-config libwebp --cflags --libs") - if not env['builtin_mbedtls']: + if not env["builtin_mbedtls"]: # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228 - env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509']) + env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"]) - if not env['builtin_wslay']: - env.ParseConfig('pkg-config libwslay --cflags --libs') + if not env["builtin_wslay"]: + env.ParseConfig("pkg-config libwslay --cflags --libs") - if not env['builtin_miniupnpc']: + if not env["builtin_miniupnpc"]: # No pkgconfig file so far, hardcode default paths. env.Prepend(CPPPATH=["/usr/include/miniupnpc"]) env.Append(LIBS=["miniupnpc"]) # On Linux wchar_t should be 32-bits # 16-bit library shouldn't be required due to compiler optimisations - if not env['builtin_pcre2']: - env.ParseConfig('pkg-config libpcre2-32 --cflags --libs') + if not env["builtin_pcre2"]: + env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") ## Flags # Linkflags below this line should typically stay the last ones - if not env['builtin_zlib']: - env.ParseConfig('pkg-config zlib --cflags --libs') + if not env["builtin_zlib"]: + env.ParseConfig("pkg-config zlib --cflags --libs") - env.Prepend(CPPPATH=['#platform/server']) - env.Append(CPPDEFINES=['SERVER_ENABLED', 'UNIX_ENABLED']) + env.Prepend(CPPPATH=["#platform/server"]) + env.Append(CPPDEFINES=["SERVER_ENABLED", "UNIX_ENABLED"]) - if (platform.system() == "Darwin"): - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-lz', '-framework', 'IOKit']) + if platform.system() == "Darwin": + env.Append(LINKFLAGS=["-framework", "Cocoa", "-framework", "Carbon", "-lz", "-framework", "IOKit"]) - env.Append(LIBS=['pthread']) + env.Append(LIBS=["pthread"]) - if (platform.system() == "Linux"): - env.Append(LIBS=['dl']) + if platform.system() == "Linux": + env.Append(LIBS=["dl"]) - if (platform.system().find("BSD") >= 0): + if platform.system().find("BSD") >= 0: env["execinfo"] = True if env["execinfo"]: - env.Append(LIBS=['execinfo']) + env.Append(LIBS=["execinfo"]) # Link those statically for portability - if env['use_static_cpp']: - env.Append(LINKFLAGS=['-static-libgcc', '-static-libstdc++']) + if env["use_static_cpp"]: + env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 3257ec261c..0fda0663a2 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -33,7 +33,7 @@ #include "core/print_string.h" #include "drivers/dummy/rasterizer_dummy.h" #include "drivers/dummy/texture_loader_dummy.h" -#include "servers/visual/visual_server_raster.h" +#include "servers/rendering/rendering_server_raster.h" #include "main/main.h" @@ -74,14 +74,14 @@ Error OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int args = OS::get_singleton()->get_cmdline_args(); current_videomode = p_desired; - main_loop = NULL; + main_loop = nullptr; RasterizerDummy::make_current(); video_driver_index = p_video_driver; // unused in server platform, but should still be initialized - visual_server = memnew(VisualServerRaster); - visual_server->init(); + rendering_server = memnew(RenderingServerRaster); + rendering_server->init(); AudioDriverManager::initialize(p_audio_driver); @@ -99,10 +99,10 @@ void OS_Server::finalize() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; - visual_server->finish(); - memdelete(visual_server); + rendering_server->finish(); + memdelete(rendering_server); memdelete(input); @@ -163,7 +163,7 @@ void OS_Server::delete_main_loop() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; } void OS_Server::set_main_loop(MainLoop *p_main_loop) { @@ -289,7 +289,7 @@ String OS_Server::get_system_dir(SystemDir p_dir) const { String pipe; List<String> arg; arg.push_back(xdgparam); - Error err = const_cast<OS_Server *>(this)->execute("xdg-user-dir", arg, true, NULL, &pipe); + Error err = const_cast<OS_Server *>(this)->execute("xdg-user-dir", arg, true, nullptr, &pipe); if (err != OK) return "."; return pipe.strip_edges(); diff --git a/platform/server/os_server.h b/platform/server/os_server.h index d40905718e..62028b26e4 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -41,14 +41,14 @@ #include "platform/x11/crash_handler_linuxbsd.h" #endif #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" #undef CursorShape class OS_Server : public OS_Unix { - VisualServer *visual_server; + RenderingServer *rendering_server; VideoMode current_videomode; List<String> args; MainLoop *main_loop; diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub index 620d8c3c3a..4358b0eead 100644 --- a/platform/uwp/SCsub +++ b/platform/uwp/SCsub @@ -1,21 +1,21 @@ #!/usr/bin/env python -Import('env') +Import("env") files = [ - 'thread_uwp.cpp', - '#platform/windows/key_mapping_windows.cpp', - '#platform/windows/windows_terminal_logger.cpp', - 'joypad_uwp.cpp', - 'context_egl_uwp.cpp', - 'app.cpp', - 'os_uwp.cpp', + "thread_uwp.cpp", + "#platform/windows/key_mapping_windows.cpp", + "#platform/windows/windows_terminal_logger.cpp", + "joypad_uwp.cpp", + "context_egl_uwp.cpp", + "app.cpp", + "os_uwp.cpp", ] if "build_angle" in env and env["build_angle"]: - cmd = env.AlwaysBuild(env.ANGLE('libANGLE.lib', None)) + cmd = env.AlwaysBuild(env.ANGLE("libANGLE.lib", None)) -prog = env.add_program('#bin/godot', files) +prog = env.add_program("#bin/godot", files) if "build_angle" in env and env["build_angle"]: env.Depends(prog, [cmd]) diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp index ccb4b43373..d3870b0b6c 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app.cpp @@ -507,12 +507,12 @@ void App::UpdateWindowSize(Size size) { char **App::get_command_line(unsigned int *out_argc) { - static char *fail_cl[] = { "--path", "game", NULL }; + static char *fail_cl[] = { "--path", "game", nullptr }; *out_argc = 2; FILE *f = _wfopen(L"__cl__.cl", L"rb"); - if (f == NULL) { + if (f == nullptr) { wprintf(L"Couldn't open command line file.\n"); return fail_cl; @@ -558,7 +558,7 @@ char **App::get_command_line(unsigned int *out_argc) { if (r == strlen) { - int warg_size = MultiByteToWideChar(CP_UTF8, 0, arg, -1, NULL, 0); + int warg_size = MultiByteToWideChar(CP_UTF8, 0, arg, -1, nullptr, 0); wchar_t *warg = new wchar_t[warg_size]; MultiByteToWideChar(CP_UTF8, 0, arg, -1, warg, warg_size); @@ -583,14 +583,14 @@ char **App::get_command_line(unsigned int *out_argc) { for (int i = 0; i < cl.Size; i++) { - int arg_size = WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, NULL, 0, NULL, NULL); + int arg_size = WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, nullptr, 0, nullptr, nullptr); char *arg = new char[arg_size]; - WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, arg, arg_size, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, cl.GetAt(i)->Data(), -1, arg, arg_size, nullptr, nullptr); ret[i] = arg; } - ret[cl.Size] = NULL; + ret[cl.Size] = nullptr; *out_argc = cl.Size; return ret; diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp index 7ac9489bb4..bc8ca2e36c 100644 --- a/platform/uwp/context_egl_uwp.cpp +++ b/platform/uwp/context_egl_uwp.cpp @@ -155,7 +155,7 @@ Error ContextEGL_UWP::initialize() { throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); } - if (eglGetConfigs(display, NULL, 0, &numConfigs) == EGL_FALSE) { + if (eglGetConfigs(display, nullptr, 0, &numConfigs) == EGL_FALSE) { throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count"); } diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 000bd18e7d..669bfe6814 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -12,11 +12,11 @@ def get_name(): def can_build(): - if (os.name == "nt"): + if os.name == "nt": # building natively on windows! - if (os.getenv("VSINSTALLDIR")): + if os.getenv("VSINSTALLDIR"): - if (os.getenv("ANGLE_SRC_PATH") is None): + if os.getenv("ANGLE_SRC_PATH") is None: return False return True @@ -25,16 +25,16 @@ def can_build(): def get_opts(): return [ - ('msvc_version', 'MSVC version to use (ignored if the VCINSTALLDIR environment variable is set)', None), + ("msvc_version", "MSVC version to use (ignored if the VCINSTALLDIR environment variable is set)", None), ] def get_flags(): return [ - ('tools', False), - ('xaudio2', True), - ('builtin_pcre2_with_jit', False), + ("tools", False), + ("xaudio2", True), + ("builtin_pcre2_with_jit", False), ] @@ -42,45 +42,53 @@ def configure(env): env.msvc = True - if (env["bits"] != "default"): + if env["bits"] != "default": print("Error: bits argument is disabled for MSVC") - print(""" + print( + """ Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings) that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=uwp) and SCons will attempt to detect what MSVC compiler will be executed and inform you. - """) + """ + ) sys.exit() ## Build type - if (env["target"] == "release"): - env.Append(CCFLAGS=['/O2', '/GL']) - env.Append(CCFLAGS=['/MD']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS', '/LTCG']) + if env["target"] == "release": + env.Append(CCFLAGS=["/O2", "/GL"]) + env.Append(CCFLAGS=["/MD"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:WINDOWS", "/LTCG"]) - elif (env["target"] == "release_debug"): - env.Append(CCFLAGS=['/O2', '/Zi']) - env.Append(CCFLAGS=['/MD']) - env.Append(CPPDEFINES=['DEBUG_ENABLED']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) + elif env["target"] == "release_debug": + env.Append(CCFLAGS=["/O2", "/Zi"]) + env.Append(CCFLAGS=["/MD"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) - elif (env["target"] == "debug"): - env.Append(CCFLAGS=['/Zi']) - env.Append(CCFLAGS=['/MDd']) - env.Append(CPPDEFINES=['DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/DEBUG']) + elif env["target"] == "debug": + env.Append(CCFLAGS=["/Zi"]) + env.Append(CCFLAGS=["/MDd"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) + env.Append(LINKFLAGS=["/DEBUG"]) ## Compiler configuration - env['ENV'] = os.environ - vc_base_path = os.environ['VCTOOLSINSTALLDIR'] if "VCTOOLSINSTALLDIR" in os.environ else os.environ['VCINSTALLDIR'] + env["ENV"] = os.environ + vc_base_path = os.environ["VCTOOLSINSTALLDIR"] if "VCTOOLSINSTALLDIR" in os.environ else os.environ["VCINSTALLDIR"] # ANGLE angle_root = os.getenv("ANGLE_SRC_PATH") - env.Prepend(CPPPATH=[angle_root + '/include']) + env.Prepend(CPPPATH=[angle_root + "/include"]) jobs = str(env.GetOption("num_jobs")) - angle_build_cmd = "msbuild.exe " + angle_root + "/winrt/10/src/angle.sln /nologo /v:m /m:" + jobs + " /p:Configuration=Release /p:Platform=" + angle_build_cmd = ( + "msbuild.exe " + + angle_root + + "/winrt/10/src/angle.sln /nologo /v:m /m:" + + jobs + + " /p:Configuration=Release /p:Platform=" + ) if os.path.isfile(str(os.getenv("ANGLE_SRC_PATH")) + "/winrt/10/src/angle.sln"): env["build_angle"] = True @@ -88,49 +96,51 @@ def configure(env): ## Architecture arch = "" - if str(os.getenv('Platform')).lower() == "arm": + if str(os.getenv("Platform")).lower() == "arm": print("Compiled program architecture will be an ARM executable. (forcing bits=32).") arch = "arm" env["bits"] = "32" - env.Append(LINKFLAGS=['/MACHINE:ARM']) - env.Append(LIBPATH=[vc_base_path + 'lib/store/arm']) + env.Append(LINKFLAGS=["/MACHINE:ARM"]) + env.Append(LIBPATH=[vc_base_path + "lib/store/arm"]) angle_build_cmd += "ARM" - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_ARM/lib']) + env.Append(LIBPATH=[angle_root + "/winrt/10/src/Release_ARM/lib"]) else: - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + compiler_version_str = methods.detect_visual_c_compiler_version(env["ENV"]) - if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + if compiler_version_str == "amd64" or compiler_version_str == "x86_amd64": env["bits"] = "64" print("Compiled program architecture will be a x64 executable (forcing bits=64).") - elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"): + elif compiler_version_str == "x86" or compiler_version_str == "amd64_x86": env["bits"] = "32" print("Compiled program architecture will be a x86 executable. (forcing bits=32).") else: - print("Failed to detect MSVC compiler architecture version... Defaulting to 32-bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup.") + print( + "Failed to detect MSVC compiler architecture version... Defaulting to 32-bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup." + ) env["bits"] = "32" - if (env["bits"] == "32"): + if env["bits"] == "32": arch = "x86" angle_build_cmd += "Win32" - env.Append(LINKFLAGS=['/MACHINE:X86']) - env.Append(LIBPATH=[vc_base_path + 'lib/store']) - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_Win32/lib']) + env.Append(LINKFLAGS=["/MACHINE:X86"]) + env.Append(LIBPATH=[vc_base_path + "lib/store"]) + env.Append(LIBPATH=[angle_root + "/winrt/10/src/Release_Win32/lib"]) else: arch = "x64" angle_build_cmd += "x64" - env.Append(LINKFLAGS=['/MACHINE:X64']) - env.Append(LIBPATH=[os.environ['VCINSTALLDIR'] + 'lib/store/amd64']) - env.Append(LIBPATH=[angle_root + '/winrt/10/src/Release_x64/lib']) + env.Append(LINKFLAGS=["/MACHINE:X64"]) + env.Append(LIBPATH=[os.environ["VCINSTALLDIR"] + "lib/store/amd64"]) + env.Append(LIBPATH=[angle_root + "/winrt/10/src/Release_x64/lib"]) env["PROGSUFFIX"] = "." + arch + env["PROGSUFFIX"] env["OBJSUFFIX"] = "." + arch + env["OBJSUFFIX"] @@ -138,39 +148,61 @@ def configure(env): ## Compile flags - env.Prepend(CPPPATH=['#platform/uwp', '#drivers/windows']) - env.Append(CPPDEFINES=['UWP_ENABLED', 'WINDOWS_ENABLED', 'TYPED_METHOD_BIND']) - env.Append(CPPDEFINES=['GLES_ENABLED', 'GL_GLEXT_PROTOTYPES', 'EGL_EGLEXT_PROTOTYPES', 'ANGLE_ENABLED']) - winver = "0x0602" # Windows 8 is the minimum target for UWP build - env.Append(CPPDEFINES=[('WINVER', winver), ('_WIN32_WINNT', winver), 'WIN32']) - - env.Append(CPPDEFINES=['__WRL_NO_DEFAULT_LIB__', ('PNG_ABORT', 'abort')]) - - env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/store/references']) - env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/x86/store/references']) - - env.Append(CCFLAGS='/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'.split()) - env.Append(CPPDEFINES=['_UNICODE', 'UNICODE', ('WINAPI_FAMILY', 'WINAPI_FAMILY_APP')]) - env.Append(CXXFLAGS=['/ZW']) - env.Append(CCFLAGS=['/AI', vc_base_path + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral']) + env.Prepend(CPPPATH=["#platform/uwp", "#drivers/windows"]) + env.Append(CPPDEFINES=["UWP_ENABLED", "WINDOWS_ENABLED", "TYPED_METHOD_BIND"]) + env.Append(CPPDEFINES=["GLES_ENABLED", "GL_GLEXT_PROTOTYPES", "EGL_EGLEXT_PROTOTYPES", "ANGLE_ENABLED"]) + winver = "0x0602" # Windows 8 is the minimum target for UWP build + env.Append(CPPDEFINES=[("WINVER", winver), ("_WIN32_WINNT", winver), "WIN32"]) + + env.Append(CPPDEFINES=["__WRL_NO_DEFAULT_LIB__", ("PNG_ABORT", "abort")]) + + env.Append(CPPFLAGS=["/AI", vc_base_path + "lib/store/references"]) + env.Append(CPPFLAGS=["/AI", vc_base_path + "lib/x86/store/references"]) + + env.Append( + CCFLAGS='/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'.split() + ) + env.Append(CPPDEFINES=["_UNICODE", "UNICODE", ("WINAPI_FAMILY", "WINAPI_FAMILY_APP")]) + env.Append(CXXFLAGS=["/ZW"]) + env.Append( + CCFLAGS=[ + "/AI", + vc_base_path + "\\vcpackages", + "/AI", + os.environ["WINDOWSSDKDIR"] + "\\References\\CommonConfiguration\\Neutral", + ] + ) ## Link flags - env.Append(LINKFLAGS=['/MANIFEST:NO', '/NXCOMPAT', '/DYNAMICBASE', '/WINMD', '/APPCONTAINER', '/ERRORREPORT:PROMPT', '/NOLOGO', '/TLBID:1', '/NODEFAULTLIB:"kernel32.lib"', '/NODEFAULTLIB:"ole32.lib"']) + env.Append( + LINKFLAGS=[ + "/MANIFEST:NO", + "/NXCOMPAT", + "/DYNAMICBASE", + "/WINMD", + "/APPCONTAINER", + "/ERRORREPORT:PROMPT", + "/NOLOGO", + "/TLBID:1", + '/NODEFAULTLIB:"kernel32.lib"', + '/NODEFAULTLIB:"ole32.lib"', + ] + ) LIBS = [ - 'WindowsApp', - 'mincore', - 'ws2_32', - 'libANGLE', - 'libEGL', - 'libGLESv2', - 'bcrypt', + "WindowsApp", + "mincore", + "ws2_32", + "libANGLE", + "libEGL", + "libGLESv2", + "bcrypt", ] env.Append(LINKFLAGS=[p + ".lib" for p in LIBS]) # Incremental linking fix - env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] - env['BUILDERS']['Program'] = methods.precious_program + env["BUILDERS"]["ProgramOriginal"] = env["BUILDERS"]["Program"] + env["BUILDERS"]["Program"] = methods.precious_program - env.Append(BUILDERS={'ANGLE': env.Builder(action=angle_build_cmd)}) + env.Append(BUILDERS={"ANGLE": env.Builder(action=angle_build_cmd)}) diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 533293387d..06bf738dc1 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -54,7 +54,7 @@ static const char *uwp_capabilities[] = { "internetClient", "internetClientServer", "privateNetworkClientServer", - NULL + nullptr }; static const char *uwp_uap_capabilities[] = { "appointments", @@ -71,7 +71,7 @@ static const char *uwp_uap_capabilities[] = { "userAccountInformation", "videosLibrary", "voipCall", - NULL + nullptr }; static const char *uwp_device_capabilities[] = { "bluetooth", @@ -79,7 +79,7 @@ static const char *uwp_device_capabilities[] = { "microphone", "proximity", "webcam", - NULL + nullptr }; class AppxPackager { @@ -478,7 +478,7 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t // Data for compression z_stream strm; - FileAccess *strm_f = NULL; + FileAccess *strm_f = nullptr; Vector<uint8_t> strm_in; strm_in.resize(BLOCK_SIZE); Vector<uint8_t> strm_out; @@ -641,7 +641,7 @@ void AppxPackager::finish() { package->close(); memdelete(package); - package = NULL; + package = nullptr; } AppxPackager::AppxPackager() {} @@ -670,7 +670,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { static const char *invalid_names[] = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", - NULL + nullptr }; const char **t = invalid_names; @@ -726,7 +726,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { "snow", "springGreen", "steelBlue", "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", "wheat", "white", "whiteSmoke", "yellow", "yellowGreen", - NULL + nullptr }; const char **color = valid_colors; @@ -876,22 +876,22 @@ class EditorExportPlatformUWP : public EditorExportPlatform { Vector<uint8_t> _get_image_data(const Ref<EditorExportPreset> &p_preset, const String &p_path) { Vector<uint8_t> data; - StreamTexture *image = NULL; + StreamTexture *image = nullptr; if (p_path.find("StoreLogo") != -1) { - image = p_preset->get("images/store_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/store_logo"))); + image = p_preset->get("images/store_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/store_logo"))); } else if (p_path.find("Square44x44Logo") != -1) { - image = p_preset->get("images/square44x44_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square44x44_logo"))); + image = p_preset->get("images/square44x44_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square44x44_logo"))); } else if (p_path.find("Square71x71Logo") != -1) { - image = p_preset->get("images/square71x71_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square71x71_logo"))); + image = p_preset->get("images/square71x71_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square71x71_logo"))); } else if (p_path.find("Square150x150Logo") != -1) { - image = p_preset->get("images/square150x150_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square150x150_logo"))); + image = p_preset->get("images/square150x150_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square150x150_logo"))); } else if (p_path.find("Square310x310Logo") != -1) { - image = p_preset->get("images/square310x310_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square310x310_logo"))); + image = p_preset->get("images/square310x310_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/square310x310_logo"))); } else if (p_path.find("Wide310x150Logo") != -1) { - image = p_preset->get("images/wide310x150_logo").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/wide310x150_logo"))); + image = p_preset->get("images/wide310x150_logo").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/wide310x150_logo"))); } else if (p_path.find("SplashScreen") != -1) { - image = p_preset->get("images/splash_screen").is_zero() ? NULL : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/splash_screen"))); + image = p_preset->get("images/splash_screen").is_zero() ? nullptr : Object::cast_to<StreamTexture>(((Object *)p_preset->get("images/splash_screen"))); } else { ERR_PRINT("Unable to load logo"); } @@ -961,7 +961,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform { ".scn", // Binary scenes are usually already compressed ".stex", // Streamable textures are usually already compressed // Trailer for easier processing - NULL + nullptr }; for (const char **ext = unconditional_compress_ext; *ext; ++ext) { @@ -1251,7 +1251,7 @@ public: AppxPackager packager; packager.init(fa_pack); - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); if (ep.step("Creating package...", 0)) { @@ -1283,7 +1283,7 @@ public: // get file name unz_file_info info; char fname[16834]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16834, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16834, nullptr, 0, nullptr, 0); String path = fname; diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 4ddb5463d0..f5e989b370 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -45,8 +45,8 @@ #include "main/main.h" #include "platform/windows/windows_terminal_logger.h" #include "servers/audio_server.h" -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "servers/rendering/rendering_server_raster.h" +#include "servers/rendering/rendering_server_wrap_mt.h" #include "thread_uwp.h" #include <ppltasks.h> @@ -180,7 +180,7 @@ void OS_UWP::screen_size_changed() { Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { - main_loop = NULL; + main_loop = nullptr; outside = true; // FIXME: Hardcoded for now, add Vulkan support. @@ -193,7 +193,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a if (gl_context->initialize() != OK) { memdelete(gl_context); - gl_context = NULL; + gl_context = nullptr; gl_initialization_error = true; } @@ -254,13 +254,13 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a set_video_mode(vm); - visual_server = memnew(VisualServerRaster); + rendering_server = memnew(RenderingServerRaster); // FIXME: Reimplement threaded rendering if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { - visual_server = memnew(VisualServerWrapMT(visual_server, false)); + rendering_server = memnew(RenderingServerWrapMT(rendering_server, false)); } - visual_server->init(); + rendering_server->init(); input = memnew(InputDefault); @@ -333,7 +333,7 @@ void OS_UWP::delete_main_loop() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; } void OS_UWP::set_main_loop(MainLoop *p_main_loop) { @@ -347,10 +347,10 @@ void OS_UWP::finalize() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; - visual_server->finish(); - memdelete(visual_server); + rendering_server->finish(); + memdelete(rendering_server); #ifdef OPENGL_ENABLED if (gl_context) memdelete(gl_context); @@ -773,9 +773,9 @@ void OS_UWP::hide_virtual_keyboard() { static String format_error_message(DWORD id) { - LPWSTR messageBuffer = NULL; + LPWSTR messageBuffer = nullptr; size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); + nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); String msg = "Error " + itos(id) + ": " + String(messageBuffer, size); @@ -869,14 +869,14 @@ OS_UWP::OS_UWP() { stdo = fopen("stdout.txt", "wb"); #endif - gl_context = NULL; + gl_context = nullptr; display_request = ref new Windows::System::Display::DisplayRequest(); managed_object = ref new ManagedType; managed_object->os = this; - mouse_mode_changed = CreateEvent(NULL, TRUE, FALSE, L"os_mouse_mode_changed"); + mouse_mode_changed = CreateEvent(nullptr, TRUE, FALSE, L"os_mouse_mode_changed"); AudioDriverManager::add_driver(&audio_driver); diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index cc4dfcc79f..ad0efa1d03 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -39,8 +39,8 @@ #include "drivers/xaudio2/audio_driver_xaudio2.h" #include "joypad_uwp.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" #include <fcntl.h> #include <io.h> @@ -88,7 +88,7 @@ private: bool outside; int old_x, old_y; Point2i center; - VisualServer *visual_server; + RenderingServer *rendering_server; int pressrc; ContextEGL_UWP *gl_context; @@ -202,7 +202,7 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); virtual Error kill(const ProcessID &p_pid); virtual bool has_environment(const String &p_var) const; diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 89ee4dfa7a..daffe59f34 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") import os from platform_methods import run_in_subprocess @@ -15,17 +15,17 @@ common_win = [ "joypad_windows.cpp", "windows_terminal_logger.cpp", "vulkan_context_win.cpp", - "context_gl_windows.cpp" + "context_gl_windows.cpp", ] -res_file = 'godot_res.rc' +res_file = "godot_res.rc" res_target = "godot_res" + env["OBJSUFFIX"] res_obj = env.RES(res_target, res_file) -prog = env.add_program('#bin/godot', common_win + res_obj, PROGSUFFIX=env["PROGSUFFIX"]) +prog = env.add_program("#bin/godot", common_win + res_obj, PROGSUFFIX=env["PROGSUFFIX"]) # Microsoft Visual Studio Project Generation -if env['vsproj']: +if env["vsproj"]: env.vs_srcs = env.vs_srcs + ["platform/windows/" + res_file] env.vs_srcs = env.vs_srcs + ["platform/windows/godot.natvis"] for x in common_win: diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp index ad62e3a306..5a36b5546d 100644 --- a/platform/windows/context_gl_windows.cpp +++ b/platform/windows/context_gl_windows.cpp @@ -52,7 +52,7 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int void ContextGL_Windows::release_current() { - wglMakeCurrent(hDC, NULL); + wglMakeCurrent(hDC, nullptr); } void ContextGL_Windows::make_current() { @@ -185,10 +185,10 @@ Error ContextGL_Windows::initialize() { 0 }; //zero indicates the end of the array - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; //pointer to the method + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr; //pointer to the method wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); - if (wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported + if (wglCreateContextAttribsARB == nullptr) //OpenGL 3.0 is not supported { wglDeleteContext(hRC); return ERR_CANT_CREATE; @@ -199,7 +199,7 @@ Error ContextGL_Windows::initialize() { wglDeleteContext(hRC); return ERR_CANT_CREATE; // Return false } - wglMakeCurrent(hDC, NULL); + wglMakeCurrent(hDC, nullptr); wglDeleteContext(hRC); hRC = new_hRC; diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp index 6145751e00..1d9eba22d8 100644 --- a/platform/windows/crash_handler_windows.cpp +++ b/platform/windows/crash_handler_windows.cpp @@ -121,7 +121,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { DWORD cbNeeded; std::vector<HMODULE> module_handles(1); - if (OS::get_singleton() == NULL || OS::get_singleton()->is_disable_crash_handler() || IsDebuggerPresent()) { + if (OS::get_singleton() == nullptr || OS::get_singleton()->is_disable_crash_handler() || IsDebuggerPresent()) { return EXCEPTION_CONTINUE_SEARCH; } @@ -131,7 +131,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_CRASH); // Load the symbols: - if (!SymInitialize(process, NULL, false)) + if (!SymInitialize(process, nullptr, false)) return EXCEPTION_CONTINUE_SEARCH; SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_UNDNAME); @@ -193,7 +193,7 @@ DWORD CrashHandlerException(EXCEPTION_POINTERS *ep) { n++; } - if (!StackWalk64(image_type, process, hThread, &frame, context, NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL)) + if (!StackWalk64(image_type, process, hThread, &frame, context, nullptr, SymFunctionTableAccess64, SymGetModuleBase64, nullptr)) break; } while (frame.AddrReturn.Offset != 0 && n < 256); diff --git a/platform/windows/detect.py b/platform/windows/detect.py index cc859c0339..9f79e92dcb 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -14,10 +14,10 @@ def get_name(): def can_build(): - if (os.name == "nt"): + if os.name == "nt": # Building natively on Windows # If VCINSTALLDIR is set in the OS environ, use traditional Godot logic to set up MSVC - if (os.getenv("VCINSTALLDIR")): # MSVC, manual setup + if os.getenv("VCINSTALLDIR"): # MSVC, manual setup return True # Otherwise, let SCons find MSVC if installed, or else Mingw. @@ -26,18 +26,18 @@ def can_build(): # null compiler. return True - if (os.name == "posix"): + if os.name == "posix": # Cross-compiling with MinGW-w64 (old MinGW32 is not supported) mingw32 = "i686-w64-mingw32-" mingw64 = "x86_64-w64-mingw32-" - if (os.getenv("MINGW32_PREFIX")): + if os.getenv("MINGW32_PREFIX"): mingw32 = os.getenv("MINGW32_PREFIX") - if (os.getenv("MINGW64_PREFIX")): + if os.getenv("MINGW64_PREFIX"): mingw64 = os.getenv("MINGW64_PREFIX") test = "gcc --version > /dev/null 2>&1" - if (os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0): + if os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0: return True return False @@ -48,47 +48,47 @@ def get_opts(): mingw32 = "" mingw64 = "" - if (os.name == "posix"): + if os.name == "posix": mingw32 = "i686-w64-mingw32-" mingw64 = "x86_64-w64-mingw32-" - if (os.getenv("MINGW32_PREFIX")): + if os.getenv("MINGW32_PREFIX"): mingw32 = os.getenv("MINGW32_PREFIX") - if (os.getenv("MINGW64_PREFIX")): + if os.getenv("MINGW64_PREFIX"): mingw64 = os.getenv("MINGW64_PREFIX") return [ - ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32), - ('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64), + ("mingw_prefix_32", "MinGW prefix (Win32)", mingw32), + ("mingw_prefix_64", "MinGW prefix (Win64)", mingw64), # Targeted Windows version: 7 (and later), minimum supported version # XP support dropped after EOL due to missing API for IPv6 and other issues # Vista support dropped after EOL due to GH-10243 - ('target_win_version', 'Targeted Windows version, >= 0x0601 (Windows 7)', '0x0601'), - EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), - BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), - ('msvc_version', 'MSVC version to use. Ignored if VCINSTALLDIR is set in shell env.', None), - BoolVariable('use_mingw', 'Use the Mingw compiler, even if MSVC is installed. Only used on Windows.', False), - BoolVariable('use_llvm', 'Use the LLVM compiler', False), - BoolVariable('use_thinlto', 'Use ThinLTO', False), + ("target_win_version", "Targeted Windows version, >= 0x0601 (Windows 7)", "0x0601"), + EnumVariable("debug_symbols", "Add debugging symbols to release builds", "yes", ("yes", "no", "full")), + BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), + ("msvc_version", "MSVC version to use. Ignored if VCINSTALLDIR is set in shell env.", None), + BoolVariable("use_mingw", "Use the Mingw compiler, even if MSVC is installed. Only used on Windows.", False), + BoolVariable("use_llvm", "Use the LLVM compiler", False), + BoolVariable("use_thinlto", "Use ThinLTO", False), ] def get_flags(): - return [ - ] + return [] def build_res_file(target, source, env): - if (env["bits"] == "32"): - cmdbase = env['mingw_prefix_32'] + if env["bits"] == "32": + cmdbase = env["mingw_prefix_32"] else: - cmdbase = env['mingw_prefix_64'] - cmdbase = cmdbase + 'windres --include-dir . ' + cmdbase = env["mingw_prefix_64"] + cmdbase = cmdbase + "windres --include-dir . " import subprocess + for x in range(len(source)): - cmd = cmdbase + '-i ' + str(source[x]) + ' -o ' + str(target[x]) + cmd = cmdbase + "-i " + str(source[x]) + " -o " + str(target[x]) try: out = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE).communicate() if len(out[1]): @@ -100,12 +100,14 @@ def build_res_file(target, source, env): def setup_msvc_manual(env): """Set up env to use MSVC manually, using VCINSTALLDIR""" - if (env["bits"] != "default"): - print(""" + if env["bits"] != "default": + print( + """ Bits argument is not supported for MSVC compilation. Architecture depends on the Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings) that is being used to run SCons. As a consequence, bits argument is disabled. Run scons again without bits argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler will be executed and inform you. - """) + """ + ) raise SCons.Errors.UserError("Bits argument should not be used when using VCINSTALLDIR") # Force bits arg @@ -114,18 +116,21 @@ def setup_msvc_manual(env): env["x86_libtheora_opt_vc"] = True # find compiler manually - compiler_version_str = methods.detect_visual_c_compiler_version(env['ENV']) + compiler_version_str = methods.detect_visual_c_compiler_version(env["ENV"]) print("Found MSVC compiler: " + compiler_version_str) # If building for 64bit architecture, disable assembly optimisations for 32 bit builds (theora as of writing)... vc compiler for 64bit can not compile _asm - if(compiler_version_str == "amd64" or compiler_version_str == "x86_amd64"): + if compiler_version_str == "amd64" or compiler_version_str == "x86_amd64": env["bits"] = "64" env["x86_libtheora_opt_vc"] = False print("Compiled program architecture will be a 64 bit executable (forcing bits=64).") - elif (compiler_version_str == "x86" or compiler_version_str == "amd64_x86"): + elif compiler_version_str == "x86" or compiler_version_str == "amd64_x86": print("Compiled program architecture will be a 32 bit executable. (forcing bits=32).") else: - print("Failed to manually detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup, or avoid setting VCINSTALLDIR.") + print( + "Failed to manually detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup, or avoid setting VCINSTALLDIR." + ) + def setup_msvc_auto(env): """Set up MSVC using SCons's auto-detection logic""" @@ -138,103 +143,127 @@ def setup_msvc_auto(env): # (Ideally we'd decide on the tool config before configuring any # environment, and just set the env up once, but this function runs # on an existing env so this is the simplest way.) - env['MSVC_SETUP_RUN'] = False # Need to set this to re-run the tool - env['MSVS_VERSION'] = None - env['MSVC_VERSION'] = None - env['TARGET_ARCH'] = None - if env['bits'] != 'default': - env['TARGET_ARCH'] = {'32': 'x86', '64': 'x86_64'}[env['bits']] - if env.has_key('msvc_version'): - env['MSVC_VERSION'] = env['msvc_version'] - env.Tool('msvc') - env.Tool('mssdk') # we want the MS SDK + env["MSVC_SETUP_RUN"] = False # Need to set this to re-run the tool + env["MSVS_VERSION"] = None + env["MSVC_VERSION"] = None + env["TARGET_ARCH"] = None + if env["bits"] != "default": + env["TARGET_ARCH"] = {"32": "x86", "64": "x86_64"}[env["bits"]] + if env.has_key("msvc_version"): + env["MSVC_VERSION"] = env["msvc_version"] + env.Tool("msvc") + env.Tool("mssdk") # we want the MS SDK # Note: actual compiler version can be found in env['MSVC_VERSION'], e.g. "14.1" for VS2015 # Get actual target arch into bits (it may be "default" at this point): - if env['TARGET_ARCH'] in ('amd64', 'x86_64'): - env['bits'] = '64' + if env["TARGET_ARCH"] in ("amd64", "x86_64"): + env["bits"] = "64" else: - env['bits'] = '32' - print("Found MSVC version %s, arch %s, bits=%s" % (env['MSVC_VERSION'], env['TARGET_ARCH'], env['bits'])) - if env['TARGET_ARCH'] in ('amd64', 'x86_64'): + env["bits"] = "32" + print("Found MSVC version %s, arch %s, bits=%s" % (env["MSVC_VERSION"], env["TARGET_ARCH"], env["bits"])) + if env["TARGET_ARCH"] in ("amd64", "x86_64"): env["x86_libtheora_opt_vc"] = False + def setup_mingw(env): """Set up env for use with mingw""" # Nothing to do here print("Using MinGW") pass + def configure_msvc(env, manual_msvc_config): """Configure env to work with MSVC""" # Build type - if (env["target"] == "release"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Append(CCFLAGS=['/O2']) - else: # optimize for size - env.Append(CCFLAGS=['/O1']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) - env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) - env.Append(LINKFLAGS=['/OPT:REF']) - - elif (env["target"] == "release_debug"): - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Append(CCFLAGS=['/O2']) - else: # optimize for size - env.Append(CCFLAGS=['/O1']) - env.AppendUnique(CPPDEFINES = ['DEBUG_ENABLED']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/OPT:REF']) - - elif (env["target"] == "debug"): - env.AppendUnique(CCFLAGS=['/Z7', '/Od', '/EHsc']) - env.AppendUnique(CPPDEFINES = ['DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED', - 'D3D_DEBUG_INFO']) - env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - env.Append(LINKFLAGS=['/DEBUG']) - - if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes"): - env.AppendUnique(CCFLAGS=['/Z7']) - env.AppendUnique(LINKFLAGS=['/DEBUG']) + if env["target"] == "release": + if env["optimize"] == "speed": # optimize for speed (default) + env.Append(CCFLAGS=["/O2"]) + else: # optimize for size + env.Append(CCFLAGS=["/O1"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:WINDOWS"]) + env.Append(LINKFLAGS=["/ENTRY:mainCRTStartup"]) + env.Append(LINKFLAGS=["/OPT:REF"]) + + elif env["target"] == "release_debug": + if env["optimize"] == "speed": # optimize for speed (default) + env.Append(CCFLAGS=["/O2"]) + else: # optimize for size + env.Append(CCFLAGS=["/O1"]) + env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) + env.Append(LINKFLAGS=["/OPT:REF"]) + + elif env["target"] == "debug": + env.AppendUnique(CCFLAGS=["/Z7", "/Od", "/EHsc"]) + env.AppendUnique(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED", "D3D_DEBUG_INFO"]) + env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"]) + env.Append(LINKFLAGS=["/DEBUG"]) + + if env["debug_symbols"] == "full" or env["debug_symbols"] == "yes": + env.AppendUnique(CCFLAGS=["/Z7"]) + env.AppendUnique(LINKFLAGS=["/DEBUG"]) ## Compile/link flags - env.AppendUnique(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo']) - if int(env['MSVC_VERSION'].split('.')[0]) >= 14: #vs2015 and later - env.AppendUnique(CCFLAGS=['/utf-8']) - env.AppendUnique(CXXFLAGS=['/TP']) # assume all sources are C++ - if manual_msvc_config: # should be automatic if SCons found it + env.AppendUnique(CCFLAGS=["/MT", "/Gd", "/GR", "/nologo"]) + if int(env["MSVC_VERSION"].split(".")[0]) >= 14: # vs2015 and later + env.AppendUnique(CCFLAGS=["/utf-8"]) + env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++ + if manual_msvc_config: # should be automatic if SCons found it if os.getenv("WindowsSdkDir") is not None: env.Prepend(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"]) else: print("Missing environment variable: WindowsSdkDir") - env.AppendUnique(CPPDEFINES = ['WINDOWS_ENABLED', - 'WASAPI_ENABLED', 'WINMIDI_ENABLED', - 'TYPED_METHOD_BIND', - 'WIN32', 'MSVC', - 'WINVER=%s' % env["target_win_version"], - '_WIN32_WINNT=%s' % env["target_win_version"]]) - env.AppendUnique(CPPDEFINES=['NOMINMAX']) # disable bogus min/max WinDef.h macros + env.AppendUnique( + CPPDEFINES=[ + "WINDOWS_ENABLED", + "WASAPI_ENABLED", + "WINMIDI_ENABLED", + "TYPED_METHOD_BIND", + "WIN32", + "MSVC", + "WINVER=%s" % env["target_win_version"], + "_WIN32_WINNT=%s" % env["target_win_version"], + ] + ) + env.AppendUnique(CPPDEFINES=["NOMINMAX"]) # disable bogus min/max WinDef.h macros if env["bits"] == "64": - env.AppendUnique(CPPDEFINES=['_WIN64']) + env.AppendUnique(CPPDEFINES=["_WIN64"]) ## Libs - LIBS = ['winmm', 'dsound', 'kernel32', 'ole32', 'oleaut32', - 'user32', 'gdi32', 'IPHLPAPI', 'Shlwapi', 'wsock32', 'Ws2_32', - 'shell32', 'advapi32', 'dinput8', 'dxguid', 'imm32', 'bcrypt', 'Avrt', - 'dwmapi'] + LIBS = [ + "winmm", + "dsound", + "kernel32", + "ole32", + "oleaut32", + "user32", + "gdi32", + "IPHLPAPI", + "Shlwapi", + "wsock32", + "Ws2_32", + "shell32", + "advapi32", + "dinput8", + "dxguid", + "imm32", + "bcrypt", + "Avrt", + "dwmapi", + ] - env.AppendUnique(CPPDEFINES=['VULKAN_ENABLED']) - if not env['builtin_vulkan']: - LIBS += ['vulkan'] + env.AppendUnique(CPPDEFINES=["VULKAN_ENABLED"]) + if not env["builtin_vulkan"]: + LIBS += ["vulkan"] else: - LIBS += ['cfgmgr32'] + LIBS += ["cfgmgr32"] - #env.AppendUnique(CPPDEFINES = ['OPENGL_ENABLED']) - LIBS += ['opengl32'] + # env.AppendUnique(CPPDEFINES = ['OPENGL_ENABLED']) + LIBS += ["opengl32"] env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS]) @@ -246,23 +275,24 @@ def configure_msvc(env, manual_msvc_config): ## LTO - if (env["use_lto"]): - env.AppendUnique(CCFLAGS=['/GL']) - env.AppendUnique(ARFLAGS=['/LTCG']) + if env["use_lto"]: + env.AppendUnique(CCFLAGS=["/GL"]) + env.AppendUnique(ARFLAGS=["/LTCG"]) if env["progress"]: - env.AppendUnique(LINKFLAGS=['/LTCG:STATUS']) + env.AppendUnique(LINKFLAGS=["/LTCG:STATUS"]) else: - env.AppendUnique(LINKFLAGS=['/LTCG']) + env.AppendUnique(LINKFLAGS=["/LTCG"]) if manual_msvc_config: env.Prepend(CPPPATH=[p for p in os.getenv("INCLUDE").split(";")]) env.Append(LIBPATH=[p for p in os.getenv("LIB").split(";")]) # Incremental linking fix - env['BUILDERS']['ProgramOriginal'] = env['BUILDERS']['Program'] - env['BUILDERS']['Program'] = methods.precious_program + env["BUILDERS"]["ProgramOriginal"] = env["BUILDERS"]["Program"] + env["BUILDERS"]["Program"] = methods.precious_program + + env.AppendUnique(LINKFLAGS=["/STACK:" + str(STACK_SIZE)]) - env.AppendUnique(LINKFLAGS=['/STACK:' + str(STACK_SIZE)]) def configure_mingw(env): # Workaround for MinGW. See: @@ -271,125 +301,148 @@ def configure_mingw(env): ## Build type - if (env["target"] == "release"): - env.Append(CCFLAGS=['-msse2']) + if env["target"] == "release": + env.Append(CCFLAGS=["-msse2"]) - if (env["optimize"] == "speed"): #optimize for speed (default) - if (env["bits"] == "64"): - env.Append(CCFLAGS=['-O3']) + if env["optimize"] == "speed": # optimize for speed (default) + if env["bits"] == "64": + env.Append(CCFLAGS=["-O3"]) else: - env.Append(CCFLAGS=['-O2']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - - - env.Append(LINKFLAGS=['-Wl,--subsystem,windows']) - - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - - elif (env["target"] == "release_debug"): - env.Append(CCFLAGS=['-O2']) - env.Append(CPPDEFINES=['DEBUG_ENABLED']) - if (env["debug_symbols"] == "yes"): - env.Prepend(CCFLAGS=['-g1']) - if (env["debug_symbols"] == "full"): - env.Prepend(CCFLAGS=['-g2']) - if (env["optimize"] == "speed"): #optimize for speed (default) - env.Append(CCFLAGS=['-O2']) - else: #optimize for size - env.Prepend(CCFLAGS=['-Os']) - - elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-g3']) - env.Append(CPPDEFINES=['DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=["-O2"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + + env.Append(LINKFLAGS=["-Wl,--subsystem,windows"]) + + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + + elif env["target"] == "release_debug": + env.Append(CCFLAGS=["-O2"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED"]) + if env["debug_symbols"] == "yes": + env.Prepend(CCFLAGS=["-g1"]) + if env["debug_symbols"] == "full": + env.Prepend(CCFLAGS=["-g2"]) + if env["optimize"] == "speed": # optimize for speed (default) + env.Append(CCFLAGS=["-O2"]) + else: # optimize for size + env.Prepend(CCFLAGS=["-Os"]) + + elif env["target"] == "debug": + env.Append(CCFLAGS=["-g3"]) + env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_MEMORY_ENABLED"]) ## Compiler configuration if os.name != "nt": env["PROGSUFFIX"] = env["PROGSUFFIX"] + ".exe" # for linux cross-compilation - if (env["bits"] == "default"): - if (os.name == "nt"): + if env["bits"] == "default": + if os.name == "nt": env["bits"] = "64" if "PROGRAMFILES(X86)" in os.environ else "32" - else: # default to 64-bit on Linux + else: # default to 64-bit on Linux env["bits"] = "64" mingw_prefix = "" - if (env["bits"] == "32"): - env.Append(LINKFLAGS=['-static']) - env.Append(LINKFLAGS=['-static-libgcc']) - env.Append(LINKFLAGS=['-static-libstdc++']) + if env["bits"] == "32": + env.Append(LINKFLAGS=["-static"]) + env.Append(LINKFLAGS=["-static-libgcc"]) + env.Append(LINKFLAGS=["-static-libstdc++"]) mingw_prefix = env["mingw_prefix_32"] else: - env.Append(LINKFLAGS=['-static']) + env.Append(LINKFLAGS=["-static"]) mingw_prefix = env["mingw_prefix_64"] - if env['use_llvm']: + if env["use_llvm"]: env["CC"] = mingw_prefix + "clang" - env['AS'] = mingw_prefix + "as" + env["AS"] = mingw_prefix + "as" env["CXX"] = mingw_prefix + "clang++" - env['AR'] = mingw_prefix + "ar" - env['RANLIB'] = mingw_prefix + "ranlib" + env["AR"] = mingw_prefix + "ar" + env["RANLIB"] = mingw_prefix + "ranlib" env["LINK"] = mingw_prefix + "clang++" else: env["CC"] = mingw_prefix + "gcc" - env['AS'] = mingw_prefix + "as" - env['CXX'] = mingw_prefix + "g++" - env['AR'] = mingw_prefix + "gcc-ar" - env['RANLIB'] = mingw_prefix + "gcc-ranlib" - env['LINK'] = mingw_prefix + "g++" + env["AS"] = mingw_prefix + "as" + env["CXX"] = mingw_prefix + "g++" + env["AR"] = mingw_prefix + "gcc-ar" + env["RANLIB"] = mingw_prefix + "gcc-ranlib" + env["LINK"] = mingw_prefix + "g++" env["x86_libtheora_opt_gcc"] = True - if env['use_lto']: - if not env['use_llvm'] and env.GetOption("num_jobs") > 1: - env.Append(CCFLAGS=['-flto']) - env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))]) + if env["use_lto"]: + if not env["use_llvm"] and env.GetOption("num_jobs") > 1: + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))]) else: - if env['use_thinlto']: - env.Append(CCFLAGS=['-flto=thin']) - env.Append(LINKFLAGS=['-flto=thin']) + if env["use_thinlto"]: + env.Append(CCFLAGS=["-flto=thin"]) + env.Append(LINKFLAGS=["-flto=thin"]) else: - env.Append(CCFLAGS=['-flto']) - env.Append(LINKFLAGS=['-flto']) + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto"]) - env.Append(LINKFLAGS=['-Wl,--stack,' + str(STACK_SIZE)]) + env.Append(LINKFLAGS=["-Wl,--stack," + str(STACK_SIZE)]) ## Compile flags - env.Append(CCFLAGS=['-mwindows']) - - env.Append(CPPDEFINES=['WINDOWS_ENABLED', 'WASAPI_ENABLED', 'WINMIDI_ENABLED']) - env.Append(CPPDEFINES=[('WINVER', env['target_win_version']), ('_WIN32_WINNT', env['target_win_version'])]) - env.Append(LIBS=['mingw32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser', 'imm32', 'bcrypt', 'avrt', 'uuid', 'dwmapi']) - - env.Append(CPPDEFINES=['VULKAN_ENABLED']) - if not env['builtin_vulkan']: - env.Append(LIBS=['vulkan']) + env.Append(CCFLAGS=["-mwindows"]) + + env.Append(CPPDEFINES=["WINDOWS_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"]) + env.Append(CPPDEFINES=[("WINVER", env["target_win_version"]), ("_WIN32_WINNT", env["target_win_version"])]) + env.Append( + LIBS=[ + "mingw32", + "dsound", + "ole32", + "d3d9", + "winmm", + "gdi32", + "iphlpapi", + "shlwapi", + "wsock32", + "ws2_32", + "kernel32", + "oleaut32", + "dinput8", + "dxguid", + "ksuser", + "imm32", + "bcrypt", + "avrt", + "uuid", + "dwmapi", + ] + ) + + env.Append(CPPDEFINES=["VULKAN_ENABLED"]) + if not env["builtin_vulkan"]: + env.Append(LIBS=["vulkan"]) else: - env.Append(LIBS=['cfgmgr32']) + env.Append(LIBS=["cfgmgr32"]) ## TODO !!! Reenable when OpenGLES Rendering Device is implemented !!! - #env.Append(CPPDEFINES=['OPENGL_ENABLED']) - env.Append(LIBS=['opengl32']) + # env.Append(CPPDEFINES=['OPENGL_ENABLED']) + env.Append(LIBS=["opengl32"]) - env.Append(CPPDEFINES=['MINGW_ENABLED', ('MINGW_HAS_SECURE_API', 1)]) + env.Append(CPPDEFINES=["MINGW_ENABLED", ("MINGW_HAS_SECURE_API", 1)]) # resrc - env.Append(BUILDERS={'RES': env.Builder(action=build_res_file, suffix='.o', src_suffix='.rc')}) + env.Append(BUILDERS={"RES": env.Builder(action=build_res_file, suffix=".o", src_suffix=".rc")}) + def configure(env): # At this point the env has been set up with basic tools/compilers. - env.Prepend(CPPPATH=['#platform/windows']) + env.Prepend(CPPPATH=["#platform/windows"]) - print("Configuring for Windows: target=%s, bits=%s" % (env['target'], env['bits'])) + print("Configuring for Windows: target=%s, bits=%s" % (env["target"], env["bits"])) - if (os.name == "nt"): - env['ENV'] = os.environ # this makes build less repeatable, but simplifies some things - env['ENV']['TMP'] = os.environ['TMP'] + if os.name == "nt": + env["ENV"] = os.environ # this makes build less repeatable, but simplifies some things + env["ENV"]["TMP"] = os.environ["TMP"] # First figure out which compiler, version, and target arch we're using if os.getenv("VCINSTALLDIR") and not env["use_mingw"]: @@ -397,7 +450,7 @@ def configure(env): setup_msvc_manual(env) env.msvc = True manual_msvc_config = True - elif env.get('MSVC_VERSION', '') and not env["use_mingw"]: + elif env.get("MSVC_VERSION", "") and not env["use_mingw"]: setup_msvc_auto(env) env.msvc = True manual_msvc_config = False @@ -409,5 +462,5 @@ def configure(env): if env.msvc: configure_msvc(env, manual_msvc_config) - else: # MinGW + else: # MinGW configure_mingw(env) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 707337bc8d..ebe9a7d27a 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* display_server_windows.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #include "display_server_windows.h" #include "core/io/marshalls.h" #include "main/main.h" @@ -13,9 +43,9 @@ #ifdef DEBUG_ENABLED static String format_error_message(DWORD id) { - LPWSTR messageBuffer = NULL; + LPWSTR messageBuffer = nullptr; size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); + nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); String msg = "Error " + itos(id) + ": " + String(messageBuffer, size); @@ -53,7 +83,7 @@ String DisplayServerWindows::get_name() const { } void DisplayServerWindows::alert(const String &p_alert, const String &p_title) { - MessageBoxW(NULL, p_alert.c_str(), p_title.c_str(), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); + MessageBoxW(nullptr, p_alert.c_str(), p_title.c_str(), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); } void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { @@ -76,11 +106,11 @@ void DisplayServerWindows::_set_mouse_mode_impl(MouseMode p_mode) { } } else { ReleaseCapture(); - ClipCursor(NULL); + ClipCursor(nullptr); } if (p_mode == MOUSE_MODE_CAPTURED || p_mode == MOUSE_MODE_HIDDEN) { - hCursor = SetCursor(NULL); + hCursor = SetCursor(nullptr); } else { CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; @@ -152,7 +182,7 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { EmptyClipboard(); HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * sizeof(CharType)); - ERR_FAIL_COND_MSG(mem == NULL, "Unable to allocate memory for clipboard contents."); + ERR_FAIL_COND_MSG(mem == nullptr, "Unable to allocate memory for clipboard contents."); LPWSTR lptstrCopy = (LPWSTR)GlobalLock(mem); memcpy(lptstrCopy, text.c_str(), (text.length() + 1) * sizeof(CharType)); @@ -163,7 +193,7 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { // set the CF_TEXT version (not needed?) CharString utf8 = text.utf8(); mem = GlobalAlloc(GMEM_MOVEABLE, utf8.length() + 1); - ERR_FAIL_COND_MSG(mem == NULL, "Unable to allocate memory for clipboard contents."); + ERR_FAIL_COND_MSG(mem == nullptr, "Unable to allocate memory for clipboard contents."); LPTSTR ptr = (LPTSTR)GlobalLock(mem); memcpy(ptr, utf8.get_data(), utf8.length()); @@ -190,10 +220,10 @@ String DisplayServerWindows::clipboard_get() const { if (IsClipboardFormatAvailable(CF_UNICODETEXT)) { HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); - if (mem != NULL) { + if (mem != nullptr) { LPWSTR ptr = (LPWSTR)GlobalLock(mem); - if (ptr != NULL) { + if (ptr != nullptr) { ret = String((CharType *)ptr); GlobalUnlock(mem); @@ -203,10 +233,10 @@ String DisplayServerWindows::clipboard_get() const { } else if (IsClipboardFormatAvailable(CF_TEXT)) { HGLOBAL mem = GetClipboardData(CF_UNICODETEXT); - if (mem != NULL) { + if (mem != nullptr) { LPTSTR ptr = (LPTSTR)GlobalLock(mem); - if (ptr != NULL) { + if (ptr != nullptr) { ret.parse_utf8((const char *)ptr); GlobalUnlock(mem); @@ -247,7 +277,7 @@ int DisplayServerWindows::get_screen_count() const { _THREAD_SAFE_METHOD_ int data = 0; - EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcCount, (LPARAM)&data); + EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcCount, (LPARAM)&data); return data; } @@ -273,7 +303,7 @@ Point2i DisplayServerWindows::screen_get_position(int p_screen) const { _THREAD_SAFE_METHOD_ EnumPosData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Point2() }; - EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcPos, (LPARAM)&data); + EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcPos, (LPARAM)&data); return data.pos; } @@ -306,7 +336,7 @@ Size2i DisplayServerWindows::screen_get_size(int p_screen) const { _THREAD_SAFE_METHOD_ EnumSizeData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Size2() }; - EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data); + EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcSize, (LPARAM)&data); return data.size; } @@ -334,7 +364,7 @@ Rect2i DisplayServerWindows::screen_get_usable_rect(int p_screen) const { _THREAD_SAFE_METHOD_ EnumRectData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Rect2i() }; - EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcUsableSize, (LPARAM)&data); + EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcUsableSize, (LPARAM)&data); return data.rect; } @@ -355,15 +385,15 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau int dpiX = 96, dpiY = 96; - static HMODULE Shcore = NULL; + static HMODULE Shcore = nullptr; typedef HRESULT(WINAPI * GetDPIForMonitor_t)(HMONITOR hmonitor, _MonitorDpiType dpiType, UINT * dpiX, UINT * dpiY); - static GetDPIForMonitor_t getDPIForMonitor = NULL; + static GetDPIForMonitor_t getDPIForMonitor = nullptr; - if (Shcore == NULL) { + if (Shcore == nullptr) { Shcore = LoadLibraryW(L"Shcore.dll"); - getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : NULL; + getDPIForMonitor = Shcore ? (GetDPIForMonitor_t)GetProcAddress(Shcore, "GetDpiForMonitor") : nullptr; - if ((Shcore == NULL) || (getDPIForMonitor == NULL)) { + if ((Shcore == nullptr) || (getDPIForMonitor == nullptr)) { if (Shcore) FreeLibrary(Shcore); Shcore = (HMODULE)INVALID_HANDLE_VALUE; @@ -382,11 +412,11 @@ static int QueryDpiForMonitor(HMONITOR hmon, _MonitorDpiType dpiType = MDT_Defau } else { static int overallX = 0, overallY = 0; if (overallX <= 0 || overallY <= 0) { - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); if (hdc) { overallX = GetDeviceCaps(hdc, LOGPIXELSX); overallY = GetDeviceCaps(hdc, LOGPIXELSY); - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); } } if (overallX > 0 && overallY > 0) { @@ -413,7 +443,7 @@ int DisplayServerWindows::screen_get_dpi(int p_screen) const { _THREAD_SAFE_METHOD_ EnumDpiData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, 72 }; - EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcDpi, (LPARAM)&data); + EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcDpi, (LPARAM)&data); return data.dpi; } bool DisplayServerWindows::screen_is_touchscreen(int p_screen) const { @@ -588,7 +618,7 @@ int DisplayServerWindows::window_get_current_screen(WindowID p_window) const { ERR_FAIL_COND_V(!windows.has(p_window), -1); EnumScreenData data = { 0, 0, MonitorFromWindow(windows[p_window].hWnd, MONITOR_DEFAULTTONEAREST) }; - EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&data); + EnumDisplayMonitors(nullptr, nullptr, _MonitorEnumProcScreen, (LPARAM)&data); return data.screen; } void DisplayServerWindows::window_set_current_screen(int p_screen, WindowID p_window) { @@ -704,7 +734,7 @@ void DisplayServerWindows::window_set_transient(WindowID p_window, WindowID p_pa wd_window.transient_parent = INVALID_WINDOW_ID; wd_parent.transient_children.erase(p_window); - SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, NULL); + SetWindowLongPtr(wd_window.hWnd, GWLP_HWNDPARENT, (LONG_PTR) nullptr); } else { ERR_FAIL_COND(!windows.has(p_parent)); ERR_FAIL_COND_MSG(wd_window.transient_parent != INVALID_WINDOW_ID, "Window already has a transient parent"); @@ -989,7 +1019,8 @@ bool DisplayServerWindows::window_is_maximize_allowed(WindowID p_window) const { _THREAD_SAFE_METHOD_ ERR_FAIL_COND_V(!windows.has(p_window), false); - const WindowData &wd = windows[p_window]; + + // FIXME: Implement this, or confirm that it should always be true. return true; //no idea } @@ -1019,14 +1050,17 @@ void DisplayServerWindows::window_set_flag(WindowFlags p_flag, bool p_enabled, W } break; case WINDOW_FLAG_TRANSPARENT: { + // FIXME: Implement. } break; case WINDOW_FLAG_NO_FOCUS: { wd.no_focus = p_enabled; _update_window_style(p_window); } break; + case WINDOW_FLAG_MAX: break; } } + bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window) const { _THREAD_SAFE_METHOD_ @@ -1048,7 +1082,13 @@ bool DisplayServerWindows::window_get_flag(WindowFlags p_flag, WindowID p_window } break; case WINDOW_FLAG_TRANSPARENT: { + // FIXME: Implement. + } break; + case WINDOW_FLAG_NO_FOCUS: { + + return wd.no_focus; } break; + case WINDOW_FLAG_MAX: break; } return false; @@ -1184,7 +1224,7 @@ void DisplayServerWindows::cursor_set_shape(CursorShape p_shape) { IDC_HELP }; - if (cursors[p_shape] != NULL) { + if (cursors[p_shape] != nullptr) { SetCursor(cursors[p_shape]); } else { SetCursor(LoadCursor(hInstance, win_cursors[p_shape])); @@ -1199,7 +1239,7 @@ DisplayServer::CursorShape DisplayServerWindows::cursor_get_shape() const { void DisplayServerWindows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap) { // Get the system display DC - HDC hDC = GetDC(NULL); + HDC hDC = GetDC(nullptr); // Create helper DC HDC hMainDC = CreateCompatibleDC(hDC); @@ -1215,7 +1255,7 @@ void DisplayServerWindows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTra hXorMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // color // Release the system display DC - ReleaseDC(NULL, hDC); + ReleaseDC(nullptr, hDC); // Select the bitmaps to helper DC HBITMAP hOldMainBitmap = (HBITMAP)SelectObject(hMainDC, hSourceBitmap); @@ -1319,12 +1359,12 @@ void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorSh COLORREF clrTransparent = -1; // Create the AND and XOR masks for the bitmap - HBITMAP hAndMask = NULL; - HBITMAP hXorMask = NULL; + HBITMAP hAndMask = nullptr; + HBITMAP hXorMask = nullptr; GetMaskBitmaps(bitmap, clrTransparent, hAndMask, hXorMask); - if (NULL == hAndMask || NULL == hXorMask) { + if (nullptr == hAndMask || nullptr == hXorMask) { memfree(buffer); DeleteObject(bitmap); return; @@ -1354,11 +1394,11 @@ void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorSh } } - if (hAndMask != NULL) { + if (hAndMask != nullptr) { DeleteObject(hAndMask); } - if (hXorMask != NULL) { + if (hXorMask != nullptr) { DeleteObject(hXorMask); } @@ -1368,7 +1408,7 @@ void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorSh // Reset to default system cursor if (cursors[p_shape]) { DestroyIcon(cursors[p_shape]); - cursors[p_shape] = NULL; + cursors[p_shape] = nullptr; } CursorShape c = cursor_shape; @@ -1430,7 +1470,7 @@ DisplayServer::LatinKeyboardVariant DisplayServerWindows::get_latin_keyboard_var name[0] = 0; GetKeyboardLayoutNameA(name); - unsigned long hex = strtoul(name, NULL, 16); + unsigned long hex = strtoul(name, nullptr, 16); int i = 0; while (azerty[i] != 0) { @@ -1463,7 +1503,7 @@ void DisplayServerWindows::process_events() { joypad->process_joypads(); } - while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { + while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); @@ -1852,7 +1892,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST); - //force_quit=true; return 0; // Jump Back } case WM_MOUSELEAVE: { @@ -1870,9 +1909,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA UINT dwSize; - GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); + GetRawInputData((HRAWINPUT)lParam, RID_INPUT, nullptr, &dwSize, sizeof(RAWINPUTHEADER)); LPBYTE lpb = new BYTE[dwSize]; - if (lpb == NULL) { + if (lpb == nullptr) { return 0; } @@ -2395,7 +2434,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biSizeImage = dib_size.x * dib_size.y * 4; - hBitmap = CreateDIBSection(hDC_dib, &bmi, DIB_RGB_COLORS, (void **)&dib_data, NULL, 0x0); + hBitmap = CreateDIBSection(hDC_dib, &bmi, DIB_RGB_COLORS, (void **)&dib_data, nullptr, 0x0); SelectObject(hDC_dib, hBitmap); ZeroMemory(dib_data, dib_size.x * dib_size.y * 4); @@ -2406,7 +2445,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA case WM_ENTERSIZEMOVE: { InputFilter::get_singleton()->release_pressed_events(); - move_timer_id = SetTimer(windows[window_id].hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC)NULL); + move_timer_id = SetTimer(windows[window_id].hWnd, 1, USER_TIMER_MINIMUM, (TIMERPROC) nullptr); } break; case WM_EXITSIZEMOVE: { KillTimer(windows[window_id].hWnd, move_timer_id); @@ -2521,16 +2560,16 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (LOWORD(lParam) == HTCLIENT) { if (windows[window_id].window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) { //Hide the cursor - if (hCursor == NULL) - hCursor = SetCursor(NULL); + if (hCursor == nullptr) + hCursor = SetCursor(nullptr); else - SetCursor(NULL); + SetCursor(nullptr); } else { - if (hCursor != NULL) { + if (hCursor != nullptr) { CursorShape c = cursor_shape; cursor_shape = CURSOR_MAX; cursor_set_shape(c); - hCursor = NULL; + hCursor = nullptr; } } } @@ -2542,7 +2581,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA const int buffsize = 4096; wchar_t buf[buffsize]; - int fcount = DragQueryFileW(hDropInfo, 0xFFFFFFFF, NULL, 0); + int fcount = DragQueryFileW(hDropInfo, 0xFFFFFFFF, nullptr, 0); Vector<String> files; @@ -2693,9 +2732,9 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, WindowRect.top, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, - NULL, NULL, hInstance, NULL); + nullptr, nullptr, hInstance, nullptr); if (!wd.hWnd) { - MessageBoxW(NULL, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION); + MessageBoxW(nullptr, L"Window Creation Error.", L"ERROR", MB_OK | MB_ICONEXCLAMATION); return INVALID_WINDOW_ID; } #ifdef VULKAN_ENABLED @@ -2703,7 +2742,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, if (rendering_driver == "vulkan") { if (context_vulkan->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top) == -1) { memdelete(context_vulkan); - context_vulkan = NULL; + context_vulkan = nullptr; ERR_FAIL_V(INVALID_WINDOW_ID); } } @@ -2775,7 +2814,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win if (OS::get_singleton()->is_hidpi_allowed()) { HMODULE Shcore = LoadLibraryW(L"Shcore.dll"); - if (Shcore != NULL) { + if (Shcore != nullptr) { typedef HRESULT(WINAPI * SetProcessDpiAwareness_t)(SHC_PROCESS_DPI_AWARENESS); SetProcessDpiAwareness_t SetProcessDpiAwareness = (SetProcessDpiAwareness_t)GetProcAddress(Shcore, "SetProcessDpiAwareness"); @@ -2793,15 +2832,15 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win wc.cbClsExtra = 0; wc.cbWndExtra = 0; //wc.hInstance = hInstance; - wc.hInstance = hInstance ? hInstance : GetModuleHandle(NULL); - wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); - wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; + wc.hInstance = hInstance ? hInstance : GetModuleHandle(nullptr); + wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); + wc.hCursor = nullptr; //LoadCursor(nullptr, IDC_ARROW); + wc.hbrBackground = nullptr; + wc.lpszMenuName = nullptr; wc.lpszClassName = L"Engine"; if (!RegisterClassExW(&wc)) { - MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + MessageBox(nullptr, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION); r_error = ERR_UNAVAILABLE; return; } @@ -2828,7 +2867,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win context_vulkan = memnew(VulkanContextWindows); if (context_vulkan->initialize() != OK) { memdelete(context_vulkan); - context_vulkan = NULL; + context_vulkan = nullptr; r_error = ERR_UNAVAILABLE; return; } @@ -2841,7 +2880,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win if (context_gles2->initialize() != OK) { memdelete(context_gles2); - context_gles2 = NULL; + context_gles2 = nullptr; ERR_FAIL_V(ERR_UNAVAILABLE); } @@ -2853,7 +2892,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win RasterizerGLES2::make_current(); } else { memdelete(context_gles2); - context_gles2 = NULL; + context_gles2 = nullptr; ERR_FAIL_V(ERR_UNAVAILABLE); } } diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 47bb3f59a6..5cd240ffb0 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* display_server_windows.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + #ifndef DISPLAY_SERVER_WINDOWS_H #define DISPLAY_SERVER_WINDOWS_H @@ -13,9 +43,9 @@ #include "joypad_windows.h" #include "key_mapping_windows.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual/rasterizer_rd/rasterizer_rd.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering/rasterizer_rd/rasterizer_rd.h" +#include "servers/rendering_server.h" #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" @@ -236,7 +266,6 @@ class DisplayServerWindows : public DisplayServer { bool shift_mem = false; bool control_mem = false; bool meta_mem = false; - bool force_quit = false; uint32_t last_button_state = 0; bool use_raw_input = false; bool drop_events = false; @@ -244,7 +273,7 @@ class DisplayServerWindows : public DisplayServer { WNDCLASSEXW wc; - HCURSOR cursors[CURSOR_MAX] = { NULL }; + HCURSOR cursors[CURSOR_MAX] = { nullptr }; CursorShape cursor_shape; Map<CursorShape, Vector<Variant>> cursors_cache; diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 78a3fc8f79..d63067587c 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -315,7 +315,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p #endif String str; - Error err = OS::get_singleton()->execute(signtool_path, args, true, NULL, &str, NULL, true); + Error err = OS::get_singleton()->execute(signtool_path, args, true, nullptr, &str, nullptr, true); ERR_FAIL_COND_V(err != OK, err); print_line("codesign (" + p_path + "): " + str); diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp index dcc12b7649..2aa928c2a7 100644 --- a/platform/windows/godot_windows.cpp +++ b/platform/windows/godot_windows.cpp @@ -121,23 +121,23 @@ CommandLineToArgvA( i++; } _argv[j] = '\0'; - argv[argc] = NULL; + argv[argc] = nullptr; (*_argc) = argc; return argv; } char *wc_to_utf8(const wchar_t *wc) { - int ulen = WideCharToMultiByte(CP_UTF8, 0, wc, -1, NULL, 0, NULL, NULL); + int ulen = WideCharToMultiByte(CP_UTF8, 0, wc, -1, nullptr, 0, nullptr, nullptr); char *ubuf = new char[ulen + 1]; - WideCharToMultiByte(CP_UTF8, 0, wc, -1, ubuf, ulen, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, wc, -1, ubuf, ulen, nullptr, nullptr); ubuf[ulen] = 0; return ubuf; } int widechar_main(int argc, wchar_t **argv) { - OS_Windows os(NULL); + OS_Windows os(nullptr); setlocale(LC_CTYPE, ""); @@ -176,7 +176,7 @@ int _main() { wc_argv = CommandLineToArgvW(GetCommandLineW(), &argc); - if (NULL == wc_argv) { + if (nullptr == wc_argv) { wprintf(L"CommandLineToArgvW failed\n"); return 0; } @@ -202,9 +202,9 @@ int main(int _argc, char **_argv) { #endif } -HINSTANCE godot_hinstance = NULL; +HINSTANCE godot_hinstance = nullptr; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { godot_hinstance = hInstance; - return main(0, NULL); + return main(0, nullptr); } diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 9de1b7b194..437c3b733d 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -57,10 +57,10 @@ JoypadWindows::JoypadWindows(HWND *hwnd) { input = InputFilter::get_singleton(); hWnd = hwnd; joypad_count = 0; - dinput = NULL; - xinput_dll = NULL; - xinput_get_state = NULL; - xinput_set_state = NULL; + dinput = nullptr; + xinput_dll = nullptr; + xinput_get_state = nullptr; + xinput_set_state = nullptr; load_xinput(); @@ -68,7 +68,7 @@ JoypadWindows::JoypadWindows(HWND *hwnd) { attached_joypads[i] = false; HRESULT result; - result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, NULL); + result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr); if (FAILED(result)) { printf("failed init DINPUT: %ld\n", result); } @@ -105,10 +105,10 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { if (p_guid == &IID_ValveStreamingGamepad || p_guid == &IID_X360WiredGamepad || p_guid == &IID_X360WirelessGamepad) return true; - PRAWINPUTDEVICELIST dev_list = NULL; + PRAWINPUTDEVICELIST dev_list = nullptr; unsigned int dev_list_count = 0; - if (GetRawInputDeviceList(NULL, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) { + if (GetRawInputDeviceList(nullptr, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) { return false; } dev_list = (PRAWINPUTDEVICELIST)malloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count); @@ -130,7 +130,7 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { (GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != (UINT)-1) && (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == (LONG)p_guid->Data1) && (GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICENAME, &dev_name, &nameSize) != (UINT)-1) && - (strstr(dev_name, "IG_") != NULL)) { + (strstr(dev_name, "IG_") != nullptr)) { free(dev_list); return true; @@ -157,7 +157,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { return false; } - hr = dinput->CreateDevice(instance->guidInstance, &joy->di_joy, NULL); + hr = dinput->CreateDevice(instance->guidInstance, &joy->di_joy, nullptr); if (FAILED(hr)) { return false; diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h index f010fd08ff..0db789c335 100644 --- a/platform/windows/joypad_windows.h +++ b/platform/windows/joypad_windows.h @@ -39,9 +39,9 @@ #ifndef SAFE_RELEASE // when Windows Media Device M? is not present #define SAFE_RELEASE(x) \ - if (x != NULL) { \ + if (x != nullptr) { \ x->Release(); \ - x = NULL; \ + x = nullptr; \ } #endif diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index f78c87be93..0a67a591b7 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -46,8 +46,8 @@ #include "main/main.h" #include "platform/windows/display_server_windows.h" #include "servers/audio_server.h" -#include "servers/visual/visual_server_raster.h" -#include "servers/visual/visual_server_wrap_mt.h" +#include "servers/rendering/rendering_server_raster.h" +#include "servers/rendering/rendering_server_wrap_mt.h" #include "windows_terminal_logger.h" #include <avrt.h> @@ -81,9 +81,9 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; #ifdef DEBUG_ENABLED static String format_error_message(DWORD id) { - LPWSTR messageBuffer = NULL; + LPWSTR messageBuffer = nullptr; size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); + nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr); String msg = "Error " + itos(id) + ": " + String(messageBuffer, size); @@ -129,7 +129,7 @@ void RedirectIOToConsole() { *stdout = *fp; - setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stdout, nullptr, _IONBF, 0); // redirect unbuffered STDIN to the console @@ -141,7 +141,7 @@ void RedirectIOToConsole() { *stdin = *fp; - setvbuf(stdin, NULL, _IONBF, 0); + setvbuf(stdin, nullptr, _IONBF, 0); // redirect unbuffered STDERR to the console @@ -153,7 +153,7 @@ void RedirectIOToConsole() { *stderr = *fp; - setvbuf(stderr, NULL, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog @@ -213,14 +213,14 @@ void OS_Windows::initialize() { process_map = memnew((Map<ProcessID, ProcessInfo>)); IP_Unix::make_default(); - main_loop = NULL; + main_loop = nullptr; } void OS_Windows::delete_main_loop() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; } void OS_Windows::set_main_loop(MainLoop *p_main_loop) { @@ -237,7 +237,7 @@ void OS_Windows::finalize() { if (main_loop) memdelete(main_loop); - main_loop = NULL; + main_loop = nullptr; } void OS_Windows::finalize_core() { @@ -263,14 +263,14 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han PAddDllDirectory add_dll_directory = (PAddDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "AddDllDirectory"); PRemoveDllDirectory remove_dll_directory = (PRemoveDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "RemoveDllDirectory"); - bool has_dll_directory_api = ((add_dll_directory != NULL) && (remove_dll_directory != NULL)); - DLL_DIRECTORY_COOKIE cookie = NULL; + bool has_dll_directory_api = ((add_dll_directory != nullptr) && (remove_dll_directory != nullptr)); + DLL_DIRECTORY_COOKIE cookie = nullptr; if (p_also_set_library_path && has_dll_directory_api) { cookie = add_dll_directory(path.get_base_dir().c_str()); } - p_library_handle = (void *)LoadLibraryExW(path.c_str(), NULL, (p_also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0); + p_library_handle = (void *)LoadLibraryExW(path.c_str(), nullptr, (p_also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0); ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ", error: " + format_error_message(GetLastError()) + "."); if (cookie) { @@ -490,7 +490,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, modstr.resize(cmdline.size()); for (int i = 0; i < cmdline.size(); i++) modstr.write[i] = cmdline[i]; - int ret = CreateProcessW(NULL, modstr.ptrw(), NULL, NULL, 0, NORMAL_PRIORITY_CLASS & CREATE_NO_WINDOW, NULL, NULL, si_w, &pi.pi); + int ret = CreateProcessW(nullptr, modstr.ptrw(), nullptr, nullptr, 0, NORMAL_PRIORITY_CLASS & CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi); ERR_FAIL_COND_V(ret == 0, ERR_CANT_FORK); if (p_blocking) { @@ -542,7 +542,7 @@ Error OS_Windows::set_cwd(const String &p_cwd) { String OS_Windows::get_executable_path() const { wchar_t bufname[4096]; - GetModuleFileNameW(NULL, bufname, 4096); + GetModuleFileNameW(nullptr, bufname, 4096); String s = bufname; return s; } @@ -550,12 +550,12 @@ String OS_Windows::get_executable_path() const { bool OS_Windows::has_environment(const String &p_var) const { #ifdef MINGW_ENABLED - return _wgetenv(p_var.c_str()) != NULL; + return _wgetenv(p_var.c_str()) != nullptr; #else wchar_t *env; size_t len; _wdupenv_s(&env, &len, p_var.c_str()); - const bool has_env = env != NULL; + const bool has_env = env != nullptr; free(env); return has_env; #endif @@ -588,7 +588,7 @@ String OS_Windows::get_stdin_string(bool p_block) { Error OS_Windows::shell_open(String p_uri) { - ShellExecuteW(NULL, NULL, p_uri.c_str(), NULL, NULL, SW_SHOWNORMAL); + ShellExecuteW(nullptr, nullptr, p_uri.c_str(), nullptr, nullptr, SW_SHOWNORMAL); return OK; } @@ -739,7 +739,7 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const { } PWSTR szPath; - HRESULT res = SHGetKnownFolderPath(id, 0, NULL, &szPath); + HRESULT res = SHGetKnownFolderPath(id, 0, nullptr, &szPath); ERR_FAIL_COND_V(res != S_OK, String()); String path = String(szPath); CoTaskMemFree(szPath); @@ -794,11 +794,11 @@ Error OS_Windows::move_to_trash(const String &p_path) { sf.hwnd = main_window; sf.wFunc = FO_DELETE; sf.pFrom = from; - sf.pTo = NULL; + sf.pTo = nullptr; sf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; sf.fAnyOperationsAborted = FALSE; - sf.hNameMappings = NULL; - sf.lpszProgressTitle = NULL; + sf.hNameMappings = nullptr; + sf.lpszProgressTitle = nullptr; int ret = SHFileOperationW(&sf); delete[] from; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 040951668d..6bdfc75ebb 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -40,8 +40,8 @@ #include "drivers/winmidi/midi_driver_winmidi.h" #include "key_mapping_windows.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" #ifdef XAUDIO2_ENABLED #include "drivers/xaudio2/audio_driver_xaudio2.h" #endif @@ -130,7 +130,7 @@ public: virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; - virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false, Mutex *p_pipe_mutex = NULL); + virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr); virtual Error kill(const ProcessID &p_pid); virtual int get_process_id() const; diff --git a/platform/windows/platform_windows_builders.py b/platform/windows/platform_windows_builders.py index a1ad3b8b50..22e33b51b4 100644 --- a/platform/windows/platform_windows_builders.py +++ b/platform/windows/platform_windows_builders.py @@ -9,14 +9,14 @@ from platform_methods import subprocess_main def make_debug_mingw(target, source, env): mingw_prefix = "" - if (env["bits"] == "32"): + if env["bits"] == "32": mingw_prefix = env["mingw_prefix_32"] else: mingw_prefix = env["mingw_prefix_64"] - os.system(mingw_prefix + 'objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0])) - os.system(mingw_prefix + 'strip --strip-debug --strip-unneeded {0}'.format(target[0])) - os.system(mingw_prefix + 'objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0])) + os.system(mingw_prefix + "objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0])) + os.system(mingw_prefix + "strip --strip-debug --strip-unneeded {0}".format(target[0])) + os.system(mingw_prefix + "objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0])) -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/platform/windows/vulkan_context_win.cpp b/platform/windows/vulkan_context_win.cpp index 66b5cf8113..98aa21411f 100644 --- a/platform/windows/vulkan_context_win.cpp +++ b/platform/windows/vulkan_context_win.cpp @@ -39,13 +39,13 @@ int VulkanContextWindows::window_create(DisplayServer::WindowID p_window_id, HWN VkWin32SurfaceCreateInfoKHR createInfo; createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; - createInfo.pNext = NULL; + createInfo.pNext = nullptr; createInfo.flags = 0; createInfo.hinstance = p_instance; createInfo.hwnd = p_window; VkSurfaceKHR surface; - VkResult err = vkCreateWin32SurfaceKHR(_get_instance(), &createInfo, NULL, &surface); + VkResult err = vkCreateWin32SurfaceKHR(_get_instance(), &createInfo, nullptr, &surface); ERR_FAIL_COND_V(err, -1); return _window_create(p_window_id, surface, p_width, p_height); } diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index 520b654b94..884d95e082 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -49,7 +49,7 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er len = BUFFER_SIZE; // Output is too big, will be truncated buf[len] = 0; - int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, NULL, 0); + int wlen = MultiByteToWideChar(CP_UTF8, 0, buf, len, nullptr, 0); if (wlen < 0) return; diff --git a/platform_methods.py b/platform_methods.py index eed76bc8a8..805d7de82a 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -11,7 +11,6 @@ JSON_SERIALIZABLE_TYPES = (bool, int, float, str) def run_in_subprocess(builder_function): - @functools.wraps(builder_function) def wrapper(target, source, env): @@ -20,38 +19,36 @@ def run_in_subprocess(builder_function): source = [node.srcnode().abspath for node in source] # Short circuit on non-Windows platforms, no need to run in subprocess - if sys.platform not in ('win32', 'cygwin'): + if sys.platform not in ("win32", "cygwin"): return builder_function(target, source, env) # Identify module module_name = builder_function.__module__ function_name = builder_function.__name__ module_path = sys.modules[module_name].__file__ - if module_path.endswith('.pyc') or module_path.endswith('.pyo'): + if module_path.endswith(".pyc") or module_path.endswith(".pyo"): module_path = module_path[:-1] # Subprocess environment subprocess_env = os.environ.copy() - subprocess_env['PYTHONPATH'] = os.pathsep.join([os.getcwd()] + sys.path) + subprocess_env["PYTHONPATH"] = os.pathsep.join([os.getcwd()] + sys.path) # Keep only JSON serializable environment items - filtered_env = dict( - (key, value) - for key, value in env.items() - if isinstance(value, JSON_SERIALIZABLE_TYPES) - ) + filtered_env = dict((key, value) for key, value in env.items() if isinstance(value, JSON_SERIALIZABLE_TYPES)) # Save parameters args = (target, source, filtered_env) data = dict(fn=function_name, args=args) - json_path = os.path.join(os.environ['TMP'], uuid.uuid4().hex + '.json') - with open(json_path, 'wt') as json_file: + json_path = os.path.join(os.environ["TMP"], uuid.uuid4().hex + ".json") + with open(json_path, "wt") as json_file: json.dump(data, json_file, indent=2) json_file_size = os.stat(json_path).st_size - print('Executing builder function in subprocess: ' - 'module_path=%r, parameter_file=%r, parameter_file_size=%r, target=%r, source=%r' % ( - module_path, json_path, json_file_size, target, source)) + print( + "Executing builder function in subprocess: " + "module_path=%r, parameter_file=%r, parameter_file_size=%r, target=%r, source=%r" + % (module_path, json_path, json_file_size, target, source) + ) try: exit_code = subprocess.call([sys.executable, module_path, json_path], env=subprocess_env) finally: @@ -59,13 +56,15 @@ def run_in_subprocess(builder_function): os.remove(json_path) except (OSError, IOError) as e: # Do not fail the entire build if it cannot delete a temporary file - print('WARNING: Could not delete temporary file: path=%r; [%s] %s' % - (json_path, e.__class__.__name__, e)) + print( + "WARNING: Could not delete temporary file: path=%r; [%s] %s" % (json_path, e.__class__.__name__, e) + ) # Must succeed if exit_code: raise RuntimeError( - 'Failed to run builder function in subprocess: module_path=%r; data=%r' % (module_path, data)) + "Failed to run builder function in subprocess: module_path=%r; data=%r" % (module_path, data) + ) return wrapper @@ -75,5 +74,5 @@ def subprocess_main(namespace): with open(sys.argv[1]) as json_file: data = json.load(json_file) - fn = namespace[data['fn']] - fn(*data['args']) + fn = namespace[data["fn"]] + fn(*data["args"]) diff --git a/scene/2d/SCsub b/scene/2d/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/2d/SCsub +++ b/scene/2d/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 4cedfc0c20..fc34f967ce 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -652,7 +652,7 @@ void AnimatedSprite2D::_reset_timeout() { void AnimatedSprite2D::set_animation(const StringName &p_animation) { - ERR_FAIL_COND_MSG(frames == NULL, vformat("There is no animation with name '%s'.", p_animation)); + ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", p_animation)); ERR_FAIL_COND_MSG(frames->get_animation_names().find(p_animation) == -1, vformat("There is no animation with name '%s'.", p_animation)); if (animation == p_animation) diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index b99c4c88bf..c46b6eeb5c 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -32,12 +32,12 @@ #include "scene/scene_string_names.h" #include "servers/audio_server.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" void Area2D::set_space_override_mode(SpaceOverride p_mode) { space_override = p_mode; - Physics2DServer::get_singleton()->area_set_space_override_mode(get_rid(), Physics2DServer::AreaSpaceOverrideMode(p_mode)); + PhysicsServer2D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer2D::AreaSpaceOverrideMode(p_mode)); } Area2D::SpaceOverride Area2D::get_space_override_mode() const { @@ -47,7 +47,7 @@ Area2D::SpaceOverride Area2D::get_space_override_mode() const { void Area2D::set_gravity_is_point(bool p_enabled) { gravity_is_point = p_enabled; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled); } bool Area2D::is_gravity_a_point() const { @@ -57,7 +57,7 @@ bool Area2D::is_gravity_a_point() const { void Area2D::set_gravity_distance_scale(real_t p_scale) { gravity_distance_scale = p_scale; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); } real_t Area2D::get_gravity_distance_scale() const { @@ -67,7 +67,7 @@ real_t Area2D::get_gravity_distance_scale() const { void Area2D::set_gravity_vector(const Vector2 &p_vec) { gravity_vec = p_vec; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, p_vec); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, p_vec); } Vector2 Area2D::get_gravity_vector() const { @@ -77,7 +77,7 @@ Vector2 Area2D::get_gravity_vector() const { void Area2D::set_gravity(real_t p_gravity) { gravity = p_gravity; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY, p_gravity); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_GRAVITY, p_gravity); } real_t Area2D::get_gravity() const { @@ -87,7 +87,7 @@ real_t Area2D::get_gravity() const { void Area2D::set_linear_damp(real_t p_linear_damp) { linear_damp = p_linear_damp; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, p_linear_damp); } real_t Area2D::get_linear_damp() const { @@ -97,7 +97,7 @@ real_t Area2D::get_linear_damp() const { void Area2D::set_angular_damp(real_t p_angular_damp) { angular_damp = p_angular_damp; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp); } real_t Area2D::get_angular_damp() const { @@ -108,7 +108,7 @@ real_t Area2D::get_angular_damp() const { void Area2D::set_priority(real_t p_priority) { priority = p_priority; - Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_PRIORITY, p_priority); + PhysicsServer2D::get_singleton()->area_set_param(get_rid(), PhysicsServer2D::AREA_PARAM_PRIORITY, p_priority); } real_t Area2D::get_priority() const { @@ -151,7 +151,7 @@ void Area2D::_body_exit_tree(ObjectID p_id) { void Area2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) { - bool body_in = p_status == Physics2DServer::AREA_BODY_ADDED; + bool body_in = p_status == PhysicsServer2D::AREA_BODY_ADDED; ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); @@ -254,7 +254,7 @@ void Area2D::_area_exit_tree(ObjectID p_id) { void Area2D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) { - bool area_in = p_status == Physics2DServer::AREA_BODY_ADDED; + bool area_in = p_status == PhysicsServer2D::AREA_BODY_ADDED; ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); @@ -403,12 +403,12 @@ void Area2D::set_monitoring(bool p_enable) { if (monitoring) { - Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); - Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); + PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); + PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); } else { - Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName()); - Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName()); + PhysicsServer2D::get_singleton()->area_set_monitor_callback(get_rid(), nullptr, StringName()); + PhysicsServer2D::get_singleton()->area_set_area_monitor_callback(get_rid(), nullptr, StringName()); _clear_monitoring(); } } @@ -420,14 +420,14 @@ bool Area2D::is_monitoring() const { void Area2D::set_monitorable(bool p_enable) { - ERR_FAIL_COND_MSG(locked || (is_inside_tree() && Physics2DServer::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); + ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer2D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); if (p_enable == monitorable) return; monitorable = p_enable; - Physics2DServer::get_singleton()->area_set_monitorable(get_rid(), monitorable); + PhysicsServer2D::get_singleton()->area_set_monitorable(get_rid(), monitorable); } bool Area2D::is_monitorable() const { @@ -492,7 +492,7 @@ bool Area2D::overlaps_body(Node *p_body) const { void Area2D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; - Physics2DServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask); + PhysicsServer2D::get_singleton()->area_set_collision_mask(get_rid(), p_mask); } uint32_t Area2D::get_collision_mask() const { @@ -503,7 +503,7 @@ uint32_t Area2D::get_collision_mask() const { void Area2D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; - Physics2DServer::get_singleton()->area_set_collision_layer(get_rid(), p_layer); + PhysicsServer2D::get_singleton()->area_set_collision_layer(get_rid(), p_layer); } uint32_t Area2D::get_collision_layer() const { @@ -676,7 +676,7 @@ void Area2D::_bind_methods() { } Area2D::Area2D() : - CollisionObject2D(Physics2DServer::get_singleton()->area_create(), true) { + CollisionObject2D(PhysicsServer2D::get_singleton()->area_create(), true) { space_override = SPACE_OVERRIDE_DISABLED; set_gravity(98); diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index df0b17800f..55d111439a 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -187,9 +187,9 @@ void AudioStreamPlayer2D::_notification(int p_what) { //check if any area is diverting sound into a bus - Physics2DDirectSpaceState *space_state = Physics2DServer::get_singleton()->space_get_direct_state(world_2d->get_space()); + PhysicsDirectSpaceState2D *space_state = PhysicsServer2D::get_singleton()->space_get_direct_state(world_2d->get_space()); - Physics2DDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS]; + PhysicsDirectSpaceState2D::ShapeResult sr[MAX_INTERSECT_AREAS]; int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true); diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index faeb6b7169..4c952b7ca6 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -36,15 +36,15 @@ void BackBufferCopy::_update_copy_mode() { case COPY_MODE_DISABLED: { - VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2()); + RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2()); } break; case COPY_MODE_RECT: { - VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect); + RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect); } break; case COPY_MODE_VIEWPORT: { - VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2()); + RS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2()); } break; } diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index a8860c3d81..d8af14a3fb 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -33,7 +33,7 @@ #include "core/engine.h" #include "core/math/math_funcs.h" #include "scene/scene_string_names.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void Camera2D::_update_scroll() { @@ -264,7 +264,7 @@ void Camera2D::_notification(int p_what) { } remove_from_group(group_name); remove_from_group(canvas_group_name); - viewport = NULL; + viewport = nullptr; } break; case NOTIFICATION_DRAW: { @@ -433,7 +433,7 @@ void Camera2D::clear_current() { current = false; if (is_inside_tree()) { - get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)(NULL)); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)nullptr); } } @@ -794,7 +794,7 @@ Camera2D::Camera2D() { first = true; smoothing_enabled = false; limit_smoothing_enabled = false; - custom_viewport = NULL; + custom_viewport = nullptr; process_mode = CAMERA2D_PROCESS_IDLE; diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index 25db434918..05f8804e2a 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -35,23 +35,23 @@ void CanvasModulate::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_CANVAS) { if (is_visible_in_tree()) { - VS::get_singleton()->canvas_set_modulate(get_canvas(), color); + RS::get_singleton()->canvas_set_modulate(get_canvas(), color); add_to_group("_canvas_modulate_" + itos(get_canvas().get_id())); } } else if (p_what == NOTIFICATION_EXIT_CANVAS) { if (is_visible_in_tree()) { - VS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1)); + RS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1)); remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id())); } } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible_in_tree()) { - VS::get_singleton()->canvas_set_modulate(get_canvas(), color); + RS::get_singleton()->canvas_set_modulate(get_canvas(), color); add_to_group("_canvas_modulate_" + itos(get_canvas().get_id())); } else { - VS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1)); + RS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1)); remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id())); } @@ -71,7 +71,7 @@ void CanvasModulate::set_color(const Color &p_color) { color = p_color; if (is_visible_in_tree()) { - VS::get_singleton()->canvas_set_modulate(get_canvas(), color); + RS::get_singleton()->canvas_set_modulate(get_canvas(), color); } } Color CanvasModulate::get_color() const { diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 4af2e846f7..d82f4a2f2b 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -31,7 +31,7 @@ #include "collision_object_2d.h" #include "scene/scene_string_names.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" void CollisionObject2D::_notification(int p_what) { @@ -42,15 +42,15 @@ void CollisionObject2D::_notification(int p_what) { Transform2D global_transform = get_global_transform(); if (area) - Physics2DServer::get_singleton()->area_set_transform(rid, global_transform); + PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform); else - Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform); + PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform); RID space = get_world_2d()->get_space(); if (area) { - Physics2DServer::get_singleton()->area_set_space(rid, space); + PhysicsServer2D::get_singleton()->area_set_space(rid, space); } else - Physics2DServer::get_singleton()->body_set_space(rid, space); + PhysicsServer2D::get_singleton()->body_set_space(rid, space); _update_pickable(); @@ -60,9 +60,9 @@ void CollisionObject2D::_notification(int p_what) { case NOTIFICATION_ENTER_CANVAS: { if (area) - Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); + PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); else - Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); + PhysicsServer2D::get_singleton()->body_attach_canvas_instance_id(rid, get_canvas_layer_instance_id()); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -78,26 +78,26 @@ void CollisionObject2D::_notification(int p_what) { Transform2D global_transform = get_global_transform(); if (area) - Physics2DServer::get_singleton()->area_set_transform(rid, global_transform); + PhysicsServer2D::get_singleton()->area_set_transform(rid, global_transform); else - Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform); + PhysicsServer2D::get_singleton()->body_set_state(rid, PhysicsServer2D::BODY_STATE_TRANSFORM, global_transform); } break; case NOTIFICATION_EXIT_TREE: { if (area) { - Physics2DServer::get_singleton()->area_set_space(rid, RID()); + PhysicsServer2D::get_singleton()->area_set_space(rid, RID()); } else - Physics2DServer::get_singleton()->body_set_space(rid, RID()); + PhysicsServer2D::get_singleton()->body_set_space(rid, RID()); } break; case NOTIFICATION_EXIT_CANVAS: { if (area) - Physics2DServer::get_singleton()->area_attach_canvas_instance_id(rid, ObjectID()); + PhysicsServer2D::get_singleton()->area_attach_canvas_instance_id(rid, ObjectID()); else - Physics2DServer::get_singleton()->body_attach_canvas_instance_id(rid, ObjectID()); + PhysicsServer2D::get_singleton()->body_attach_canvas_instance_id(rid, ObjectID()); } break; } } @@ -136,9 +136,9 @@ void CollisionObject2D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl sd.disabled = p_disabled; for (int i = 0; i < sd.shapes.size(); i++) { if (area) { - Physics2DServer::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); + PhysicsServer2D::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); } else { - Physics2DServer::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); + PhysicsServer2D::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); } } } @@ -160,7 +160,7 @@ void CollisionObject2D::shape_owner_set_one_way_collision(uint32_t p_owner, bool ShapeData &sd = shapes[p_owner]; sd.one_way_collision = p_enable; for (int i = 0; i < sd.shapes.size(); i++) { - Physics2DServer::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin); + PhysicsServer2D::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin); } } @@ -181,7 +181,7 @@ void CollisionObject2D::shape_owner_set_one_way_collision_margin(uint32_t p_owne ShapeData &sd = shapes[p_owner]; sd.one_way_collision_margin = p_margin; for (int i = 0; i < sd.shapes.size(); i++) { - Physics2DServer::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin); + PhysicsServer2D::get_singleton()->body_set_shape_as_one_way_collision(rid, sd.shapes[i].index, sd.one_way_collision, sd.one_way_collision_margin); } } @@ -218,9 +218,9 @@ void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transf sd.xform = p_transform; for (int i = 0; i < sd.shapes.size(); i++) { if (area) { - Physics2DServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, sd.xform); + PhysicsServer2D::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, sd.xform); } else { - Physics2DServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, sd.xform); + PhysicsServer2D::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, sd.xform); } } } @@ -233,7 +233,7 @@ Transform2D CollisionObject2D::shape_owner_get_transform(uint32_t p_owner) const Object *CollisionObject2D::shape_owner_get_owner(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), NULL); + ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr); return shapes[p_owner].owner; } @@ -248,9 +248,9 @@ void CollisionObject2D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2 s.index = total_subshapes; s.shape = p_shape; if (area) { - Physics2DServer::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); + PhysicsServer2D::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); } else { - Physics2DServer::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); + PhysicsServer2D::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); } sd.shapes.push_back(s); @@ -284,9 +284,9 @@ void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) int index_to_remove = shapes[p_owner].shapes[p_shape].index; if (area) { - Physics2DServer::get_singleton()->area_remove_shape(rid, index_to_remove); + PhysicsServer2D::get_singleton()->area_remove_shape(rid, index_to_remove); } else { - Physics2DServer::get_singleton()->body_remove_shape(rid, index_to_remove); + PhysicsServer2D::get_singleton()->body_remove_shape(rid, index_to_remove); } shapes[p_owner].shapes.remove(p_shape); @@ -375,9 +375,9 @@ void CollisionObject2D::_update_pickable() { bool is_pickable = pickable && is_visible_in_tree(); if (area) - Physics2DServer::get_singleton()->area_set_pickable(rid, is_pickable); + PhysicsServer2D::get_singleton()->area_set_pickable(rid, is_pickable); else - Physics2DServer::get_singleton()->body_set_pickable(rid, is_pickable); + PhysicsServer2D::get_singleton()->body_set_pickable(rid, is_pickable); } String CollisionObject2D::get_configuration_warning() const { @@ -442,9 +442,9 @@ CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) { if (p_area) { - Physics2DServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); + PhysicsServer2D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); } else { - Physics2DServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id()); + PhysicsServer2D::get_singleton()->body_attach_object_instance_id(rid, get_instance_id()); } } @@ -457,5 +457,5 @@ CollisionObject2D::CollisionObject2D() { CollisionObject2D::~CollisionObject2D() { - Physics2DServer::get_singleton()->free(rid); + PhysicsServer2D::get_singleton()->free(rid); } diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 8874f61bb7..e931f20f40 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -60,7 +60,7 @@ class CollisionObject2D : public Node2D { disabled = false; one_way_collision = false; one_way_collision_margin = 0; - owner = NULL; + owner = nullptr; } }; diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index e9dfb94cb2..1e48b2d67f 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -106,7 +106,7 @@ void CollisionPolygon2D::_notification(int p_what) { /*if (Engine::get_singleton()->is_editor_hint()) { //display above all else set_z_as_relative(false); - set_z_index(VS::CANVAS_ITEM_Z_MAX - 1); + set_z_index(RS::CANVAS_ITEM_Z_MAX - 1); }*/ } break; @@ -129,7 +129,7 @@ void CollisionPolygon2D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; case NOTIFICATION_DRAW: { @@ -319,7 +319,7 @@ CollisionPolygon2D::CollisionPolygon2D() { aabb = Rect2(-10, -10, 20, 20); build_mode = BUILD_SOLIDS; set_notify_local_transform(true); - parent = NULL; + parent = nullptr; owner_id = 0; disabled = false; one_way_collision = false; diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index b2ad040654..b1dbc57c94 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -73,7 +73,7 @@ void CollisionShape2D::_notification(int p_what) { /*if (Engine::get_singleton()->is_editor_hint()) { //display above all else set_z_as_relative(false); - set_z_index(VS::CANVAS_ITEM_Z_MAX - 1); + set_z_index(RS::CANVAS_ITEM_Z_MAX - 1); }*/ } break; @@ -96,7 +96,7 @@ void CollisionShape2D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; case NOTIFICATION_DRAW: { @@ -249,7 +249,7 @@ CollisionShape2D::CollisionShape2D() { rect = Rect2(-Point2(10, 10), Point2(20, 20)); set_notify_local_transform(true); owner_id = 0; - parent = NULL; + parent = nullptr; disabled = false; one_way_collision = false; one_way_collision_margin = 1.0; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 8678e5a1f4..0a6b091a51 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -34,7 +34,7 @@ #include "scene/2d/gpu_particles_2d.h" #include "scene/main/canvas_item.h" #include "scene/resources/particles_material.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void CPUParticles2D::set_emitting(bool p_emitting) { @@ -60,7 +60,7 @@ void CPUParticles2D::set_amount(int p_amount) { } particle_data.resize((8 + 4 + 4) * p_amount); - VS::get_singleton()->multimesh_allocate(multimesh, p_amount, VS::MULTIMESH_TRANSFORM_2D, true, true); + RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_2D, true, true); particle_order.resize(p_amount); } @@ -198,14 +198,14 @@ void CPUParticles2D::_update_mesh_texture() { indices.push_back(0); Array arr; - arr.resize(VS::ARRAY_MAX); - arr[VS::ARRAY_VERTEX] = vertices; - arr[VS::ARRAY_TEX_UV] = uvs; - arr[VS::ARRAY_COLOR] = colors; - arr[VS::ARRAY_INDEX] = indices; + arr.resize(RS::ARRAY_MAX); + arr[RS::ARRAY_VERTEX] = vertices; + arr[RS::ARRAY_TEX_UV] = uvs; + arr[RS::ARRAY_COLOR] = colors; + arr[RS::ARRAY_INDEX] = indices; - VS::get_singleton()->mesh_clear(mesh); - VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VS::PRIMITIVE_TRIANGLES, arr); + RS::get_singleton()->mesh_clear(mesh); + RS::get_singleton()->mesh_add_surface_from_arrays(mesh, RS::PRIMITIVE_TRIANGLES, arr); } void CPUParticles2D::set_texture(const Ref<Texture2D> &p_texture) { @@ -976,7 +976,7 @@ void CPUParticles2D::_update_particle_data_buffer() { int pc = particles.size(); int *ow; - int *order = NULL; + int *order = nullptr; float *w = particle_data.ptrw(); const Particle *r = particles.ptr(); @@ -1046,17 +1046,17 @@ void CPUParticles2D::_set_redraw(bool p_redraw) { MutexLock lock(update_mutex); if (redraw) { - VS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread)); - VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true); + RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread)); + RS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), true); - VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1); + RS::get_singleton()->multimesh_set_visible_instances(multimesh, -1); } else { - if (VS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread))) { - VS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread)); + if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread))) { + RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles2D::_update_render_thread)); } - VS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), false); + RS::get_singleton()->canvas_item_set_update_when_visible(get_canvas_item(), false); - VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0); + RS::get_singleton()->multimesh_set_visible_instances(multimesh, 0); } } @@ -1067,7 +1067,7 @@ void CPUParticles2D::_update_render_thread() { MutexLock lock(update_mutex); - VS::get_singleton()->multimesh_set_buffer(multimesh, particle_data); + RS::get_singleton()->multimesh_set_buffer(multimesh, particle_data); } void CPUParticles2D::_notification(int p_what) { @@ -1098,7 +1098,7 @@ void CPUParticles2D::_notification(int p_what) { normrid = normalmap->get_rid(); } - VS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid, normrid); + RS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid, normrid); } if (p_what == NOTIFICATION_INTERNAL_PROCESS) { @@ -1145,7 +1145,7 @@ void CPUParticles2D::_notification(int p_what) { void CPUParticles2D::convert_from_particles(Node *p_particles) { GPUParticles2D *particles = Object::cast_to<GPUParticles2D>(p_particles); - ERR_FAIL_COND_MSG(!particles, "Only Particles2D nodes can be converted to CPUParticles2D."); + ERR_FAIL_COND_MSG(!particles, "Only GPUParticles2D nodes can be converted to CPUParticles2D."); set_emitting(particles->is_emitting()); set_amount(particles->get_amount()); @@ -1428,9 +1428,9 @@ CPUParticles2D::CPUParticles2D() { redraw = false; emitting = false; - mesh = VisualServer::get_singleton()->mesh_create(); - multimesh = VisualServer::get_singleton()->multimesh_create(); - VisualServer::get_singleton()->multimesh_set_mesh(multimesh, mesh); + mesh = RenderingServer::get_singleton()->mesh_create(); + multimesh = RenderingServer::get_singleton()->multimesh_create(); + RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, mesh); set_emitting(true); set_one_shot(false); @@ -1481,6 +1481,6 @@ CPUParticles2D::CPUParticles2D() { } CPUParticles2D::~CPUParticles2D() { - VS::get_singleton()->free(multimesh); - VS::get_singleton()->free(mesh); + RS::get_singleton()->free(multimesh); + RS::get_singleton()->free(mesh); } diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index d3d1326018..de3f8fa09e 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -40,7 +40,7 @@ void GPUParticles2D::set_emitting(bool p_emitting) { - VS::get_singleton()->particles_set_emitting(particles, p_emitting); + RS::get_singleton()->particles_set_emitting(particles, p_emitting); if (p_emitting && one_shot) { set_process_internal(true); @@ -53,25 +53,25 @@ void GPUParticles2D::set_amount(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1."); amount = p_amount; - VS::get_singleton()->particles_set_amount(particles, amount); + RS::get_singleton()->particles_set_amount(particles, amount); } void GPUParticles2D::set_lifetime(float p_lifetime) { ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; - VS::get_singleton()->particles_set_lifetime(particles, lifetime); + RS::get_singleton()->particles_set_lifetime(particles, lifetime); } void GPUParticles2D::set_one_shot(bool p_enable) { one_shot = p_enable; - VS::get_singleton()->particles_set_one_shot(particles, one_shot); + RS::get_singleton()->particles_set_one_shot(particles, one_shot); if (is_emitting()) { set_process_internal(true); if (!one_shot) - VisualServer::get_singleton()->particles_restart(particles); + RenderingServer::get_singleton()->particles_restart(particles); } if (!one_shot) @@ -80,17 +80,17 @@ void GPUParticles2D::set_one_shot(bool p_enable) { void GPUParticles2D::set_pre_process_time(float p_time) { pre_process_time = p_time; - VS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time); + RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time); } void GPUParticles2D::set_explosiveness_ratio(float p_ratio) { explosiveness_ratio = p_ratio; - VS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); + RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); } void GPUParticles2D::set_randomness_ratio(float p_ratio) { randomness_ratio = p_ratio; - VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); + RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { @@ -101,7 +101,7 @@ void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { aabb.size.x = p_visibility_rect.size.x; aabb.size.y = p_visibility_rect.size.y; - VS::get_singleton()->particles_set_custom_aabb(particles, aabb); + RS::get_singleton()->particles_set_custom_aabb(particles, aabb); _change_notify("visibility_rect"); update(); @@ -109,7 +109,7 @@ void GPUParticles2D::set_visibility_rect(const Rect2 &p_visibility_rect) { void GPUParticles2D::set_use_local_coordinates(bool p_enable) { local_coords = p_enable; - VS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); + RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); set_notify_transform(!p_enable); if (!p_enable && is_inside_tree()) { _update_particle_emission_transform(); @@ -124,7 +124,7 @@ void GPUParticles2D::_update_particle_emission_transform() { xf.basis.set_axis(1, Vector3(xf2d.get_axis(1).x, xf2d.get_axis(1).y, 0)); xf.set_origin(Vector3(xf2d.get_origin().x, xf2d.get_origin().y, 0)); - VS::get_singleton()->particles_set_emission_transform(particles, xf); + RS::get_singleton()->particles_set_emission_transform(particles, xf); } void GPUParticles2D::set_process_material(const Ref<Material> &p_material) { @@ -139,7 +139,7 @@ void GPUParticles2D::set_process_material(const Ref<Material> &p_material) { RID material_rid; if (process_material.is_valid()) material_rid = process_material->get_rid(); - VS::get_singleton()->particles_set_process_material(particles, material_rid); + RS::get_singleton()->particles_set_process_material(particles, material_rid); update_configuration_warning(); } @@ -147,12 +147,12 @@ void GPUParticles2D::set_process_material(const Ref<Material> &p_material) { void GPUParticles2D::set_speed_scale(float p_scale) { speed_scale = p_scale; - VS::get_singleton()->particles_set_speed_scale(particles, p_scale); + RS::get_singleton()->particles_set_speed_scale(particles, p_scale); } bool GPUParticles2D::is_emitting() const { - return VS::get_singleton()->particles_get_emitting(particles); + return RS::get_singleton()->particles_get_emitting(particles); } int GPUParticles2D::get_amount() const { @@ -200,7 +200,7 @@ float GPUParticles2D::get_speed_scale() const { void GPUParticles2D::set_draw_order(DrawOrder p_order) { draw_order = p_order; - VS::get_singleton()->particles_set_draw_order(particles, VS::ParticlesDrawOrder(p_order)); + RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order)); } GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const { @@ -210,7 +210,7 @@ GPUParticles2D::DrawOrder GPUParticles2D::get_draw_order() const { void GPUParticles2D::set_fixed_fps(int p_count) { fixed_fps = p_count; - VS::get_singleton()->particles_set_fixed_fps(particles, p_count); + RS::get_singleton()->particles_set_fixed_fps(particles, p_count); } int GPUParticles2D::get_fixed_fps() const { @@ -219,7 +219,7 @@ int GPUParticles2D::get_fixed_fps() const { void GPUParticles2D::set_fractional_delta(bool p_enable) { fractional_delta = p_enable; - VS::get_singleton()->particles_set_fractional_delta(particles, p_enable); + RS::get_singleton()->particles_set_fractional_delta(particles, p_enable); } bool GPUParticles2D::get_fractional_delta() const { @@ -228,8 +228,8 @@ bool GPUParticles2D::get_fractional_delta() const { String GPUParticles2D::get_configuration_warning() const { - if (VisualServer::get_singleton()->is_low_end()) { - return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles\" option for this purpose."); + if (RenderingServer::get_singleton()->is_low_end()) { + return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles2D\" option for this purpose."); } String warnings; @@ -259,7 +259,7 @@ String GPUParticles2D::get_configuration_warning() const { Rect2 GPUParticles2D::capture_rect() const { - AABB aabb = VS::get_singleton()->particles_get_current_aabb(particles); + AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles); Rect2 r; r.position.x = aabb.position.x; r.position.y = aabb.position.y; @@ -291,8 +291,8 @@ void GPUParticles2D::_validate_property(PropertyInfo &property) const { } void GPUParticles2D::restart() { - VS::get_singleton()->particles_restart(particles); - VS::get_singleton()->particles_set_emitting(particles, true); + RS::get_singleton()->particles_restart(particles); + RS::get_singleton()->particles_set_emitting(particles, true); } void GPUParticles2D::_notification(int p_what) { @@ -306,7 +306,7 @@ void GPUParticles2D::_notification(int p_what) { if (normal_map.is_valid()) normal_rid = normal_map->get_rid(); - VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid); + RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid); #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) { @@ -318,10 +318,10 @@ void GPUParticles2D::_notification(int p_what) { if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) { if (can_process()) { - VS::get_singleton()->particles_set_speed_scale(particles, speed_scale); + RS::get_singleton()->particles_set_speed_scale(particles, speed_scale); } else { - VS::get_singleton()->particles_set_speed_scale(particles, 0); + RS::get_singleton()->particles_set_speed_scale(particles, 0); } } @@ -408,7 +408,7 @@ void GPUParticles2D::_bind_methods() { GPUParticles2D::GPUParticles2D() { - particles = VS::get_singleton()->particles_create(); + particles = RS::get_singleton()->particles_create(); one_shot = false; // Needed so that set_emitting doesn't access uninitialized values set_emitting(true); @@ -428,5 +428,5 @@ GPUParticles2D::GPUParticles2D() { GPUParticles2D::~GPUParticles2D() { - VS::get_singleton()->free(particles); + RS::get_singleton()->free(particles); } diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 9cc9ab25ac..4d49f4762f 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -32,15 +32,15 @@ #include "core/engine.h" #include "physics_body_2d.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" void Joint2D::_update_joint(bool p_only_free) { if (joint.is_valid()) { if (ba.is_valid() && bb.is_valid() && exclude_from_collision) - Physics2DServer::get_singleton()->joint_disable_collisions_between_bodies(joint, false); + PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, false); - Physics2DServer::get_singleton()->free(joint); + PhysicsServer2D::get_singleton()->free(joint); joint = RID(); ba = RID(); bb = RID(); @@ -49,8 +49,8 @@ void Joint2D::_update_joint(bool p_only_free) { if (p_only_free || !is_inside_tree()) return; - Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL; - Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL; + Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr; + Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr; if (!node_a || !node_b) return; @@ -66,12 +66,12 @@ void Joint2D::_update_joint(bool p_only_free) { if (!joint.is_valid()) return; - Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias); + PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias); ba = body_a->get_rid(); bb = body_b->get_rid(); - Physics2DServer::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); + PhysicsServer2D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); } void Joint2D::set_node_a(const NodePath &p_node_a) { @@ -119,7 +119,7 @@ void Joint2D::set_bias(real_t p_bias) { bias = p_bias; if (joint.is_valid()) - Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias); + PhysicsServer2D::get_singleton()->get_singleton()->joint_set_param(joint, PhysicsServer2D::JOINT_PARAM_BIAS, bias); } real_t Joint2D::get_bias() const { @@ -192,8 +192,8 @@ void PinJoint2D::_notification(int p_what) { RID PinJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b) { - RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID()); - Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness); + RID pj = PhysicsServer2D::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID()); + PhysicsServer2D::get_singleton()->pin_joint_set_param(pj, PhysicsServer2D::PIN_JOINT_SOFTNESS, softness); return pj; } @@ -202,7 +202,7 @@ void PinJoint2D::set_softness(real_t p_softness) { softness = p_softness; update(); if (get_joint().is_valid()) - Physics2DServer::get_singleton()->pin_joint_set_param(get_joint(), Physics2DServer::PIN_JOINT_SOFTNESS, p_softness); + PhysicsServer2D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness); } real_t PinJoint2D::get_softness() const { @@ -253,7 +253,7 @@ RID GrooveJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D *body_b Vector2 groove_A2 = gt.xform(Vector2(0, length)); Vector2 anchor_B = gt.xform(Vector2(0, initial_offset)); - return Physics2DServer::get_singleton()->groove_joint_create(groove_A1, groove_A2, anchor_B, body_a->get_rid(), body_b->get_rid()); + return PhysicsServer2D::get_singleton()->groove_joint_create(groove_A1, groove_A2, anchor_B, body_a->get_rid(), body_b->get_rid()); } void GrooveJoint2D::set_length(real_t p_length) { @@ -324,11 +324,11 @@ RID DampedSpringJoint2D::_configure_joint(PhysicsBody2D *body_a, PhysicsBody2D * Vector2 anchor_A = gt.get_origin(); Vector2 anchor_B = gt.xform(Vector2(0, length)); - RID dsj = Physics2DServer::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid()); + RID dsj = PhysicsServer2D::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid()); if (rest_length) - Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_REST_LENGTH, rest_length); - Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_STIFFNESS, stiffness); - Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_DAMPING, damping); + PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_REST_LENGTH, rest_length); + PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_STIFFNESS, stiffness); + PhysicsServer2D::get_singleton()->damped_string_joint_set_param(dsj, PhysicsServer2D::DAMPED_STRING_DAMPING, damping); return dsj; } @@ -349,7 +349,7 @@ void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) { rest_length = p_rest_length; update(); if (get_joint().is_valid()) - Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length); + PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length); } real_t DampedSpringJoint2D::get_rest_length() const { @@ -362,7 +362,7 @@ void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) { stiffness = p_stiffness; update(); if (get_joint().is_valid()) - Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_STIFFNESS, p_stiffness); + PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_STIFFNESS, p_stiffness); } real_t DampedSpringJoint2D::get_stiffness() const { @@ -375,7 +375,7 @@ void DampedSpringJoint2D::set_damping(real_t p_damping) { damping = p_damping; update(); if (get_joint().is_valid()) - Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_DAMPING, p_damping); + PhysicsServer2D::get_singleton()->damped_string_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_STRING_DAMPING, p_damping); } real_t DampedSpringJoint2D::get_damping() const { diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index e61b1fa339..b3d54b81f8 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -31,7 +31,7 @@ #include "light_2d.h" #include "core/engine.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #ifdef TOOLS_ENABLED Dictionary Light2D::_edit_get_state() const { @@ -100,7 +100,7 @@ void Light2D::_update_light_visibility() { } #endif - VS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible_in_tree() && editor_ok); + RS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible_in_tree() && editor_ok); } void Light2D::set_enabled(bool p_enabled) { @@ -129,9 +129,9 @@ void Light2D::set_texture(const Ref<Texture2D> &p_texture) { texture = p_texture; if (texture.is_valid()) - VS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid()); + RS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid()); else - VS::get_singleton()->canvas_light_set_texture(canvas_light, RID()); + RS::get_singleton()->canvas_light_set_texture(canvas_light, RID()); update_configuration_warning(); } @@ -144,7 +144,7 @@ Ref<Texture2D> Light2D::get_texture() const { void Light2D::set_texture_offset(const Vector2 &p_offset) { texture_offset = p_offset; - VS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset); + RS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset); item_rect_changed(); _change_notify("offset"); } @@ -157,7 +157,7 @@ Vector2 Light2D::get_texture_offset() const { void Light2D::set_color(const Color &p_color) { color = p_color; - VS::get_singleton()->canvas_light_set_color(canvas_light, color); + RS::get_singleton()->canvas_light_set_color(canvas_light, color); } Color Light2D::get_color() const { @@ -167,7 +167,7 @@ Color Light2D::get_color() const { void Light2D::set_height(float p_height) { height = p_height; - VS::get_singleton()->canvas_light_set_height(canvas_light, height); + RS::get_singleton()->canvas_light_set_height(canvas_light, height); } float Light2D::get_height() const { @@ -178,7 +178,7 @@ float Light2D::get_height() const { void Light2D::set_energy(float p_energy) { energy = p_energy; - VS::get_singleton()->canvas_light_set_energy(canvas_light, energy); + RS::get_singleton()->canvas_light_set_energy(canvas_light, energy); } float Light2D::get_energy() const { @@ -193,7 +193,7 @@ void Light2D::set_texture_scale(float p_scale) { if (_scale == 0) { _scale = CMP_EPSILON; } - VS::get_singleton()->canvas_light_set_scale(canvas_light, _scale); + RS::get_singleton()->canvas_light_set_scale(canvas_light, _scale); item_rect_changed(); } @@ -205,7 +205,7 @@ float Light2D::get_texture_scale() const { void Light2D::set_z_range_min(int p_min_z) { z_min = p_min_z; - VS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max); + RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max); } int Light2D::get_z_range_min() const { @@ -215,7 +215,7 @@ int Light2D::get_z_range_min() const { void Light2D::set_z_range_max(int p_max_z) { z_max = p_max_z; - VS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max); + RS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max); } int Light2D::get_z_range_max() const { @@ -225,7 +225,7 @@ int Light2D::get_z_range_max() const { void Light2D::set_layer_range_min(int p_min_layer) { layer_min = p_min_layer; - VS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max); + RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max); } int Light2D::get_layer_range_min() const { @@ -235,7 +235,7 @@ int Light2D::get_layer_range_min() const { void Light2D::set_layer_range_max(int p_max_layer) { layer_max = p_max_layer; - VS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max); + RS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max); } int Light2D::get_layer_range_max() const { @@ -245,7 +245,7 @@ int Light2D::get_layer_range_max() const { void Light2D::set_item_cull_mask(int p_mask) { item_mask = p_mask; - VS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light, item_mask); + RS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light, item_mask); } int Light2D::get_item_cull_mask() const { @@ -256,7 +256,7 @@ int Light2D::get_item_cull_mask() const { void Light2D::set_item_shadow_cull_mask(int p_mask) { item_shadow_mask = p_mask; - VS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light, item_shadow_mask); + RS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light, item_shadow_mask); } int Light2D::get_item_shadow_cull_mask() const { @@ -267,7 +267,7 @@ int Light2D::get_item_shadow_cull_mask() const { void Light2D::set_mode(Mode p_mode) { mode = p_mode; - VS::get_singleton()->canvas_light_set_mode(canvas_light, VS::CanvasLightMode(p_mode)); + RS::get_singleton()->canvas_light_set_mode(canvas_light, RS::CanvasLightMode(p_mode)); } Light2D::Mode Light2D::get_mode() const { @@ -278,7 +278,7 @@ Light2D::Mode Light2D::get_mode() const { void Light2D::set_shadow_enabled(bool p_enabled) { shadow = p_enabled; - VS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow); + RS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow); } bool Light2D::is_shadow_enabled() const { @@ -288,7 +288,7 @@ bool Light2D::is_shadow_enabled() const { void Light2D::set_shadow_buffer_size(int p_size) { shadow_buffer_size = p_size; - VS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size); + RS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size); } int Light2D::get_shadow_buffer_size() const { @@ -299,7 +299,7 @@ int Light2D::get_shadow_buffer_size() const { void Light2D::set_shadow_filter(ShadowFilter p_filter) { ERR_FAIL_INDEX(p_filter, SHADOW_FILTER_MAX); shadow_filter = p_filter; - VS::get_singleton()->canvas_light_set_shadow_filter(canvas_light, VS::CanvasLightShadowFilter(p_filter)); + RS::get_singleton()->canvas_light_set_shadow_filter(canvas_light, RS::CanvasLightShadowFilter(p_filter)); } Light2D::ShadowFilter Light2D::get_shadow_filter() const { @@ -309,7 +309,7 @@ Light2D::ShadowFilter Light2D::get_shadow_filter() const { void Light2D::set_shadow_color(const Color &p_shadow_color) { shadow_color = p_shadow_color; - VS::get_singleton()->canvas_light_set_shadow_color(canvas_light, shadow_color); + RS::get_singleton()->canvas_light_set_shadow_color(canvas_light, shadow_color); } Color Light2D::get_shadow_color() const { @@ -320,13 +320,13 @@ void Light2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - VS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas()); + RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas()); _update_light_visibility(); } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - VS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform()); + RS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform()); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -335,7 +335,7 @@ void Light2D::_notification(int p_what) { if (p_what == NOTIFICATION_EXIT_TREE) { - VS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID()); + RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID()); _update_light_visibility(); } } @@ -352,7 +352,7 @@ String Light2D::get_configuration_warning() const { void Light2D::set_shadow_smooth(float p_amount) { shadow_smooth = p_amount; - VS::get_singleton()->canvas_light_set_shadow_smooth(canvas_light, shadow_smooth); + RS::get_singleton()->canvas_light_set_shadow_smooth(canvas_light, shadow_smooth); } float Light2D::get_shadow_smooth() const { @@ -432,8 +432,8 @@ void Light2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Add,Sub,Mix,Mask"), "set_mode", "get_mode"); ADD_GROUP("Range", "range_"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range_height", PROPERTY_HINT_RANGE, "-2048,2048,0.1,or_lesser,or_greater"), "set_height", "get_height"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_min", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_min", "get_z_range_min"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_max", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_max", "get_z_range_max"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_min", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_min", "get_z_range_min"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "range_z_max", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range_max", "get_z_range_max"); ADD_PROPERTY(PropertyInfo(Variant::INT, "range_layer_min", PROPERTY_HINT_RANGE, "-512,512,1"), "set_layer_range_min", "get_layer_range_min"); ADD_PROPERTY(PropertyInfo(Variant::INT, "range_layer_max", PROPERTY_HINT_RANGE, "-512,512,1"), "set_layer_range_max", "get_layer_range_max"); ADD_PROPERTY(PropertyInfo(Variant::INT, "range_item_cull_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_item_cull_mask", "get_item_cull_mask"); @@ -458,7 +458,7 @@ void Light2D::_bind_methods() { Light2D::Light2D() { - canvas_light = VisualServer::get_singleton()->canvas_light_create(); + canvas_light = RenderingServer::get_singleton()->canvas_light_create(); enabled = true; editor_only = false; shadow = false; @@ -483,5 +483,5 @@ Light2D::Light2D() { Light2D::~Light2D() { - VisualServer::get_singleton()->free(canvas_light); + RenderingServer::get_singleton()->free(canvas_light); } diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index d4a5c93823..bd1a820aec 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -88,7 +88,7 @@ void OccluderPolygon2D::set_polygon(const Vector<Vector2> &p_polygon) { polygon = p_polygon; rect_cache_dirty = true; - VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed); + RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed); emit_changed(); } @@ -103,7 +103,7 @@ void OccluderPolygon2D::set_closed(bool p_closed) { return; closed = p_closed; if (polygon.size()) - VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, polygon, closed); + RS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, polygon, closed); emit_changed(); } @@ -115,7 +115,7 @@ bool OccluderPolygon2D::is_closed() const { void OccluderPolygon2D::set_cull_mode(CullMode p_mode) { cull = p_mode; - VS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, VS::CanvasOccluderPolygonCullMode(p_mode)); + RS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, RS::CanvasOccluderPolygonCullMode(p_mode)); } OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const { @@ -150,7 +150,7 @@ void OccluderPolygon2D::_bind_methods() { OccluderPolygon2D::OccluderPolygon2D() { - occ_polygon = VS::get_singleton()->canvas_occluder_polygon_create(); + occ_polygon = RS::get_singleton()->canvas_occluder_polygon_create(); closed = true; cull = CULL_DISABLED; rect_cache_dirty = true; @@ -158,7 +158,7 @@ OccluderPolygon2D::OccluderPolygon2D() { OccluderPolygon2D::~OccluderPolygon2D() { - VS::get_singleton()->free(occ_polygon); + RS::get_singleton()->free(occ_polygon); } void LightOccluder2D::_poly_changed() { @@ -172,17 +172,17 @@ void LightOccluder2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_CANVAS) { - VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas()); - VS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform()); - VS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree()); + RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas()); + RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform()); + RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree()); } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - VS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform()); + RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform()); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - VS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree()); + RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree()); } if (p_what == NOTIFICATION_DRAW) { @@ -214,7 +214,7 @@ void LightOccluder2D::_notification(int p_what) { if (p_what == NOTIFICATION_EXIT_CANVAS) { - VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID()); + RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID()); } } @@ -239,9 +239,9 @@ void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polyg occluder_polygon = p_polygon; if (occluder_polygon.is_valid()) - VS::get_singleton()->canvas_light_occluder_set_polygon(occluder, occluder_polygon->get_rid()); + RS::get_singleton()->canvas_light_occluder_set_polygon(occluder, occluder_polygon->get_rid()); else - VS::get_singleton()->canvas_light_occluder_set_polygon(occluder, RID()); + RS::get_singleton()->canvas_light_occluder_set_polygon(occluder, RID()); #ifdef DEBUG_ENABLED if (occluder_polygon.is_valid()) @@ -258,7 +258,7 @@ Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const { void LightOccluder2D::set_occluder_light_mask(int p_mask) { mask = p_mask; - VS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask); + RS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask); } int LightOccluder2D::get_occluder_light_mask() const { @@ -293,12 +293,12 @@ void LightOccluder2D::_bind_methods() { LightOccluder2D::LightOccluder2D() { - occluder = VS::get_singleton()->canvas_light_occluder_create(); + occluder = RS::get_singleton()->canvas_light_occluder_create(); mask = 1; set_notify_transform(true); } LightOccluder2D::~LightOccluder2D() { - VS::get_singleton()->free(occluder); + RS::get_singleton()->free(occluder); } diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 873c901c0a..c45eab70df 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -311,7 +311,7 @@ void Line2D::_draw() { lb.build(); - VS::get_singleton()->canvas_item_add_triangle_array( + RS::get_singleton()->canvas_item_add_triangle_array( get_canvas_item(), lb.indices, lb.vertices, diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 3385f2fbe0..6b06f2227a 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -95,9 +95,9 @@ static inline Vector2 interpolate(const Rect2 &r, const Vector2 &v) { LineBuilder::LineBuilder() { joint_mode = Line2D::LINE_JOINT_SHARP; width = 10; - curve = NULL; + curve = nullptr; default_color = Color(0.4, 0.5, 1); - gradient = NULL; + gradient = nullptr; sharp_limit = 2.f; round_precision = 8; begin_cap_mode = Line2D::LINE_CAP_NONE; @@ -147,8 +147,8 @@ void LineBuilder::build() { float current_distance1 = 0.f; float total_distance = 0.f; float width_factor = 1.f; - _interpolate_color = gradient != NULL; - bool retrieve_curve = curve != NULL; + _interpolate_color = gradient != nullptr; + bool retrieve_curve = curve != nullptr; bool distance_required = _interpolate_color || retrieve_curve || texture_mode == Line2D::LINE_TEXTURE_TILE || diff --git a/scene/2d/navigation_2d.cpp b/scene/2d/navigation_2d.cpp index bbabfa16c7..ae9fc0f32c 100644 --- a/scene/2d/navigation_2d.cpp +++ b/scene/2d/navigation_2d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "navigation_2d.h" -#include "servers/navigation_2d_server.h" +#include "servers/navigation_server_2d.h" void Navigation2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rid"), &Navigation2D::get_rid); @@ -51,44 +51,44 @@ void Navigation2D::_bind_methods() { void Navigation2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - Navigation2DServer::get_singleton()->map_set_active(map, true); + NavigationServer2D::get_singleton()->map_set_active(map, true); } break; case NOTIFICATION_EXIT_TREE: { - Navigation2DServer::get_singleton()->map_set_active(map, false); + NavigationServer2D::get_singleton()->map_set_active(map, false); } break; } } void Navigation2D::set_cell_size(float p_cell_size) { cell_size = p_cell_size; - Navigation2DServer::get_singleton()->map_set_cell_size(map, cell_size); + NavigationServer2D::get_singleton()->map_set_cell_size(map, cell_size); } void Navigation2D::set_edge_connection_margin(float p_edge_connection_margin) { edge_connection_margin = p_edge_connection_margin; - Navigation2DServer::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin); + NavigationServer2D::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin); } Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) const { - return Navigation2DServer::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); + return NavigationServer2D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); } Vector2 Navigation2D::get_closest_point(const Vector2 &p_point) const { - return Navigation2DServer::get_singleton()->map_get_closest_point(map, p_point); + return NavigationServer2D::get_singleton()->map_get_closest_point(map, p_point); } RID Navigation2D::get_closest_point_owner(const Vector2 &p_point) const { - return Navigation2DServer::get_singleton()->map_get_closest_point_owner(map, p_point); + return NavigationServer2D::get_singleton()->map_get_closest_point_owner(map, p_point); } Navigation2D::Navigation2D() { - map = Navigation2DServer::get_singleton()->map_create(); + map = NavigationServer2D::get_singleton()->map_create(); set_cell_size(10); // Ten pixels set_edge_connection_margin(100); } Navigation2D::~Navigation2D() { - Navigation2DServer::get_singleton()->free(map); + NavigationServer2D::get_singleton()->free(map); } diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp index e345a076ae..32da46e8a8 100644 --- a/scene/2d/navigation_agent_2d.cpp +++ b/scene/2d/navigation_agent_2d.cpp @@ -32,7 +32,7 @@ #include "core/engine.h" #include "scene/2d/navigation_2d.h" -#include "servers/navigation_2d_server.h" +#include "servers/navigation_server_2d.h" void NavigationAgent2D::_bind_methods() { @@ -94,16 +94,16 @@ void NavigationAgent2D::_notification(int p_what) { agent_parent = Object::cast_to<Node2D>(get_parent()); - Navigation2DServer::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); + NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); // Search the navigation node and set it { - Navigation2D *nav = NULL; + Navigation2D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation2D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -114,14 +114,14 @@ void NavigationAgent2D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - agent_parent = NULL; - set_navigation(NULL); + agent_parent = nullptr; + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (agent_parent) { - Navigation2DServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin()); + NavigationServer2D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().get_origin()); if (!target_reached) { if (distance_to_target() < target_desired_distance) { emit_signal("target_reached"); @@ -134,15 +134,15 @@ void NavigationAgent2D::_notification(int p_what) { } NavigationAgent2D::NavigationAgent2D() : - agent_parent(NULL), - navigation(NULL), + agent_parent(nullptr), + navigation(nullptr), agent(RID()), target_desired_distance(1.0), path_max_distance(3.0), velocity_submitted(false), target_reached(false), navigation_finished(true) { - agent = Navigation2DServer::get_singleton()->agent_create(); + agent = NavigationServer2D::get_singleton()->agent_create(); set_neighbor_dist(500.0); set_max_neighbors(10); set_time_horizon(20.0); @@ -151,7 +151,7 @@ NavigationAgent2D::NavigationAgent2D() : } NavigationAgent2D::~NavigationAgent2D() { - Navigation2DServer::get_singleton()->free(agent); + NavigationServer2D::get_singleton()->free(agent); agent = RID(); // Pointless } @@ -160,12 +160,12 @@ void NavigationAgent2D::set_navigation(Navigation2D *p_nav) { return; // Pointless navigation = p_nav; - Navigation2DServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationAgent2D::set_navigation_node(Node *p_nav) { Navigation2D *nav = Object::cast_to<Navigation2D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } @@ -179,27 +179,27 @@ void NavigationAgent2D::set_target_desired_distance(real_t p_dd) { void NavigationAgent2D::set_radius(real_t p_radius) { radius = p_radius; - Navigation2DServer::get_singleton()->agent_set_radius(agent, radius); + NavigationServer2D::get_singleton()->agent_set_radius(agent, radius); } void NavigationAgent2D::set_neighbor_dist(real_t p_dist) { neighbor_dist = p_dist; - Navigation2DServer::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist); + NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist); } void NavigationAgent2D::set_max_neighbors(int p_count) { max_neighbors = p_count; - Navigation2DServer::get_singleton()->agent_set_max_neighbors(agent, max_neighbors); + NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors); } void NavigationAgent2D::set_time_horizon(real_t p_time) { time_horizon = p_time; - Navigation2DServer::get_singleton()->agent_set_time_horizon(agent, time_horizon); + NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, time_horizon); } void NavigationAgent2D::set_max_speed(real_t p_max_speed) { max_speed = p_max_speed; - Navigation2DServer::get_singleton()->agent_set_max_speed(agent, max_speed); + NavigationServer2D::get_singleton()->agent_set_max_speed(agent, max_speed); } void NavigationAgent2D::set_path_max_distance(real_t p_pmd) { @@ -225,7 +225,7 @@ Vector2 NavigationAgent2D::get_target_location() const { Vector2 NavigationAgent2D::get_next_location() { update_navigation(); if (navigation_path.size() == 0) { - ERR_FAIL_COND_V(agent_parent == NULL, Vector2()); + ERR_FAIL_COND_V(agent_parent == nullptr, Vector2()); return agent_parent->get_global_transform().get_origin(); } else { return navigation_path[nav_path_index]; @@ -233,7 +233,7 @@ Vector2 NavigationAgent2D::get_next_location() { } real_t NavigationAgent2D::distance_to_target() const { - ERR_FAIL_COND_V(agent_parent == NULL, 0.0); + ERR_FAIL_COND_V(agent_parent == nullptr, 0.0); return agent_parent->get_global_transform().get_origin().distance_to(target_location); } @@ -260,8 +260,8 @@ Vector2 NavigationAgent2D::get_final_location() { void NavigationAgent2D::set_velocity(Vector2 p_velocity) { target_velocity = p_velocity; - Navigation2DServer::get_singleton()->agent_set_target_velocity(agent, target_velocity); - Navigation2DServer::get_singleton()->agent_set_velocity(agent, prev_safe_velocity); + NavigationServer2D::get_singleton()->agent_set_target_velocity(agent, target_velocity); + NavigationServer2D::get_singleton()->agent_set_velocity(agent, prev_safe_velocity); velocity_submitted = true; } @@ -288,8 +288,8 @@ String NavigationAgent2D::get_configuration_warning() const { void NavigationAgent2D::update_navigation() { - if (agent_parent == NULL) return; - if (navigation == NULL) return; + if (agent_parent == nullptr) return; + if (navigation == nullptr) return; if (update_frame_id == Engine::get_singleton()->get_physics_frames()) return; update_frame_id = Engine::get_singleton()->get_physics_frames(); @@ -298,7 +298,7 @@ void NavigationAgent2D::update_navigation() { bool reload_path = false; - if (Navigation2DServer::get_singleton()->agent_is_map_changed(agent)) { + if (NavigationServer2D::get_singleton()->agent_is_map_changed(agent)) { reload_path = true; } else if (navigation_path.size() == 0) { reload_path = true; @@ -317,7 +317,7 @@ void NavigationAgent2D::update_navigation() { } if (reload_path) { - navigation_path = Navigation2DServer::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true); + navigation_path = NavigationServer2D::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true); navigation_finished = false; nav_path_index = 0; emit_signal("path_changed"); diff --git a/scene/2d/navigation_obstacle_2d.cpp b/scene/2d/navigation_obstacle_2d.cpp index cc9f5740a9..50d02ca507 100644 --- a/scene/2d/navigation_obstacle_2d.cpp +++ b/scene/2d/navigation_obstacle_2d.cpp @@ -33,7 +33,7 @@ #include "scene/2d/collision_shape_2d.h" #include "scene/2d/navigation_2d.h" #include "scene/2d/physics_body_2d.h" -#include "servers/navigation_2d_server.h" +#include "servers/navigation_server_2d.h" void NavigationObstacle2D::_bind_methods() { @@ -49,12 +49,12 @@ void NavigationObstacle2D::_notification(int p_what) { // Search the navigation node and set it { - Navigation2D *nav = NULL; + Navigation2D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation2D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -65,13 +65,13 @@ void NavigationObstacle2D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - set_navigation(NULL); + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { Node2D *node = Object::cast_to<Node2D>(get_parent()); if (node) { - Navigation2DServer::get_singleton()->agent_set_position(agent, node->get_global_transform().get_origin()); + NavigationServer2D::get_singleton()->agent_set_position(agent, node->get_global_transform().get_origin()); } } break; @@ -79,13 +79,13 @@ void NavigationObstacle2D::_notification(int p_what) { } NavigationObstacle2D::NavigationObstacle2D() : - navigation(NULL), + navigation(nullptr), agent(RID()) { - agent = Navigation2DServer::get_singleton()->agent_create(); + agent = NavigationServer2D::get_singleton()->agent_create(); } NavigationObstacle2D::~NavigationObstacle2D() { - Navigation2DServer::get_singleton()->free(agent); + NavigationServer2D::get_singleton()->free(agent); agent = RID(); // Pointless } @@ -94,12 +94,12 @@ void NavigationObstacle2D::set_navigation(Navigation2D *p_nav) { return; // Pointless navigation = p_nav; - Navigation2DServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationObstacle2D::set_navigation_node(Node *p_nav) { Navigation2D *nav = Object::cast_to<Navigation2D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } @@ -146,9 +146,9 @@ void NavigationObstacle2D::update_agent_shape() { radius = 1.0; // Never a 0 radius // Initialize the Agent as an object - Navigation2DServer::get_singleton()->agent_set_neighbor_dist(agent, 0.0); - Navigation2DServer::get_singleton()->agent_set_max_neighbors(agent, 0); - Navigation2DServer::get_singleton()->agent_set_time_horizon(agent, 0.0); - Navigation2DServer::get_singleton()->agent_set_radius(agent, radius); - Navigation2DServer::get_singleton()->agent_set_max_speed(agent, 0.0); + NavigationServer2D::get_singleton()->agent_set_neighbor_dist(agent, 0.0); + NavigationServer2D::get_singleton()->agent_set_max_neighbors(agent, 0); + NavigationServer2D::get_singleton()->agent_set_time_horizon(agent, 0.0); + NavigationServer2D::get_singleton()->agent_set_radius(agent, radius); + NavigationServer2D::get_singleton()->agent_set_max_speed(agent, 0.0); } diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index bc3e305281..d77fd5b097 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -34,7 +34,7 @@ #include "core/engine.h" #include "core/os/mutex.h" #include "navigation_2d.h" -#include "servers/navigation_2d_server.h" +#include "servers/navigation_server_2d.h" #include "thirdparty/misc/triangulator.h" @@ -281,7 +281,7 @@ void NavigationPolygon::make_polygons_from_outlines() { for (int l = 0; l < olsize2; l++) { - if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], NULL)) { + if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], nullptr)) { interscount++; } } @@ -385,12 +385,12 @@ void NavigationRegion2D::set_enabled(bool p_enabled) { if (!enabled) { - Navigation2DServer::get_singleton()->region_set_map(region, RID()); + NavigationServer2D::get_singleton()->region_set_map(region, RID()); } else { if (navigation) { - Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); } } @@ -429,7 +429,7 @@ void NavigationRegion2D::_notification(int p_what) { if (enabled) { - Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); } break; } @@ -440,16 +440,16 @@ void NavigationRegion2D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - Navigation2DServer::get_singleton()->region_set_transform(region, get_global_transform()); + NavigationServer2D::get_singleton()->region_set_transform(region, get_global_transform()); } break; case NOTIFICATION_EXIT_TREE: { if (navigation) { - Navigation2DServer::get_singleton()->region_set_map(region, RID()); + NavigationServer2D::get_singleton()->region_set_map(region, RID()); } - navigation = NULL; + navigation = nullptr; } break; case NOTIFICATION_DRAW: { @@ -494,7 +494,7 @@ void NavigationRegion2D::_notification(int p_what) { } } } - VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, vertices, colors); + RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, vertices, colors); } } break; } @@ -511,7 +511,7 @@ void NavigationRegion2D::set_navigation_polygon(const Ref<NavigationPolygon> &p_ } navpoly = p_navpoly; - Navigation2DServer::get_singleton()->region_set_navpoly(region, p_navpoly); + NavigationServer2D::get_singleton()->region_set_navpoly(region, p_navpoly); if (navpoly.is_valid()) { navpoly->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NavigationRegion2D::_navpoly_changed)); @@ -572,11 +572,11 @@ NavigationRegion2D::NavigationRegion2D() { enabled = true; set_notify_transform(true); - region = Navigation2DServer::get_singleton()->region_create(); + region = NavigationServer2D::get_singleton()->region_create(); - navigation = NULL; + navigation = nullptr; } NavigationRegion2D::~NavigationRegion2D() { - Navigation2DServer::get_singleton()->free(region); + NavigationServer2D::get_singleton()->free(region); } diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 0b0b9820d3..ac8a77b6cb 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -33,7 +33,7 @@ #include "core/message_queue.h" #include "scene/gui/control.h" #include "scene/main/window.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #ifdef TOOLS_ENABLED Dictionary Node2D::_edit_get_state() const { @@ -136,7 +136,7 @@ void Node2D::_update_transform() { _mat.set_rotation_and_scale(angle, _scale); _mat.elements[2] = pos; - VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat); + RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat); if (!is_inside_tree()) return; @@ -315,7 +315,7 @@ void Node2D::set_transform(const Transform2D &p_transform) { _mat = p_transform; _xform_dirty = true; - VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat); + RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat); if (!is_inside_tree()) return; @@ -334,10 +334,10 @@ void Node2D::set_global_transform(const Transform2D &p_transform) { void Node2D::set_z_index(int p_z) { - ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN); - ERR_FAIL_COND(p_z > VS::CANVAS_ITEM_Z_MAX); + ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN); + ERR_FAIL_COND(p_z > RS::CANVAS_ITEM_Z_MAX); z_index = p_z; - VS::get_singleton()->canvas_item_set_z_index(get_canvas_item(), z_index); + RS::get_singleton()->canvas_item_set_z_index(get_canvas_item(), z_index); _change_notify("z_index"); } @@ -346,7 +346,7 @@ void Node2D::set_z_as_relative(bool p_enabled) { if (z_relative == p_enabled) return; z_relative = p_enabled; - VS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(), p_enabled); + RS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(), p_enabled); } bool Node2D::is_z_relative() const { @@ -452,7 +452,7 @@ void Node2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); ADD_GROUP("Z Index", ""); - ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "z_as_relative"), "set_z_as_relative", "is_z_relative"); } diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 5aea1025ef..181f0f158c 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -78,7 +78,7 @@ void ParallaxLayer::_update_mirroring() { RID c = pb->get_canvas(); RID ci = get_canvas_item(); Point2 mirrorScale = mirroring * get_scale(); - VisualServer::get_singleton()->canvas_set_item_mirroring(c, ci, mirrorScale); + RenderingServer::get_singleton()->canvas_set_item_mirroring(c, ci, mirrorScale); } } diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 3e807f12dc..d55b21bc24 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -242,7 +242,7 @@ void PathFollow2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - path = NULL; + path = nullptr; } break; } } @@ -421,7 +421,7 @@ PathFollow2D::PathFollow2D() { offset = 0; h_offset = 0; v_offset = 0; - path = NULL; + path = nullptr; rotate = true; cubic = true; loop = true; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 9bfeca7e56..21dc9537ec 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -82,7 +82,7 @@ void PhysicsBody2D::_bind_methods() { void PhysicsBody2D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; - Physics2DServer::get_singleton()->body_set_collision_layer(get_rid(), p_layer); + PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), p_layer); } uint32_t PhysicsBody2D::get_collision_layer() const { @@ -93,7 +93,7 @@ uint32_t PhysicsBody2D::get_collision_layer() const { void PhysicsBody2D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; - Physics2DServer::get_singleton()->body_set_collision_mask(get_rid(), p_mask); + PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), p_mask); } uint32_t PhysicsBody2D::get_collision_mask() const { @@ -130,10 +130,10 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { return get_collision_layer() & (1 << p_bit); } -PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : - CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) { +PhysicsBody2D::PhysicsBody2D(PhysicsServer2D::BodyMode p_mode) : + CollisionObject2D(PhysicsServer2D::get_singleton()->body_create(), false) { - Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode); + PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), p_mode); collision_layer = 1; collision_mask = 1; set_pickable(false); @@ -141,11 +141,11 @@ PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : Array PhysicsBody2D::get_collision_exceptions() { List<RID> exceptions; - Physics2DServer::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); + PhysicsServer2D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { RID body = E->get(); - ObjectID instance_id = Physics2DServer::get_singleton()->body_get_object_instance_id(body); + ObjectID instance_id = PhysicsServer2D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(obj); ret.append(physics_body); @@ -157,28 +157,28 @@ void PhysicsBody2D::add_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node); - ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody type."); - Physics2DServer::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid()); + ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody2D type."); + PhysicsServer2D::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid()); } void PhysicsBody2D::remove_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); PhysicsBody2D *physics_body = Object::cast_to<PhysicsBody2D>(p_node); - ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody type."); - Physics2DServer::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid()); + ERR_FAIL_COND_MSG(!physics_body, "Collision exception only works between two objects of PhysicsBody2D type."); + PhysicsServer2D::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid()); } void StaticBody2D::set_constant_linear_velocity(const Vector2 &p_vel) { constant_linear_velocity = p_vel; - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity); } void StaticBody2D::set_constant_angular_velocity(real_t p_vel) { constant_angular_velocity = p_vel; - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity); } Vector2 StaticBody2D::get_constant_linear_velocity() const { @@ -225,7 +225,7 @@ void StaticBody2D::_bind_methods() { } StaticBody2D::StaticBody2D() : - PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) { + PhysicsBody2D(PhysicsServer2D::BODY_MODE_STATIC) { constant_angular_velocity = 0; } @@ -235,11 +235,11 @@ StaticBody2D::~StaticBody2D() { void StaticBody2D::_reload_physics_characteristics() { if (physics_material_override.is_null()) { - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, 0); - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, 1); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1); } else { - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); } } @@ -360,20 +360,20 @@ struct _RigidBody2DInOut { int local_shape; }; -bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) { +bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) { - Physics2DServer::MotionResult *r = NULL; + PhysicsServer2D::MotionResult *r = nullptr; if (p_result.is_valid()) r = p_result->get_result_ptr(); - return Physics2DServer::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r); + return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r); } void RigidBody2D::_direct_state_changed(Object *p_state) { #ifdef DEBUG_ENABLED - state = Object::cast_to<Physics2DDirectBodyState>(p_state); + state = Object::cast_to<PhysicsDirectBodyState2D>(p_state); #else - state = (Physics2DDirectBodyState *)p_state; //trust it + state = (PhysicsDirectBodyState2D *)p_state; //trust it #endif set_block_transform_notify(true); // don't want notify (would feedback loop) @@ -474,7 +474,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) { contact_monitor->locked = false; } - state = NULL; + state = nullptr; } void RigidBody2D::set_mode(Mode p_mode) { @@ -484,20 +484,20 @@ void RigidBody2D::set_mode(Mode p_mode) { case MODE_RIGID: { - Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_RIGID); + PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_RIGID); } break; case MODE_STATIC: { - Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_STATIC); + PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_STATIC); } break; case MODE_KINEMATIC: { - Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_KINEMATIC); + PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_KINEMATIC); } break; case MODE_CHARACTER: { - Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_CHARACTER); + PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BODY_MODE_CHARACTER); } break; } @@ -514,7 +514,7 @@ void RigidBody2D::set_mass(real_t p_mass) { mass = p_mass; _change_notify("mass"); _change_notify("weight"); - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_MASS, mass); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass); } real_t RigidBody2D::get_mass() const { @@ -524,12 +524,12 @@ real_t RigidBody2D::get_mass() const { void RigidBody2D::set_inertia(real_t p_inertia) { ERR_FAIL_COND(p_inertia < 0); - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_INERTIA, p_inertia); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, p_inertia); } real_t RigidBody2D::get_inertia() const { - return Physics2DServer::get_singleton()->body_get_param(get_rid(), Physics2DServer::BODY_PARAM_INERTIA); + return PhysicsServer2D::get_singleton()->body_get_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA); } void RigidBody2D::set_weight(real_t p_weight) { @@ -564,7 +564,7 @@ Ref<PhysicsMaterial> RigidBody2D::get_physics_material_override() const { void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) { gravity_scale = p_gravity_scale; - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); } real_t RigidBody2D::get_gravity_scale() const { @@ -575,7 +575,7 @@ void RigidBody2D::set_linear_damp(real_t p_linear_damp) { ERR_FAIL_COND(p_linear_damp < -1); linear_damp = p_linear_damp; - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_LINEAR_DAMP, linear_damp); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp); } real_t RigidBody2D::get_linear_damp() const { @@ -586,7 +586,7 @@ void RigidBody2D::set_angular_damp(real_t p_angular_damp) { ERR_FAIL_COND(p_angular_damp < -1); angular_damp = p_angular_damp; - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_ANGULAR_DAMP, angular_damp); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp); } real_t RigidBody2D::get_angular_damp() const { @@ -602,7 +602,7 @@ void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) { if (state) { set_linear_velocity(v); } else { - Physics2DServer::get_singleton()->body_set_axis_velocity(get_rid(), p_axis); + PhysicsServer2D::get_singleton()->body_set_axis_velocity(get_rid(), p_axis); linear_velocity = v; } } @@ -614,7 +614,7 @@ void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) { state->set_linear_velocity(linear_velocity); else { - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_LINEAR_VELOCITY, linear_velocity); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); } } @@ -629,7 +629,7 @@ void RigidBody2D::set_angular_velocity(real_t p_velocity) { if (state) state->set_angular_velocity(angular_velocity); else - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); } real_t RigidBody2D::get_angular_velocity() const { @@ -642,7 +642,7 @@ void RigidBody2D::set_use_custom_integrator(bool p_enable) { return; custom_integrator = p_enable; - Physics2DServer::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); + PhysicsServer2D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); } bool RigidBody2D::is_using_custom_integrator() { @@ -652,13 +652,13 @@ bool RigidBody2D::is_using_custom_integrator() { void RigidBody2D::set_sleeping(bool p_sleeping) { sleeping = p_sleeping; - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_SLEEPING, sleeping); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping); } void RigidBody2D::set_can_sleep(bool p_active) { can_sleep = p_active; - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_CAN_SLEEP, p_active); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active); } bool RigidBody2D::is_able_to_sleep() const { @@ -674,7 +674,7 @@ bool RigidBody2D::is_sleeping() const { void RigidBody2D::set_max_contacts_reported(int p_amount) { max_contacts_reported = p_amount; - Physics2DServer::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); + PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); } int RigidBody2D::get_max_contacts_reported() const { @@ -683,55 +683,55 @@ int RigidBody2D::get_max_contacts_reported() const { } void RigidBody2D::apply_central_impulse(const Vector2 &p_impulse) { - Physics2DServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); + PhysicsServer2D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); } void RigidBody2D::apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) { - Physics2DServer::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse); + PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse); } void RigidBody2D::apply_torque_impulse(float p_torque) { - Physics2DServer::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque); + PhysicsServer2D::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque); } void RigidBody2D::set_applied_force(const Vector2 &p_force) { - Physics2DServer::get_singleton()->body_set_applied_force(get_rid(), p_force); + PhysicsServer2D::get_singleton()->body_set_applied_force(get_rid(), p_force); }; Vector2 RigidBody2D::get_applied_force() const { - return Physics2DServer::get_singleton()->body_get_applied_force(get_rid()); + return PhysicsServer2D::get_singleton()->body_get_applied_force(get_rid()); }; void RigidBody2D::set_applied_torque(const float p_torque) { - Physics2DServer::get_singleton()->body_set_applied_torque(get_rid(), p_torque); + PhysicsServer2D::get_singleton()->body_set_applied_torque(get_rid(), p_torque); }; float RigidBody2D::get_applied_torque() const { - return Physics2DServer::get_singleton()->body_get_applied_torque(get_rid()); + return PhysicsServer2D::get_singleton()->body_get_applied_torque(get_rid()); }; void RigidBody2D::add_central_force(const Vector2 &p_force) { - Physics2DServer::get_singleton()->body_add_central_force(get_rid(), p_force); + PhysicsServer2D::get_singleton()->body_add_central_force(get_rid(), p_force); } void RigidBody2D::add_force(const Vector2 &p_offset, const Vector2 &p_force) { - Physics2DServer::get_singleton()->body_add_force(get_rid(), p_offset, p_force); + PhysicsServer2D::get_singleton()->body_add_force(get_rid(), p_offset, p_force); } void RigidBody2D::add_torque(const float p_torque) { - Physics2DServer::get_singleton()->body_add_torque(get_rid(), p_torque); + PhysicsServer2D::get_singleton()->body_add_torque(get_rid(), p_torque); } void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) { ccd_mode = p_mode; - Physics2DServer::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), Physics2DServer::CCDMode(p_mode)); + PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode)); } RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const { @@ -780,7 +780,7 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) { } memdelete(contact_monitor); - contact_monitor = NULL; + contact_monitor = nullptr; } else { contact_monitor = memnew(ContactMonitor); @@ -790,7 +790,7 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) { bool RigidBody2D::is_contact_monitor_enabled() const { - return contact_monitor != NULL; + return contact_monitor != nullptr; } void RigidBody2D::_notification(int p_what) { @@ -898,7 +898,7 @@ void RigidBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody2D::get_colliding_bodies); - BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "Physics2DDirectBodyState"))); + BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectBodyState2D"))); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass"); @@ -939,7 +939,7 @@ void RigidBody2D::_bind_methods() { } RigidBody2D::RigidBody2D() : - PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) { + PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) { mode = MODE_RIGID; @@ -950,17 +950,17 @@ RigidBody2D::RigidBody2D() : angular_damp = -1; max_contacts_reported = 0; - state = NULL; + state = nullptr; angular_velocity = 0; sleeping = false; ccd_mode = CCD_MODE_DISABLED; custom_integrator = false; - contact_monitor = NULL; + contact_monitor = nullptr; can_sleep = true; - Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } RigidBody2D::~RigidBody2D() { @@ -971,11 +971,11 @@ RigidBody2D::~RigidBody2D() { void RigidBody2D::_reload_physics_characteristics() { if (physics_material_override.is_null()) { - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, 0); - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, 1); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1); } else { - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); - Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); + PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); } } @@ -1001,12 +1001,12 @@ Ref<KinematicCollision2D> KinematicBody2D::_move(const Vector2 &p_motion, bool p bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) { - Physics2DServer::SeparationResult sep_res[8]; //max 8 rays + PhysicsServer2D::SeparationResult sep_res[8]; //max 8 rays Transform2D gt = get_global_transform(); Vector2 recover; - int hits = Physics2DServer::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin); + int hits = PhysicsServer2D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin); int deepest = -1; float deepest_depth; for (int i = 0; i < hits; i++) { @@ -1042,8 +1042,8 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_ ERR_PRINT("Functions move_and_slide and move_and_collide do not work together with 'sync to physics' option. Please read the documentation."); } Transform2D gt = get_global_transform(); - Physics2DServer::MotionResult result; - bool colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, margin, &result, p_exclude_raycast_shapes); + PhysicsServer2D::MotionResult result; + bool colliding = PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, margin, &result, p_exclude_raycast_shapes); if (colliding) { r_collision.collider_metadata = result.collider_metadata; @@ -1077,7 +1077,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 current_floor_velocity = floor_velocity; if (on_floor && on_floor_body.is_valid()) { //this approach makes sure there is less delay between the actual body velocity and the one we saved - Physics2DDirectBodyState *bs = Physics2DServer::get_singleton()->body_get_direct_state(on_floor_body); + PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(on_floor_body); if (bs) { current_floor_velocity = bs->get_linear_velocity(); } @@ -1227,7 +1227,7 @@ bool KinematicBody2D::test_move(const Transform2D &p_from, const Vector2 &p_moti ERR_FAIL_COND_V(!is_inside_tree(), false); - return Physics2DServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin); + return PhysicsServer2D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia, margin); } void KinematicBody2D::set_safe_margin(float p_margin) { @@ -1277,11 +1277,11 @@ void KinematicBody2D::set_sync_to_physics(bool p_enable) { return; if (p_enable) { - Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); set_only_update_transform_changes(true); set_notify_local_transform(true); } else { - Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, ""); + PhysicsServer2D::get_singleton()->body_set_force_integration_callback(get_rid(), nullptr, ""); set_only_update_transform_changes(false); set_notify_local_transform(false); } @@ -1296,7 +1296,7 @@ void KinematicBody2D::_direct_state_changed(Object *p_state) { if (!sync_to_physics) return; - Physics2DDirectBodyState *state = Object::cast_to<Physics2DDirectBodyState>(p_state); + PhysicsDirectBodyState2D *state = Object::cast_to<PhysicsDirectBodyState2D>(p_state); last_valid_transform = state->get_transform(); set_notify_local_transform(false); @@ -1320,7 +1320,7 @@ void KinematicBody2D::_notification(int p_what) { if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) { //used by sync to physics, send the new transform to the physics Transform2D new_transform = get_global_transform(); - Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_TRANSFORM, new_transform); + PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_TRANSFORM, new_transform); //but then revert changes set_notify_local_transform(false); set_global_transform(last_valid_transform); @@ -1357,7 +1357,7 @@ void KinematicBody2D::_bind_methods() { } KinematicBody2D::KinematicBody2D() : - PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC) { + PhysicsBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) { margin = 0.08; @@ -1368,12 +1368,12 @@ KinematicBody2D::KinematicBody2D() : } KinematicBody2D::~KinematicBody2D() { if (motion_cache.is_valid()) { - motion_cache->owner = NULL; + motion_cache->owner = nullptr; } for (int i = 0; i < slide_colliders.size(); i++) { if (slide_colliders[i].is_valid()) { - slide_colliders.write[i]->owner = NULL; + slide_colliders.write[i]->owner = nullptr; } } } @@ -1394,7 +1394,7 @@ Vector2 KinematicCollision2D::get_remainder() const { return collision.remainder; } Object *KinematicCollision2D::get_local_shape() const { - if (!owner) return NULL; + if (!owner) return nullptr; uint32_t ownerid = owner->shape_find_owner(collision.local_shape); return owner->shape_owner_get_owner(ownerid); } @@ -1405,7 +1405,7 @@ Object *KinematicCollision2D::get_collider() const { return ObjectDB::get_instance(collision.collider); } - return NULL; + return nullptr; } ObjectID KinematicCollision2D::get_collider_id() const { @@ -1422,7 +1422,7 @@ Object *KinematicCollision2D::get_collider_shape() const { } } - return NULL; + return nullptr; } int KinematicCollision2D::get_collider_shape_index() const { @@ -1468,5 +1468,5 @@ KinematicCollision2D::KinematicCollision2D() { collision.collider_shape = 0; collision.local_shape = 0; - owner = NULL; + owner = nullptr; } diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index eb7aefb495..0d92a820e3 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -34,7 +34,7 @@ #include "core/vset.h" #include "scene/2d/collision_object_2d.h" #include "scene/resources/physics_material.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" class KinematicCollision2D; @@ -50,7 +50,7 @@ class PhysicsBody2D : public CollisionObject2D { protected: void _notification(int p_what); - PhysicsBody2D(Physics2DServer::BodyMode p_mode); + PhysicsBody2D(PhysicsServer2D::BodyMode p_mode); static void _bind_methods(); @@ -123,7 +123,7 @@ public: private: bool can_sleep; - Physics2DDirectBodyState *state; + PhysicsDirectBodyState2D *state; Mode mode; real_t mass; @@ -185,7 +185,7 @@ private: void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape); void _direct_state_changed(Object *p_state); - bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>()); + bool _test_motion(const Vector2 &p_motion, bool p_infinite_inertia = true, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>()); protected: void _notification(int p_what); @@ -303,7 +303,7 @@ private: Vector<Ref<KinematicCollision2D>> slide_colliders; Ref<KinematicCollision2D> motion_cache; - _FORCE_INLINE_ bool _ignores_mode(Physics2DServer::BodyMode) const; + _FORCE_INLINE_ bool _ignores_mode(PhysicsServer2D::BodyMode) const; Ref<KinematicCollision2D> _move(const Vector2 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, bool p_test_only = false); Ref<KinematicCollision2D> _get_slide_collision(int p_bounce); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 95656b9610..84c1828b47 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -103,7 +103,7 @@ void Polygon2D::_notification(int p_what) { if (polygon.size() < 3) return; - Skeleton2D *skeleton_node = NULL; + Skeleton2D *skeleton_node = nullptr; if (has_node(skeleton)) { skeleton_node = Object::cast_to<Skeleton2D>(get_node(skeleton)); } @@ -111,10 +111,10 @@ void Polygon2D::_notification(int p_what) { ObjectID new_skeleton_id; if (skeleton_node) { - VS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), skeleton_node->get_skeleton()); + RS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), skeleton_node->get_skeleton()); new_skeleton_id = skeleton_node->get_instance_id(); } else { - VS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), RID()); + RS::get_singleton()->canvas_item_attach_skeleton(get_canvas_item(), RID()); } if (new_skeleton_id != current_skeleton_id) { @@ -307,7 +307,7 @@ void Polygon2D::_notification(int p_what) { if (invert || polygons.size() == 0) { Vector<int> indices = Geometry::triangulate_polygon(points); if (indices.size()) { - VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess)); + RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess)); } } else { //draw individual polygons @@ -341,7 +341,7 @@ void Polygon2D::_notification(int p_what) { } if (total_indices.size()) { - VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID()); + RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID()); } } diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index fd6e0aebcc..9d6c7304ce 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -33,7 +33,7 @@ #include "collision_object_2d.h" #include "core/engine.h" #include "physics_body_2d.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" void RayCast2D::set_cast_to(const Vector2 &p_point) { @@ -79,7 +79,7 @@ bool RayCast2D::is_colliding() const { Object *RayCast2D::get_collider() const { if (against.is_null()) - return NULL; + return nullptr; return ObjectDB::get_instance(against); } @@ -205,7 +205,7 @@ void RayCast2D::_update_raycast_state() { Ref<World2D> w2d = get_world_2d(); ERR_FAIL_COND(w2d.is_null()); - Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space()); + PhysicsDirectSpaceState2D *dss = PhysicsServer2D::get_singleton()->space_get_direct_state(w2d->get_space()); ERR_FAIL_COND(!dss); Transform2D gt = get_global_transform(); @@ -214,7 +214,7 @@ void RayCast2D::_update_raycast_state() { if (to == Vector2()) to = Vector2(0, 0.01); - Physics2DDirectSpaceState::RayResult rr; + PhysicsDirectSpaceState2D::RayResult rr; if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) { diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 9ebaf23c3a..86c9ff6076 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -35,7 +35,7 @@ void Bone2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { Node *parent = get_parent(); parent_bone = Object::cast_to<Bone2D>(parent); - skeleton = NULL; + skeleton = nullptr; while (parent) { skeleton = Object::cast_to<Skeleton2D>(parent); if (skeleton) @@ -73,9 +73,9 @@ void Bone2D::_notification(int p_what) { } } skeleton->_make_bone_setup_dirty(); - skeleton = NULL; + skeleton = nullptr; } - parent_bone = NULL; + parent_bone = nullptr; } } void Bone2D::_bind_methods() { @@ -157,8 +157,8 @@ String Bone2D::get_configuration_warning() const { } Bone2D::Bone2D() { - skeleton = NULL; - parent_bone = NULL; + skeleton = nullptr; + parent_bone = nullptr; skeleton_index = -1; default_length = 16; set_notify_local_transform(true); @@ -186,7 +186,7 @@ void Skeleton2D::_update_bone_setup() { return; bone_setup_dirty = false; - VS::get_singleton()->skeleton_allocate(skeleton, bones.size(), true); + RS::get_singleton()->skeleton_allocate(skeleton, bones.size(), true); bones.sort(); //sorty so they are always in the same order/index @@ -240,7 +240,7 @@ void Skeleton2D::_update_transform() { for (int i = 0; i < bones.size(); i++) { Transform2D final_xform = bones[i].accum_transform * bones[i].rest_inverse; - VS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform); + RS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform); } } @@ -257,8 +257,8 @@ int Skeleton2D::get_bone_count() const { Bone2D *Skeleton2D::get_bone(int p_idx) { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); - ERR_FAIL_INDEX_V(p_idx, bones.size(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); + ERR_FAIL_INDEX_V(p_idx, bones.size(), nullptr); return bones[p_idx].bone; } @@ -276,7 +276,7 @@ void Skeleton2D::_notification(int p_what) { } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - VS::get_singleton()->skeleton_set_base_transform_2d(skeleton, get_global_transform()); + RS::get_singleton()->skeleton_set_base_transform_2d(skeleton, get_global_transform()); } } @@ -300,11 +300,11 @@ Skeleton2D::Skeleton2D() { bone_setup_dirty = true; transform_dirty = true; - skeleton = VS::get_singleton()->skeleton_create(); + skeleton = RS::get_singleton()->skeleton_create(); set_notify_transform(true); } Skeleton2D::~Skeleton2D() { - VS::get_singleton()->free(skeleton); + RS::get_singleton()->free(skeleton); } diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp index d45fe9a2a5..df8859bd9a 100644 --- a/scene/2d/sprite_2d.cpp +++ b/scene/2d/sprite_2d.cpp @@ -131,7 +131,7 @@ void Sprite2D::_notification(int p_what) { Rect2 src_rect, dst_rect; bool filter_clip; _get_rects(src_rect, dst_rect, filter_clip); - texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess), VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, filter_clip); + texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, filter_clip); } break; } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 601be17274..1cf12e4421 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -35,8 +35,8 @@ #include "core/method_bind_ext.gen.inc" #include "core/os/os.h" #include "scene/2d/area_2d.h" -#include "servers/navigation_2d_server.h" -#include "servers/physics_2d_server.h" +#include "servers/navigation_server_2d.h" +#include "servers/physics_server_2d.h" int TileMap::_get_quadrant_size() const { @@ -87,7 +87,7 @@ void TileMap::_notification(int p_what) { if (navigation) { for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) { - Navigation2DServer::get_singleton()->region_set_map(F->get().region, RID()); + NavigationServer2D::get_singleton()->region_set_map(F->get().region, RID()); } q.navpoly_ids.clear(); } @@ -98,13 +98,13 @@ void TileMap::_notification(int p_what) { } for (Map<PosKey, Quadrant::Occluder>::Element *F = q.occluder_instances.front(); F; F = F->next()) { - VS::get_singleton()->free(F->get().id); + RS::get_singleton()->free(F->get().id); } q.occluder_instances.clear(); } - collision_parent = NULL; - navigation = NULL; + collision_parent = nullptr; + navigation = nullptr; } break; @@ -130,7 +130,7 @@ void TileMap::_update_quadrant_space(const RID &p_space) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); - Physics2DServer::get_singleton()->body_set_space(q.body, p_space); + PhysicsServer2D::get_singleton()->body_set_space(q.body, p_space); } } } @@ -158,18 +158,18 @@ void TileMap::_update_quadrant_transform() { if (!use_parent) { xform = global_transform * xform; - Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform); + PhysicsServer2D::get_singleton()->body_set_state(q.body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform); } if (navigation) { for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) { - Navigation2DServer::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform); + NavigationServer2D::get_singleton()->region_set_transform(F->get().region, nav_rel * F->get().xform); } } for (Map<PosKey, Quadrant::Occluder>::Element *F = q.occluder_instances.front(); F; F = F->next()) { - VS::get_singleton()->canvas_light_occluder_set_transform(F->get().id, global_transform * F->get().xform); + RS::get_singleton()->canvas_light_occluder_set_transform(F->get().id, global_transform * F->get().xform); } } } @@ -298,7 +298,7 @@ void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const } void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> &p_shape, const TileSet::ShapeData &p_shape_data, const Transform2D &p_xform, const Vector2 &p_metadata) { - Physics2DServer *ps = Physics2DServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); if (!use_parent) { ps->body_add_shape(p_q.body, p_shape->get_rid(), p_xform); @@ -314,7 +314,7 @@ void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> int real_index = collision_parent->shape_owner_get_shape_index(p_q.shape_owner_id, shape_idx); RID rid = collision_parent->get_rid(); - if (Object::cast_to<Area2D>(collision_parent) != NULL) { + if (Object::cast_to<Area2D>(collision_parent) != nullptr) { ps->area_set_shape_transform(rid, real_index, get_transform() * xform); } else { ps->body_set_shape_transform(rid, real_index, get_transform() * xform); @@ -334,8 +334,8 @@ void TileMap::update_dirty_quadrants() { return; } - VisualServer *vs = VisualServer::get_singleton(); - Physics2DServer *ps = Physics2DServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); + PhysicsServer2D *ps = PhysicsServer2D::get_singleton(); Vector2 tofs = get_cell_draw_offset(); Transform2D nav_rel; if (navigation) @@ -378,13 +378,13 @@ void TileMap::update_dirty_quadrants() { if (navigation) { for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) { - Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID()); + NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); } q.navpoly_ids.clear(); } for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) { - VS::get_singleton()->free(E->get().id); + RS::get_singleton()->free(E->get().id); } q.occluder_instances.clear(); Ref<ShaderMaterial> prev_material; @@ -439,7 +439,7 @@ void TileMap::update_dirty_quadrants() { debug_canvas_item = vs->canvas_item_create(); vs->canvas_item_set_parent(debug_canvas_item, canvas_item); vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item, false); - vs->canvas_item_set_z_index(debug_canvas_item, VS::CANVAS_ITEM_Z_MAX - 1); + vs->canvas_item_set_z_index(debug_canvas_item, RS::CANVAS_ITEM_Z_MAX - 1); q.canvas_items.push_back(debug_canvas_item); prev_debug_canvas_item = debug_canvas_item; } @@ -550,7 +550,7 @@ void TileMap::update_dirty_quadrants() { if (r == Rect2()) { tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map); } else { - tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, clip_uv); + tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, clip_uv); } Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id); @@ -612,10 +612,10 @@ void TileMap::update_dirty_quadrants() { xform.set_origin(offset.floor() + q.pos); _fix_cell_transform(xform, c, npoly_ofs, s); - RID region = Navigation2DServer::get_singleton()->region_create(); - Navigation2DServer::get_singleton()->region_set_map(region, navigation->get_rid()); - Navigation2DServer::get_singleton()->region_set_transform(region, nav_rel * xform); - Navigation2DServer::get_singleton()->region_set_navpoly(region, navpoly); + RID region = NavigationServer2D::get_singleton()->region_create(); + NavigationServer2D::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer2D::get_singleton()->region_set_transform(region, nav_rel * xform); + NavigationServer2D::get_singleton()->region_set_navpoly(region, navpoly); Quadrant::NavPoly np; np.region = region; @@ -626,7 +626,7 @@ void TileMap::update_dirty_quadrants() { RID debug_navigation_item = vs->canvas_item_create(); vs->canvas_item_set_parent(debug_navigation_item, canvas_item); vs->canvas_item_set_z_as_relative_to_parent(debug_navigation_item, false); - vs->canvas_item_set_z_index(debug_navigation_item, VS::CANVAS_ITEM_Z_MAX - 2); // Display one below collision debug + vs->canvas_item_set_z_index(debug_navigation_item, RS::CANVAS_ITEM_Z_MAX - 2); // Display one below collision debug if (debug_navigation_item.is_valid()) { Vector<Vector2> navigation_polygon_vertices = navpoly->get_vertices(); @@ -685,11 +685,11 @@ void TileMap::update_dirty_quadrants() { xform.set_origin(offset.floor() + q.pos); _fix_cell_transform(xform, c, occluder_ofs, s); - RID orid = VS::get_singleton()->canvas_light_occluder_create(); - VS::get_singleton()->canvas_light_occluder_set_transform(orid, get_global_transform() * xform); - VS::get_singleton()->canvas_light_occluder_set_polygon(orid, occluder->get_rid()); - VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid, get_canvas()); - VS::get_singleton()->canvas_light_occluder_set_light_mask(orid, occluder_light_mask); + RID orid = RS::get_singleton()->canvas_light_occluder_create(); + RS::get_singleton()->canvas_light_occluder_set_transform(orid, get_global_transform() * xform); + RS::get_singleton()->canvas_light_occluder_set_polygon(orid, occluder->get_rid()); + RS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid, get_canvas()); + RS::get_singleton()->canvas_light_occluder_set_light_mask(orid, occluder_light_mask); Quadrant::Occluder oc; oc.xform = xform; oc.id = orid; @@ -711,7 +711,7 @@ void TileMap::update_dirty_quadrants() { Quadrant &q = E->get(); for (List<RID>::Element *F = q.canvas_items.front(); F; F = F->next()) { - VS::get_singleton()->canvas_item_set_draw_index(F->get(), index++); + RS::get_singleton()->canvas_item_set_draw_index(F->get(), index++); } } @@ -763,24 +763,24 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons q.pos.y += cell_size.y; xform.set_origin(q.pos); - //q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); + //q.canvas_item = RenderingServer::get_singleton()->canvas_item_create(); if (!use_parent) { - q.body = Physics2DServer::get_singleton()->body_create(); - Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + q.body = PhysicsServer2D::get_singleton()->body_create(); + PhysicsServer2D::get_singleton()->body_set_mode(q.body, use_kinematic ? PhysicsServer2D::BODY_MODE_KINEMATIC : PhysicsServer2D::BODY_MODE_STATIC); - Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id()); - Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer); - Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask); - Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction); - Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce); + PhysicsServer2D::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id()); + PhysicsServer2D::get_singleton()->body_set_collision_layer(q.body, collision_layer); + PhysicsServer2D::get_singleton()->body_set_collision_mask(q.body, collision_mask); + PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_FRICTION, friction); + PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_BOUNCE, bounce); if (is_inside_tree()) { xform = get_global_transform() * xform; RID space = get_world_2d()->get_space(); - Physics2DServer::get_singleton()->body_set_space(q.body, space); + PhysicsServer2D::get_singleton()->body_set_space(q.body, space); } - Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform); + PhysicsServer2D::get_singleton()->body_set_state(q.body, PhysicsServer2D::BODY_STATE_TRANSFORM, xform); } else if (collision_parent) { xform = get_transform() * xform; q.shape_owner_id = collision_parent->create_shape_owner(this); @@ -797,14 +797,14 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) { Quadrant &q = Q->get(); if (!use_parent) { - Physics2DServer::get_singleton()->free(q.body); + PhysicsServer2D::get_singleton()->free(q.body); } else if (collision_parent) { collision_parent->remove_shape_owner(q.shape_owner_id); } for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { - VisualServer::get_singleton()->free(E->get()); + RenderingServer::get_singleton()->free(E->get()); } q.canvas_items.clear(); if (q.dirty_list.in_list()) @@ -813,13 +813,13 @@ void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) { if (navigation) { for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) { - Navigation2DServer::get_singleton()->region_set_map(E->get().region, RID()); + NavigationServer2D::get_singleton()->region_set_map(E->get().region, RID()); } q.navpoly_ids.clear(); } for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) { - VS::get_singleton()->free(E->get().id); + RS::get_singleton()->free(E->get().id); } q.occluder_instances.clear(); @@ -921,7 +921,7 @@ void TileMap::make_bitmask_area_dirty(const Vector2 &p_pos) { for (int x = p_pos.x - 1; x <= p_pos.x + 1; x++) { for (int y = p_pos.y - 1; y <= p_pos.y + 1; y++) { PosKey p(x, y); - if (dirty_bitmask.find(p) == NULL) { + if (dirty_bitmask.find(p) == nullptr) { dirty_bitmask.push_back(p); } } @@ -962,7 +962,7 @@ void TileMap::update_cell_bitmask(int p_x, int p_y) { ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot update cell bitmask if Tileset is not open."); PosKey p(p_x, p_y); Map<PosKey, Cell>::Element *E = tile_map.find(p); - if (E != NULL) { + if (E != nullptr) { int id = get_cell(p_x, p_y); if (tile_set->tile_get_tile_mode(id) == TileSet::AUTO_TILE) { uint16_t mask = 0; @@ -1197,7 +1197,7 @@ void TileMap::_update_all_items_material_state() { void TileMap::_update_item_material_state(const RID &p_canvas_item) { - VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid()); + RS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid()); } void TileMap::clear() { @@ -1302,7 +1302,7 @@ void TileMap::set_collision_layer(uint32_t p_layer) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); - Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer); + PhysicsServer2D::get_singleton()->body_set_collision_layer(q.body, collision_layer); } } } @@ -1314,7 +1314,7 @@ void TileMap::set_collision_mask(uint32_t p_mask) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); - Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask); + PhysicsServer2D::get_singleton()->body_set_collision_mask(q.body, collision_mask); } } } @@ -1368,7 +1368,7 @@ void TileMap::set_collision_use_parent(bool p_use_parent) { if (use_parent && is_inside_tree()) { collision_parent = Object::cast_to<CollisionObject2D>(get_parent()); } else { - collision_parent = NULL; + collision_parent = nullptr; } _recreate_quadrants(); @@ -1383,7 +1383,7 @@ void TileMap::set_collision_friction(float p_friction) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); - Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction); + PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_FRICTION, p_friction); } } } @@ -1400,7 +1400,7 @@ void TileMap::set_collision_bounce(float p_bounce) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { Quadrant &q = E->get(); - Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce); + PhysicsServer2D::get_singleton()->body_set_param(q.body, PhysicsServer2D::BODY_PARAM_BOUNCE, p_bounce); } } } @@ -1655,7 +1655,7 @@ void TileMap::set_y_sort_mode(bool p_enable) { _clear_quadrants(); y_sort_mode = p_enable; - VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), y_sort_mode); + RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), y_sort_mode); _recreate_quadrants(); emit_signal("settings_changed"); } @@ -1746,7 +1746,7 @@ void TileMap::set_occluder_light_mask(int p_mask) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { for (Map<PosKey, Quadrant::Occluder>::Element *F = E->get().occluder_instances.front(); F; F = F->next()) { - VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask); + RenderingServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask); } } } @@ -1762,7 +1762,7 @@ void TileMap::set_light_mask(int p_light_mask) { for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { for (List<RID>::Element *F = E->get().canvas_items.front(); F; F = F->next()) { - VisualServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask()); + RenderingServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask()); } } } @@ -1959,9 +1959,9 @@ TileMap::TileMap() { mode = MODE_SQUARE; half_offset = HALF_OFFSET_DISABLED; use_parent = false; - collision_parent = NULL; + collision_parent = nullptr; use_kinematic = false; - navigation = NULL; + navigation = nullptr; y_sort_mode = false; compatibility_mode = false; centered_textures = false; diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp index 62f10a5c96..15d97eeaa0 100644 --- a/scene/2d/y_sort.cpp +++ b/scene/2d/y_sort.cpp @@ -33,7 +33,7 @@ void YSort::set_sort_enabled(bool p_enabled) { sort_enabled = p_enabled; - VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled); + RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled); } bool YSort::is_sort_enabled() const { @@ -53,5 +53,5 @@ void YSort::_bind_methods() { YSort::YSort() { sort_enabled = true; - VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true); + RS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true); } diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 45b96bd9c4..ce69e8aa19 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -1,8 +1,8 @@ #!/usr/bin/env python -Import('env') +Import("env") -if env['disable_3d']: +if env["disable_3d"]: env.add_source_files(env.scene_sources, "node_3d.cpp") env.add_source_files(env.scene_sources, "skeleton_3d.cpp") else: diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp index beeaf7125a..17ae553e5e 100644 --- a/scene/3d/area_3d.cpp +++ b/scene/3d/area_3d.cpp @@ -32,12 +32,12 @@ #include "scene/scene_string_names.h" #include "servers/audio_server.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" void Area3D::set_space_override_mode(SpaceOverride p_mode) { space_override = p_mode; - PhysicsServer::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer::AreaSpaceOverrideMode(p_mode)); + PhysicsServer3D::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer3D::AreaSpaceOverrideMode(p_mode)); } Area3D::SpaceOverride Area3D::get_space_override_mode() const { @@ -47,7 +47,7 @@ Area3D::SpaceOverride Area3D::get_space_override_mode() const { void Area3D::set_gravity_is_point(bool p_enabled) { gravity_is_point = p_enabled; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT, p_enabled); } bool Area3D::is_gravity_a_point() const { @@ -57,7 +57,7 @@ bool Area3D::is_gravity_a_point() const { void Area3D::set_gravity_distance_scale(real_t p_scale) { gravity_distance_scale = p_scale; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale); } real_t Area3D::get_gravity_distance_scale() const { @@ -67,7 +67,7 @@ real_t Area3D::get_gravity_distance_scale() const { void Area3D::set_gravity_vector(const Vector3 &p_vec) { gravity_vec = p_vec; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_VECTOR, p_vec); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, p_vec); } Vector3 Area3D::get_gravity_vector() const { @@ -77,7 +77,7 @@ Vector3 Area3D::get_gravity_vector() const { void Area3D::set_gravity(real_t p_gravity) { gravity = p_gravity; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY, p_gravity); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_GRAVITY, p_gravity); } real_t Area3D::get_gravity() const { @@ -86,7 +86,7 @@ real_t Area3D::get_gravity() const { void Area3D::set_linear_damp(real_t p_linear_damp) { linear_damp = p_linear_damp; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, p_linear_damp); } real_t Area3D::get_linear_damp() const { @@ -96,7 +96,7 @@ real_t Area3D::get_linear_damp() const { void Area3D::set_angular_damp(real_t p_angular_damp) { angular_damp = p_angular_damp; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, p_angular_damp); } real_t Area3D::get_angular_damp() const { @@ -107,7 +107,7 @@ real_t Area3D::get_angular_damp() const { void Area3D::set_priority(real_t p_priority) { priority = p_priority; - PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_PRIORITY, p_priority); + PhysicsServer3D::get_singleton()->area_set_param(get_rid(), PhysicsServer3D::AREA_PARAM_PRIORITY, p_priority); } real_t Area3D::get_priority() const { @@ -150,7 +150,7 @@ void Area3D::_body_exit_tree(ObjectID p_id) { void Area3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape) { - bool body_in = p_status == PhysicsServer::AREA_BODY_ADDED; + bool body_in = p_status == PhysicsServer3D::AREA_BODY_ADDED; ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); @@ -298,11 +298,11 @@ void Area3D::set_monitoring(bool p_enable) { if (monitoring) { - PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); - PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); + PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout); + PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout); } else { - PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName()); - PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName()); + PhysicsServer3D::get_singleton()->area_set_monitor_callback(get_rid(), nullptr, StringName()); + PhysicsServer3D::get_singleton()->area_set_area_monitor_callback(get_rid(), nullptr, StringName()); _clear_monitoring(); } } @@ -343,7 +343,7 @@ void Area3D::_area_exit_tree(ObjectID p_id) { void Area3D::_area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape) { - bool area_in = p_status == PhysicsServer::AREA_BODY_ADDED; + bool area_in = p_status == PhysicsServer3D::AREA_BODY_ADDED; ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); @@ -436,14 +436,14 @@ Array Area3D::get_overlapping_bodies() const { void Area3D::set_monitorable(bool p_enable) { - ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); + ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false)."); if (p_enable == monitorable) return; monitorable = p_enable; - PhysicsServer::get_singleton()->area_set_monitorable(get_rid(), monitorable); + PhysicsServer3D::get_singleton()->area_set_monitorable(get_rid(), monitorable); } bool Area3D::is_monitorable() const { @@ -489,7 +489,7 @@ bool Area3D::overlaps_body(Node *p_body) const { void Area3D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; - PhysicsServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask); + PhysicsServer3D::get_singleton()->area_set_collision_mask(get_rid(), p_mask); } uint32_t Area3D::get_collision_mask() const { @@ -499,7 +499,7 @@ uint32_t Area3D::get_collision_mask() const { void Area3D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; - PhysicsServer::get_singleton()->area_set_collision_layer(get_rid(), p_layer); + PhysicsServer3D::get_singleton()->area_set_collision_layer(get_rid(), p_layer); } uint32_t Area3D::get_collision_layer() const { @@ -728,7 +728,7 @@ void Area3D::_bind_methods() { } Area3D::Area3D() : - CollisionObject3D(PhysicsServer::get_singleton()->area_create(), true) { + CollisionObject3D(PhysicsServer3D::get_singleton()->area_create(), true) { space_override = SPACE_OVERRIDE_DISABLED; set_gravity(9.8); diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index ce7c885a40..537c094ceb 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -40,14 +40,14 @@ void ARVRCamera::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { // need to find our ARVROrigin parent and let it know we're its camera! ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin != NULL) { + if (origin != nullptr) { origin->set_tracked_camera(this); } }; break; case NOTIFICATION_EXIT_TREE: { // need to find our ARVROrigin parent and let it know we're no longer its camera! ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin != NULL) { + if (origin != nullptr) { origin->clear_tracked_camera_if(this); } }; break; @@ -60,7 +60,7 @@ String ARVRCamera::get_configuration_warning() const { // must be child node of ARVROrigin! ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin == NULL) { + if (origin == nullptr) { return TTR("ARVRCamera must have an ARVROrigin node as its parent."); }; @@ -192,7 +192,7 @@ void ARVRController::_notification(int p_what) { // find the tracker for our controller ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + if (tracker == nullptr) { // this controller is currently turned off is_active = false; button_states = 0; @@ -279,7 +279,7 @@ String ARVRController::get_controller_name(void) const { ERR_FAIL_NULL_V(arvr_server, String()); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + if (tracker == nullptr) { return String("Not connected"); }; @@ -292,7 +292,7 @@ int ARVRController::get_joystick_id() const { ERR_FAIL_NULL_V(arvr_server, 0); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + if (tracker == nullptr) { // No tracker? no joystick id... (0 is our first joystick) return -1; }; @@ -324,7 +324,7 @@ real_t ARVRController::get_rumble() const { ERR_FAIL_NULL_V(arvr_server, 0.0); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + if (tracker == nullptr) { return 0.0; }; @@ -337,7 +337,7 @@ void ARVRController::set_rumble(real_t p_rumble) { ERR_FAIL_NULL(arvr_server); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker != NULL) { + if (tracker != nullptr) { tracker->set_rumble(p_rumble); }; }; @@ -356,7 +356,7 @@ ARVRPositionalTracker::TrackerHand ARVRController::get_hand() const { ERR_FAIL_NULL_V(arvr_server, ARVRPositionalTracker::TRACKER_HAND_UNKNOWN); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id); - if (tracker == NULL) { + if (tracker == nullptr) { return ARVRPositionalTracker::TRACKER_HAND_UNKNOWN; }; @@ -369,7 +369,7 @@ String ARVRController::get_configuration_warning() const { // must be child node of ARVROrigin! ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin == NULL) { + if (origin == nullptr) { return TTR("ARVRController must have an ARVROrigin node as its parent."); }; @@ -407,7 +407,7 @@ void ARVRAnchor::_notification(int p_what) { // find the tracker for our anchor ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id); - if (tracker == NULL) { + if (tracker == nullptr) { // this anchor is currently not available is_active = false; } else { @@ -479,7 +479,7 @@ String ARVRAnchor::get_anchor_name(void) const { ERR_FAIL_NULL_V(arvr_server, String()); ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id); - if (tracker == NULL) { + if (tracker == nullptr) { return String("Not connected"); }; @@ -496,7 +496,7 @@ String ARVRAnchor::get_configuration_warning() const { // must be child node of ARVROrigin! ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent()); - if (origin == NULL) { + if (origin == nullptr) { return TTR("ARVRAnchor must have an ARVROrigin node as its parent."); }; @@ -535,7 +535,7 @@ String ARVROrigin::get_configuration_warning() const { if (!is_visible() || !is_inside_tree()) return String(); - if (tracked_camera == NULL) + if (tracked_camera == nullptr) return TTR("ARVROrigin requires an ARVRCamera child node."); return String(); @@ -553,7 +553,7 @@ void ARVROrigin::set_tracked_camera(ARVRCamera *p_tracked_camera) { void ARVROrigin::clear_tracked_camera_if(ARVRCamera *p_tracked_camera) { if (tracked_camera == p_tracked_camera) { - tracked_camera = NULL; + tracked_camera = nullptr; }; }; @@ -591,7 +591,7 @@ void ARVROrigin::_notification(int p_what) { // check if we have a primary interface Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); - if (arvr_interface.is_valid() && tracked_camera != NULL) { + if (arvr_interface.is_valid() && tracked_camera != nullptr) { // get our positioning transform for our headset Transform t = arvr_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform()); @@ -613,7 +613,7 @@ void ARVROrigin::_notification(int p_what) { }; ARVROrigin::ARVROrigin() { - tracked_camera = NULL; + tracked_camera = nullptr; }; ARVROrigin::~ARVROrigin(){ diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 807515219f..097368853e 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "audio_stream_player_3d.h" + #include "core/engine.h" #include "scene/3d/area_3d.h" #include "scene/3d/camera_3d.h" @@ -96,7 +97,7 @@ static const Vector3 speaker_directions[7] = { }; void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tightness, AudioStreamPlayer3D::Output &output) { - unsigned int speaker_count; // only main speakers (no LFE) + unsigned int speaker_count = 0; // only main speakers (no LFE) switch (AudioServer::get_singleton()->get_speaker_mode()) { case AudioServer::SPEAKER_MODE_STEREO: speaker_count = 2; @@ -395,12 +396,12 @@ void AudioStreamPlayer3D::_notification(int p_what) { //check if any area is diverting sound into a bus - PhysicsDirectSpaceState *space_state = PhysicsServer::get_singleton()->space_get_direct_state(world->get_space()); + PhysicsDirectSpaceState3D *space_state = PhysicsServer3D::get_singleton()->space_get_direct_state(world->get_space()); - PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS]; + PhysicsDirectSpaceState3D::ShapeResult sr[MAX_INTERSECT_AREAS]; int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask, false, true); - Area3D *area = NULL; + Area3D *area = nullptr; for (int i = 0; i < areas; i++) { if (!sr[i].collider) diff --git a/scene/3d/audio_stream_player_3d.h b/scene/3d/audio_stream_player_3d.h index 1cce0c77d5..13e08339e2 100644 --- a/scene/3d/audio_stream_player_3d.h +++ b/scene/3d/audio_stream_player_3d.h @@ -82,7 +82,7 @@ private: Output() { filter_gain = 0; - viewport = NULL; + viewport = nullptr; reverb_bus_index = -1; bus_index = -1; } diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 73b1d450f0..6bde56104e 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -39,7 +39,7 @@ void BakedLightmapData::set_bounds(const AABB &p_bounds) { bounds = p_bounds; - VS::get_singleton()->lightmap_capture_set_bounds(baked_light, p_bounds); + RS::get_singleton()->lightmap_capture_set_bounds(baked_light, p_bounds); } AABB BakedLightmapData::get_bounds() const { @@ -49,18 +49,18 @@ AABB BakedLightmapData::get_bounds() const { void BakedLightmapData::set_octree(const Vector<uint8_t> &p_octree) { - VS::get_singleton()->lightmap_capture_set_octree(baked_light, p_octree); + RS::get_singleton()->lightmap_capture_set_octree(baked_light, p_octree); } Vector<uint8_t> BakedLightmapData::get_octree() const { - return VS::get_singleton()->lightmap_capture_get_octree(baked_light); + return RS::get_singleton()->lightmap_capture_get_octree(baked_light); } void BakedLightmapData::set_cell_space_transform(const Transform &p_xform) { cell_space_xform = p_xform; - VS::get_singleton()->lightmap_capture_set_octree_cell_transform(baked_light, p_xform); + RS::get_singleton()->lightmap_capture_set_octree_cell_transform(baked_light, p_xform); } Transform BakedLightmapData::get_cell_space_transform() const { @@ -69,7 +69,7 @@ Transform BakedLightmapData::get_cell_space_transform() const { void BakedLightmapData::set_cell_subdiv(int p_cell_subdiv) { cell_subdiv = p_cell_subdiv; - VS::get_singleton()->lightmap_capture_set_octree_cell_subdiv(baked_light, p_cell_subdiv); + RS::get_singleton()->lightmap_capture_set_octree_cell_subdiv(baked_light, p_cell_subdiv); } int BakedLightmapData::get_cell_subdiv() const { @@ -79,7 +79,7 @@ int BakedLightmapData::get_cell_subdiv() const { void BakedLightmapData::set_energy(float p_energy) { energy = p_energy; - VS::get_singleton()->lightmap_capture_set_energy(baked_light, energy); + RS::get_singleton()->lightmap_capture_set_energy(baked_light, energy); } float BakedLightmapData::get_energy() const { @@ -181,21 +181,21 @@ void BakedLightmapData::_bind_methods() { BakedLightmapData::BakedLightmapData() { - baked_light = VS::get_singleton()->lightmap_capture_create(); + baked_light = RS::get_singleton()->lightmap_capture_create(); energy = 1; cell_subdiv = 1; } BakedLightmapData::~BakedLightmapData() { - VS::get_singleton()->free(baked_light); + RS::get_singleton()->free(baked_light); } /////////////////////////// -BakedLightmap::BakeBeginFunc BakedLightmap::bake_begin_function = NULL; -BakedLightmap::BakeStepFunc BakedLightmap::bake_step_function = NULL; -BakedLightmap::BakeEndFunc BakedLightmap::bake_end_function = NULL; +BakedLightmap::BakeBeginFunc BakedLightmap::bake_begin_function = nullptr; +BakedLightmap::BakeStepFunc BakedLightmap::bake_step_function = nullptr; +BakedLightmap::BakeEndFunc BakedLightmap::bake_end_function = nullptr; void BakedLightmap::set_bake_cell_size(float p_cell_size) { bake_cell_size = p_cell_size; @@ -425,13 +425,13 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi pmc++; PlotLight pl = E->get(); switch (pl.light->get_light_type()) { - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { baker.plot_light_directional(-pl.local_xform.basis.get_axis(2), pl.light->get_color(), pl.light->get_param(Light::PARAM_ENERGY), pl.light->get_param(Light::PARAM_INDIRECT_ENERGY), pl.light->get_bake_mode() == Light::BAKE_ALL); } break; - case VS::LIGHT_OMNI: { + case RS::LIGHT_OMNI: { baker.plot_light_omni(pl.local_xform.origin, pl.light->get_color(), pl.light->get_param(Light::PARAM_ENERGY), pl.light->get_param(Light::PARAM_INDIRECT_ENERGY), pl.light->get_param(Light::PARAM_RANGE), pl.light->get_param(Light::PARAM_ATTENUATION), pl.light->get_bake_mode() == Light::BAKE_ALL); } break; - case VS::LIGHT_SPOT: { + case RS::LIGHT_SPOT: { baker.plot_light_spot(pl.local_xform.origin, pl.local_xform.basis.get_axis(2), pl.light->get_color(), pl.light->get_param(Light::PARAM_ENERGY), pl.light->get_param(Light::PARAM_INDIRECT_ENERGY), pl.light->get_param(Light::PARAM_RANGE), pl.light->get_param(Light::PARAM_ATTENUATION), pl.light->get_param(Light::PARAM_SPOT_ANGLE), pl.light->get_param(Light::PARAM_SPOT_ATTENUATION), pl.light->get_bake_mode() == Light::BAKE_ALL); } break; @@ -675,12 +675,12 @@ void BakedLightmap::_assign_lightmaps() { if (instance_idx >= 0) { RID instance = node->call("get_bake_mesh_instance", instance_idx); if (instance.is_valid()) { - VS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), lightmap->get_rid()); + RS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), lightmap->get_rid()); } } else { VisualInstance *vi = Object::cast_to<VisualInstance>(node); ERR_CONTINUE(!vi); - VS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), lightmap->get_rid()); + RS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), lightmap->get_rid()); } } } @@ -693,12 +693,12 @@ void BakedLightmap::_clear_lightmaps() { if (instance_idx >= 0) { RID instance = node->call("get_bake_mesh_instance", instance_idx); if (instance.is_valid()) { - VS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), RID()); + RS::get_singleton()->instance_set_use_lightmap(instance, get_instance(), RID()); } } else { VisualInstance *vi = Object::cast_to<VisualInstance>(node); ERR_CONTINUE(!vi); - VS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), RID()); + RS::get_singleton()->instance_set_use_lightmap(vi->get_instance(), get_instance(), RID()); } } } diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index 60cccbeedd..706c49b43b 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -82,7 +82,7 @@ void Camera3D::_update_camera() { if (!is_inside_tree()) return; - VisualServer::get_singleton()->camera_set_transform(camera, get_camera_transform()); + RenderingServer::get_singleton()->camera_set_transform(camera, get_camera_transform()); // here goes listener stuff /* @@ -138,7 +138,7 @@ void Camera3D::_notification(int p_what) { if (viewport) { viewport->_camera_remove(this); - viewport = NULL; + viewport = nullptr; } } break; @@ -173,7 +173,7 @@ void Camera3D::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_f far = p_z_far; mode = PROJECTION_PERSPECTIVE; - VisualServer::get_singleton()->camera_set_perspective(camera, fov, near, far); + RenderingServer::get_singleton()->camera_set_perspective(camera, fov, near, far); update_gizmo(); force_change = false; } @@ -189,7 +189,7 @@ void Camera3D::set_orthogonal(float p_size, float p_z_near, float p_z_far) { mode = PROJECTION_ORTHOGONAL; force_change = false; - VisualServer::get_singleton()->camera_set_orthogonal(camera, size, near, far); + RenderingServer::get_singleton()->camera_set_orthogonal(camera, size, near, far); update_gizmo(); } @@ -205,7 +205,7 @@ void Camera3D::set_frustum(float p_size, Vector2 p_offset, float p_z_near, float mode = PROJECTION_FRUSTUM; force_change = false; - VisualServer::get_singleton()->camera_set_frustum(camera, size, frustum_offset, near, far); + RenderingServer::get_singleton()->camera_set_frustum(camera, size, frustum_offset, near, far); update_gizmo(); } @@ -241,7 +241,7 @@ void Camera3D::clear_current(bool p_enable_next) { return; if (get_viewport()->get_camera() == this) { - get_viewport()->_camera_set(NULL); + get_viewport()->_camera_set(nullptr); if (p_enable_next) { get_viewport()->_camera_make_next_current(this); @@ -413,30 +413,13 @@ Vector3 Camera3D::project_position(const Point2 &p_point, float p_z_depth) const return get_camera_transform().xform(p); } -/* -void Camera::_camera_make_current(Node *p_camera) { - - - if (p_camera==this) { - VisualServer::get_singleton()->viewport_attach_camera(viewport_id,camera); - active=true; - } else { - if (active && p_camera==NULL) { - //detech camera because no one else will claim it - VisualServer::get_singleton()->viewport_attach_camera(viewport_id,RID()); - } - active=false; - } -} -*/ - void Camera3D::set_environment(const Ref<Environment> &p_environment) { environment = p_environment; if (environment.is_valid()) - VS::get_singleton()->camera_set_environment(camera, environment->get_rid()); + RS::get_singleton()->camera_set_environment(camera, environment->get_rid()); else - VS::get_singleton()->camera_set_environment(camera, RID()); + RS::get_singleton()->camera_set_environment(camera, RID()); _update_camera_mode(); } @@ -449,9 +432,9 @@ void Camera3D::set_effects(const Ref<CameraEffects> &p_effects) { effects = p_effects; if (effects.is_valid()) - VS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid()); + RS::get_singleton()->camera_set_camera_effects(camera, effects->get_rid()); else - VS::get_singleton()->camera_set_camera_effects(camera, RID()); + RS::get_singleton()->camera_set_camera_effects(camera, RID()); _update_camera_mode(); } @@ -462,7 +445,7 @@ Ref<CameraEffects> Camera3D::get_effects() const { void Camera3D::set_keep_aspect_mode(KeepAspect p_aspect) { keep_aspect = p_aspect; - VisualServer::get_singleton()->camera_set_use_vertical_aspect(camera, p_aspect == KEEP_WIDTH); + RenderingServer::get_singleton()->camera_set_use_vertical_aspect(camera, p_aspect == KEEP_WIDTH); _update_camera_mode(); _change_notify(); } @@ -628,7 +611,7 @@ void Camera3D::set_zfar(float p_zfar) { void Camera3D::set_cull_mask(uint32_t p_layers) { layers = p_layers; - VisualServer::get_singleton()->camera_set_cull_mask(camera, layers); + RenderingServer::get_singleton()->camera_set_cull_mask(camera, layers); _update_camera_mode(); } @@ -696,14 +679,14 @@ Vector3 Camera3D::get_doppler_tracked_velocity() const { } Camera3D::Camera3D() { - camera = VisualServer::get_singleton()->camera_create(); + camera = RenderingServer::get_singleton()->camera_create(); size = 1; fov = 0; frustum_offset = Vector2(); near = 0; far = 0; current = false; - viewport = NULL; + viewport = nullptr; force_change = false; mode = PROJECTION_PERSPECTIVE; set_perspective(70.0, 0.05, 100.0); @@ -711,7 +694,7 @@ Camera3D::Camera3D() { layers = 0xfffff; v_offset = 0; h_offset = 0; - VisualServer::get_singleton()->camera_set_cull_mask(camera, layers); + RenderingServer::get_singleton()->camera_set_cull_mask(camera, layers); //active=false; velocity_tracker.instance(); doppler_tracking = DOPPLER_TRACKING_DISABLED; @@ -721,7 +704,7 @@ Camera3D::Camera3D() { Camera3D::~Camera3D() { - VisualServer::get_singleton()->free(camera); + RenderingServer::get_singleton()->free(camera); } //////////////////////////////////////// @@ -760,7 +743,7 @@ void ClippedCamera3D::_notification(int p_what) { return; } - PhysicsDirectSpaceState *dspace = get_world()->get_direct_space_state(); + PhysicsDirectSpaceState3D *dspace = get_world()->get_direct_space_state(); ERR_FAIL_COND(!dspace); // most likely physics set to threads Vector3 cam_fw = -get_global_transform().basis.get_axis(Vector3::AXIS_Z).normalized(); @@ -791,7 +774,7 @@ void ClippedCamera3D::_notification(int p_what) { } if (!all_equal) { - PhysicsServer::get_singleton()->shape_set_data(pyramid_shape, local_points); + PhysicsServer3D::get_singleton()->shape_set_data(pyramid_shape, local_points); points = local_points; } } @@ -945,10 +928,10 @@ ClippedCamera3D::ClippedCamera3D() { collision_mask = 1; set_notify_local_transform(Engine::get_singleton()->is_editor_hint()); points.resize(5); - pyramid_shape = PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON); + pyramid_shape = PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON); clip_to_areas = false; clip_to_bodies = true; } ClippedCamera3D::~ClippedCamera3D() { - PhysicsServer::get_singleton()->free(pyramid_shape); + PhysicsServer3D::get_singleton()->free(pyramid_shape); } diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 9ae7371b6a..e6cd7bfe7e 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -31,7 +31,7 @@ #include "collision_object_3d.h" #include "scene/scene_string_names.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" void CollisionObject3D::_notification(int p_what) { @@ -40,15 +40,15 @@ void CollisionObject3D::_notification(int p_what) { case NOTIFICATION_ENTER_WORLD: { if (area) - PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform()); + PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform()); else - PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); RID space = get_world()->get_space(); if (area) { - PhysicsServer::get_singleton()->area_set_space(rid, space); + PhysicsServer3D::get_singleton()->area_set_space(rid, space); } else - PhysicsServer::get_singleton()->body_set_space(rid, space); + PhysicsServer3D::get_singleton()->body_set_space(rid, space); _update_pickable(); //get space @@ -57,9 +57,9 @@ void CollisionObject3D::_notification(int p_what) { case NOTIFICATION_TRANSFORM_CHANGED: { if (area) - PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform()); + PhysicsServer3D::get_singleton()->area_set_transform(rid, get_global_transform()); else - PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer3D::get_singleton()->body_set_state(rid, PhysicsServer3D::BODY_STATE_TRANSFORM, get_global_transform()); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -70,9 +70,9 @@ void CollisionObject3D::_notification(int p_what) { case NOTIFICATION_EXIT_WORLD: { if (area) { - PhysicsServer::get_singleton()->area_set_space(rid, RID()); + PhysicsServer3D::get_singleton()->area_set_space(rid, RID()); } else - PhysicsServer::get_singleton()->body_set_space(rid, RID()); + PhysicsServer3D::get_singleton()->body_set_space(rid, RID()); } break; } @@ -108,9 +108,9 @@ void CollisionObject3D::_update_pickable() { bool pickable = ray_pickable && is_visible_in_tree(); if (area) - PhysicsServer::get_singleton()->area_set_ray_pickable(rid, pickable); + PhysicsServer3D::get_singleton()->area_set_ray_pickable(rid, pickable); else - PhysicsServer::get_singleton()->body_set_ray_pickable(rid, pickable); + PhysicsServer3D::get_singleton()->body_set_ray_pickable(rid, pickable); } void CollisionObject3D::set_ray_pickable(bool p_ray_pickable) { @@ -191,9 +191,9 @@ void CollisionObject3D::shape_owner_set_disabled(uint32_t p_owner, bool p_disabl sd.disabled = p_disabled; for (int i = 0; i < sd.shapes.size(); i++) { if (area) { - PhysicsServer::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); + PhysicsServer3D::get_singleton()->area_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); } else { - PhysicsServer::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); + PhysicsServer3D::get_singleton()->body_set_shape_disabled(rid, sd.shapes[i].index, p_disabled); } } } @@ -230,9 +230,9 @@ void CollisionObject3D::shape_owner_set_transform(uint32_t p_owner, const Transf sd.xform = p_transform; for (int i = 0; i < sd.shapes.size(); i++) { if (area) { - PhysicsServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform); + PhysicsServer3D::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform); } else { - PhysicsServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform); + PhysicsServer3D::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform); } } } @@ -245,7 +245,7 @@ Transform CollisionObject3D::shape_owner_get_transform(uint32_t p_owner) const { Object *CollisionObject3D::shape_owner_get_owner(uint32_t p_owner) const { - ERR_FAIL_COND_V(!shapes.has(p_owner), NULL); + ERR_FAIL_COND_V(!shapes.has(p_owner), nullptr); return shapes[p_owner].owner; } @@ -260,9 +260,9 @@ void CollisionObject3D::shape_owner_add_shape(uint32_t p_owner, const Ref<Shape3 s.index = total_subshapes; s.shape = p_shape; if (area) { - PhysicsServer::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); + PhysicsServer3D::get_singleton()->area_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); } else { - PhysicsServer::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); + PhysicsServer3D::get_singleton()->body_add_shape(rid, p_shape->get_rid(), sd.xform, sd.disabled); } sd.shapes.push_back(s); @@ -296,9 +296,9 @@ void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) int index_to_remove = shapes[p_owner].shapes[p_shape].index; if (area) { - PhysicsServer::get_singleton()->area_remove_shape(rid, index_to_remove); + PhysicsServer3D::get_singleton()->area_remove_shape(rid, index_to_remove); } else { - PhysicsServer::get_singleton()->body_remove_shape(rid, index_to_remove); + PhysicsServer3D::get_singleton()->body_remove_shape(rid, index_to_remove); } shapes[p_owner].shapes.remove(p_shape); @@ -349,9 +349,9 @@ CollisionObject3D::CollisionObject3D(RID p_rid, bool p_area) { total_subshapes = 0; if (p_area) { - PhysicsServer::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); + PhysicsServer3D::get_singleton()->area_attach_object_instance_id(rid, get_instance_id()); } else { - PhysicsServer::get_singleton()->body_attach_object_instance_id(rid, get_instance_id()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(rid, get_instance_id()); } //set_transform_notify(true); } @@ -374,7 +374,7 @@ String CollisionObject3D::get_configuration_warning() const { if (!warning.empty()) { warning += "\n\n"; } - warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape or CollisionPolygon as a child to define its shape."); + warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape3D or CollisionPolygon3D as a child to define its shape."); } return warning; @@ -392,5 +392,5 @@ CollisionObject3D::CollisionObject3D() { CollisionObject3D::~CollisionObject3D() { - PhysicsServer::get_singleton()->free(rid); + PhysicsServer3D::get_singleton()->free(rid); } diff --git a/scene/3d/collision_object_3d.h b/scene/3d/collision_object_3d.h index 6a70f56caa..67d3aed3c8 100644 --- a/scene/3d/collision_object_3d.h +++ b/scene/3d/collision_object_3d.h @@ -56,7 +56,7 @@ class CollisionObject3D : public Node3D { ShapeData() { disabled = false; - owner = NULL; + owner = nullptr; } }; diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index c8b1b728bc..66bd903eeb 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -112,7 +112,7 @@ void CollisionPolygon3D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; } } @@ -165,11 +165,11 @@ bool CollisionPolygon3D::is_disabled() const { String CollisionPolygon3D::get_configuration_warning() const { if (!Object::cast_to<CollisionObject3D>(get_parent())) { - return TTR("CollisionPolygon only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape."); + return TTR("CollisionPolygon3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape."); } if (polygon.empty()) { - return TTR("An empty CollisionPolygon has no effect on collision."); + return TTR("An empty CollisionPolygon3D has no effect on collision."); } return String(); @@ -201,7 +201,7 @@ CollisionPolygon3D::CollisionPolygon3D() { aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); depth = 1.0; set_notify_local_transform(true); - parent = NULL; + parent = nullptr; owner_id = 0; disabled = false; } diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index eab09883cd..a66e84ac3c 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -29,6 +29,10 @@ /*************************************************************************/ #include "collision_shape_3d.h" + +#include "core/math/quick_hull.h" +#include "mesh_instance_3d.h" +#include "physics_body_3d.h" #include "scene/resources/box_shape_3d.h" #include "scene/resources/capsule_shape_3d.h" #include "scene/resources/concave_polygon_shape_3d.h" @@ -36,11 +40,9 @@ #include "scene/resources/ray_shape_3d.h" #include "scene/resources/sphere_shape_3d.h" #include "scene/resources/world_margin_shape_3d.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" + //TODO: Implement CylinderShape and HeightMapShape? -#include "core/math/quick_hull.h" -#include "mesh_instance_3d.h" -#include "physics_body_3d.h" void CollisionShape3D::make_convex_from_brothers() { @@ -103,7 +105,7 @@ void CollisionShape3D::_notification(int p_what) { parent->remove_shape_owner(owner_id); } owner_id = 0; - parent = NULL; + parent = nullptr; } break; } } @@ -116,17 +118,17 @@ void CollisionShape3D::resource_changed(RES res) { String CollisionShape3D::get_configuration_warning() const { if (!Object::cast_to<CollisionObject3D>(get_parent())) { - return TTR("CollisionShape only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape."); + return TTR("CollisionShape3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, KinematicBody3D, etc. to give them a shape."); } if (!shape.is_valid()) { - return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it."); + return TTR("A shape must be provided for CollisionShape3D to function. Please create a shape resource for it."); } if (Object::cast_to<RigidBody3D>(get_parent())) { if (Object::cast_to<ConcavePolygonShape3D>(*shape)) { if (Object::cast_to<RigidBody3D>(get_parent())->get_mode() != RigidBody3D::MODE_STATIC) { - return TTR("ConcavePolygonShape doesn't support RigidBody in another mode than static."); + return TTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static."); } } } @@ -196,10 +198,10 @@ bool CollisionShape3D::is_disabled() const { CollisionShape3D::CollisionShape3D() { - //indicator = VisualServer::get_singleton()->mesh_create(); + //indicator = RenderingServer::get_singleton()->mesh_create(); disabled = false; - debug_shape = NULL; - parent = NULL; + debug_shape = nullptr; + parent = nullptr; owner_id = 0; set_notify_local_transform(true); } @@ -207,7 +209,7 @@ CollisionShape3D::CollisionShape3D() { CollisionShape3D::~CollisionShape3D() { if (!shape.is_null()) shape->unregister_owner(this); - //VisualServer::get_singleton()->free(indicator); + //RenderingServer::get_singleton()->free(indicator); } void CollisionShape3D::_update_debug_shape() { @@ -215,7 +217,7 @@ void CollisionShape3D::_update_debug_shape() { if (debug_shape) { debug_shape->queue_delete(); - debug_shape = NULL; + debug_shape = nullptr; } Ref<Shape3D> s = get_shape(); diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 71e869e6e9..12c105b0f4 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -33,7 +33,7 @@ #include "scene/3d/camera_3d.h" #include "scene/3d/gpu_particles_3d.h" #include "scene/resources/particles_material.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" AABB CPUParticles3D::get_aabb() const { @@ -73,7 +73,7 @@ void CPUParticles3D::set_amount(int p_amount) { } particle_data.resize((12 + 4 + 4) * p_amount); - VS::get_singleton()->multimesh_allocate(multimesh, p_amount, VS::MULTIMESH_TRANSFORM_3D, true, true); + RS::get_singleton()->multimesh_allocate(multimesh, p_amount, RS::MULTIMESH_TRANSFORM_3D, true, true); particle_order.resize(p_amount); } @@ -171,9 +171,9 @@ void CPUParticles3D::set_mesh(const Ref<Mesh> &p_mesh) { mesh = p_mesh; if (mesh.is_valid()) { - VS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid()); + RS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid()); } else { - VS::get_singleton()->multimesh_set_mesh(multimesh, RID()); + RS::get_singleton()->multimesh_set_mesh(multimesh, RID()); } } @@ -208,13 +208,13 @@ String CPUParticles3D::get_configuration_warning() const { if (get_mesh().is_valid()) { mesh_found = true; for (int j = 0; j < get_mesh()->get_surface_count(); j++) { - anim_material_found = Object::cast_to<ShaderMaterial>(get_mesh()->surface_get_material(j).ptr()) != NULL; + anim_material_found = Object::cast_to<ShaderMaterial>(get_mesh()->surface_get_material(j).ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_mesh()->surface_get_material(j).ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); } } - anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != NULL; + anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_material_override().ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); @@ -228,7 +228,7 @@ String CPUParticles3D::get_configuration_warning() const { get_param_curve(PARAM_ANIM_SPEED).is_valid() || get_param_curve(PARAM_ANIM_OFFSET).is_valid())) { if (warnings != String()) warnings += "\n"; - warnings += "- " + TTR("CPUParticles animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\"."); + warnings += "- " + TTR("CPUParticles3D animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\"."); } return warnings; @@ -1022,7 +1022,7 @@ void CPUParticles3D::_update_particle_data_buffer() { int pc = particles.size(); int *ow; - int *order = NULL; + int *order = nullptr; float *w = particle_data.ptrw(); const Particle *r = particles.ptr(); @@ -1115,15 +1115,15 @@ void CPUParticles3D::_set_redraw(bool p_redraw) { MutexLock lock(update_mutex); if (redraw) { - VS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread)); - VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true); - VS::get_singleton()->multimesh_set_visible_instances(multimesh, -1); + RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread)); + RS::get_singleton()->instance_geometry_set_flag(get_instance(), RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true); + RS::get_singleton()->multimesh_set_visible_instances(multimesh, -1); } else { - if (VS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread))) { - VS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread)); + if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread))) { + RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &CPUParticles3D::_update_render_thread)); } - VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false); - VS::get_singleton()->multimesh_set_visible_instances(multimesh, 0); + RS::get_singleton()->instance_geometry_set_flag(get_instance(), RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, false); + RS::get_singleton()->multimesh_set_visible_instances(multimesh, 0); } } } @@ -1133,7 +1133,7 @@ void CPUParticles3D::_update_render_thread() { MutexLock lock(update_mutex); if (can_update) { - VS::get_singleton()->multimesh_set_buffer(multimesh, particle_data); + RS::get_singleton()->multimesh_set_buffer(multimesh, particle_data); can_update = false; //wait for next time } } @@ -1206,7 +1206,7 @@ void CPUParticles3D::_notification(int p_what) { void CPUParticles3D::convert_from_particles(Node *p_particles) { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_particles); - ERR_FAIL_COND_MSG(!particles, "Only Particles nodes can be converted to CPUParticles."); + ERR_FAIL_COND_MSG(!particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D."); set_emitting(particles->is_emitting()); set_amount(particles->get_amount()); @@ -1488,8 +1488,8 @@ CPUParticles3D::CPUParticles3D() { set_notify_transform(true); - multimesh = VisualServer::get_singleton()->multimesh_create(); - VisualServer::get_singleton()->multimesh_set_visible_instances(multimesh, 0); + multimesh = RenderingServer::get_singleton()->multimesh_create(); + RenderingServer::get_singleton()->multimesh_set_visible_instances(multimesh, 0); set_base(multimesh); set_emitting(true); @@ -1542,5 +1542,5 @@ CPUParticles3D::CPUParticles3D() { } CPUParticles3D::~CPUParticles3D() { - VS::get_singleton()->free(multimesh); + RS::get_singleton()->free(multimesh); } diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 413d5a2b1d..6d571ee4f2 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -92,7 +92,7 @@ Dictionary GIProbeData::_get_data() const { } void GIProbeData::allocate(const Transform &p_to_cell_xform, const AABB &p_aabb, const Vector3 &p_octree_size, const Vector<uint8_t> &p_octree_cells, const Vector<uint8_t> &p_data_cells, const Vector<uint8_t> &p_distance_field, const Vector<int> &p_level_counts) { - VS::get_singleton()->gi_probe_allocate(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts); + RS::get_singleton()->gi_probe_allocate(probe, p_to_cell_xform, p_aabb, p_octree_size, p_octree_cells, p_data_cells, p_distance_field, p_level_counts); bounds = p_aabb; to_cell_xform = p_to_cell_xform; octree_size = p_octree_size; @@ -105,24 +105,24 @@ Vector3 GIProbeData::get_octree_size() const { return octree_size; } Vector<uint8_t> GIProbeData::get_octree_cells() const { - return VS::get_singleton()->gi_probe_get_octree_cells(probe); + return RS::get_singleton()->gi_probe_get_octree_cells(probe); } Vector<uint8_t> GIProbeData::get_data_cells() const { - return VS::get_singleton()->gi_probe_get_data_cells(probe); + return RS::get_singleton()->gi_probe_get_data_cells(probe); } Vector<uint8_t> GIProbeData::get_distance_field() const { - return VS::get_singleton()->gi_probe_get_distance_field(probe); + return RS::get_singleton()->gi_probe_get_distance_field(probe); } Vector<int> GIProbeData::get_level_counts() const { - return VS::get_singleton()->gi_probe_get_level_counts(probe); + return RS::get_singleton()->gi_probe_get_level_counts(probe); } Transform GIProbeData::get_to_cell_xform() const { return to_cell_xform; } void GIProbeData::set_dynamic_range(float p_range) { - VS::get_singleton()->gi_probe_set_dynamic_range(probe, p_range); + RS::get_singleton()->gi_probe_set_dynamic_range(probe, p_range); dynamic_range = p_range; } @@ -131,7 +131,7 @@ float GIProbeData::get_dynamic_range() const { } void GIProbeData::set_propagation(float p_propagation) { - VS::get_singleton()->gi_probe_set_propagation(probe, p_propagation); + RS::get_singleton()->gi_probe_set_propagation(probe, p_propagation); propagation = p_propagation; } @@ -140,7 +140,7 @@ float GIProbeData::get_propagation() const { } void GIProbeData::set_anisotropy_strength(float p_anisotropy_strength) { - VS::get_singleton()->gi_probe_set_anisotropy_strength(probe, p_anisotropy_strength); + RS::get_singleton()->gi_probe_set_anisotropy_strength(probe, p_anisotropy_strength); anisotropy_strength = p_anisotropy_strength; } @@ -149,7 +149,7 @@ float GIProbeData::get_anisotropy_strength() const { } void GIProbeData::set_energy(float p_energy) { - VS::get_singleton()->gi_probe_set_energy(probe, p_energy); + RS::get_singleton()->gi_probe_set_energy(probe, p_energy); energy = p_energy; } @@ -158,7 +158,7 @@ float GIProbeData::get_energy() const { } void GIProbeData::set_ao(float p_ao) { - VS::get_singleton()->gi_probe_set_ao(probe, p_ao); + RS::get_singleton()->gi_probe_set_ao(probe, p_ao); ao = p_ao; } @@ -167,7 +167,7 @@ float GIProbeData::get_ao() const { } void GIProbeData::set_ao_size(float p_ao_size) { - VS::get_singleton()->gi_probe_set_ao_size(probe, p_ao_size); + RS::get_singleton()->gi_probe_set_ao_size(probe, p_ao_size); ao_size = p_ao_size; } @@ -176,7 +176,7 @@ float GIProbeData::get_ao_size() const { } void GIProbeData::set_bias(float p_bias) { - VS::get_singleton()->gi_probe_set_bias(probe, p_bias); + RS::get_singleton()->gi_probe_set_bias(probe, p_bias); bias = p_bias; } @@ -185,7 +185,7 @@ float GIProbeData::get_bias() const { } void GIProbeData::set_normal_bias(float p_normal_bias) { - VS::get_singleton()->gi_probe_set_normal_bias(probe, p_normal_bias); + RS::get_singleton()->gi_probe_set_normal_bias(probe, p_normal_bias); normal_bias = p_normal_bias; } @@ -194,7 +194,7 @@ float GIProbeData::get_normal_bias() const { } void GIProbeData::set_interior(bool p_enable) { - VS::get_singleton()->gi_probe_set_interior(probe, p_enable); + RS::get_singleton()->gi_probe_set_interior(probe, p_enable); interior = p_enable; } @@ -203,7 +203,7 @@ bool GIProbeData::is_interior() const { } void GIProbeData::set_use_two_bounces(bool p_enable) { - VS::get_singleton()->gi_probe_set_use_two_bounces(probe, p_enable); + RS::get_singleton()->gi_probe_set_use_two_bounces(probe, p_enable); use_two_bounces = p_enable; } @@ -293,13 +293,14 @@ GIProbeData::GIProbeData() { propagation = 0.7; anisotropy_strength = 0.5; interior = false; + use_two_bounces = false; - probe = VS::get_singleton()->gi_probe_create(); + probe = RS::get_singleton()->gi_probe_create(); } GIProbeData::~GIProbeData() { - VS::get_singleton()->free(probe); + RS::get_singleton()->free(probe); } ////////////////////// @@ -308,9 +309,9 @@ GIProbeData::~GIProbeData() { void GIProbe::set_probe_data(const Ref<GIProbeData> &p_data) { if (p_data.is_valid()) { - VS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid()); + RS::get_singleton()->instance_set_base(get_instance(), p_data->get_rid()); } else { - VS::get_singleton()->instance_set_base(get_instance(), RID()); + RS::get_singleton()->instance_set_base(get_instance(), RID()); } probe_data = p_data; @@ -402,9 +403,9 @@ void GIProbe::_find_meshes(Node *p_at_node, List<PlotMesh> &plot_meshes) { } } -GIProbe::BakeBeginFunc GIProbe::bake_begin_function = NULL; -GIProbe::BakeStepFunc GIProbe::bake_step_function = NULL; -GIProbe::BakeEndFunc GIProbe::bake_end_function = NULL; +GIProbe::BakeBeginFunc GIProbe::bake_begin_function = nullptr; +GIProbe::BakeStepFunc GIProbe::bake_step_function = nullptr; +GIProbe::BakeEndFunc GIProbe::bake_end_function = nullptr; Vector3i GIProbe::get_estimated_cell_size() const { static const int subdiv_value[SUBDIV_MAX] = { 6, 7, 8, 9 }; @@ -511,7 +512,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { void GIProbe::_debug_bake() { - bake(NULL, true); + bake(nullptr, true); } AABB GIProbe::get_aabb() const { @@ -526,7 +527,7 @@ Vector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const { String GIProbe::get_configuration_warning() const { - if (VisualServer::get_singleton()->is_low_end()) { + if (RenderingServer::get_singleton()->is_low_end()) { return TTR("GIProbes are not supported by the GLES2 video driver.\nUse a BakedLightmap instead."); } return String(); @@ -563,10 +564,10 @@ GIProbe::GIProbe() { subdiv = SUBDIV_128; extents = Vector3(10, 10, 10); - gi_probe = VS::get_singleton()->gi_probe_create(); + gi_probe = RS::get_singleton()->gi_probe_create(); set_disable_scale(true); } GIProbe::~GIProbe() { - VS::get_singleton()->free(gi_probe); + RS::get_singleton()->free(gi_probe); } diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index c00ee2cb73..28b533e82d 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -161,7 +161,7 @@ public: Vector3 get_extents() const; Vector3i get_estimated_cell_size() const; - void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false); + void bake(Node *p_from_node = nullptr, bool p_create_visual_debug = false); virtual AABB get_aabb() const; virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const; diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index a283ec41b2..7744c477cb 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "scene/resources/particles_material.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" AABB GPUParticles3D::get_aabb() const { @@ -46,7 +46,7 @@ Vector<Face3> GPUParticles3D::get_faces(uint32_t p_usage_flags) const { void GPUParticles3D::set_emitting(bool p_emitting) { - VS::get_singleton()->particles_set_emitting(particles, p_emitting); + RS::get_singleton()->particles_set_emitting(particles, p_emitting); if (p_emitting && one_shot) { set_process_internal(true); @@ -59,25 +59,25 @@ void GPUParticles3D::set_amount(int p_amount) { ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles cannot be smaller than 1."); amount = p_amount; - VS::get_singleton()->particles_set_amount(particles, amount); + RS::get_singleton()->particles_set_amount(particles, amount); } void GPUParticles3D::set_lifetime(float p_lifetime) { ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; - VS::get_singleton()->particles_set_lifetime(particles, lifetime); + RS::get_singleton()->particles_set_lifetime(particles, lifetime); } void GPUParticles3D::set_one_shot(bool p_one_shot) { one_shot = p_one_shot; - VS::get_singleton()->particles_set_one_shot(particles, one_shot); + RS::get_singleton()->particles_set_one_shot(particles, one_shot); if (is_emitting()) { set_process_internal(true); if (!one_shot) - VisualServer::get_singleton()->particles_restart(particles); + RenderingServer::get_singleton()->particles_restart(particles); } if (!one_shot) @@ -87,29 +87,29 @@ void GPUParticles3D::set_one_shot(bool p_one_shot) { void GPUParticles3D::set_pre_process_time(float p_time) { pre_process_time = p_time; - VS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time); + RS::get_singleton()->particles_set_pre_process_time(particles, pre_process_time); } void GPUParticles3D::set_explosiveness_ratio(float p_ratio) { explosiveness_ratio = p_ratio; - VS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); + RS::get_singleton()->particles_set_explosiveness_ratio(particles, explosiveness_ratio); } void GPUParticles3D::set_randomness_ratio(float p_ratio) { randomness_ratio = p_ratio; - VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); + RS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } void GPUParticles3D::set_visibility_aabb(const AABB &p_aabb) { visibility_aabb = p_aabb; - VS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); + RS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); update_gizmo(); _change_notify("visibility_aabb"); } void GPUParticles3D::set_use_local_coordinates(bool p_enable) { local_coords = p_enable; - VS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); + RS::get_singleton()->particles_set_use_local_coordinates(particles, local_coords); } void GPUParticles3D::set_process_material(const Ref<Material> &p_material) { @@ -117,7 +117,7 @@ void GPUParticles3D::set_process_material(const Ref<Material> &p_material) { RID material_rid; if (process_material.is_valid()) material_rid = process_material->get_rid(); - VS::get_singleton()->particles_set_process_material(particles, material_rid); + RS::get_singleton()->particles_set_process_material(particles, material_rid); update_configuration_warning(); } @@ -125,12 +125,12 @@ void GPUParticles3D::set_process_material(const Ref<Material> &p_material) { void GPUParticles3D::set_speed_scale(float p_scale) { speed_scale = p_scale; - VS::get_singleton()->particles_set_speed_scale(particles, p_scale); + RS::get_singleton()->particles_set_speed_scale(particles, p_scale); } bool GPUParticles3D::is_emitting() const { - return VS::get_singleton()->particles_get_emitting(particles); + return RS::get_singleton()->particles_get_emitting(particles); } int GPUParticles3D::get_amount() const { @@ -178,7 +178,7 @@ float GPUParticles3D::get_speed_scale() const { void GPUParticles3D::set_draw_order(DrawOrder p_order) { draw_order = p_order; - VS::get_singleton()->particles_set_draw_order(particles, VS::ParticlesDrawOrder(p_order)); + RS::get_singleton()->particles_set_draw_order(particles, RS::ParticlesDrawOrder(p_order)); } GPUParticles3D::DrawOrder GPUParticles3D::get_draw_order() const { @@ -190,7 +190,7 @@ void GPUParticles3D::set_draw_passes(int p_count) { ERR_FAIL_COND(p_count < 1); draw_passes.resize(p_count); - VS::get_singleton()->particles_set_draw_passes(particles, p_count); + RS::get_singleton()->particles_set_draw_passes(particles, p_count); _change_notify(); } int GPUParticles3D::get_draw_passes() const { @@ -208,7 +208,7 @@ void GPUParticles3D::set_draw_pass_mesh(int p_pass, const Ref<Mesh> &p_mesh) { if (p_mesh.is_valid()) mesh_rid = p_mesh->get_rid(); - VS::get_singleton()->particles_set_draw_pass_mesh(particles, p_pass, mesh_rid); + RS::get_singleton()->particles_set_draw_pass_mesh(particles, p_pass, mesh_rid); update_configuration_warning(); } @@ -222,7 +222,7 @@ Ref<Mesh> GPUParticles3D::get_draw_pass_mesh(int p_pass) const { void GPUParticles3D::set_fixed_fps(int p_count) { fixed_fps = p_count; - VS::get_singleton()->particles_set_fixed_fps(particles, p_count); + RS::get_singleton()->particles_set_fixed_fps(particles, p_count); } int GPUParticles3D::get_fixed_fps() const { @@ -231,7 +231,7 @@ int GPUParticles3D::get_fixed_fps() const { void GPUParticles3D::set_fractional_delta(bool p_enable) { fractional_delta = p_enable; - VS::get_singleton()->particles_set_fractional_delta(particles, p_enable); + RS::get_singleton()->particles_set_fractional_delta(particles, p_enable); } bool GPUParticles3D::get_fractional_delta() const { @@ -240,8 +240,8 @@ bool GPUParticles3D::get_fractional_delta() const { String GPUParticles3D::get_configuration_warning() const { - if (VisualServer::get_singleton()->is_low_end()) { - return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles node instead. You can use the \"Convert to CPUParticles\" option for this purpose."); + if (RenderingServer::get_singleton()->is_low_end()) { + return TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles3D node instead. You can use the \"Convert to CPUParticles3D\" option for this purpose."); } String warnings; @@ -253,7 +253,7 @@ String GPUParticles3D::get_configuration_warning() const { if (draw_passes[i].is_valid()) { meshes_found = true; for (int j = 0; j < draw_passes[i]->get_surface_count(); j++) { - anim_material_found = Object::cast_to<ShaderMaterial>(draw_passes[i]->surface_get_material(j).ptr()) != NULL; + anim_material_found = Object::cast_to<ShaderMaterial>(draw_passes[i]->surface_get_material(j).ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(draw_passes[i]->surface_get_material(j).ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); } @@ -261,7 +261,7 @@ String GPUParticles3D::get_configuration_warning() const { } } - anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != NULL; + anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != nullptr; StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_material_override().ptr()); anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); @@ -291,13 +291,13 @@ String GPUParticles3D::get_configuration_warning() const { void GPUParticles3D::restart() { - VisualServer::get_singleton()->particles_restart(particles); - VisualServer::get_singleton()->particles_set_emitting(particles, true); + RenderingServer::get_singleton()->particles_restart(particles); + RenderingServer::get_singleton()->particles_set_emitting(particles, true); } AABB GPUParticles3D::capture_aabb() const { - return VS::get_singleton()->particles_get_current_aabb(particles); + return RS::get_singleton()->particles_get_current_aabb(particles); } void GPUParticles3D::_validate_property(PropertyInfo &property) const { @@ -315,10 +315,10 @@ void GPUParticles3D::_notification(int p_what) { if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) { if (can_process()) { - VS::get_singleton()->particles_set_speed_scale(particles, speed_scale); + RS::get_singleton()->particles_set_speed_scale(particles, speed_scale); } else { - VS::get_singleton()->particles_set_speed_scale(particles, 0); + RS::get_singleton()->particles_set_speed_scale(particles, 0); } } @@ -334,8 +334,8 @@ void GPUParticles3D::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { // make sure particles are updated before rendering occurs if they were active before - if (is_visible_in_tree() && !VS::get_singleton()->particles_is_inactive(particles)) { - VS::get_singleton()->particles_request_process(particles); + if (is_visible_in_tree() && !RS::get_singleton()->particles_is_inactive(particles)) { + RS::get_singleton()->particles_request_process(particles); } } } @@ -416,7 +416,7 @@ void GPUParticles3D::_bind_methods() { GPUParticles3D::GPUParticles3D() { - particles = VS::get_singleton()->particles_create(); + particles = RS::get_singleton()->particles_create(); set_base(particles); one_shot = false; // Needed so that set_emitting doesn't access uninitialized values set_emitting(true); @@ -437,5 +437,5 @@ GPUParticles3D::GPUParticles3D() { GPUParticles3D::~GPUParticles3D() { - VS::get_singleton()->free(particles); + RS::get_singleton()->free(particles); } diff --git a/scene/3d/immediate_geometry_3d.cpp b/scene/3d/immediate_geometry_3d.cpp index acc1f407f9..63d4b1ac84 100644 --- a/scene/3d/immediate_geometry_3d.cpp +++ b/scene/3d/immediate_geometry_3d.cpp @@ -32,39 +32,39 @@ void ImmediateGeometry3D::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) { - VS::get_singleton()->immediate_begin(im, (VS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID()); + RS::get_singleton()->immediate_begin(im, (RS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID()); if (p_texture.is_valid()) cached_textures.push_back(p_texture); } void ImmediateGeometry3D::set_normal(const Vector3 &p_normal) { - VS::get_singleton()->immediate_normal(im, p_normal); + RS::get_singleton()->immediate_normal(im, p_normal); } void ImmediateGeometry3D::set_tangent(const Plane &p_tangent) { - VS::get_singleton()->immediate_tangent(im, p_tangent); + RS::get_singleton()->immediate_tangent(im, p_tangent); } void ImmediateGeometry3D::set_color(const Color &p_color) { - VS::get_singleton()->immediate_color(im, p_color); + RS::get_singleton()->immediate_color(im, p_color); } void ImmediateGeometry3D::set_uv(const Vector2 &p_uv) { - VS::get_singleton()->immediate_uv(im, p_uv); + RS::get_singleton()->immediate_uv(im, p_uv); } void ImmediateGeometry3D::set_uv2(const Vector2 &p_uv2) { - VS::get_singleton()->immediate_uv2(im, p_uv2); + RS::get_singleton()->immediate_uv2(im, p_uv2); } void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) { - VS::get_singleton()->immediate_vertex(im, p_vertex); + RS::get_singleton()->immediate_vertex(im, p_vertex); if (empty) { aabb.position = p_vertex; aabb.size = Vector3(); @@ -76,12 +76,12 @@ void ImmediateGeometry3D::add_vertex(const Vector3 &p_vertex) { void ImmediateGeometry3D::end() { - VS::get_singleton()->immediate_end(im); + RS::get_singleton()->immediate_end(im); } void ImmediateGeometry3D::clear() { - VS::get_singleton()->immediate_clear(im); + RS::get_singleton()->immediate_clear(im); empty = true; cached_textures.clear(); } @@ -158,12 +158,12 @@ void ImmediateGeometry3D::_bind_methods() { ImmediateGeometry3D::ImmediateGeometry3D() { - im = VisualServer::get_singleton()->immediate_create(); + im = RenderingServer::get_singleton()->immediate_create(); set_base(im); empty = true; } ImmediateGeometry3D::~ImmediateGeometry3D() { - VisualServer::get_singleton()->free(im); + RenderingServer::get_singleton()->free(im); } diff --git a/scene/3d/immediate_geometry_3d.h b/scene/3d/immediate_geometry_3d.h index d968187ba3..6e15450a5b 100644 --- a/scene/3d/immediate_geometry_3d.h +++ b/scene/3d/immediate_geometry_3d.h @@ -40,7 +40,7 @@ class ImmediateGeometry3D : public GeometryInstance3D { RID im; //a list of textures drawn need to be kept, to avoid references - // in VisualServer from becoming invalid if the texture is no longer used + // in RenderingServer from becoming invalid if the texture is no longer used List<Ref<Texture2D>> cached_textures; bool empty; AABB aabb; diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 434f35fc57..be3b369724 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -44,7 +44,7 @@ void Light3D::set_param(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); param[p_param] = p_value; - VS::get_singleton()->light_set_param(light, VS::LightParam(p_param), p_value); + RS::get_singleton()->light_set_param(light, RS::LightParam(p_param), p_value); if (p_param == PARAM_SPOT_ANGLE || p_param == PARAM_RANGE) { update_gizmo(); @@ -68,9 +68,9 @@ float Light3D::get_param(Param p_param) const { void Light3D::set_shadow(bool p_enable) { shadow = p_enable; - VS::get_singleton()->light_set_shadow(light, p_enable); + RS::get_singleton()->light_set_shadow(light, p_enable); - if (type == VisualServer::LIGHT_SPOT) { + if (type == RenderingServer::LIGHT_SPOT) { update_configuration_warning(); } } @@ -82,7 +82,7 @@ bool Light3D::has_shadow() const { void Light3D::set_negative(bool p_enable) { negative = p_enable; - VS::get_singleton()->light_set_negative(light, p_enable); + RS::get_singleton()->light_set_negative(light, p_enable); } bool Light3D::is_negative() const { @@ -92,7 +92,7 @@ bool Light3D::is_negative() const { void Light3D::set_cull_mask(uint32_t p_cull_mask) { cull_mask = p_cull_mask; - VS::get_singleton()->light_set_cull_mask(light, p_cull_mask); + RS::get_singleton()->light_set_cull_mask(light, p_cull_mask); } uint32_t Light3D::get_cull_mask() const { @@ -102,7 +102,7 @@ uint32_t Light3D::get_cull_mask() const { void Light3D::set_color(const Color &p_color) { color = p_color; - VS::get_singleton()->light_set_color(light, p_color); + RS::get_singleton()->light_set_color(light, p_color); // The gizmo color depends on the light color, so update it. update_gizmo(); } @@ -114,7 +114,7 @@ Color Light3D::get_color() const { void Light3D::set_shadow_color(const Color &p_shadow_color) { shadow_color = p_shadow_color; - VS::get_singleton()->light_set_shadow_color(light, p_shadow_color); + RS::get_singleton()->light_set_shadow_color(light, p_shadow_color); } Color Light3D::get_shadow_color() const { @@ -124,7 +124,7 @@ Color Light3D::get_shadow_color() const { void Light3D::set_shadow_reverse_cull_face(bool p_enable) { reverse_cull = p_enable; - VS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull); + RS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull); } bool Light3D::get_shadow_reverse_cull_face() const { @@ -134,15 +134,15 @@ bool Light3D::get_shadow_reverse_cull_face() const { AABB Light3D::get_aabb() const { - if (type == VisualServer::LIGHT_DIRECTIONAL) { + if (type == RenderingServer::LIGHT_DIRECTIONAL) { return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); - } else if (type == VisualServer::LIGHT_OMNI) { + } else if (type == RenderingServer::LIGHT_OMNI) { return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]); - } else if (type == VisualServer::LIGHT_SPOT) { + } else if (type == RenderingServer::LIGHT_SPOT) { float len = param[PARAM_RANGE]; float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len; @@ -159,7 +159,7 @@ Vector<Face3> Light3D::get_faces(uint32_t p_usage_flags) const { void Light3D::set_bake_mode(BakeMode p_mode) { bake_mode = p_mode; - VS::get_singleton()->light_set_use_gi(light, p_mode != BAKE_DISABLED); + RS::get_singleton()->light_set_use_gi(light, p_mode != BAKE_DISABLED); } Light3D::BakeMode Light3D::get_bake_mode() const { @@ -187,7 +187,7 @@ void Light3D::_update_visibility() { } #endif - VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok); + RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree() && editor_ok); _change_notify("geometry/visible"); } @@ -217,7 +217,7 @@ bool Light3D::is_editor_only() const { void Light3D::_validate_property(PropertyInfo &property) const { - if (VisualServer::get_singleton()->is_low_end() && property.name == "shadow_contact") { + if (RenderingServer::get_singleton()->is_low_end() && property.name == "shadow_contact") { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } @@ -292,18 +292,18 @@ void Light3D::_bind_methods() { BIND_ENUM_CONSTANT(BAKE_ALL); } -Light3D::Light3D(VisualServer::LightType p_type) { +Light3D::Light3D(RenderingServer::LightType p_type) { type = p_type; switch (p_type) { - case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break; - case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break; - case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break; + case RS::LIGHT_DIRECTIONAL: light = RenderingServer::get_singleton()->directional_light_create(); break; + case RS::LIGHT_OMNI: light = RenderingServer::get_singleton()->omni_light_create(); break; + case RS::LIGHT_SPOT: light = RenderingServer::get_singleton()->spot_light_create(); break; default: { }; } - VS::get_singleton()->instance_set_base(get_instance(), light); + RS::get_singleton()->instance_set_base(get_instance(), light); reverse_cull = false; bake_mode = BAKE_INDIRECT; @@ -335,23 +335,23 @@ Light3D::Light3D(VisualServer::LightType p_type) { Light3D::Light3D() { - type = VisualServer::LIGHT_DIRECTIONAL; - ERR_PRINT("Light should not be instanced directly; use the DirectionalLight, OmniLight or SpotLight subtypes instead."); + type = RenderingServer::LIGHT_DIRECTIONAL; + ERR_PRINT("Light3D should not be instanced directly; use the DirectionalLight3D, OmniLight3D or SpotLight3D subtypes instead."); } Light3D::~Light3D() { - VS::get_singleton()->instance_set_base(get_instance(), RID()); + RS::get_singleton()->instance_set_base(get_instance(), RID()); if (light.is_valid()) - VisualServer::get_singleton()->free(light); + RenderingServer::get_singleton()->free(light); } ///////////////////////////////////////// void DirectionalLight3D::set_shadow_mode(ShadowMode p_mode) { shadow_mode = p_mode; - VS::get_singleton()->light_directional_set_shadow_mode(light, VS::LightDirectionalShadowMode(p_mode)); + RS::get_singleton()->light_directional_set_shadow_mode(light, RS::LightDirectionalShadowMode(p_mode)); } DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const { @@ -361,7 +361,7 @@ DirectionalLight3D::ShadowMode DirectionalLight3D::get_shadow_mode() const { void DirectionalLight3D::set_shadow_depth_range(ShadowDepthRange p_range) { shadow_depth_range = p_range; - VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range)); + RS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, RS::LightDirectionalShadowDepthRangeMode(p_range)); } DirectionalLight3D::ShadowDepthRange DirectionalLight3D::get_shadow_depth_range() const { @@ -372,7 +372,7 @@ DirectionalLight3D::ShadowDepthRange DirectionalLight3D::get_shadow_depth_range( void DirectionalLight3D::set_blend_splits(bool p_enable) { blend_splits = p_enable; - VS::get_singleton()->light_directional_set_blend_splits(light, p_enable); + RS::get_singleton()->light_directional_set_blend_splits(light, p_enable); } bool DirectionalLight3D::is_blend_splits_enabled() const { @@ -412,7 +412,7 @@ void DirectionalLight3D::_bind_methods() { } DirectionalLight3D::DirectionalLight3D() : - Light3D(VisualServer::LIGHT_DIRECTIONAL) { + Light3D(RenderingServer::LIGHT_DIRECTIONAL) { set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8); set_param(PARAM_SHADOW_BIAS, 0.1); @@ -428,7 +428,7 @@ DirectionalLight3D::DirectionalLight3D() : void OmniLight3D::set_shadow_mode(ShadowMode p_mode) { shadow_mode = p_mode; - VS::get_singleton()->light_omni_set_shadow_mode(light, VS::LightOmniShadowMode(p_mode)); + RS::get_singleton()->light_omni_set_shadow_mode(light, RS::LightOmniShadowMode(p_mode)); } OmniLight3D::ShadowMode OmniLight3D::get_shadow_mode() const { @@ -451,7 +451,7 @@ void OmniLight3D::_bind_methods() { } OmniLight3D::OmniLight3D() : - Light3D(VisualServer::LIGHT_OMNI) { + Light3D(RenderingServer::LIGHT_OMNI) { set_shadow_mode(SHADOW_CUBE); } @@ -464,7 +464,7 @@ String SpotLight3D::get_configuration_warning() const { warning += "\n\n"; } - warning += TTR("A SpotLight with an angle wider than 90 degrees cannot cast shadows."); + warning += TTR("A SpotLight3D with an angle wider than 90 degrees cannot cast shadows."); } return warning; diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 7b3273e1e4..197e5854ec 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -33,7 +33,7 @@ #include "scene/3d/visual_instance_3d.h" #include "scene/resources/texture.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class Light3D : public VisualInstance3D { @@ -42,23 +42,23 @@ class Light3D : public VisualInstance3D { public: enum Param { - PARAM_ENERGY = VS::LIGHT_PARAM_ENERGY, - PARAM_INDIRECT_ENERGY = VS::LIGHT_PARAM_INDIRECT_ENERGY, - PARAM_SPECULAR = VS::LIGHT_PARAM_SPECULAR, - PARAM_RANGE = VS::LIGHT_PARAM_RANGE, - PARAM_ATTENUATION = VS::LIGHT_PARAM_ATTENUATION, - PARAM_SPOT_ANGLE = VS::LIGHT_PARAM_SPOT_ANGLE, - PARAM_SPOT_ATTENUATION = VS::LIGHT_PARAM_SPOT_ATTENUATION, - PARAM_CONTACT_SHADOW_SIZE = VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE, - PARAM_SHADOW_MAX_DISTANCE = VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE, - PARAM_SHADOW_SPLIT_1_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET, - PARAM_SHADOW_SPLIT_2_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET, - PARAM_SHADOW_SPLIT_3_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET, - PARAM_SHADOW_FADE_START = VS::LIGHT_PARAM_SHADOW_FADE_START, - PARAM_SHADOW_NORMAL_BIAS = VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS, - PARAM_SHADOW_BIAS = VS::LIGHT_PARAM_SHADOW_BIAS, - PARAM_SHADOW_BIAS_SPLIT_SCALE = VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE, - PARAM_MAX = VS::LIGHT_PARAM_MAX + PARAM_ENERGY = RS::LIGHT_PARAM_ENERGY, + PARAM_INDIRECT_ENERGY = RS::LIGHT_PARAM_INDIRECT_ENERGY, + PARAM_SPECULAR = RS::LIGHT_PARAM_SPECULAR, + PARAM_RANGE = RS::LIGHT_PARAM_RANGE, + PARAM_ATTENUATION = RS::LIGHT_PARAM_ATTENUATION, + PARAM_SPOT_ANGLE = RS::LIGHT_PARAM_SPOT_ANGLE, + PARAM_SPOT_ATTENUATION = RS::LIGHT_PARAM_SPOT_ATTENUATION, + PARAM_CONTACT_SHADOW_SIZE = RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE, + PARAM_SHADOW_MAX_DISTANCE = RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE, + PARAM_SHADOW_SPLIT_1_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET, + PARAM_SHADOW_SPLIT_2_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET, + PARAM_SHADOW_SPLIT_3_OFFSET = RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET, + PARAM_SHADOW_FADE_START = RS::LIGHT_PARAM_SHADOW_FADE_START, + PARAM_SHADOW_NORMAL_BIAS = RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS, + PARAM_SHADOW_BIAS = RS::LIGHT_PARAM_SHADOW_BIAS, + PARAM_SHADOW_BIAS_SPLIT_SCALE = RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE, + PARAM_MAX = RS::LIGHT_PARAM_MAX }; enum BakeMode { @@ -75,7 +75,7 @@ private: bool negative; bool reverse_cull; uint32_t cull_mask; - VS::LightType type; + RS::LightType type; bool editor_only; void _update_visibility(); BakeMode bake_mode; @@ -91,10 +91,10 @@ protected: void _notification(int p_what); virtual void _validate_property(PropertyInfo &property) const; - Light3D(VisualServer::LightType p_type); + Light3D(RenderingServer::LightType p_type); public: - VS::LightType get_light_type() const { return type; } + RS::LightType get_light_type() const { return type; } void set_editor_only(bool p_editor_only); bool is_editor_only() const; @@ -145,8 +145,8 @@ public: }; enum ShadowDepthRange { - SHADOW_DEPTH_RANGE_STABLE = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE, - SHADOW_DEPTH_RANGE_OPTIMIZED = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED, + SHADOW_DEPTH_RANGE_STABLE = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE, + SHADOW_DEPTH_RANGE_OPTIMIZED = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED, }; private: @@ -210,7 +210,7 @@ public: virtual String get_configuration_warning() const; SpotLight3D() : - Light3D(VisualServer::LIGHT_SPOT) {} + Light3D(RenderingServer::LIGHT_SPOT) {} }; #endif diff --git a/scene/3d/listener_3d.cpp b/scene/3d/listener_3d.cpp index f352eb24b1..426e34ea80 100644 --- a/scene/3d/listener_3d.cpp +++ b/scene/3d/listener_3d.cpp @@ -131,7 +131,7 @@ void Listener3D::clear_current() { return; if (get_viewport()->get_listener() == this) { - get_viewport()->_listener_set(NULL); + get_viewport()->_listener_set(nullptr); get_viewport()->_listener_make_next_current(this); } } diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index 5f826505b4..d56a095a5b 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -47,7 +47,7 @@ bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) { Map<StringName, BlendShapeTrack>::Element *E = blend_shape_tracks.find(p_name); if (E) { E->get().value = p_value; - VisualServer::get_singleton()->instance_set_blend_shape_weight(get_instance(), E->get().idx, E->get().value); + RenderingServer::get_singleton()->instance_set_blend_shape_weight(get_instance(), E->get().idx, E->get().value); return true; } @@ -165,9 +165,9 @@ void MeshInstance3D::_resolve_skeleton_path() { skin_ref = new_skin_reference; if (skin_ref.is_valid()) { - VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), skin_ref->get_skeleton()); + RenderingServer::get_singleton()->instance_attach_skeleton(get_instance(), skin_ref->get_skeleton()); } else { - VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), RID()); + RenderingServer::get_singleton()->instance_attach_skeleton(get_instance(), RID()); } } @@ -217,11 +217,11 @@ Vector<Face3> MeshInstance3D::get_faces(uint32_t p_usage_flags) const { Node *MeshInstance3D::create_trimesh_collision_node() { if (mesh.is_null()) - return NULL; + return nullptr; Ref<Shape3D> shape = mesh->create_trimesh_shape(); if (shape.is_null()) - return NULL; + return nullptr; StaticBody3D *static_body = memnew(StaticBody3D); CollisionShape3D *cshape = memnew(CollisionShape3D); @@ -247,11 +247,11 @@ void MeshInstance3D::create_trimesh_collision() { Node *MeshInstance3D::create_convex_collision_node() { if (mesh.is_null()) - return NULL; + return nullptr; Ref<Shape3D> shape = mesh->create_convex_shape(); if (shape.is_null()) - return NULL; + return nullptr; StaticBody3D *static_body = memnew(StaticBody3D); CollisionShape3D *cshape = memnew(CollisionShape3D); @@ -293,9 +293,9 @@ void MeshInstance3D::set_surface_material(int p_surface, const Ref<Material> &p_ materials.write[p_surface] = p_material; if (materials[p_surface].is_valid()) - VS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid()); + RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid()); else - VS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID()); + RS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID()); } Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const { @@ -305,6 +305,23 @@ Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const { return materials[p_surface]; } +Ref<Material> MeshInstance3D::get_active_material(int p_surface) const { + + if (get_material_override() != Ref<Material>()) { + return get_material_override(); + } else if (p_surface < materials.size()) { + return materials[p_surface]; + } else { + Ref<Mesh> mesh = get_mesh(); + + if (mesh.is_null() || p_surface >= mesh->get_surface_count()) { + return Ref<Material>(); + } + + return mesh->surface_get_material(p_surface); + } +} + void MeshInstance3D::_mesh_changed() { materials.resize(mesh->get_surface_count()); @@ -397,6 +414,7 @@ void MeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance3D::get_surface_material_count); ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance3D::set_surface_material); ClassDB::bind_method(D_METHOD("get_surface_material", "surface"), &MeshInstance3D::get_surface_material); + ClassDB::bind_method(D_METHOD("get_active_material", "surface"), &MeshInstance3D::get_active_material); ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance3D::create_trimesh_collision); ClassDB::set_method_flags("MeshInstance3D", "create_trimesh_collision", METHOD_FLAGS_DEFAULT); diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index e45f68e295..914148f427 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -84,6 +84,7 @@ public: int get_surface_material_count() const; void set_surface_material(int p_surface, const Ref<Material> &p_material); Ref<Material> get_surface_material(int p_surface) const; + Ref<Material> get_active_material(int p_surface) const; Node *create_trimesh_collision_node(); void create_trimesh_collision(); diff --git a/scene/3d/navigation_3d.cpp b/scene/3d/navigation_3d.cpp index 28da04fcbe..f880f65d37 100644 --- a/scene/3d/navigation_3d.cpp +++ b/scene/3d/navigation_3d.cpp @@ -30,33 +30,33 @@ #include "navigation_3d.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" Vector<Vector3> Navigation3D::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) const { - return NavigationServer::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); + return NavigationServer3D::get_singleton()->map_get_path(map, p_start, p_end, p_optimize); } Vector3 Navigation3D::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, bool p_use_collision) const { - return NavigationServer::get_singleton()->map_get_closest_point_to_segment(map, p_from, p_to, p_use_collision); + return NavigationServer3D::get_singleton()->map_get_closest_point_to_segment(map, p_from, p_to, p_use_collision); } Vector3 Navigation3D::get_closest_point(const Vector3 &p_point) const { - return NavigationServer::get_singleton()->map_get_closest_point(map, p_point); + return NavigationServer3D::get_singleton()->map_get_closest_point(map, p_point); } Vector3 Navigation3D::get_closest_point_normal(const Vector3 &p_point) const { - return NavigationServer::get_singleton()->map_get_closest_point_normal(map, p_point); + return NavigationServer3D::get_singleton()->map_get_closest_point_normal(map, p_point); } RID Navigation3D::get_closest_point_owner(const Vector3 &p_point) const { - return NavigationServer::get_singleton()->map_get_closest_point_owner(map, p_point); + return NavigationServer3D::get_singleton()->map_get_closest_point_owner(map, p_point); } void Navigation3D::set_up_vector(const Vector3 &p_up) { up = p_up; - NavigationServer::get_singleton()->map_set_up(map, up); + NavigationServer3D::get_singleton()->map_set_up(map, up); } Vector3 Navigation3D::get_up_vector() const { @@ -66,12 +66,12 @@ Vector3 Navigation3D::get_up_vector() const { void Navigation3D::set_cell_size(float p_cell_size) { cell_size = p_cell_size; - NavigationServer::get_singleton()->map_set_cell_size(map, cell_size); + NavigationServer3D::get_singleton()->map_set_cell_size(map, cell_size); } void Navigation3D::set_edge_connection_margin(float p_edge_connection_margin) { edge_connection_margin = p_edge_connection_margin; - NavigationServer::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin); + NavigationServer3D::get_singleton()->map_set_edge_connection_margin(map, edge_connection_margin); } void Navigation3D::_bind_methods() { @@ -101,18 +101,18 @@ void Navigation3D::_bind_methods() { void Navigation3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - NavigationServer::get_singleton()->map_set_active(map, true); + NavigationServer3D::get_singleton()->map_set_active(map, true); } break; case NOTIFICATION_EXIT_TREE: { - NavigationServer::get_singleton()->map_set_active(map, false); + NavigationServer3D::get_singleton()->map_set_active(map, false); } break; } } Navigation3D::Navigation3D() { - map = NavigationServer::get_singleton()->map_create(); + map = NavigationServer3D::get_singleton()->map_create(); set_cell_size(0.3); set_edge_connection_margin(5.0); // Five meters, depends alot on the agents radius @@ -121,5 +121,5 @@ Navigation3D::Navigation3D() { } Navigation3D::~Navigation3D() { - NavigationServer::get_singleton()->free(map); + NavigationServer3D::get_singleton()->free(map); } diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp index 219e868f29..0449ab15b7 100644 --- a/scene/3d/navigation_agent_3d.cpp +++ b/scene/3d/navigation_agent_3d.cpp @@ -32,7 +32,7 @@ #include "core/engine.h" #include "scene/3d/navigation_3d.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" void NavigationAgent3D::_bind_methods() { @@ -102,16 +102,16 @@ void NavigationAgent3D::_notification(int p_what) { agent_parent = Object::cast_to<Node3D>(get_parent()); - NavigationServer::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); + NavigationServer3D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done"); // Search the navigation node and set it { - Navigation3D *nav = NULL; + Navigation3D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation3D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -122,14 +122,14 @@ void NavigationAgent3D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - agent_parent = NULL; - set_navigation(NULL); + agent_parent = nullptr; + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (agent_parent) { - NavigationServer::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin); + NavigationServer3D::get_singleton()->agent_set_position(agent, agent_parent->get_global_transform().origin); if (!target_reached) { if (distance_to_target() < target_desired_distance) { emit_signal("target_reached"); @@ -142,8 +142,8 @@ void NavigationAgent3D::_notification(int p_what) { } NavigationAgent3D::NavigationAgent3D() : - agent_parent(NULL), - navigation(NULL), + agent_parent(nullptr), + navigation(nullptr), agent(RID()), target_desired_distance(1.0), navigation_height_offset(0.0), @@ -151,7 +151,7 @@ NavigationAgent3D::NavigationAgent3D() : velocity_submitted(false), target_reached(false), navigation_finished(true) { - agent = NavigationServer::get_singleton()->agent_create(); + agent = NavigationServer3D::get_singleton()->agent_create(); set_neighbor_dist(50.0); set_max_neighbors(10); set_time_horizon(5.0); @@ -161,7 +161,7 @@ NavigationAgent3D::NavigationAgent3D() : } NavigationAgent3D::~NavigationAgent3D() { - NavigationServer::get_singleton()->free(agent); + NavigationServer3D::get_singleton()->free(agent); agent = RID(); // Pointless } @@ -170,12 +170,12 @@ void NavigationAgent3D::set_navigation(Navigation3D *p_nav) { return; // Pointless navigation = p_nav; - NavigationServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationAgent3D::set_navigation_node(Node *p_nav) { Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } @@ -189,7 +189,7 @@ void NavigationAgent3D::set_target_desired_distance(real_t p_dd) { void NavigationAgent3D::set_radius(real_t p_radius) { radius = p_radius; - NavigationServer::get_singleton()->agent_set_radius(agent, radius); + NavigationServer3D::get_singleton()->agent_set_radius(agent, radius); } void NavigationAgent3D::set_agent_height_offset(real_t p_hh) { @@ -198,27 +198,27 @@ void NavigationAgent3D::set_agent_height_offset(real_t p_hh) { void NavigationAgent3D::set_ignore_y(bool p_ignore_y) { ignore_y = p_ignore_y; - NavigationServer::get_singleton()->agent_set_ignore_y(agent, ignore_y); + NavigationServer3D::get_singleton()->agent_set_ignore_y(agent, ignore_y); } void NavigationAgent3D::set_neighbor_dist(real_t p_dist) { neighbor_dist = p_dist; - NavigationServer::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist); + NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, neighbor_dist); } void NavigationAgent3D::set_max_neighbors(int p_count) { max_neighbors = p_count; - NavigationServer::get_singleton()->agent_set_max_neighbors(agent, max_neighbors); + NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, max_neighbors); } void NavigationAgent3D::set_time_horizon(real_t p_time) { time_horizon = p_time; - NavigationServer::get_singleton()->agent_set_time_horizon(agent, time_horizon); + NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, time_horizon); } void NavigationAgent3D::set_max_speed(real_t p_max_speed) { max_speed = p_max_speed; - NavigationServer::get_singleton()->agent_set_max_speed(agent, max_speed); + NavigationServer3D::get_singleton()->agent_set_max_speed(agent, max_speed); } void NavigationAgent3D::set_path_max_distance(real_t p_pmd) { @@ -244,7 +244,7 @@ Vector3 NavigationAgent3D::get_target_location() const { Vector3 NavigationAgent3D::get_next_location() { update_navigation(); if (navigation_path.size() == 0) { - ERR_FAIL_COND_V(agent_parent == NULL, Vector3()); + ERR_FAIL_COND_V(agent_parent == nullptr, Vector3()); return agent_parent->get_global_transform().origin; } else { return navigation_path[nav_path_index] - Vector3(0, navigation_height_offset, 0); @@ -252,7 +252,7 @@ Vector3 NavigationAgent3D::get_next_location() { } real_t NavigationAgent3D::distance_to_target() const { - ERR_FAIL_COND_V(agent_parent == NULL, 0.0); + ERR_FAIL_COND_V(agent_parent == nullptr, 0.0); return agent_parent->get_global_transform().origin.distance_to(target_location); } @@ -279,8 +279,8 @@ Vector3 NavigationAgent3D::get_final_location() { void NavigationAgent3D::set_velocity(Vector3 p_velocity) { target_velocity = p_velocity; - NavigationServer::get_singleton()->agent_set_target_velocity(agent, target_velocity); - NavigationServer::get_singleton()->agent_set_velocity(agent, prev_safe_velocity); + NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, target_velocity); + NavigationServer3D::get_singleton()->agent_set_velocity(agent, prev_safe_velocity); velocity_submitted = true; } @@ -298,7 +298,7 @@ void NavigationAgent3D::_avoidance_done(Vector3 p_new_velocity) { String NavigationAgent3D::get_configuration_warning() const { if (!Object::cast_to<Node3D>(get_parent())) { - return TTR("The NavigationAgent can be used only under a spatial node."); + return TTR("The NavigationAgent3D can be used only under a spatial node."); } return String(); @@ -306,8 +306,8 @@ String NavigationAgent3D::get_configuration_warning() const { void NavigationAgent3D::update_navigation() { - if (agent_parent == NULL) return; - if (navigation == NULL) return; + if (agent_parent == nullptr) return; + if (navigation == nullptr) return; if (update_frame_id == Engine::get_singleton()->get_physics_frames()) return; update_frame_id = Engine::get_singleton()->get_physics_frames(); @@ -316,7 +316,7 @@ void NavigationAgent3D::update_navigation() { bool reload_path = false; - if (NavigationServer::get_singleton()->agent_is_map_changed(agent)) { + if (NavigationServer3D::get_singleton()->agent_is_map_changed(agent)) { reload_path = true; } else if (navigation_path.size() == 0) { reload_path = true; @@ -337,7 +337,7 @@ void NavigationAgent3D::update_navigation() { } if (reload_path) { - navigation_path = NavigationServer::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true); + navigation_path = NavigationServer3D::get_singleton()->map_get_path(navigation->get_rid(), o, target_location, true); navigation_finished = false; nav_path_index = 0; emit_signal("path_changed"); diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp index 9eef4a1340..2ee2008799 100644 --- a/scene/3d/navigation_obstacle_3d.cpp +++ b/scene/3d/navigation_obstacle_3d.cpp @@ -33,7 +33,7 @@ #include "scene/3d/collision_shape_3d.h" #include "scene/3d/navigation_3d.h" #include "scene/3d/physics_body_3d.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" void NavigationObstacle3D::_bind_methods() { @@ -49,12 +49,12 @@ void NavigationObstacle3D::_notification(int p_what) { // Search the navigation node and set it { - Navigation3D *nav = NULL; + Navigation3D *nav = nullptr; Node *p = get_parent(); - while (p != NULL) { + while (p != nullptr) { nav = Object::cast_to<Navigation3D>(p); - if (nav != NULL) - p = NULL; + if (nav != nullptr) + p = nullptr; else p = p->get_parent(); } @@ -65,21 +65,21 @@ void NavigationObstacle3D::_notification(int p_what) { set_physics_process_internal(true); } break; case NOTIFICATION_EXIT_TREE: { - set_navigation(NULL); + set_navigation(nullptr); set_physics_process_internal(false); } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { Node3D *spatial = Object::cast_to<Node3D>(get_parent()); if (spatial) { - NavigationServer::get_singleton()->agent_set_position(agent, spatial->get_global_transform().origin); + NavigationServer3D::get_singleton()->agent_set_position(agent, spatial->get_global_transform().origin); } PhysicsBody3D *rigid = Object::cast_to<PhysicsBody3D>(get_parent()); if (rigid) { Vector3 v = rigid->get_linear_velocity(); - NavigationServer::get_singleton()->agent_set_velocity(agent, v); - NavigationServer::get_singleton()->agent_set_target_velocity(agent, v); + NavigationServer3D::get_singleton()->agent_set_velocity(agent, v); + NavigationServer3D::get_singleton()->agent_set_target_velocity(agent, v); } } break; @@ -87,13 +87,13 @@ void NavigationObstacle3D::_notification(int p_what) { } NavigationObstacle3D::NavigationObstacle3D() : - navigation(NULL), + navigation(nullptr), agent(RID()) { - agent = NavigationServer::get_singleton()->agent_create(); + agent = NavigationServer3D::get_singleton()->agent_create(); } NavigationObstacle3D::~NavigationObstacle3D() { - NavigationServer::get_singleton()->free(agent); + NavigationServer3D::get_singleton()->free(agent); agent = RID(); // Pointless } @@ -102,12 +102,12 @@ void NavigationObstacle3D::set_navigation(Navigation3D *p_nav) { return; // Pointless navigation = p_nav; - NavigationServer::get_singleton()->agent_set_map(agent, navigation == NULL ? RID() : navigation->get_rid()); + NavigationServer3D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid()); } void NavigationObstacle3D::set_navigation_node(Node *p_nav) { Navigation3D *nav = Object::cast_to<Navigation3D>(p_nav); - ERR_FAIL_COND(nav == NULL); + ERR_FAIL_COND(nav == nullptr); set_navigation(nav); } @@ -118,7 +118,7 @@ Node *NavigationObstacle3D::get_navigation_node() const { String NavigationObstacle3D::get_configuration_warning() const { if (!Object::cast_to<Node3D>(get_parent())) { - return TTR("The NavigationObstacle only serves to provide collision avoidance to a spatial object."); + return TTR("The NavigationObstacle3D only serves to provide collision avoidance to a spatial object."); } return String(); @@ -155,9 +155,9 @@ void NavigationObstacle3D::update_agent_shape() { radius = 1.0; // Never a 0 radius // Initialize the Agent as an object - NavigationServer::get_singleton()->agent_set_neighbor_dist(agent, 0.0); - NavigationServer::get_singleton()->agent_set_max_neighbors(agent, 0); - NavigationServer::get_singleton()->agent_set_time_horizon(agent, 0.0); - NavigationServer::get_singleton()->agent_set_radius(agent, radius); - NavigationServer::get_singleton()->agent_set_max_speed(agent, 0.0); + NavigationServer3D::get_singleton()->agent_set_neighbor_dist(agent, 0.0); + NavigationServer3D::get_singleton()->agent_set_max_neighbors(agent, 0); + NavigationServer3D::get_singleton()->agent_set_time_horizon(agent, 0.0); + NavigationServer3D::get_singleton()->agent_set_radius(agent, radius); + NavigationServer3D::get_singleton()->agent_set_max_speed(agent, 0.0); } diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp index 8035e6149d..043b816033 100644 --- a/scene/3d/navigation_region_3d.cpp +++ b/scene/3d/navigation_region_3d.cpp @@ -29,10 +29,11 @@ /*************************************************************************/ #include "navigation_region_3d.h" + #include "core/os/thread.h" #include "mesh_instance_3d.h" #include "navigation_3d.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" void NavigationRegion3D::set_enabled(bool p_enabled) { @@ -45,12 +46,12 @@ void NavigationRegion3D::set_enabled(bool p_enabled) { if (!enabled) { - NavigationServer::get_singleton()->region_set_map(region, RID()); + NavigationServer3D::get_singleton()->region_set_map(region, RID()); } else { if (navigation) { - NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); } } @@ -86,7 +87,7 @@ void NavigationRegion3D::_notification(int p_what) { if (enabled) { - NavigationServer::get_singleton()->region_set_map(region, navigation->get_rid()); + NavigationServer3D::get_singleton()->region_set_map(region, navigation->get_rid()); } break; } @@ -110,21 +111,21 @@ void NavigationRegion3D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - NavigationServer::get_singleton()->region_set_transform(region, get_global_transform()); + NavigationServer3D::get_singleton()->region_set_transform(region, get_global_transform()); } break; case NOTIFICATION_EXIT_TREE: { if (navigation) { - NavigationServer::get_singleton()->region_set_map(region, RID()); + NavigationServer3D::get_singleton()->region_set_map(region, RID()); } if (debug_view) { debug_view->queue_delete(); - debug_view = NULL; + debug_view = nullptr; } - navigation = NULL; + navigation = nullptr; } break; } } @@ -144,7 +145,7 @@ void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_navmes navmesh->add_change_receptor(this); } - NavigationServer::get_singleton()->region_set_navmesh(region, p_navmesh); + NavigationServer3D::get_singleton()->region_set_navmesh(region, p_navmesh); if (debug_view && navmesh.is_valid()) { Object::cast_to<MeshInstance3D>(debug_view)->set_mesh(navmesh->get_debug_mesh()); @@ -171,7 +172,7 @@ void _bake_navigation_mesh(void *p_user_data) { if (args->nav_region->get_navigation_mesh().is_valid()) { Ref<NavigationMesh> nav_mesh = args->nav_region->get_navigation_mesh()->duplicate(); - NavigationServer::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_region); + NavigationServer3D::get_singleton()->region_bake_navmesh(nav_mesh, args->nav_region); args->nav_region->call_deferred("_bake_finished", nav_mesh); memdelete(args); } else { @@ -183,18 +184,18 @@ void _bake_navigation_mesh(void *p_user_data) { } void NavigationRegion3D::bake_navigation_mesh() { - ERR_FAIL_COND(bake_thread != NULL); + ERR_FAIL_COND(bake_thread != nullptr); BakeThreadsArgs *args = memnew(BakeThreadsArgs); args->nav_region = this; bake_thread = Thread::create(_bake_navigation_mesh, args); - ERR_FAIL_COND(bake_thread == NULL); + ERR_FAIL_COND(bake_thread == nullptr); } void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_nav_mesh) { set_navigation_mesh(p_nav_mesh); - bake_thread = NULL; + bake_thread = nullptr; } String NavigationRegion3D::get_configuration_warning() const { @@ -214,7 +215,7 @@ String NavigationRegion3D::get_configuration_warning() const { c = Object::cast_to<Node3D>(c->get_parent()); } - return TTR("NavigationRegion must be a child or grandchild to a Navigation node. It only provides navigation data."); + return TTR("NavigationRegion3D must be a child or grandchild to a Navigation3D node. It only provides navigation data."); } void NavigationRegion3D::_bind_methods() { @@ -244,15 +245,15 @@ NavigationRegion3D::NavigationRegion3D() { enabled = true; set_notify_transform(true); - region = NavigationServer::get_singleton()->region_create(); + region = NavigationServer3D::get_singleton()->region_create(); - navigation = NULL; - debug_view = NULL; - bake_thread = NULL; + navigation = nullptr; + debug_view = nullptr; + bake_thread = nullptr; } NavigationRegion3D::~NavigationRegion3D() { if (navmesh.is_valid()) navmesh->remove_change_receptor(this); - NavigationServer::get_singleton()->free(region); + NavigationServer3D::get_singleton()->free(region); } diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 7f444d59bf..0b7407e049 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -134,7 +134,7 @@ void Node3D::_notification(int p_what) { if (data.parent) data.C = data.parent->data.children.push_back(this); else - data.C = NULL; + data.C = nullptr; if (data.toplevel && !Engine::get_singleton()->is_editor_hint()) { @@ -158,14 +158,14 @@ void Node3D::_notification(int p_what) { get_tree()->xform_change_list.remove(&xform_change); if (data.C) data.parent->data.children.erase(data.C); - data.parent = NULL; - data.C = NULL; + data.parent = nullptr; + data.C = nullptr; data.toplevel_active = false; } break; case NOTIFICATION_ENTER_WORLD: { data.inside_world = true; - data.viewport = NULL; + data.viewport = nullptr; Node *parent = get_parent(); while (parent && !data.viewport) { data.viewport = Object::cast_to<Viewport>(parent); @@ -176,7 +176,7 @@ void Node3D::_notification(int p_what) { if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, NULL, 0); + get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, nullptr, 0); } #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && get_tree()->is_node_being_edited(this)) { @@ -208,10 +208,10 @@ void Node3D::_notification(int p_what) { if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, NULL, 0); + get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, nullptr, 0); } - data.viewport = NULL; + data.viewport = nullptr; data.inside_world = false; } break; @@ -829,7 +829,7 @@ Node3D::Node3D() : data.toplevel = false; data.toplevel_active = false; data.scale = Vector3(1, 1, 1); - data.viewport = NULL; + data.viewport = nullptr; data.inside_world = false; data.visible = true; data.disable_scale = false; @@ -840,8 +840,8 @@ Node3D::Node3D() : #endif data.notify_local_transform = false; data.notify_transform = false; - data.parent = NULL; - data.C = NULL; + data.parent = nullptr; + data.C = nullptr; } Node3D::~Node3D() { diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 2169f664ea..f06135f53d 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -229,7 +229,7 @@ void PathFollow3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { - path = NULL; + path = nullptr; } break; } } @@ -262,11 +262,11 @@ String PathFollow3D::get_configuration_warning() const { return String(); if (!Object::cast_to<Path3D>(get_parent())) { - return TTR("PathFollow only works when set as a child of a Path node."); + return TTR("PathFollow3D only works when set as a child of a Path3D node."); } else { Path3D *path = Object::cast_to<Path3D>(get_parent()); if (path->get_curve().is_valid() && !path->get_curve()->is_up_vector_enabled() && rotation_mode == ROTATION_ORIENTED) { - return TTR("PathFollow's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its parent Path's Curve resource."); + return TTR("PathFollow3D's ROTATION_ORIENTED requires \"Up Vector\" to be enabled in its parent Path3D's Curve resource."); } } @@ -409,7 +409,7 @@ PathFollow3D::PathFollow3D() { delta_offset = 0; h_offset = 0; v_offset = 0; - path = NULL; + path = nullptr; rotation_mode = ROTATION_XYZ; cubic = true; loop = true; diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index ce1643aa6c..2b6eb8ac8a 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -38,7 +38,7 @@ #include "core/rid.h" #include "scene/3d/collision_shape_3d.h" #include "scene/scene_string_names.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" #ifdef TOOLS_ENABLED #include "editor/plugins/node_3d_editor_plugin.h" @@ -61,7 +61,7 @@ float PhysicsBody3D::get_inverse_mass() const { void PhysicsBody3D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; - PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), p_layer); + PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), p_layer); } uint32_t PhysicsBody3D::get_collision_layer() const { @@ -72,7 +72,7 @@ uint32_t PhysicsBody3D::get_collision_layer() const { void PhysicsBody3D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; - PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), p_mask); + PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), p_mask); } uint32_t PhysicsBody3D::get_collision_mask() const { @@ -112,11 +112,11 @@ bool PhysicsBody3D::get_collision_layer_bit(int p_bit) const { Array PhysicsBody3D::get_collision_exceptions() { List<RID> exceptions; - PhysicsServer::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); + PhysicsServer3D::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions); Array ret; for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { RID body = E->get(); - ObjectID instance_id = PhysicsServer::get_singleton()->body_get_object_instance_id(body); + ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj); ret.append(physics_body); @@ -128,16 +128,16 @@ void PhysicsBody3D::add_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node); - ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); - PhysicsServer::get_singleton()->body_add_collision_exception(get_rid(), collision_object->get_rid()); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); + PhysicsServer3D::get_singleton()->body_add_collision_exception(get_rid(), collision_object->get_rid()); } void PhysicsBody3D::remove_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node); - ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); - PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid()); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); + PhysicsServer3D::get_singleton()->body_remove_collision_exception(get_rid(), collision_object->get_rid()); } void PhysicsBody3D::_set_layers(uint32_t p_mask) { @@ -171,8 +171,8 @@ void PhysicsBody3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); } -PhysicsBody3D::PhysicsBody3D(PhysicsServer::BodyMode p_mode) : - CollisionObject3D(PhysicsServer::get_singleton()->body_create(p_mode), false) { +PhysicsBody3D::PhysicsBody3D(PhysicsServer3D::BodyMode p_mode) : + CollisionObject3D(PhysicsServer3D::get_singleton()->body_create(p_mode), false) { collision_layer = 1; collision_mask = 1; @@ -200,13 +200,13 @@ Ref<PhysicsMaterial> StaticBody3D::get_physics_material_override() const { void StaticBody3D::set_constant_linear_velocity(const Vector3 &p_vel) { constant_linear_velocity = p_vel; - PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity); + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity); } void StaticBody3D::set_constant_angular_velocity(const Vector3 &p_vel) { constant_angular_velocity = p_vel; - PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity); + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity); } Vector3 StaticBody3D::get_constant_linear_velocity() const { @@ -238,18 +238,18 @@ void StaticBody3D::_bind_methods() { } StaticBody3D::StaticBody3D() : - PhysicsBody3D(PhysicsServer::BODY_MODE_STATIC) { + PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC) { } StaticBody3D::~StaticBody3D() {} void StaticBody3D::_reload_physics_characteristics() { if (physics_material_override.is_null()) { - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, 0); - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, 1); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1); } else { - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); } } @@ -372,9 +372,9 @@ struct _RigidBodyInOut { void RigidBody3D::_direct_state_changed(Object *p_state) { #ifdef DEBUG_ENABLED - state = Object::cast_to<PhysicsDirectBodyState>(p_state); + state = Object::cast_to<PhysicsDirectBodyState3D>(p_state); #else - state = (PhysicsDirectBodyState *)p_state; //trust it + state = (PhysicsDirectBodyState3D *)p_state; //trust it #endif set_ignore_transform_notification(true); @@ -406,7 +406,7 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { _RigidBodyInOut *toadd = (_RigidBodyInOut *)alloca(state->get_contact_count() * sizeof(_RigidBodyInOut)); int toadd_count = 0; //state->get_contact_count(); - RigidBody_RemoveAction *toremove = (RigidBody_RemoveAction *)alloca(rc * sizeof(RigidBody_RemoveAction)); + RigidBody3D_RemoveAction *toremove = (RigidBody3D_RemoveAction *)alloca(rc * sizeof(RigidBody3D_RemoveAction)); int toremove_count = 0; //put the ones to add @@ -474,7 +474,7 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { contact_monitor->locked = false; } - state = NULL; + state = nullptr; } void RigidBody3D::_notification(int p_what) { @@ -502,20 +502,20 @@ void RigidBody3D::set_mode(Mode p_mode) { case MODE_RIGID: { - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_RIGID); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_RIGID); } break; case MODE_STATIC: { - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_STATIC); } break; case MODE_CHARACTER: { - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_CHARACTER); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_CHARACTER); } break; case MODE_KINEMATIC: { - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_KINEMATIC); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_KINEMATIC); } break; } update_configuration_warning(); @@ -532,7 +532,7 @@ void RigidBody3D::set_mass(real_t p_mass) { mass = p_mass; _change_notify("mass"); _change_notify("weight"); - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass); } real_t RigidBody3D::get_mass() const { @@ -570,7 +570,7 @@ Ref<PhysicsMaterial> RigidBody3D::get_physics_material_override() const { void RigidBody3D::set_gravity_scale(real_t p_gravity_scale) { gravity_scale = p_gravity_scale; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); } real_t RigidBody3D::get_gravity_scale() const { @@ -581,7 +581,7 @@ void RigidBody3D::set_linear_damp(real_t p_linear_damp) { ERR_FAIL_COND(p_linear_damp < -1); linear_damp = p_linear_damp; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_LINEAR_DAMP, linear_damp); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp); } real_t RigidBody3D::get_linear_damp() const { @@ -592,7 +592,7 @@ void RigidBody3D::set_angular_damp(real_t p_angular_damp) { ERR_FAIL_COND(p_angular_damp < -1); angular_damp = p_angular_damp; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_ANGULAR_DAMP, angular_damp); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp); } real_t RigidBody3D::get_angular_damp() const { @@ -608,7 +608,7 @@ void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) { if (state) { set_linear_velocity(v); } else { - PhysicsServer::get_singleton()->body_set_axis_velocity(get_rid(), p_axis); + PhysicsServer3D::get_singleton()->body_set_axis_velocity(get_rid(), p_axis); linear_velocity = v; } } @@ -619,7 +619,7 @@ void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) { if (state) state->set_linear_velocity(linear_velocity); else - PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_LINEAR_VELOCITY, linear_velocity); + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); } Vector3 RigidBody3D::get_linear_velocity() const { @@ -633,7 +633,7 @@ void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) { if (state) state->set_angular_velocity(angular_velocity); else - PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); } Vector3 RigidBody3D::get_angular_velocity() const { @@ -646,7 +646,7 @@ void RigidBody3D::set_use_custom_integrator(bool p_enable) { return; custom_integrator = p_enable; - PhysicsServer::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); + PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); } bool RigidBody3D::is_using_custom_integrator() { @@ -656,13 +656,13 @@ bool RigidBody3D::is_using_custom_integrator() { void RigidBody3D::set_sleeping(bool p_sleeping) { sleeping = p_sleeping; - PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_SLEEPING, sleeping); + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping); } void RigidBody3D::set_can_sleep(bool p_active) { can_sleep = p_active; - PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_CAN_SLEEP, p_active); + PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active); } bool RigidBody3D::is_able_to_sleep() const { @@ -678,7 +678,7 @@ bool RigidBody3D::is_sleeping() const { void RigidBody3D::set_max_contacts_reported(int p_amount) { max_contacts_reported = p_amount; - PhysicsServer::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); + PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); } int RigidBody3D::get_max_contacts_reported() const { @@ -687,34 +687,34 @@ int RigidBody3D::get_max_contacts_reported() const { } void RigidBody3D::add_central_force(const Vector3 &p_force) { - PhysicsServer::get_singleton()->body_add_central_force(get_rid(), p_force); + PhysicsServer3D::get_singleton()->body_add_central_force(get_rid(), p_force); } void RigidBody3D::add_force(const Vector3 &p_force, const Vector3 &p_pos) { - PhysicsServer::get_singleton()->body_add_force(get_rid(), p_force, p_pos); + PhysicsServer3D::get_singleton()->body_add_force(get_rid(), p_force, p_pos); } void RigidBody3D::add_torque(const Vector3 &p_torque) { - PhysicsServer::get_singleton()->body_add_torque(get_rid(), p_torque); + PhysicsServer3D::get_singleton()->body_add_torque(get_rid(), p_torque); } void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) { - PhysicsServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); + PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); } void RigidBody3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { - PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); + PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); } void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) { - PhysicsServer::get_singleton()->body_apply_torque_impulse(get_rid(), p_impulse); + PhysicsServer3D::get_singleton()->body_apply_torque_impulse(get_rid(), p_impulse); } void RigidBody3D::set_use_continuous_collision_detection(bool p_enable) { ccd = p_enable; - PhysicsServer::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable); + PhysicsServer3D::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable); } bool RigidBody3D::is_using_continuous_collision_detection() const { @@ -744,7 +744,7 @@ void RigidBody3D::set_contact_monitor(bool p_enabled) { } memdelete(contact_monitor); - contact_monitor = NULL; + contact_monitor = nullptr; } else { contact_monitor = memnew(ContactMonitor); @@ -754,15 +754,15 @@ void RigidBody3D::set_contact_monitor(bool p_enabled) { bool RigidBody3D::is_contact_monitor_enabled() const { - return contact_monitor != NULL; + return contact_monitor != nullptr; } -void RigidBody3D::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock) { - PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock); +void RigidBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) { + PhysicsServer3D::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock); } -bool RigidBody3D::get_axis_lock(PhysicsServer::BodyAxis p_axis) const { - return PhysicsServer::get_singleton()->body_is_axis_locked(get_rid(), p_axis); +bool RigidBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const { + return PhysicsServer3D::get_singleton()->body_is_axis_locked(get_rid(), p_axis); } Array RigidBody3D::get_colliding_bodies() const { @@ -794,7 +794,7 @@ String RigidBody3D::get_configuration_warning() const { if (warning != String()) { warning += "\n\n"; } - warning += TTR("Size changes to RigidBody (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."); + warning += TTR("Size changes to RigidBody3D (in character or rigid modes) will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."); } return warning; @@ -864,7 +864,7 @@ void RigidBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody3D::get_colliding_bodies); - BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectBodyState"))); + BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectBodyState3D"))); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass"); @@ -878,12 +878,12 @@ void RigidBody3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleeping", "is_sleeping"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), "set_can_sleep", "is_able_to_sleep"); ADD_GROUP("Axis Lock", "axis_lock_"); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_x"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_X); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_y"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Y); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_z"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Z); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_x"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_X); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_y"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_Y); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_ANGULAR_Z); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_linear_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_x"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_X); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_y"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_Y); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "axis_lock_angular_z"), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_ANGULAR_Z); ADD_GROUP("Linear", "linear_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater"), "set_linear_damp", "get_linear_damp"); @@ -904,13 +904,13 @@ void RigidBody3D::_bind_methods() { } RigidBody3D::RigidBody3D() : - PhysicsBody3D(PhysicsServer::BODY_MODE_RIGID) { + PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) { mode = MODE_RIGID; mass = 1; max_contacts_reported = 0; - state = NULL; + state = nullptr; gravity_scale = 1; linear_damp = -1; @@ -921,10 +921,10 @@ RigidBody3D::RigidBody3D() : ccd = false; custom_integrator = false; - contact_monitor = NULL; + contact_monitor = nullptr; can_sleep = true; - PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } RigidBody3D::~RigidBody3D() { @@ -935,11 +935,11 @@ RigidBody3D::~RigidBody3D() { void RigidBody3D::_reload_physics_characteristics() { if (physics_material_override.is_null()) { - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, 0); - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, 1); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1); } else { - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material_override->computed_bounce()); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, physics_material_override->computed_friction()); } } @@ -974,8 +974,8 @@ Vector3 KinematicBody3D::get_angular_velocity() const { bool KinematicBody3D::move_and_collide(const Vector3 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) { Transform gt = get_global_transform(); - PhysicsServer::MotionResult result; - bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, &result, p_exclude_raycast_shapes); + PhysicsServer3D::MotionResult result; + bool colliding = PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, &result, p_exclude_raycast_shapes); if (colliding) { r_collision.collider_metadata = result.collider_metadata; @@ -1168,17 +1168,17 @@ bool KinematicBody3D::test_move(const Transform &p_from, const Vector3 &p_motion ERR_FAIL_COND_V(!is_inside_tree(), false); - return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia); + return PhysicsServer3D::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, p_infinite_inertia); } bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision) { - PhysicsServer::SeparationResult sep_res[8]; //max 8 rays + PhysicsServer3D::SeparationResult sep_res[8]; //max 8 rays Transform gt = get_global_transform(); Vector3 recover; - int hits = PhysicsServer::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin); + int hits = PhysicsServer3D::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin); int deepest = -1; float deepest_depth; for (int i = 0; i < hits; i++) { @@ -1208,18 +1208,18 @@ bool KinematicBody3D::separate_raycast_shapes(bool p_infinite_inertia, Collision } } -void KinematicBody3D::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock) { - PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock); +void KinematicBody3D::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock) { + PhysicsServer3D::get_singleton()->body_set_axis_lock(get_rid(), p_axis, p_lock); } -bool KinematicBody3D::get_axis_lock(PhysicsServer::BodyAxis p_axis) const { - return PhysicsServer::get_singleton()->body_is_axis_locked(get_rid(), p_axis); +bool KinematicBody3D::get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const { + return PhysicsServer3D::get_singleton()->body_is_axis_locked(get_rid(), p_axis); } void KinematicBody3D::set_safe_margin(float p_margin) { margin = p_margin; - PhysicsServer::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin); + PhysicsServer3D::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin); } float KinematicBody3D::get_safe_margin() const { @@ -1289,18 +1289,18 @@ void KinematicBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody3D::get_slide_count); ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody3D::_get_slide_collision); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_x", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_X); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_y", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Y); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_z", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer::BODY_AXIS_LINEAR_Z); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_x", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_X); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_y", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Y); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "move_lock_z", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_axis_lock", "get_axis_lock", PhysicsServer3D::BODY_AXIS_LINEAR_Z); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin"); } void KinematicBody3D::_direct_state_changed(Object *p_state) { #ifdef DEBUG_ENABLED - PhysicsDirectBodyState *state = Object::cast_to<PhysicsDirectBodyState>(p_state); + PhysicsDirectBodyState3D *state = Object::cast_to<PhysicsDirectBodyState3D>(p_state); #else - PhysicsDirectBodyState *state = (PhysicsDirectBodyState *)p_state; //trust it + PhysicsDirectBodyState3D *state = (PhysicsDirectBodyState3D *)p_state; //trust it #endif linear_velocity = state->get_linear_velocity(); @@ -1308,7 +1308,7 @@ void KinematicBody3D::_direct_state_changed(Object *p_state) { } KinematicBody3D::KinematicBody3D() : - PhysicsBody3D(PhysicsServer::BODY_MODE_KINEMATIC) { + PhysicsBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) { margin = 0.001; locked_axis = 0; @@ -1316,17 +1316,17 @@ KinematicBody3D::KinematicBody3D() : on_ceiling = false; on_wall = false; - PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); } KinematicBody3D::~KinematicBody3D() { if (motion_cache.is_valid()) { - motion_cache->owner = NULL; + motion_cache->owner = nullptr; } for (int i = 0; i < slide_colliders.size(); i++) { if (slide_colliders[i].is_valid()) { - slide_colliders.write[i]->owner = NULL; + slide_colliders.write[i]->owner = nullptr; } } } @@ -1346,7 +1346,7 @@ Vector3 KinematicCollision3D::get_remainder() const { return collision.remainder; } Object *KinematicCollision3D::get_local_shape() const { - if (!owner) return NULL; + if (!owner) return nullptr; uint32_t ownerid = owner->shape_find_owner(collision.local_shape); return owner->shape_owner_get_owner(ownerid); } @@ -1357,7 +1357,7 @@ Object *KinematicCollision3D::get_collider() const { return ObjectDB::get_instance(collision.collider); } - return NULL; + return nullptr; } ObjectID KinematicCollision3D::get_collider_id() const { @@ -1374,7 +1374,7 @@ Object *KinematicCollision3D::get_collider_shape() const { } } - return NULL; + return nullptr; } int KinematicCollision3D::get_collider_shape_index() const { @@ -1420,7 +1420,7 @@ KinematicCollision3D::KinematicCollision3D() { collision.collider_shape = 0; collision.local_shape = 0; - owner = NULL; + owner = nullptr; } /////////////////////////////////////// @@ -1437,11 +1437,11 @@ void PhysicalBone3D::JointData::_get_property_list(List<PropertyInfo> *p_list) c } void PhysicalBone3D::apply_central_impulse(const Vector3 &p_impulse) { - PhysicsServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); + PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); } void PhysicalBone3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { - PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); + PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); } void PhysicalBone3D::reset_physics_simulation_state() { @@ -1470,17 +1470,17 @@ bool PhysicalBone3D::PinJointData::_set(const StringName &p_name, const Variant if ("joint_constraints/bias" == p_name) { bias = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PIN_JOINT_BIAS, bias); + PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_BIAS, bias); } else if ("joint_constraints/damping" == p_name) { damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PIN_JOINT_DAMPING, damping); + PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_DAMPING, damping); } else if ("joint_constraints/impulse_clamp" == p_name) { impulse_clamp = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp); + PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, impulse_clamp); } else { return false; @@ -1523,27 +1523,27 @@ bool PhysicalBone3D::ConeJointData::_set(const StringName &p_name, const Variant if ("joint_constraints/swing_span" == p_name) { swing_span = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN, swing_span); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, swing_span); } else if ("joint_constraints/twist_span" == p_name) { twist_span = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN, twist_span); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, twist_span); } else if ("joint_constraints/bias" == p_name) { bias = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_BIAS, bias); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, bias); } else if ("joint_constraints/softness" == p_name) { softness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_SOFTNESS, softness); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, softness); } else if ("joint_constraints/relaxation" == p_name) { relaxation = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::CONE_TWIST_JOINT_RELAXATION, relaxation); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, relaxation); } else { return false; @@ -1592,32 +1592,32 @@ bool PhysicalBone3D::HingeJointData::_set(const StringName &p_name, const Varian if ("joint_constraints/angular_limit_enabled" == p_name) { angular_limit_enabled = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_flag(j, PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled); + PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, angular_limit_enabled); } else if ("joint_constraints/angular_limit_upper" == p_name) { angular_limit_upper = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, angular_limit_upper); } else if ("joint_constraints/angular_limit_lower" == p_name) { angular_limit_lower = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, angular_limit_lower); } else if ("joint_constraints/angular_limit_bias" == p_name) { angular_limit_bias = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, angular_limit_bias); } else if ("joint_constraints/angular_limit_softness" == p_name) { angular_limit_softness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, angular_limit_softness); } else if ("joint_constraints/angular_limit_relaxation" == p_name) { angular_limit_relaxation = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, angular_limit_relaxation); } else { return false; @@ -1669,52 +1669,52 @@ bool PhysicalBone3D::SliderJointData::_set(const StringName &p_name, const Varia if ("joint_constraints/linear_limit_upper" == p_name) { linear_limit_upper = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, linear_limit_upper); } else if ("joint_constraints/linear_limit_lower" == p_name) { linear_limit_lower = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, linear_limit_lower); } else if ("joint_constraints/linear_limit_softness" == p_name) { linear_limit_softness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, linear_limit_softness); } else if ("joint_constraints/linear_limit_restitution" == p_name) { linear_limit_restitution = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, linear_limit_restitution); } else if ("joint_constraints/linear_limit_damping" == p_name) { linear_limit_damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, linear_limit_restitution); } else if ("joint_constraints/angular_limit_upper" == p_name) { angular_limit_upper = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, angular_limit_upper); } else if ("joint_constraints/angular_limit_lower" == p_name) { angular_limit_lower = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, angular_limit_lower); } else if ("joint_constraints/angular_limit_softness" == p_name) { angular_limit_softness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness); } else if ("joint_constraints/angular_limit_restitution" == p_name) { angular_limit_restitution = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, angular_limit_softness); } else if ("joint_constraints/angular_limit_damping" == p_name) { angular_limit_damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, angular_limit_damping); } else { return false; @@ -1797,107 +1797,107 @@ bool PhysicalBone3D::SixDOFJointData::_set(const StringName &p_name, const Varia if ("linear_limit_enabled" == var_name) { axis_data[axis].linear_limit_enabled = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, axis_data[axis].linear_limit_enabled); } else if ("linear_limit_upper" == var_name) { axis_data[axis].linear_limit_upper = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, axis_data[axis].linear_limit_upper); } else if ("linear_limit_lower" == var_name) { axis_data[axis].linear_limit_lower = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, axis_data[axis].linear_limit_lower); } else if ("linear_limit_softness" == var_name) { axis_data[axis].linear_limit_softness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, axis_data[axis].linear_limit_softness); } else if ("linear_spring_enabled" == var_name) { axis_data[axis].linear_spring_enabled = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, axis_data[axis].linear_spring_enabled); } else if ("linear_spring_stiffness" == var_name) { axis_data[axis].linear_spring_stiffness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, axis_data[axis].linear_spring_stiffness); } else if ("linear_spring_damping" == var_name) { axis_data[axis].linear_spring_damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, axis_data[axis].linear_spring_damping); } else if ("linear_equilibrium_point" == var_name) { axis_data[axis].linear_equilibrium_point = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].linear_equilibrium_point); } else if ("linear_restitution" == var_name) { axis_data[axis].linear_restitution = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, axis_data[axis].linear_restitution); } else if ("linear_damping" == var_name) { axis_data[axis].linear_damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, axis_data[axis].linear_damping); } else if ("angular_limit_enabled" == var_name) { axis_data[axis].angular_limit_enabled = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, axis_data[axis].angular_limit_enabled); } else if ("angular_limit_upper" == var_name) { axis_data[axis].angular_limit_upper = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, axis_data[axis].angular_limit_upper); } else if ("angular_limit_lower" == var_name) { axis_data[axis].angular_limit_lower = Math::deg2rad(real_t(p_value)); if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, axis_data[axis].angular_limit_lower); } else if ("angular_limit_softness" == var_name) { axis_data[axis].angular_limit_softness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, axis_data[axis].angular_limit_softness); } else if ("angular_restitution" == var_name) { axis_data[axis].angular_restitution = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, axis_data[axis].angular_restitution); } else if ("angular_damping" == var_name) { axis_data[axis].angular_damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, axis_data[axis].angular_damping); } else if ("erp" == var_name) { axis_data[axis].erp = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, axis_data[axis].erp); } else if ("angular_spring_enabled" == var_name) { axis_data[axis].angular_spring_enabled = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, axis_data[axis].angular_spring_enabled); } else if ("angular_spring_stiffness" == var_name) { axis_data[axis].angular_spring_stiffness = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, axis_data[axis].angular_spring_stiffness); } else if ("angular_spring_damping" == var_name) { axis_data[axis].angular_spring_damping = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, axis_data[axis].angular_spring_damping); } else if ("angular_equilibrium_point" == var_name) { axis_data[axis].angular_equilibrium_point = p_value; if (j.is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, axis, PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, axis_data[axis].angular_equilibrium_point); } else { return false; @@ -2078,9 +2078,9 @@ void PhysicalBone3D::_notification(int p_what) { parent_skeleton->unbind_physical_bone_from_bone(bone_id); } } - parent_skeleton = NULL; + parent_skeleton = nullptr; if (joint.is_valid()) { - PhysicsServer::get_singleton()->free(joint); + PhysicsServer3D::get_singleton()->free(joint); joint = RID(); } break; @@ -2101,12 +2101,12 @@ void PhysicalBone3D::_direct_state_changed(Object *p_state) { /// Update bone transform - PhysicsDirectBodyState *state; + PhysicsDirectBodyState3D *state; #ifdef DEBUG_ENABLED - state = Object::cast_to<PhysicsDirectBodyState>(p_state); + state = Object::cast_to<PhysicsDirectBodyState3D>(p_state); #else - state = (PhysicsDirectBodyState *)p_state; //trust it + state = (PhysicsDirectBodyState3D *)p_state; //trust it #endif Transform global_transform(state->get_transform()); @@ -2181,7 +2181,7 @@ void PhysicalBone3D::_bind_methods() { Skeleton3D *PhysicalBone3D::find_skeleton_parent(Node *p_parent) { if (!p_parent) { - return NULL; + return nullptr; } Skeleton3D *s = Object::cast_to<Skeleton3D>(p_parent); return s ? s : find_skeleton_parent(p_parent->get_parent()); @@ -2197,7 +2197,7 @@ void PhysicalBone3D::_fix_joint_offset() { void PhysicalBone3D::_reload_joint() { if (joint.is_valid()) { - PhysicsServer::get_singleton()->free(joint); + PhysicsServer3D::get_singleton()->free(joint); joint = RID(); } @@ -2217,78 +2217,78 @@ void PhysicalBone3D::_reload_joint() { switch (get_joint_type()) { case JOINT_TYPE_PIN: { - joint = PhysicsServer::get_singleton()->joint_create_pin(body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin); + joint = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a.origin, get_rid(), joint_offset.origin); const PinJointData *pjd(static_cast<const PinJointData *>(joint_data)); - PhysicsServer::get_singleton()->pin_joint_set_param(joint, PhysicsServer::PIN_JOINT_BIAS, pjd->bias); - PhysicsServer::get_singleton()->pin_joint_set_param(joint, PhysicsServer::PIN_JOINT_DAMPING, pjd->damping); - PhysicsServer::get_singleton()->pin_joint_set_param(joint, PhysicsServer::PIN_JOINT_IMPULSE_CLAMP, pjd->impulse_clamp); + PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_BIAS, pjd->bias); + PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_DAMPING, pjd->damping); + PhysicsServer3D::get_singleton()->pin_joint_set_param(joint, PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP, pjd->impulse_clamp); } break; case JOINT_TYPE_CONE: { - joint = PhysicsServer::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, get_rid(), joint_offset); + joint = PhysicsServer3D::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, get_rid(), joint_offset); const ConeJointData *cjd(static_cast<const ConeJointData *>(joint_data)); - PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span); - PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN, cjd->twist_span); - PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_BIAS, cjd->bias); - PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_SOFTNESS, cjd->softness); - PhysicsServer::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer::CONE_TWIST_JOINT_RELAXATION, cjd->relaxation); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN, cjd->swing_span); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN, cjd->twist_span); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_BIAS, cjd->bias); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS, cjd->softness); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(joint, PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION, cjd->relaxation); } break; case JOINT_TYPE_HINGE: { - joint = PhysicsServer::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, get_rid(), joint_offset); + joint = PhysicsServer3D::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, get_rid(), joint_offset); const HingeJointData *hjd(static_cast<const HingeJointData *>(joint_data)); - PhysicsServer::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled); - PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_UPPER, hjd->angular_limit_upper); - PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_LOWER, hjd->angular_limit_lower); - PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_BIAS, hjd->angular_limit_bias); - PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS, hjd->angular_limit_softness); - PhysicsServer::get_singleton()->hinge_joint_set_param(joint, PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION, hjd->angular_limit_relaxation); + PhysicsServer3D::get_singleton()->hinge_joint_set_flag(joint, PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, hjd->angular_limit_enabled); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, hjd->angular_limit_upper); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, hjd->angular_limit_lower); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, hjd->angular_limit_bias); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, hjd->angular_limit_softness); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(joint, PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, hjd->angular_limit_relaxation); } break; case JOINT_TYPE_SLIDER: { - joint = PhysicsServer::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, get_rid(), joint_offset); + joint = PhysicsServer3D::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, get_rid(), joint_offset); const SliderJointData *sjd(static_cast<const SliderJointData *>(joint_data)); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER, sjd->linear_limit_lower); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, sjd->linear_limit_softness); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, sjd->linear_limit_restitution); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, sjd->linear_limit_restitution); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, sjd->angular_limit_upper); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, sjd->angular_limit_lower); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness); - PhysicsServer::get_singleton()->slider_joint_set_param(joint, PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, sjd->angular_limit_damping); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, sjd->linear_limit_upper); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, sjd->linear_limit_lower); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, sjd->linear_limit_softness); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, sjd->linear_limit_restitution); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, sjd->linear_limit_restitution); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, sjd->angular_limit_upper); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, sjd->angular_limit_lower); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, sjd->angular_limit_softness); + PhysicsServer3D::get_singleton()->slider_joint_set_param(joint, PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, sjd->angular_limit_damping); } break; case JOINT_TYPE_6DOF: { - joint = PhysicsServer::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, get_rid(), joint_offset); + joint = PhysicsServer3D::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, get_rid(), joint_offset); const SixDOFJointData *g6dofjd(static_cast<const SixDOFJointData *>(joint_data)); for (int axis = 0; axis < 3; ++axis) { - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, g6dofjd->axis_data[axis].linear_limit_enabled); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT, g6dofjd->axis_data[axis].linear_limit_upper); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT, g6dofjd->axis_data[axis].linear_limit_lower); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].linear_limit_softness); - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, g6dofjd->axis_data[axis].linear_spring_enabled); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].linear_spring_stiffness); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING, g6dofjd->axis_data[axis].linear_spring_damping); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].linear_equilibrium_point); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION, g6dofjd->axis_data[axis].linear_restitution); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING, g6dofjd->axis_data[axis].linear_damping); - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, g6dofjd->axis_data[axis].angular_limit_enabled); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, g6dofjd->axis_data[axis].angular_limit_upper); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, g6dofjd->axis_data[axis].angular_limit_lower); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].angular_limit_softness); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION, g6dofjd->axis_data[axis].angular_restitution); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING, g6dofjd->axis_data[axis].angular_damping); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_ERP, g6dofjd->axis_data[axis].erp); - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, g6dofjd->axis_data[axis].angular_spring_enabled); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].angular_spring_stiffness); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, g6dofjd->axis_data[axis].angular_spring_damping); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].angular_equilibrium_point); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, g6dofjd->axis_data[axis].linear_limit_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, g6dofjd->axis_data[axis].linear_limit_upper); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, g6dofjd->axis_data[axis].linear_limit_lower); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].linear_limit_softness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, g6dofjd->axis_data[axis].linear_spring_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].linear_spring_stiffness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, g6dofjd->axis_data[axis].linear_spring_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].linear_equilibrium_point); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, g6dofjd->axis_data[axis].linear_restitution); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, g6dofjd->axis_data[axis].linear_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, g6dofjd->axis_data[axis].angular_limit_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, g6dofjd->axis_data[axis].angular_limit_upper); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, g6dofjd->axis_data[axis].angular_limit_lower); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, g6dofjd->axis_data[axis].angular_limit_softness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, g6dofjd->axis_data[axis].angular_restitution); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, g6dofjd->axis_data[axis].angular_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, g6dofjd->axis_data[axis].erp); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, g6dofjd->axis_data[axis].angular_spring_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, g6dofjd->axis_data[axis].angular_spring_stiffness); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, g6dofjd->axis_data[axis].angular_spring_damping); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(joint, static_cast<Vector3::Axis>(axis), PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, g6dofjd->axis_data[axis].angular_equilibrium_point); } } break; @@ -2333,7 +2333,7 @@ void PhysicalBone3D::set_joint_type(JointType p_joint_type) { if (joint_data) memdelete(joint_data); - joint_data = NULL; + joint_data = nullptr; switch (p_joint_type) { case JOINT_TYPE_PIN: joint_data = memnew(PinJointData); @@ -2441,7 +2441,7 @@ void PhysicalBone3D::set_mass(real_t p_mass) { ERR_FAIL_COND(p_mass <= 0); mass = p_mass; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass); } real_t PhysicalBone3D::get_mass() const { @@ -2464,7 +2464,7 @@ void PhysicalBone3D::set_friction(real_t p_friction) { ERR_FAIL_COND(p_friction < 0 || p_friction > 1); friction = p_friction; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, friction); } real_t PhysicalBone3D::get_friction() const { @@ -2477,7 +2477,7 @@ void PhysicalBone3D::set_bounce(real_t p_bounce) { ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1); bounce = p_bounce; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, bounce); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, bounce); } real_t PhysicalBone3D::get_bounce() const { @@ -2488,7 +2488,7 @@ real_t PhysicalBone3D::get_bounce() const { void PhysicalBone3D::set_gravity_scale(real_t p_gravity_scale) { gravity_scale = p_gravity_scale; - PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale); + PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); } real_t PhysicalBone3D::get_gravity_scale() const { @@ -2497,12 +2497,12 @@ real_t PhysicalBone3D::get_gravity_scale() const { } PhysicalBone3D::PhysicalBone3D() : - PhysicsBody3D(PhysicsServer::BODY_MODE_STATIC), + PhysicsBody3D(PhysicsServer3D::BODY_MODE_STATIC), #ifdef TOOLS_ENABLED gizmo_move_joint(false), #endif - joint_data(NULL), - parent_skeleton(NULL), + joint_data(nullptr), + parent_skeleton(nullptr), simulate_physics(false), _internal_simulate_physics(false), bone_id(-1), @@ -2566,10 +2566,10 @@ void PhysicalBone3D::_start_physics_simulation() { return; } reset_to_rest_position(); - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_RIGID); - PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); - PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); - PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_RIGID); + PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); + PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); + PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); set_as_toplevel(true); _internal_simulate_physics = true; } @@ -2579,16 +2579,16 @@ void PhysicalBone3D::_stop_physics_simulation() { return; } if (parent_skeleton->get_animate_physical_bones()) { - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_KINEMATIC); - PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); - PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_KINEMATIC); + PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); + PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); } else { - PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_STATIC); - PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), 0); - PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), 0); + PhysicsServer3D::get_singleton()->body_set_mode(get_rid(), PhysicsServer3D::BODY_MODE_STATIC); + PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), 0); + PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), 0); } if (_internal_simulate_physics) { - PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, ""); + PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), nullptr, ""); parent_skeleton->set_bone_global_pose_override(bone_id, Transform(), 0.0, false); set_as_toplevel(false); _internal_simulate_physics = false; diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index e7a403122b..bf7854b68d 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -34,7 +34,7 @@ #include "core/vset.h" #include "scene/3d/collision_object_3d.h" #include "scene/resources/physics_material.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" #include "skeleton_3d.h" class PhysicsBody3D : public CollisionObject3D { @@ -49,7 +49,7 @@ class PhysicsBody3D : public CollisionObject3D { protected: static void _bind_methods(); - PhysicsBody3D(PhysicsServer::BodyMode p_mode); + PhysicsBody3D(PhysicsServer3D::BodyMode p_mode); public: virtual Vector3 get_linear_velocity() const; @@ -118,7 +118,7 @@ public: protected: bool can_sleep; - PhysicsDirectBodyState *state; + PhysicsDirectBodyState3D *state; Mode mode; real_t mass; @@ -156,7 +156,7 @@ protected: tagged = false; } }; - struct RigidBody_RemoveAction { + struct RigidBody3D_RemoveAction { ObjectID body_id; ShapePair pair; @@ -234,8 +234,8 @@ public: void set_use_continuous_collision_detection(bool p_enable); bool is_using_continuous_collision_detection() const; - void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock); - bool get_axis_lock(PhysicsServer::BodyAxis p_axis) const; + void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock); + bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const; Array get_colliding_bodies() const; @@ -296,7 +296,7 @@ private: Vector<Ref<KinematicCollision3D>> slide_colliders; Ref<KinematicCollision3D> motion_cache; - _FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const; + _FORCE_INLINE_ bool _ignores_mode(PhysicsServer3D::BodyMode) const; Ref<KinematicCollision3D> _move(const Vector3 &p_motion, bool p_infinite_inertia = true, bool p_exclude_raycast_shapes = true, bool p_test_only = false); Ref<KinematicCollision3D> _get_slide_collision(int p_bounce); @@ -316,8 +316,8 @@ public: bool separate_raycast_shapes(bool p_infinite_inertia, Collision &r_collision); - void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool p_lock); - bool get_axis_lock(PhysicsServer::BodyAxis p_axis) const; + void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool p_lock); + bool get_axis_lock(PhysicsServer3D::BodyAxis p_axis) const; void set_safe_margin(float p_margin); float get_safe_margin() const; @@ -381,7 +381,7 @@ public: struct JointData { virtual JointType get_joint_type() { return JOINT_TYPE_NONE; } - /// "j" is used to set the parameter inside the PhysicsServer + /// "j" is used to set the parameter inside the PhysicsServer3D virtual bool _set(const StringName &p_name, const Variant &p_value, RID j = RID()); virtual bool _get(const StringName &p_name, Variant &r_ret) const; virtual void _get_property_list(List<PropertyInfo> *p_list) const; diff --git a/scene/3d/physics_joint_3d.cpp b/scene/3d/physics_joint_3d.cpp index dd7868cb38..591c17a91e 100644 --- a/scene/3d/physics_joint_3d.cpp +++ b/scene/3d/physics_joint_3d.cpp @@ -34,9 +34,9 @@ void Joint3D::_update_joint(bool p_only_free) { if (joint.is_valid()) { if (ba.is_valid() && bb.is_valid()) - PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb); + PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb); - PhysicsServer::get_singleton()->free(joint); + PhysicsServer3D::get_singleton()->free(joint); joint = RID(); ba = RID(); bb = RID(); @@ -45,8 +45,8 @@ void Joint3D::_update_joint(bool p_only_free) { if (p_only_free || !is_inside_tree()) return; - Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL; - Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL; + Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)nullptr; + Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)nullptr; PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a); PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b); @@ -62,13 +62,13 @@ void Joint3D::_update_joint(bool p_only_free) { if (!joint.is_valid()) return; - PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority); + PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority); ba = body_a->get_rid(); if (body_b) bb = body_b->get_rid(); - PhysicsServer::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); + PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision); } void Joint3D::set_node_a(const NodePath &p_node_a) { @@ -101,7 +101,7 @@ void Joint3D::set_solver_priority(int p_priority) { solver_priority = p_priority; if (joint.is_valid()) - PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority); + PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority); } int Joint3D::get_solver_priority() const { @@ -186,7 +186,7 @@ void PinJoint3D::set_param(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, 3); params[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer::PinJointParam(p_param), p_value); + PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value); } float PinJoint3D::get_param(Param p_param) const { @@ -205,9 +205,9 @@ RID PinJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) { else local_b = pinpos; - RID j = PhysicsServer::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); + RID j = PhysicsServer3D::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); for (int i = 0; i < 3; i++) { - PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PinJointParam(i), params[i]); + PhysicsServer3D::get_singleton()->pin_joint_set_param(j, PhysicsServer3D::PinJointParam(i), params[i]); } return j; } @@ -290,7 +290,7 @@ void HingeJoint3D::set_param(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); params[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer::HingeJointParam(p_param), p_value); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value); update_gizmo(); } @@ -305,7 +305,7 @@ void HingeJoint3D::set_flag(Flag p_flag, bool p_value) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags[p_flag] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer::HingeJointFlag(p_flag), p_value); + PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value); update_gizmo(); } @@ -331,13 +331,13 @@ RID HingeJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b) local_b.orthonormalize(); - RID j = PhysicsServer::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); + RID j = PhysicsServer3D::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); for (int i = 0; i < PARAM_MAX; i++) { - PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HingeJointParam(i), params[i]); + PhysicsServer3D::get_singleton()->hinge_joint_set_param(j, PhysicsServer3D::HingeJointParam(i), params[i]); } for (int i = 0; i < FLAG_MAX; i++) { set_flag(Flag(i), flags[i]); - PhysicsServer::get_singleton()->hinge_joint_set_flag(j, PhysicsServer::HingeJointFlag(i), flags[i]); + PhysicsServer3D::get_singleton()->hinge_joint_set_flag(j, PhysicsServer3D::HingeJointFlag(i), flags[i]); } return j; } @@ -448,7 +448,7 @@ void SliderJoint3D::set_param(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); params[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer::SliderJointParam(p_param), p_value); + PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value); update_gizmo(); } float SliderJoint3D::get_param(Param p_param) const { @@ -473,9 +473,9 @@ RID SliderJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *body_b local_b.orthonormalize(); - RID j = PhysicsServer::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); + RID j = PhysicsServer3D::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); for (int i = 0; i < PARAM_MAX; i++) { - PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SliderJointParam(i), params[i]); + PhysicsServer3D::get_singleton()->slider_joint_set_param(j, PhysicsServer3D::SliderJointParam(i), params[i]); } return j; @@ -561,7 +561,7 @@ void ConeTwistJoint3D::set_param(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); params[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer::ConeTwistJointParam(p_param), p_value); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value); update_gizmo(); } @@ -590,9 +590,9 @@ RID ConeTwistJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *bod local_b.orthonormalize(); - RID j = PhysicsServer::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); + RID j = PhysicsServer3D::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); for (int i = 0; i < PARAM_MAX; i++) { - PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::ConeTwistJointParam(i), params[i]); + PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer3D::ConeTwistJointParam(i), params[i]); } return j; @@ -832,7 +832,7 @@ void Generic6DOFJoint3D::set_param_x(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); params_x[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisParam(p_param), p_value); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value); update_gizmo(); } @@ -847,7 +847,7 @@ void Generic6DOFJoint3D::set_param_y(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); params_y[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisParam(p_param), p_value); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value); update_gizmo(); } float Generic6DOFJoint3D::get_param_y(Param p_param) const { @@ -861,7 +861,7 @@ void Generic6DOFJoint3D::set_param_z(Param p_param, float p_value) { ERR_FAIL_INDEX(p_param, PARAM_MAX); params_z[p_param] = p_value; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisParam(p_param), p_value); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value); update_gizmo(); } float Generic6DOFJoint3D::get_param_z(Param p_param) const { @@ -875,7 +875,7 @@ void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags_x[p_flag] = p_enabled; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled); update_gizmo(); } bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const { @@ -889,7 +889,7 @@ void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags_y[p_flag] = p_enabled; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled); update_gizmo(); } bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const { @@ -903,7 +903,7 @@ void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags_z[p_flag] = p_enabled; if (get_joint().is_valid()) - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled); update_gizmo(); } bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const { @@ -915,7 +915,7 @@ bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const { void Generic6DOFJoint3D::set_precision(int p_precision) { precision = p_precision; - PhysicsServer::get_singleton()->generic_6dof_joint_set_precision( + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_precision( get_joint(), precision); } @@ -939,16 +939,16 @@ RID Generic6DOFJoint3D::_configure_joint(PhysicsBody3D *body_a, PhysicsBody3D *b local_b.orthonormalize(); - RID j = PhysicsServer::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); + RID j = PhysicsServer3D::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b); for (int i = 0; i < PARAM_MAX; i++) { - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisParam(i), params_x[i]); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisParam(i), params_y[i]); - PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisParam(i), params_z[i]); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(i), params_x[i]); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(i), params_y[i]); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(i), params_z[i]); } for (int i = 0; i < FLAG_MAX; i++) { - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisFlag(i), flags_x[i]); - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisFlag(i), flags_y[i]); - PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisFlag(i), flags_z[i]); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_x[i]); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_y[i]); + PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_z[i]); } return j; diff --git a/scene/3d/physics_joint_3d.h b/scene/3d/physics_joint_3d.h index b7c131c666..ce0c7af5d1 100644 --- a/scene/3d/physics_joint_3d.h +++ b/scene/3d/physics_joint_3d.h @@ -82,9 +82,9 @@ class PinJoint3D : public Joint3D { public: enum Param { - PARAM_BIAS = PhysicsServer::PIN_JOINT_BIAS, - PARAM_DAMPING = PhysicsServer::PIN_JOINT_DAMPING, - PARAM_IMPULSE_CLAMP = PhysicsServer::PIN_JOINT_IMPULSE_CLAMP + PARAM_BIAS = PhysicsServer3D::PIN_JOINT_BIAS, + PARAM_DAMPING = PhysicsServer3D::PIN_JOINT_DAMPING, + PARAM_IMPULSE_CLAMP = PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP }; protected: @@ -107,21 +107,21 @@ class HingeJoint3D : public Joint3D { public: enum Param { - PARAM_BIAS = PhysicsServer::HINGE_JOINT_BIAS, - PARAM_LIMIT_UPPER = PhysicsServer::HINGE_JOINT_LIMIT_UPPER, - PARAM_LIMIT_LOWER = PhysicsServer::HINGE_JOINT_LIMIT_LOWER, - PARAM_LIMIT_BIAS = PhysicsServer::HINGE_JOINT_LIMIT_BIAS, - PARAM_LIMIT_SOFTNESS = PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS, - PARAM_LIMIT_RELAXATION = PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION, - PARAM_MOTOR_TARGET_VELOCITY = PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY, - PARAM_MOTOR_MAX_IMPULSE = PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE, - PARAM_MAX = PhysicsServer::HINGE_JOINT_MAX + PARAM_BIAS = PhysicsServer3D::HINGE_JOINT_BIAS, + PARAM_LIMIT_UPPER = PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER, + PARAM_LIMIT_LOWER = PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER, + PARAM_LIMIT_BIAS = PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS, + PARAM_LIMIT_SOFTNESS = PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS, + PARAM_LIMIT_RELAXATION = PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION, + PARAM_MOTOR_TARGET_VELOCITY = PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY, + PARAM_MOTOR_MAX_IMPULSE = PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE, + PARAM_MAX = PhysicsServer3D::HINGE_JOINT_MAX }; enum Flag { - FLAG_USE_LIMIT = PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT, - FLAG_ENABLE_MOTOR = PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR, - FLAG_MAX = PhysicsServer::HINGE_JOINT_FLAG_MAX + FLAG_USE_LIMIT = PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT, + FLAG_ENABLE_MOTOR = PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR, + FLAG_MAX = PhysicsServer3D::HINGE_JOINT_FLAG_MAX }; protected: @@ -155,30 +155,30 @@ class SliderJoint3D : public Joint3D { public: enum Param { - PARAM_LINEAR_LIMIT_UPPER = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER, - PARAM_LINEAR_LIMIT_LOWER = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER, - PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, - PARAM_LINEAR_LIMIT_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, - PARAM_LINEAR_LIMIT_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, - PARAM_LINEAR_MOTION_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS, - PARAM_LINEAR_MOTION_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION, - PARAM_LINEAR_MOTION_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING, - PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS, - PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION, - PARAM_LINEAR_ORTHOGONAL_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING, - - PARAM_ANGULAR_LIMIT_UPPER = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, - PARAM_ANGULAR_LIMIT_LOWER = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, - PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, - PARAM_ANGULAR_LIMIT_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION, - PARAM_ANGULAR_LIMIT_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, - PARAM_ANGULAR_MOTION_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS, - PARAM_ANGULAR_MOTION_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION, - PARAM_ANGULAR_MOTION_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING, - PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS, - PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION, - PARAM_ANGULAR_ORTHOGONAL_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING, - PARAM_MAX = PhysicsServer::SLIDER_JOINT_MAX + PARAM_LINEAR_LIMIT_UPPER = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER, + PARAM_LINEAR_LIMIT_LOWER = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER, + PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS, + PARAM_LINEAR_LIMIT_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION, + PARAM_LINEAR_LIMIT_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING, + PARAM_LINEAR_MOTION_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS, + PARAM_LINEAR_MOTION_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION, + PARAM_LINEAR_MOTION_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING, + PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS, + PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION, + PARAM_LINEAR_ORTHOGONAL_DAMPING = PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING, + + PARAM_ANGULAR_LIMIT_UPPER = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER, + PARAM_ANGULAR_LIMIT_LOWER = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER, + PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS, + PARAM_ANGULAR_LIMIT_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION, + PARAM_ANGULAR_LIMIT_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING, + PARAM_ANGULAR_MOTION_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS, + PARAM_ANGULAR_MOTION_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION, + PARAM_ANGULAR_MOTION_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING, + PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS, + PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION, + PARAM_ANGULAR_ORTHOGONAL_DAMPING = PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING, + PARAM_MAX = PhysicsServer3D::SLIDER_JOINT_MAX }; @@ -244,39 +244,39 @@ class Generic6DOFJoint3D : public Joint3D { public: enum Param { - PARAM_LINEAR_LOWER_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT, - PARAM_LINEAR_UPPER_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT, - PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, - PARAM_LINEAR_RESTITUTION = PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION, - PARAM_LINEAR_DAMPING = PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING, - PARAM_LINEAR_MOTOR_TARGET_VELOCITY = PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY, - PARAM_LINEAR_MOTOR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT, - PARAM_LINEAR_SPRING_STIFFNESS = PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, - PARAM_LINEAR_SPRING_DAMPING = PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING, - PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, - PARAM_ANGULAR_LOWER_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, - PARAM_ANGULAR_UPPER_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, - PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, - PARAM_ANGULAR_DAMPING = PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING, - PARAM_ANGULAR_RESTITUTION = PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION, - PARAM_ANGULAR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT, - PARAM_ANGULAR_ERP = PhysicsServer::G6DOF_JOINT_ANGULAR_ERP, - PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY, - PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT, - PARAM_ANGULAR_SPRING_STIFFNESS = PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, - PARAM_ANGULAR_SPRING_DAMPING = PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, - PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, - PARAM_MAX = PhysicsServer::G6DOF_JOINT_MAX, + PARAM_LINEAR_LOWER_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT, + PARAM_LINEAR_UPPER_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT, + PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS, + PARAM_LINEAR_RESTITUTION = PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION, + PARAM_LINEAR_DAMPING = PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING, + PARAM_LINEAR_MOTOR_TARGET_VELOCITY = PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY, + PARAM_LINEAR_MOTOR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT, + PARAM_LINEAR_SPRING_STIFFNESS = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS, + PARAM_LINEAR_SPRING_DAMPING = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING, + PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT, + PARAM_ANGULAR_LOWER_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT, + PARAM_ANGULAR_UPPER_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT, + PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS, + PARAM_ANGULAR_DAMPING = PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING, + PARAM_ANGULAR_RESTITUTION = PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION, + PARAM_ANGULAR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT, + PARAM_ANGULAR_ERP = PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP, + PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY, + PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT, + PARAM_ANGULAR_SPRING_STIFFNESS = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS, + PARAM_ANGULAR_SPRING_DAMPING = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING, + PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT = PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT, + PARAM_MAX = PhysicsServer3D::G6DOF_JOINT_MAX, }; enum Flag { - FLAG_ENABLE_LINEAR_LIMIT = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, - FLAG_ENABLE_ANGULAR_LIMIT = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, - FLAG_ENABLE_LINEAR_SPRING = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, - FLAG_ENABLE_ANGULAR_SPRING = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, - FLAG_ENABLE_MOTOR = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR, - FLAG_ENABLE_LINEAR_MOTOR = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR, - FLAG_MAX = PhysicsServer::G6DOF_JOINT_FLAG_MAX + FLAG_ENABLE_LINEAR_LIMIT = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, + FLAG_ENABLE_ANGULAR_LIMIT = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, + FLAG_ENABLE_LINEAR_SPRING = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING, + FLAG_ENABLE_ANGULAR_SPRING = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING, + FLAG_ENABLE_MOTOR = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR, + FLAG_ENABLE_LINEAR_MOTOR = PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR, + FLAG_MAX = PhysicsServer3D::G6DOF_JOINT_FLAG_MAX }; protected: diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index e22c44a3a2..a18da61656 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -33,7 +33,7 @@ #include "collision_object_3d.h" #include "core/engine.h" #include "mesh_instance_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" void RayCast3D::set_cast_to(const Vector3 &p_point) { @@ -81,7 +81,7 @@ bool RayCast3D::is_colliding() const { Object *RayCast3D::get_collider() const { if (against.is_null()) - return NULL; + return nullptr; return ObjectDB::get_instance(against); } @@ -199,7 +199,7 @@ void RayCast3D::_update_raycast_state() { Ref<World3D> w3d = get_world(); ERR_FAIL_COND(w3d.is_null()); - PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space()); + PhysicsDirectSpaceState3D *dss = PhysicsServer3D::get_singleton()->space_get_direct_state(w3d->get_space()); ERR_FAIL_COND(!dss); Transform gt = get_global_transform(); @@ -208,7 +208,7 @@ void RayCast3D::_update_raycast_state() { if (to == Vector3()) to = Vector3(0, 0.01, 0); - PhysicsDirectSpaceState::RayResult rr; + PhysicsDirectSpaceState3D::RayResult rr; if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) { @@ -387,7 +387,7 @@ void RayCast3D::_clear_debug_shape() { else memdelete(mi); - debug_shape = NULL; + debug_shape = nullptr; } RayCast3D::RayCast3D() { @@ -398,7 +398,7 @@ RayCast3D::RayCast3D() { against_shape = 0; collision_mask = 1; cast_to = Vector3(0, -1, 0); - debug_shape = NULL; + debug_shape = nullptr; exclude_parent_body = true; collide_with_areas = false; collide_with_bodies = true; diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 3cf8e43ec2..24bf8b43d1 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -33,7 +33,7 @@ void ReflectionProbe::set_intensity(float p_intensity) { intensity = p_intensity; - VS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity); + RS::get_singleton()->reflection_probe_set_intensity(probe, p_intensity); } float ReflectionProbe::get_intensity() const { @@ -44,12 +44,12 @@ float ReflectionProbe::get_intensity() const { void ReflectionProbe::set_interior_ambient(Color p_ambient) { interior_ambient = p_ambient; - VS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient); + RS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient); } void ReflectionProbe::set_interior_ambient_energy(float p_energy) { interior_ambient_energy = p_energy; - VS::get_singleton()->reflection_probe_set_interior_ambient_energy(probe, p_energy); + RS::get_singleton()->reflection_probe_set_interior_ambient_energy(probe, p_energy); } float ReflectionProbe::get_interior_ambient_energy() const { @@ -64,7 +64,7 @@ Color ReflectionProbe::get_interior_ambient() const { void ReflectionProbe::set_interior_ambient_probe_contribution(float p_contribution) { interior_ambient_probe_contribution = p_contribution; - VS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution); + RS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution); } float ReflectionProbe::get_interior_ambient_probe_contribution() const { @@ -75,7 +75,7 @@ float ReflectionProbe::get_interior_ambient_probe_contribution() const { void ReflectionProbe::set_max_distance(float p_distance) { max_distance = p_distance; - VS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance); + RS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance); } float ReflectionProbe::get_max_distance() const { @@ -97,8 +97,8 @@ void ReflectionProbe::set_extents(const Vector3 &p_extents) { } } - VS::get_singleton()->reflection_probe_set_extents(probe, extents); - VS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset); + RS::get_singleton()->reflection_probe_set_extents(probe, extents); + RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset); _change_notify("extents"); update_gizmo(); } @@ -117,8 +117,8 @@ void ReflectionProbe::set_origin_offset(const Vector3 &p_extents) { origin_offset[i] = SGN(origin_offset[i]) * (extents[i] - 0.01); } } - VS::get_singleton()->reflection_probe_set_extents(probe, extents); - VS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset); + RS::get_singleton()->reflection_probe_set_extents(probe, extents); + RS::get_singleton()->reflection_probe_set_origin_offset(probe, origin_offset); _change_notify("origin_offset"); update_gizmo(); @@ -131,7 +131,7 @@ Vector3 ReflectionProbe::get_origin_offset() const { void ReflectionProbe::set_enable_box_projection(bool p_enable) { box_projection = p_enable; - VS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable); + RS::get_singleton()->reflection_probe_set_enable_box_projection(probe, p_enable); } bool ReflectionProbe::is_box_projection_enabled() const { @@ -141,7 +141,7 @@ bool ReflectionProbe::is_box_projection_enabled() const { void ReflectionProbe::set_as_interior(bool p_enable) { interior = p_enable; - VS::get_singleton()->reflection_probe_set_as_interior(probe, interior); + RS::get_singleton()->reflection_probe_set_as_interior(probe, interior); _change_notify(); } @@ -153,7 +153,7 @@ bool ReflectionProbe::is_set_as_interior() const { void ReflectionProbe::set_enable_shadows(bool p_enable) { enable_shadows = p_enable; - VS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable); + RS::get_singleton()->reflection_probe_set_enable_shadows(probe, p_enable); } bool ReflectionProbe::are_shadows_enabled() const { @@ -163,7 +163,7 @@ bool ReflectionProbe::are_shadows_enabled() const { void ReflectionProbe::set_cull_mask(uint32_t p_layers) { cull_mask = p_layers; - VS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers); + RS::get_singleton()->reflection_probe_set_cull_mask(probe, p_layers); } uint32_t ReflectionProbe::get_cull_mask() const { @@ -172,7 +172,7 @@ uint32_t ReflectionProbe::get_cull_mask() const { void ReflectionProbe::set_update_mode(UpdateMode p_mode) { update_mode = p_mode; - VS::get_singleton()->reflection_probe_set_update_mode(probe, VS::ReflectionProbeUpdateMode(p_mode)); + RS::get_singleton()->reflection_probe_set_update_mode(probe, RS::ReflectionProbeUpdateMode(p_mode)); } ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const { @@ -272,12 +272,12 @@ ReflectionProbe::ReflectionProbe() { cull_mask = (1 << 20) - 1; update_mode = UPDATE_ONCE; - probe = VisualServer::get_singleton()->reflection_probe_create(); - VS::get_singleton()->instance_set_base(get_instance(), probe); + probe = RenderingServer::get_singleton()->reflection_probe_create(); + RS::get_singleton()->instance_set_base(get_instance(), probe); set_disable_scale(true); } ReflectionProbe::~ReflectionProbe() { - VS::get_singleton()->free(probe); + RS::get_singleton()->free(probe); } diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index 9cc0c3e8c7..3867d13435 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -34,7 +34,7 @@ #include "scene/3d/visual_instance_3d.h" #include "scene/resources/sky.h" #include "scene/resources/texture.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class ReflectionProbe : public VisualInstance3D { GDCLASS(ReflectionProbe, VisualInstance3D); diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 1ea6647d61..59a6e23005 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -62,7 +62,7 @@ SkinReference::~SkinReference() { skeleton_node->skin_bindings.erase(this); } - VS::get_singleton()->free(skeleton); + RS::get_singleton()->free(skeleton); } bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { @@ -227,7 +227,7 @@ void Skeleton3D::_notification(int p_what) { case NOTIFICATION_UPDATE_SKELETON: { - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); Bone *bonesptr = bones.ptrw(); int len = bones.size(); @@ -320,7 +320,7 @@ void Skeleton3D::_notification(int p_what) { uint32_t bind_count = skin->get_bind_count(); if (E->get()->bind_count != bind_count) { - VS::get_singleton()->skeleton_allocate(skeleton, bind_count); + RS::get_singleton()->skeleton_allocate(skeleton, bind_count); E->get()->bind_count = bind_count; E->get()->skin_bone_indices.resize(bind_count); E->get()->skin_bone_indices_ptrs = E->get()->skin_bone_indices.ptrw(); @@ -685,19 +685,19 @@ void Skeleton3D::bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physic void Skeleton3D::unbind_physical_bone_from_bone(int p_bone) { ERR_FAIL_INDEX(p_bone, bones.size()); - bones.write[p_bone].physical_bone = NULL; + bones.write[p_bone].physical_bone = nullptr; _rebuild_physical_bones_cache(); } PhysicalBone3D *Skeleton3D::get_physical_bone(int p_bone) { - ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL); + ERR_FAIL_INDEX_V(p_bone, bones.size(), nullptr); return bones[p_bone].physical_bone; } PhysicalBone3D *Skeleton3D::get_physical_bone_parent(int p_bone) { - ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL); + ERR_FAIL_INDEX_V(p_bone, bones.size(), nullptr); if (bones[p_bone].cache_parent_physical_bone) { return bones[p_bone].cache_parent_physical_bone; @@ -707,11 +707,11 @@ PhysicalBone3D *Skeleton3D::get_physical_bone_parent(int p_bone) { } PhysicalBone3D *Skeleton3D::_get_physical_bone_parent(int p_bone) { - ERR_FAIL_INDEX_V(p_bone, bones.size(), NULL); + ERR_FAIL_INDEX_V(p_bone, bones.size(), nullptr); const int parent_bone = bones[p_bone].parent; if (0 > parent_bone) { - return NULL; + return nullptr; } PhysicalBone3D *pb = bones[parent_bone].physical_bone; @@ -802,9 +802,9 @@ void _physical_bones_add_remove_collision_exception(bool p_add, Node *p_node, RI CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_node); if (co) { if (p_add) { - PhysicsServer::get_singleton()->body_add_collision_exception(co->get_rid(), p_exception); + PhysicsServer3D::get_singleton()->body_add_collision_exception(co->get_rid(), p_exception); } else { - PhysicsServer::get_singleton()->body_remove_collision_exception(co->get_rid(), p_exception); + PhysicsServer3D::get_singleton()->body_remove_collision_exception(co->get_rid(), p_exception); } } } @@ -871,7 +871,7 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) { skin_ref->skeleton_node = this; skin_ref->bind_count = 0; - skin_ref->skeleton = VisualServer::get_singleton()->skeleton_create(); + skin_ref->skeleton = RenderingServer::get_singleton()->skeleton_create(); skin_ref->skeleton_node = this; skin_ref->skin = skin; diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index 2ae04aa575..08b8691658 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -112,8 +112,8 @@ private: global_pose_override_amount = 0; global_pose_override_reset = false; #ifndef _3D_DISABLED - physical_bone = NULL; - cache_parent_physical_bone = NULL; + physical_bone = nullptr; + cache_parent_physical_bone = nullptr; #endif // _3D_DISABLED } }; diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index a6c3e25399..7366290ed3 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -42,7 +42,7 @@ FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::find_child return &children.write[i]; } } - return NULL; + return nullptr; } FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::add_child(const BoneId p_bone_id) { @@ -65,7 +65,7 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain chain.chain_root.initial_transform = p_task->skeleton->get_bone_global_pose(chain.chain_root.bone); chain.chain_root.current_pos = chain.chain_root.initial_transform.origin; chain.chain_root.pb = p_task->skeleton->get_physical_bone(chain.chain_root.bone); - chain.middle_chain_item = NULL; + chain.middle_chain_item = nullptr; // Holds all IDs that are composing a single chain in reverse order Vector<BoneId> chain_ids; @@ -119,7 +119,7 @@ bool FabrikInverseKinematic::build_chain(Task *p_task, bool p_force_simple_chain } if (!middle_chain_item_id) - chain.middle_chain_item = NULL; + chain.middle_chain_item = nullptr; // Initialize current tip chain.tips.write[x].chain_item = sub_chain; @@ -226,14 +226,14 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_ if (p_solve_magnet && sub_chain_root == r_chain.middle_chain_item) { // In case of magnet solving this is the tip - sub_chain_root = NULL; + sub_chain_root = nullptr; } else { sub_chain_root = &child; } } else { // Is tip - sub_chain_root = NULL; + sub_chain_root = nullptr; } } } @@ -251,7 +251,7 @@ FabrikInverseKinematic::Task *FabrikInverseKinematic::create_simple_task(Skeleto if (!build_chain(task)) { free_task(task); - return NULL; + return nullptr; } return task; @@ -328,7 +328,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove if (!ci->children.empty()) ci = &ci->children.write[0]; else - ci = NULL; + ci = nullptr; } } @@ -432,14 +432,14 @@ SkeletonIK3D::SkeletonIK3D() : use_magnet(false), min_distance(0.01), max_iterations(10), - skeleton(NULL), - target_node_override(NULL), - task(NULL) { + skeleton(nullptr), + target_node_override(nullptr), + task(nullptr) { } SkeletonIK3D::~SkeletonIK3D() { FabrikInverseKinematic::free_task(task); - task = NULL; + task = nullptr; } void SkeletonIK3D::set_root_bone(const StringName &p_root_bone) { @@ -479,7 +479,7 @@ const Transform &SkeletonIK3D::get_target_transform() const { void SkeletonIK3D::set_target_node(const NodePath &p_node) { target_node_path_override = p_node; - target_node_override = NULL; + target_node_override = nullptr; reload_goal(); } @@ -550,7 +550,7 @@ Transform SkeletonIK3D::_get_target_transform() { void SkeletonIK3D::reload_chain() { FabrikInverseKinematic::free_task(task); - task = NULL; + task = nullptr; if (!skeleton) return; diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index ebfebd1e66..5fbbe6e9e7 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -64,9 +64,9 @@ class FabrikInverseKinematic { Vector3 current_ori; ChainItem() : - parent_item(NULL), + parent_item(nullptr), bone(-1), - pb(NULL), + pb(nullptr), length(0) {} ChainItem *find_child(const BoneId p_bone_id); @@ -78,8 +78,8 @@ class FabrikInverseKinematic { const EndEffector *end_effector; ChainTip() : - chain_item(NULL), - end_effector(NULL) {} + chain_item(nullptr), + end_effector(nullptr) {} ChainTip(ChainItem *p_chain_item, const EndEffector *p_end_effector) : chain_item(p_chain_item), @@ -115,7 +115,7 @@ public: Transform goal_global_transform; Task() : - skeleton(NULL), + skeleton(nullptr), min_distance(0.01), max_iterations(10), root_bone(-1) {} diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 6c93c3c1c7..6092818252 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "soft_body_3d.h" + #include "core/list.h" #include "core/object.h" #include "core/os/os.h" @@ -36,11 +37,11 @@ #include "scene/3d/collision_object_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/3d/skeleton_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" -SoftBodyVisualServerHandler::SoftBodyVisualServerHandler() {} +SoftBodyRenderingServerHandler::SoftBodyRenderingServerHandler() {} -void SoftBodyVisualServerHandler::prepare(RID p_mesh, int p_surface) { +void SoftBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) { clear(); ERR_FAIL_COND(!p_mesh.is_valid()); @@ -51,19 +52,19 @@ void SoftBodyVisualServerHandler::prepare(RID p_mesh, int p_surface) { #warning Softbody is not working, needs to be redone considering that these functions no longer exist #endif #if 0 - const uint32_t surface_format = VS::get_singleton()->mesh_surface_get_format(mesh, surface); - const int surface_vertex_len = VS::get_singleton()->mesh_surface_get_array_len(mesh, p_surface); - const int surface_index_len = VS::get_singleton()->mesh_surface_get_array_index_len(mesh, p_surface); - uint32_t surface_offsets[VS::ARRAY_MAX]; - - buffer = VS::get_singleton()->mesh_surface_get_array(mesh, surface); - stride = VS::get_singleton()->mesh_surface_make_offsets_from_format(surface_format, surface_vertex_len, surface_index_len, surface_offsets); - offset_vertices = surface_offsets[VS::ARRAY_VERTEX]; - offset_normal = surface_offsets[VS::ARRAY_NORMAL]; + const uint32_t surface_format = RS::get_singleton()->mesh_surface_get_format(mesh, surface); + const int surface_vertex_len = RS::get_singleton()->mesh_surface_get_array_len(mesh, p_surface); + const int surface_index_len = RS::get_singleton()->mesh_surface_get_array_index_len(mesh, p_surface); + uint32_t surface_offsets[RS::ARRAY_MAX]; + + buffer = RS::get_singleton()->mesh_surface_get_array(mesh, surface); + stride = RS::get_singleton()->mesh_surface_make_offsets_from_format(surface_format, surface_vertex_len, surface_index_len, surface_offsets); + offset_vertices = surface_offsets[RS::ARRAY_VERTEX]; + offset_normal = surface_offsets[RS::ARRAY_NORMAL]; #endif } -void SoftBodyVisualServerHandler::clear() { +void SoftBodyRenderingServerHandler::clear() { if (mesh.is_valid()) { buffer.resize(0); @@ -72,33 +73,33 @@ void SoftBodyVisualServerHandler::clear() { mesh = RID(); } -void SoftBodyVisualServerHandler::open() { +void SoftBodyRenderingServerHandler::open() { write_buffer = buffer.ptrw(); } -void SoftBodyVisualServerHandler::close() { +void SoftBodyRenderingServerHandler::close() { //write_buffer.release(); } -void SoftBodyVisualServerHandler::commit_changes() { - VS::get_singleton()->mesh_surface_update_region(mesh, surface, 0, buffer); +void SoftBodyRenderingServerHandler::commit_changes() { + RS::get_singleton()->mesh_surface_update_region(mesh, surface, 0, buffer); } -void SoftBodyVisualServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) { +void SoftBodyRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) { copymem(&write_buffer[p_vertex_id * stride + offset_vertices], p_vector3, sizeof(float) * 3); } -void SoftBodyVisualServerHandler::set_normal(int p_vertex_id, const void *p_vector3) { +void SoftBodyRenderingServerHandler::set_normal(int p_vertex_id, const void *p_vector3) { copymem(&write_buffer[p_vertex_id * stride + offset_normal], p_vector3, sizeof(float) * 3); } -void SoftBodyVisualServerHandler::set_aabb(const AABB &p_aabb) { - VS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb); +void SoftBodyRenderingServerHandler::set_aabb(const AABB &p_aabb) { + RS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb); } SoftBody3D::PinnedPoint::PinnedPoint() : point_index(-1), - spatial_attachment(NULL) { + spatial_attachment(nullptr) { } SoftBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) { @@ -120,7 +121,7 @@ void SoftBody3D::_update_pickable() { if (!is_inside_tree()) return; bool pickable = ray_pickable && is_visible_in_tree(); - PhysicsServer::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable); + PhysicsServer3D::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable); } bool SoftBody3D::_set(const StringName &p_name, const Variant &p_value) { @@ -270,7 +271,7 @@ void SoftBody3D::_notification(int p_what) { } RID space = get_world()->get_space(); - PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, space); + PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, space); prepare_physics_server(); } break; case NOTIFICATION_READY: { @@ -285,10 +286,10 @@ void SoftBody3D::_notification(int p_what) { return; } - PhysicsServer::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform()); + PhysicsServer3D::get_singleton()->soft_body_set_transform(physics_rid, get_global_transform()); set_notify_transform(false); - // Required to be top level with Transform at center of world in order to modify VisualServer only to support custom Transform + // Required to be top level with Transform at center of world in order to modify RenderingServer only to support custom Transform set_as_toplevel(true); set_transform(Transform()); set_notify_transform(true); @@ -301,7 +302,7 @@ void SoftBody3D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_WORLD: { - PhysicsServer::get_singleton()->soft_body_set_space(physics_rid, RID()); + PhysicsServer3D::get_singleton()->soft_body_set_space(physics_rid, RID()); } break; } @@ -402,7 +403,7 @@ String SoftBody3D::get_configuration_warning() const { if (!warning.empty()) warning += "\n\n"; - warning += TTR("Size changes to SoftBody will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."); + warning += TTR("Size changes to SoftBody3D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."); } return warning; @@ -418,7 +419,7 @@ void SoftBody3D::_update_physics_server() { const PinnedPoint *r = pinned_points.ptr(); for (int i = 0; i < pinned_points_indices_size; ++i) { if (r[i].spatial_attachment) { - PhysicsServer::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, r[i].spatial_attachment->get_global_transform().xform(r[i].offset)); + PhysicsServer3D::get_singleton()->soft_body_move_point(physics_rid, r[i].point_index, r[i].spatial_attachment->get_global_transform().xform(r[i].offset)); } } } @@ -427,9 +428,9 @@ void SoftBody3D::_draw_soft_mesh() { if (get_mesh().is_null()) return; - if (!visual_server_handler.is_ready()) { + if (!rendering_server_handler.is_ready()) { - visual_server_handler.prepare(get_mesh()->get_rid(), 0); + rendering_server_handler.prepare(get_mesh()->get_rid(), 0); /// Necessary in order to render the mesh correctly (Soft body nodes are in global space) simulation_started = true; @@ -439,11 +440,11 @@ void SoftBody3D::_draw_soft_mesh() { _update_physics_server(); - visual_server_handler.open(); - PhysicsServer::get_singleton()->soft_body_update_visual_server(physics_rid, &visual_server_handler); - visual_server_handler.close(); + rendering_server_handler.open(); + PhysicsServer3D::get_singleton()->soft_body_update_rendering_server(physics_rid, &rendering_server_handler); + rendering_server_handler.close(); - visual_server_handler.commit_changes(); + rendering_server_handler.commit_changes(); } void SoftBody3D::prepare_physics_server() { @@ -451,9 +452,9 @@ void SoftBody3D::prepare_physics_server() { if (Engine::get_singleton()->is_editor_hint()) { if (get_mesh().is_valid()) - PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); + PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); else - PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, NULL); + PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr); return; } @@ -461,13 +462,13 @@ void SoftBody3D::prepare_physics_server() { if (get_mesh().is_valid()) { become_mesh_owner(); - PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); - VS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); + PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, get_mesh()); + RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); } else { - PhysicsServer::get_singleton()->soft_body_set_mesh(physics_rid, NULL); - if (VS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) { - VS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); + PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, nullptr); + if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) { + RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh)); } } } @@ -508,7 +509,7 @@ void SoftBody3D::become_mesh_owner() { void SoftBody3D::set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; - PhysicsServer::get_singleton()->soft_body_set_collision_mask(physics_rid, p_mask); + PhysicsServer3D::get_singleton()->soft_body_set_collision_mask(physics_rid, p_mask); } uint32_t SoftBody3D::get_collision_mask() const { @@ -516,7 +517,7 @@ uint32_t SoftBody3D::get_collision_mask() const { } void SoftBody3D::set_collision_layer(uint32_t p_layer) { collision_layer = p_layer; - PhysicsServer::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer); + PhysicsServer3D::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer); } uint32_t SoftBody3D::get_collision_layer() const { @@ -570,11 +571,11 @@ Vector<SoftBody3D::PinnedPoint> SoftBody3D::get_pinned_points_indices() { Array SoftBody3D::get_collision_exceptions() { List<RID> exceptions; - PhysicsServer::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); + PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); Array ret; for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) { RID body = E->get(); - ObjectID instance_id = PhysicsServer::get_singleton()->body_get_object_instance_id(body); + ObjectID instance_id = PhysicsServer3D::get_singleton()->body_get_object_instance_id(body); Object *obj = ObjectDB::get_instance(instance_id); PhysicsBody3D *physics_body = Object::cast_to<PhysicsBody3D>(obj); ret.append(physics_body); @@ -585,91 +586,91 @@ Array SoftBody3D::get_collision_exceptions() { void SoftBody3D::add_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node); - ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); - PhysicsServer::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid()); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); + PhysicsServer3D::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid()); } void SoftBody3D::remove_collision_exception_with(Node *p_node) { ERR_FAIL_NULL(p_node); CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node); - ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject."); - PhysicsServer::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid()); + ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); + PhysicsServer3D::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid()); } int SoftBody3D::get_simulation_precision() { - return PhysicsServer::get_singleton()->soft_body_get_simulation_precision(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_simulation_precision(physics_rid); } void SoftBody3D::set_simulation_precision(int p_simulation_precision) { - PhysicsServer::get_singleton()->soft_body_set_simulation_precision(physics_rid, p_simulation_precision); + PhysicsServer3D::get_singleton()->soft_body_set_simulation_precision(physics_rid, p_simulation_precision); } real_t SoftBody3D::get_total_mass() { - return PhysicsServer::get_singleton()->soft_body_get_total_mass(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_total_mass(physics_rid); } void SoftBody3D::set_total_mass(real_t p_total_mass) { - PhysicsServer::get_singleton()->soft_body_set_total_mass(physics_rid, p_total_mass); + PhysicsServer3D::get_singleton()->soft_body_set_total_mass(physics_rid, p_total_mass); } void SoftBody3D::set_linear_stiffness(real_t p_linear_stiffness) { - PhysicsServer::get_singleton()->soft_body_set_linear_stiffness(physics_rid, p_linear_stiffness); + PhysicsServer3D::get_singleton()->soft_body_set_linear_stiffness(physics_rid, p_linear_stiffness); } real_t SoftBody3D::get_linear_stiffness() { - return PhysicsServer::get_singleton()->soft_body_get_linear_stiffness(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_linear_stiffness(physics_rid); } void SoftBody3D::set_areaAngular_stiffness(real_t p_areaAngular_stiffness) { - PhysicsServer::get_singleton()->soft_body_set_areaAngular_stiffness(physics_rid, p_areaAngular_stiffness); + PhysicsServer3D::get_singleton()->soft_body_set_areaAngular_stiffness(physics_rid, p_areaAngular_stiffness); } real_t SoftBody3D::get_areaAngular_stiffness() { - return PhysicsServer::get_singleton()->soft_body_get_areaAngular_stiffness(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_areaAngular_stiffness(physics_rid); } void SoftBody3D::set_volume_stiffness(real_t p_volume_stiffness) { - PhysicsServer::get_singleton()->soft_body_set_volume_stiffness(physics_rid, p_volume_stiffness); + PhysicsServer3D::get_singleton()->soft_body_set_volume_stiffness(physics_rid, p_volume_stiffness); } real_t SoftBody3D::get_volume_stiffness() { - return PhysicsServer::get_singleton()->soft_body_get_volume_stiffness(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_volume_stiffness(physics_rid); } real_t SoftBody3D::get_pressure_coefficient() { - return PhysicsServer::get_singleton()->soft_body_get_pressure_coefficient(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_pressure_coefficient(physics_rid); } void SoftBody3D::set_pose_matching_coefficient(real_t p_pose_matching_coefficient) { - PhysicsServer::get_singleton()->soft_body_set_pose_matching_coefficient(physics_rid, p_pose_matching_coefficient); + PhysicsServer3D::get_singleton()->soft_body_set_pose_matching_coefficient(physics_rid, p_pose_matching_coefficient); } real_t SoftBody3D::get_pose_matching_coefficient() { - return PhysicsServer::get_singleton()->soft_body_get_pose_matching_coefficient(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_pose_matching_coefficient(physics_rid); } void SoftBody3D::set_pressure_coefficient(real_t p_pressure_coefficient) { - PhysicsServer::get_singleton()->soft_body_set_pressure_coefficient(physics_rid, p_pressure_coefficient); + PhysicsServer3D::get_singleton()->soft_body_set_pressure_coefficient(physics_rid, p_pressure_coefficient); } real_t SoftBody3D::get_damping_coefficient() { - return PhysicsServer::get_singleton()->soft_body_get_damping_coefficient(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_damping_coefficient(physics_rid); } void SoftBody3D::set_damping_coefficient(real_t p_damping_coefficient) { - PhysicsServer::get_singleton()->soft_body_set_damping_coefficient(physics_rid, p_damping_coefficient); + PhysicsServer3D::get_singleton()->soft_body_set_damping_coefficient(physics_rid, p_damping_coefficient); } real_t SoftBody3D::get_drag_coefficient() { - return PhysicsServer::get_singleton()->soft_body_get_drag_coefficient(physics_rid); + return PhysicsServer3D::get_singleton()->soft_body_get_drag_coefficient(physics_rid); } void SoftBody3D::set_drag_coefficient(real_t p_drag_coefficient) { - PhysicsServer::get_singleton()->soft_body_set_drag_coefficient(physics_rid, p_drag_coefficient); + PhysicsServer3D::get_singleton()->soft_body_set_drag_coefficient(physics_rid, p_drag_coefficient); } Vector3 SoftBody3D::get_point_transform(int p_point_index) { - return PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index); + return PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index); } void SoftBody3D::pin_point_toggle(int p_point_index) { @@ -701,7 +702,7 @@ bool SoftBody3D::is_ray_pickable() const { } SoftBody3D::SoftBody3D() : - physics_rid(PhysicsServer::get_singleton()->soft_body_create()), + physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()), mesh_owner(false), collision_mask(1), collision_layer(1), @@ -709,18 +710,18 @@ SoftBody3D::SoftBody3D() : pinned_points_cache_dirty(true), ray_pickable(true) { - PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id()); + PhysicsServer3D::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id()); } SoftBody3D::~SoftBody3D() { - PhysicsServer::get_singleton()->free(physics_rid); + PhysicsServer3D::get_singleton()->free(physics_rid); } void SoftBody3D::reset_softbody_pin() { - PhysicsServer::get_singleton()->soft_body_remove_all_pinned_points(physics_rid); + PhysicsServer3D::get_singleton()->soft_body_remove_all_pinned_points(physics_rid); const PinnedPoint *pps = pinned_points.ptr(); for (int i = pinned_points.size() - 1; 0 < i; --i) { - PhysicsServer::get_singleton()->soft_body_pin_point(physics_rid, pps[i].point_index, true); + PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, pps[i].point_index, true); } } @@ -747,7 +748,7 @@ void SoftBody3D::_update_cache_pin_points_datas() { } void SoftBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) { - PhysicsServer::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin); + PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin); } void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) { @@ -761,7 +762,7 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_ if (!p_spatial_attachment_path.is_empty() && has_node(p_spatial_attachment_path)) { pp.spatial_attachment = Object::cast_to<Node3D>(get_node(p_spatial_attachment_path)); - pp.offset = (pp.spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, pp.point_index)); + pp.offset = (pp.spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, pp.point_index)); } pinned_points.push_back(pp); @@ -773,7 +774,7 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_ if (!p_spatial_attachment_path.is_empty() && has_node(p_spatial_attachment_path)) { pinned_point->spatial_attachment = Object::cast_to<Node3D>(get_node(p_spatial_attachment_path)); - pinned_point->offset = (pinned_point->spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, pinned_point->point_index)); + pinned_point->offset = (pinned_point->spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, pinned_point->point_index)); } } } @@ -793,7 +794,7 @@ void SoftBody3D::_reset_points_offsets() { if (!r[i].spatial_attachment) continue; - w[i].offset = (r[i].spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer::get_singleton()->soft_body_get_point_global_position(physics_rid, r[i].point_index)); + w[i].offset = (r[i].spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, r[i].point_index)); } } @@ -807,7 +808,7 @@ void SoftBody3D::_remove_pinned_point(int p_point_index) { int SoftBody3D::_get_pinned_point(int p_point_index, SoftBody3D::PinnedPoint *&r_point) const { const int id = _has_pinned_point(p_point_index); if (-1 == id) { - r_point = NULL; + r_point = nullptr; return -1; } else { r_point = const_cast<SoftBody3D::PinnedPoint *>(&pinned_points.ptr()[id]); diff --git a/scene/3d/soft_body_3d.h b/scene/3d/soft_body_3d.h index a1a4b4fa2f..7dd5880985 100644 --- a/scene/3d/soft_body_3d.h +++ b/scene/3d/soft_body_3d.h @@ -35,7 +35,7 @@ class SoftBody3D; -class SoftBodyVisualServerHandler { +class SoftBodyRenderingServerHandler { friend class SoftBody3D; @@ -49,7 +49,7 @@ class SoftBodyVisualServerHandler { uint8_t *write_buffer; private: - SoftBodyVisualServerHandler(); + SoftBodyRenderingServerHandler(); bool is_ready() { return mesh.is_valid(); } void prepare(RID p_mesh_rid, int p_surface); void clear(); @@ -79,7 +79,7 @@ public: }; private: - SoftBodyVisualServerHandler visual_server_handler; + SoftBodyRenderingServerHandler rendering_server_handler; RID physics_rid; diff --git a/scene/3d/spring_arm_3d.cpp b/scene/3d/spring_arm_3d.cpp index 1856171539..281be3f7d3 100644 --- a/scene/3d/spring_arm_3d.cpp +++ b/scene/3d/spring_arm_3d.cpp @@ -32,7 +32,7 @@ #include "core/engine.h" #include "scene/3d/collision_object_3d.h" #include "scene/resources/sphere_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" SpringArm3D::SpringArm3D() : spring_length(1), @@ -146,7 +146,7 @@ void SpringArm3D::process_spring() { if (shape.is_null()) { motion = Vector3(cast_direction * (spring_length)); - PhysicsDirectSpaceState::RayResult r; + PhysicsDirectSpaceState3D::RayResult r; bool intersected = get_world()->get_direct_space_state()->intersect_ray(get_global_transform().origin, get_global_transform().origin + motion, r, excluded_objects, mask); if (intersected) { float dist = get_global_transform().origin.distance_to(r.position); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index fd22076091..85e5ebc475 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -83,8 +83,8 @@ void SpriteBase3D::_notification(int p_what) { if (parent_sprite) { parent_sprite->children.erase(pI); - pI = NULL; - parent_sprite = NULL; + pI = nullptr; + parent_sprite = nullptr; } } } @@ -364,8 +364,8 @@ SpriteBase3D::SpriteBase3D() { centered = true; hflip = false; vflip = false; - parent_sprite = NULL; - pI = NULL; + parent_sprite = nullptr; + pI = nullptr; for (int i = 0; i < FLAG_MAX; i++) flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED; @@ -377,13 +377,13 @@ SpriteBase3D::SpriteBase3D() { modulate = Color(1, 1, 1, 1); pending_update = false; opacity = 1.0; - immediate = VisualServer::get_singleton()->immediate_create(); + immediate = RenderingServer::get_singleton()->immediate_create(); set_base(immediate); } SpriteBase3D::~SpriteBase3D() { - VisualServer::get_singleton()->free(immediate); + RenderingServer::get_singleton()->free(immediate); } /////////////////////////////////////////// @@ -392,7 +392,7 @@ void Sprite3D::_draw() { RID immediate = get_immediate(); - VS::get_singleton()->immediate_clear(immediate); + RS::get_singleton()->immediate_clear(immediate); if (!texture.is_valid()) return; Vector2 tsize = texture->get_size(); @@ -441,7 +441,7 @@ void Sprite3D::_draw() { // Properly setup UVs for impostor textures (AtlasTexture). Ref<AtlasTexture> atlas_tex = texture; - if (atlas_tex != NULL) { + if (atlas_tex != nullptr) { src_tsize[0] = atlas_tex->get_atlas()->get_width(); src_tsize[1] = atlas_tex->get_atlas()->get_height(); } @@ -475,9 +475,9 @@ void Sprite3D::_draw() { } RID mat = StandardMaterial3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y); - VS::get_singleton()->immediate_set_material(immediate, mat); + RS::get_singleton()->immediate_set_material(immediate, mat); - VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid()); + RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_TRIANGLES, texture->get_rid()); int x_axis = ((axis + 1) % 3); int y_axis = ((axis + 2) % 3); @@ -502,15 +502,15 @@ void Sprite3D::_draw() { static const int index[6] = { 0, 1, 2, 0, 2, 3 }; - VS::get_singleton()->immediate_normal(immediate, normal); - VS::get_singleton()->immediate_tangent(immediate, tangent); - VS::get_singleton()->immediate_color(immediate, color); - VS::get_singleton()->immediate_uv(immediate, uvs[i]); + RS::get_singleton()->immediate_normal(immediate, normal); + RS::get_singleton()->immediate_tangent(immediate, tangent); + RS::get_singleton()->immediate_color(immediate, color); + RS::get_singleton()->immediate_uv(immediate, uvs[i]); Vector3 vtx; vtx[x_axis] = vertices[index[i]][0]; vtx[y_axis] = vertices[index[i]][1]; - VS::get_singleton()->immediate_vertex(immediate, vtx); + RS::get_singleton()->immediate_vertex(immediate, vtx); if (i == 0) { aabb.position = vtx; aabb.size = Vector3(); @@ -519,7 +519,7 @@ void Sprite3D::_draw() { } } set_aabb(aabb); - VS::get_singleton()->immediate_end(immediate); + RS::get_singleton()->immediate_end(immediate); } void Sprite3D::_texture_changed() { @@ -717,7 +717,7 @@ Sprite3D::Sprite3D() { void AnimatedSprite3D::_draw() { RID immediate = get_immediate(); - VS::get_singleton()->immediate_clear(immediate); + RS::get_singleton()->immediate_clear(immediate); if (frames.is_null()) { return; @@ -775,7 +775,7 @@ void AnimatedSprite3D::_draw() { // Properly setup UVs for impostor textures (AtlasTexture). Ref<AtlasTexture> atlas_tex = texture; - if (atlas_tex != NULL) { + if (atlas_tex != nullptr) { src_tsize[0] = atlas_tex->get_atlas()->get_width(); src_tsize[1] = atlas_tex->get_atlas()->get_height(); } @@ -810,9 +810,9 @@ void AnimatedSprite3D::_draw() { RID mat = StandardMaterial3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y); - VS::get_singleton()->immediate_set_material(immediate, mat); + RS::get_singleton()->immediate_set_material(immediate, mat); - VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid()); + RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_TRIANGLES, texture->get_rid()); int x_axis = ((axis + 1) % 3); int y_axis = ((axis + 2) % 3); @@ -840,15 +840,15 @@ void AnimatedSprite3D::_draw() { 0, 2, 3 }; - VS::get_singleton()->immediate_normal(immediate, normal); - VS::get_singleton()->immediate_tangent(immediate, tangent); - VS::get_singleton()->immediate_color(immediate, color); - VS::get_singleton()->immediate_uv(immediate, uvs[i]); + RS::get_singleton()->immediate_normal(immediate, normal); + RS::get_singleton()->immediate_tangent(immediate, tangent); + RS::get_singleton()->immediate_color(immediate, color); + RS::get_singleton()->immediate_uv(immediate, uvs[i]); Vector3 vtx; vtx[x_axis] = vertices[indices[i]][0]; vtx[y_axis] = vertices[indices[i]][1]; - VS::get_singleton()->immediate_vertex(immediate, vtx); + RS::get_singleton()->immediate_vertex(immediate, vtx); if (i == 0) { aabb.position = vtx; aabb.size = Vector3(); @@ -857,7 +857,7 @@ void AnimatedSprite3D::_draw() { } } set_aabb(aabb); - VS::get_singleton()->immediate_end(immediate); + RS::get_singleton()->immediate_end(immediate); } void AnimatedSprite3D::_validate_property(PropertyInfo &property) const { diff --git a/scene/3d/vehicle_body_3d.cpp b/scene/3d/vehicle_body_3d.cpp index 5d601b0d43..5c2fa59a21 100644 --- a/scene/3d/vehicle_body_3d.cpp +++ b/scene/3d/vehicle_body_3d.cpp @@ -99,19 +99,19 @@ void VehicleWheel3D::_notification(int p_what) { if (!cb) return; cb->wheels.erase(this); - body = NULL; + body = nullptr; } } String VehicleWheel3D::get_configuration_warning() const { if (!Object::cast_to<VehicleBody3D>(get_parent())) { - return TTR("VehicleWheel serves to provide a wheel system to a VehicleBody. Please use it as a child of a VehicleBody."); + return TTR("VehicleWheel3D serves to provide a wheel system to a VehicleBody3D. Please use it as a child of a VehicleBody3D."); } return String(); } -void VehicleWheel3D::_update(PhysicsDirectBodyState *s) { +void VehicleWheel3D::_update(PhysicsDirectBodyState3D *s) { if (m_raycastInfo.m_isInContact) @@ -285,7 +285,7 @@ void VehicleWheel3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_brake", "get_brake"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering"); - ADD_GROUP("VehicleBody Motion", ""); + ADD_GROUP("VehicleBody3D Motion", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_traction"), "set_use_as_traction", "is_used_as_traction"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_as_steering"), "set_use_as_steering", "is_used_as_steering"); ADD_GROUP("Wheel", "wheel_"); @@ -385,10 +385,10 @@ VehicleWheel3D::VehicleWheel3D() { m_clippedInvContactDotSuspension = 1.0; m_raycastInfo.m_isInContact = false; - body = NULL; + body = nullptr; } -void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState *s) { +void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s) { wheel.m_raycastInfo.m_isInContact = false; @@ -405,7 +405,7 @@ void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirect wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.get_basis().xform(wheel.m_wheelAxleCS).normalized(); } -void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState *s) { +void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState3D *s) { VehicleWheel3D &wheel = *wheels[p_idx]; _update_wheel_transform(wheel, s); @@ -430,7 +430,7 @@ void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState *s) { wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength); } -real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState *s) { +real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState3D *s) { VehicleWheel3D &wheel = *wheels[p_idx]; @@ -448,13 +448,13 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState *s) { real_t param = real_t(0.); - PhysicsDirectSpaceState::RayResult rr; + PhysicsDirectSpaceState3D::RayResult rr; - PhysicsDirectSpaceState *ss = s->get_space_state(); + PhysicsDirectSpaceState3D *ss = s->get_space_state(); bool col = ss->intersect_ray(source, target, rr, exclude); - wheel.m_raycastInfo.m_groundObject = 0; + wheel.m_raycastInfo.m_groundObject = nullptr; if (col) { param = source.distance_to(rr.position) / source.distance_to(target); @@ -513,7 +513,7 @@ real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState *s) { return depth; } -void VehicleBody3D::_update_suspension(PhysicsDirectBodyState *s) { +void VehicleBody3D::_update_suspension(PhysicsDirectBodyState3D *s) { real_t chassisMass = mass; @@ -558,7 +558,7 @@ void VehicleBody3D::_update_suspension(PhysicsDirectBodyState *s) { } //bilateral constraint between two dynamic objects -void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1, +void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState3D *s, const Vector3 &pos1, PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence) { real_t normalLenSqr = normal.length_squared(); @@ -636,7 +636,7 @@ void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState *s, const V #endif } -VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) : +VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState3D *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) : m_s(s), m_body1(body1), m_frictionPositionWorld(frictionPosWorld), @@ -698,7 +698,7 @@ real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contact } static const real_t sideFrictionStiffness2 = real_t(1.0); -void VehicleBody3D::_update_friction(PhysicsDirectBodyState *s) { +void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) { //calculate the impulse, so that the wheels don't move sidewards int numWheel = wheels.size(); @@ -854,7 +854,7 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) { RigidBody3D::_direct_state_changed(p_state); - state = Object::cast_to<PhysicsDirectBodyState>(p_state); + state = Object::cast_to<PhysicsDirectBodyState3D>(p_state); float step = state->get_step(); @@ -917,7 +917,7 @@ void VehicleBody3D::_direct_state_changed(Object *p_state) { wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact } - state = NULL; + state = nullptr; } void VehicleBody3D::set_engine_force(float p_engine_force) { @@ -988,11 +988,11 @@ VehicleBody3D::VehicleBody3D() { engine_force = 0; brake = 0; - state = NULL; + state = nullptr; ccd = false; exclude.insert(get_rid()); - //PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); + //PhysicsServer3D::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); set_mass(40); } diff --git a/scene/3d/vehicle_body_3d.h b/scene/3d/vehicle_body_3d.h index 1ca9b6253f..d5e896263d 100644 --- a/scene/3d/vehicle_body_3d.h +++ b/scene/3d/vehicle_body_3d.h @@ -91,7 +91,7 @@ class VehicleWheel3D : public Node3D { PhysicsBody3D *m_groundObject; //could be general void* ptr } m_raycastInfo; - void _update(PhysicsDirectBodyState *s); + void _update(PhysicsDirectBodyState3D *s); protected: void _notification(int p_what); @@ -170,24 +170,24 @@ class VehicleBody3D : public RigidBody3D { Vector<real_t> m_sideImpulse; struct btVehicleWheelContactPoint { - PhysicsDirectBodyState *m_s; + PhysicsDirectBodyState3D *m_s; PhysicsBody3D *m_body1; Vector3 m_frictionPositionWorld; Vector3 m_frictionDirectionWorld; real_t m_jacDiagABInv; real_t m_maxImpulse; - btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse); + btVehicleWheelContactPoint(PhysicsDirectBodyState3D *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse); }; - void _resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1, PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence); + void _resolve_single_bilateral(PhysicsDirectBodyState3D *s, const Vector3 &pos1, PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence); real_t _calc_rolling_friction(btVehicleWheelContactPoint &contactPoint); - void _update_friction(PhysicsDirectBodyState *s); - void _update_suspension(PhysicsDirectBodyState *s); - real_t _ray_cast(int p_idx, PhysicsDirectBodyState *s); - void _update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState *s); - void _update_wheel(int p_idx, PhysicsDirectBodyState *s); + void _update_friction(PhysicsDirectBodyState3D *s); + void _update_suspension(PhysicsDirectBodyState3D *s); + real_t _ray_cast(int p_idx, PhysicsDirectBodyState3D *s); + void _update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState3D *s); + void _update_wheel(int p_idx, PhysicsDirectBodyState3D *s); friend class VehicleWheel3D; Vector<VehicleWheel3D *> wheels; diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index 14a975c023..775a9b76e2 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -31,7 +31,7 @@ #include "visual_instance_3d.h" #include "scene/scene_string_names.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #include "skeleton_3d.h" AABB VisualInstance3D::get_transformed_aabb() const { @@ -45,7 +45,7 @@ void VisualInstance3D::_update_visibility() { return; _change_notify("visible"); - VS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree()); + RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree()); } void VisualInstance3D::_notification(int p_what) { @@ -58,23 +58,23 @@ void VisualInstance3D::_notification(int p_what) { /* Skeleton *skeleton=Object::cast_to<Skeleton>(get_parent()); if (skeleton) - VisualServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() ); + RenderingServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() ); */ ERR_FAIL_COND(get_world().is_null()); - VisualServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario()); + RenderingServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario()); _update_visibility(); } break; case NOTIFICATION_TRANSFORM_CHANGED: { Transform gt = get_global_transform(); - VisualServer::get_singleton()->instance_set_transform(instance, gt); + RenderingServer::get_singleton()->instance_set_transform(instance, gt); } break; case NOTIFICATION_EXIT_WORLD: { - VisualServer::get_singleton()->instance_set_scenario(instance, RID()); - VisualServer::get_singleton()->instance_attach_skeleton(instance, RID()); - //VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() ); + RenderingServer::get_singleton()->instance_set_scenario(instance, RID()); + RenderingServer::get_singleton()->instance_attach_skeleton(instance, RID()); + //RS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() ); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -97,7 +97,7 @@ RID VisualInstance3D::_get_visual_instance_rid() const { void VisualInstance3D::set_layer_mask(uint32_t p_mask) { layers = p_mask; - VisualServer::get_singleton()->instance_set_layer_mask(instance, p_mask); + RenderingServer::get_singleton()->instance_set_layer_mask(instance, p_mask); } uint32_t VisualInstance3D::get_layer_mask() const { @@ -137,7 +137,7 @@ void VisualInstance3D::_bind_methods() { void VisualInstance3D::set_base(const RID &p_base) { - VisualServer::get_singleton()->instance_set_base(instance, p_base); + RenderingServer::get_singleton()->instance_set_base(instance, p_base); base = p_base; } @@ -148,21 +148,21 @@ RID VisualInstance3D::get_base() const { VisualInstance3D::VisualInstance3D() { - instance = VisualServer::get_singleton()->instance_create(); - VisualServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id()); + instance = RenderingServer::get_singleton()->instance_create(); + RenderingServer::get_singleton()->instance_attach_object_instance_id(instance, get_instance_id()); layers = 1; set_notify_transform(true); } VisualInstance3D::~VisualInstance3D() { - VisualServer::get_singleton()->free(instance); + RenderingServer::get_singleton()->free(instance); } void GeometryInstance3D::set_material_override(const Ref<Material> &p_material) { material_override = p_material; - VS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID()); + RS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID()); } Ref<Material> GeometryInstance3D::get_material_override() const { @@ -173,7 +173,7 @@ Ref<Material> GeometryInstance3D::get_material_override() const { void GeometryInstance3D::set_lod_min_distance(float p_dist) { lod_min_distance = p_dist; - VS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); + RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_min_distance() const { @@ -184,7 +184,7 @@ float GeometryInstance3D::get_lod_min_distance() const { void GeometryInstance3D::set_lod_max_distance(float p_dist) { lod_max_distance = p_dist; - VS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); + RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_max_distance() const { @@ -195,7 +195,7 @@ float GeometryInstance3D::get_lod_max_distance() const { void GeometryInstance3D::set_lod_min_hysteresis(float p_dist) { lod_min_hysteresis = p_dist; - VS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); + RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_min_hysteresis() const { @@ -206,7 +206,7 @@ float GeometryInstance3D::get_lod_min_hysteresis() const { void GeometryInstance3D::set_lod_max_hysteresis(float p_dist) { lod_max_hysteresis = p_dist; - VS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); + RS::get_singleton()->instance_geometry_set_draw_range(get_instance(), lod_min_distance, lod_max_distance, lod_min_hysteresis, lod_max_hysteresis); } float GeometryInstance3D::get_lod_max_hysteresis() const { @@ -224,7 +224,7 @@ void GeometryInstance3D::set_flag(Flags p_flag, bool p_value) { return; flags[p_flag] = p_value; - VS::get_singleton()->instance_geometry_set_flag(get_instance(), (VS::InstanceFlags)p_flag, p_value); + RS::get_singleton()->instance_geometry_set_flag(get_instance(), (RS::InstanceFlags)p_flag, p_value); } bool GeometryInstance3D::get_flag(Flags p_flag) const { @@ -238,7 +238,7 @@ void GeometryInstance3D::set_cast_shadows_setting(ShadowCastingSetting p_shadow_ shadow_casting_setting = p_shadow_casting_setting; - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (VS::ShadowCastingSetting)p_shadow_casting_setting); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (RS::ShadowCastingSetting)p_shadow_casting_setting); } GeometryInstance3D::ShadowCastingSetting GeometryInstance3D::get_cast_shadows_setting() const { @@ -250,7 +250,7 @@ void GeometryInstance3D::set_extra_cull_margin(float p_margin) { ERR_FAIL_COND(p_margin < 0); extra_cull_margin = p_margin; - VS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin); + RS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin); } float GeometryInstance3D::get_extra_cull_margin() const { @@ -260,7 +260,7 @@ float GeometryInstance3D::get_extra_cull_margin() const { void GeometryInstance3D::set_custom_aabb(AABB aabb) { - VS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb); + RS::get_singleton()->instance_set_custom_aabb(get_instance(), aabb); } void GeometryInstance3D::_bind_methods() { @@ -331,5 +331,5 @@ GeometryInstance3D::GeometryInstance3D() { shadow_casting_setting = SHADOW_CASTING_SETTING_ON; extra_cull_margin = 0; - //VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0); + //RS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0); } diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index 59a935fdee..9476c28848 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -86,17 +86,17 @@ class GeometryInstance3D : public VisualInstance3D { public: enum Flags { - FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT, - FLAG_USE_DYNAMIC_GI = VS::INSTANCE_FLAG_USE_DYNAMIC_GI, - FLAG_DRAW_NEXT_FRAME_IF_VISIBLE = VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, - FLAG_MAX = VS::INSTANCE_FLAG_MAX, + FLAG_USE_BAKED_LIGHT = RS::INSTANCE_FLAG_USE_BAKED_LIGHT, + FLAG_USE_DYNAMIC_GI = RS::INSTANCE_FLAG_USE_DYNAMIC_GI, + FLAG_DRAW_NEXT_FRAME_IF_VISIBLE = RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, + FLAG_MAX = RS::INSTANCE_FLAG_MAX, }; enum ShadowCastingSetting { - SHADOW_CASTING_SETTING_OFF = VS::SHADOW_CASTING_SETTING_OFF, - SHADOW_CASTING_SETTING_ON = VS::SHADOW_CASTING_SETTING_ON, - SHADOW_CASTING_SETTING_DOUBLE_SIDED = VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED, - SHADOW_CASTING_SETTING_SHADOWS_ONLY = VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY + SHADOW_CASTING_SETTING_OFF = RS::SHADOW_CASTING_SETTING_OFF, + SHADOW_CASTING_SETTING_ON = RS::SHADOW_CASTING_SETTING_ON, + SHADOW_CASTING_SETTING_DOUBLE_SIDED = RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED, + SHADOW_CASTING_SETTING_SHADOWS_ONLY = RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY }; private: diff --git a/scene/SCsub b/scene/SCsub index 1c5b87b87a..f9fc00f3f2 100644 --- a/scene/SCsub +++ b/scene/SCsub @@ -1,16 +1,16 @@ #!/usr/bin/env python -Import('env') +Import("env") env.scene_sources = [] # Thirdparty code thirdparty_dir = "#thirdparty/misc/" thirdparty_sources = [ - # C++ sources - "easing_equations.cpp", - # C sources - "mikktspace.c", + # C++ sources + "easing_equations.cpp", + # C sources + "mikktspace.c", ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] @@ -23,14 +23,14 @@ env.add_source_files(env.scene_sources, "*.cpp") # Chain load SCsubs -SConscript('main/SCsub') -SConscript('gui/SCsub') -SConscript('3d/SCsub') -SConscript('2d/SCsub') -SConscript('animation/SCsub') -SConscript('audio/SCsub') -SConscript('resources/SCsub') -SConscript('debugger/SCsub') +SConscript("main/SCsub") +SConscript("gui/SCsub") +SConscript("3d/SCsub") +SConscript("2d/SCsub") +SConscript("animation/SCsub") +SConscript("audio/SCsub") +SConscript("resources/SCsub") +SConscript("debugger/SCsub") # Build it all as a library diff --git a/scene/animation/SCsub b/scene/animation/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/animation/SCsub +++ b/scene/animation/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 8ba7a38628..570735ad87 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -41,7 +41,7 @@ StringName AnimationNodeAnimation::get_animation() const { return animation; } -Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = NULL; +Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = nullptr; void AnimationNodeAnimation::get_parameter_list(List<PropertyInfo> *r_list) const { r_list->push_back(PropertyInfo(Variant::FLOAT, time, PROPERTY_HINT_NONE, "", 0)); diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index 79a7c36e7f..ab8be47b4d 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -287,7 +287,7 @@ void AnimationCache::set_all(float p_time, float p_delta) { if (!args.size()) { - call_track(i, name, NULL, 0, err); + call_track(i, name, nullptr, 0, err); } else { Vector<const Variant *> argptrs; @@ -332,7 +332,7 @@ void AnimationCache::set_root(Node *p_root) { AnimationCache::AnimationCache() { - root = NULL; + root = nullptr; cache_dirty = true; cache_valid = false; } diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h index 20147f060b..23312ca7ec 100644 --- a/scene/animation/animation_cache.h +++ b/scene/animation/animation_cache.h @@ -50,12 +50,12 @@ class AnimationCache : public Object { Vector<StringName> subpath; bool valid; Path() { - object = NULL; - skeleton = NULL; - node = NULL; + object = nullptr; + skeleton = nullptr; + node = nullptr; bone_idx = -1; valid = false; - spatial = NULL; + spatial = nullptr; } }; diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index ce1e75a61d..9f5e06c43d 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -225,7 +225,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta } //find the last cost transition - List<int>::Element *least_cost_transition = NULL; + List<int>::Element *least_cost_transition = nullptr; float least_cost = 1e20; for (List<int>::Element *E = open_list.front(); E; E = E->next()) { @@ -516,6 +516,11 @@ AnimationNodeStateMachinePlayback::AnimationNodeStateMachinePlayback() { len_current = 0; fading_time = 0; stop_request = false; + len_total = 0.0; + pos_current = 0.0; + loops_current = 0; + fading_pos = 0.0; + start_request_travel = false; } /////////////////////////////////////////////////////// @@ -525,7 +530,7 @@ void AnimationNodeStateMachine::get_parameter_list(List<PropertyInfo> *r_list) c List<StringName> advance_conditions; for (int i = 0; i < transitions.size(); i++) { StringName ac = transitions[i].transition->get_advance_condition_name(); - if (ac != StringName() && advance_conditions.find(ac) == NULL) { + if (ac != StringName() && advance_conditions.find(ac) == nullptr) { advance_conditions.push_back(ac); } } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 6c870682a6..b657833a3b 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -244,7 +244,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { for (int i = 0; i < a->get_track_count(); i++) { - p_anim->node_cache.write[i] = NULL; + p_anim->node_cache.write[i] = nullptr; RES resource; Vector<StringName> leftover_path; Node *child = parent->get_node_and_resource(a->track_get_path(i), resource, leftover_path); @@ -293,13 +293,13 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name); if (p_anim->node_cache[i]->bone_idx < 0) { // broken track (nonexistent bone) - p_anim->node_cache[i]->skeleton = NULL; - p_anim->node_cache[i]->spatial = NULL; + p_anim->node_cache[i]->skeleton = nullptr; + p_anim->node_cache[i]->spatial = nullptr; ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0); } } else { // no property, just use spatialnode - p_anim->node_cache[i]->skeleton = NULL; + p_anim->node_cache[i]->skeleton = nullptr; } } } @@ -830,7 +830,7 @@ void AnimationPlayer::_animation_process2(float p_delta, bool p_started) { c.seeked = false; } - List<Blend>::Element *prev = NULL; + List<Blend>::Element *prev = nullptr; for (List<Blend>::Element *E = c.blend.back(); E; E = prev) { Blend &b = E->get(); @@ -1242,19 +1242,6 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float bool AnimationPlayer::is_playing() const { return playing; - /* - if (playback.current.from==NULL) - return false; - - float len=playback.current.from->animation->get_length(); - float pos = playback.current.pos; - bool loop=playback.current.from->animation->has_loop(); - if (!loop && pos >= len) { - return false; - }; - - return true; - */ } void AnimationPlayer::set_current_animation(const String &p_anim) { @@ -1296,7 +1283,7 @@ void AnimationPlayer::stop(bool p_reset) { Playback &c = playback; c.blend.clear(); if (p_reset) { - c.current.from = NULL; + c.current.from = nullptr; c.current.speed_scale = 1; c.current.pos = 0; } diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 32bed6f4d6..c134aff707 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -118,9 +118,9 @@ private: Variant capture; PropertyAnim() : - owner(NULL), + owner(nullptr), special(SP_NONE), - object(NULL), + object(nullptr), accum_pass(0) {} }; @@ -135,9 +135,9 @@ private: uint64_t accum_pass; BezierAnim() : - owner(NULL), + owner(nullptr), bezier_accum(0.0), - object(NULL), + object(nullptr), accum_pass(0) {} }; @@ -145,10 +145,10 @@ private: TrackNodeCache() : id(0), - node(NULL), - spatial(NULL), - node_2d(NULL), - skeleton(NULL), + node(nullptr), + spatial(nullptr), + node_2d(nullptr), + skeleton(nullptr), bone_idx(-1), accum_pass(0), audio_playing(false), @@ -212,7 +212,7 @@ private: pos = 0; speed_scale = 1.0; - from = NULL; + from = nullptr; } }; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 0e1089cc6a..f8b3ca291b 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -128,8 +128,8 @@ float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode * float t = process(p_time, p_seek); - state = NULL; - parent = NULL; + state = nullptr; + parent = nullptr; base_path = StringName(); connections.clear(); @@ -164,7 +164,7 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p //inputs.write[p_input].last_pass = state->last_pass; float activity = 0; - float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), NULL, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); + float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path); @@ -202,7 +202,7 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin blendw[i] = 0.0; //all to zero by default } - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = filter.next(K))) { if (!state->track_map.has(*K)) { continue; @@ -316,7 +316,7 @@ String AnimationNode::get_caption() const { void AnimationNode::add_input(const String &p_name) { //root nodes can't add inputs - ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != NULL); + ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != nullptr); Input input; ERR_FAIL_COND(p_name.find(".") != -1 || p_name.find("/") != -1); input.name = p_name; @@ -374,7 +374,7 @@ Array AnimationNode::_get_filters() const { Array paths; - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = filter.next(K))) { paths.push_back(String(*K)); //use strings, so sorting is possible } @@ -453,8 +453,8 @@ void AnimationNode::_bind_methods() { AnimationNode::AnimationNode() { - state = NULL; - parent = NULL; + state = nullptr; + parent = nullptr; filter_enabled = false; } @@ -558,17 +558,17 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { NodePath path = anim->track_get_path(i); Animation::TrackType track_type = anim->track_get_type(i); - TrackCache *track = NULL; + TrackCache *track = nullptr; if (track_cache.has(path)) { track = track_cache.get(path); } //if not valid, delete track - if (track && (track->type != track_type || ObjectDB::get_instance(track->object_id) == NULL)) { + if (track && (track->type != track_type || ObjectDB::get_instance(track->object_id) == nullptr)) { playing_caches.erase(track); memdelete(track); track_cache.erase(path); - track = NULL; + track = nullptr; } if (!track) { @@ -615,7 +615,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { TrackCacheTransform *track_xform = memnew(TrackCacheTransform); track_xform->spatial = spatial; - track_xform->skeleton = NULL; + track_xform->skeleton = nullptr; track_xform->bone_idx = -1; if (path.get_subname_count() == 1 && Object::cast_to<Skeleton3D>(spatial)) { @@ -700,7 +700,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { List<NodePath> to_delete; - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = track_cache.next(K))) { TrackCache *tc = track_cache[*K]; if (tc->setup_pass != setup_pass) { @@ -717,7 +717,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { state.track_map.clear(); - K = NULL; + K = nullptr; int idx = 0; while ((K = track_cache.next(K))) { state.track_map[*K] = idx; @@ -733,7 +733,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { void AnimationTree::_clear_caches() { - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = track_cache.next(K))) { memdelete(track_cache[*K]); } @@ -829,11 +829,11 @@ void AnimationTree::_process_graph(float p_delta) { if (started) { //if started, seek - root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, NULL, &state, 0, true, Vector<StringName>()); + root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, Vector<StringName>()); started = false; } - root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, NULL, &state, p_delta, false, Vector<StringName>()); + root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, p_delta, false, Vector<StringName>()); } if (!state.valid) { @@ -1224,7 +1224,7 @@ void AnimationTree::_process_graph(float p_delta) { { // finally, set the tracks - const NodePath *K = NULL; + const NodePath *K = nullptr; while ((K = track_cache.next(K))) { TrackCache *track = track_cache[*K]; if (track->process_pass != process_pass) diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index faf4333f1d..d558170f23 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -101,7 +101,7 @@ public: Array _get_filters() const; void _set_filters(const Array &p_filters); friend class AnimationNodeBlendTree; - float _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, float *r_max = NULL); + float _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, float *r_max = nullptr); protected: void blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend); @@ -186,7 +186,7 @@ private: root_motion = false; setup_pass = 0; process_pass = 0; - object = NULL; + object = nullptr; } virtual ~TrackCache() {} }; @@ -202,9 +202,9 @@ private: TrackCacheTransform() { type = Animation::TYPE_TRANSFORM; - spatial = NULL; + spatial = nullptr; bone_idx = -1; - skeleton = NULL; + skeleton = nullptr; } }; diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index ce9b8bd213..f993127b07 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -79,7 +79,7 @@ void RootMotionView::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - VS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false)); + RS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false)); first = true; } @@ -122,11 +122,11 @@ void RootMotionView::_notification(int p_what) { } accumulated.origin.z = Math::fposmod(accumulated.origin.z, cell_size); - VS::get_singleton()->immediate_clear(immediate); + RS::get_singleton()->immediate_clear(immediate); int cells_in_radius = int((radius / cell_size) + 1.0); - VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_LINES); + RS::get_singleton()->immediate_begin(immediate, RS::PRIMITIVE_LINES); for (int i = -cells_in_radius; i < cells_in_radius; i++) { for (int j = -cells_in_radius; j < cells_in_radius; j++) { @@ -142,21 +142,21 @@ void RootMotionView::_notification(int p_what) { c_i.a *= MAX(0, 1.0 - from_i.length() / radius); c_j.a *= MAX(0, 1.0 - from_j.length() / radius); - VS::get_singleton()->immediate_color(immediate, c); - VS::get_singleton()->immediate_vertex(immediate, from); + RS::get_singleton()->immediate_color(immediate, c); + RS::get_singleton()->immediate_vertex(immediate, from); - VS::get_singleton()->immediate_color(immediate, c_i); - VS::get_singleton()->immediate_vertex(immediate, from_i); + RS::get_singleton()->immediate_color(immediate, c_i); + RS::get_singleton()->immediate_vertex(immediate, from_i); - VS::get_singleton()->immediate_color(immediate, c); - VS::get_singleton()->immediate_vertex(immediate, from); + RS::get_singleton()->immediate_color(immediate, c); + RS::get_singleton()->immediate_vertex(immediate, from); - VS::get_singleton()->immediate_color(immediate, c_j); - VS::get_singleton()->immediate_vertex(immediate, from_j); + RS::get_singleton()->immediate_color(immediate, c_j); + RS::get_singleton()->immediate_vertex(immediate, from_j); } } - VS::get_singleton()->immediate_end(immediate); + RS::get_singleton()->immediate_end(immediate); } } @@ -197,12 +197,12 @@ RootMotionView::RootMotionView() { radius = 10; cell_size = 1; set_process_internal(true); - immediate = VisualServer::get_singleton()->immediate_create(); + immediate = RenderingServer::get_singleton()->immediate_create(); set_base(immediate); color = Color(0.5, 0.5, 1.0); } RootMotionView::~RootMotionView() { set_base(RID()); - VisualServer::get_singleton()->free(immediate); + RenderingServer::get_singleton()->free(immediate); } diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 628568afbb..bc28c38e2c 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -297,7 +297,7 @@ Variant Tween::_get_initial_val(const InterpolateData &p_data) const { case TARGETING_METHOD: { // Get the object that is being targeted Object *object = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(object == NULL, p_data.initial_val); + ERR_FAIL_COND_V(object == nullptr, p_data.initial_val); // Are we targeting a property or a method? Variant initial_val; @@ -309,7 +309,7 @@ Variant Tween::_get_initial_val(const InterpolateData &p_data) const { } else { // Call the method and get the initial value from it Callable::CallError error; - initial_val = object->call(p_data.target_key[0], NULL, 0, error); + initial_val = object->call(p_data.target_key[0], nullptr, 0, error); ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); } return initial_val; @@ -329,7 +329,7 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const { case FOLLOW_METHOD: { // Get the object that is being followed Object *target = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(target == NULL, p_data.initial_val); + ERR_FAIL_COND_V(target == nullptr, p_data.initial_val); // We want to figure out the final value Variant final_val; @@ -341,7 +341,7 @@ Variant Tween::_get_final_val(const InterpolateData &p_data) const { } else { // We're looking at a method. Call the method on the target object Callable::CallError error; - final_val = target->call(p_data.target_key[0], NULL, 0, error); + final_val = target->call(p_data.target_key[0], nullptr, 0, error); ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); } @@ -371,7 +371,7 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) { case FOLLOW_METHOD: { // We're following an object, so grab that instance Object *target = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(target == NULL, p_data.initial_val); + ERR_FAIL_COND_V(target == nullptr, p_data.initial_val); // We want to figure out the final value Variant final_val; @@ -383,7 +383,7 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) { } else { // We're looking at a method. Call the method on the target object Callable::CallError error; - final_val = target->call(p_data.target_key[0], NULL, 0, error); + final_val = target->call(p_data.target_key[0], nullptr, 0, error); ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); } @@ -607,7 +607,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { // Get the object we want to apply the new value to Object *object = ObjectDB::get_instance(p_data.id); - ERR_FAIL_COND_V(object == NULL, false); + ERR_FAIL_COND_V(object == nullptr, false); // What kind of data are we mutating? switch (p_data.type) { @@ -634,7 +634,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { object->call(p_data.key[0], (const Variant **)arg, 1, error); } else { // Don't pass any argument - object->call(p_data.key[0], NULL, 0, error); + object->call(p_data.key[0], nullptr, 0, error); } // Did we get an error from the function call? @@ -700,7 +700,7 @@ void Tween::_tween_process(float p_delta) { // Get the target object for this interpolation Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // Are we still delaying this tween? @@ -860,7 +860,7 @@ void Tween::reset(Object *p_object, StringName p_key) { // Get the target object InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // Do we have the correct object and key? @@ -901,7 +901,7 @@ void Tween::stop(Object *p_object, StringName p_key) { // Get the object the tween is targeting InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // Is this the correct object and does it have the given key? @@ -937,7 +937,7 @@ void Tween::resume(Object *p_object, StringName p_key) { // Grab the object InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // If the object and string key match, activate it @@ -975,7 +975,7 @@ void Tween::remove(Object *p_object, StringName p_key) { // Get the target object InterpolateData &data = E->get(); Object *object = ObjectDB::get_instance(data.id); - if (object == NULL) + if (object == nullptr) continue; // If the target object and string key match, queue it for removal @@ -1264,7 +1264,7 @@ void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p // Validate and apply interpolation data // Give it the object - ERR_FAIL_COND_MSG(p_object == NULL, "Invalid object provided to Tween."); + ERR_FAIL_COND_MSG(p_object == nullptr, "Invalid object provided to Tween."); data.id = p_object->get_instance_id(); // Validate the initial and final values @@ -1335,7 +1335,7 @@ void Tween::interpolate_property(Object *p_object, NodePath p_property, Variant if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Build the interpolation data - _build_interpolation(INTER_PROPERTY, p_object, &p_property, NULL, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); + _build_interpolation(INTER_PROPERTY, p_object, &p_property, nullptr, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); } void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { @@ -1350,7 +1350,7 @@ void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Build the interpolation data - _build_interpolation(INTER_METHOD, p_object, NULL, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); + _build_interpolation(INTER_METHOD, p_object, nullptr, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); } void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE) { @@ -1361,7 +1361,7 @@ void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_c } // Check that the target object is valid - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); // Duration cannot be negative ERR_FAIL_COND(p_duration < 0); @@ -1418,7 +1418,7 @@ void Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S } // Check that the target object is valid - ERR_FAIL_COND(p_object == NULL); + ERR_FAIL_COND(p_object == nullptr); // No negative durations allowed ERR_FAIL_COND(p_duration < 0); @@ -1486,8 +1486,8 @@ void Tween::follow_property(Object *p_object, NodePath p_property, Variant p_ini if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); // Confirm the source and target objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_target == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_target == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1547,8 +1547,8 @@ void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t(); // Verify the source and target objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_target == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_target == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1566,7 +1566,7 @@ void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initi // Call the method to get the target value Callable::CallError error; - Variant target_val = p_target->call(p_target_method, NULL, 0, error); + Variant target_val = p_target->call(p_target_method, nullptr, 0, error); ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK); // Convert target INT values to FLOAT as they are better for interpolation @@ -1610,8 +1610,8 @@ void Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Verify both objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_initial == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_initial == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1676,8 +1676,8 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t(); // Make sure the given objects are valid - ERR_FAIL_COND(p_object == NULL); - ERR_FAIL_COND(p_initial == NULL); + ERR_FAIL_COND(p_object == nullptr); + ERR_FAIL_COND(p_initial == nullptr); // No negative durations ERR_FAIL_COND(p_duration < 0); @@ -1695,7 +1695,7 @@ void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_in // Call the method to get the initial value Callable::CallError error; - Variant initial_val = p_initial->call(p_initial_method, NULL, 0, error); + Variant initial_val = p_initial->call(p_initial_method, nullptr, 0, error); ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK); // Convert initial INT values to FLOAT as they aer better for interpolation diff --git a/scene/audio/SCsub b/scene/audio/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/audio/SCsub +++ b/scene/audio/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 2582bab200..f612944a62 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -36,7 +36,7 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) { int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); - AudioFrame *targets[4] = { NULL, NULL, NULL, NULL }; + AudioFrame *targets[4] = { nullptr, nullptr, nullptr, nullptr }; if (AudioServer::get_singleton()->get_speaker_mode() == AudioServer::SPEAKER_MODE_STEREO) { targets[0] = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0); diff --git a/scene/debugger/SCsub b/scene/debugger/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/debugger/SCsub +++ b/scene/debugger/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 359f936793..8cb63c4ab5 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -40,7 +40,7 @@ void SceneDebugger::initialize() { #ifdef DEBUG_ENABLED LiveEditor::singleton = memnew(LiveEditor); - EngineDebugger::register_message_capture("scene", EngineDebugger::Capture(NULL, SceneDebugger::parse_message)); + EngineDebugger::register_message_capture("scene", EngineDebugger::Capture(nullptr, SceneDebugger::parse_message)); #endif } @@ -51,7 +51,7 @@ void SceneDebugger::deinitialize() { if (EngineDebugger::has_capture("scene")) EngineDebugger::unregister_message_capture("scene"); memdelete(LiveEditor::singleton); - LiveEditor::singleton = NULL; + LiveEditor::singleton = nullptr; } #endif } @@ -279,7 +279,7 @@ SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) { } } else if (Script *s = Object::cast_to<Script>(obj)) { // Add script constants (no instance). - _parse_script_properties(s, NULL); + _parse_script_properties(s, nullptr); } // Add base object properties. @@ -373,7 +373,7 @@ void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) { var = res->get_path(); } else { //only send information that can be sent.. int len = 0; //test how big is this to encode - encode_variant(var, NULL, len); + encode_variant(var, nullptr, len); if (len > p_max_size) { //limit to max size hint = PROPERTY_HINT_OBJECT_TOO_BIG; hint_string = ""; @@ -478,7 +478,7 @@ void SceneDebuggerTree::deserialize(const Array &p_arr) { } /// LiveEditor -LiveEditor *LiveEditor::singleton = NULL; +LiveEditor *LiveEditor::singleton = nullptr; LiveEditor *LiveEditor::get_singleton() { return singleton; } @@ -515,7 +515,7 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian return; NodePath np = live_edit_node_path_cache[p_id]; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -553,7 +553,7 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A return; NodePath np = live_edit_node_path_cache[p_id]; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -626,7 +626,7 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -664,7 +664,7 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p if (!ps.is_valid()) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -697,7 +697,7 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) { if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -728,7 +728,7 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -762,7 +762,7 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -808,7 +808,7 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_ if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); @@ -841,7 +841,7 @@ void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new if (!scene_tree) return; - Node *base = NULL; + Node *base = nullptr; if (scene_tree->root->has_node(live_edit_root)) base = scene_tree->root->get_node(live_edit_root); diff --git a/scene/gui/SCsub b/scene/gui/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/gui/SCsub +++ b/scene/gui/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index a05ac08e9d..1cdc6f8057 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -498,7 +498,7 @@ BaseButton *ButtonGroup::get_pressed_button() { return E->get(); } - return NULL; + return nullptr; } void ButtonGroup::_bind_methods() { diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index f71d322412..1f8487c173 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -31,7 +31,7 @@ #include "button.h" #include "core/translation.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Size2 Button::get_minimum_size() const { diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index d68bd4fe4e..470450e3ed 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -30,7 +30,7 @@ #include "check_box.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Size2 CheckBox::get_icon_size() const { Ref<Texture2D> checked = Control::get_theme_icon("checked"); diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index ac967a128c..96484424f8 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -31,7 +31,7 @@ #include "check_button.h" #include "core/print_string.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Size2 CheckButton::get_icon_size() const { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 2ec9bb2292..5e0f4c91e8 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -80,7 +80,7 @@ void ColorPicker::_notification(int p_what) { } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - if (screen != NULL && screen->is_visible()) + if (screen != nullptr && screen->is_visible()) screen->hide(); } break; } @@ -275,7 +275,7 @@ void ColorPicker::_text_type_toggled() { c_text->set_editable(false); } else { text_type->set_text("#"); - text_type->set_icon(NULL); + text_type->set_icon(nullptr); c_text->set_editable(true); } @@ -732,7 +732,7 @@ ColorPicker::ColorPicker() : changing_color = false; presets_enabled = true; presets_visible = true; - screen = NULL; + screen = nullptr; HBoxContainer *hb_edit = memnew(HBoxContainer); add_child(hb_edit); @@ -1024,8 +1024,8 @@ ColorPickerButton::ColorPickerButton() { // Initialization is now done deferred, // this improves performance in the inspector as the color picker // can be expensive to initialize. - picker = NULL; - popup = NULL; + picker = nullptr; + popup = nullptr; edit_alpha = true; set_toggle_mode(true); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 14bca0e2c8..775f863a4f 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -40,7 +40,7 @@ #include "scene/main/canvas_layer.h" #include "scene/main/window.h" #include "scene/scene_string_names.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #ifdef TOOLS_ENABLED #include "editor/editor_settings.h" @@ -455,13 +455,13 @@ void Control::remove_child_notify(Node *p_child) { Control *child_c = Object::cast_to<Control>(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { - _propagate_theme_changed(child_c, NULL, NULL); + _propagate_theme_changed(child_c, nullptr, nullptr); } Window *child_w = Object::cast_to<Window>(p_child); if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) { - _propagate_theme_changed(child_w, NULL, NULL); + _propagate_theme_changed(child_w, nullptr, nullptr); } } @@ -470,7 +470,7 @@ void Control::_update_canvas_item_transform() { Transform2D xform = _get_internal_transform(); xform[2] += get_position(); - VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform); + RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform); } void Control::_notification(int p_notification) { @@ -495,7 +495,7 @@ void Control::_notification(int p_notification) { data.parent = Object::cast_to<Control>(get_parent()); Node *parent = this; //meh - Control *parent_control = NULL; + Control *parent_control = nullptr; bool subwindow = false; while (parent) { @@ -548,7 +548,7 @@ void Control::_notification(int p_notification) { if (data.parent_canvas_item) { data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); - data.parent_canvas_item = NULL; + data.parent_canvas_item = nullptr; } else if (!is_set_as_toplevel()) { //disconnect viewport get_viewport()->disconnect("size_changed", callable_mp(this, &Control::_size_changed)); @@ -556,17 +556,11 @@ void Control::_notification(int p_notification) { if (data.RI) { get_viewport()->_gui_remove_root_control(data.RI); - data.RI = NULL; + data.RI = nullptr; } - data.parent = NULL; - data.parent_canvas_item = NULL; - /* - if (data.theme_owner && data.theme.is_null()) { - data.theme_owner=NULL; - notification(NOTIFICATION_THEME_CHANGED); - } - */ + data.parent = nullptr; + data.parent_canvas_item = nullptr; } break; case NOTIFICATION_MOVED_IN_PARENT: { @@ -588,8 +582,8 @@ void Control::_notification(int p_notification) { case NOTIFICATION_DRAW: { _update_canvas_item_transform(); - VisualServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), !data.disable_visibility_clip, Rect2(Point2(), get_size())); - VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), data.clip_contents); + RenderingServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), !data.disable_visibility_clip, Rect2(Point2(), get_size())); + RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), data.clip_contents); //emit_signal(SceneStringNames::get_singleton()->draw); } break; @@ -621,7 +615,7 @@ void Control::_notification(int p_notification) { if (!is_visible_in_tree()) { - if (get_viewport() != NULL) + if (get_viewport() != nullptr) get_viewport()->_gui_hid_control(this); //remove key focus @@ -753,7 +747,7 @@ Size2 Control::get_minimum_size() const { if (si) { Callable::CallError ce; - Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, NULL, 0, ce); + Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, nullptr, 0, ce); if (ce.error == Callable::CallError::CALL_OK) return s; } @@ -799,8 +793,8 @@ bool Control::_find_theme_item(Control *p_theme_owner, Window *p_theme_owner_win theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = NULL; - theme_owner_window = NULL; + theme_owner = nullptr; + theme_owner_window = nullptr; } } } @@ -843,8 +837,8 @@ bool Control::_has_theme_item(Control *p_theme_owner, Window *p_theme_owner_wind theme_owner_window = parent_w->theme_owner_window; } else { - theme_owner = NULL; - theme_owner_window = NULL; + theme_owner = nullptr; + theme_owner_window = nullptr; } } } @@ -1034,37 +1028,37 @@ int Control::get_constants(Control *p_theme_owner, Window *p_theme_owner_window, bool Control::has_theme_icon_override(const StringName &p_name) const { const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); - return tex != NULL; + return tex != nullptr; } bool Control::has_theme_shader_override(const StringName &p_name) const { const Ref<Shader> *sdr = data.shader_override.getptr(p_name); - return sdr != NULL; + return sdr != nullptr; } bool Control::has_theme_stylebox_override(const StringName &p_name) const { const Ref<StyleBox> *style = data.style_override.getptr(p_name); - return style != NULL; + return style != nullptr; } bool Control::has_theme_font_override(const StringName &p_name) const { const Ref<Font> *font = data.font_override.getptr(p_name); - return font != NULL; + return font != nullptr; } bool Control::has_theme_color_override(const StringName &p_name) const { const Color *color = data.color_override.getptr(p_name); - return color != NULL; + return color != nullptr; } bool Control::has_theme_constant_override(const StringName &p_name) const { const int *constant = data.constant_override.getptr(p_name); - return constant != NULL; + return constant != nullptr; } bool Control::has_theme_icon(const StringName &p_name, const StringName &p_type) const { @@ -1890,17 +1884,17 @@ void Control::set_focus_mode(FocusMode p_focus_mode) { static Control *_next_control(Control *p_from) { if (p_from->is_set_as_toplevel()) - return NULL; // can't go above + return nullptr; // can't go above Control *parent = Object::cast_to<Control>(p_from->get_parent()); if (!parent) { - return NULL; + return nullptr; } int next = p_from->get_position_in_parent(); - ERR_FAIL_INDEX_V(next, parent->get_child_count(), NULL); + ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr); for (int i = (next + 1); i < parent->get_child_count(); i++) { Control *c = Object::cast_to<Control>(parent->get_child(i)); @@ -1927,9 +1921,9 @@ Control *Control::find_next_valid_focus() const { Control *c; if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Next focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Next focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) return c; @@ -1937,7 +1931,7 @@ Control *Control::find_next_valid_focus() const { // find next child - Control *next_child = NULL; + Control *next_child = nullptr; for (int i = 0; i < from->get_child_count(); i++) { @@ -1974,7 +1968,7 @@ Control *Control::find_next_valid_focus() const { } if (next_child == this) // no next control-> - return (get_focus_mode() == FOCUS_ALL) ? next_child : NULL; + return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr; if (next_child) { if (next_child->get_focus_mode() == FOCUS_ALL) return next_child; @@ -1983,12 +1977,12 @@ Control *Control::find_next_valid_focus() const { break; } - return NULL; + return nullptr; } static Control *_prev_control(Control *p_from) { - Control *child = NULL; + Control *child = nullptr; for (int i = p_from->get_child_count() - 1; i >= 0; i--) { Control *c = Object::cast_to<Control>(p_from->get_child(i)); @@ -2018,9 +2012,9 @@ Control *Control::find_prev_valid_focus() const { Control *c; if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Previous focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Previous focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) return c; @@ -2028,7 +2022,7 @@ Control *Control::find_prev_valid_focus() const { // find prev child - Control *prev_child = NULL; + Control *prev_child = nullptr; if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) { @@ -2060,7 +2054,7 @@ Control *Control::find_prev_valid_focus() const { } if (prev_child == this) // no prev control-> - return (get_focus_mode() == FOCUS_ALL) ? prev_child : NULL; + return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr; if (prev_child->get_focus_mode() == FOCUS_ALL) return prev_child; @@ -2068,7 +2062,7 @@ Control *Control::find_prev_valid_focus() const { from = prev_child; } - return NULL; + return nullptr; } Control::FocusMode Control::get_focus_mode() const { @@ -2221,7 +2215,7 @@ Control *Control::make_custom_tooltip(const String &p_text) const { if (get_script_instance()) { return const_cast<Control *>(this)->call("_make_custom_tooltip", p_text); } - return NULL; + return nullptr; } void Control::set_default_cursor_shape(CursorShape p_shape) { @@ -2288,19 +2282,19 @@ NodePath Control::get_focus_previous() const { Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { - ERR_FAIL_INDEX_V((int)p_margin, 4, NULL); + ERR_FAIL_INDEX_V((int)p_margin, 4, nullptr); if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT) - return NULL; + return nullptr; if (!data.focus_neighbour[p_margin].is_empty()) { - Control *c = NULL; + Control *c = nullptr; Node *n = get_node(data.focus_neighbour[p_margin]); if (n) { c = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!c, NULL, "Neighbor focus node is not a control: " + n->get_name() + "."); + ERR_FAIL_COND_V_MSG(!c, nullptr, "Neighbor focus node is not a control: " + n->get_name() + "."); } else { - return NULL; + return nullptr; } bool valid = true; if (!c->is_visible()) @@ -2315,7 +2309,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { } float dist = 1e7; - Control *result = NULL; + Control *result = nullptr; Point2 points[4]; @@ -2357,7 +2351,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { } if (!base) - return NULL; + return nullptr; _window_find_focus_neighbour(vdir, base, points, maxd, dist, &result); @@ -2515,7 +2509,7 @@ Control::MouseFilter Control::get_mouse_filter() const { Control *Control::get_focus_owner() const { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); return get_viewport()->_gui_get_focus_owner(); } @@ -2991,19 +2985,19 @@ void Control::_bind_methods() { } Control::Control() { - data.parent = NULL; + data.parent = nullptr; data.mouse_filter = MOUSE_FILTER_STOP; - data.RI = NULL; - data.theme_owner = NULL; - data.theme_owner_window = NULL; + data.RI = nullptr; + data.theme_owner = nullptr; + data.theme_owner_window = nullptr; data.default_cursor = CURSOR_ARROW; data.h_size_flags = SIZE_FILL; data.v_size_flags = SIZE_FILL; data.expand = 1; data.rotation = 0; - data.parent_canvas_item = NULL; + data.parent_canvas_item = nullptr; data.scale = Vector2(1, 1); data.block_minimum_size_adjust = false; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index a4f0338f00..6be74d8d29 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -34,11 +34,11 @@ #include "core/print_string.h" #include "scene/gui/label.h" -FileDialog::GetIconFunc FileDialog::get_icon_func = NULL; -FileDialog::GetIconFunc FileDialog::get_large_icon_func = NULL; +FileDialog::GetIconFunc FileDialog::get_icon_func = nullptr; +FileDialog::GetIconFunc FileDialog::get_large_icon_func = nullptr; -FileDialog::RegisterFunc FileDialog::register_func = NULL; -FileDialog::RegisterFunc FileDialog::unregister_func = NULL; +FileDialog::RegisterFunc FileDialog::register_func = nullptr; +FileDialog::RegisterFunc FileDialog::unregister_func = nullptr; VBoxContainer *FileDialog::get_vbox() { return vbox; @@ -195,7 +195,7 @@ void FileDialog::_action_pressed() { if (mode == FILE_MODE_OPEN_FILES) { - TreeItem *ti = tree->get_next_selected(NULL); + TreeItem *ti = tree->get_next_selected(nullptr); String fbase = dir_access->get_current_dir(); Vector<String> files; @@ -543,7 +543,7 @@ void FileDialog::update_file_list() { files.pop_front(); } - if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == NULL) + if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == nullptr) tree->get_root()->get_children()->select(0); } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index fd7935b376..e37e93e2a9 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -854,7 +854,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (in_box) gn->set_selected(box_selection_mode_aditive); else - gn->set_selected(previus_selected.find(gn) != NULL); + gn->set_selected(previus_selected.find(gn) != nullptr); } top_layer->update(); @@ -872,7 +872,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (!gn) continue; - gn->set_selected(previus_selected.find(gn) != NULL); + gn->set_selected(previus_selected.find(gn) != nullptr); } top_layer->update(); } else { @@ -922,7 +922,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { - GraphNode *gn = NULL; + GraphNode *gn = nullptr; for (int i = get_child_count() - 1; i >= 0; i--) { @@ -1323,7 +1323,7 @@ GraphEdit::GraphEdit() { set_focus_mode(FOCUS_ALL); awaiting_scroll_offset_update = false; - top_layer = NULL; + top_layer = nullptr; top_layer = memnew(GraphEditFilter(this)); add_child(top_layer); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index c28a60ff87..5dbc5bc50d 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -593,7 +593,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid()) { - ERR_FAIL_COND_MSG(get_parent_control() == NULL, "GraphNode must be the child of a GraphEdit node."); + ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphNode must be the child of a GraphEdit node."); if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 2db44d0b66..47a5ac68d2 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -859,9 +859,9 @@ void ItemList::_notification(int p_what) { } if (has_focus()) { - VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true); draw_style_box(get_theme_stylebox("bg_focus"), Rect2(Point2(), size)); - VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false); } if (shape_changed) { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index ef1bb958f6..bedcef2df2 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -84,7 +84,7 @@ void Label::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { if (clip) { - VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); + RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); } if (word_cache_dirty) @@ -105,7 +105,7 @@ void Label::_notification(int p_what) { style->draw(ci, Rect2(Point2(0, 0), get_size())); - VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(), font.is_valid() && font->is_distance_field_hint()); + RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(), font.is_valid() && font->is_distance_field_hint()); int font_h = font->get_height() + line_spacing; @@ -282,7 +282,7 @@ void Label::_notification(int p_what) { from = from->next; } - wc = to ? to->next : 0; + wc = to ? to->next : nullptr; line++; } } @@ -404,7 +404,7 @@ void Label::regenerate_word_cache() { line_count = 1; total_char_cache = 0; - WordCache *last = NULL; + WordCache *last = nullptr; for (int i = 0; i <= xl_text.length(); i++) { @@ -447,7 +447,7 @@ void Label::regenerate_word_cache() { } if (i < xl_text.length() && xl_text[i] == ' ') { - if (line_width > 0 || last == NULL || last->char_pos != WordCache::CHAR_WRAPLINE) { + if (line_width > 0 || last == nullptr || last->char_pos != WordCache::CHAR_WRAPLINE) { space_count++; line_width += space_width; } else { @@ -697,7 +697,7 @@ Label::Label(const String &p_text) { align = ALIGN_LEFT; valign = VALIGN_TOP; xl_text = ""; - word_cache = NULL; + word_cache = nullptr; word_cache_dirty = true; autowrap = false; line_count = 0; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 734e27b1b6..b9b7560f2e 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -630,7 +630,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { int selected = selection.end - selection.begin; Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { for (int i = selection.begin; i < selection.end; i++) cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width; } @@ -815,9 +815,9 @@ void LineEdit::_notification(int p_what) { bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y; if (selected) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color); } else { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color); } drawer.draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, font_color); @@ -839,7 +839,7 @@ void LineEdit::_notification(int p_what) { bool selected = selection.enabled && char_ofs >= selection.begin && char_ofs < selection.end; if (selected) - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color); int yofs = y_ofs + (caret_height - font->get_height()) / 2; drawer.draw_char(ci, Point2(x_ofs, yofs + font_ascent), cchar, next, selected ? font_color_selected : font_color); @@ -847,9 +847,9 @@ void LineEdit::_notification(int p_what) { if (char_ofs == cursor_pos && draw_caret && !using_placeholder) { if (ime_text.length() == 0) { #ifdef TOOLS_ENABLED - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); #else - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(1, caret_height)), cursor_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(1, caret_height)), cursor_color); #endif } } @@ -874,9 +874,9 @@ void LineEdit::_notification(int p_what) { bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y; if (selected) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 3)), font_color); } else { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs + caret_height), Size2(im_char_width, 1)), font_color); } drawer.draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, font_color); @@ -905,9 +905,9 @@ void LineEdit::_notification(int p_what) { } } #ifdef TOOLS_ENABLED - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); #else - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(1, caret_height)), cursor_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(caret_x_ofs, y_ofs), Size2(1, caret_height)), cursor_color); #endif } } @@ -1001,7 +1001,7 @@ void LineEdit::paste_text() { } void LineEdit::undo() { - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { if (undo_stack.size() <= 1) { return; } @@ -1023,7 +1023,7 @@ void LineEdit::undo() { } void LineEdit::redo() { - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { return; } if (undo_stack_pos == undo_stack.back()) { @@ -1096,7 +1096,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { while (ofs < text.length()) { int char_w = 0; - if (font != NULL) { + if (font != nullptr) { char_w = font->get_char_size(pass ? secret_character[0] : text[ofs]).width; } pixel_ofs += char_w; @@ -1148,7 +1148,7 @@ int LineEdit::get_cursor_pixel_pos() { } while (ofs < cursor_pos) { - if (font != NULL) { + if (font != nullptr) { pixel_ofs += font->get_char_size(pass ? secret_character[0] : text[ofs]).width; } ofs++; @@ -1207,7 +1207,7 @@ void LineEdit::delete_char() { if ((text.length() <= 0) || (cursor_pos == 0)) return; Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { cached_width -= font->get_char_size(pass ? secret_character[0] : text[cursor_pos - 1]).width; } @@ -1226,7 +1226,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { if (text.size() > 0) { Ref<Font> font = get_theme_font("font"); - if (font != NULL) { + if (font != nullptr) { for (int i = p_from_column; i < p_to_column; i++) cached_width -= font->get_char_size(pass ? secret_character[0] : text[i]).width; } @@ -1709,7 +1709,7 @@ void LineEdit::_emit_text_change() { void LineEdit::update_cached_width() { Ref<Font> font = get_theme_font("font"); cached_width = 0; - if (font != NULL) { + if (font != nullptr) { String text = get_text(); for (int i = 0; i < text.length(); i++) { cached_width += font->get_char_size(pass ? secret_character[0] : text[i]).width; @@ -1720,7 +1720,7 @@ void LineEdit::update_cached_width() { void LineEdit::update_placeholder_width() { Ref<Font> font = get_theme_font("font"); cached_placeholder_width = 0; - if (font != NULL) { + if (font != nullptr) { for (int i = 0; i < placeholder_translated.length(); i++) { cached_placeholder_width += font->get_char_size(placeholder_translated[i]).width; } @@ -1729,7 +1729,7 @@ void LineEdit::update_placeholder_width() { void LineEdit::_clear_redo() { _create_undo_state(); - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { return; } @@ -1744,7 +1744,7 @@ void LineEdit::_clear_redo() { void LineEdit::_clear_undo_stack() { undo_stack.clear(); - undo_stack_pos = NULL; + undo_stack_pos = nullptr; _create_undo_state(); } @@ -1865,7 +1865,7 @@ void LineEdit::_bind_methods() { LineEdit::LineEdit() { - undo_stack_pos = NULL; + undo_stack_pos = nullptr; _create_undo_state(); align = ALIGN_LEFT; cached_width = 0; diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 0ef1f53006..cf10c4cfbd 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -30,7 +30,7 @@ #include "nine_patch_rect.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void NinePatchRect::_notification(int p_what) { @@ -45,7 +45,7 @@ void NinePatchRect::_notification(int p_what) { texture->get_rect_region(rect, src_rect, rect, src_rect); RID ci = get_canvas_item(); - VS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NinePatchAxisMode(axis_h), VS::NinePatchAxisMode(axis_v), draw_center); + RS::get_singleton()->canvas_item_add_nine_patch(ci, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center); } } diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index ae51463a15..a17d0eb9c6 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "panel.h" + #include "core/print_string.h" void Panel::_notification(int p_what) { @@ -54,7 +55,11 @@ void Panel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_mode"), &Panel::get_mode); ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Background,Foreground"), "set_mode", "get_mode"); + + BIND_ENUM_CONSTANT(MODE_BACKGROUND); + BIND_ENUM_CONSTANT(MODE_FOREGROUND); } + Panel::Panel() { // Has visible stylebox, so stop by default. set_mouse_filter(MOUSE_FILTER_STOP); diff --git a/scene/gui/panel.h b/scene/gui/panel.h index 739c64c0a6..75e266b6a6 100644 --- a/scene/gui/panel.h +++ b/scene/gui/panel.h @@ -40,7 +40,7 @@ class Panel : public Control { public: enum Mode { MODE_BACKGROUND, - MODE_FOREGROUND + MODE_FOREGROUND, }; private: @@ -59,4 +59,5 @@ public: }; VARIANT_ENUM_CAST(Panel::Mode) -#endif + +#endif // PANEL_H diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index c096dc94cb..1e933c9aa1 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -394,7 +394,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; - if (allow_search && k.is_valid() && k->get_unicode()) { + if (allow_search && k.is_valid() && k->get_unicode() && k->is_pressed()) { uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t diff = now - search_time_msec; @@ -1514,6 +1514,7 @@ PopupMenu::PopupMenu() { submenu_over = -1; initial_button_mask = 0; during_grabbed_click = false; + invalidated_click = false; allow_search = false; search_time_msec = 0; diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index adc5f81465..ab2f64e1b4 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -236,7 +236,7 @@ void Range::_unref_shared() { shared->owners.erase(this); if (shared->owners.size() == 0) { memdelete(shared); - shared = NULL; + shared = nullptr; } } } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index df28a4c12f..5fb2243aff 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -53,7 +53,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return p_item->subitems.front()->get(); } else if (!p_item->parent) { - return NULL; + return nullptr; } else if (p_item->E->next()) { return p_item->E->next()->get(); @@ -66,7 +66,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { if (p_item->parent) return p_item->E->next()->get(); else - return NULL; + return nullptr; } } else { @@ -74,7 +74,7 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { return p_item->subitems.front()->get(); } else if (p_item->type == ITEM_FRAME) { - return NULL; + return nullptr; } else if (p_item->E->next()) { return p_item->E->next()->get(); @@ -87,11 +87,11 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) { if (p_item->type != ITEM_FRAME) return p_item->E->next()->get(); else - return NULL; + return nullptr; } } - return NULL; + return nullptr; } RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { @@ -101,7 +101,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { return p_item->subitems.back()->get(); } else if (!p_item->parent) { - return NULL; + return nullptr; } else if (p_item->E->prev()) { return p_item->E->prev()->get(); @@ -114,7 +114,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { if (p_item->parent) return p_item->E->prev()->get(); else - return NULL; + return nullptr; } } else { @@ -122,7 +122,7 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { return p_item->subitems.back()->get(); } else if (p_item->type == ITEM_FRAME) { - return NULL; + return nullptr; } else if (p_item->E->prev()) { return p_item->E->prev()->get(); @@ -135,11 +135,11 @@ RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) { if (p_item->type != ITEM_FRAME) return p_item->E->prev()->get(); else - return NULL; + return nullptr; } } - return NULL; + return nullptr; } Rect2 RichTextLabel::_get_text_rect() { @@ -158,7 +158,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & ci = get_canvas_item(); if (r_click_item) - *r_click_item = NULL; + *r_click_item = nullptr; } Line &l = p_frame->lines.write[p_line]; Item *it = l.from; @@ -356,7 +356,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & Color font_color_shadow; bool underline = false; bool strikethrough = false; - ItemFade *fade = NULL; + ItemFade *fade = nullptr; int it_char_start = p_char_count; Vector<ItemFX *> fx_stack = Vector<ItemFX *>(); @@ -603,7 +603,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & #ifdef TOOLS_ENABLED underline_width *= EDSCALE; #endif - VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width); + RS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, underline_width); } else if (strikethrough) { Color uc = color; uc.a *= 0.5; @@ -612,7 +612,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & #ifdef TOOLS_ENABLED strikethrough_width *= EDSCALE; #endif - VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width); + RS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + wofs, uy), p_ofs + Point2(align_ofs + wofs + w, uy), uc, strikethrough_width); } } @@ -915,7 +915,7 @@ void RichTextLabel::_update_scroll() { void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_time) { Item *it = p_frame; while (it) { - ItemFX *ifx = NULL; + ItemFX *ifx = nullptr; if (it->type == ITEM_CUSTOMFX || it->type == ITEM_SHAKE || it->type == ITEM_WAVE || it->type == ITEM_TORNADO || it->type == ITEM_RAINBOW) { ifx = static_cast<ItemFX *>(it); @@ -928,7 +928,7 @@ void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, float p_delta_ ifx->elapsed_time += p_delta_time; - ItemShake *shake = NULL; + ItemShake *shake = nullptr; if (it->type == ITEM_SHAKE) { shake = static_cast<ItemShake *>(it); @@ -952,7 +952,7 @@ void RichTextLabel::_notification(int p_what) { case NOTIFICATION_MOUSE_EXIT: { if (meta_hovering) { - meta_hovering = NULL; + meta_hovering = nullptr; emit_signal("meta_hover_ended", current_meta); current_meta = false; update(); @@ -991,9 +991,9 @@ void RichTextLabel::_notification(int p_what) { draw_style_box(get_theme_stylebox("normal"), Rect2(Point2(), size)); if (has_focus()) { - VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); draw_style_box(get_theme_stylebox("focus"), Rect2(Point2(), size)); - VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); } int ofs = vscroll->get_value(); @@ -1022,7 +1022,7 @@ void RichTextLabel::_notification(int p_what) { visible_line_count = 0; while (y < size.height && from_line < main->lines.size()) { - visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), NULL, NULL, NULL, total_chars); + visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), nullptr, nullptr, nullptr, total_chars); total_chars += main->lines[from_line].char_count; from_line++; @@ -1040,7 +1040,7 @@ void RichTextLabel::_notification(int p_what) { void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item, int *r_click_char, bool *r_outside) { if (r_click_item) - *r_click_item = NULL; + *r_click_item = nullptr; Rect2 text_rect = _get_text_rect(); int ofs = vscroll->get_value(); @@ -1086,11 +1086,11 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const return CURSOR_ARROW; //invalid int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; ((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line, &outside); - if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, NULL)) + if (item && !outside && ((RichTextLabel *)(this))->_find_meta(item, nullptr)) return CURSOR_POINTING_HAND; return CURSOR_ARROW; @@ -1108,7 +1108,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed() && !b->is_doubleclick()) { scroll_updated = false; int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1122,9 +1122,9 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { // Erase previous selection. if (selection.active) { - selection.from = NULL; + selection.from = nullptr; selection.from_char = '\0'; - selection.to = NULL; + selection.to = nullptr; selection.to_char = '\0'; selection.active = false; @@ -1136,7 +1136,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { //doubleclick: select word int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1163,11 +1163,11 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { } } else if (!b->is_pressed()) { - selection.click = NULL; + selection.click = nullptr; if (!b->is_doubleclick() && !scroll_updated) { int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, b->get_position(), &item, &line, &outside); @@ -1276,7 +1276,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { return; int line = 0; - Item *item = NULL; + Item *item = nullptr; bool outside; _find_click(main, m->get_position(), &item, &line, &outside); @@ -1325,7 +1325,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { emit_signal("meta_hover_started", meta); } } else if (meta_hovering) { - meta_hovering = NULL; + meta_hovering = nullptr; emit_signal("meta_hover_ended", current_meta); current_meta = false; } @@ -1641,7 +1641,7 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) } } - if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) { + if (current_frame->lines[current_frame->lines.size() - 1].from == nullptr) { current_frame->lines.write[current_frame->lines.size() - 1].from = p_item; } p_item->line = current_frame->lines.size() - 1; @@ -1938,7 +1938,7 @@ void RichTextLabel::push_cell() { item->cell = true; item->parent_line = item->parent_frame->lines.size() - 1; item->lines.resize(1); - item->lines.write[0].from = NULL; + item->lines.write[0].from = nullptr; item->first_invalid_line = 0; } @@ -1969,7 +1969,7 @@ void RichTextLabel::clear() { main->lines.resize(1); main->first_invalid_line = 0; update(); - selection.click = NULL; + selection.click = nullptr; selection.active = false; current_idx = 1; @@ -2953,7 +2953,7 @@ RichTextLabel::RichTextLabel() { tab_size = 4; default_align = ALIGN_LEFT; underline_meta = true; - meta_hovering = NULL; + meta_hovering = nullptr; override_selected_font_color = false; scroll_visible = false; @@ -2977,7 +2977,7 @@ RichTextLabel::RichTextLabel() { current_idx = 1; use_bbcode = false; - selection.click = NULL; + selection.click = nullptr; selection.active = false; selection.enabled = false; diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index dd439208af..7f2b5facb9 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -98,7 +98,7 @@ private: int maximum_width; Line() { - from = NULL; + from = nullptr; char_count = 0; } }; @@ -119,9 +119,11 @@ private: } Item() { - parent = NULL; - E = NULL; + parent = nullptr; + E = nullptr; line = 0; + index = 0; + type = ITEM_FRAME; } virtual ~Item() { _clear_children(); } }; @@ -135,7 +137,7 @@ private: ItemFrame() { type = ITEM_FRAME; - parent_frame = NULL; + parent_frame = nullptr; cell = false; parent_line = 0; } @@ -368,8 +370,8 @@ private: int visible_characters; float percent_visible; - int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0); - void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL); + int _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Color &p_font_color_shadow, bool p_shadow_as_outline, const Point2 &shadow_ofs, const Point2i &p_click_pos = Point2i(), Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr, int p_char_count = 0); + void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr); Ref<Font> _find_font(Item *p_item); int _find_margin(Item *p_item, const Ref<Font> &p_base_font); @@ -377,7 +379,7 @@ private: Color _find_color(Item *p_item, const Color &p_default_color); bool _find_underline(Item *p_item); bool _find_strikethrough(Item *p_item); - bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL); + bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = nullptr); bool _find_layout_subitem(Item *from, Item *to); bool _find_by_type(Item *p_item, ItemType p_type); void _fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 5e9541730e..1c63c25e28 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -308,7 +308,7 @@ void ScrollBar::_notification(int p_what) { drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit)); } - drag_node = NULL; + drag_node = nullptr; } if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { @@ -542,7 +542,7 @@ void ScrollBar::_drag_node_exit() { if (drag_node) { drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); } - drag_node = NULL; + drag_node = nullptr; } void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) { @@ -616,7 +616,7 @@ void ScrollBar::set_drag_node(const NodePath &p_path) { } } - drag_node = NULL; + drag_node = nullptr; drag_node_path = p_path; if (is_inside_tree()) { @@ -662,7 +662,7 @@ ScrollBar::ScrollBar(Orientation p_orientation) { orientation = p_orientation; highlight = HIGHLIGHT_NONE; custom_step = -1; - drag_node = NULL; + drag_node = nullptr; drag.active = false; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index ccfa8ebf63..8572d570fb 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -60,7 +60,7 @@ void SpinBox::_text_entered(const String &p_string) { return; } - Variant value = expr->execute(Array(), NULL, false); + Variant value = expr->execute(Array(), nullptr, false); if (value.get_type() != Variant::NIL) { set_value(value); _value_changed(0); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 4eb614a9ac..de892a4fb9 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -50,7 +50,7 @@ Control *SplitContainer::_getch(int p_idx) const { idx++; } - return NULL; + return nullptr; } void SplitContainer::_resort() { diff --git a/scene/gui/viewport_container.cpp b/scene/gui/subviewport_container.cpp index 7ce1d9e551..50f468741d 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* viewport_container.cpp */ +/* subviewport_container.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,12 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "viewport_container.h" +#include "subviewport_container.h" #include "core/engine.h" #include "scene/main/viewport.h" -Size2 ViewportContainer::get_minimum_size() const { +Size2 SubViewportContainer::get_minimum_size() const { if (stretch) return Size2(); @@ -52,19 +52,19 @@ Size2 ViewportContainer::get_minimum_size() const { return ms; } -void ViewportContainer::set_stretch(bool p_enable) { +void SubViewportContainer::set_stretch(bool p_enable) { stretch = p_enable; queue_sort(); update(); } -bool ViewportContainer::is_stretch_enabled() const { +bool SubViewportContainer::is_stretch_enabled() const { return stretch; } -void ViewportContainer::set_stretch_shrink(int p_shrink) { +void SubViewportContainer::set_stretch_shrink(int p_shrink) { ERR_FAIL_COND(p_shrink < 1); if (shrink == p_shrink) @@ -87,12 +87,12 @@ void ViewportContainer::set_stretch_shrink(int p_shrink) { update(); } -int ViewportContainer::get_stretch_shrink() const { +int SubViewportContainer::get_stretch_shrink() const { return shrink; } -void ViewportContainer::_notification(int p_what) { +void SubViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_RESIZED) { @@ -142,7 +142,7 @@ void ViewportContainer::_notification(int p_what) { } } -void ViewportContainer::_input(const Ref<InputEvent> &p_event) { +void SubViewportContainer::_input(const Ref<InputEvent> &p_event) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -167,7 +167,7 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) { } } -void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { +void SubViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { if (Engine::get_singleton()->is_editor_hint()) return; @@ -192,21 +192,21 @@ void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { } } -void ViewportContainer::_bind_methods() { +void SubViewportContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &ViewportContainer::_unhandled_input); - ClassDB::bind_method(D_METHOD("_input", "event"), &ViewportContainer::_input); - ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &ViewportContainer::set_stretch); - ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &ViewportContainer::is_stretch_enabled); + ClassDB::bind_method(D_METHOD("_unhandled_input", "event"), &SubViewportContainer::_unhandled_input); + ClassDB::bind_method(D_METHOD("_input", "event"), &SubViewportContainer::_input); + ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch); + ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled); - ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &ViewportContainer::set_stretch_shrink); - ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &ViewportContainer::get_stretch_shrink); + ClassDB::bind_method(D_METHOD("set_stretch_shrink", "amount"), &SubViewportContainer::set_stretch_shrink); + ClassDB::bind_method(D_METHOD("get_stretch_shrink"), &SubViewportContainer::get_stretch_shrink); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stretch"), "set_stretch", "is_stretch_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_shrink"), "set_stretch_shrink", "get_stretch_shrink"); } -ViewportContainer::ViewportContainer() { +SubViewportContainer::SubViewportContainer() { stretch = false; shrink = 1; diff --git a/scene/gui/viewport_container.h b/scene/gui/subviewport_container.h index 8597444426..6ff3d188e2 100644 --- a/scene/gui/viewport_container.h +++ b/scene/gui/subviewport_container.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* viewport_container.h */ +/* subviewport_container.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,9 +33,9 @@ #include "scene/gui/container.h" -class ViewportContainer : public Container { +class SubViewportContainer : public Container { - GDCLASS(ViewportContainer, Container); + GDCLASS(SubViewportContainer, Container); bool stretch; int shrink; @@ -55,7 +55,7 @@ public: virtual Size2 get_minimum_size() const; - ViewportContainer(); + SubViewportContainer(); }; #endif // VIEWPORTCONTAINER_H diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 7cecbf7fa2..de80049862 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -602,7 +602,7 @@ Control *TabContainer::get_tab_control(int p_idx) const { if (p_idx >= 0 && p_idx < tabs.size()) return tabs[p_idx]; else - return NULL; + return nullptr; } Control *TabContainer::get_current_tab_control() const { @@ -611,7 +611,7 @@ Control *TabContainer::get_current_tab_control() const { if (current >= 0 && current < tabs.size()) return tabs[current]; else - return NULL; + return nullptr; } void TabContainer::remove_child_notify(Node *p_child) { @@ -1041,7 +1041,7 @@ TabContainer::TabContainer() { previous = 0; align = ALIGN_CENTER; tabs_visible = true; - popup = NULL; + popup = nullptr; drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; use_hidden_tabs_for_min_size = false; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index fb477ee3b4..36e35897d1 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -728,7 +728,7 @@ void TextEdit::_notification(int p_what) { _update_scrollbars(); RID ci = get_canvas_item(); - VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); + RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width; int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT) - cache.minimap_width; @@ -749,14 +749,14 @@ void TextEdit::_notification(int p_what) { if (syntax_coloring) { if (cache.background_color.a > 0.01) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), cache.background_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), cache.background_color); } } if (line_length_guidelines) { const int hard_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_hard_col - cursor.x_ofs; if (hard_x > xmargin_beg && hard_x < xmargin_end) { - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color); } // Draw a "Soft" line length guideline, less visible than the hard line length guideline. @@ -764,7 +764,7 @@ void TextEdit::_notification(int p_what) { // Only drawn if its column differs from the hard line length guideline. const int soft_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_soft_col - cursor.x_ofs; if (hard_x != soft_x && soft_x > xmargin_beg && soft_x < xmargin_end) { - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5)); + RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5)); } } @@ -955,7 +955,7 @@ void TextEdit::_notification(int p_what) { // draw the minimap Color viewport_color = (cache.background_color.get_v() < 0.5) ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), viewport_offset_y, cache.minimap_width, viewport_height), viewport_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), viewport_offset_y, cache.minimap_width, viewport_height), viewport_color); for (int i = 0; i < minimap_draw_amount; i++) { minimap_line++; @@ -1008,7 +1008,7 @@ void TextEdit::_notification(int p_what) { } if (minimap_line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), i * 3, cache.minimap_width, 2), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), i * 3, cache.minimap_width, 2), cache.current_line_color); } Color previous_color; @@ -1057,7 +1057,7 @@ void TextEdit::_notification(int p_what) { // take one for zero indexing, and if we hit whitespace / the end of a word. int chars = MAX(0, (j - (characters - 1)) - (is_whitespace ? 1 : 0)) + 1; int char_x_ofs = indent_px + ((xmargin_end + minimap_char_size.x) + (minimap_char_size.x * chars)) + tabs; - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_x_ofs, minimap_line_height * i), Point2(minimap_char_size.x * characters, minimap_char_size.y)), previous_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_x_ofs, minimap_line_height * i), Point2(minimap_char_size.x * characters, minimap_char_size.y)), previous_color); } if (out_of_bounds) { @@ -1164,24 +1164,24 @@ void TextEdit::_notification(int p_what) { } if (text.is_marked(line)) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color); } if (str.length() == 0) { // Draw line background if empty as we won't loop at at all. if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); } // Give visual indication of empty selected line. if (selection.active && line >= selection.from_line && line <= selection.to_line && char_margin >= xmargin_beg) { int char_w = cache.font->get_char_size(' ').width; - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color); } } else { // If it has text, then draw current line marker in the margin, as line number etc will draw over it, draw the rest of line marker later. if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_beg + ofs_x, get_row_height()), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_beg + ofs_x, get_row_height()), cache.current_line_color); } } @@ -1190,9 +1190,9 @@ void TextEdit::_notification(int p_what) { if (text.is_breakpoint(line) && !draw_breakpoint_gutter) { #ifdef TOOLS_ENABLED - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color); #else - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color); #endif } @@ -1202,7 +1202,7 @@ void TextEdit::_notification(int p_what) { int vertical_gap = (get_row_height() * 40) / 100; int horizontal_gap = (cache.breakpoint_gutter_width * 30) / 100; int marker_radius = get_row_height() - (vertical_gap * 2); - VisualServer::get_singleton()->canvas_item_add_circle(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 + marker_radius / 2, ofs_y + vertical_gap + marker_radius / 2), marker_radius, Color(cache.bookmark_color.r, cache.bookmark_color.g, cache.bookmark_color.b)); + RenderingServer::get_singleton()->canvas_item_add_circle(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 + marker_radius / 2, ofs_y + vertical_gap + marker_radius / 2), marker_radius, Color(cache.bookmark_color.r, cache.bookmark_color.g, cache.bookmark_color.b)); } } @@ -1214,7 +1214,7 @@ void TextEdit::_notification(int p_what) { int marker_height = get_row_height() - (vertical_gap * 2); int marker_width = cache.breakpoint_gutter_width - (horizontal_gap * 2); // No transparency on marker. - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2, ofs_y + vertical_gap, marker_width, marker_height), Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b)); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2, ofs_y + vertical_gap, marker_width, marker_height), Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b)); } } @@ -1254,9 +1254,9 @@ void TextEdit::_notification(int p_what) { cache.executing_icon->draw_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2 - icon_extra_size / 2, ofs_y + vertical_gap - icon_extra_size / 2, marker_width, marker_height), false, Color(cache.executing_line_color.r, cache.executing_line_color.g, cache.executing_line_color.b)); } else { #ifdef TOOLS_ENABLED - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.executing_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.executing_line_color); #else - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.executing_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.executing_line_color); #endif } } @@ -1315,10 +1315,10 @@ void TextEdit::_notification(int p_what) { if (j == str.length() - 1) { // End of line when last char is skipped. - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); } else if ((char_ofs + char_margin) > xmargin_beg) { // Char next to margin is skipped. - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, (char_ofs + char_margin) - (xmargin_beg + ofs_x), get_row_height()), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, (char_ofs + char_margin) - (xmargin_beg + ofs_x), get_row_height()), cache.current_line_color); } } continue; @@ -1338,7 +1338,7 @@ void TextEdit::_notification(int p_what) { in_search_result = j >= search_text_col && j < search_text_col + search_text.length(); if (in_search_result) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.search_result_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.search_result_color); } } @@ -1348,32 +1348,32 @@ void TextEdit::_notification(int p_what) { if (line == cursor.line && cursor_wrap_index == line_wrap_index && highlight_current_line) { // Draw the wrap indent offset highlight. if (line_wrap_index != 0 && j == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + ofs_x - indent_px, ofs_y, indent_px, get_row_height()), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + ofs_x - indent_px, ofs_y, indent_px, get_row_height()), cache.current_line_color); } // If its the last char draw to end of the line. if (j == str.length() - 1) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w + ofs_x, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); } // Actual text. if (!in_selection) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color); } } if (in_selection) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color); } if (in_search_result) { Color border_color = (line == search_result_line && j >= search_result_col && j < search_result_col + search_text.length()) ? cache.font_color : cache.search_result_border_color; - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, 1)), border_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, 1)), border_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color); if (j == search_text_col) - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(1, get_row_height())), border_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(1, get_row_height())), border_color); if (j == search_text_col + search_text.length() - 1) - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w + ofs_x - 1, ofs_y), Size2i(1, get_row_height())), border_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w + ofs_x - 1, ofs_y), Size2i(1, get_row_height())), border_color); } if (highlight_all_occurrences && !only_whitespaces_highlighted) { @@ -1392,7 +1392,7 @@ void TextEdit::_notification(int p_what) { } if (in_highlighted_word) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color); } } } @@ -1449,9 +1449,9 @@ void TextEdit::_notification(int p_what) { bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y; if (selected) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color); } else { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color); } drawer.draw_char(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + ascent), cchar, next, color); @@ -1468,7 +1468,7 @@ void TextEdit::_notification(int p_what) { #else int caret_h = (block_caret) ? 4 : 2; #endif - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, caret_h)), cache.caret_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, caret_h)), cache.caret_color); } else { #ifdef TOOLS_ENABLED caret_w = (block_caret) ? caret_w : 2 * EDSCALE; @@ -1476,7 +1476,7 @@ void TextEdit::_notification(int p_what) { caret_w = (block_caret) ? caret_w : 2; #endif - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color); } } } @@ -1544,9 +1544,9 @@ void TextEdit::_notification(int p_what) { bool selected = ofs >= ime_selection.x && ofs < ime_selection.x + ime_selection.y; if (selected) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 3)), color); } else { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color); } drawer.draw_char(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + ascent), cchar, next, color); @@ -1564,7 +1564,7 @@ void TextEdit::_notification(int p_what) { #else int caret_h = (block_caret) ? 4 : 2; #endif - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(char_w, caret_h)), cache.caret_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(char_w, caret_h)), cache.caret_color); } else { int char_w = cache.font->get_char_size(' ').width; #ifdef TOOLS_ENABLED @@ -1573,7 +1573,7 @@ void TextEdit::_notification(int p_what) { int caret_w = (block_caret) ? char_w : 2; #endif - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, cache.font->get_height())), cache.caret_color); } } } @@ -1634,10 +1634,10 @@ void TextEdit::_notification(int p_what) { draw_style_box(csb, Rect2(completion_rect.position - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0))); if (cache.completion_background_color.a > 0.01) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color); } int line_from = CLAMP(completion_index - lines / 2, 0, completion_options_size - lines); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color); draw_rect(Rect2(completion_rect.position + Vector2(icon_area_size.x + icon_hsep, 0), Size2(MIN(nofs, completion_rect.size.width - (icon_area_size.x + icon_hsep)), completion_rect.size.height)), cache.completion_existing_color); for (int i = 0; i < lines; i++) { @@ -2186,7 +2186,7 @@ Vector2i TextEdit::_get_cursor_pixel_pos() { int x = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs; int ix = 0; while (ix < rows2[0].size() && ix < cursor.column) { - if (cache.font != NULL) { + if (cache.font != nullptr) { x += cache.font->get_char_size(rows2[0].get(ix)).width; } ix++; @@ -3990,7 +3990,7 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i text.set_breakpoint(p_line, false); text.set_hidden(p_line, false); - text.set_info_icon(p_line, NULL, ""); + text.set_info_icon(p_line, nullptr, ""); } text.set_line_wrap_amount(p_line, -1); @@ -6087,7 +6087,7 @@ void TextEdit::_do_text_op(const TextOperation &p_op, bool p_reverse) { void TextEdit::_clear_redo() { - if (undo_stack_pos == NULL) + if (undo_stack_pos == nullptr) return; // Nothing to clear. _push_current_op(); @@ -6103,7 +6103,7 @@ void TextEdit::undo() { _push_current_op(); - if (undo_stack_pos == NULL) { + if (undo_stack_pos == nullptr) { if (!undo_stack.size()) return; // Nothing to undo. @@ -6152,7 +6152,7 @@ void TextEdit::redo() { _push_current_op(); - if (undo_stack_pos == NULL) + if (undo_stack_pos == nullptr) return; // Nothing to do. deselect(); @@ -6184,7 +6184,7 @@ void TextEdit::clear_undo_history() { saved_version = 0; current_op.type = TextOperation::TYPE_NONE; - undo_stack_pos = NULL; + undo_stack_pos = nullptr; undo_stack.clear(); } @@ -6633,8 +6633,8 @@ void TextEdit::_update_completion_candidates() { const CharType *tgt = &option.display[0]; const CharType *tgt_lower = &display_lower[0]; - const CharType *ssq_last_tgt = NULL; - const CharType *ssq_lower_last_tgt = NULL; + const CharType *ssq_last_tgt = nullptr; + const CharType *ssq_lower_last_tgt = nullptr; for (; *tgt; tgt++, tgt_lower++) { if (*ssq == *tgt) { @@ -6701,7 +6701,7 @@ void TextEdit::query_code_comple() { bool ignored = completion_active && !completion_options.empty(); if (ignored) { ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT; - const ScriptCodeCompletionOption *previous_option = NULL; + const ScriptCodeCompletionOption *previous_option = nullptr; for (int i = 0; i < completion_options.size(); i++) { const ScriptCodeCompletionOption ¤t_option = completion_options[i]; if (!previous_option) { @@ -7259,7 +7259,7 @@ TextEdit::TextEdit() { wrap_at = 0; wrap_right_offset = 10; set_focus_mode(FOCUS_ALL); - syntax_highlighter = NULL; + syntax_highlighter = nullptr; _update_caches(); cache.row_height = 1; cache.line_spacing = 1; @@ -7323,7 +7323,7 @@ TextEdit::TextEdit() { current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; - undo_stack_pos = NULL; + undo_stack_pos = nullptr; setting_text = false; last_dblclk = 0; current_op.version = 0; @@ -7333,7 +7333,7 @@ TextEdit::TextEdit() { completion_enabled = false; completion_active = false; completion_line_ofs = 0; - tooltip_obj = NULL; + tooltip_obj = nullptr; line_numbers = false; line_numbers_zero_padded = false; line_length_guidelines = false; @@ -7394,7 +7394,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int return syntax_highlighting_cache[p_line]; } - if (syntax_highlighter != NULL) { + if (syntax_highlighter != nullptr) { Map<int, HighlighterInfo> color_map = syntax_highlighter->_get_line_syntax_highlighting(p_line); syntax_highlighting_cache[p_line] = color_map; return color_map; @@ -7508,7 +7508,7 @@ Map<int, TextEdit::HighlighterInfo> TextEdit::_get_line_syntax_highlighting(int if (col) { for (int k = j - 1; k >= 0; k--) { if (str[k] == '.') { - col = NULL; // Member indexing not allowed. + col = nullptr; // Member indexing not allowed. break; } else if (str[k] > 32) { break; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 7d096f7897..ef8c39d32f 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -530,7 +530,7 @@ private: protected: virtual String get_tooltip(const Point2 &p_pos) const; - void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL); + void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = nullptr, int *r_end_char = nullptr); void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column); void _insert_text_at_cursor(const String &p_text); void _gui_input(const Ref<InputEvent> &p_gui_input); diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index abf6b2ed49..0dd43e4a35 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -300,7 +300,7 @@ void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, p_texture->get_rect_region(dst_rect, src_rect, dst_rect, src_rect); RID ci = get_canvas_item(); - VS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, VS::NINE_PATCH_STRETCH, VS::NINE_PATCH_STRETCH, true, p_modulate); + RS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, true, p_modulate); } void TextureProgress::_notification(int p_what) { diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 6dafd3bf4f..baa138847f 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -30,7 +30,7 @@ #include "texture_rect.h" #include "core/core_string_names.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void TextureRect::_notification(int p_what) { diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 653ac74164..a7acaae8df 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -71,7 +71,7 @@ void TreeItem::move_to_bottom() { parent->children = next; } last->next = this; - next = NULL; + next = nullptr; } Size2 TreeItem::Cell::get_icon_size() const { @@ -371,7 +371,7 @@ TreeItem *TreeItem::get_next() { TreeItem *TreeItem::get_prev() { if (!parent || parent->children == this) - return NULL; + return nullptr; TreeItem *prev = parent->children; while (prev && prev->next != this) @@ -400,7 +400,7 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) { current = current->parent; if (current == tree->root && tree->hide_root) { - return NULL; + return nullptr; } else if (!current) { if (p_wrap) { current = this; @@ -410,7 +410,7 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) { temp = temp->get_next_visible(); } } else { - return NULL; + return nullptr; } } } else { @@ -450,7 +450,7 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) { if (p_wrap) return tree->root; else - return NULL; + return nullptr; } else { current = current->next; } @@ -472,7 +472,7 @@ void TreeItem::remove_child(TreeItem *p_item) { *c = (*c)->next; - aux->parent = NULL; + aux->parent = nullptr; return; } @@ -890,11 +890,11 @@ void TreeItem::clear_children() { TreeItem *aux = c; c = c->get_next(); - aux->parent = 0; // so it won't try to recursively autoremove from me in here + aux->parent = nullptr; // so it won't try to recursively autoremove from me in here memdelete(aux); } - children = 0; + children = nullptr; }; TreeItem::TreeItem(Tree *p_tree) { @@ -904,9 +904,9 @@ TreeItem::TreeItem(Tree *p_tree) { disable_folding = false; custom_min_height = 0; - parent = 0; // parent item - next = 0; // next in list - children = 0; //child items + parent = nullptr; // parent item + next = nullptr; // next in list + children = nullptr; //child items } TreeItem::~TreeItem() { @@ -918,29 +918,29 @@ TreeItem::~TreeItem() { if (tree && tree->root == this) { - tree->root = 0; + tree->root = nullptr; } if (tree && tree->popup_edited_item == this) { - tree->popup_edited_item = NULL; + tree->popup_edited_item = nullptr; tree->pressing_for_editor = false; } if (tree && tree->cache.hover_item == this) { - tree->cache.hover_item = NULL; + tree->cache.hover_item = nullptr; } if (tree && tree->selected_item == this) - tree->selected_item = NULL; + tree->selected_item = nullptr; if (tree && tree->drop_mode_over == this) - tree->drop_mode_over = NULL; + tree->drop_mode_over = nullptr; if (tree && tree->single_select_defer == this) - tree->single_select_defer = NULL; + tree->single_select_defer = nullptr; if (tree && tree->edited_item == this) { - tree->edited_item = NULL; + tree->edited_item = nullptr; tree->pressing_for_editor = false; } } @@ -1220,7 +1220,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 } if (cache.draw_guides) { - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.position.x, cell_rect.position.y + cell_rect.size.height), cell_rect.position + cell_rect.size, cache.guide_color, 1); + RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.position.x, cell_rect.position.y + cell_rect.size.height), cell_rect.position + cell_rect.size, cache.guide_color, 1); } if (i == 0) { @@ -1266,12 +1266,12 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 r.size.x += cache.hseparation; } if (p_item->cells[i].custom_bg_outline) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), p_item->cells[i].bg_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), p_item->cells[i].bg_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), p_item->cells[i].bg_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), p_item->cells[i].bg_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), p_item->cells[i].bg_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), p_item->cells[i].bg_color); } else { - VisualServer::get_singleton()->canvas_item_add_rect(ci, r, p_item->cells[i].bg_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, r, p_item->cells[i].bg_color); } } @@ -1280,16 +1280,16 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Rect2 r = cell_rect; if (drop_mode_section == -1 || drop_mode_section == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color); } if (drop_mode_section == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color); } if (drop_mode_section == 1 || drop_mode_section == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color); + RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color); } } @@ -1498,7 +1498,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin); Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs; - if (c->get_children() != NULL) + if (c->get_children() != nullptr) root_pos -= Point2i(cache.arrow->get_width(), 0); float line_width = 1.0; @@ -1509,8 +1509,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs; if (root_pos.y + line_width >= 0) { - VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width); - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), Point2i(parent_pos.x, prev_ofs), cache.relationship_line_color, line_width); + RenderingServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x - Math::floor(line_width / 2), root_pos.y), cache.relationship_line_color, line_width); + RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), Point2i(parent_pos.x, prev_ofs), cache.relationship_line_color, line_width); } if (htotal < 0) { @@ -2131,7 +2131,7 @@ void Tree::popup_select(int p_option) { void Tree::_go_left() { if (selected_col == 0) { - if (selected_item->get_children() != NULL && !selected_item->is_collapsed()) { + if (selected_item->get_children() != nullptr && !selected_item->is_collapsed()) { selected_item->set_collapsed(true); } else { if (columns.size() == 1) { // goto parent with one column @@ -2160,7 +2160,7 @@ void Tree::_go_left() { void Tree::_go_right() { if (selected_col == (columns.size() - 1)) { - if (selected_item->get_children() != NULL && selected_item->is_collapsed()) { + if (selected_item->get_children() != nullptr && selected_item->is_collapsed()) { selected_item->set_collapsed(false); } else if (selected_item->get_next_visible()) { selected_col = 0; @@ -2181,7 +2181,7 @@ void Tree::_go_right() { } void Tree::_go_up() { - TreeItem *prev = NULL; + TreeItem *prev = nullptr; if (!selected_item) { prev = get_last_item(); selected_col = 0; @@ -2221,7 +2221,7 @@ void Tree::_go_up() { } void Tree::_go_down() { - TreeItem *next = NULL; + TreeItem *next = nullptr; if (!selected_item) { if (root) { @@ -2324,7 +2324,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!cursor_can_exit_tree) accept_event(); - TreeItem *next = NULL; + TreeItem *next = nullptr; if (!selected_item) return; next = selected_item; @@ -2362,7 +2362,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!cursor_can_exit_tree) accept_event(); - TreeItem *prev = NULL; + TreeItem *prev = nullptr; if (!selected_item) return; prev = selected_item; @@ -2584,7 +2584,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (single_select_defer) { select_single_item(single_select_defer, root, single_select_defer_column); - single_select_defer = NULL; + single_select_defer = nullptr; } range_click_timer->stop(); @@ -2609,7 +2609,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { pressing_for_editor = false; } - if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != NULL) { + if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) { // make sure in case of wrong reference after reconstructing whole TreeItems cache.click_item = get_item_at_position(cache.click_pos); emit_signal("button_pressed", cache.click_item, cache.click_column, cache.click_id); @@ -2617,7 +2617,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { cache.click_type = Cache::CLICK_NONE; cache.click_index = -1; cache.click_id = -1; - cache.click_item = NULL; + cache.click_item = nullptr; cache.click_column = 0; if (drag_touching) { @@ -2711,7 +2711,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } if (b->get_button_index() == BUTTON_LEFT) { - if (get_item_at_position(b->get_position()) == NULL && !b->get_shift() && !b->get_control() && !b->get_command()) + if (get_item_at_position(b->get_position()) == nullptr && !b->get_shift() && !b->get_control() && !b->get_command()) emit_signal("nothing_selected"); } } @@ -2946,7 +2946,7 @@ void Tree::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAG_BEGIN) { - single_select_defer = NULL; + single_select_defer = nullptr; if (cache.scroll_speed > 0) { scrolling = true; set_physics_process_internal(true); @@ -3030,9 +3030,9 @@ void Tree::_notification(int p_what) { bg->draw(ci, Rect2(Point2(), get_size())); if (has_focus()) { - VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, true); bg_focus->draw(ci, Rect2(Point2(), get_size())); - VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); + RenderingServer::get_singleton()->canvas_item_add_clip_ignore(ci, false); } int tbh = _get_title_button_height(); @@ -3076,7 +3076,7 @@ void Tree::_notification(int p_what) { if (p_what == NOTIFICATION_RESIZED || p_what == NOTIFICATION_TRANSFORM_CHANGED) { - if (popup_edited_item != NULL) { + if (popup_edited_item != nullptr) { Rect2 rect = popup_edited_item->get_meta("__focus_rect"); Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2); Point2i textedpos = get_global_position() + rect.position - ofs; @@ -3097,18 +3097,18 @@ Size2 Tree::get_minimum_size() const { TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { - ERR_FAIL_COND_V(blocked > 0, NULL); + ERR_FAIL_COND_V(blocked > 0, nullptr); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; if (p_parent) { // Append or insert a new item to the given parent. ti = memnew(TreeItem(this)); - ERR_FAIL_COND_V(!ti, NULL); + ERR_FAIL_COND_V(!ti, nullptr); ti->cells.resize(columns.size()); - TreeItem *prev = NULL; + TreeItem *prev = nullptr; TreeItem *c = p_parent->children; int idx = 0; @@ -3132,7 +3132,7 @@ TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) { if (!root) { // No root exists, make the given item the new root. ti = memnew(TreeItem(this)); - ERR_FAIL_COND_V(!ti, NULL); + ERR_FAIL_COND_V(!ti, nullptr); ti->cells.resize(columns.size()); root = ti; @@ -3227,7 +3227,7 @@ void Tree::deselect_all() { ERR_FAIL_COND(item == prev_item); } - selected_item = NULL; + selected_item = nullptr; selected_col = -1; update(); @@ -3235,7 +3235,7 @@ void Tree::deselect_all() { bool Tree::is_anything_selected() { - return (selected_item != NULL); + return (selected_item != nullptr); } void Tree::clear() { @@ -3253,12 +3253,12 @@ void Tree::clear() { if (root) { memdelete(root); - root = NULL; + root = nullptr; }; - selected_item = NULL; - edited_item = NULL; - popup_edited_item = NULL; + selected_item = nullptr; + edited_item = nullptr; + popup_edited_item = nullptr; update(); }; @@ -3315,10 +3315,10 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { /* if (!p_item) - return NULL; + return nullptr; */ if (!root) - return NULL; + return nullptr; while (true) { @@ -3338,8 +3338,8 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { while (!p_item->next) { p_item = p_item->parent; - if (p_item == NULL) - return NULL; + if (p_item == nullptr) + return nullptr; } p_item = p_item->next; @@ -3351,7 +3351,7 @@ TreeItem *Tree::get_next_selected(TreeItem *p_item) { return p_item; } - return NULL; + return nullptr; } int Tree::get_column_width(int p_column) const { @@ -3458,7 +3458,7 @@ int Tree::get_item_offset(TreeItem *p_item) const { while (!it->next) { it = it->parent; - if (it == NULL) + if (it == nullptr) return 0; } @@ -3626,7 +3626,7 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c break; } - return NULL; + return nullptr; } TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_selectable) { @@ -3636,7 +3636,7 @@ TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_select if (!from) from = root; if (!from) - return NULL; + return nullptr; return _search_item_text(from->get_next_visible(true), p_find, r_col, p_selectable); } @@ -3649,7 +3649,7 @@ TreeItem *Tree::get_item_with_text(const String &p_find) const { } } } - return NULL; + return nullptr; } void Tree::_do_incr_search(const String &p_add) { @@ -3703,7 +3703,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ pos.x -= w; } - return NULL; + return nullptr; } else { pos.y -= h; @@ -3714,7 +3714,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ } if (p_item->is_collapsed()) - return NULL; // do not try children, it's collapsed + return nullptr; // do not try children, it's collapsed TreeItem *n = p_item->get_children(); while (n) { @@ -3728,7 +3728,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_ n = n->get_next(); } - return NULL; + return nullptr; } int Tree::get_column_at_position(const Point2 &p_pos) const { @@ -3790,7 +3790,7 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { pos -= cache.bg->get_offset(); pos.y -= _get_title_button_height(); if (pos.y < 0) - return NULL; + return nullptr; if (h_scroll->is_visible_in_tree()) pos.x += h_scroll->get_value(); @@ -3806,7 +3806,7 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const { } } - return NULL; + return nullptr; } String Tree::get_tooltip(const Point2 &p_pos) const { @@ -3883,7 +3883,7 @@ void Tree::set_drop_mode_flags(int p_flags) { return; drop_mode_flags = p_flags; if (drop_mode_flags == 0) { - drop_mode_over = NULL; + drop_mode_over = nullptr; } update(); @@ -4015,17 +4015,17 @@ Tree::Tree() { selected_col = 0; columns.resize(1); - selected_item = NULL; - edited_item = NULL; + selected_item = nullptr; + edited_item = nullptr; selected_col = -1; edited_col = -1; hide_root = false; select_mode = SELECT_SINGLE; - root = 0; - popup_menu = NULL; - popup_edited_item = NULL; - text_editor = NULL; + root = nullptr; + popup_menu = nullptr; + popup_edited_item = nullptr; + text_editor = nullptr; set_focus_mode(FOCUS_ALL); popup_menu = memnew(PopupMenu); @@ -4078,7 +4078,7 @@ Tree::Tree() { cache.hover_index = -1; cache.click_index = -1; cache.click_id = -1; - cache.click_item = NULL; + cache.click_item = nullptr; cache.click_column = 0; cache.hover_cell = -1; last_keypress = 0; @@ -4098,9 +4098,9 @@ Tree::Tree() { hide_folding = false; drop_mode_flags = 0; - drop_mode_over = NULL; + drop_mode_over = nullptr; drop_mode_section = 0; - single_select_defer = NULL; + single_select_defer = nullptr; scrolling = false; allow_rmb_select = false; @@ -4108,7 +4108,7 @@ Tree::Tree() { set_clip_contents(true); - cache.hover_item = NULL; + cache.hover_item = nullptr; cache.hover_cell = -1; allow_reselect = false; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index becbe76598..87c2588a12 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -383,7 +383,7 @@ private: //void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color); int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item); - void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false); + void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = nullptr, bool *r_in_range = nullptr, bool p_force_deselect = false); int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const Ref<InputEventWithModifiers> &p_mod); void _text_editor_enter(String p_text); void _text_editor_modal_close(); @@ -584,7 +584,7 @@ public: bool edit_selected(); // First item that starts with the text, from the current focused item down and wraps around. - TreeItem *search_item_text(const String &p_find, int *r_col = NULL, bool p_selectable = false); + TreeItem *search_item_text(const String &p_find, int *r_col = nullptr, bool p_selectable = false); // First item that matches the whole text, from the first item down. TreeItem *get_item_with_text(const String &p_find) const; diff --git a/scene/main/SCsub b/scene/main/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/main/SCsub +++ b/scene/main/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index 7a0fc3352b..2eacad68c3 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -40,13 +40,12 @@ #include "scene/resources/style_box.h" #include "scene/resources/texture.h" #include "scene/scene_string_names.h" -#include "servers/visual/visual_server_raster.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Mutex CanvasItemMaterial::material_mutex; -SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = NULL; +SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = nullptr; Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map; -CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = NULL; +CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = nullptr; void CanvasItemMaterial::init_shaders() { @@ -63,7 +62,7 @@ void CanvasItemMaterial::finish_shaders() { memdelete(dirty_materials); memdelete(shader_names); - dirty_materials = NULL; + dirty_materials = nullptr; } void CanvasItemMaterial::_update_shader() { @@ -78,7 +77,7 @@ void CanvasItemMaterial::_update_shader() { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { //deallocate shader, as it's no longer in use - VS::get_singleton()->free(shader_map[current_key].shader); + RS::get_singleton()->free(shader_map[current_key].shader); shader_map.erase(current_key); } } @@ -87,7 +86,7 @@ void CanvasItemMaterial::_update_shader() { if (shader_map.has(mk)) { - VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader); + RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader); shader_map[mk].users++; return; } @@ -138,14 +137,14 @@ void CanvasItemMaterial::_update_shader() { } ShaderData shader_data; - shader_data.shader = VS::get_singleton()->shader_create(); + shader_data.shader = RS::get_singleton()->shader_create(); shader_data.users = 1; - VS::get_singleton()->shader_set_code(shader_data.shader, code); + RS::get_singleton()->shader_set_code(shader_data.shader, code); shader_map[mk] = shader_data; - VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); + RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); } void CanvasItemMaterial::flush_changes() { @@ -207,7 +206,7 @@ bool CanvasItemMaterial::get_particles_animation() const { void CanvasItemMaterial::set_particles_anim_h_frames(int p_frames) { particles_anim_h_frames = p_frames; - VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames); + RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames); } int CanvasItemMaterial::get_particles_anim_h_frames() const { @@ -217,7 +216,7 @@ int CanvasItemMaterial::get_particles_anim_h_frames() const { void CanvasItemMaterial::set_particles_anim_v_frames(int p_frames) { particles_anim_v_frames = p_frames; - VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames); + RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames); } int CanvasItemMaterial::get_particles_anim_v_frames() const { @@ -228,7 +227,7 @@ int CanvasItemMaterial::get_particles_anim_v_frames() const { void CanvasItemMaterial::set_particles_anim_loop(bool p_loop) { particles_anim_loop = p_loop; - VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop); + RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop); } bool CanvasItemMaterial::get_particles_anim_loop() const { @@ -316,11 +315,11 @@ CanvasItemMaterial::~CanvasItemMaterial() { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { //deallocate shader, as it's no longer in use - VS::get_singleton()->free(shader_map[current_key].shader); + RS::get_singleton()->free(shader_map[current_key].shader); shader_map.erase(current_key); } - VS::get_singleton()->material_set_shader(_get_material(), RID()); + RS::get_singleton()->material_set_shader(_get_material(), RID()); } } @@ -388,7 +387,7 @@ void CanvasItem::show() { return; visible = true; - VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, true); + RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, true); if (!is_inside_tree()) return; @@ -403,7 +402,7 @@ void CanvasItem::hide() { return; visible = false; - VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, false); + RenderingServer::get_singleton()->canvas_item_set_visible(canvas_item, false); if (!is_inside_tree()) return; @@ -412,7 +411,7 @@ void CanvasItem::hide() { _change_notify("visible"); } -CanvasItem *CanvasItem::current_item_drawn = NULL; +CanvasItem *CanvasItem::current_item_drawn = nullptr; CanvasItem *CanvasItem::get_current_item_drawn() { return current_item_drawn; } @@ -424,7 +423,7 @@ void CanvasItem::_update_callback() { return; } - VisualServer::get_singleton()->canvas_item_clear(get_canvas_item()); + RenderingServer::get_singleton()->canvas_item_clear(get_canvas_item()); //todo updating = true - only allow drawing here if (is_visible_in_tree()) { //todo optimize this!! if (first_draw) { @@ -436,9 +435,9 @@ void CanvasItem::_update_callback() { notification(NOTIFICATION_DRAW); emit_signal(SceneStringNames::get_singleton()->draw); if (get_script_instance()) { - get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw, NULL, 0); + get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw, nullptr, 0); } - current_item_drawn = NULL; + current_item_drawn = nullptr; drawing = false; } //todo updating = false @@ -494,9 +493,9 @@ void CanvasItem::_toplevel_raise_self() { return; if (canvas_layer) - VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, canvas_layer->get_sort_index()); + RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, canvas_layer->get_sort_index()); else - VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_viewport()->gui_get_canvas_sort_index()); + RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_viewport()->gui_get_canvas_sort_index()); } void CanvasItem::_enter_canvas() { @@ -505,7 +504,7 @@ void CanvasItem::_enter_canvas() { Node *n = this; - canvas_layer = NULL; + canvas_layer = nullptr; while (n) { @@ -525,7 +524,7 @@ void CanvasItem::_enter_canvas() { else canvas = get_viewport()->find_world_2d()->get_canvas(); - VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas); + RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas); group = "root_canvas" + itos(canvas.get_id()); @@ -541,8 +540,8 @@ void CanvasItem::_enter_canvas() { CanvasItem *parent = get_parent_item(); canvas_layer = parent->canvas_layer; - VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item()); - VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index()); + RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item()); + RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index()); } pending_update = false; @@ -554,8 +553,8 @@ void CanvasItem::_enter_canvas() { void CanvasItem::_exit_canvas() { notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification - VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, RID()); - canvas_layer = NULL; + RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, RID()); + canvas_layer = nullptr; group = ""; } @@ -608,7 +607,7 @@ void CanvasItem::_notification(int p_what) { } else { CanvasItem *p = get_parent_item(); ERR_FAIL_COND(!p); - VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index()); + RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index()); } } break; @@ -618,7 +617,7 @@ void CanvasItem::_notification(int p_what) { _exit_canvas(); if (C) { Object::cast_to<CanvasItem>(get_parent())->children_items.erase(C); - C = NULL; + C = nullptr; } if (window) { window->disconnect(SceneStringNames::get_singleton()->visibility_changed, callable_mp(this, &CanvasItem::_window_visibility_changed)); @@ -674,7 +673,7 @@ void CanvasItem::set_modulate(const Color &p_modulate) { return; modulate = p_modulate; - VisualServer::get_singleton()->canvas_item_set_modulate(canvas_item, modulate); + RenderingServer::get_singleton()->canvas_item_set_modulate(canvas_item, modulate); } Color CanvasItem::get_modulate() const { @@ -704,7 +703,7 @@ bool CanvasItem::is_set_as_toplevel() const { CanvasItem *CanvasItem::get_parent_item() const { if (toplevel) - return NULL; + return nullptr; return Object::cast_to<CanvasItem>(get_parent()); } @@ -715,7 +714,7 @@ void CanvasItem::set_self_modulate(const Color &p_self_modulate) { return; self_modulate = p_self_modulate; - VisualServer::get_singleton()->canvas_item_set_self_modulate(canvas_item, self_modulate); + RenderingServer::get_singleton()->canvas_item_set_self_modulate(canvas_item, self_modulate); } Color CanvasItem::get_self_modulate() const { @@ -728,7 +727,7 @@ void CanvasItem::set_light_mask(int p_light_mask) { return; light_mask = p_light_mask; - VS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask); + RS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask); } int CanvasItem::get_light_mask() const { @@ -747,7 +746,7 @@ void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); - VisualServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width); + RenderingServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width); } void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width) { @@ -756,14 +755,14 @@ void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_co Vector<Color> colors; colors.push_back(p_color); - VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width); + RenderingServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width); } void CanvasItem::draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); - VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width); + RenderingServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width); } void CanvasItem::draw_arc(const Vector2 &p_center, float p_radius, float p_start_angle, float p_end_angle, int p_point_count, const Color &p_color, float p_width) { @@ -785,14 +784,14 @@ void CanvasItem::draw_multiline(const Vector<Point2> &p_points, const Color &p_c Vector<Color> colors; colors.push_back(p_color); - VisualServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, colors, p_width); + RenderingServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, colors, p_width); } void CanvasItem::draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); - VisualServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, p_colors, p_width); + RenderingServer::get_singleton()->canvas_item_add_multiline(canvas_item, p_points, p_colors, p_width); } void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled, float p_width) { @@ -804,7 +803,7 @@ void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_fil WARN_PRINT("The draw_rect() \"width\" argument has no effect when \"filled\" is \"true\"."); } - VisualServer::get_singleton()->canvas_item_add_rect(canvas_item, p_rect, p_color); + RenderingServer::get_singleton()->canvas_item_add_rect(canvas_item, p_rect, p_color); } else { // Thick lines are offset depending on their width to avoid partial overlapping. // Thin lines don't require an offset, so don't apply one in this case @@ -815,25 +814,25 @@ void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_fil offset = 0.0; } - VisualServer::get_singleton()->canvas_item_add_line( + RenderingServer::get_singleton()->canvas_item_add_line( canvas_item, p_rect.position + Size2(-offset, 0), p_rect.position + Size2(p_rect.size.width + offset, 0), p_color, p_width); - VisualServer::get_singleton()->canvas_item_add_line( + RenderingServer::get_singleton()->canvas_item_add_line( canvas_item, p_rect.position + Size2(p_rect.size.width, offset), p_rect.position + Size2(p_rect.size.width, p_rect.size.height - offset), p_color, p_width); - VisualServer::get_singleton()->canvas_item_add_line( + RenderingServer::get_singleton()->canvas_item_add_line( canvas_item, p_rect.position + Size2(p_rect.size.width + offset, p_rect.size.height), p_rect.position + Size2(-offset, p_rect.size.height), p_color, p_width); - VisualServer::get_singleton()->canvas_item_add_line( + RenderingServer::get_singleton()->canvas_item_add_line( canvas_item, p_rect.position + Size2(0, p_rect.size.height - offset), p_rect.position + Size2(0, offset), @@ -846,7 +845,7 @@ void CanvasItem::draw_circle(const Point2 &p_pos, float p_radius, const Color &p ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); - VisualServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color); + RenderingServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color); } void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { @@ -855,7 +854,7 @@ void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_p ERR_FAIL_COND(p_texture.is_null()); - p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map, p_specular_map, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { @@ -863,13 +862,13 @@ void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); ERR_FAIL_COND(p_texture.is_null()); - p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); ERR_FAIL_COND(p_texture.is_null()); - p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat), p_clip_uv); + p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat), p_clip_uv); } void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect) { @@ -887,7 +886,7 @@ void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Col RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal, rid_specular, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + RenderingServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) { @@ -895,14 +894,14 @@ void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const S Transform2D xform(p_rot, p_offset); xform.scale_basis(p_scale); - VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, xform); + RenderingServer::get_singleton()->canvas_item_add_set_transform(canvas_item, xform); } void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) { ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); - VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix); + RenderingServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix); } void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { @@ -913,7 +912,7 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + RenderingServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { @@ -926,7 +925,7 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + RenderingServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, const Transform2D &p_transform, const Color &p_modulate, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { @@ -936,7 +935,7 @@ void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_text RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_map_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + RenderingServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, TextureFilter p_texture_filter, TextureRepeat p_texture_repeat) { @@ -945,7 +944,7 @@ void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Tex RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_map_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, VS::CanvasItemTextureFilter(p_texture_filter), VS::CanvasItemTextureRepeat(p_texture_repeat)); + RenderingServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess, RS::CanvasItemTextureFilter(p_texture_filter), RS::CanvasItemTextureRepeat(p_texture_repeat)); } void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) { @@ -1067,7 +1066,7 @@ void CanvasItem::set_draw_behind_parent(bool p_enable) { if (behind == p_enable) return; behind = p_enable; - VisualServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item, behind); + RenderingServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item, behind); } bool CanvasItem::is_draw_behind_parent_enabled() const { @@ -1081,14 +1080,14 @@ void CanvasItem::set_material(const Ref<Material> &p_material) { RID rid; if (material.is_valid()) rid = material->get_rid(); - VS::get_singleton()->canvas_item_set_material(canvas_item, rid); + RS::get_singleton()->canvas_item_set_material(canvas_item, rid); _change_notify(); //properties for material exposed } void CanvasItem::set_use_parent_material(bool p_use_parent_material) { use_parent_material = p_use_parent_material; - VS::get_singleton()->canvas_item_set_use_parent_material(canvas_item, p_use_parent_material); + RS::get_singleton()->canvas_item_set_use_parent_material(canvas_item, p_use_parent_material); } bool CanvasItem::get_use_parent_material() const { @@ -1373,18 +1372,18 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) { } else { //from viewport switch (get_viewport()->get_default_canvas_item_texture_filter()) { - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS; break; default: { } } } } else { - texture_filter_cache = VS::CanvasItemTextureFilter(texture_filter); + texture_filter_cache = RS::CanvasItemTextureFilter(texture_filter); } - VS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache); + RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache); update(); if (p_propagate) { @@ -1422,17 +1421,17 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) { } else { //from viewport switch (get_viewport()->get_default_canvas_item_texture_repeat()) { - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; break; - case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED; break; + case Viewport::DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR; break; default: { } } } } else { - texture_repeat_cache = VS::CanvasItemTextureRepeat(texture_repeat); + texture_repeat_cache = RS::CanvasItemTextureRepeat(texture_repeat); } - VS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache); + RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache); update(); if (p_propagate) { for (List<CanvasItem *>::Element *E = children_items.front(); E; E = E->next()) { @@ -1460,7 +1459,7 @@ CanvasItem::CanvasItem() : xform_change(this) { window = nullptr; - canvas_item = VisualServer::get_singleton()->canvas_item_create(); + canvas_item = RenderingServer::get_singleton()->canvas_item_create(); visible = true; pending_update = false; modulate = Color(1, 1, 1, 1); @@ -1470,8 +1469,7 @@ CanvasItem::CanvasItem() : drawing = false; behind = false; block_transform_notify = false; - //viewport=NULL; - canvas_layer = NULL; + canvas_layer = nullptr; use_parent_material = false; global_invalid = true; notify_local_transform = false; @@ -1479,13 +1477,13 @@ CanvasItem::CanvasItem() : light_mask = 1; texture_repeat = TEXTURE_REPEAT_PARENT_NODE; texture_filter = TEXTURE_FILTER_PARENT_NODE; - texture_filter_cache = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; - texture_repeat_cache = VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; + texture_filter_cache = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; + texture_repeat_cache = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; - C = NULL; + C = nullptr; } CanvasItem::~CanvasItem() { - VisualServer::get_singleton()->free(canvas_item); + RenderingServer::get_singleton()->free(canvas_item); } diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h index 3f176e5f60..dc17c5283b 100644 --- a/scene/main/canvas_item.h +++ b/scene/main/canvas_item.h @@ -213,8 +213,8 @@ private: bool notify_local_transform; bool notify_transform; - VS::CanvasItemTextureFilter texture_filter_cache; - VS::CanvasItemTextureRepeat texture_repeat_cache; + RS::CanvasItemTextureFilter texture_filter_cache; + RS::CanvasItemTextureRepeat texture_repeat_cache; TextureFilter texture_filter; TextureRepeat texture_repeat; diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 2085fa3a60..15f64390de 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -35,7 +35,7 @@ void CanvasLayer::set_layer(int p_xform) { layer = p_xform; if (viewport.is_valid()) - VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); } int CanvasLayer::get_layer() const { @@ -48,7 +48,7 @@ void CanvasLayer::set_transform(const Transform2D &p_xform) { transform = p_xform; locrotscale_dirty = true; if (viewport.is_valid()) - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); } Transform2D CanvasLayer::get_transform() const { @@ -61,7 +61,7 @@ void CanvasLayer::_update_xform() { transform.set_rotation_and_scale(rot, scale); transform.set_origin(ofs); if (viewport.is_valid()) - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); } void CanvasLayer::_update_locrotscale() { @@ -150,16 +150,16 @@ void CanvasLayer::_notification(int p_what) { vp->_canvas_layer_add(this); viewport = vp->get_viewport_rid(); - VisualServer::get_singleton()->viewport_attach_canvas(viewport, canvas); - VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); + RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); _update_follow_viewport(); } break; case NOTIFICATION_EXIT_TREE: { vp->_canvas_layer_remove(this); - VisualServer::get_singleton()->viewport_remove_canvas(viewport, canvas); + RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas); viewport = RID(); _update_follow_viewport(false); @@ -167,7 +167,7 @@ void CanvasLayer::_notification(int p_what) { case NOTIFICATION_MOVED_IN_PARENT: { if (is_inside_tree()) - VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); } break; } @@ -191,7 +191,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) { ERR_FAIL_NULL(p_viewport); if (is_inside_tree()) { vp->_canvas_layer_remove(this); - VisualServer::get_singleton()->viewport_remove_canvas(viewport, canvas); + RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas); viewport = RID(); } @@ -213,9 +213,9 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) { vp->_canvas_layer_add(this); viewport = vp->get_viewport_rid(); - VisualServer::get_singleton()->viewport_attach_canvas(viewport, canvas); - VisualServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); + RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas); + RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent()); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform); } } @@ -266,9 +266,9 @@ void CanvasLayer::_update_follow_viewport(bool p_force_exit) { return; } if (p_force_exit || !follow_viewport) { - VS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0); + RS::get_singleton()->canvas_set_parent(canvas, RID(), 1.0); } else { - VS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale); + RS::get_singleton()->canvas_set_parent(canvas, vp->get_world_2d()->get_canvas(), follow_viewport_scale); } } @@ -320,13 +320,13 @@ void CanvasLayer::_bind_methods() { CanvasLayer::CanvasLayer() { - vp = NULL; + vp = nullptr; scale = Vector2(1, 1); rot = 0; locrotscale_dirty = false; layer = 1; - canvas = VS::get_singleton()->canvas_create(); - custom_viewport = NULL; + canvas = RS::get_singleton()->canvas_create(); + custom_viewport = nullptr; sort_index = 0; follow_viewport = false; @@ -335,5 +335,5 @@ CanvasLayer::CanvasLayer() { CanvasLayer::~CanvasLayer() { - VS::get_singleton()->free(canvas); + RS::get_singleton()->free(canvas); } diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index fee2ada76d..dc0da015ac 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -162,12 +162,12 @@ void HTTPRequest::cancel_request() { thread_request_quit = true; Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } if (file) { memdelete(file); - file = NULL; + file = nullptr; } client->close(); body.resize(0); @@ -566,7 +566,7 @@ void HTTPRequest::_bind_methods() { HTTPRequest::HTTPRequest() { - thread = NULL; + thread = nullptr; port = 80; redirections = 0; @@ -583,7 +583,7 @@ HTTPRequest::HTTPRequest() { thread_done = false; downloaded = 0; body_size_limit = -1; - file = NULL; + file = nullptr; timer = memnew(Timer); timer->set_one_shot(true); diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index fe238af1c4..78958a7a1c 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -77,11 +77,11 @@ String InstancePlaceholder::get_instance_path() const { Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene> &p_custom_scene) { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); Node *base = get_parent(); if (!base) - return NULL; + return nullptr; Ref<PackedScene> ps; if (p_custom_scene.is_valid()) @@ -90,10 +90,10 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene ps = ResourceLoader::load(path, "PackedScene"); if (!ps.is_valid()) - return NULL; + return nullptr; Node *scene = ps->instance(); if (!scene) - return NULL; + return nullptr; scene->set_name(get_name()); int pos = get_position_in_parent(); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index b882b9ead6..6b46ffd8ad 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -82,7 +82,7 @@ void Node::_notification(int p_notification) { if (data.parent) data.pause_owner = data.parent->data.pause_owner; else - data.pause_owner = NULL; + data.pause_owner = nullptr; } else { data.pause_owner = this; } @@ -112,17 +112,17 @@ void Node::_notification(int p_notification) { if (data.unhandled_key_input) remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id())); - data.pause_owner = NULL; + data.pause_owner = nullptr; if (data.path_cache) { memdelete(data.path_cache); - data.path_cache = NULL; + data.path_cache = nullptr; } } break; case NOTIFICATION_PATH_CHANGED: { if (data.path_cache) { memdelete(data.path_cache); - data.path_cache = NULL; + data.path_cache = nullptr; } } break; case NOTIFICATION_READY: { @@ -149,7 +149,7 @@ void Node::_notification(int p_notification) { set_physics_process(true); } - get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, NULL, 0); + get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, nullptr, 0); } } break; @@ -158,11 +158,11 @@ void Node::_notification(int p_notification) { } break; case NOTIFICATION_PREDELETE: { - set_owner(NULL); + set_owner(nullptr); while (data.owned.size()) { - data.owned.front()->get()->set_owner(NULL); + data.owned.front()->get()->set_owner(nullptr); } if (data.parent) { @@ -226,7 +226,7 @@ void Node::_propagate_enter_tree() { if (get_script_instance()) { - get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, NULL, 0); + get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, nullptr, 0); } emit_signal(SceneStringNames::get_singleton()->tree_entered); @@ -278,7 +278,7 @@ void Node::_propagate_exit_tree() { if (get_script_instance()) { - get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, NULL, 0); + get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, nullptr, 0); } emit_signal(SceneStringNames::get_singleton()->tree_exiting); @@ -290,17 +290,17 @@ void Node::_propagate_exit_tree() { for (Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) { data.tree->remove_from_group(E->key(), this); - E->get().group = NULL; + E->get().group = nullptr; } - data.viewport = NULL; + data.viewport = nullptr; if (data.tree) data.tree->tree_changed(); data.inside_tree = false; data.ready_notified = false; - data.tree = NULL; + data.tree = nullptr; data.depth = -1; } @@ -423,7 +423,7 @@ void Node::set_pause_mode(PauseMode p_mode) { if ((data.pause_mode == PAUSE_MODE_INHERIT) == prev_inherits) return; ///nothing changed - Node *owner = NULL; + Node *owner = nullptr; if (data.pause_mode == PAUSE_MODE_INHERIT) { @@ -914,7 +914,7 @@ void Node::set_process_priority(int p_priority) { data.process_priority = p_priority; // Make sure we are in SceneTree. - if (data.tree == NULL) { + if (data.tree == nullptr) { return; } @@ -1295,7 +1295,7 @@ void Node::_propagate_validate_owner() { if (!found) { data.owner->data.owned.erase(data.OW); - data.owner = NULL; + data.owner = nullptr; } } @@ -1336,7 +1336,7 @@ void Node::remove_child(Node *p_child) { //if (data.scene) { does not matter - p_child->_set_tree(NULL); + p_child->_set_tree(nullptr); //} remove_child_notify(p_child); @@ -1354,7 +1354,7 @@ void Node::remove_child(Node *p_child) { children[i]->notification(NOTIFICATION_MOVED_IN_PARENT); } - p_child->data.parent = NULL; + p_child->data.parent = nullptr; p_child->data.pos = -1; // validate owner @@ -1371,7 +1371,7 @@ int Node::get_child_count() const { } Node *Node::get_child(int p_index) const { - ERR_FAIL_INDEX_V(p_index, data.children.size(), NULL); + ERR_FAIL_INDEX_V(p_index, data.children.size(), nullptr); return data.children[p_index]; } @@ -1386,19 +1386,19 @@ Node *Node::_get_child_by_name(const StringName &p_name) const { return cd[i]; } - return NULL; + return nullptr; } Node *Node::get_node_or_null(const NodePath &p_path) const { if (p_path.is_empty()) { - return NULL; + return nullptr; } - ERR_FAIL_COND_V_MSG(!data.inside_tree && p_path.is_absolute(), NULL, "Can't use get_node() with absolute paths from outside the active scene tree."); + ERR_FAIL_COND_V_MSG(!data.inside_tree && p_path.is_absolute(), nullptr, "Can't use get_node() with absolute paths from outside the active scene tree."); - Node *current = NULL; - Node *root = NULL; + Node *current = nullptr; + Node *root = nullptr; if (!p_path.is_absolute()) { current = const_cast<Node *>(this); //start from this @@ -1412,7 +1412,7 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { for (int i = 0; i < p_path.get_name_count(); i++) { StringName name = p_path.get_name(i); - Node *next = NULL; + Node *next = nullptr; if (name == SceneStringNames::get_singleton()->dot) { // . @@ -1420,18 +1420,18 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { } else if (name == SceneStringNames::get_singleton()->doubledot) { // .. - if (current == NULL || !current->data.parent) - return NULL; + if (current == nullptr || !current->data.parent) + return nullptr; next = current->data.parent; - } else if (current == NULL) { + } else if (current == nullptr) { if (name == root->get_name()) next = root; } else { - next = NULL; + next = nullptr; for (int j = 0; j < current->data.children.size(); j++) { @@ -1443,8 +1443,8 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { break; } } - if (next == NULL) { - return NULL; + if (next == nullptr) { + return nullptr; }; } current = next; @@ -1456,13 +1456,13 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { Node *Node::get_node(const NodePath &p_path) const { Node *node = get_node_or_null(p_path); - ERR_FAIL_COND_V_MSG(!node, NULL, "Node not found: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!node, nullptr, "Node not found: " + p_path + "."); return node; } bool Node::has_node(const NodePath &p_path) const { - return get_node_or_null(p_path) != NULL; + return get_node_or_null(p_path) != nullptr; } Node *Node::find_node(const String &p_mask, bool p_recursive, bool p_owned) const { @@ -1482,7 +1482,7 @@ Node *Node::find_node(const String &p_mask, bool p_recursive, bool p_owned) cons if (ret) return ret; } - return NULL; + return nullptr; } Node *Node::get_parent() const { @@ -1500,7 +1500,7 @@ Node *Node::find_parent(const String &p_mask) const { p = p->data.parent; } - return NULL; + return nullptr; } bool Node::is_a_parent_of(const Node *p_node) const { @@ -1607,8 +1607,8 @@ void Node::set_owner(Node *p_owner) { if (data.owner) { data.owner->data.owned.erase(data.OW); - data.OW = NULL; - data.owner = NULL; + data.OW = nullptr; + data.owner = nullptr; } ERR_FAIL_COND(p_owner == this); @@ -1663,7 +1663,7 @@ Node *Node::find_common_parent_with(const Node *p_node) const { } if (!common_parent) - return NULL; + return nullptr; return const_cast<Node *>(common_parent); } @@ -1762,7 +1762,7 @@ void Node::add_to_group(const StringName &p_identifier, bool p_persistent) { if (data.tree) { gd.group = data.tree->add_to_group(p_identifier, this); } else { - gd.group = NULL; + gd.group = nullptr; } gd.persistent = p_persistent; @@ -1935,7 +1935,7 @@ void Node::remove_and_skip() { continue; remove_child(c_node); - c_node->_propagate_replace_owner(this, NULL); + c_node->_propagate_replace_owner(this, nullptr); children.push_back(c_node); clear = false; break; @@ -1949,7 +1949,7 @@ void Node::remove_and_skip() { Node *c_node = children.front()->get(); data.parent->add_child(c_node); - c_node->_propagate_replace_owner(NULL, new_owner); + c_node->_propagate_replace_owner(nullptr, new_owner); children.pop_front(); } @@ -2049,7 +2049,7 @@ int Node::get_position_in_parent() const { Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const { - Node *node = NULL; + Node *node = nullptr; bool instanced = false; @@ -2063,25 +2063,25 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const } else if ((p_flags & DUPLICATE_USE_INSTANCING) && get_filename() != String()) { Ref<PackedScene> res = ResourceLoader::load(get_filename()); - ERR_FAIL_COND_V(res.is_null(), NULL); + ERR_FAIL_COND_V(res.is_null(), nullptr); PackedScene::GenEditState ges = PackedScene::GEN_EDIT_STATE_DISABLED; #ifdef TOOLS_ENABLED if (p_flags & DUPLICATE_FROM_EDITOR) ges = PackedScene::GEN_EDIT_STATE_INSTANCE; #endif node = res->instance(ges); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); instanced = true; } else { Object *obj = ClassDB::instance(get_class()); - ERR_FAIL_COND_V(!obj, NULL); + ERR_FAIL_COND_V(!obj, nullptr); node = Object::cast_to<Node>(obj); if (!node) memdelete(obj); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); } if (get_filename() != "") { //an instance @@ -2189,7 +2189,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const if (!dup) { memdelete(node); - return NULL; + return nullptr; } node->add_child(dup); @@ -2204,14 +2204,14 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const if (!parent) { memdelete(node); - return NULL; + return nullptr; } Node *dup = E->get()->_duplicate(p_flags, r_duplimap); if (!dup) { memdelete(node); - return NULL; + return nullptr; } parent->add_child(dup); @@ -2256,7 +2256,7 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p if (get_owner() != get_parent()->get_owner()) return; - Node *node = NULL; + Node *node = nullptr; if (get_filename() != "") { @@ -2369,15 +2369,15 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const { - ERR_FAIL_COND_V(get_filename() != "", NULL); + ERR_FAIL_COND_V(get_filename() != "", nullptr); Object *obj = ClassDB::instance(get_class()); - ERR_FAIL_COND_V_MSG(!obj, NULL, "Node: Could not duplicate: " + String(get_class()) + "."); + ERR_FAIL_COND_V_MSG(!obj, nullptr, "Node: Could not duplicate: " + String(get_class()) + "."); Node *node = Object::cast_to<Node>(obj); if (!node) { memdelete(obj); - ERR_FAIL_V_MSG(NULL, "Node: Could not duplicate: " + String(get_class()) + "."); + ERR_FAIL_V_MSG(nullptr, "Node: Could not duplicate: " + String(get_class()) + "."); } node->set_name(get_name()); @@ -2591,7 +2591,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str r_res = RES(); r_leftover_subpath = Vector<StringName>(); if (!node) - return NULL; + return nullptr; if (p_path.get_subname_count()) { @@ -2601,7 +2601,7 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str Variant new_res_v = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j)); if (new_res_v.get_type() == Variant::NIL) { // Found nothing on that path - return NULL; + return nullptr; } RES new_res = new_res_v; @@ -2623,8 +2623,8 @@ Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<Str void Node::_set_tree(SceneTree *p_tree) { - SceneTree *tree_changed_a = NULL; - SceneTree *tree_changed_b = NULL; + SceneTree *tree_changed_a = nullptr; + SceneTree *tree_changed_b = nullptr; //ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null @@ -3012,8 +3012,8 @@ Node::Node() { data.pos = -1; data.depth = -1; data.blocked = 0; - data.parent = NULL; - data.tree = NULL; + data.parent = nullptr; + data.tree = nullptr; data.physics_process = false; data.idle_process = false; data.process_priority = 0; @@ -3022,18 +3022,18 @@ Node::Node() { data.inside_tree = false; data.ready_notified = false; - data.owner = NULL; - data.OW = NULL; + data.owner = nullptr; + data.OW = nullptr; data.input = false; data.unhandled_input = false; data.unhandled_key_input = false; data.pause_mode = PAUSE_MODE_INHERIT; - data.pause_owner = NULL; + data.pause_owner = nullptr; data.network_master = 1; //server by default - data.path_cache = NULL; + data.path_cache = nullptr; data.parent_owned = false; data.in_constructor = true; - data.viewport = NULL; + data.viewport = nullptr; data.use_placeholder = false; data.display_folded = false; data.ready_first = true; diff --git a/scene/main/node.h b/scene/main/node.h index cf25a92be6..292ec0e291 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -180,7 +180,7 @@ private: void _duplicate_signals(const Node *p_original, Node *p_copy) const; void _duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const; - Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = NULL) const; + Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = nullptr) const; Array _get_children() const; Array _get_groups() const; @@ -286,7 +286,7 @@ public: Node *find_parent(const String &p_mask) const; _FORCE_INLINE_ SceneTree *get_tree() const { - ERR_FAIL_COND_V(!data.tree, NULL); + ERR_FAIL_COND_V(!data.tree, nullptr); return data.tree; } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index d6c0323f25..41f31617d2 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -48,9 +48,9 @@ #include "scene/resources/packed_scene.h" #include "scene/scene_string_names.h" #include "servers/display_server.h" -#include "servers/navigation_server.h" -#include "servers/physics_2d_server.h" -#include "servers/physics_server.h" +#include "servers/navigation_server_3d.h" +#include "servers/physics_server_2d.h" +#include "servers/physics_server_3d.h" #include "window.h" #include <stdio.h> @@ -112,7 +112,7 @@ void SceneTree::node_added(Node *p_node) { void SceneTree::node_removed(Node *p_node) { if (current_scene == p_node) { - current_scene = NULL; + current_scene = nullptr; } emit_signal(node_removed_name, p_node); if (call_lock > 0) @@ -435,7 +435,7 @@ bool SceneTree::idle(float p_time) { //print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage())); //print_line("node count: "+itos(get_node_count())); - //print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED))); + //print_line("TEXTURE RAM: "+itos(RS::get_singleton()->get_render_info(RS::INFO_TEXTURE_MEM_USED))); root_lock++; @@ -539,10 +539,10 @@ void SceneTree::finish() { MainLoop::finish(); if (root) { - root->_set_tree(NULL); + root->_set_tree(nullptr); root->_propagate_after_exit_tree(); memdelete(root); //delete root - root = NULL; + root = nullptr; } // cleanup timers @@ -796,9 +796,9 @@ void SceneTree::set_pause(bool p_enabled) { if (p_enabled == pause) return; pause = p_enabled; - NavigationServer::get_singleton()->set_active(!p_enabled); - PhysicsServer::get_singleton()->set_active(!p_enabled); - Physics2DServer::get_singleton()->set_active(!p_enabled); + NavigationServer3D::get_singleton()->set_active(!p_enabled); + PhysicsServer3D::get_singleton()->set_active(!p_enabled); + PhysicsServer2D::get_singleton()->set_active(!p_enabled); if (get_root()) get_root()->propagate_notification(p_enabled ? Node::NOTIFICATION_PAUSED : Node::NOTIFICATION_UNPAUSED); } @@ -1037,7 +1037,7 @@ Node *SceneTree::get_edited_scene_root() const { #ifdef TOOLS_ENABLED return edited_scene_root; #else - return NULL; + return nullptr; #endif } @@ -1056,7 +1056,7 @@ void SceneTree::_change_scene(Node *p_to) { if (current_scene) { memdelete(current_scene); - current_scene = NULL; + current_scene = nullptr; } // If we're quitting, abort. @@ -1082,7 +1082,7 @@ Error SceneTree::change_scene(const String &p_path) { } Error SceneTree::change_scene_to(const Ref<PackedScene> &p_scene) { - Node *new_scene = NULL; + Node *new_scene = nullptr; if (p_scene.is_valid()) { new_scene = p_scene->instance(); ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE); @@ -1321,7 +1321,7 @@ void SceneTree::_bind_methods() { BIND_ENUM_CONSTANT(GROUP_CALL_UNIQUE); } -SceneTree *SceneTree::singleton = NULL; +SceneTree *SceneTree::singleton = nullptr; SceneTree::IdleCallback SceneTree::idle_callbacks[SceneTree::MAX_IDLE_CALLBACKS]; int SceneTree::idle_callback_count = 0; @@ -1372,7 +1372,7 @@ void SceneTree::get_argument_options(const StringName &p_function, int p_idx, Li SceneTree::SceneTree() { - if (singleton == NULL) singleton = this; + if (singleton == nullptr) singleton = this; _quit = false; accept_quit = true; quit_on_go_back = true; @@ -1392,7 +1392,7 @@ SceneTree::SceneTree() { physics_process_time = 1; idle_process_time = 1; - root = NULL; + root = nullptr; pause = false; current_frame = 0; current_event = 0; @@ -1419,7 +1419,7 @@ SceneTree::SceneTree() { //root->set_world_2d( Ref<World2D>( memnew( World2D ))); root->set_as_audio_listener(true); root->set_as_audio_listener_2d(true); - current_scene = NULL; + current_scene = nullptr; int msaa_mode = GLOBAL_DEF("rendering/quality/filters/msaa", 0); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x")); @@ -1463,16 +1463,16 @@ SceneTree::SceneTree() { root->connect("focus_entered", callable_mp(this, &SceneTree::_main_window_focus_in)); #ifdef TOOLS_ENABLED - edited_scene_root = NULL; + edited_scene_root = nullptr; #endif } SceneTree::~SceneTree() { if (root) { - root->_set_tree(NULL); + root->_set_tree(nullptr); root->_propagate_after_exit_tree(); memdelete(root); } - if (singleton == this) singleton = NULL; + if (singleton == this) singleton = nullptr; } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index d293a3cd32..5fcd4bf009 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -53,7 +53,7 @@ #include "scene/resources/mesh.h" #include "scene/scene_string_names.h" #include "servers/display_server.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" void ViewportTexture::setup_local_to_scene() { @@ -61,7 +61,7 @@ void ViewportTexture::setup_local_to_scene() { vp->viewport_textures.erase(this); } - vp = NULL; + vp = nullptr; Node *local_scene = get_local_scene(); if (!local_scene) { @@ -78,11 +78,11 @@ void ViewportTexture::setup_local_to_scene() { vp->viewport_textures.insert(this); if (proxy_ph.is_valid()) { - VS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid); - VS::get_singleton()->free(proxy_ph); + RS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid); + RS::get_singleton()->free(proxy_ph); } else { ERR_FAIL_COND(proxy.is_valid()); //should be invalid - proxy = VS::get_singleton()->texture_proxy_create(vp->texture_rid); + proxy = RS::get_singleton()->texture_proxy_create(vp->texture_rid); } } @@ -122,8 +122,8 @@ RID ViewportTexture::get_rid() const { //ERR_FAIL_COND_V_MSG(!vp, RID(), "Viewport Texture must be set to use it."); if (proxy.is_null()) { - proxy_ph = VS::get_singleton()->texture_2d_placeholder_create(); - proxy = VS::get_singleton()->texture_proxy_create(proxy_ph); + proxy_ph = RS::get_singleton()->texture_2d_placeholder_create(); + proxy = RS::get_singleton()->texture_proxy_create(proxy_ph); } return proxy; } @@ -135,7 +135,7 @@ bool ViewportTexture::has_alpha() const { Ref<Image> ViewportTexture::get_data() const { ERR_FAIL_COND_V_MSG(!vp, Ref<Image>(), "Viewport Texture must be set to use it."); - return VS::get_singleton()->texture_2d_get(vp->texture_rid); + return RS::get_singleton()->texture_2d_get(vp->texture_rid); } void ViewportTexture::_bind_methods() { @@ -148,7 +148,7 @@ void ViewportTexture::_bind_methods() { ViewportTexture::ViewportTexture() { - vp = NULL; + vp = nullptr; set_local_to_scene(true); } @@ -159,10 +159,10 @@ ViewportTexture::~ViewportTexture() { } if (proxy_ph.is_valid()) { - VS::get_singleton()->free(proxy_ph); + RS::get_singleton()->free(proxy_ph); } if (proxy.is_valid()) { - VS::get_singleton()->free(proxy); + RS::get_singleton()->free(proxy); } } @@ -190,17 +190,17 @@ Viewport::GUI::GUI() { embedding_subwindows = false; dragging = false; - mouse_focus = NULL; + mouse_focus = nullptr; forced_mouse_focus = false; - mouse_click_grabber = NULL; + mouse_click_grabber = nullptr; mouse_focus_mask = 0; - key_focus = NULL; - mouse_over = NULL; - drag_mouse_over = NULL; + key_focus = nullptr; + mouse_over = nullptr; + drag_mouse_over = nullptr; - tooltip = NULL; - tooltip_popup = NULL; - tooltip_label = NULL; + tooltip = nullptr; + tooltip_popup = nullptr; + tooltip_label = nullptr; } ///////////////////////////////////// @@ -240,7 +240,7 @@ void Viewport::_collision_object_input_event(CollisionObject3D *p_object, Camera void Viewport::_sub_window_update_order() { for (int i = 0; i < gui.sub_windows.size(); i++) { - VS::get_singleton()->canvas_item_set_draw_index(gui.sub_windows[i].canvas_item, i); + RS::get_singleton()->canvas_item_set_draw_index(gui.sub_windows[i].canvas_item, i); } } @@ -252,19 +252,19 @@ void Viewport::_sub_window_register(Window *p_window) { } if (gui.sub_windows.size() == 0) { - subwindow_canvas = VS::get_singleton()->canvas_create(); - VS::get_singleton()->viewport_attach_canvas(viewport, subwindow_canvas); - VS::get_singleton()->viewport_set_canvas_stacking(viewport, subwindow_canvas, SUBWINDOW_CANVAS_LAYER, 0); + subwindow_canvas = RS::get_singleton()->canvas_create(); + RS::get_singleton()->viewport_attach_canvas(viewport, subwindow_canvas); + RS::get_singleton()->viewport_set_canvas_stacking(viewport, subwindow_canvas, SUBWINDOW_CANVAS_LAYER, 0); } SubWindow sw; - sw.canvas_item = VS::get_singleton()->canvas_item_create(); - VS::get_singleton()->canvas_item_set_parent(sw.canvas_item, subwindow_canvas); + sw.canvas_item = RS::get_singleton()->canvas_item_create(); + RS::get_singleton()->canvas_item_set_parent(sw.canvas_item, subwindow_canvas); sw.window = p_window; gui.sub_windows.push_back(sw); _sub_window_grab_focus(p_window); - VisualServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, viewport); + RenderingServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, viewport); } void Viewport::_sub_window_update(Window *p_window) { @@ -283,7 +283,7 @@ void Viewport::_sub_window_update(Window *p_window) { Transform2D pos; pos.set_origin(p_window->get_position()); - VS::get_singleton()->canvas_item_clear(sw.canvas_item); + RS::get_singleton()->canvas_item_clear(sw.canvas_item); Rect2i r = Rect2i(p_window->get_position(), sw.window->get_size()); if (!p_window->get_flag(Window::FLAG_BORDERLESS)) { @@ -309,7 +309,7 @@ void Viewport::_sub_window_update(Window *p_window) { close_icon->draw(sw.canvas_item, r.position + Vector2(r.size.width - close_h_ofs, -close_v_ofs)); } - VS::get_singleton()->canvas_item_add_texture_rect(sw.canvas_item, r, sw.window->get_texture()->get_rid()); + RS::get_singleton()->canvas_item_add_texture_rect(sw.canvas_item, r, sw.window->get_texture()->get_rid()); } void Viewport::_sub_window_grab_focus(Window *p_window) { @@ -388,14 +388,14 @@ void Viewport::_sub_window_remove(Window *p_window) { for (int i = 0; i < gui.sub_windows.size(); i++) { if (gui.sub_windows[i].window == p_window) { - VS::get_singleton()->free(gui.sub_windows[i].canvas_item); + RS::get_singleton()->free(gui.sub_windows[i].canvas_item); gui.sub_windows.remove(i); break; } } if (gui.sub_windows.size() == 0) { - VS::get_singleton()->free(subwindow_canvas); + RS::get_singleton()->free(subwindow_canvas); subwindow_canvas = RID(); } @@ -419,7 +419,7 @@ void Viewport::_sub_window_remove(Window *p_window) { } } - VisualServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, p_window->parent ? p_window->parent->viewport : RID()); + RenderingServer::get_singleton()->viewport_set_parent_viewport(p_window->viewport, p_window->parent ? p_window->parent->viewport : RID()); } void Viewport::_own_world_changed() { @@ -437,7 +437,7 @@ void Viewport::_own_world_changed() { } if (is_inside_tree()) { - VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); } _update_listener(); @@ -453,14 +453,14 @@ void Viewport::_notification(int p_what) { if (get_parent()) { parent = get_parent()->get_viewport(); - VisualServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid()); + RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid()); } else { - parent = NULL; + parent = nullptr; } current_canvas = find_world_2d()->get_canvas(); - VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); - VisualServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas); _update_listener(); _update_listener_2d(); @@ -470,29 +470,29 @@ void Viewport::_notification(int p_what) { add_to_group("_viewports"); if (get_tree()->is_debugging_collisions_hint()) { //2D - Physics2DServer::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(), get_tree()->get_collision_debug_contact_count()); - contact_2d_debug = VisualServer::get_singleton()->canvas_item_create(); - VisualServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas()); + PhysicsServer2D::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(), get_tree()->get_collision_debug_contact_count()); + contact_2d_debug = RenderingServer::get_singleton()->canvas_item_create(); + RenderingServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas()); //3D - PhysicsServer::get_singleton()->space_set_debug_contacts(find_world()->get_space(), get_tree()->get_collision_debug_contact_count()); - contact_3d_debug_multimesh = VisualServer::get_singleton()->multimesh_create(); - VisualServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), VS::MULTIMESH_TRANSFORM_3D, true); - VisualServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0); - VisualServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid()); - contact_3d_debug_instance = VisualServer::get_singleton()->instance_create(); - VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh); - VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario()); - //VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true); + PhysicsServer3D::get_singleton()->space_set_debug_contacts(find_world()->get_space(), get_tree()->get_collision_debug_contact_count()); + contact_3d_debug_multimesh = RenderingServer::get_singleton()->multimesh_create(); + RenderingServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, true); + RenderingServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0); + RenderingServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid()); + contact_3d_debug_instance = RenderingServer::get_singleton()->instance_create(); + RenderingServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh); + RenderingServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario()); + //RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true); } } break; case NOTIFICATION_READY: { #ifndef _3D_DISABLED if (listeners.size() && !listener) { - Listener3D *first = NULL; + Listener3D *first = nullptr; for (Set<Listener3D *>::Element *E = listeners.front(); E; E = E->next()) { - if (first == NULL || first->is_greater_than(E->get())) { + if (first == nullptr || first->is_greater_than(E->get())) { first = E->get(); } } @@ -503,10 +503,10 @@ void Viewport::_notification(int p_what) { if (cameras.size() && !camera) { //there are cameras but no current camera, pick first in tree and make it current - Camera3D *first = NULL; + Camera3D *first = nullptr; for (Set<Camera3D *>::Element *E = cameras.front(); E; E = E->next()) { - if (first == NULL || first->is_greater_than(E->get())) { + if (first == nullptr || first->is_greater_than(E->get())) { first = E->get(); } } @@ -527,24 +527,24 @@ void Viewport::_notification(int p_what) { if (world_2d.is_valid()) world_2d->_remove_viewport(this); - VisualServer::get_singleton()->viewport_set_scenario(viewport, RID()); - VisualServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, RID()); + RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas); if (contact_2d_debug.is_valid()) { - VisualServer::get_singleton()->free(contact_2d_debug); + RenderingServer::get_singleton()->free(contact_2d_debug); contact_2d_debug = RID(); } if (contact_3d_debug_multimesh.is_valid()) { - VisualServer::get_singleton()->free(contact_3d_debug_multimesh); - VisualServer::get_singleton()->free(contact_3d_debug_instance); + RenderingServer::get_singleton()->free(contact_3d_debug_multimesh); + RenderingServer::get_singleton()->free(contact_3d_debug_instance); contact_3d_debug_instance = RID(); contact_3d_debug_multimesh = RID(); } remove_from_group("_viewports"); - VS::get_singleton()->viewport_set_active(viewport, false); - VisualServer::get_singleton()->viewport_set_parent_viewport(viewport, RID()); + RS::get_singleton()->viewport_set_active(viewport, false); + RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID()); } break; case NOTIFICATION_INTERNAL_PROCESS: { @@ -561,36 +561,36 @@ void Viewport::_notification(int p_what) { if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) { - VisualServer::get_singleton()->canvas_item_clear(contact_2d_debug); - VisualServer::get_singleton()->canvas_item_set_draw_index(contact_2d_debug, 0xFFFFF); //very high index + RenderingServer::get_singleton()->canvas_item_clear(contact_2d_debug); + RenderingServer::get_singleton()->canvas_item_set_draw_index(contact_2d_debug, 0xFFFFF); //very high index - Vector<Vector2> points = Physics2DServer::get_singleton()->space_get_contacts(find_world_2d()->get_space()); - int point_count = Physics2DServer::get_singleton()->space_get_contact_count(find_world_2d()->get_space()); + Vector<Vector2> points = PhysicsServer2D::get_singleton()->space_get_contacts(find_world_2d()->get_space()); + int point_count = PhysicsServer2D::get_singleton()->space_get_contact_count(find_world_2d()->get_space()); Color ccol = get_tree()->get_debug_collision_contact_color(); for (int i = 0; i < point_count; i++) { - VisualServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol); + RenderingServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol); } } if (get_tree()->is_debugging_collisions_hint() && contact_3d_debug_multimesh.is_valid()) { - Vector<Vector3> points = PhysicsServer::get_singleton()->space_get_contacts(find_world()->get_space()); - int point_count = PhysicsServer::get_singleton()->space_get_contact_count(find_world()->get_space()); + Vector<Vector3> points = PhysicsServer3D::get_singleton()->space_get_contacts(find_world()->get_space()); + int point_count = PhysicsServer3D::get_singleton()->space_get_contact_count(find_world()->get_space()); - VS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count); + RS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count); } if (physics_object_picking && (to_screen_rect == Rect2i() || InputFilter::get_singleton()->get_mouse_mode() != InputFilter::MOUSE_MODE_CAPTURED)) { #ifndef _3D_DISABLED Vector2 last_pos(1e20, 1e20); - CollisionObject3D *last_object = NULL; + CollisionObject3D *last_object = nullptr; ObjectID last_id; #endif - PhysicsDirectSpaceState::RayResult result; - Physics2DDirectSpaceState *ss2d = Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space()); + PhysicsDirectSpaceState3D::RayResult result; + PhysicsDirectSpaceState2D *ss2d = PhysicsServer2D::get_singleton()->space_get_direct_state(find_world_2d()->get_space()); if (physics_has_last_mousepos) { // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. @@ -697,7 +697,7 @@ void Viewport::_notification(int p_what) { uint64_t frame = get_tree()->get_frame(); - Physics2DDirectSpaceState::ShapeResult res[64]; + PhysicsDirectSpaceState2D::ShapeResult res[64]; for (Set<CanvasLayer *>::Element *E = canvas_layers.front(); E; E = E->next()) { Transform2D canvas_transform; ObjectID canvas_layer_id; @@ -805,7 +805,7 @@ void Viewport::_notification(int p_what) { Vector3 from = camera->project_ray_origin(pos); Vector3 dir = camera->project_ray_normal(pos); - PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space()); + PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world()->get_space()); if (space) { bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true); @@ -890,9 +890,9 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_override, co to_screen_rect = p_to_screen_rect; if (p_allocated) { - VS::get_singleton()->viewport_set_size(viewport, size.width, size.height); + RS::get_singleton()->viewport_set_size(viewport, size.width, size.height); } else { - VS::get_singleton()->viewport_set_size(viewport, 0, 0); + RS::get_singleton()->viewport_set_size(viewport, 0, 0); } _update_global_transform(); @@ -974,9 +974,9 @@ void Viewport::enable_canvas_transform_override(bool p_enable) { override_canvas_transform = p_enable; if (p_enable) { - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override); } else { - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform); } } @@ -991,7 +991,7 @@ void Viewport::set_canvas_transform_override(const Transform2D &p_transform) { canvas_transform_override = p_transform; if (override_canvas_transform) { - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform_override); } } @@ -1004,7 +1004,7 @@ void Viewport::set_canvas_transform(const Transform2D &p_transform) { canvas_transform = p_transform; if (!override_canvas_transform) { - VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform); + RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform); } } @@ -1017,7 +1017,7 @@ void Viewport::_update_global_transform() { Transform2D sxform = stretch_transform * global_canvas_transform; - VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform); + RenderingServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform); } void Viewport::set_global_canvas_transform(const Transform2D &p_transform) { @@ -1059,7 +1059,7 @@ void Viewport::_listener_remove(Listener3D *p_listener) { listeners.erase(p_listener); if (listener == p_listener) { - listener = NULL; + listener = nullptr; } } @@ -1073,14 +1073,14 @@ void Viewport::_listener_make_next_current(Listener3D *p_exclude) { continue; if (!E->get()->is_inside_tree()) continue; - if (listener != NULL) + if (listener != nullptr) return; E->get()->make_current(); } } else { // Attempt to reset listener to the camera position - if (camera != NULL) { + if (camera != nullptr) { _update_listener(); _camera_transform_changed_notify(); } @@ -1109,9 +1109,9 @@ void Viewport::_camera_set(Camera3D *p_camera) { if (!camera_override) { if (camera) - VisualServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera()); + RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera()); else - VisualServer::get_singleton()->viewport_attach_camera(viewport, RID()); + RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID()); } if (camera) { @@ -1134,7 +1134,7 @@ void Viewport::_camera_remove(Camera3D *p_camera) { cameras.erase(p_camera); if (camera == p_camera) { camera->notification(Camera3D::NOTIFICATION_LOST_CURRENT); - camera = NULL; + camera = nullptr; } } @@ -1147,7 +1147,7 @@ void Viewport::_camera_make_next_current(Camera3D *p_exclude) { continue; if (!E->get()->is_inside_tree()) continue; - if (camera != NULL) + if (camera != nullptr) return; E->get()->make_current(); @@ -1168,7 +1168,7 @@ void Viewport::_canvas_layer_remove(CanvasLayer *p_canvas_layer) { void Viewport::set_transparent_background(bool p_enable) { transparent_bg = p_enable; - VS::get_singleton()->viewport_set_transparent_background(viewport, p_enable); + RS::get_singleton()->viewport_set_transparent_background(viewport, p_enable); } bool Viewport::has_transparent_background() const { @@ -1187,7 +1187,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) { if (is_inside_tree()) { find_world_2d()->_remove_viewport(this); - VisualServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas); + RenderingServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas); } if (p_world_2d.is_valid()) @@ -1201,7 +1201,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) { if (is_inside_tree()) { current_canvas = find_world_2d()->get_canvas(); - VisualServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas); + RenderingServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas); find_world_2d()->_register_viewport(this, Rect2()); } } @@ -1312,7 +1312,7 @@ void Viewport::set_world(const Ref<World3D> &p_world) { _propagate_enter_world(this); if (is_inside_tree()) { - VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); } _update_listener(); @@ -1357,18 +1357,18 @@ void Viewport::enable_camera_override(bool p_enable) { } if (p_enable) { - camera_override.rid = VisualServer::get_singleton()->camera_create(); + camera_override.rid = RenderingServer::get_singleton()->camera_create(); } else { - VisualServer::get_singleton()->free(camera_override.rid); + RenderingServer::get_singleton()->free(camera_override.rid); camera_override.rid = RID(); } if (p_enable) { - VisualServer::get_singleton()->viewport_attach_camera(viewport, camera_override.rid); + RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera_override.rid); } else if (camera) { - VisualServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera()); + RenderingServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera()); } else { - VisualServer::get_singleton()->viewport_attach_camera(viewport, RID()); + RenderingServer::get_singleton()->viewport_attach_camera(viewport, RID()); } #endif } @@ -1380,7 +1380,7 @@ bool Viewport::is_camera_override_enabled() const { void Viewport::set_camera_override_transform(const Transform &p_transform) { if (camera_override) { camera_override.transform = p_transform; - VisualServer::get_singleton()->camera_set_transform(camera_override.rid, p_transform); + RenderingServer::get_singleton()->camera_set_transform(camera_override.rid, p_transform); } } @@ -1403,7 +1403,7 @@ void Viewport::set_camera_override_perspective(float p_fovy_degrees, float p_z_n camera_override.z_far = p_z_far; camera_override.projection = CameraOverrideData::PROJECTION_PERSPECTIVE; - VisualServer::get_singleton()->camera_set_perspective(camera_override.rid, camera_override.fov, camera_override.z_near, camera_override.z_far); + RenderingServer::get_singleton()->camera_set_perspective(camera_override.rid, camera_override.fov, camera_override.z_near, camera_override.z_far); } } @@ -1418,7 +1418,7 @@ void Viewport::set_camera_override_orthogonal(float p_size, float p_z_near, floa camera_override.z_far = p_z_far; camera_override.projection = CameraOverrideData::PROJECTION_ORTHOGONAL; - VisualServer::get_singleton()->camera_set_orthogonal(camera_override.rid, camera_override.size, camera_override.z_near, camera_override.z_far); + RenderingServer::get_singleton()->camera_set_orthogonal(camera_override.rid, camera_override.size, camera_override.z_near, camera_override.z_far); } } @@ -1458,7 +1458,7 @@ void Viewport::set_shadow_atlas_size(int p_size) { return; shadow_atlas_size = p_size; - VS::get_singleton()->viewport_set_shadow_atlas_size(viewport, p_size); + RS::get_singleton()->viewport_set_shadow_atlas_size(viewport, p_size); } int Viewport::get_shadow_atlas_size() const { @@ -1477,7 +1477,7 @@ void Viewport::set_shadow_atlas_quadrant_subdiv(int p_quadrant, ShadowAtlasQuadr shadow_atlas_quadrant_subdiv[p_quadrant] = p_subdiv; static const int subdiv[SHADOW_ATLAS_QUADRANT_SUBDIV_MAX] = { 0, 1, 4, 16, 64, 256, 1024 }; - VS::get_singleton()->viewport_set_shadow_atlas_quadrant_subdivision(viewport, p_quadrant, subdiv[p_subdiv]); + RS::get_singleton()->viewport_set_shadow_atlas_quadrant_subdivision(viewport, p_quadrant, subdiv[p_subdiv]); } Viewport::ShadowAtlasQuadrantSubdiv Viewport::get_shadow_atlas_quadrant_subdiv(int p_quadrant) const { @@ -1528,12 +1528,12 @@ void Viewport::_gui_sort_roots() { void Viewport::_gui_cancel_tooltip() { - gui.tooltip = NULL; + gui.tooltip = nullptr; gui.tooltip_timer = -1; if (gui.tooltip_popup) { gui.tooltip_popup->queue_delete(); - gui.tooltip_popup = NULL; - gui.tooltip_label = NULL; + gui.tooltip_popup = nullptr; + gui.tooltip_label = nullptr; } } @@ -1571,7 +1571,7 @@ void Viewport::_gui_show_tooltip() { return; } - Control *which = NULL; + Control *which = nullptr; String tooltip = _gui_get_tooltip(gui.tooltip, gui.tooltip->get_global_transform().xform_inv(gui.tooltip_pos), &which); tooltip = tooltip.strip_edges(); if (tooltip.length() == 0) @@ -1579,8 +1579,8 @@ void Viewport::_gui_show_tooltip() { if (gui.tooltip_popup) { memdelete(gui.tooltip_popup); - gui.tooltip_popup = NULL; - gui.tooltip_label = NULL; + gui.tooltip_popup = nullptr; + gui.tooltip_label = nullptr; } if (!which) { @@ -1651,7 +1651,7 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu Ref<InputEventPanGesture> pn = p_input; cant_stop_me_now = pn.is_valid() || cant_stop_me_now; - bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != NULL; + bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != nullptr; CanvasItem *ci = p_control; while (ci) { @@ -1741,23 +1741,23 @@ Control *Viewport::_gui_find_control(const Point2 &p_global) { return ret; } - return NULL; + return nullptr; } Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform) { if (Object::cast_to<Viewport>(p_node)) - return NULL; + return nullptr; if (!p_node->is_visible()) { //return _find_next_visible_control_at_pos(p_node,p_global,r_inv_xform); - return NULL; //canvas item hidden, discard + return nullptr; //canvas item hidden, discard } Transform2D matrix = p_xform * p_node->get_transform(); // matrix.basis_determinant() == 0.0f implies that node does not exist on scene if (matrix.basis_determinant() == 0.0f) - return NULL; + return nullptr; Control *c = Object::cast_to<Control>(p_node); @@ -1776,7 +1776,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_ } if (!c) - return NULL; + return nullptr; matrix.affine_invert(); @@ -1785,7 +1785,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_ r_inv_xform = matrix; return c; } else - return NULL; + return nullptr; } bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check) { @@ -1938,7 +1938,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.drag_preview) { memdelete(gui.drag_preview); - gui.drag_preview = NULL; + gui.drag_preview = nullptr; } _propagate_viewport_notification(this, NOTIFICATION_DRAG_END); //change mouse accordingly @@ -1957,7 +1957,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.drag_preview && mb->get_button_index() == BUTTON_LEFT) { memdelete(gui.drag_preview); - gui.drag_preview = NULL; + gui.drag_preview = nullptr; } gui.drag_data = Variant(); @@ -1985,7 +1985,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { //disable mouse focus if needed before calling input, this makes popups on mouse press event work better, as the release will never be received otherwise if (gui.mouse_focus_mask == 0) { - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; } @@ -2011,7 +2011,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { gui.last_mouse_pos = mpos; - Control *over = NULL; + Control *over = nullptr; // D&D if (!gui.drag_attempted && gui.mouse_focus && mm->get_button_mask() & BUTTON_MASK_LEFT) { @@ -2031,15 +2031,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { gui.drag_data = control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos) - gui.drag_accum); if (gui.drag_data.get_type() != Variant::NIL) { - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; gui.mouse_focus_mask = 0; break; } else { - if (gui.drag_preview != NULL) { + if (gui.drag_preview != nullptr) { ERR_PRINT("Don't set a drag preview and return null data. Preview was deleted and drag request ignored."); memdelete(gui.drag_preview); - gui.drag_preview = NULL; + gui.drag_preview = nullptr; } gui.dragging = false; } @@ -2395,7 +2395,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } - Control *from = gui.key_focus ? gui.key_focus : NULL; //hmm + Control *from = gui.key_focus ? gui.key_focus : nullptr; //hmm //keyboard focus //if (from && p_event->is_pressed() && !p_event->get_alt() && !p_event->get_metakey() && !p_event->key->get_command()) { @@ -2405,7 +2405,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { bool mods = k.is_valid() && (k->get_control() || k->get_alt() || k->get_shift() || k->get_metakey()); if (from && p_event->is_pressed()) { - Control *next = NULL; + Control *next = nullptr; InputFilter *input = InputFilter::get_singleton(); @@ -2463,7 +2463,7 @@ void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control * gui.dragging = true; gui.drag_data = p_data; - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; if (p_control) { _gui_set_drag_preview(p_base, p_control); @@ -2475,7 +2475,7 @@ void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) { ERR_FAIL_NULL(p_control); ERR_FAIL_COND(!Object::cast_to<Control>((Object *)p_control)); ERR_FAIL_COND(p_control->is_inside_tree()); - ERR_FAIL_COND(p_control->get_parent() != NULL); + ERR_FAIL_COND(p_control->get_parent() != nullptr); if (gui.drag_preview) { memdelete(gui.drag_preview); @@ -2506,22 +2506,12 @@ void Viewport::_gui_hid_control(Control *p_control) { _drop_mouse_focus(); } - /* ??? - if (data.window==p_control) { - window->drag_data=Variant(); - if (window->drag_preview) { - memdelete( window->drag_preview); - window->drag_preview=NULL; - } - } - */ - if (gui.key_focus == p_control) _gui_remove_focus(); if (gui.mouse_over == p_control) - gui.mouse_over = NULL; + gui.mouse_over = nullptr; if (gui.drag_mouse_over == p_control) - gui.drag_mouse_over = NULL; + gui.drag_mouse_over = nullptr; if (gui.tooltip == p_control) _gui_cancel_tooltip(); } @@ -2529,28 +2519,28 @@ void Viewport::_gui_hid_control(Control *p_control) { void Viewport::_gui_remove_control(Control *p_control) { if (gui.mouse_focus == p_control) { - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; gui.mouse_focus_mask = 0; } if (gui.last_mouse_focus == p_control) { - gui.last_mouse_focus = NULL; + gui.last_mouse_focus = nullptr; } if (gui.key_focus == p_control) - gui.key_focus = NULL; + gui.key_focus = nullptr; if (gui.mouse_over == p_control) - gui.mouse_over = NULL; + gui.mouse_over = nullptr; if (gui.drag_mouse_over == p_control) - gui.drag_mouse_over = NULL; + gui.drag_mouse_over = nullptr; if (gui.tooltip == p_control) - gui.tooltip = NULL; + gui.tooltip = nullptr; } void Viewport::_gui_remove_focus() { if (gui.key_focus) { Node *f = gui.key_focus; - gui.key_focus = NULL; + gui.key_focus = nullptr; f->notification(Control::NOTIFICATION_FOCUS_EXIT, true); } } @@ -2583,7 +2573,7 @@ void Viewport::_drop_mouse_focus() { Control *c = gui.mouse_focus; int mask = gui.mouse_focus_mask; - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; gui.mouse_focus_mask = 0; @@ -2645,7 +2635,7 @@ void Viewport::_post_gui_grab_click_focus() { // Redundant grab requests were made return; } - gui.mouse_click_grabber = NULL; + gui.mouse_click_grabber = nullptr; if (gui.mouse_focus) { @@ -3063,7 +3053,7 @@ void Viewport::unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coor get_tree()->_call_input_pause(unhandled_input_group, "_unhandled_input", ev, this); //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev); - if (!is_input_handled() && Object::cast_to<InputEventKey>(*ev) != NULL) { + if (!is_input_handled() && Object::cast_to<InputEventKey>(*ev) != nullptr) { get_tree()->_call_input_pause(unhandled_key_input_group, "_unhandled_key_input", ev, this); //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev); } @@ -3109,7 +3099,7 @@ void Viewport::set_use_own_world(bool p_world) { _propagate_enter_world(this); if (is_inside_tree()) { - VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); + RenderingServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario()); } _update_listener(); @@ -3183,7 +3173,7 @@ void Viewport::set_msaa(MSAA p_msaa) { if (msaa == p_msaa) return; msaa = p_msaa; - VS::get_singleton()->viewport_set_msaa(viewport, VS::ViewportMSAA(p_msaa)); + RS::get_singleton()->viewport_set_msaa(viewport, RS::ViewportMSAA(p_msaa)); } Viewport::MSAA Viewport::get_msaa() const { @@ -3194,7 +3184,7 @@ Viewport::MSAA Viewport::get_msaa() const { void Viewport::set_debug_draw(DebugDraw p_debug_draw) { debug_draw = p_debug_draw; - VS::get_singleton()->viewport_set_debug_draw(viewport, VS::ViewportDebugDraw(p_debug_draw)); + RS::get_singleton()->viewport_set_debug_draw(viewport, RS::ViewportDebugDraw(p_debug_draw)); } Viewport::DebugDraw Viewport::get_debug_draw() const { @@ -3204,7 +3194,7 @@ Viewport::DebugDraw Viewport::get_debug_draw() const { int Viewport::get_render_info(RenderInfo p_info) { - return VS::get_singleton()->viewport_get_render_info(viewport, VS::ViewportRenderInfo(p_info)); + return RS::get_singleton()->viewport_get_render_info(viewport, RS::ViewportRenderInfo(p_info)); } void Viewport::set_snap_controls_to_pixels(bool p_enable) { @@ -3527,23 +3517,23 @@ Viewport::Viewport() { world_2d = Ref<World2D>(memnew(World2D)); - viewport = VisualServer::get_singleton()->viewport_create(); - texture_rid = VisualServer::get_singleton()->viewport_get_texture(viewport); + viewport = RenderingServer::get_singleton()->viewport_create(); + texture_rid = RenderingServer::get_singleton()->viewport_get_texture(viewport); default_texture.instance(); default_texture->vp = const_cast<Viewport *>(this); viewport_textures.insert(default_texture.ptr()); - default_texture->proxy = VS::get_singleton()->texture_proxy_create(texture_rid); + default_texture->proxy = RS::get_singleton()->texture_proxy_create(texture_rid); audio_listener = false; //internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create(); audio_listener_2d = false; transparent_bg = false; - parent = NULL; - listener = NULL; - camera = NULL; + parent = nullptr; + listener = nullptr; + camera = nullptr; override_canvas_transform = false; - canvas_layers.insert(NULL); // This eases picking code (interpreted as the canvas of the Viewport) + canvas_layers.insert(nullptr); // This eases picking code (interpreted as the canvas of the Viewport) gen_mipmaps = false; @@ -3577,15 +3567,15 @@ Viewport::Viewport() { gui.tooltip_delay = GLOBAL_DEF("gui/timers/tooltip_delay_sec", 0.5); ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::FLOAT, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers - gui.tooltip = NULL; - gui.tooltip_label = NULL; - gui.drag_preview = NULL; + gui.tooltip = nullptr; + gui.tooltip_label = nullptr; + gui.drag_preview = nullptr; gui.drag_attempted = false; gui.canvas_sort_index = 0; gui.roots_order_dirty = false; - gui.mouse_focus = NULL; + gui.mouse_focus = nullptr; gui.forced_mouse_focus = false; - gui.last_mouse_focus = NULL; + gui.last_mouse_focus = nullptr; gui.subwindow_focused = nullptr; gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED; @@ -3612,9 +3602,9 @@ Viewport::~Viewport() { //erase itself from viewport textures for (Set<ViewportTexture *>::Element *E = viewport_textures.front(); E; E = E->next()) { - E->get()->vp = NULL; + E->get()->vp = nullptr; } - VisualServer::get_singleton()->free(viewport); + RenderingServer::get_singleton()->free(viewport); } ///////////////////////////////// @@ -3622,7 +3612,7 @@ Viewport::~Viewport() { void SubViewport::set_use_arvr(bool p_use_arvr) { arvr = p_use_arvr; - VS::get_singleton()->viewport_set_use_arvr(get_viewport_rid(), arvr); + RS::get_singleton()->viewport_set_use_arvr(get_viewport_rid(), arvr); } bool SubViewport::is_using_arvr() { @@ -3639,7 +3629,7 @@ Size2i SubViewport::get_size() const { void SubViewport::set_update_mode(UpdateMode p_mode) { update_mode = p_mode; - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::ViewportUpdateMode(p_mode)); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::ViewportUpdateMode(p_mode)); } SubViewport::UpdateMode SubViewport::get_update_mode() const { @@ -3649,7 +3639,7 @@ SubViewport::UpdateMode SubViewport::get_update_mode() const { void SubViewport::set_clear_mode(ClearMode p_mode) { clear_mode = p_mode; - VS::get_singleton()->viewport_set_clear_mode(get_viewport_rid(), VS::ViewportClearMode(p_mode)); + RS::get_singleton()->viewport_set_clear_mode(get_viewport_rid(), RS::ViewportClearMode(p_mode)); } SubViewport::ClearMode SubViewport::get_clear_mode() const { @@ -3664,10 +3654,10 @@ DisplayServer::WindowID SubViewport::get_window_id() const { void SubViewport::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - VS::get_singleton()->viewport_set_active(get_viewport_rid(), true); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), true); } if (p_what == NOTIFICATION_EXIT_TREE) { - VS::get_singleton()->viewport_set_active(get_viewport_rid(), false); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), false); } } diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 8a56caea52..8982869783 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -36,7 +36,7 @@ #include "scene/resources/texture.h" #include "scene/resources/world_2d.h" #include "servers/display_server.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class Camera3D; class Camera2D; @@ -374,7 +374,7 @@ private: void _gui_remove_root_control(List<Control *>::Element *RI); - String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_which = NULL); + String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_which = nullptr); void _gui_cancel_tooltip(); void _gui_show_tooltip(); diff --git a/scene/main/window.cpp b/scene/main/window.cpp index b22b99c50c..45982e0e93 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -249,7 +249,7 @@ void Window::_make_window() { } } - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_WHEN_VISIBLE); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE); } void Window::_update_from_window() { @@ -279,7 +279,7 @@ void Window::_clear_window() { window_id = DisplayServer::INVALID_WINDOW_ID; _update_viewport_size(); - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); } void Window::_rect_changed_callback(const Rect2i &p_callback) { @@ -387,11 +387,11 @@ void Window::set_visible(bool p_visible) { if (visible) { embedder = embedder_vp; embedder->_sub_window_register(this); - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); } else { embedder->_sub_window_remove(this); embedder = nullptr; - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); } _update_window_size(); } @@ -402,7 +402,7 @@ void Window::set_visible(bool p_visible) { notification(NOTIFICATION_VISIBILITY_CHANGED); emit_signal(SceneStringNames::get_singleton()->visibility_changed); - VS::get_singleton()->viewport_set_active(get_viewport_rid(), visible); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), visible); } void Window::_clear_transient() { @@ -606,14 +606,14 @@ void Window::_update_viewport_size() { //black bars and margin if (content_scale_aspect != CONTENT_SCALE_ASPECT_EXPAND && screen_size.x < video_mode.x) { margin.x = Math::round((video_mode.x - screen_size.x) / 2.0); - //VisualServer::get_singleton()->black_bars_set_margins(margin.x, 0, margin.x, 0); + //RenderingServer::get_singleton()->black_bars_set_margins(margin.x, 0, margin.x, 0); offset.x = Math::round(margin.x * viewport_size.y / screen_size.y); } else if (content_scale_aspect != CONTENT_SCALE_ASPECT_EXPAND && screen_size.y < video_mode.y) { margin.y = Math::round((video_mode.y - screen_size.y) / 2.0); - //VisualServer::get_singleton()->black_bars_set_margins(0, margin.y, 0, margin.y); + //RenderingServer::get_singleton()->black_bars_set_margins(0, margin.y, 0, margin.y); offset.y = Math::round(margin.y * viewport_size.x / screen_size.x); } else { - //VisualServer::get_singleton()->black_bars_set_margins(0, 0, 0, 0); + //RenderingServer::get_singleton()->black_bars_set_margins(0, 0, 0, 0); } switch (content_scale_mode) { @@ -646,9 +646,9 @@ void Window::_update_viewport_size() { _set_size(final_size, final_size_override, attach_to_screen_rect, stretch_transform, allocate); if (window_id != DisplayServer::INVALID_WINDOW_ID) { - VisualServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id); + RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), attach_to_screen_rect, window_id); } else { - VisualServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), Rect2i(), DisplayServer::INVALID_WINDOW_ID); + RenderingServer::get_singleton()->viewport_attach_to_screen(get_viewport_rid(), Rect2i(), DisplayServer::INVALID_WINDOW_ID); } if (window_id == DisplayServer::MAIN_WINDOW_ID) { @@ -718,7 +718,7 @@ void Window::_notification(int p_what) { //create as embedded if (embedder) { embedder->_sub_window_register(this); - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); _update_window_size(); } @@ -736,7 +736,7 @@ void Window::_notification(int p_what) { } _update_viewport_size(); //then feed back to the viewport _update_window_callbacks(); - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_WHEN_VISIBLE); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_WHEN_VISIBLE); } else { //create if (visible) { @@ -752,7 +752,7 @@ void Window::_notification(int p_what) { if (visible) { notification(NOTIFICATION_VISIBILITY_CHANGED); emit_signal(SceneStringNames::get_singleton()->visibility_changed); - VS::get_singleton()->viewport_set_active(get_viewport_rid(), true); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), true); } } @@ -773,7 +773,7 @@ void Window::_notification(int p_what) { if (window_id == DisplayServer::MAIN_WINDOW_ID) { - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); _update_window_callbacks(); } else { _clear_window(); @@ -783,12 +783,12 @@ void Window::_notification(int p_what) { if (embedder) { embedder->_sub_window_remove(this); embedder = nullptr; - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); } _update_viewport_size(); //called by clear and make, which does not happen here } - VS::get_singleton()->viewport_set_active(get_viewport_rid(), false); + RS::get_singleton()->viewport_set_active(get_viewport_rid(), false); } } @@ -1108,13 +1108,13 @@ void Window::remove_child_notify(Node *p_child) { Control *child_c = Object::cast_to<Control>(p_child); if (child_c && (child_c->data.theme_owner || child_c->data.theme_owner_window) && child_c->data.theme.is_null()) { - Control::_propagate_theme_changed(child_c, NULL, NULL); + Control::_propagate_theme_changed(child_c, nullptr, nullptr); } Window *child_w = Object::cast_to<Window>(p_child); if (child_w && (child_w->theme_owner || child_w->theme_owner_window) && child_w->theme.is_null()) { - Control::_propagate_theme_changed(child_w, NULL, NULL); + Control::_propagate_theme_changed(child_w, nullptr, nullptr); } if (is_inside_tree() && wrap_controls) { @@ -1285,7 +1285,7 @@ void Window::_bind_methods() { ClassDB::bind_method(D_METHOD("set_exclusive", "exclusive"), &Window::set_exclusive); ClassDB::bind_method(D_METHOD("is_exclusive"), &Window::is_exclusive); - ClassDB::bind_method(D_METHOD("can_draw"), &Window::is_transient); + ClassDB::bind_method(D_METHOD("can_draw"), &Window::can_draw); ClassDB::bind_method(D_METHOD("has_focus"), &Window::has_focus); ClassDB::bind_method(D_METHOD("grab_focus"), &Window::grab_focus); @@ -1400,7 +1400,7 @@ Window::Window() { } content_scale_mode = CONTENT_SCALE_MODE_DISABLED; content_scale_aspect = CONTENT_SCALE_ASPECT_IGNORE; - VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); } Window::~Window() { } diff --git a/scene/main/window.h b/scene/main/window.h index be07762f20..adaa5ca3be 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -43,7 +43,7 @@ public: MODE_WINDOWED = DisplayServer::WINDOW_MODE_WINDOWED, MODE_MINIMIZED = DisplayServer::WINDOW_MODE_MINIMIZED, MODE_MAXIMIZED = DisplayServer::WINDOW_MODE_MAXIMIZED, - MODE_FULLSCREEN = DisplayServer::WINDOW_MODE_FULLSCREEN + MODE_FULLSCREEN = DisplayServer::WINDOW_MODE_FULLSCREEN, }; enum Flags { @@ -59,7 +59,6 @@ public: CONTENT_SCALE_MODE_DISABLED, CONTENT_SCALE_MODE_OBJECTS, CONTENT_SCALE_MODE_PIXELS, - }; enum ContentScaleAspect { @@ -68,10 +67,10 @@ public: CONTENT_SCALE_ASPECT_KEEP_WIDTH, CONTENT_SCALE_ASPECT_KEEP_HEIGHT, CONTENT_SCALE_ASPECT_EXPAND, - }; + enum { - DEFAULT_WINDOW_SIZE = 100 + DEFAULT_WINDOW_SIZE = 100, }; private: @@ -258,8 +257,8 @@ public: ~Window(); }; -VARIANT_ENUM_CAST(Window::Window::Mode); -VARIANT_ENUM_CAST(Window::Window::Flags); +VARIANT_ENUM_CAST(Window::Mode); +VARIANT_ENUM_CAST(Window::Flags); VARIANT_ENUM_CAST(Window::ContentScaleMode); VARIANT_ENUM_CAST(Window::ContentScaleAspect); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 1094759ce7..94162cbe4e 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -110,6 +110,7 @@ #include "scene/gui/slider.h" #include "scene/gui/spin_box.h" #include "scene/gui/split_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/gui/tab_container.h" #include "scene/gui/tabs.h" #include "scene/gui/text_edit.h" @@ -119,7 +120,6 @@ #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" #include "scene/gui/video_player.h" -#include "scene/gui/viewport_container.h" #include "scene/main/canvas_item.h" #include "scene/main/canvas_layer.h" #include "scene/main/http_request.h" @@ -270,6 +270,7 @@ void register_scene_types() { ClassDB::register_virtual_class<InstancePlaceholder>(); ClassDB::register_virtual_class<Viewport>(); + ClassDB::register_class<SubViewport>(); ClassDB::register_class<ViewportTexture>(); ClassDB::register_class<HTTPRequest>(); ClassDB::register_class<Timer>(); @@ -356,7 +357,7 @@ void register_scene_types() { ClassDB::register_class<ConfirmationDialog>(); ClassDB::register_class<MarginContainer>(); - ClassDB::register_class<ViewportContainer>(); + ClassDB::register_class<SubViewportContainer>(); ClassDB::register_virtual_class<SplitContainer>(); ClassDB::register_class<HSplitContainer>(); ClassDB::register_class<VSplitContainer>(); @@ -754,6 +755,8 @@ void register_scene_types() { ClassDB::add_compatibility_class("Area", "Area3D"); ClassDB::add_compatibility_class("BoneAttachment", "BoneAttachment3D"); ClassDB::add_compatibility_class("BoxShape", "BoxShape3D"); + ClassDB::add_compatibility_class("BulletPhysicsDirectBodyState", "BulletPhysicsDirectBodyState3D"); + ClassDB::add_compatibility_class("BulletPhysicsServer", "BulletPhysicsServer3D"); ClassDB::add_compatibility_class("Camera", "Camera3D"); ClassDB::add_compatibility_class("CapsuleShape", "CapsuleShape3D"); ClassDB::add_compatibility_class("ClippedCamera", "ClippedCamera3D"); @@ -764,8 +767,19 @@ void register_scene_types() { ClassDB::add_compatibility_class("ConeTwistJoint", "ConeTwistJoint3D"); ClassDB::add_compatibility_class("ConvexPolygonShape", "ConvexPolygonShape3D"); ClassDB::add_compatibility_class("CPUParticles", "CPUParticles3D"); + ClassDB::add_compatibility_class("CSGBox", "CSGBox3D"); + ClassDB::add_compatibility_class("CSGCombiner", "CSGCombiner3D"); + ClassDB::add_compatibility_class("CSGCylinder", "CSGCylinder3D"); + ClassDB::add_compatibility_class("CSGMesh", "CSGMesh3D"); + ClassDB::add_compatibility_class("CSGPolygon", "CSGPolygon3D"); + ClassDB::add_compatibility_class("CSGPrimitive", "CSGPrimitive3D"); + ClassDB::add_compatibility_class("CSGShape", "CSGShape3D"); + ClassDB::add_compatibility_class("CSGSphere", "CSGSphere3D"); + ClassDB::add_compatibility_class("CSGTorus", "CSGTorus3D"); ClassDB::add_compatibility_class("CylinderShape", "CylinderShape3D"); ClassDB::add_compatibility_class("DirectionalLight", "DirectionalLight3D"); + ClassDB::add_compatibility_class("EditorSpatialGizmo", "EditorNode3DGizmo"); + ClassDB::add_compatibility_class("EditorSpatialGizmoPlugin", "EditorNode3DGizmoPlugin"); ClassDB::add_compatibility_class("Generic6DOFJoint", "Generic6DOFJoint3D"); ClassDB::add_compatibility_class("HeightMapShape", "HeightMapShape3D"); ClassDB::add_compatibility_class("HingeJoint", "HingeJoint3D"); @@ -783,13 +797,28 @@ void register_scene_types() { ClassDB::add_compatibility_class("NavigationObstacle", "NavigationObstacle3D"); ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D"); ClassDB::add_compatibility_class("NavigationRegion", "NavigationRegion3D"); + ClassDB::add_compatibility_class("Navigation2DServer", "NavigationServer2D"); + ClassDB::add_compatibility_class("NavigationServer", "NavigationServer3D"); ClassDB::add_compatibility_class("OmniLight", "OmniLight3D"); ClassDB::add_compatibility_class("Particles", "GPUParticles3D"); ClassDB::add_compatibility_class("Particles2D", "GPUParticles2D"); ClassDB::add_compatibility_class("Path", "Path3D"); ClassDB::add_compatibility_class("PathFollow", "PathFollow3D"); ClassDB::add_compatibility_class("PhysicalBone", "PhysicalBone3D"); + ClassDB::add_compatibility_class("Physics2DDirectBodyStateSW", "PhysicsDirectBodyState2DSW"); + ClassDB::add_compatibility_class("Physics2DDirectBodyState", "PhysicsDirectBodyState2D"); + ClassDB::add_compatibility_class("Physics2DDirectSpaceState", "PhysicsDirectSpaceState2D"); + ClassDB::add_compatibility_class("Physics2DServerSW", "PhysicsServer2DSW"); + ClassDB::add_compatibility_class("Physics2DServer", "PhysicsServer2D"); + ClassDB::add_compatibility_class("Physics2DShapeQueryParameters", "PhysicsShapeQueryParameters2D"); + ClassDB::add_compatibility_class("Physics2DShapeQueryResult", "PhysicsShapeQueryResult2D"); + ClassDB::add_compatibility_class("Physics2DTestMotionResult", "PhysicsTestMotionResult2D"); ClassDB::add_compatibility_class("PhysicsBody", "PhysicsBody3D"); + ClassDB::add_compatibility_class("PhysicsDirectBodyState", "PhysicsDirectBodyState3D"); + ClassDB::add_compatibility_class("PhysicsDirectSpaceState", "PhysicsDirectSpaceState3D"); + ClassDB::add_compatibility_class("PhysicsServer", "PhysicsServer3D"); + ClassDB::add_compatibility_class("PhysicsShapeQueryParameters", "PhysicsShapeQueryParameters3D"); + ClassDB::add_compatibility_class("PhysicsShapeQueryResult", "PhysicsShapeQueryResult3D"); ClassDB::add_compatibility_class("PinJoint", "PinJoint3D"); ClassDB::add_compatibility_class("PlaneShape", "WorldMarginShape3D"); ClassDB::add_compatibility_class("ProximityGroup", "ProximityGroup3D"); @@ -803,6 +832,7 @@ void register_scene_types() { ClassDB::add_compatibility_class("SliderJoint", "SliderJoint3D"); ClassDB::add_compatibility_class("SoftBody", "SoftBody3D"); ClassDB::add_compatibility_class("Spatial", "Node3D"); + ClassDB::add_compatibility_class("SpatialGizmo", "Node3DGizmo"); ClassDB::add_compatibility_class("SpatialMaterial", "StandardMaterial3D"); ClassDB::add_compatibility_class("SpatialVelocityTracker", "VelocityTracker3D"); ClassDB::add_compatibility_class("SphereShape", "SphereShape3D"); @@ -812,13 +842,18 @@ void register_scene_types() { ClassDB::add_compatibility_class("StaticBody", "StaticBody3D"); ClassDB::add_compatibility_class("VehicleBody", "VehicleBody3D"); ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D"); + ClassDB::add_compatibility_class("ViewportContainer", "SubViewportContainer"); ClassDB::add_compatibility_class("VisibilityEnabler", "VisibilityEnabler3D"); ClassDB::add_compatibility_class("VisibilityNotifier", "VisibilityNotifier3D"); + ClassDB::add_compatibility_class("VisualServer", "RenderingServer"); ClassDB::add_compatibility_class("VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant"); ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc"); ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp"); ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform"); ClassDB::add_compatibility_class("World", "World3D"); + ClassDB::add_compatibility_class("ProceduralSky", "Sky"); + ClassDB::add_compatibility_class("PanoramaSky", "Sky"); + #endif OS::get_singleton()->yield(); //may take time to init diff --git a/scene/resources/SCsub b/scene/resources/SCsub index 5e5b6f8fd5..3a86b22835 100644 --- a/scene/resources/SCsub +++ b/scene/resources/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 36d5df52df..e4e5177a8c 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -84,7 +84,10 @@ private: float transition; float time; // time in secs - Key() { transition = 1; } + Key() { + transition = 1; + time = 0; + } }; // transform key holds either Vector3 or Quaternion diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index a68b750b31..d630a1f3ee 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -481,8 +481,8 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) { AudioServer::get_singleton()->lock(); if (data) { - AudioServer::get_singleton()->audio_data_free(data); - data = NULL; + memfree(data); + data = nullptr; data_bytes = 0; } @@ -491,7 +491,7 @@ void AudioStreamSample::set_data(const Vector<uint8_t> &p_data) { const uint8_t *r = p_data.ptr(); int alloc_len = datalen + DATA_PAD * 2; - data = AudioServer::get_singleton()->audio_data_alloc(alloc_len); //alloc with some padding for interpolation + data = memalloc(alloc_len); //alloc with some padding for interpolation zeromem(data, alloc_len); uint8_t *dataptr = (uint8_t *)data; copymem(dataptr + DATA_PAD, r, datalen); @@ -654,14 +654,14 @@ AudioStreamSample::AudioStreamSample() { loop_begin = 0; loop_end = 0; mix_rate = 44100; - data = NULL; + data = nullptr; data_bytes = 0; } AudioStreamSample::~AudioStreamSample() { if (data) { - AudioServer::get_singleton()->audio_data_free(data); - data = NULL; + memfree(data); + data = nullptr; data_bytes = 0; } } diff --git a/scene/resources/box_shape_3d.cpp b/scene/resources/box_shape_3d.cpp index 3ac29642d7..64c821a011 100644 --- a/scene/resources/box_shape_3d.cpp +++ b/scene/resources/box_shape_3d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "box_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> BoxShape3D::get_debug_mesh_lines() { @@ -54,7 +54,7 @@ real_t BoxShape3D::get_enclosing_radius() const { void BoxShape3D::_update_shape() { - PhysicsServer::get_singleton()->shape_set_data(get_shape(), extents); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), extents); Shape3D::_update_shape(); } @@ -80,7 +80,7 @@ void BoxShape3D::_bind_methods() { } BoxShape3D::BoxShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_BOX)) { set_extents(Vector3(1, 1, 1)); } diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 9b8083de97..ab2657c892 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -30,8 +30,8 @@ #include "capsule_shape_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" Vector<Vector2> CapsuleShape2D::_get_points() const { @@ -54,7 +54,7 @@ bool CapsuleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_ void CapsuleShape2D::_update_shape() { - Physics2DServer::get_singleton()->shape_set_data(get_rid(), Vector2(radius, height)); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), Vector2(radius, height)); emit_changed(); } @@ -85,7 +85,7 @@ void CapsuleShape2D::draw(const RID &p_to_rid, const Color &p_color) { Vector<Vector2> points = _get_points(); Vector<Color> col; col.push_back(p_color); - VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); + RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); } Rect2 CapsuleShape2D::get_rect() const { @@ -114,7 +114,7 @@ void CapsuleShape2D::_bind_methods() { } CapsuleShape2D::CapsuleShape2D() : - Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->capsule_shape_create()) { radius = 10; height = 20; diff --git a/scene/resources/capsule_shape_3d.cpp b/scene/resources/capsule_shape_3d.cpp index a929caa275..da3ffcb306 100644 --- a/scene/resources/capsule_shape_3d.cpp +++ b/scene/resources/capsule_shape_3d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "capsule_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> CapsuleShape3D::get_debug_mesh_lines() { @@ -78,7 +78,7 @@ void CapsuleShape3D::_update_shape() { Dictionary d; d["radius"] = radius; d["height"] = height; - PhysicsServer::get_singleton()->shape_set_data(get_shape(), d); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d); Shape3D::_update_shape(); } @@ -120,7 +120,7 @@ void CapsuleShape3D::_bind_methods() { } CapsuleShape3D::CapsuleShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CAPSULE)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CAPSULE)) { radius = 1.0; height = 1.0; diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index 37874e17ef..afb7597280 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -30,8 +30,8 @@ #include "circle_shape_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" bool CircleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { @@ -40,7 +40,7 @@ bool CircleShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_t void CircleShape2D::_update_shape() { - Physics2DServer::get_singleton()->shape_set_data(get_rid(), radius); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), radius); emit_changed(); } @@ -84,11 +84,11 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) { Vector<Color> col; col.push_back(p_color); - VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); + RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); } CircleShape2D::CircleShape2D() : - Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->circle_shape_create()) { radius = 10; _update_shape(); diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index c3e9e19721..c8fec3b72d 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -30,8 +30,8 @@ #include "concave_polygon_shape_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { @@ -52,13 +52,13 @@ bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, do void ConcavePolygonShape2D::set_segments(const Vector<Vector2> &p_segments) { - Physics2DServer::get_singleton()->shape_set_data(get_rid(), p_segments); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), p_segments); emit_changed(); } Vector<Vector2> ConcavePolygonShape2D::get_segments() const { - return Physics2DServer::get_singleton()->shape_get_data(get_rid()); + return PhysicsServer2D::get_singleton()->shape_get_data(get_rid()); } void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) { @@ -70,7 +70,7 @@ void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) { const Vector2 *r = s.ptr(); for (int i = 0; i < len; i += 2) { - VisualServer::get_singleton()->canvas_item_add_line(p_to_rid, r[i], r[i + 1], p_color, 2); + RenderingServer::get_singleton()->canvas_item_add_line(p_to_rid, r[i], r[i + 1], p_color, 2); } } @@ -113,7 +113,7 @@ void ConcavePolygonShape2D::_bind_methods() { } ConcavePolygonShape2D::ConcavePolygonShape2D() : - Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->concave_polygon_shape_create()) { Vector<Vector2> empty; set_segments(empty); } diff --git a/scene/resources/concave_polygon_shape_3d.cpp b/scene/resources/concave_polygon_shape_3d.cpp index 6be4a087ad..42e06a49b6 100644 --- a/scene/resources/concave_polygon_shape_3d.cpp +++ b/scene/resources/concave_polygon_shape_3d.cpp @@ -30,7 +30,7 @@ #include "concave_polygon_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> ConcavePolygonShape3D::get_debug_mesh_lines() { @@ -80,13 +80,13 @@ void ConcavePolygonShape3D::_update_shape() { void ConcavePolygonShape3D::set_faces(const Vector<Vector3> &p_faces) { - PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), p_faces); notify_change_to_owners(); } Vector<Vector3> ConcavePolygonShape3D::get_faces() const { - return PhysicsServer::get_singleton()->shape_get_data(get_shape()); + return PhysicsServer3D::get_singleton()->shape_get_data(get_shape()); } void ConcavePolygonShape3D::_bind_methods() { @@ -97,7 +97,7 @@ void ConcavePolygonShape3D::_bind_methods() { } ConcavePolygonShape3D::ConcavePolygonShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONCAVE_POLYGON)) { //set_planes(Vector3(1,1,1)); } diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index 95967429c9..6b1ddec507 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -31,8 +31,8 @@ #include "convex_polygon_shape_2d.h" #include "core/math/geometry.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" bool ConvexPolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { @@ -45,7 +45,7 @@ void ConvexPolygonShape2D::_update_shape() { if (Geometry::is_polygon_clockwise(final_points)) { //needs to be counter clockwise final_points.invert(); } - Physics2DServer::get_singleton()->shape_set_data(get_rid(), final_points); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), final_points); emit_changed(); } @@ -81,7 +81,7 @@ void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) { Vector<Color> col; col.push_back(p_color); - VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); + RenderingServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); } Rect2 ConvexPolygonShape2D::get_rect() const { @@ -106,5 +106,5 @@ real_t ConvexPolygonShape2D::get_enclosing_radius() const { } ConvexPolygonShape2D::ConvexPolygonShape2D() : - Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->convex_polygon_shape_create()) { } diff --git a/scene/resources/convex_polygon_shape_3d.cpp b/scene/resources/convex_polygon_shape_3d.cpp index e25301b2eb..ec9ab68015 100644 --- a/scene/resources/convex_polygon_shape_3d.cpp +++ b/scene/resources/convex_polygon_shape_3d.cpp @@ -30,7 +30,7 @@ #include "convex_polygon_shape_3d.h" #include "core/math/quick_hull.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> ConvexPolygonShape3D::get_debug_mesh_lines() { @@ -67,7 +67,7 @@ real_t ConvexPolygonShape3D::get_enclosing_radius() const { void ConvexPolygonShape3D::_update_shape() { - PhysicsServer::get_singleton()->shape_set_data(get_shape(), points); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), points); Shape3D::_update_shape(); } @@ -92,5 +92,5 @@ void ConvexPolygonShape3D::_bind_methods() { } ConvexPolygonShape3D::ConvexPolygonShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CONVEX_POLYGON)) { } diff --git a/scene/resources/cylinder_shape_3d.cpp b/scene/resources/cylinder_shape_3d.cpp index 7636c55346..19f0542818 100644 --- a/scene/resources/cylinder_shape_3d.cpp +++ b/scene/resources/cylinder_shape_3d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "cylinder_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> CylinderShape3D::get_debug_mesh_lines() { @@ -71,7 +71,7 @@ void CylinderShape3D::_update_shape() { Dictionary d; d["radius"] = radius; d["height"] = height; - PhysicsServer::get_singleton()->shape_set_data(get_shape(), d); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d); Shape3D::_update_shape(); } @@ -113,7 +113,7 @@ void CylinderShape3D::_bind_methods() { } CylinderShape3D::CylinderShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CYLINDER)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_CYLINDER)) { radius = 1.0; height = 2.0; diff --git a/scene/resources/default_theme/SCsub b/scene/resources/default_theme/SCsub index b01e2fd54d..fc61250247 100644 --- a/scene/resources/default_theme/SCsub +++ b/scene/resources/default_theme/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 0c45779307..e6f09eb034 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -890,9 +890,9 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) { void clear_default_theme() { - Theme::set_project_default(NULL); - Theme::set_default(NULL); - Theme::set_default_icon(NULL); - Theme::set_default_style(NULL); - Theme::set_default_font(NULL); + Theme::set_project_default(nullptr); + Theme::set_default(nullptr); + Theme::set_default_icon(nullptr); + Theme::set_default_style(nullptr); + Theme::set_default_font(nullptr); } diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py index cf0ccf1c3a..efad3b2815 100755 --- a/scene/resources/default_theme/make_header.py +++ b/scene/resources/default_theme/make_header.py @@ -13,7 +13,7 @@ os.chdir(os.path.dirname(os.path.realpath(__file__))) f = open("theme_data.h", "wb") -f.write(b"// THIS FILE HAS BEEN AUTOGENERATED, DON\'T EDIT!!\n") +f.write(b"// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!\n") # Generate png image block f.write(b"\n// png image block\n") @@ -31,17 +31,17 @@ for x in pixmaps: pngf = open(x, "rb") b = pngf.read(1) - while(len(b) == 1): + while len(b) == 1: f.write(hex(ord(b)).encode(enc)) b = pngf.read(1) - if (len(b) == 1): + if len(b) == 1: f.write(b", ") f.write(b"\n};\n") pngf.close() # Generate shaders block -f.write(b"\n// shaders block\n"); +f.write(b"\n// shaders block\n") shaders = glob.glob("*.gsl") shaders.sort() @@ -56,15 +56,15 @@ for x in shaders: sf = open(x, "rb") b = sf.readline() - while(b != ""): - if (b.endswith("\r\n")): + while b != "": + if b.endswith("\r\n"): b = b[:-2] - if (b.endswith("\n")): + if b.endswith("\n"): b = b[:-1] - s = ' \"' + b + s = ' "' + b f.write(s.encode(enc)) b = sf.readline() - if (b != ""): + if b != "": f.write(b'"\n') f.write(b'";\n') diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 410c4990a2..a613b01376 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -107,7 +107,7 @@ DynamicFontData::DynamicFontData() { antialiased = true; force_autohinter = false; hinting = DynamicFontData::HINTING_NORMAL; - font_mem = NULL; + font_mem = nullptr; font_mem_size = 0; } @@ -124,7 +124,7 @@ Error DynamicFontAtSize::_load() { ERR_FAIL_COND_V_MSG(error != 0, ERR_CANT_CREATE, "Error initializing FreeType."); // FT_OPEN_STREAM is extremely slow only on Android. - if (OS::get_singleton()->get_name() == "Android" && font->font_mem == NULL && font->font_path != String()) { + if (OS::get_singleton()->get_name() == "Android" && font->font_mem == nullptr && font->font_path != String()) { // cache font only once for each font->font_path if (_fontdata.has(font->font_path)) { @@ -148,7 +148,7 @@ Error DynamicFontAtSize::_load() { } } - if (font->font_mem == NULL && font->font_path != String()) { + if (font->font_mem == nullptr && font->font_path != String()) { FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); if (!f) { @@ -157,7 +157,7 @@ Error DynamicFontAtSize::_load() { } memset(&stream, 0, sizeof(FT_StreamRec)); - stream.base = NULL; + stream.base = nullptr; stream.size = f->get_len(); stream.pos = 0; stream.descriptor.pointer = f; @@ -245,7 +245,7 @@ float DynamicFontAtSize::get_descent() const { const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFontAtSize::_find_char_with_font(CharType p_char, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const { const Character *chr = char_map.getptr(p_char); - ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(NULL, NULL))); + ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(nullptr, nullptr))); if (!chr->found) { @@ -269,7 +269,7 @@ const Pair<const DynamicFontAtSize::Character *, DynamicFontAtSize *> DynamicFon //not found, try 0xFFFD to display 'not found'. const_cast<DynamicFontAtSize *>(this)->_update_char(0xFFFD); chr = char_map.getptr(0xFFFD); - ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(NULL, NULL))); + ERR_FAIL_COND_V(!chr, (Pair<const Character *, DynamicFontAtSize *>(nullptr, nullptr))); } return Pair<const Character *, DynamicFontAtSize *>(chr, const_cast<DynamicFontAtSize *>(this)); @@ -336,7 +336,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT modulate.r = modulate.g = modulate.b = 1.0; } RID texture = font->textures[ch->texture_idx].texture->get_rid(); - VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false); } advance = ch->advance; @@ -565,7 +565,7 @@ DynamicFontAtSize::Character DynamicFontAtSize::_make_outline_char(CharType p_ch goto cleanup_stroker; if (FT_Glyph_Stroke(&glyph, stroker, 1) != 0) goto cleanup_glyph; - if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1) != 0) + if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1) != 0) goto cleanup_glyph; glyph_bitmap = (FT_BitmapGlyph)glyph; @@ -992,11 +992,12 @@ void DynamicFont::_bind_methods() { Mutex DynamicFont::dynamic_font_mutex; -SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = NULL; +SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = nullptr; DynamicFont::DynamicFont() : font_list(this) { + valid = false; cache_id.size = 16; outline_cache_id.size = 16; spacing_top = 0; @@ -1020,7 +1021,7 @@ void DynamicFont::initialize_dynamic_fonts() { void DynamicFont::finish_dynamic_fonts() { memdelete(dynamic_fonts); - dynamic_fonts = NULL; + dynamic_fonts = nullptr; } void DynamicFont::update_oversampling() { diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 88b1df039e..9e628fc35a 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -302,7 +302,7 @@ VARIANT_ENUM_CAST(DynamicFont::SpacingType); class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index d407dd3722..835fef81e1 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -30,7 +30,7 @@ #include "environment.h" #include "core/project_settings.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #include "texture.h" RID Environment::get_rid() const { @@ -41,7 +41,7 @@ RID Environment::get_rid() const { void Environment::set_background(BGMode p_bg) { bg_mode = p_bg; - VS::get_singleton()->environment_set_background(environment, VS::EnvironmentBG(p_bg)); + RS::get_singleton()->environment_set_background(environment, RS::EnvironmentBG(p_bg)); _change_notify(); } @@ -53,56 +53,56 @@ void Environment::set_sky(const Ref<Sky> &p_sky) { if (bg_sky.is_valid()) sb_rid = bg_sky->get_rid(); - VS::get_singleton()->environment_set_sky(environment, sb_rid); + RS::get_singleton()->environment_set_sky(environment, sb_rid); } void Environment::set_sky_custom_fov(float p_scale) { bg_sky_custom_fov = p_scale; - VS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale); + RS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale); } void Environment::set_bg_color(const Color &p_color) { bg_color = p_color; - VS::get_singleton()->environment_set_bg_color(environment, p_color); + RS::get_singleton()->environment_set_bg_color(environment, p_color); } void Environment::set_bg_energy(float p_energy) { bg_energy = p_energy; - VS::get_singleton()->environment_set_bg_energy(environment, p_energy); + RS::get_singleton()->environment_set_bg_energy(environment, p_energy); } void Environment::set_canvas_max_layer(int p_max_layer) { bg_canvas_max_layer = p_max_layer; - VS::get_singleton()->environment_set_canvas_max_layer(environment, p_max_layer); + RS::get_singleton()->environment_set_canvas_max_layer(environment, p_max_layer); } void Environment::set_ambient_light_color(const Color &p_color) { ambient_color = p_color; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color); + RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color); } void Environment::set_ambient_light_energy(float p_energy) { ambient_energy = p_energy; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color); + RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color); } void Environment::set_ambient_light_sky_contribution(float p_energy) { ambient_sky_contribution = p_energy; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color); + RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color); } void Environment::set_camera_feed_id(int p_camera_feed_id) { camera_feed_id = p_camera_feed_id; // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 - VS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id); + RS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id); #endif }; void Environment::set_ambient_source(AmbientSource p_source) { ambient_source = p_source; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color); + RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color); } Environment::AmbientSource Environment::get_ambient_source() const { @@ -110,7 +110,7 @@ Environment::AmbientSource Environment::get_ambient_source() const { } void Environment::set_reflection_source(ReflectionSource p_source) { reflection_source = p_source; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color); + RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color); } Environment::ReflectionSource Environment::get_reflection_source() const { return reflection_source; @@ -132,7 +132,7 @@ float Environment::get_sky_custom_fov() const { void Environment::set_sky_rotation(const Vector3 &p_rotation) { sky_rotation = p_rotation; - VS::get_singleton()->environment_set_sky_orientation(environment, Basis(p_rotation)); + RS::get_singleton()->environment_set_sky_orientation(environment, Basis(p_rotation)); } Vector3 Environment::get_sky_rotation() const { @@ -172,7 +172,7 @@ int Environment::get_camera_feed_id(void) const { void Environment::set_tonemapper(ToneMapper p_tone_mapper) { tone_mapper = p_tone_mapper; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } Environment::ToneMapper Environment::get_tonemapper() const { @@ -183,7 +183,7 @@ Environment::ToneMapper Environment::get_tonemapper() const { void Environment::set_tonemap_exposure(float p_exposure) { tonemap_exposure = p_exposure; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } float Environment::get_tonemap_exposure() const { @@ -194,7 +194,7 @@ float Environment::get_tonemap_exposure() const { void Environment::set_tonemap_white(float p_white) { tonemap_white = p_white; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } float Environment::get_tonemap_white() const { @@ -204,7 +204,7 @@ float Environment::get_tonemap_white() const { void Environment::set_tonemap_auto_exposure(bool p_enabled) { tonemap_auto_exposure = p_enabled; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); _change_notify(); } bool Environment::get_tonemap_auto_exposure() const { @@ -215,7 +215,7 @@ bool Environment::get_tonemap_auto_exposure() const { void Environment::set_tonemap_auto_exposure_max(float p_auto_exposure_max) { tonemap_auto_exposure_max = p_auto_exposure_max; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } float Environment::get_tonemap_auto_exposure_max() const { @@ -225,7 +225,7 @@ float Environment::get_tonemap_auto_exposure_max() const { void Environment::set_tonemap_auto_exposure_min(float p_auto_exposure_min) { tonemap_auto_exposure_min = p_auto_exposure_min; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } float Environment::get_tonemap_auto_exposure_min() const { @@ -235,7 +235,7 @@ float Environment::get_tonemap_auto_exposure_min() const { void Environment::set_tonemap_auto_exposure_speed(float p_auto_exposure_speed) { tonemap_auto_exposure_speed = p_auto_exposure_speed; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } float Environment::get_tonemap_auto_exposure_speed() const { @@ -245,7 +245,7 @@ float Environment::get_tonemap_auto_exposure_speed() const { void Environment::set_tonemap_auto_exposure_grey(float p_auto_exposure_grey) { tonemap_auto_exposure_grey = p_auto_exposure_grey; - VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); + RS::get_singleton()->environment_set_tonemap(environment, RS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey); } float Environment::get_tonemap_auto_exposure_grey() const { @@ -255,7 +255,7 @@ float Environment::get_tonemap_auto_exposure_grey() const { void Environment::set_adjustment_enable(bool p_enable) { adjustment_enabled = p_enable; - VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); + RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); _change_notify(); } @@ -267,7 +267,7 @@ bool Environment::is_adjustment_enabled() const { void Environment::set_adjustment_brightness(float p_brightness) { adjustment_brightness = p_brightness; - VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); + RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); } float Environment::get_adjustment_brightness() const { @@ -277,7 +277,7 @@ float Environment::get_adjustment_brightness() const { void Environment::set_adjustment_contrast(float p_contrast) { adjustment_contrast = p_contrast; - VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); + RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); } float Environment::get_adjustment_contrast() const { @@ -287,7 +287,7 @@ float Environment::get_adjustment_contrast() const { void Environment::set_adjustment_saturation(float p_saturation) { adjustment_saturation = p_saturation; - VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); + RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); } float Environment::get_adjustment_saturation() const { @@ -297,7 +297,7 @@ float Environment::get_adjustment_saturation() const { void Environment::set_adjustment_color_correction(const Ref<Texture2D> &p_ramp) { adjustment_color_correction = p_ramp; - VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); + RS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID()); } Ref<Texture2D> Environment::get_adjustment_color_correction() const { @@ -345,7 +345,7 @@ void Environment::_validate_property(PropertyInfo &property) const { "ssao_", "glow_", "adjustment_", - NULL + nullptr }; @@ -354,7 +354,7 @@ void Environment::_validate_property(PropertyInfo &property) const { "tonemap_", "ss_reflections_", "ssao_", - NULL + nullptr }; @@ -371,7 +371,7 @@ void Environment::_validate_property(PropertyInfo &property) const { prefixes++; } - if (VisualServer::get_singleton()->is_low_end()) { + if (RenderingServer::get_singleton()->is_low_end()) { prefixes = high_end_prefixes; while (*prefixes) { String prefix = String(*prefixes); @@ -389,7 +389,7 @@ void Environment::_validate_property(PropertyInfo &property) const { void Environment::set_ssr_enabled(bool p_enable) { ssr_enabled = p_enable; - VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); _change_notify(); } @@ -401,7 +401,7 @@ bool Environment::is_ssr_enabled() const { void Environment::set_ssr_max_steps(int p_steps) { ssr_max_steps = p_steps; - VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } int Environment::get_ssr_max_steps() const { @@ -411,7 +411,7 @@ int Environment::get_ssr_max_steps() const { void Environment::set_ssr_fade_in(float p_fade_in) { ssr_fade_in = p_fade_in; - VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } float Environment::get_ssr_fade_in() const { @@ -421,7 +421,7 @@ float Environment::get_ssr_fade_in() const { void Environment::set_ssr_fade_out(float p_fade_out) { ssr_fade_out = p_fade_out; - VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } float Environment::get_ssr_fade_out() const { @@ -431,27 +431,17 @@ float Environment::get_ssr_fade_out() const { void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) { ssr_depth_tolerance = p_depth_tolerance; - VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); + RS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance); } float Environment::get_ssr_depth_tolerance() const { return ssr_depth_tolerance; } -void Environment::set_ssr_rough(bool p_enable) { - - ssr_roughness = p_enable; - VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness); -} -bool Environment::is_ssr_rough() const { - - return ssr_roughness; -} - void Environment::set_ssao_enabled(bool p_enable) { ssao_enabled = p_enable; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); _change_notify(); } @@ -463,7 +453,7 @@ bool Environment::is_ssao_enabled() const { void Environment::set_ssao_radius(float p_radius) { ssao_radius = p_radius; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_radius() const { @@ -473,7 +463,7 @@ float Environment::get_ssao_radius() const { void Environment::set_ssao_intensity(float p_intensity) { ssao_intensity = p_intensity; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_intensity() const { @@ -484,7 +474,7 @@ float Environment::get_ssao_intensity() const { void Environment::set_ssao_bias(float p_bias) { ssao_bias = p_bias; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_bias() const { @@ -494,7 +484,7 @@ float Environment::get_ssao_bias() const { void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) { ssao_direct_light_affect = p_direct_light_affect; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_direct_light_affect() const { @@ -504,7 +494,7 @@ float Environment::get_ssao_direct_light_affect() const { void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) { ssao_ao_channel_affect = p_ao_channel_affect; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_ao_channel_affect() const { @@ -514,7 +504,7 @@ float Environment::get_ssao_ao_channel_affect() const { void Environment::set_ao_color(const Color &p_color) { ao_color = p_color; - VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, VS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, VS::EnvironmentReflectionSource(reflection_source), ao_color); + RS::get_singleton()->environment_set_ambient_light(environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), ao_color); } Color Environment::get_ao_color() const { @@ -525,7 +515,7 @@ Color Environment::get_ao_color() const { void Environment::set_ssao_blur(SSAOBlur p_blur) { ssao_blur = p_blur; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } Environment::SSAOBlur Environment::get_ssao_blur() const { @@ -535,7 +525,7 @@ Environment::SSAOBlur Environment::get_ssao_blur() const { void Environment::set_ssao_edge_sharpness(float p_edge_sharpness) { ssao_edge_sharpness = p_edge_sharpness; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); + RS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, RS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_edge_sharpness() const { @@ -546,7 +536,7 @@ float Environment::get_ssao_edge_sharpness() const { void Environment::set_glow_enabled(bool p_enabled) { glow_enabled = p_enabled; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); _change_notify(); } @@ -557,18 +547,18 @@ bool Environment::is_glow_enabled() const { void Environment::set_glow_level(int p_level, bool p_enabled) { - ERR_FAIL_INDEX(p_level, VS::MAX_GLOW_LEVELS); + ERR_FAIL_INDEX(p_level, RS::MAX_GLOW_LEVELS); if (p_enabled) glow_levels |= (1 << p_level); else glow_levels &= ~(1 << p_level); - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } bool Environment::is_glow_level_enabled(int p_level) const { - ERR_FAIL_INDEX_V(p_level, VS::MAX_GLOW_LEVELS, false); + ERR_FAIL_INDEX_V(p_level, RS::MAX_GLOW_LEVELS, false); return glow_levels & (1 << p_level); } @@ -577,7 +567,7 @@ void Environment::set_glow_intensity(float p_intensity) { glow_intensity = p_intensity; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_intensity() const { @@ -587,7 +577,7 @@ float Environment::get_glow_intensity() const { void Environment::set_glow_strength(float p_strength) { glow_strength = p_strength; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_strength() const { @@ -597,7 +587,7 @@ float Environment::get_glow_strength() const { void Environment::set_glow_mix(float p_mix) { glow_mix = p_mix; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_mix() const { @@ -608,7 +598,7 @@ void Environment::set_glow_bloom(float p_threshold) { glow_bloom = p_threshold; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_bloom() const { @@ -619,7 +609,7 @@ void Environment::set_glow_blend_mode(GlowBlendMode p_mode) { glow_blend_mode = p_mode; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); _change_notify(); } Environment::GlowBlendMode Environment::get_glow_blend_mode() const { @@ -631,7 +621,7 @@ void Environment::set_glow_hdr_bleed_threshold(float p_threshold) { glow_hdr_bleed_threshold = p_threshold; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_hdr_bleed_threshold() const { @@ -642,7 +632,7 @@ void Environment::set_glow_hdr_luminance_cap(float p_amount) { glow_hdr_luminance_cap = p_amount; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_hdr_luminance_cap() const { @@ -653,28 +643,17 @@ void Environment::set_glow_hdr_bleed_scale(float p_scale) { glow_hdr_bleed_scale = p_scale; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); + RS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, RS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap); } float Environment::get_glow_hdr_bleed_scale() const { return glow_hdr_bleed_scale; } -void Environment::set_glow_bicubic_upscale(bool p_enable) { - - glow_bicubic_upscale = p_enable; - VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_mix, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_threshold, glow_hdr_luminance_cap, glow_bicubic_upscale); -} - -bool Environment::is_glow_bicubic_upscale_enabled() const { - - return glow_bicubic_upscale; -} - void Environment::set_fog_enabled(bool p_enabled) { fog_enabled = p_enabled; - VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); + RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); _change_notify(); } @@ -686,7 +665,7 @@ bool Environment::is_fog_enabled() const { void Environment::set_fog_color(const Color &p_color) { fog_color = p_color; - VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); + RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); } Color Environment::get_fog_color() const { @@ -696,7 +675,7 @@ Color Environment::get_fog_color() const { void Environment::set_fog_sun_color(const Color &p_color) { fog_sun_color = p_color; - VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); + RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); } Color Environment::get_fog_sun_color() const { @@ -706,7 +685,7 @@ Color Environment::get_fog_sun_color() const { void Environment::set_fog_sun_amount(float p_amount) { fog_sun_amount = p_amount; - VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); + RS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount); } float Environment::get_fog_sun_amount() const { @@ -716,7 +695,7 @@ float Environment::get_fog_sun_amount() const { void Environment::set_fog_depth_enabled(bool p_enabled) { fog_depth_enabled = p_enabled; - VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); + RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); } bool Environment::is_fog_depth_enabled() const { @@ -726,7 +705,7 @@ bool Environment::is_fog_depth_enabled() const { void Environment::set_fog_depth_begin(float p_distance) { fog_depth_begin = p_distance; - VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); + RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); } float Environment::get_fog_depth_begin() const { @@ -736,7 +715,7 @@ float Environment::get_fog_depth_begin() const { void Environment::set_fog_depth_end(float p_distance) { fog_depth_end = p_distance; - VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); + RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); } float Environment::get_fog_depth_end() const { @@ -747,7 +726,7 @@ float Environment::get_fog_depth_end() const { void Environment::set_fog_depth_curve(float p_curve) { fog_depth_curve = p_curve; - VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); + RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); } float Environment::get_fog_depth_curve() const { @@ -757,7 +736,7 @@ float Environment::get_fog_depth_curve() const { void Environment::set_fog_transmit_enabled(bool p_enabled) { fog_transmit_enabled = p_enabled; - VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); + RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); } bool Environment::is_fog_transmit_enabled() const { @@ -767,7 +746,7 @@ bool Environment::is_fog_transmit_enabled() const { void Environment::set_fog_transmit_curve(float p_curve) { fog_transmit_curve = p_curve; - VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); + RS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve); } float Environment::get_fog_transmit_curve() const { @@ -777,7 +756,7 @@ float Environment::get_fog_transmit_curve() const { void Environment::set_fog_height_enabled(bool p_enabled) { fog_height_enabled = p_enabled; - VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); + RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); } bool Environment::is_fog_height_enabled() const { @@ -787,7 +766,7 @@ bool Environment::is_fog_height_enabled() const { void Environment::set_fog_height_min(float p_distance) { fog_height_min = p_distance; - VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); + RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); } float Environment::get_fog_height_min() const { @@ -797,7 +776,7 @@ float Environment::get_fog_height_min() const { void Environment::set_fog_height_max(float p_distance) { fog_height_max = p_distance; - VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); + RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); } float Environment::get_fog_height_max() const { @@ -807,7 +786,7 @@ float Environment::get_fog_height_max() const { void Environment::set_fog_height_curve(float p_distance) { fog_height_curve = p_distance; - VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); + RS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve); } float Environment::get_fog_height_curve() const { @@ -992,16 +971,12 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_ssr_depth_tolerance", "depth_tolerance"), &Environment::set_ssr_depth_tolerance); ClassDB::bind_method(D_METHOD("get_ssr_depth_tolerance"), &Environment::get_ssr_depth_tolerance); - ClassDB::bind_method(D_METHOD("set_ssr_rough", "rough"), &Environment::set_ssr_rough); - ClassDB::bind_method(D_METHOD("is_ssr_rough"), &Environment::is_ssr_rough); - ADD_GROUP("SS Reflections", "ss_reflections_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ss_reflections_enabled"), "set_ssr_enabled", "is_ssr_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "ss_reflections_max_steps", PROPERTY_HINT_RANGE, "1,512,1"), "set_ssr_max_steps", "get_ssr_max_steps"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_fade_in", PROPERTY_HINT_EXP_EASING), "set_ssr_fade_in", "get_ssr_fade_in"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_fade_out", PROPERTY_HINT_EXP_EASING), "set_ssr_fade_out", "get_ssr_fade_out"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_depth_tolerance", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_ssr_depth_tolerance", "get_ssr_depth_tolerance"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ss_reflections_roughness"), "set_ssr_rough", "is_ssr_rough"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ss_reflections_depth_tolerance", PROPERTY_HINT_RANGE, "0.01,128,0.1"), "set_ssr_depth_tolerance", "get_ssr_depth_tolerance"); ClassDB::bind_method(D_METHOD("set_ssao_enabled", "enabled"), &Environment::set_ssao_enabled); ClassDB::bind_method(D_METHOD("is_ssao_enabled"), &Environment::is_ssao_enabled); @@ -1067,9 +1042,6 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_scale", "scale"), &Environment::set_glow_hdr_bleed_scale); ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_scale"), &Environment::get_glow_hdr_bleed_scale); - ClassDB::bind_method(D_METHOD("set_glow_bicubic_upscale", "enabled"), &Environment::set_glow_bicubic_upscale); - ClassDB::bind_method(D_METHOD("is_glow_bicubic_upscale_enabled"), &Environment::is_glow_bicubic_upscale_enabled); - ADD_GROUP("Glow", "glow_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_enabled"), "set_glow_enabled", "is_glow_enabled"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/1"), "set_glow_level", "is_glow_level_enabled", 0); @@ -1088,7 +1060,6 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_hdr_threshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_threshold", "get_glow_hdr_bleed_threshold"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_hdr_luminance_cap", PROPERTY_HINT_RANGE, "0.0,256.0,0.01"), "set_glow_hdr_luminance_cap", "get_glow_hdr_luminance_cap"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_hdr_scale", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_scale", "get_glow_hdr_bleed_scale"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_bicubic_upscale"), "set_glow_bicubic_upscale", "is_glow_bicubic_upscale_enabled"); ClassDB::bind_method(D_METHOD("set_adjustment_enable", "enabled"), &Environment::set_adjustment_enable); ClassDB::bind_method(D_METHOD("is_adjustment_enabled"), &Environment::is_adjustment_enabled); @@ -1152,7 +1123,7 @@ Environment::Environment() : ssao_blur(SSAO_BLUR_3x3), glow_blend_mode(GLOW_BLEND_MODE_ADDITIVE) { - environment = VS::get_singleton()->environment_create(); + environment = RS::get_singleton()->environment_create(); bg_mode = BG_CLEAR_COLOR; bg_sky_custom_fov = 0; @@ -1188,7 +1159,6 @@ Environment::Environment() : ssr_fade_in = 0.15; ssr_fade_out = 2.0; ssr_depth_tolerance = 0.2; - ssr_roughness = true; ssao_enabled = false; ssao_radius = 1; @@ -1209,7 +1179,6 @@ Environment::Environment() : glow_hdr_bleed_threshold = 1.0; glow_hdr_luminance_cap = 12.0; glow_hdr_bleed_scale = 2.0; - glow_bicubic_upscale = false; fog_enabled = false; fog_color = Color(0.5, 0.5, 0.5); @@ -1236,7 +1205,7 @@ Environment::Environment() : Environment::~Environment() { - VS::get_singleton()->free(environment); + RS::get_singleton()->free(environment); } ////////////////////// @@ -1244,7 +1213,7 @@ Environment::~Environment() { void CameraEffects::set_dof_blur_far_enabled(bool p_enable) { dof_blur_far_enabled = p_enable; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); } bool CameraEffects::is_dof_blur_far_enabled() const { @@ -1255,7 +1224,7 @@ bool CameraEffects::is_dof_blur_far_enabled() const { void CameraEffects::set_dof_blur_far_distance(float p_distance) { dof_blur_far_distance = p_distance; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); } float CameraEffects::get_dof_blur_far_distance() const { @@ -1265,7 +1234,7 @@ float CameraEffects::get_dof_blur_far_distance() const { void CameraEffects::set_dof_blur_far_transition(float p_distance) { dof_blur_far_transition = p_distance; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); } float CameraEffects::get_dof_blur_far_transition() const { @@ -1275,7 +1244,7 @@ float CameraEffects::get_dof_blur_far_transition() const { void CameraEffects::set_dof_blur_near_enabled(bool p_enable) { dof_blur_near_enabled = p_enable; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); _change_notify(); } @@ -1287,7 +1256,7 @@ bool CameraEffects::is_dof_blur_near_enabled() const { void CameraEffects::set_dof_blur_near_distance(float p_distance) { dof_blur_near_distance = p_distance; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); } float CameraEffects::get_dof_blur_near_distance() const { @@ -1298,7 +1267,7 @@ float CameraEffects::get_dof_blur_near_distance() const { void CameraEffects::set_dof_blur_near_transition(float p_distance) { dof_blur_near_transition = p_distance; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); } float CameraEffects::get_dof_blur_near_transition() const { @@ -1309,7 +1278,7 @@ float CameraEffects::get_dof_blur_near_transition() const { void CameraEffects::set_dof_blur_amount(float p_amount) { dof_blur_amount = p_amount; - VS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); + RS::get_singleton()->camera_effects_set_dof_blur(camera_effects, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_amount); } float CameraEffects::get_dof_blur_amount() const { @@ -1318,7 +1287,7 @@ float CameraEffects::get_dof_blur_amount() const { void CameraEffects::set_override_exposure_enabled(bool p_enabled) { override_exposure_enabled = p_enabled; - VS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure); + RS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure); } bool CameraEffects::is_override_exposure_enabled() const { @@ -1327,7 +1296,7 @@ bool CameraEffects::is_override_exposure_enabled() const { void CameraEffects::set_override_exposure(float p_exposure) { override_exposure = p_exposure; - VS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure); + RS::get_singleton()->camera_effects_set_custom_exposure(camera_effects, override_exposure_enabled, override_exposure); } float CameraEffects::get_override_exposure() const { @@ -1382,7 +1351,7 @@ void CameraEffects::_bind_methods() { CameraEffects::CameraEffects() { - camera_effects = VS::get_singleton()->camera_effects_create(); + camera_effects = RS::get_singleton()->camera_effects_create(); dof_blur_far_enabled = false; dof_blur_far_distance = 10; @@ -1400,5 +1369,5 @@ CameraEffects::CameraEffects() { CameraEffects::~CameraEffects() { - VS::get_singleton()->free(camera_effects); + RS::get_singleton()->free(camera_effects); } diff --git a/scene/resources/environment.h b/scene/resources/environment.h index f9fe26f792..02434bc592 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -34,7 +34,7 @@ #include "core/resource.h" #include "scene/resources/sky.h" #include "scene/resources/texture.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class Environment : public Resource { @@ -125,7 +125,6 @@ private: float ssr_fade_in; float ssr_fade_out; float ssr_depth_tolerance; - bool ssr_roughness; bool ssao_enabled; float ssao_radius; @@ -146,7 +145,6 @@ private: float glow_hdr_bleed_threshold; float glow_hdr_bleed_scale; float glow_hdr_luminance_cap; - bool glow_bicubic_upscale; bool fog_enabled; Color fog_color; @@ -258,9 +256,6 @@ public: void set_ssr_depth_tolerance(float p_depth_tolerance); float get_ssr_depth_tolerance() const; - void set_ssr_rough(bool p_enable); - bool is_ssr_rough() const; - void set_ssao_enabled(bool p_enable); bool is_ssao_enabled() const; @@ -318,9 +313,6 @@ public: void set_glow_hdr_bleed_scale(float p_scale); float get_glow_hdr_bleed_scale() const; - void set_glow_bicubic_upscale(bool p_enable); - bool is_glow_bicubic_upscale_enabled() const; - void set_fog_enabled(bool p_enabled); bool is_fog_enabled() const; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 1f5e4b647a..192eefbf6a 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -128,7 +128,7 @@ Vector<int> BitmapFont::_get_chars() const { Vector<int> chars; - const CharType *key = NULL; + const CharType *key = nullptr; while ((key = char_map.next(key))) { @@ -382,7 +382,7 @@ Vector<CharType> BitmapFont::get_char_keys() const { Vector<CharType> chars; chars.resize(char_map.size()); - const CharType *ct = NULL; + const CharType *ct = nullptr; int count = 0; while ((ct = char_map.next(ct))) { @@ -528,7 +528,7 @@ Size2 Font::get_wordwrap_string_size(const String &p_string, float p_width) cons void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) { - for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != NULL; fallback_child = fallback_child->get_fallback()) { + for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != nullptr; fallback_child = fallback_child->get_fallback()) { ERR_FAIL_COND_MSG(fallback_child == this, "Can't set as fallback one of its parents to prevent crashes due to recursive loop."); } @@ -556,7 +556,7 @@ float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_c cpos.x += c->h_align; cpos.y -= ascent; cpos.y += c->v_align; - VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), RID(), Color(1, 1, 1, 1), false); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), RID(), Color(1, 1, 1, 1), false); } return get_char_size(p_char, p_next).width; diff --git a/scene/resources/font.h b/scene/resources/font.h index 076532f390..ce75f27e2a 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -200,7 +200,7 @@ public: class ResourceFormatLoaderBMFont : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/height_map_shape_3d.cpp b/scene/resources/height_map_shape_3d.cpp index 85c081238d..33b6063299 100644 --- a/scene/resources/height_map_shape_3d.cpp +++ b/scene/resources/height_map_shape_3d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "height_map_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> HeightMapShape3D::get_debug_mesh_lines() { Vector<Vector3> points; @@ -88,7 +88,7 @@ void HeightMapShape3D::_update_shape() { d["heights"] = map_data; d["min_height"] = min_height; d["max_height"] = max_height; - PhysicsServer::get_singleton()->shape_set_data(get_shape(), d); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d); Shape3D::_update_shape(); } @@ -192,7 +192,7 @@ void HeightMapShape3D::_bind_methods() { } HeightMapShape3D::HeightMapShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_HEIGHTMAP)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_HEIGHTMAP)) { map_width = 2; map_depth = 2; diff --git a/scene/resources/line_shape_2d.cpp b/scene/resources/line_shape_2d.cpp index 3b30b4528a..a1c1b2f9f4 100644 --- a/scene/resources/line_shape_2d.cpp +++ b/scene/resources/line_shape_2d.cpp @@ -30,8 +30,8 @@ #include "line_shape_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" bool LineShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { @@ -52,7 +52,7 @@ void LineShape2D::_update_shape() { Array arr; arr.push_back(normal); arr.push_back(d); - Physics2DServer::get_singleton()->shape_set_data(get_rid(), arr); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), arr); emit_changed(); } @@ -82,9 +82,9 @@ void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) { Vector2 point = get_d() * get_normal(); Vector2 l1[2] = { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 }; - VS::get_singleton()->canvas_item_add_line(p_to_rid, l1[0], l1[1], p_color, 3); + RS::get_singleton()->canvas_item_add_line(p_to_rid, l1[0], l1[1], p_color, 3); Vector2 l2[2] = { point, point + get_normal() * 30 }; - VS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3); + RS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3); } Rect2 LineShape2D::get_rect() const { @@ -117,7 +117,7 @@ void LineShape2D::_bind_methods() { } LineShape2D::LineShape2D() : - Shape2D(Physics2DServer::get_singleton()->line_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->line_shape_create()) { normal = Vector2(0, 1); d = 0; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index d387a39dbe..84c1c9d734 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -40,7 +40,7 @@ void Material::set_next_pass(const Ref<Material> &p_pass) { - for (Ref<Material> pass_child = p_pass; pass_child != NULL; pass_child = pass_child->get_next_pass()) { + for (Ref<Material> pass_child = p_pass; pass_child != nullptr; pass_child = pass_child->get_next_pass()) { ERR_FAIL_COND_MSG(pass_child == this, "Can't set as next_pass one of its parents to prevent crashes due to recursive loop."); } @@ -51,7 +51,7 @@ void Material::set_next_pass(const Ref<Material> &p_pass) { RID next_pass_rid; if (next_pass.is_valid()) next_pass_rid = next_pass->get_rid(); - VS::get_singleton()->material_set_next_pass(material, next_pass_rid); + RS::get_singleton()->material_set_next_pass(material, next_pass_rid); } Ref<Material> Material::get_next_pass() const { @@ -64,7 +64,7 @@ void Material::set_render_priority(int p_priority) { ERR_FAIL_COND(p_priority < RENDER_PRIORITY_MIN); ERR_FAIL_COND(p_priority > RENDER_PRIORITY_MAX); render_priority = p_priority; - VS::get_singleton()->material_set_render_priority(material, p_priority); + RS::get_singleton()->material_set_render_priority(material, p_priority); } int Material::get_render_priority() const { @@ -100,13 +100,13 @@ void Material::_bind_methods() { Material::Material() { - material = VisualServer::get_singleton()->material_create(); + material = RenderingServer::get_singleton()->material_create(); render_priority = 0; } Material::~Material() { - VisualServer::get_singleton()->free(material); + RenderingServer::get_singleton()->free(material); } /////////////////////////////////// @@ -126,7 +126,7 @@ bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) { } } if (pr) { - VisualServer::get_singleton()->material_set_param(_get_material(), pr, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), pr, p_value); return true; } } @@ -150,7 +150,7 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const { } if (pr) { - r_ret = VisualServer::get_singleton()->material_get_param(_get_material(), pr); + r_ret = RenderingServer::get_singleton()->material_get_param(_get_material(), pr); return true; } } @@ -171,7 +171,7 @@ bool ShaderMaterial::property_can_revert(const String &p_name) { StringName pr = shader->remap_param(p_name); if (pr) { - Variant default_value = VisualServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr); + Variant default_value = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr); Variant current_value; _get(p_name, current_value); return default_value.get_type() != Variant::NIL && default_value != current_value; @@ -185,7 +185,7 @@ Variant ShaderMaterial::property_get_revert(const String &p_name) { if (shader.is_valid()) { StringName pr = shader->remap_param(p_name); if (pr) { - r_ret = VisualServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr); + r_ret = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr); } } return r_ret; @@ -211,7 +211,7 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) { } } - VS::get_singleton()->material_set_shader(_get_material(), rid); + RS::get_singleton()->material_set_shader(_get_material(), rid); _change_notify(); //properties for shader exposed emit_changed(); } @@ -223,12 +223,12 @@ Ref<Shader> ShaderMaterial::get_shader() const { void ShaderMaterial::set_shader_param(const StringName &p_param, const Variant &p_value) { - VS::get_singleton()->material_set_param(_get_material(), p_param, p_value); + RS::get_singleton()->material_set_param(_get_material(), p_param, p_value); } Variant ShaderMaterial::get_shader_param(const StringName &p_param) const { - return VS::get_singleton()->material_get_param(_get_material(), p_param); + return RS::get_singleton()->material_get_param(_get_material(), p_param); } void ShaderMaterial::_shader_changed() { @@ -290,9 +290,9 @@ ShaderMaterial::~ShaderMaterial() { ///////////////////////////////// Mutex BaseMaterial3D::material_mutex; -SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = NULL; +SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = nullptr; Map<BaseMaterial3D::MaterialKey, BaseMaterial3D::ShaderData> BaseMaterial3D::shader_map; -BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = NULL; +BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = nullptr; void BaseMaterial3D::init_shaders() { @@ -375,7 +375,7 @@ void BaseMaterial3D::finish_shaders() { } memdelete(dirty_materials); - dirty_materials = NULL; + dirty_materials = nullptr; memdelete(shader_names); } @@ -392,7 +392,7 @@ void BaseMaterial3D::_update_shader() { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { //deallocate shader, as it's no longer in use - VS::get_singleton()->free(shader_map[current_key].shader); + RS::get_singleton()->free(shader_map[current_key].shader); shader_map.erase(current_key); } } @@ -401,7 +401,7 @@ void BaseMaterial3D::_update_shader() { if (shader_map.has(mk)) { - VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader); + RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader); shader_map[mk].users++; return; } @@ -773,7 +773,7 @@ void BaseMaterial3D::_update_shader() { code += "\tvec2 base_uv2 = UV2;\n"; } - if (!VisualServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar + if (!RenderingServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar code += "\t{\n"; code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-) @@ -953,7 +953,7 @@ void BaseMaterial3D::_update_shader() { if (distance_fade != DISTANCE_FADE_DISABLED) { if ((distance_fade == DISTANCE_FADE_OBJECT_DITHER || distance_fade == DISTANCE_FADE_PIXEL_DITHER)) { - if (!VisualServer::get_singleton()->is_low_end()) { + if (!RenderingServer::get_singleton()->is_low_end()) { code += "\t{\n"; if (distance_fade == DISTANCE_FADE_OBJECT_DITHER) { code += "\t\tfloat fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);\n"; @@ -1112,14 +1112,14 @@ void BaseMaterial3D::_update_shader() { code += "}\n"; ShaderData shader_data; - shader_data.shader = VS::get_singleton()->shader_create(); + shader_data.shader = RS::get_singleton()->shader_create(); shader_data.users = 1; - VS::get_singleton()->shader_set_code(shader_data.shader, code); + RS::get_singleton()->shader_set_code(shader_data.shader, code); shader_map[mk] = shader_data; - VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); + RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); } void BaseMaterial3D::flush_changes() { @@ -1151,7 +1151,7 @@ void BaseMaterial3D::set_albedo(const Color &p_albedo) { albedo = p_albedo; - VS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo); + RS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo); } Color BaseMaterial3D::get_albedo() const { @@ -1162,7 +1162,7 @@ Color BaseMaterial3D::get_albedo() const { void BaseMaterial3D::set_specular(float p_specular) { specular = p_specular; - VS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular); + RS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular); } float BaseMaterial3D::get_specular() const { @@ -1173,7 +1173,7 @@ float BaseMaterial3D::get_specular() const { void BaseMaterial3D::set_roughness(float p_roughness) { roughness = p_roughness; - VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness); + RS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness); } float BaseMaterial3D::get_roughness() const { @@ -1184,7 +1184,7 @@ float BaseMaterial3D::get_roughness() const { void BaseMaterial3D::set_metallic(float p_metallic) { metallic = p_metallic; - VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic); + RS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic); } float BaseMaterial3D::get_metallic() const { @@ -1195,7 +1195,7 @@ float BaseMaterial3D::get_metallic() const { void BaseMaterial3D::set_emission(const Color &p_emission) { emission = p_emission; - VS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission); + RS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission); } Color BaseMaterial3D::get_emission() const { @@ -1205,7 +1205,7 @@ Color BaseMaterial3D::get_emission() const { void BaseMaterial3D::set_emission_energy(float p_emission_energy) { emission_energy = p_emission_energy; - VS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy); + RS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy); } float BaseMaterial3D::get_emission_energy() const { @@ -1215,7 +1215,7 @@ float BaseMaterial3D::get_emission_energy() const { void BaseMaterial3D::set_normal_scale(float p_normal_scale) { normal_scale = p_normal_scale; - VS::get_singleton()->material_set_param(_get_material(), shader_names->normal_scale, p_normal_scale); + RS::get_singleton()->material_set_param(_get_material(), shader_names->normal_scale, p_normal_scale); } float BaseMaterial3D::get_normal_scale() const { @@ -1225,7 +1225,7 @@ float BaseMaterial3D::get_normal_scale() const { void BaseMaterial3D::set_rim(float p_rim) { rim = p_rim; - VS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim); + RS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim); } float BaseMaterial3D::get_rim() const { @@ -1235,7 +1235,7 @@ float BaseMaterial3D::get_rim() const { void BaseMaterial3D::set_rim_tint(float p_rim_tint) { rim_tint = p_rim_tint; - VS::get_singleton()->material_set_param(_get_material(), shader_names->rim_tint, p_rim_tint); + RS::get_singleton()->material_set_param(_get_material(), shader_names->rim_tint, p_rim_tint); } float BaseMaterial3D::get_rim_tint() const { @@ -1245,7 +1245,7 @@ float BaseMaterial3D::get_rim_tint() const { void BaseMaterial3D::set_ao_light_affect(float p_ao_light_affect) { ao_light_affect = p_ao_light_affect; - VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect); + RS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect); } float BaseMaterial3D::get_ao_light_affect() const { @@ -1255,7 +1255,7 @@ float BaseMaterial3D::get_ao_light_affect() const { void BaseMaterial3D::set_clearcoat(float p_clearcoat) { clearcoat = p_clearcoat; - VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat); + RS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat); } float BaseMaterial3D::get_clearcoat() const { @@ -1266,7 +1266,7 @@ float BaseMaterial3D::get_clearcoat() const { void BaseMaterial3D::set_clearcoat_gloss(float p_clearcoat_gloss) { clearcoat_gloss = p_clearcoat_gloss; - VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat_gloss, p_clearcoat_gloss); + RS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat_gloss, p_clearcoat_gloss); } float BaseMaterial3D::get_clearcoat_gloss() const { @@ -1277,7 +1277,7 @@ float BaseMaterial3D::get_clearcoat_gloss() const { void BaseMaterial3D::set_anisotropy(float p_anisotropy) { anisotropy = p_anisotropy; - VS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy); + RS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy); } float BaseMaterial3D::get_anisotropy() const { @@ -1287,7 +1287,7 @@ float BaseMaterial3D::get_anisotropy() const { void BaseMaterial3D::set_heightmap_scale(float p_heightmap_scale) { heightmap_scale = p_heightmap_scale; - VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_scale, p_heightmap_scale); + RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_scale, p_heightmap_scale); } float BaseMaterial3D::get_heightmap_scale() const { @@ -1298,7 +1298,7 @@ float BaseMaterial3D::get_heightmap_scale() const { void BaseMaterial3D::set_subsurface_scattering_strength(float p_subsurface_scattering_strength) { subsurface_scattering_strength = p_subsurface_scattering_strength; - VS::get_singleton()->material_set_param(_get_material(), shader_names->subsurface_scattering_strength, subsurface_scattering_strength); + RS::get_singleton()->material_set_param(_get_material(), shader_names->subsurface_scattering_strength, subsurface_scattering_strength); } float BaseMaterial3D::get_subsurface_scattering_strength() const { @@ -1309,7 +1309,7 @@ float BaseMaterial3D::get_subsurface_scattering_strength() const { void BaseMaterial3D::set_transmission(const Color &p_transmission) { transmission = p_transmission; - VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission); + RS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission); } Color BaseMaterial3D::get_transmission() const { @@ -1320,7 +1320,7 @@ Color BaseMaterial3D::get_transmission() const { void BaseMaterial3D::set_refraction(float p_refraction) { refraction = p_refraction; - VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction); + RS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction); } float BaseMaterial3D::get_refraction() const { @@ -1488,7 +1488,7 @@ void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_t ERR_FAIL_INDEX(p_param, TEXTURE_MAX); textures[p_param] = p_texture; RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID(); - VS::get_singleton()->material_set_param(_get_material(), shader_names->texture_names[p_param], rid); + RS::get_singleton()->material_set_param(_get_material(), shader_names->texture_names[p_param], rid); _change_notify(); _queue_shader_change(); } @@ -1637,7 +1637,7 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const { void BaseMaterial3D::set_point_size(float p_point_size) { point_size = p_point_size; - VS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size); + RS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size); } float BaseMaterial3D::get_point_size() const { @@ -1648,7 +1648,7 @@ float BaseMaterial3D::get_point_size() const { void BaseMaterial3D::set_uv1_scale(const Vector3 &p_scale) { uv1_scale = p_scale; - VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale); } Vector3 BaseMaterial3D::get_uv1_scale() const { @@ -1659,7 +1659,7 @@ Vector3 BaseMaterial3D::get_uv1_scale() const { void BaseMaterial3D::set_uv1_offset(const Vector3 &p_offset) { uv1_offset = p_offset; - VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset); } Vector3 BaseMaterial3D::get_uv1_offset() const { @@ -1669,7 +1669,7 @@ Vector3 BaseMaterial3D::get_uv1_offset() const { void BaseMaterial3D::set_uv1_triplanar_blend_sharpness(float p_sharpness) { uv1_triplanar_sharpness = p_sharpness; - VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness); } float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const { @@ -1680,7 +1680,7 @@ float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const { void BaseMaterial3D::set_uv2_scale(const Vector3 &p_scale) { uv2_scale = p_scale; - VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale); } Vector3 BaseMaterial3D::get_uv2_scale() const { @@ -1691,7 +1691,7 @@ Vector3 BaseMaterial3D::get_uv2_scale() const { void BaseMaterial3D::set_uv2_offset(const Vector3 &p_offset) { uv2_offset = p_offset; - VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset); } Vector3 BaseMaterial3D::get_uv2_offset() const { @@ -1702,7 +1702,7 @@ Vector3 BaseMaterial3D::get_uv2_offset() const { void BaseMaterial3D::set_uv2_triplanar_blend_sharpness(float p_sharpness) { uv2_triplanar_sharpness = p_sharpness; - VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness); } float BaseMaterial3D::get_uv2_triplanar_blend_sharpness() const { @@ -1725,7 +1725,7 @@ BaseMaterial3D::BillboardMode BaseMaterial3D::get_billboard_mode() const { void BaseMaterial3D::set_particles_anim_h_frames(int p_frames) { particles_anim_h_frames = p_frames; - VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames); + RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames); } int BaseMaterial3D::get_particles_anim_h_frames() const { @@ -1735,7 +1735,7 @@ int BaseMaterial3D::get_particles_anim_h_frames() const { void BaseMaterial3D::set_particles_anim_v_frames(int p_frames) { particles_anim_v_frames = p_frames; - VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames); + RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames); } int BaseMaterial3D::get_particles_anim_v_frames() const { @@ -1746,7 +1746,7 @@ int BaseMaterial3D::get_particles_anim_v_frames() const { void BaseMaterial3D::set_particles_anim_loop(bool p_loop) { particles_anim_loop = p_loop; - VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop); + RS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop); } bool BaseMaterial3D::get_particles_anim_loop() const { @@ -1769,7 +1769,7 @@ bool BaseMaterial3D::is_heightmap_deep_parallax_enabled() const { void BaseMaterial3D::set_heightmap_deep_parallax_min_layers(int p_layer) { deep_parallax_min_layers = p_layer; - VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_min_layers, p_layer); + RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_min_layers, p_layer); } int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const { @@ -1779,7 +1779,7 @@ int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const { void BaseMaterial3D::set_heightmap_deep_parallax_max_layers(int p_layer) { deep_parallax_max_layers = p_layer; - VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_max_layers, p_layer); + RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_max_layers, p_layer); } int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const { @@ -1789,7 +1789,7 @@ int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const { void BaseMaterial3D::set_heightmap_deep_parallax_flip_tangent(bool p_flip) { heightmap_parallax_flip_tangent = p_flip; - VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1)); + RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1)); } bool BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent() const { @@ -1800,7 +1800,7 @@ bool BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent() const { void BaseMaterial3D::set_heightmap_deep_parallax_flip_binormal(bool p_flip) { heightmap_parallax_flip_binormal = p_flip; - VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1)); + RS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1)); } bool BaseMaterial3D::get_heightmap_deep_parallax_flip_binormal() const { @@ -1820,7 +1820,7 @@ bool BaseMaterial3D::is_grow_enabled() const { void BaseMaterial3D::set_alpha_scissor_threshold(float p_threshold) { alpha_scissor_threshold = p_threshold; - VS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_threshold); + RS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_threshold); } float BaseMaterial3D::get_alpha_scissor_threshold() const { @@ -1830,7 +1830,7 @@ float BaseMaterial3D::get_alpha_scissor_threshold() const { void BaseMaterial3D::set_grow(float p_grow) { grow = p_grow; - VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow); + RS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow); } float BaseMaterial3D::get_grow() const { @@ -1853,7 +1853,7 @@ static Plane _get_texture_mask(BaseMaterial3D::TextureChannel p_channel) { void BaseMaterial3D::set_metallic_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); metallic_texture_channel = p_channel; - VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel)); + RS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel)); } BaseMaterial3D::TextureChannel BaseMaterial3D::get_metallic_texture_channel() const { @@ -1875,7 +1875,7 @@ void BaseMaterial3D::set_ao_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); ao_texture_channel = p_channel; - VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel)); + RS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel)); } BaseMaterial3D::TextureChannel BaseMaterial3D::get_ao_texture_channel() const { @@ -1886,7 +1886,7 @@ void BaseMaterial3D::set_refraction_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); refraction_texture_channel = p_channel; - VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel)); + RS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel)); } BaseMaterial3D::TextureChannel BaseMaterial3D::get_refraction_texture_channel() const { @@ -1954,7 +1954,7 @@ bool BaseMaterial3D::is_proximity_fade_enabled() const { void BaseMaterial3D::set_proximity_fade_distance(float p_distance) { proximity_fade_distance = p_distance; - VS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance); + RS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance); } float BaseMaterial3D::get_proximity_fade_distance() const { @@ -1975,7 +1975,7 @@ BaseMaterial3D::DistanceFadeMode BaseMaterial3D::get_distance_fade() const { void BaseMaterial3D::set_distance_fade_max_distance(float p_distance) { distance_fade_max_distance = p_distance; - VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance); + RS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance); } float BaseMaterial3D::get_distance_fade_max_distance() const { @@ -1985,7 +1985,7 @@ float BaseMaterial3D::get_distance_fade_max_distance() const { void BaseMaterial3D::set_distance_fade_min_distance(float p_distance) { distance_fade_min_distance = p_distance; - VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance); + RS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance); } float BaseMaterial3D::get_distance_fade_min_distance() const { @@ -2561,11 +2561,11 @@ BaseMaterial3D::~BaseMaterial3D() { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { //deallocate shader, as it's no longer in use - VS::get_singleton()->free(shader_map[current_key].shader); + RS::get_singleton()->free(shader_map[current_key].shader); shader_map.erase(current_key); } - VS::get_singleton()->material_set_shader(_get_material(), RID()); + RS::get_singleton()->material_set_shader(_get_material(), RID()); } } @@ -2641,7 +2641,7 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value) { "depth_flip_binormal", "heightmap_flip_binormal" }, { "depth_texture", "heightmap_texture" }, - { NULL, NULL }, + { nullptr, nullptr }, }; int idx = 0; diff --git a/scene/resources/material.h b/scene/resources/material.h index fc77226fb9..0c9352baf4 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -35,8 +35,8 @@ #include "core/self_list.h" #include "scene/resources/shader.h" #include "scene/resources/texture.h" -#include "servers/visual/shader_language.h" -#include "servers/visual_server.h" +#include "servers/rendering/shader_language.h" +#include "servers/rendering_server.h" class Material : public Resource { @@ -57,8 +57,8 @@ protected: public: enum { - RENDER_PRIORITY_MAX = VS::MATERIAL_RENDER_PRIORITY_MAX, - RENDER_PRIORITY_MIN = VS::MATERIAL_RENDER_PRIORITY_MIN, + RENDER_PRIORITY_MAX = RS::MATERIAL_RENDER_PRIORITY_MAX, + RENDER_PRIORITY_MIN = RS::MATERIAL_RENDER_PRIORITY_MIN, }; void set_next_pass(const Ref<Material> &p_pass); Ref<Material> get_next_pass() const; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 0d32fdb0fa..6bb5be15f3 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -37,7 +37,7 @@ #include <stdlib.h> -Mesh::ConvexDecompositionFunc Mesh::convex_composition_function = NULL; +Mesh::ConvexDecompositionFunc Mesh::convex_composition_function = nullptr; Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { @@ -169,20 +169,20 @@ Vector<Face3> Mesh::get_faces() const { /* for (int i=0;i<surfaces.size();i++) { - if (VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != VisualServer::PRIMITIVE_TRIANGLES ) + if (RenderingServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != RenderingServer::PRIMITIVE_TRIANGLES ) continue; Vector<int> indices; Vector<Vector3> vertices; - vertices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_VERTEX); + vertices=RenderingServer::get_singleton()->mesh_surface_get_array(mesh, i,RenderingServer::ARRAY_VERTEX); - int len=VisualServer::get_singleton()->mesh_surface_get_array_index_len(mesh, i); + int len=RenderingServer::get_singleton()->mesh_surface_get_array_index_len(mesh, i); bool has_indices; if (len>0) { - indices=VisualServer::get_singleton()->mesh_surface_get_array(mesh, i,VisualServer::ARRAY_INDEX); + indices=RenderingServer::get_singleton()->mesh_surface_get_array(mesh, i,RenderingServer::ARRAY_INDEX); has_indices=true; } else { @@ -372,7 +372,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const { ERR_FAIL_COND_V(arrays.size() != ARRAY_MAX, Ref<ArrayMesh>()); { - int *ir = NULL; + int *ir = nullptr; Vector<int> indices = arrays[ARRAY_INDEX]; bool has_indices = false; Vector<Vector3> vertices = arrays[ARRAY_VERTEX]; @@ -846,7 +846,7 @@ Array ArrayMesh::_get_surfaces() const { Array ret; for (int i = 0; i < surfaces.size(); i++) { - VisualServer::SurfaceData surface = VS::get_singleton()->mesh_get_surface(mesh, i); + RenderingServer::SurfaceData surface = RS::get_singleton()->mesh_get_surface(mesh, i); Dictionary data; data["format"] = surface.format; data["primitive"] = surface.primitive; @@ -902,20 +902,20 @@ Array ArrayMesh::_get_surfaces() const { void ArrayMesh::_create_if_empty() const { if (!mesh.is_valid()) { - mesh = VS::get_singleton()->mesh_create(); - VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)blend_shape_mode); + mesh = RS::get_singleton()->mesh_create(); + RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)blend_shape_mode); } } void ArrayMesh::_set_surfaces(const Array &p_surfaces) { - Vector<VS::SurfaceData> surface_data; + Vector<RS::SurfaceData> surface_data; Vector<Ref<Material>> surface_materials; Vector<String> surface_names; Vector<bool> surface_2d; for (int i = 0; i < p_surfaces.size(); i++) { - VS::SurfaceData surface; + RS::SurfaceData surface; Dictionary d = p_surfaces[i]; ERR_FAIL_COND(!d.has("format")); ERR_FAIL_COND(!d.has("primitive")); @@ -923,7 +923,7 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { ERR_FAIL_COND(!d.has("vertex_count")); ERR_FAIL_COND(!d.has("aabb")); surface.format = d["format"]; - surface.primitive = VS::PrimitiveType(int(d["primitive"])); + surface.primitive = RS::PrimitiveType(int(d["primitive"])); surface.vertex_data = d["vertex_data"]; surface.vertex_count = d["vertex_count"]; surface.aabb = d["aabb"]; @@ -938,7 +938,7 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { Array lods = d["lods"]; ERR_FAIL_COND(lods.size() & 1); //must be even for (int j = 0; j < lods.size(); j += 2) { - VS::SurfaceData::LOD lod; + RS::SurfaceData::LOD lod; lod.edge_length = lods[j + 0]; lod.index_data = lods[j + 1]; surface.lods.push_back(lod); @@ -993,15 +993,15 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) { if (mesh.is_valid()) { //if mesh exists, it needs to be updated - VS::get_singleton()->mesh_clear(mesh); + RS::get_singleton()->mesh_clear(mesh); for (int i = 0; i < surface_data.size(); i++) { - VS::get_singleton()->mesh_add_surface(mesh, surface_data[i]); + RS::get_singleton()->mesh_add_surface(mesh, surface_data[i]); } } else { // if mesh does not exist (first time this is loaded, most likely), // we can create it with a single call, which is a lot more efficient and thread friendly - mesh = VS::get_singleton()->mesh_create_from_surfaces(surface_data); - VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)blend_shape_mode); + mesh = RS::get_singleton()->mesh_create_from_surfaces(surface_data); + RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)blend_shape_mode); } surfaces.clear(); @@ -1102,7 +1102,7 @@ void ArrayMesh::_recompute_aabb() { #ifndef _MSC_VER #warning need to add binding to add_surface using future MeshSurfaceData object #endif -void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<VS::SurfaceData::LOD> &p_lods) { +void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes, const Vector<AABB> &p_bone_aabb, const Vector<RS::SurfaceData::LOD> &p_lods) { _create_if_empty(); @@ -1117,9 +1117,9 @@ void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const surfaces.push_back(s); _recompute_aabb(); - VS::SurfaceData sd; + RS::SurfaceData sd; sd.format = p_format; - sd.primitive = VS::PrimitiveType(p_primitive); + sd.primitive = RS::PrimitiveType(p_primitive); sd.aabb = p_aabb; sd.vertex_count = p_vertex_count; sd.vertex_data = p_array; @@ -1129,7 +1129,7 @@ void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const sd.bone_aabbs = p_bone_aabb; sd.lods = p_lods; - VisualServer::get_singleton()->mesh_add_surface(mesh, sd); + RenderingServer::get_singleton()->mesh_add_surface(mesh, sd); clear_cache(); _change_notify(); @@ -1140,9 +1140,9 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array & ERR_FAIL_COND(p_arrays.size() != ARRAY_MAX); - VS::SurfaceData surface; + RS::SurfaceData surface; - Error err = VS::get_singleton()->mesh_create_surface_data_from_arrays(&surface, (VisualServer::PrimitiveType)p_primitive, p_arrays, p_blend_shapes, p_lods, p_flags); + Error err = RS::get_singleton()->mesh_create_surface_data_from_arrays(&surface, (RenderingServer::PrimitiveType)p_primitive, p_arrays, p_blend_shapes, p_lods, p_flags); ERR_FAIL_COND(err != OK); /* print_line("format: " + itos(surface.format)); @@ -1159,16 +1159,16 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array & Array ArrayMesh::surface_get_arrays(int p_surface) const { ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array()); - return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface); + return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface); } Array ArrayMesh::surface_get_blend_shape_arrays(int p_surface) const { ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array()); - return VisualServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface); + return RenderingServer::get_singleton()->mesh_surface_get_blend_shape_arrays(mesh, p_surface); } Dictionary ArrayMesh::surface_get_lods(int p_surface) const { ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Dictionary()); - return VisualServer::get_singleton()->mesh_surface_get_lods(mesh, p_surface); + return RenderingServer::get_singleton()->mesh_surface_get_lods(mesh, p_surface); } int ArrayMesh::get_surface_count() const { @@ -1193,7 +1193,7 @@ void ArrayMesh::add_blend_shape(const StringName &p_name) { } blend_shapes.push_back(name); - //VS::get_singleton()->mesh_set_blend_shape_count(mesh, blend_shapes.size()); + //RS::get_singleton()->mesh_set_blend_shape_count(mesh, blend_shapes.size()); } int ArrayMesh::get_blend_shape_count() const { @@ -1215,7 +1215,7 @@ void ArrayMesh::set_blend_shape_mode(BlendShapeMode p_mode) { blend_shape_mode = p_mode; if (mesh.is_valid()) { - VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)p_mode); + RS::get_singleton()->mesh_set_blend_shape_mode(mesh, (RS::BlendShapeMode)p_mode); } } @@ -1254,7 +1254,7 @@ void ArrayMesh::surface_set_material(int p_idx, const Ref<Material> &p_material) if (surfaces[p_idx].material == p_material) return; surfaces.write[p_idx].material = p_material; - VisualServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null() ? RID() : p_material->get_rid()); + RenderingServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null() ? RID() : p_material->get_rid()); _change_notify("material"); emit_changed(); @@ -1286,7 +1286,7 @@ String ArrayMesh::surface_get_name(int p_idx) const { void ArrayMesh::surface_update_region(int p_surface, int p_offset, const Vector<uint8_t> &p_data) { ERR_FAIL_INDEX(p_surface, surfaces.size()); - VS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data); + RS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data); emit_changed(); } @@ -1318,7 +1318,7 @@ void ArrayMesh::clear_surfaces() { if (!mesh.is_valid()) { return; } - VS::get_singleton()->mesh_clear(mesh); + RS::get_singleton()->mesh_clear(mesh); surfaces.clear(); aabb = AABB(); } @@ -1327,7 +1327,7 @@ void ArrayMesh::set_custom_aabb(const AABB &p_custom) { _create_if_empty(); custom_aabb = p_custom; - VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); + RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); emit_changed(); } @@ -1359,7 +1359,7 @@ void ArrayMesh::regen_normalmaps() { } //dirty hack -bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) = NULL; +bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) = nullptr; struct ArrayMeshLightmapSurface { @@ -1609,7 +1609,7 @@ void ArrayMesh::_bind_methods() { } void ArrayMesh::reload_from_file() { - VisualServer::get_singleton()->mesh_clear(mesh); + RenderingServer::get_singleton()->mesh_clear(mesh); surfaces.clear(); clear_blend_shapes(); clear_cache(); @@ -1622,13 +1622,13 @@ void ArrayMesh::reload_from_file() { ArrayMesh::ArrayMesh() { //mesh is now created on demand - //mesh = VisualServer::get_singleton()->mesh_create(); + //mesh = RenderingServer::get_singleton()->mesh_create(); blend_shape_mode = BLEND_SHAPE_MODE_RELATIVE; } ArrayMesh::~ArrayMesh() { if (mesh.is_valid()) { - VisualServer::get_singleton()->free(mesh); + RenderingServer::get_singleton()->free(mesh); } } diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index e5f87dbbe5..25a9722046 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -36,7 +36,7 @@ #include "core/resource.h" #include "scene/resources/material.h" #include "scene/resources/shape_3d.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class Mesh : public Resource { GDCLASS(Mesh, Resource); @@ -51,22 +51,22 @@ protected: public: enum { - NO_INDEX_ARRAY = VisualServer::NO_INDEX_ARRAY, - ARRAY_WEIGHTS_SIZE = VisualServer::ARRAY_WEIGHTS_SIZE + NO_INDEX_ARRAY = RenderingServer::NO_INDEX_ARRAY, + ARRAY_WEIGHTS_SIZE = RenderingServer::ARRAY_WEIGHTS_SIZE }; enum ArrayType { - ARRAY_VERTEX = VisualServer::ARRAY_VERTEX, - ARRAY_NORMAL = VisualServer::ARRAY_NORMAL, - ARRAY_TANGENT = VisualServer::ARRAY_TANGENT, - ARRAY_COLOR = VisualServer::ARRAY_COLOR, - ARRAY_TEX_UV = VisualServer::ARRAY_TEX_UV, - ARRAY_TEX_UV2 = VisualServer::ARRAY_TEX_UV2, - ARRAY_BONES = VisualServer::ARRAY_BONES, - ARRAY_WEIGHTS = VisualServer::ARRAY_WEIGHTS, - ARRAY_INDEX = VisualServer::ARRAY_INDEX, - ARRAY_MAX = VisualServer::ARRAY_MAX + ARRAY_VERTEX = RenderingServer::ARRAY_VERTEX, + ARRAY_NORMAL = RenderingServer::ARRAY_NORMAL, + ARRAY_TANGENT = RenderingServer::ARRAY_TANGENT, + ARRAY_COLOR = RenderingServer::ARRAY_COLOR, + ARRAY_TEX_UV = RenderingServer::ARRAY_TEX_UV, + ARRAY_TEX_UV2 = RenderingServer::ARRAY_TEX_UV2, + ARRAY_BONES = RenderingServer::ARRAY_BONES, + ARRAY_WEIGHTS = RenderingServer::ARRAY_WEIGHTS, + ARRAY_INDEX = RenderingServer::ARRAY_INDEX, + ARRAY_MAX = RenderingServer::ARRAY_MAX }; @@ -98,18 +98,18 @@ public: }; enum PrimitiveType { - PRIMITIVE_POINTS = VisualServer::PRIMITIVE_POINTS, - PRIMITIVE_LINES = VisualServer::PRIMITIVE_LINES, - PRIMITIVE_LINE_STRIP = VisualServer::PRIMITIVE_LINE_STRIP, - PRIMITIVE_TRIANGLES = VisualServer::PRIMITIVE_TRIANGLES, - PRIMITIVE_TRIANGLE_STRIP = VisualServer::PRIMITIVE_TRIANGLE_STRIP, - PRIMITIVE_MAX = VisualServer::PRIMITIVE_MAX, + PRIMITIVE_POINTS = RenderingServer::PRIMITIVE_POINTS, + PRIMITIVE_LINES = RenderingServer::PRIMITIVE_LINES, + PRIMITIVE_LINE_STRIP = RenderingServer::PRIMITIVE_LINE_STRIP, + PRIMITIVE_TRIANGLES = RenderingServer::PRIMITIVE_TRIANGLES, + PRIMITIVE_TRIANGLE_STRIP = RenderingServer::PRIMITIVE_TRIANGLE_STRIP, + PRIMITIVE_MAX = RenderingServer::PRIMITIVE_MAX, }; enum BlendShapeMode { - BLEND_SHAPE_MODE_NORMALIZED = VS::BLEND_SHAPE_MODE_NORMALIZED, - BLEND_SHAPE_MODE_RELATIVE = VS::BLEND_SHAPE_MODE_RELATIVE, + BLEND_SHAPE_MODE_NORMALIZED = RS::BLEND_SHAPE_MODE_NORMALIZED, + BLEND_SHAPE_MODE_RELATIVE = RS::BLEND_SHAPE_MODE_RELATIVE, }; virtual int get_surface_count() const = 0; @@ -193,7 +193,7 @@ protected: public: void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), uint32_t p_flags = ARRAY_COMPRESS_DEFAULT); - void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<VS::SurfaceData::LOD> &p_lods = Vector<VS::SurfaceData::LOD>()); + void add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<Vector<uint8_t>> &p_blend_shapes = Vector<Vector<uint8_t>>(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>(), const Vector<RS::SurfaceData::LOD> &p_lods = Vector<RS::SurfaceData::LOD>()); Array surface_get_arrays(int p_surface) const; Array surface_get_blend_shape_arrays(int p_surface) const; diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 8b7f8288b8..76d96786bc 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -58,30 +58,30 @@ Error MeshDataTool::create_from_surface(const Ref<ArrayMesh> &p_mesh, int p_surf const Vector3 *vr = varray.ptr(); - const Vector3 *nr = NULL; + const Vector3 *nr = nullptr; if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL) nr = arrays[Mesh::ARRAY_NORMAL].operator Vector<Vector3>().ptr(); - const real_t *ta = NULL; + const real_t *ta = nullptr; if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL) ta = arrays[Mesh::ARRAY_TANGENT].operator Vector<real_t>().ptr(); - const Vector2 *uv = NULL; + const Vector2 *uv = nullptr; if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL) uv = arrays[Mesh::ARRAY_TEX_UV].operator Vector<Vector2>().ptr(); - const Vector2 *uv2 = NULL; + const Vector2 *uv2 = nullptr; if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL) uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator Vector<Vector2>().ptr(); - const Color *col = NULL; + const Color *col = nullptr; if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL) col = arrays[Mesh::ARRAY_COLOR].operator Vector<Color>().ptr(); - const int *bo = NULL; + const int *bo = nullptr; if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL) bo = arrays[Mesh::ARRAY_BONES].operator Vector<int>().ptr(); - const real_t *we = NULL; + const real_t *we = nullptr; if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL) we = arrays[Mesh::ARRAY_WEIGHTS].operator Vector<real_t>().ptr(); @@ -202,43 +202,43 @@ Error MeshDataTool::commit_to_surface(const Ref<ArrayMesh> &p_mesh) { v.resize(vcount); Vector3 *vr = v.ptrw(); - Vector3 *nr = NULL; + Vector3 *nr = nullptr; if (format & Mesh::ARRAY_FORMAT_NORMAL) { n.resize(vcount); nr = n.ptrw(); } - real_t *ta = NULL; + real_t *ta = nullptr; if (format & Mesh::ARRAY_FORMAT_TANGENT) { t.resize(vcount * 4); ta = t.ptrw(); } - Vector2 *uv = NULL; + Vector2 *uv = nullptr; if (format & Mesh::ARRAY_FORMAT_TEX_UV) { u.resize(vcount); uv = u.ptrw(); } - Vector2 *uv2 = NULL; + Vector2 *uv2 = nullptr; if (format & Mesh::ARRAY_FORMAT_TEX_UV2) { u2.resize(vcount); uv2 = u2.ptrw(); } - Color *col = NULL; + Color *col = nullptr; if (format & Mesh::ARRAY_FORMAT_COLOR) { c.resize(vcount); col = c.ptrw(); } - int *bo = NULL; + int *bo = nullptr; if (format & Mesh::ARRAY_FORMAT_BONES) { b.resize(vcount * 4); bo = b.ptrw(); } - real_t *we = NULL; + real_t *we = nullptr; if (format & Mesh::ARRAY_FORMAT_WEIGHTS) { w.resize(vcount * 4); we = w.ptrw(); diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index aa8be326f5..ce561bfaaf 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -30,7 +30,7 @@ #include "multimesh.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #ifndef DISABLE_DEPRECATED // Kept for compatibility from 3.x to 4.0. @@ -198,20 +198,20 @@ Vector<Color> MultiMesh::_get_custom_data_array() const { #endif // DISABLE_DEPRECATED void MultiMesh::set_buffer(const Vector<float> &p_buffer) { - VS::get_singleton()->multimesh_set_buffer(multimesh, p_buffer); + RS::get_singleton()->multimesh_set_buffer(multimesh, p_buffer); } Vector<float> MultiMesh::get_buffer() const { - return VS::get_singleton()->multimesh_get_buffer(multimesh); + return RS::get_singleton()->multimesh_get_buffer(multimesh); } void MultiMesh::set_mesh(const Ref<Mesh> &p_mesh) { mesh = p_mesh; if (!mesh.is_null()) - VisualServer::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid()); + RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid()); else - VisualServer::get_singleton()->multimesh_set_mesh(multimesh, RID()); + RenderingServer::get_singleton()->multimesh_set_mesh(multimesh, RID()); } Ref<Mesh> MultiMesh::get_mesh() const { @@ -221,7 +221,7 @@ Ref<Mesh> MultiMesh::get_mesh() const { void MultiMesh::set_instance_count(int p_count) { ERR_FAIL_COND(p_count < 0); - VisualServer::get_singleton()->multimesh_allocate(multimesh, p_count, VS::MultimeshTransformFormat(transform_format), use_colors, use_custom_data); + RenderingServer::get_singleton()->multimesh_allocate(multimesh, p_count, RS::MultimeshTransformFormat(transform_format), use_colors, use_custom_data); instance_count = p_count; } int MultiMesh::get_instance_count() const { @@ -232,7 +232,7 @@ int MultiMesh::get_instance_count() const { void MultiMesh::set_visible_instance_count(int p_count) { ERR_FAIL_COND(p_count < -1); ERR_FAIL_COND(p_count > instance_count); - VisualServer::get_singleton()->multimesh_set_visible_instances(multimesh, p_count); + RenderingServer::get_singleton()->multimesh_set_visible_instances(multimesh, p_count); visible_instance_count = p_count; } int MultiMesh::get_visible_instance_count() const { @@ -242,45 +242,45 @@ int MultiMesh::get_visible_instance_count() const { void MultiMesh::set_instance_transform(int p_instance, const Transform &p_transform) { - VisualServer::get_singleton()->multimesh_instance_set_transform(multimesh, p_instance, p_transform); + RenderingServer::get_singleton()->multimesh_instance_set_transform(multimesh, p_instance, p_transform); } void MultiMesh::set_instance_transform_2d(int p_instance, const Transform2D &p_transform) { - VisualServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform); + RenderingServer::get_singleton()->multimesh_instance_set_transform_2d(multimesh, p_instance, p_transform); } Transform MultiMesh::get_instance_transform(int p_instance) const { - return VisualServer::get_singleton()->multimesh_instance_get_transform(multimesh, p_instance); + return RenderingServer::get_singleton()->multimesh_instance_get_transform(multimesh, p_instance); } Transform2D MultiMesh::get_instance_transform_2d(int p_instance) const { - return VisualServer::get_singleton()->multimesh_instance_get_transform_2d(multimesh, p_instance); + return RenderingServer::get_singleton()->multimesh_instance_get_transform_2d(multimesh, p_instance); } void MultiMesh::set_instance_color(int p_instance, const Color &p_color) { - VisualServer::get_singleton()->multimesh_instance_set_color(multimesh, p_instance, p_color); + RenderingServer::get_singleton()->multimesh_instance_set_color(multimesh, p_instance, p_color); } Color MultiMesh::get_instance_color(int p_instance) const { - return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance); + return RenderingServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance); } void MultiMesh::set_instance_custom_data(int p_instance, const Color &p_custom_data) { - VisualServer::get_singleton()->multimesh_instance_set_custom_data(multimesh, p_instance, p_custom_data); + RenderingServer::get_singleton()->multimesh_instance_set_custom_data(multimesh, p_instance, p_custom_data); } Color MultiMesh::get_instance_custom_data(int p_instance) const { - return VisualServer::get_singleton()->multimesh_instance_get_custom_data(multimesh, p_instance); + return RenderingServer::get_singleton()->multimesh_instance_get_custom_data(multimesh, p_instance); } AABB MultiMesh::get_aabb() const { - return VisualServer::get_singleton()->multimesh_get_aabb(multimesh); + return RenderingServer::get_singleton()->multimesh_get_aabb(multimesh); } RID MultiMesh::get_rid() const { @@ -375,7 +375,7 @@ void MultiMesh::_bind_methods() { MultiMesh::MultiMesh() { - multimesh = VisualServer::get_singleton()->multimesh_create(); + multimesh = RenderingServer::get_singleton()->multimesh_create(); use_colors = false; use_custom_data = false; transform_format = TRANSFORM_2D; @@ -385,5 +385,5 @@ MultiMesh::MultiMesh() { MultiMesh::~MultiMesh() { - VisualServer::get_singleton()->free(multimesh); + RenderingServer::get_singleton()->free(multimesh); } diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h index 8ca30a5b88..c1e52bc981 100644 --- a/scene/resources/multimesh.h +++ b/scene/resources/multimesh.h @@ -32,7 +32,7 @@ #define MULTIMESH_H #include "scene/resources/mesh.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class MultiMesh : public Resource { @@ -41,8 +41,8 @@ class MultiMesh : public Resource { public: enum TransformFormat { - TRANSFORM_2D = VS::MULTIMESH_TRANSFORM_2D, - TRANSFORM_3D = VS::MULTIMESH_TRANSFORM_3D + TRANSFORM_2D = RS::MULTIMESH_TRANSFORM_2D, + TRANSFORM_3D = RS::MULTIMESH_TRANSFORM_3D }; private: diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 549c29a7f3..633771506e 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -51,25 +51,25 @@ Node *SceneState::instance(GenEditState p_edit_state) const { // nodes where instancing failed (because something is missing) List<Node *> stray_instances; -#define NODE_FROM_ID(p_name, p_id) \ - Node *p_name; \ - if (p_id & FLAG_ID_IS_PATH) { \ - NodePath np = node_paths[p_id & FLAG_MASK]; \ - p_name = ret_nodes[0]->get_node_or_null(np); \ - } else { \ - ERR_FAIL_INDEX_V(p_id &FLAG_MASK, nc, NULL); \ - p_name = ret_nodes[p_id & FLAG_MASK]; \ +#define NODE_FROM_ID(p_name, p_id) \ + Node *p_name; \ + if (p_id & FLAG_ID_IS_PATH) { \ + NodePath np = node_paths[p_id & FLAG_MASK]; \ + p_name = ret_nodes[0]->get_node_or_null(np); \ + } else { \ + ERR_FAIL_INDEX_V(p_id &FLAG_MASK, nc, nullptr); \ + p_name = ret_nodes[p_id & FLAG_MASK]; \ } int nc = nodes.size(); - ERR_FAIL_COND_V(nc == 0, NULL); + ERR_FAIL_COND_V(nc == 0, nullptr); - const StringName *snames = NULL; + const StringName *snames = nullptr; int sname_count = names.size(); if (sname_count) snames = &names[0]; - const Variant *props = NULL; + const Variant *props = nullptr; int prop_count = variants.size(); if (prop_count) props = &variants[0]; @@ -88,11 +88,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const { const NodeData &n = nd[i]; - Node *parent = NULL; + Node *parent = nullptr; if (i > 0) { - ERR_FAIL_COND_V_MSG(n.parent == -1, NULL, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name])); + ERR_FAIL_COND_V_MSG(n.parent == -1, nullptr, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name])); NODE_FROM_ID(nparent, n.parent); #ifdef DEBUG_ENABLED if (!nparent && (n.parent & FLAG_ID_IS_PATH)) { @@ -103,14 +103,14 @@ Node *SceneState::instance(GenEditState p_edit_state) const { parent = nparent; } - Node *node = NULL; + Node *node = nullptr; if (i == 0 && base_scene_idx >= 0) { //scene inheritance on root node Ref<PackedScene> sdata = props[base_scene_idx]; - ERR_FAIL_COND_V(!sdata.is_valid(), NULL); + ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); //only main gets main edit state - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); if (p_edit_state != GEN_EDIT_STATE_DISABLED) { node->set_scene_inherited_state(sdata->get_state()); } @@ -123,9 +123,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { if (disable_placeholders) { Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene"); - ERR_FAIL_COND_V(!sdata.is_valid(), NULL); + ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); } else { InstancePlaceholder *ip = memnew(InstancePlaceholder); ip->set_instance_path(path); @@ -134,9 +134,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { node->set_scene_instance_load_placeholder(true); } else { Ref<PackedScene> sdata = props[n.instance & FLAG_MASK]; - ERR_FAIL_COND_V(!sdata.is_valid(), NULL); + ERR_FAIL_COND_V(!sdata.is_valid(), nullptr); node = sdata->instance(p_edit_state == GEN_EDIT_STATE_DISABLED ? PackedScene::GEN_EDIT_STATE_DISABLED : PackedScene::GEN_EDIT_STATE_INSTANCE); - ERR_FAIL_COND_V(!node, NULL); + ERR_FAIL_COND_V(!node, nullptr); } } else if (n.type == TYPE_INSTANCED) { @@ -155,7 +155,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { if (!Object::cast_to<Node>(obj)) { if (obj) { memdelete(obj); - obj = NULL; + obj = nullptr; } WARN_PRINT(String("Warning node of type " + snames[n.type].operator String() + " does not exist.").ascii().get_data()); if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) { @@ -193,8 +193,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const { for (int j = 0; j < nprop_count; j++) { bool valid; - ERR_FAIL_INDEX_V(nprops[j].name, sname_count, NULL); - ERR_FAIL_INDEX_V(nprops[j].value, prop_count, NULL); + ERR_FAIL_INDEX_V(nprops[j].name, sname_count, nullptr); + ERR_FAIL_INDEX_V(nprops[j].value, prop_count, nullptr); if (snames[nprops[j].name] == CoreStringNames::get_singleton()->_script) { //work around to avoid old script variables from disappearing, should be the proper fix to: @@ -260,7 +260,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //groups for (int j = 0; j < n.groups.size(); j++) { - ERR_FAIL_INDEX_V(n.groups[j], sname_count, NULL); + ERR_FAIL_INDEX_V(n.groups[j], sname_count, nullptr); node->add_to_group(snames[n.groups[j]], true); } @@ -315,8 +315,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const { for (int i = 0; i < cc; i++) { const ConnectionData &c = cdata[i]; - //ERR_FAIL_INDEX_V( c.from, nc, NULL ); - //ERR_FAIL_INDEX_V( c.to, nc, NULL ); + //ERR_FAIL_INDEX_V( c.from, nc, nullptr ); + //ERR_FAIL_INDEX_V( c.to, nc, nullptr ); NODE_FROM_ID(cfrom, c.from); NODE_FROM_ID(cto, c.to); @@ -450,7 +450,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map nd.instance = _vm_get_variant(instance, variant_map); } } - n = NULL; + n = nullptr; } else { if (n->get_filename() != String()) { //is an instance @@ -773,7 +773,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName } } - nl = NULL; + nl = nullptr; } else { if (nl->get_filename() != String()) { //is an instance @@ -896,7 +896,7 @@ Error SceneState::pack(Node *p_scene) { } variants.resize(variant_map.size()); - const Variant *K = NULL; + const Variant *K = nullptr; while ((K = variant_map.next(K))) { int idx = variant_map[*K]; @@ -1689,12 +1689,12 @@ bool PackedScene::can_instance() const { Node *PackedScene::instance(GenEditState p_edit_state) const { #ifndef TOOLS_ENABLED - ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, NULL, "Edit state is only for editors, does not work without tools compiled."); + ERR_FAIL_COND_V_MSG(p_edit_state != GEN_EDIT_STATE_DISABLED, nullptr, "Edit state is only for editors, does not work without tools compiled."); #endif Node *s = state->instance((SceneState::GenEditState)p_edit_state); if (!s) - return NULL; + return nullptr; if (p_edit_state != GEN_EDIT_STATE_DISABLED) { s->set_scene_instance_state(state); diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index f18e8956f1..83430aef9e 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -31,9 +31,9 @@ #include "particles_material.h" Mutex ParticlesMaterial::material_mutex; -SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = NULL; +SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = nullptr; Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map; -ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL; +ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = nullptr; void ParticlesMaterial::init_shaders() { @@ -104,7 +104,7 @@ void ParticlesMaterial::init_shaders() { void ParticlesMaterial::finish_shaders() { memdelete(dirty_materials); - dirty_materials = NULL; + dirty_materials = nullptr; memdelete(shader_names); } @@ -121,7 +121,7 @@ void ParticlesMaterial::_update_shader() { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { //deallocate shader, as it's no longer in use - VS::get_singleton()->free(shader_map[current_key].shader); + RS::get_singleton()->free(shader_map[current_key].shader); shader_map.erase(current_key); } } @@ -130,7 +130,7 @@ void ParticlesMaterial::_update_shader() { if (shader_map.has(mk)) { - VS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader); + RS::get_singleton()->material_set_shader(_get_material(), shader_map[mk].shader); shader_map[mk].users++; return; } @@ -592,14 +592,14 @@ void ParticlesMaterial::_update_shader() { code += "\n"; ShaderData shader_data; - shader_data.shader = VS::get_singleton()->shader_create(); + shader_data.shader = RS::get_singleton()->shader_create(); shader_data.users = 1; - VS::get_singleton()->shader_set_code(shader_data.shader, code); + RS::get_singleton()->shader_set_code(shader_data.shader, code); shader_map[mk] = shader_data; - VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); + RS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); } void ParticlesMaterial::flush_changes() { @@ -631,7 +631,7 @@ bool ParticlesMaterial::_is_shader_dirty() const { void ParticlesMaterial::set_direction(Vector3 p_direction) { direction = p_direction; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->direction, direction); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->direction, direction); } Vector3 ParticlesMaterial::get_direction() const { @@ -642,7 +642,7 @@ Vector3 ParticlesMaterial::get_direction() const { void ParticlesMaterial::set_spread(float p_spread) { spread = p_spread; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->spread, p_spread); } float ParticlesMaterial::get_spread() const { @@ -653,7 +653,7 @@ float ParticlesMaterial::get_spread() const { void ParticlesMaterial::set_flatness(float p_flatness) { flatness = p_flatness; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->flatness, p_flatness); } float ParticlesMaterial::get_flatness() const { @@ -668,40 +668,40 @@ void ParticlesMaterial::set_param(Parameter p_param, float p_value) { switch (p_param) { case PARAM_INITIAL_LINEAR_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity, p_value); } break; case PARAM_ANGULAR_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity, p_value); } break; case PARAM_ORBIT_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity, p_value); } break; case PARAM_LINEAR_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel, p_value); } break; case PARAM_RADIAL_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel, p_value); } break; case PARAM_TANGENTIAL_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel, p_value); } break; case PARAM_DAMPING: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->damping, p_value); } break; case PARAM_ANGLE: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle, p_value); } break; case PARAM_SCALE: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->scale, p_value); } break; case PARAM_HUE_VARIATION: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation, p_value); } break; case PARAM_ANIM_SPEED: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed, p_value); } break; case PARAM_ANIM_OFFSET: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset, p_value); } break; case PARAM_MAX: break; // Can't happen, but silences warning } @@ -721,40 +721,40 @@ void ParticlesMaterial::set_param_randomness(Parameter p_param, float p_value) { switch (p_param) { case PARAM_INITIAL_LINEAR_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_linear_velocity_random, p_value); } break; case PARAM_ANGULAR_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_random, p_value); } break; case PARAM_ORBIT_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_random, p_value); } break; case PARAM_LINEAR_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_random, p_value); } break; case PARAM_RADIAL_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_random, p_value); } break; case PARAM_TANGENTIAL_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_random, p_value); } break; case PARAM_DAMPING: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_random, p_value); } break; case PARAM_ANGLE: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->initial_angle_random, p_value); } break; case PARAM_SCALE: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_random, p_value); } break; case PARAM_HUE_VARIATION: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_random, p_value); } break; case PARAM_ANIM_SPEED: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_random, p_value); } break; case PARAM_ANIM_OFFSET: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_random, p_value); } break; case PARAM_MAX: break; // Can't happen, but silences warning } @@ -786,47 +786,47 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D //do none for this one } break; case PARAM_ANGULAR_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angular_velocity_texture, p_texture); _adjust_curve_range(p_texture, -360, 360); } break; case PARAM_ORBIT_VELOCITY: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->orbit_velocity_texture, p_texture); _adjust_curve_range(p_texture, -500, 500); } break; case PARAM_LINEAR_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->linear_accel_texture, p_texture); _adjust_curve_range(p_texture, -200, 200); } break; case PARAM_RADIAL_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->radial_accel_texture, p_texture); _adjust_curve_range(p_texture, -200, 200); } break; case PARAM_TANGENTIAL_ACCEL: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->tangent_accel_texture, p_texture); _adjust_curve_range(p_texture, -200, 200); } break; case PARAM_DAMPING: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->damping_texture, p_texture); _adjust_curve_range(p_texture, 0, 100); } break; case PARAM_ANGLE: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->angle_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->angle_texture, p_texture); _adjust_curve_range(p_texture, -360, 360); } break; case PARAM_SCALE: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->scale_texture, p_texture); _adjust_curve_range(p_texture, 0, 1); } break; case PARAM_HUE_VARIATION: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->hue_variation_texture, p_texture); _adjust_curve_range(p_texture, -1, 1); } break; case PARAM_ANIM_SPEED: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_speed_texture, p_texture); _adjust_curve_range(p_texture, 0, 200); } break; case PARAM_ANIM_OFFSET: { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->anim_offset_texture, p_texture); } break; case PARAM_MAX: break; // Can't happen, but silences warning } @@ -842,7 +842,7 @@ Ref<Texture2D> ParticlesMaterial::get_param_texture(Parameter p_param) const { void ParticlesMaterial::set_color(const Color &p_color) { - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->color, p_color); color = p_color; } @@ -854,7 +854,7 @@ Color ParticlesMaterial::get_color() const { void ParticlesMaterial::set_color_ramp(const Ref<Texture2D> &p_texture) { color_ramp = p_texture; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture); _queue_shader_change(); _change_notify(); } @@ -888,38 +888,38 @@ void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) { void ParticlesMaterial::set_emission_sphere_radius(float p_radius) { emission_sphere_radius = p_radius; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_sphere_radius, p_radius); } void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) { emission_box_extents = p_extents; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents); } void ParticlesMaterial::set_emission_point_texture(const Ref<Texture2D> &p_points) { emission_point_texture = p_points; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points); } void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture2D> &p_normals) { emission_normal_texture = p_normals; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals); } void ParticlesMaterial::set_emission_color_texture(const Ref<Texture2D> &p_colors) { emission_color_texture = p_colors; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors); _queue_shader_change(); } void ParticlesMaterial::set_emission_point_count(int p_count) { emission_point_count = p_count; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_point_count, p_count); } ParticlesMaterial::EmissionShape ParticlesMaterial::get_emission_shape() const { @@ -957,7 +957,7 @@ int ParticlesMaterial::get_emission_point_count() const { void ParticlesMaterial::set_trail_divisor(int p_divisor) { trail_divisor = p_divisor; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_divisor, p_divisor); } int ParticlesMaterial::get_trail_divisor() const { @@ -974,7 +974,7 @@ void ParticlesMaterial::set_trail_size_modifier(const Ref<CurveTexture> &p_trail curve->ensure_default_setup(); } - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_size_modifier, curve); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_size_modifier, curve); _queue_shader_change(); } @@ -986,7 +986,7 @@ Ref<CurveTexture> ParticlesMaterial::get_trail_size_modifier() const { void ParticlesMaterial::set_trail_color_modifier(const Ref<GradientTexture> &p_trail_color_modifier) { trail_color_modifier = p_trail_color_modifier; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->trail_color_modifier, p_trail_color_modifier); _queue_shader_change(); } @@ -1002,7 +1002,7 @@ void ParticlesMaterial::set_gravity(const Vector3 &p_gravity) { if (gset == Vector3()) { gset = Vector3(0, -0.000001, 0); //as gravity is used as upvector in some calculations } - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->gravity, gset); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->gravity, gset); } Vector3 ParticlesMaterial::get_gravity() const { @@ -1013,7 +1013,7 @@ Vector3 ParticlesMaterial::get_gravity() const { void ParticlesMaterial::set_lifetime_randomness(float p_lifetime) { lifetime_randomness = p_lifetime; - VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->lifetime_randomness, lifetime_randomness); + RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->lifetime_randomness, lifetime_randomness); } float ParticlesMaterial::get_lifetime_randomness() const { @@ -1280,10 +1280,10 @@ ParticlesMaterial::~ParticlesMaterial() { shader_map[current_key].users--; if (shader_map[current_key].users == 0) { //deallocate shader, as it's no longer in use - VS::get_singleton()->free(shader_map[current_key].shader); + RS::get_singleton()->free(shader_map[current_key].shader); shader_map.erase(current_key); } - VS::get_singleton()->material_set_shader(_get_material(), RID()); + RS::get_singleton()->material_set_shader(_get_material(), RID()); } } diff --git a/scene/resources/physics_material.h b/scene/resources/physics_material.h index 2f7f4424b2..f4a77d9854 100644 --- a/scene/resources/physics_material.h +++ b/scene/resources/physics_material.h @@ -32,7 +32,7 @@ #define physics_material_override_H #include "core/resource.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" class PhysicsMaterial : public Resource { diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index eff0721cef..c3daedf918 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -42,7 +42,7 @@ bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const { Vector2 a = points[e.points[0]].pos; Vector2 b = points[e.points[1]].pos; - if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, nullptr)) { crosses++; } } @@ -119,7 +119,7 @@ void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int> Vector2 a = points[e.points[0]].pos; Vector2 b = points[e.points[1]].pos; - if (Geometry::segment_intersects_segment_2d(a, b, from, to, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) { valid = false; break; } @@ -209,7 +209,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector Vector2 a = points[e.points[0]].pos; Vector2 b = points[e.points[1]].pos; - if (Geometry::segment_intersects_segment_2d(a, b, from, to, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, from, to, nullptr)) { can_see_eachother = false; break; } @@ -268,7 +268,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector e.points[0] != ignore_from_edge.points[0] && e.points[1] != ignore_from_edge.points[0]) { - if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, nullptr)) { valid_a = false; } } @@ -281,7 +281,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector e.points[0] != ignore_to_edge.points[0] && e.points[1] != ignore_to_edge.points[0]) { - if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, NULL)) { + if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, nullptr)) { valid_b = false; } } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 959ee214a2..46e8575018 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "primitive_meshes.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" /** PrimitiveMesh @@ -37,10 +37,10 @@ void PrimitiveMesh::_update() const { Array arr; - arr.resize(VS::ARRAY_MAX); + arr.resize(RS::ARRAY_MAX); _create_mesh_array(arr); - Vector<Vector3> points = arr[VS::ARRAY_VERTEX]; + Vector<Vector3> points = arr[RS::ARRAY_VERTEX]; aabb = AABB(); @@ -57,10 +57,10 @@ void PrimitiveMesh::_update() const { } } - Vector<int> indices = arr[VS::ARRAY_INDEX]; + Vector<int> indices = arr[RS::ARRAY_INDEX]; if (flip_faces) { - Vector<Vector3> normals = arr[VS::ARRAY_NORMAL]; + Vector<Vector3> normals = arr[RS::ARRAY_NORMAL]; if (normals.size() && indices.size()) { @@ -79,17 +79,17 @@ void PrimitiveMesh::_update() const { SWAP(w[i + 0], w[i + 1]); } } - arr[VS::ARRAY_NORMAL] = normals; - arr[VS::ARRAY_INDEX] = indices; + arr[RS::ARRAY_NORMAL] = normals; + arr[RS::ARRAY_INDEX] = indices; } } array_len = pc; index_array_len = indices.size(); // in with the new - VisualServer::get_singleton()->mesh_clear(mesh); - VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh, (VisualServer::PrimitiveType)primitive_type, arr); - VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid()); + RenderingServer::get_singleton()->mesh_clear(mesh); + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh, (RenderingServer::PrimitiveType)primitive_type, arr); + RenderingServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid()); pending_request = false; @@ -136,7 +136,7 @@ Array PrimitiveMesh::surface_get_arrays(int p_surface) const { _update(); } - return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh, 0); + return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, 0); } Dictionary PrimitiveMesh::surface_get_lods(int p_surface) const { @@ -150,7 +150,7 @@ Array PrimitiveMesh::surface_get_blend_shape_arrays(int p_surface) const { uint32_t PrimitiveMesh::surface_get_format(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, 1, 0); - return VS::ARRAY_FORMAT_VERTEX | VS::ARRAY_FORMAT_NORMAL | VS::ARRAY_FORMAT_TANGENT | VS::ARRAY_FORMAT_TEX_UV | VS::ARRAY_FORMAT_INDEX | VS::ARRAY_COMPRESS_DEFAULT; + return RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL | RS::ARRAY_FORMAT_TANGENT | RS::ARRAY_FORMAT_TEX_UV | RS::ARRAY_FORMAT_INDEX | RS::ARRAY_COMPRESS_DEFAULT; } Mesh::PrimitiveType PrimitiveMesh::surface_get_primitive_type(int p_idx) const { @@ -164,7 +164,7 @@ void PrimitiveMesh::surface_set_material(int p_idx, const Ref<Material> &p_mater } Ref<Material> PrimitiveMesh::surface_get_material(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, 1, NULL); + ERR_FAIL_INDEX_V(p_idx, 1, nullptr); return material; } @@ -215,7 +215,7 @@ void PrimitiveMesh::set_material(const Ref<Material> &p_material) { material = p_material; if (!pending_request) { // just apply it, else it'll happen when _update is called. - VisualServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid()); + RenderingServer::get_singleton()->mesh_surface_set_material(mesh, 0, material.is_null() ? RID() : material->get_rid()); _change_notify(); emit_changed(); }; @@ -232,7 +232,7 @@ Array PrimitiveMesh::get_mesh_arrays() const { void PrimitiveMesh::set_custom_aabb(const AABB &p_custom) { custom_aabb = p_custom; - VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); + RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); emit_changed(); } @@ -254,7 +254,7 @@ PrimitiveMesh::PrimitiveMesh() { flip_faces = false; // defaults - mesh = VisualServer::get_singleton()->mesh_create(); + mesh = RenderingServer::get_singleton()->mesh_create(); // assume primitive triangles as the type, correct for all but one and it will change this :) primitive_type = Mesh::PRIMITIVE_TRIANGLES; @@ -267,7 +267,7 @@ PrimitiveMesh::PrimitiveMesh() { } PrimitiveMesh::~PrimitiveMesh() { - VisualServer::get_singleton()->free(mesh); + RenderingServer::get_singleton()->free(mesh); } /** @@ -413,11 +413,11 @@ void CapsuleMesh::_create_mesh_array(Array &p_arr) const { thisrow = point; }; - p_arr[VS::ARRAY_VERTEX] = points; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; - p_arr[VS::ARRAY_INDEX] = indices; + p_arr[RS::ARRAY_VERTEX] = points; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_INDEX] = indices; } void CapsuleMesh::_bind_methods() { @@ -670,11 +670,11 @@ void CubeMesh::_create_mesh_array(Array &p_arr) const { thisrow = point; }; - p_arr[VS::ARRAY_VERTEX] = points; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; - p_arr[VS::ARRAY_INDEX] = indices; + p_arr[RS::ARRAY_VERTEX] = points; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_INDEX] = indices; } void CubeMesh::_bind_methods() { @@ -871,11 +871,11 @@ void CylinderMesh::_create_mesh_array(Array &p_arr) const { }; }; - p_arr[VS::ARRAY_VERTEX] = points; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; - p_arr[VS::ARRAY_INDEX] = indices; + p_arr[RS::ARRAY_VERTEX] = points; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_INDEX] = indices; } void CylinderMesh::_bind_methods() { @@ -1010,11 +1010,11 @@ void PlaneMesh::_create_mesh_array(Array &p_arr) const { thisrow = point; }; - p_arr[VS::ARRAY_VERTEX] = points; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; - p_arr[VS::ARRAY_INDEX] = indices; + p_arr[RS::ARRAY_VERTEX] = points; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_INDEX] = indices; } void PlaneMesh::_bind_methods() { @@ -1270,11 +1270,11 @@ void PrismMesh::_create_mesh_array(Array &p_arr) const { thisrow = point; }; - p_arr[VS::ARRAY_VERTEX] = points; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; - p_arr[VS::ARRAY_INDEX] = indices; + p_arr[RS::ARRAY_VERTEX] = points; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_INDEX] = indices; } void PrismMesh::_bind_methods() { @@ -1401,10 +1401,10 @@ void QuadMesh::_create_mesh_array(Array &p_arr) const { uvs.set(i, quad_uv[j]); } - p_arr[VS::ARRAY_VERTEX] = faces; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_VERTEX] = faces; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; } void QuadMesh::_bind_methods() { @@ -1494,11 +1494,11 @@ void SphereMesh::_create_mesh_array(Array &p_arr) const { thisrow = point; }; - p_arr[VS::ARRAY_VERTEX] = points; - p_arr[VS::ARRAY_NORMAL] = normals; - p_arr[VS::ARRAY_TANGENT] = tangents; - p_arr[VS::ARRAY_TEX_UV] = uvs; - p_arr[VS::ARRAY_INDEX] = indices; + p_arr[RS::ARRAY_VERTEX] = points; + p_arr[RS::ARRAY_NORMAL] = normals; + p_arr[RS::ARRAY_TANGENT] = tangents; + p_arr[RS::ARRAY_TEX_UV] = uvs; + p_arr[RS::ARRAY_INDEX] = indices; } void SphereMesh::_bind_methods() { @@ -1585,7 +1585,7 @@ void PointMesh::_create_mesh_array(Array &p_arr) const { faces.resize(1); faces.set(0, Vector3(0.0, 0.0, 0.0)); - p_arr[VS::ARRAY_VERTEX] = faces; + p_arr[RS::ARRAY_VERTEX] = faces; } PointMesh::PointMesh() { diff --git a/scene/resources/ray_shape_3d.cpp b/scene/resources/ray_shape_3d.cpp index ad927afd58..0211c55f46 100644 --- a/scene/resources/ray_shape_3d.cpp +++ b/scene/resources/ray_shape_3d.cpp @@ -30,7 +30,7 @@ #include "ray_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> RayShape3D::get_debug_mesh_lines() { @@ -50,7 +50,7 @@ void RayShape3D::_update_shape() { Dictionary d; d["length"] = length; d["slips_on_slope"] = slips_on_slope; - PhysicsServer::get_singleton()->shape_set_data(get_shape(), d); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), d); Shape3D::_update_shape(); } @@ -92,7 +92,7 @@ void RayShape3D::_bind_methods() { } RayShape3D::RayShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_RAY)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_RAY)) { length = 1.0; slips_on_slope = false; diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index f8c8ffb289..19e72a65b0 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -30,11 +30,11 @@ #include "rectangle_shape_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" void RectangleShape2D::_update_shape() { - Physics2DServer::get_singleton()->shape_set_data(get_rid(), extents); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), extents); emit_changed(); } @@ -51,7 +51,7 @@ Vector2 RectangleShape2D::get_extents() const { void RectangleShape2D::draw(const RID &p_to_rid, const Color &p_color) { - VisualServer::get_singleton()->canvas_item_add_rect(p_to_rid, Rect2(-extents, extents * 2.0), p_color); + RenderingServer::get_singleton()->canvas_item_add_rect(p_to_rid, Rect2(-extents, extents * 2.0), p_color); } Rect2 RectangleShape2D::get_rect() const { @@ -72,7 +72,7 @@ void RectangleShape2D::_bind_methods() { } RectangleShape2D::RectangleShape2D() : - Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->rectangle_shape_create()) { extents = Vector2(10, 10); _update_shape(); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 238bdf05ef..5068bb548f 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -795,7 +795,7 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p ignore_resource_parsing = true; //FileAccess - FileAccess *fw = NULL; + FileAccess *fw = nullptr; String base_path = local_path.get_base_dir(); @@ -961,7 +961,7 @@ void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) { rp.ext_func = _parse_ext_resources; rp.sub_func = _parse_sub_resources; - rp.func = NULL; + rp.func = nullptr; rp.userdata = this; } @@ -1392,7 +1392,7 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const return loader.rename_dependencies(f, p_path, p_map); } -ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = NULL; +ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = nullptr; Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path, const String &p_dst_path) { @@ -1674,7 +1674,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r RES res = E->get(); ERR_CONTINUE(!resource_set.has(res)); - bool main = (E->next() == NULL); + bool main = (E->next() == nullptr); if (main && packed_scene.is_valid()) break; //save as a scene @@ -1880,7 +1880,7 @@ void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, L p_extensions->push_back("tres"); //text resource } -ResourceFormatSaverText *ResourceFormatSaverText::singleton = NULL; +ResourceFormatSaverText *ResourceFormatSaverText::singleton = nullptr; ResourceFormatSaverText::ResourceFormatSaverText() { singleton = this; } diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index 2425ac7f6c..fbbd2e3346 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -134,7 +134,7 @@ public: class ResourceFormatLoaderText : public ResourceFormatLoader { public: static ResourceFormatLoaderText *singleton; - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index 2e78a4fccf..814c349784 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -30,8 +30,8 @@ #include "segment_shape_2d.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" bool SegmentShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const { @@ -45,7 +45,7 @@ void SegmentShape2D::_update_shape() { Rect2 r; r.position = a; r.size = b; - Physics2DServer::get_singleton()->shape_set_data(get_rid(), r); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), r); emit_changed(); } @@ -71,7 +71,7 @@ Vector2 SegmentShape2D::get_b() const { void SegmentShape2D::draw(const RID &p_to_rid, const Color &p_color) { - VisualServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3); + RenderingServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3); } Rect2 SegmentShape2D::get_rect() const { @@ -99,7 +99,7 @@ void SegmentShape2D::_bind_methods() { } SegmentShape2D::SegmentShape2D() : - Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->segment_shape_create()) { a = Vector2(); b = Vector2(0, 10); @@ -113,14 +113,14 @@ void RayShape2D::_update_shape() { Dictionary d; d["length"] = length; d["slips_on_slope"] = slips_on_slope; - Physics2DServer::get_singleton()->shape_set_data(get_rid(), d); + PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), d); emit_changed(); } void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) { Vector2 tip = Vector2(0, get_length()); - VS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3); + RS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3); Vector<Vector2> pts; float tsize = 4; pts.push_back(tip + Vector2(0, tsize)); @@ -130,7 +130,7 @@ void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) { for (int i = 0; i < 3; i++) cols.push_back(p_color); - VS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID()); + RS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID()); } Rect2 RayShape2D::get_rect() const { @@ -179,7 +179,7 @@ bool RayShape2D::get_slips_on_slope() const { } RayShape2D::RayShape2D() : - Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) { + Shape2D(PhysicsServer2D::get_singleton()->ray_shape_create()) { length = 20; slips_on_slope = false; diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 47f6d673ae..a62e7ded16 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -31,8 +31,8 @@ #include "shader.h" #include "core/os/file_access.h" #include "scene/scene_string_names.h" -#include "servers/visual/shader_language.h" -#include "servers/visual_server.h" +#include "servers/rendering/shader_language.h" +#include "servers/rendering_server.h" #include "texture.h" Shader::Mode Shader::get_mode() const { @@ -54,7 +54,7 @@ void Shader::set_code(const String &p_code) { mode = MODE_SPATIAL; } - VisualServer::get_singleton()->shader_set_code(shader, p_code); + RenderingServer::get_singleton()->shader_set_code(shader, p_code); params_cache_dirty = true; emit_changed(); @@ -63,7 +63,7 @@ void Shader::set_code(const String &p_code) { String Shader::get_code() const { _update_shader(); - return VisualServer::get_singleton()->shader_get_code(shader); + return RenderingServer::get_singleton()->shader_get_code(shader); } void Shader::get_param_list(List<PropertyInfo> *p_params) const { @@ -71,7 +71,7 @@ void Shader::get_param_list(List<PropertyInfo> *p_params) const { _update_shader(); List<PropertyInfo> local; - VisualServer::get_singleton()->shader_get_param_list(shader, &local); + RenderingServer::get_singleton()->shader_get_param_list(shader, &local); params_cache.clear(); params_cache_dirty = false; @@ -104,10 +104,10 @@ void Shader::set_default_texture_param(const StringName &p_param, const Ref<Text if (p_texture.is_valid()) { default_textures[p_param] = p_texture; - VS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid()); + RS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid()); } else { default_textures.erase(p_param); - VS::get_singleton()->shader_set_default_texture_param(shader, p_param, RID()); + RS::get_singleton()->shader_set_default_texture_param(shader, p_param, RID()); } emit_changed(); @@ -166,13 +166,13 @@ void Shader::_bind_methods() { Shader::Shader() { mode = MODE_SPATIAL; - shader = VisualServer::get_singleton()->shader_create(); + shader = RenderingServer::get_singleton()->shader_create(); params_cache_dirty = true; } Shader::~Shader() { - VisualServer::get_singleton()->free(shader); + RenderingServer::get_singleton()->free(shader); } //////////// diff --git a/scene/resources/shader.h b/scene/resources/shader.h index 5804fe8fef..cf0cec362c 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -56,7 +56,7 @@ private: Mode mode; // hack the name of performance - // shaders keep a list of ShaderMaterial -> VisualServer name translations, to make + // shaders keep a list of ShaderMaterial -> RenderingServer name translations, to make // conversion fast and save memory. mutable bool params_cache_dirty; mutable Map<StringName, StringName> params_cache; //map a shader param to a material param.. @@ -84,7 +84,7 @@ public: _FORCE_INLINE_ StringName remap_param(const StringName &p_param) const { if (params_cache_dirty) - get_param_list(NULL); + get_param_list(nullptr); const Map<StringName, StringName>::Element *E = params_cache.find(p_param); if (E) @@ -102,7 +102,7 @@ VARIANT_ENUM_CAST(Shader::Mode); class ResourceFormatLoaderShader : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp index 64930c3117..4fe585053a 100644 --- a/scene/resources/shape_2d.cpp +++ b/scene/resources/shape_2d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "shape_2d.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" RID Shape2D::get_rid() const { return shape; @@ -38,7 +38,7 @@ RID Shape2D::get_rid() const { void Shape2D::set_custom_solver_bias(real_t p_bias) { custom_bias = p_bias; - Physics2DServer::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias); + PhysicsServer2D::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias); } real_t Shape2D::get_custom_solver_bias() const { @@ -50,13 +50,13 @@ bool Shape2D::collide_with_motion(const Transform2D &p_local_xform, const Vector ERR_FAIL_COND_V(p_shape.is_null(), false); int r; - return Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, NULL, 0, r); + return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, nullptr, 0, r); } bool Shape2D::collide(const Transform2D &p_local_xform, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform) { ERR_FAIL_COND_V(p_shape.is_null(), false); int r; - return Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), NULL, 0, r); + return PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), nullptr, 0, r); } Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Transform2D &p_shape_xform, const Vector2 &p_shape_motion) { @@ -66,7 +66,7 @@ Array Shape2D::collide_with_motion_and_get_contacts(const Transform2D &p_local_x Vector2 result[max_contacts * 2]; int contacts = 0; - if (!Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts)) + if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts)) return Array(); Array results; @@ -84,7 +84,7 @@ Array Shape2D::collide_and_get_contacts(const Transform2D &p_local_xform, const Vector2 result[max_contacts * 2]; int contacts = 0; - if (!Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts)) + if (!PhysicsServer2D::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts)) return Array(); Array results; @@ -115,5 +115,5 @@ Shape2D::Shape2D(const RID &p_rid) { Shape2D::~Shape2D() { - Physics2DServer::get_singleton()->free(shape); + PhysicsServer2D::get_singleton()->free(shape); } diff --git a/scene/resources/shape_3d.cpp b/scene/resources/shape_3d.cpp index c3aeba857a..f4a5d91e52 100644 --- a/scene/resources/shape_3d.cpp +++ b/scene/resources/shape_3d.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "scene/main/scene_tree.h" #include "scene/resources/mesh.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" void Shape3D::add_vertices_to_array(Vector<Vector3> &array, const Transform &p_xform) { @@ -56,7 +56,7 @@ real_t Shape3D::get_margin() const { void Shape3D::set_margin(real_t p_margin) { margin = p_margin; - PhysicsServer::get_singleton()->shape_set_margin(shape, margin); + PhysicsServer3D::get_singleton()->shape_set_margin(shape, margin); } Ref<ArrayMesh> Shape3D::get_debug_mesh() { @@ -123,5 +123,5 @@ Shape3D::Shape3D(RID p_shape) : Shape3D::~Shape3D() { - PhysicsServer::get_singleton()->free(shape); + PhysicsServer3D::get_singleton()->free(shape); } diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp index 1185b693b7..cbe86b16b2 100644 --- a/scene/resources/sky.cpp +++ b/scene/resources/sky.cpp @@ -39,7 +39,7 @@ void Sky::set_radiance_size(RadianceSize p_size) { static const int size[RADIANCE_SIZE_MAX] = { 32, 64, 128, 256, 512, 1024, 2048 }; - VS::get_singleton()->sky_set_radiance_size(sky, size[radiance_size]); + RS::get_singleton()->sky_set_radiance_size(sky, size[radiance_size]); } Sky::RadianceSize Sky::get_radiance_size() const { @@ -49,7 +49,7 @@ Sky::RadianceSize Sky::get_radiance_size() const { void Sky::set_process_mode(ProcessMode p_mode) { mode = p_mode; - VS::get_singleton()->sky_set_mode(sky, VS::SkyMode(mode)); + RS::get_singleton()->sky_set_mode(sky, RS::SkyMode(mode)); } Sky::ProcessMode Sky::get_process_mode() const { @@ -61,7 +61,7 @@ void Sky::set_material(const Ref<Material> &p_material) { RID material_rid; if (sky_material.is_valid()) material_rid = sky_material->get_rid(); - VS::get_singleton()->sky_set_material(sky, material_rid); + RS::get_singleton()->sky_set_material(sky, material_rid); } Ref<Material> Sky::get_material() const { @@ -104,10 +104,10 @@ void Sky::_bind_methods() { Sky::Sky() { mode = PROCESS_MODE_QUALITY; radiance_size = RADIANCE_SIZE_256; - sky = VS::get_singleton()->sky_create(); + sky = RS::get_singleton()->sky_create(); } Sky::~Sky() { - VS::get_singleton()->free(sky); + RS::get_singleton()->free(sky); }
\ No newline at end of file diff --git a/scene/resources/sky_material.cpp b/scene/resources/sky_material.cpp index c3e51460c6..37b88cccea 100644 --- a/scene/resources/sky_material.cpp +++ b/scene/resources/sky_material.cpp @@ -6,7 +6,7 @@ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -33,7 +33,7 @@ void ProceduralSkyMaterial::set_sky_top_color(const Color &p_sky_top) { sky_top_color = p_sky_top; - VS::get_singleton()->material_set_param(_get_material(), "sky_top_color", sky_top_color.to_linear()); + RS::get_singleton()->material_set_param(_get_material(), "sky_top_color", sky_top_color.to_linear()); } Color ProceduralSkyMaterial::get_sky_top_color() const { @@ -44,7 +44,7 @@ Color ProceduralSkyMaterial::get_sky_top_color() const { void ProceduralSkyMaterial::set_sky_horizon_color(const Color &p_sky_horizon) { sky_horizon_color = p_sky_horizon; - VS::get_singleton()->material_set_param(_get_material(), "sky_horizon_color", sky_horizon_color.to_linear()); + RS::get_singleton()->material_set_param(_get_material(), "sky_horizon_color", sky_horizon_color.to_linear()); } Color ProceduralSkyMaterial::get_sky_horizon_color() const { @@ -54,7 +54,7 @@ Color ProceduralSkyMaterial::get_sky_horizon_color() const { void ProceduralSkyMaterial::set_sky_curve(float p_curve) { sky_curve = p_curve; - VS::get_singleton()->material_set_param(_get_material(), "sky_curve", sky_curve); + RS::get_singleton()->material_set_param(_get_material(), "sky_curve", sky_curve); } float ProceduralSkyMaterial::get_sky_curve() const { @@ -64,7 +64,7 @@ float ProceduralSkyMaterial::get_sky_curve() const { void ProceduralSkyMaterial::set_sky_energy(float p_energy) { sky_energy = p_energy; - VS::get_singleton()->material_set_param(_get_material(), "sky_energy", sky_energy); + RS::get_singleton()->material_set_param(_get_material(), "sky_energy", sky_energy); } float ProceduralSkyMaterial::get_sky_energy() const { @@ -74,7 +74,7 @@ float ProceduralSkyMaterial::get_sky_energy() const { void ProceduralSkyMaterial::set_ground_bottom_color(const Color &p_ground_bottom) { ground_bottom_color = p_ground_bottom; - VS::get_singleton()->material_set_param(_get_material(), "ground_bottom_color", ground_bottom_color.to_linear()); + RS::get_singleton()->material_set_param(_get_material(), "ground_bottom_color", ground_bottom_color.to_linear()); } Color ProceduralSkyMaterial::get_ground_bottom_color() const { @@ -84,7 +84,7 @@ Color ProceduralSkyMaterial::get_ground_bottom_color() const { void ProceduralSkyMaterial::set_ground_horizon_color(const Color &p_ground_horizon) { ground_horizon_color = p_ground_horizon; - VS::get_singleton()->material_set_param(_get_material(), "ground_horizon_color", ground_horizon_color.to_linear()); + RS::get_singleton()->material_set_param(_get_material(), "ground_horizon_color", ground_horizon_color.to_linear()); } Color ProceduralSkyMaterial::get_ground_horizon_color() const { @@ -94,7 +94,7 @@ Color ProceduralSkyMaterial::get_ground_horizon_color() const { void ProceduralSkyMaterial::set_ground_curve(float p_curve) { ground_curve = p_curve; - VS::get_singleton()->material_set_param(_get_material(), "ground_curve", ground_curve); + RS::get_singleton()->material_set_param(_get_material(), "ground_curve", ground_curve); } float ProceduralSkyMaterial::get_ground_curve() const { @@ -104,7 +104,7 @@ float ProceduralSkyMaterial::get_ground_curve() const { void ProceduralSkyMaterial::set_ground_energy(float p_energy) { ground_energy = p_energy; - VS::get_singleton()->material_set_param(_get_material(), "ground_energy", ground_energy); + RS::get_singleton()->material_set_param(_get_material(), "ground_energy", ground_energy); } float ProceduralSkyMaterial::get_ground_energy() const { @@ -114,7 +114,7 @@ float ProceduralSkyMaterial::get_ground_energy() const { void ProceduralSkyMaterial::set_sun_angle_min(float p_angle) { sun_angle_min = p_angle; - VS::get_singleton()->material_set_param(_get_material(), "sun_angle_min", Math::deg2rad(sun_angle_min)); + RS::get_singleton()->material_set_param(_get_material(), "sun_angle_min", Math::deg2rad(sun_angle_min)); } float ProceduralSkyMaterial::get_sun_angle_min() const { @@ -124,7 +124,7 @@ float ProceduralSkyMaterial::get_sun_angle_min() const { void ProceduralSkyMaterial::set_sun_angle_max(float p_angle) { sun_angle_max = p_angle; - VS::get_singleton()->material_set_param(_get_material(), "sun_angle_max", Math::deg2rad(sun_angle_max)); + RS::get_singleton()->material_set_param(_get_material(), "sun_angle_max", Math::deg2rad(sun_angle_max)); } float ProceduralSkyMaterial::get_sun_angle_max() const { @@ -134,7 +134,7 @@ float ProceduralSkyMaterial::get_sun_angle_max() const { void ProceduralSkyMaterial::set_sun_curve(float p_curve) { sun_curve = p_curve; - VS::get_singleton()->material_set_param(_get_material(), "sun_curve", sun_curve); + RS::get_singleton()->material_set_param(_get_material(), "sun_curve", sun_curve); } float ProceduralSkyMaterial::get_sun_curve() const { @@ -271,11 +271,11 @@ ProceduralSkyMaterial::ProceduralSkyMaterial() { code += "\tCOLOR = mix(ground, sky, step(0.0, EYEDIR.y));\n"; code += "}\n"; - shader = VS::get_singleton()->shader_create(); + shader = RS::get_singleton()->shader_create(); - VS::get_singleton()->shader_set_code(shader, code); + RS::get_singleton()->shader_set_code(shader, code); - VS::get_singleton()->material_set_shader(_get_material(), shader); + RS::get_singleton()->material_set_shader(_get_material(), shader); set_sky_top_color(Color(0.35, 0.46, 0.71)); set_sky_horizon_color(Color(0.55, 0.69, 0.81)); @@ -293,8 +293,8 @@ ProceduralSkyMaterial::ProceduralSkyMaterial() { } ProceduralSkyMaterial::~ProceduralSkyMaterial() { - VS::get_singleton()->free(shader); - VS::get_singleton()->material_set_shader(_get_material(), RID()); + RS::get_singleton()->free(shader); + RS::get_singleton()->material_set_shader(_get_material(), RID()); } ///////////////////////////////////////// @@ -303,7 +303,7 @@ ProceduralSkyMaterial::~ProceduralSkyMaterial() { void PanoramaSkyMaterial::set_panorama(const Ref<Texture2D> &p_panorama) { panorama = p_panorama; - VS::get_singleton()->material_set_param(_get_material(), "source_panorama", panorama); + RS::get_singleton()->material_set_param(_get_material(), "source_panorama", panorama); } Ref<Texture2D> PanoramaSkyMaterial::get_panorama() const { @@ -341,16 +341,16 @@ PanoramaSkyMaterial::PanoramaSkyMaterial() { code += "\tCOLOR = texture(source_panorama, SKY_COORDS).rgb;\n"; code += "}"; - shader = VS::get_singleton()->shader_create(); + shader = RS::get_singleton()->shader_create(); - VS::get_singleton()->shader_set_code(shader, code); + RS::get_singleton()->shader_set_code(shader, code); - VS::get_singleton()->material_set_shader(_get_material(), shader); + RS::get_singleton()->material_set_shader(_get_material(), shader); } PanoramaSkyMaterial::~PanoramaSkyMaterial() { - VS::get_singleton()->free(shader); - VS::get_singleton()->material_set_shader(_get_material(), RID()); + RS::get_singleton()->free(shader); + RS::get_singleton()->material_set_shader(_get_material(), RID()); } ////////////////////////////////// /* PhysicalSkyMaterial */ @@ -358,7 +358,7 @@ PanoramaSkyMaterial::~PanoramaSkyMaterial() { void PhysicalSkyMaterial::set_rayleigh_coefficient(float p_rayleigh) { rayleigh = p_rayleigh; - VS::get_singleton()->material_set_param(_get_material(), "rayleigh", rayleigh); + RS::get_singleton()->material_set_param(_get_material(), "rayleigh", rayleigh); } float PhysicalSkyMaterial::get_rayleigh_coefficient() const { @@ -368,7 +368,7 @@ float PhysicalSkyMaterial::get_rayleigh_coefficient() const { void PhysicalSkyMaterial::set_rayleigh_color(Color p_rayleigh_color) { rayleigh_color = p_rayleigh_color; - VS::get_singleton()->material_set_param(_get_material(), "rayleigh_color", rayleigh_color); + RS::get_singleton()->material_set_param(_get_material(), "rayleigh_color", rayleigh_color); } Color PhysicalSkyMaterial::get_rayleigh_color() const { @@ -378,7 +378,7 @@ Color PhysicalSkyMaterial::get_rayleigh_color() const { void PhysicalSkyMaterial::set_mie_coefficient(float p_mie) { mie = p_mie; - VS::get_singleton()->material_set_param(_get_material(), "mie", mie); + RS::get_singleton()->material_set_param(_get_material(), "mie", mie); } float PhysicalSkyMaterial::get_mie_coefficient() const { @@ -388,7 +388,7 @@ float PhysicalSkyMaterial::get_mie_coefficient() const { void PhysicalSkyMaterial::set_mie_eccentricity(float p_eccentricity) { mie_eccentricity = p_eccentricity; - VS::get_singleton()->material_set_param(_get_material(), "mie_eccentricity", mie_eccentricity); + RS::get_singleton()->material_set_param(_get_material(), "mie_eccentricity", mie_eccentricity); } float PhysicalSkyMaterial::get_mie_eccentricity() const { @@ -398,7 +398,7 @@ float PhysicalSkyMaterial::get_mie_eccentricity() const { void PhysicalSkyMaterial::set_mie_color(Color p_mie_color) { mie_color = p_mie_color; - VS::get_singleton()->material_set_param(_get_material(), "mie_color", mie_color); + RS::get_singleton()->material_set_param(_get_material(), "mie_color", mie_color); } Color PhysicalSkyMaterial::get_mie_color() const { return mie_color; @@ -407,7 +407,7 @@ Color PhysicalSkyMaterial::get_mie_color() const { void PhysicalSkyMaterial::set_turbidity(float p_turbidity) { turbidity = p_turbidity; - VS::get_singleton()->material_set_param(_get_material(), "turbidity", turbidity); + RS::get_singleton()->material_set_param(_get_material(), "turbidity", turbidity); } float PhysicalSkyMaterial::get_turbidity() const { @@ -417,7 +417,7 @@ float PhysicalSkyMaterial::get_turbidity() const { void PhysicalSkyMaterial::set_sun_disk_scale(float p_sun_disk_scale) { sun_disk_scale = p_sun_disk_scale; - VS::get_singleton()->material_set_param(_get_material(), "sun_disk_scale", sun_disk_scale); + RS::get_singleton()->material_set_param(_get_material(), "sun_disk_scale", sun_disk_scale); } float PhysicalSkyMaterial::get_sun_disk_scale() const { @@ -427,7 +427,7 @@ float PhysicalSkyMaterial::get_sun_disk_scale() const { void PhysicalSkyMaterial::set_ground_color(Color p_ground_color) { ground_color = p_ground_color; - VS::get_singleton()->material_set_param(_get_material(), "ground_color", ground_color); + RS::get_singleton()->material_set_param(_get_material(), "ground_color", ground_color); } Color PhysicalSkyMaterial::get_ground_color() const { @@ -437,7 +437,7 @@ Color PhysicalSkyMaterial::get_ground_color() const { void PhysicalSkyMaterial::set_exposure(float p_exposure) { exposure = p_exposure; - VS::get_singleton()->material_set_param(_get_material(), "exposure", exposure); + RS::get_singleton()->material_set_param(_get_material(), "exposure", exposure); } float PhysicalSkyMaterial::get_exposure() const { @@ -447,7 +447,7 @@ float PhysicalSkyMaterial::get_exposure() const { void PhysicalSkyMaterial::set_dither_strength(float p_dither_strength) { dither_strength = p_dither_strength; - VS::get_singleton()->material_set_param(_get_material(), "dither_strength", dither_strength); + RS::get_singleton()->material_set_param(_get_material(), "dither_strength", dither_strength); } float PhysicalSkyMaterial::get_dither_strength() const { @@ -604,11 +604,11 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() { code += "\tCOLOR += (hash(EYEDIR * 1741.9782) * 0.08 - 0.04) * 0.008 * dither_strength;\n"; code += "}\n"; - shader = VS::get_singleton()->shader_create(); + shader = RS::get_singleton()->shader_create(); - VS::get_singleton()->shader_set_code(shader, code); + RS::get_singleton()->shader_set_code(shader, code); - VS::get_singleton()->material_set_shader(_get_material(), shader); + RS::get_singleton()->material_set_shader(_get_material(), shader); set_rayleigh_coefficient(2.0); set_rayleigh_color(Color(0.056, 0.14, 0.3)); @@ -623,6 +623,6 @@ PhysicalSkyMaterial::PhysicalSkyMaterial() { } PhysicalSkyMaterial::~PhysicalSkyMaterial() { - VS::get_singleton()->free(shader); - VS::get_singleton()->material_set_shader(_get_material(), RID()); + RS::get_singleton()->free(shader); + RS::get_singleton()->material_set_shader(_get_material(), RID()); } diff --git a/scene/resources/sky_material.h b/scene/resources/sky_material.h index 2d0a62e0f6..515706b0c5 100644 --- a/scene/resources/sky_material.h +++ b/scene/resources/sky_material.h @@ -6,7 +6,7 @@ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/scene/resources/sphere_shape_3d.cpp b/scene/resources/sphere_shape_3d.cpp index 46f7c96ce1..153db4c291 100644 --- a/scene/resources/sphere_shape_3d.cpp +++ b/scene/resources/sphere_shape_3d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "sphere_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> SphereShape3D::get_debug_mesh_lines() { @@ -61,7 +61,7 @@ real_t SphereShape3D::get_enclosing_radius() const { void SphereShape3D::_update_shape() { - PhysicsServer::get_singleton()->shape_set_data(get_shape(), radius); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), radius); Shape3D::_update_shape(); } @@ -87,7 +87,7 @@ void SphereShape3D::_bind_methods() { } SphereShape3D::SphereShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_SPHERE)) { set_radius(1.0); } diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 0cd2bed71d..56fb5d441f 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -202,7 +202,7 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const { if (normal_map.is_valid()) normal_rid = normal_map->get_rid(); - VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NinePatchAxisMode(axis_h), VS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid); + RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid); } void StyleBoxTexture::set_draw_center(bool p_enabled) { @@ -853,7 +853,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { } //DRAWING - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors, uvs); } @@ -1050,7 +1050,7 @@ Size2 StyleBoxLine::get_center_size() const { } void StyleBoxLine::draw(RID p_canvas_item, const Rect2 &p_rect) const { - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); Rect2i r = p_rect; if (vertical) { diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 1aa1a00c55..f19b93d00d 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -33,7 +33,7 @@ #include "core/resource.h" #include "scene/resources/texture.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class CanvasItem; diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index fa177d03fb..4b392e23b7 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -519,7 +519,7 @@ void SurfaceTool::deindex() { void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) { Array arr = p_existing->surface_get_arrays(p_surface); - ERR_FAIL_COND(arr.size() != VS::ARRAY_MAX); + ERR_FAIL_COND(arr.size() != RS::ARRAY_MAX); _create_list_from_arrays(arr, r_vertex, r_index, lformat); } @@ -527,14 +527,14 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array Vector<SurfaceTool::Vertex> ret; - Vector<Vector3> varr = p_arrays[VS::ARRAY_VERTEX]; - Vector<Vector3> narr = p_arrays[VS::ARRAY_NORMAL]; - Vector<float> tarr = p_arrays[VS::ARRAY_TANGENT]; - Vector<Color> carr = p_arrays[VS::ARRAY_COLOR]; - Vector<Vector2> uvarr = p_arrays[VS::ARRAY_TEX_UV]; - Vector<Vector2> uv2arr = p_arrays[VS::ARRAY_TEX_UV2]; - Vector<int> barr = p_arrays[VS::ARRAY_BONES]; - Vector<float> warr = p_arrays[VS::ARRAY_WEIGHTS]; + Vector<Vector3> varr = p_arrays[RS::ARRAY_VERTEX]; + Vector<Vector3> narr = p_arrays[RS::ARRAY_NORMAL]; + Vector<float> tarr = p_arrays[RS::ARRAY_TANGENT]; + Vector<Color> carr = p_arrays[RS::ARRAY_COLOR]; + Vector<Vector2> uvarr = p_arrays[RS::ARRAY_TEX_UV]; + Vector<Vector2> uv2arr = p_arrays[RS::ARRAY_TEX_UV2]; + Vector<int> barr = p_arrays[RS::ARRAY_BONES]; + Vector<float> warr = p_arrays[RS::ARRAY_WEIGHTS]; int vc = varr.size(); if (vc == 0) @@ -542,48 +542,48 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array int lformat = 0; if (varr.size()) { - lformat |= VS::ARRAY_FORMAT_VERTEX; + lformat |= RS::ARRAY_FORMAT_VERTEX; } if (narr.size()) { - lformat |= VS::ARRAY_FORMAT_NORMAL; + lformat |= RS::ARRAY_FORMAT_NORMAL; } if (tarr.size()) { - lformat |= VS::ARRAY_FORMAT_TANGENT; + lformat |= RS::ARRAY_FORMAT_TANGENT; } if (carr.size()) { - lformat |= VS::ARRAY_FORMAT_COLOR; + lformat |= RS::ARRAY_FORMAT_COLOR; } if (uvarr.size()) { - lformat |= VS::ARRAY_FORMAT_TEX_UV; + lformat |= RS::ARRAY_FORMAT_TEX_UV; } if (uv2arr.size()) { - lformat |= VS::ARRAY_FORMAT_TEX_UV2; + lformat |= RS::ARRAY_FORMAT_TEX_UV2; } if (barr.size()) { - lformat |= VS::ARRAY_FORMAT_BONES; + lformat |= RS::ARRAY_FORMAT_BONES; } if (warr.size()) { - lformat |= VS::ARRAY_FORMAT_WEIGHTS; + lformat |= RS::ARRAY_FORMAT_WEIGHTS; } for (int i = 0; i < vc; i++) { Vertex v; - if (lformat & VS::ARRAY_FORMAT_VERTEX) + if (lformat & RS::ARRAY_FORMAT_VERTEX) v.vertex = varr[i]; - if (lformat & VS::ARRAY_FORMAT_NORMAL) + if (lformat & RS::ARRAY_FORMAT_NORMAL) v.normal = narr[i]; - if (lformat & VS::ARRAY_FORMAT_TANGENT) { + if (lformat & RS::ARRAY_FORMAT_TANGENT) { Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]); v.tangent = p.normal; v.binormal = p.normal.cross(v.tangent).normalized() * p.d; } - if (lformat & VS::ARRAY_FORMAT_COLOR) + if (lformat & RS::ARRAY_FORMAT_COLOR) v.color = carr[i]; - if (lformat & VS::ARRAY_FORMAT_TEX_UV) + if (lformat & RS::ARRAY_FORMAT_TEX_UV) v.uv = uvarr[i]; - if (lformat & VS::ARRAY_FORMAT_TEX_UV2) + if (lformat & RS::ARRAY_FORMAT_TEX_UV2) v.uv2 = uv2arr[i]; - if (lformat & VS::ARRAY_FORMAT_BONES) { + if (lformat & RS::ARRAY_FORMAT_BONES) { Vector<int> b; b.resize(4); b.write[0] = barr[i * 4 + 0]; @@ -592,7 +592,7 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array b.write[3] = barr[i * 4 + 3]; v.bones = b; } - if (lformat & VS::ARRAY_FORMAT_WEIGHTS) { + if (lformat & RS::ARRAY_FORMAT_WEIGHTS) { Vector<float> w; w.resize(4); w.write[0] = warr[i * 4 + 0]; @@ -610,14 +610,14 @@ Vector<SurfaceTool::Vertex> SurfaceTool::create_vertex_array_from_triangle_array void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) { - Vector<Vector3> varr = arr[VS::ARRAY_VERTEX]; - Vector<Vector3> narr = arr[VS::ARRAY_NORMAL]; - Vector<float> tarr = arr[VS::ARRAY_TANGENT]; - Vector<Color> carr = arr[VS::ARRAY_COLOR]; - Vector<Vector2> uvarr = arr[VS::ARRAY_TEX_UV]; - Vector<Vector2> uv2arr = arr[VS::ARRAY_TEX_UV2]; - Vector<int> barr = arr[VS::ARRAY_BONES]; - Vector<float> warr = arr[VS::ARRAY_WEIGHTS]; + Vector<Vector3> varr = arr[RS::ARRAY_VERTEX]; + Vector<Vector3> narr = arr[RS::ARRAY_NORMAL]; + Vector<float> tarr = arr[RS::ARRAY_TANGENT]; + Vector<Color> carr = arr[RS::ARRAY_COLOR]; + Vector<Vector2> uvarr = arr[RS::ARRAY_TEX_UV]; + Vector<Vector2> uv2arr = arr[RS::ARRAY_TEX_UV2]; + Vector<int> barr = arr[RS::ARRAY_BONES]; + Vector<float> warr = arr[RS::ARRAY_WEIGHTS]; int vc = varr.size(); if (vc == 0) @@ -625,48 +625,48 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li lformat = 0; if (varr.size()) { - lformat |= VS::ARRAY_FORMAT_VERTEX; + lformat |= RS::ARRAY_FORMAT_VERTEX; } if (narr.size()) { - lformat |= VS::ARRAY_FORMAT_NORMAL; + lformat |= RS::ARRAY_FORMAT_NORMAL; } if (tarr.size()) { - lformat |= VS::ARRAY_FORMAT_TANGENT; + lformat |= RS::ARRAY_FORMAT_TANGENT; } if (carr.size()) { - lformat |= VS::ARRAY_FORMAT_COLOR; + lformat |= RS::ARRAY_FORMAT_COLOR; } if (uvarr.size()) { - lformat |= VS::ARRAY_FORMAT_TEX_UV; + lformat |= RS::ARRAY_FORMAT_TEX_UV; } if (uv2arr.size()) { - lformat |= VS::ARRAY_FORMAT_TEX_UV2; + lformat |= RS::ARRAY_FORMAT_TEX_UV2; } if (barr.size()) { - lformat |= VS::ARRAY_FORMAT_BONES; + lformat |= RS::ARRAY_FORMAT_BONES; } if (warr.size()) { - lformat |= VS::ARRAY_FORMAT_WEIGHTS; + lformat |= RS::ARRAY_FORMAT_WEIGHTS; } for (int i = 0; i < vc; i++) { Vertex v; - if (lformat & VS::ARRAY_FORMAT_VERTEX) + if (lformat & RS::ARRAY_FORMAT_VERTEX) v.vertex = varr[i]; - if (lformat & VS::ARRAY_FORMAT_NORMAL) + if (lformat & RS::ARRAY_FORMAT_NORMAL) v.normal = narr[i]; - if (lformat & VS::ARRAY_FORMAT_TANGENT) { + if (lformat & RS::ARRAY_FORMAT_TANGENT) { Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]); v.tangent = p.normal; v.binormal = p.normal.cross(v.tangent).normalized() * p.d; } - if (lformat & VS::ARRAY_FORMAT_COLOR) + if (lformat & RS::ARRAY_FORMAT_COLOR) v.color = carr[i]; - if (lformat & VS::ARRAY_FORMAT_TEX_UV) + if (lformat & RS::ARRAY_FORMAT_TEX_UV) v.uv = uvarr[i]; - if (lformat & VS::ARRAY_FORMAT_TEX_UV2) + if (lformat & RS::ARRAY_FORMAT_TEX_UV2) v.uv2 = uv2arr[i]; - if (lformat & VS::ARRAY_FORMAT_BONES) { + if (lformat & RS::ARRAY_FORMAT_BONES) { Vector<int> b; b.resize(4); b.write[0] = barr[i * 4 + 0]; @@ -675,7 +675,7 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li b.write[3] = barr[i * 4 + 3]; v.bones = b; } - if (lformat & VS::ARRAY_FORMAT_WEIGHTS) { + if (lformat & RS::ARRAY_FORMAT_WEIGHTS) { Vector<float> w; w.resize(4); w.write[0] = warr[i * 4 + 0]; @@ -690,11 +690,11 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List<Vertex> *r_vertex, Li //indices - Vector<int> idx = arr[VS::ARRAY_INDEX]; + Vector<int> idx = arr[RS::ARRAY_INDEX]; int is = idx.size(); if (is) { - lformat |= VS::ARRAY_FORMAT_INDEX; + lformat |= RS::ARRAY_FORMAT_INDEX; const int *iarr = idx.ptr(); for (int i = 0; i < is; i++) { r_index->push_back(iarr[i]); @@ -733,7 +733,7 @@ void SurfaceTool::create_from_blend_shape(const Ref<Mesh> &p_existing, int p_sur ERR_FAIL_COND(shape_idx == -1); ERR_FAIL_COND(shape_idx >= arr.size()); Array mesh = arr[shape_idx]; - ERR_FAIL_COND(mesh.size() != VS::ARRAY_MAX); + ERR_FAIL_COND(mesh.size() != RS::ARRAY_MAX); _create_list_from_arrays(arr[shape_idx], &vertex_array, &index_array, format); } @@ -755,10 +755,10 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const Vertex v = E->get(); v.vertex = p_xform.xform(v.vertex); - if (nformat & VS::ARRAY_FORMAT_NORMAL) { + if (nformat & RS::ARRAY_FORMAT_NORMAL) { v.normal = p_xform.basis.xform(v.normal); } - if (nformat & VS::ARRAY_FORMAT_TANGENT) { + if (nformat & RS::ARRAY_FORMAT_TANGENT) { v.tangent = p_xform.basis.xform(v.tangent); v.binormal = p_xform.basis.xform(v.binormal); } @@ -854,7 +854,7 @@ void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, cons const tbool bIsOrientationPreserving, const int iFace, const int iVert) { TangentGenerationContextUserData &triangle_data = *reinterpret_cast<TangentGenerationContextUserData *>(pContext->m_pUserData); - Vertex *vtx = NULL; + Vertex *vtx = nullptr; if (triangle_data.indices.size() > 0) { int index = triangle_data.indices[iFace * 3 + iVert]->get(); if (index < triangle_data.vertices.size()) { @@ -864,7 +864,7 @@ void SurfaceTool::mikktSetTSpaceDefault(const SMikkTSpaceContext *pContext, cons vtx = &triangle_data.vertices[iFace * 3 + iVert]->get(); } - if (vtx != NULL) { + if (vtx != nullptr) { vtx->tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]); vtx->binormal = Vector3(-fvBiTangent[0], -fvBiTangent[1], -fvBiTangent[2]); // for some reason these are reversed, something with the coordinate system in Godot } @@ -882,7 +882,7 @@ void SurfaceTool::generate_tangents() { mkif.m_getPosition = mikktGetPosition; mkif.m_getTexCoord = mikktGetTexCoord; mkif.m_setTSpace = mikktSetTSpaceDefault; - mkif.m_setTSpaceBasic = NULL; + mkif.m_setTSpaceBasic = nullptr; SMikkTSpaceContext msc; msc.m_pInterface = &mkif; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 1c5b2abad2..749dff24f2 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -47,25 +47,25 @@ bool Texture2D::is_pixel_opaque(int p_x, int p_y) const { return true; } -void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { +void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat); } bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const { @@ -82,9 +82,9 @@ void Texture2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_height"), &Texture2D::get_height); ClassDB::bind_method(D_METHOD("get_size"), &Texture2D::get_size); ClassDB::bind_method(D_METHOD("has_alpha"), &Texture2D::has_alpha); - ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT)); - ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT)); - ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT)); + ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT)); + ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT), DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data); ADD_GROUP("", ""); @@ -121,7 +121,7 @@ bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) { Size2 s = p_value; w = s.width; h = s.height; - VisualServer::get_singleton()->texture_set_size_override(texture, w, h); + RenderingServer::get_singleton()->texture_set_size_override(texture, w, h); } else return false; @@ -158,8 +158,8 @@ void ImageTexture::_reload_hook(const RID &p_hook) { ERR_FAIL_COND_MSG(err != OK, "Cannot load image from path '" + path + "'."); - RID new_texture = VisualServer::get_singleton()->texture_2d_create(img); - VisualServer::get_singleton()->texture_replace(texture, new_texture); + RID new_texture = RenderingServer::get_singleton()->texture_2d_create(img); + RenderingServer::get_singleton()->texture_replace(texture, new_texture); _change_notify(); emit_changed(); @@ -174,10 +174,10 @@ void ImageTexture::create_from_image(const Ref<Image> &p_image) { mipmaps = p_image->has_mipmaps(); if (texture.is_null()) { - texture = VisualServer::get_singleton()->texture_2d_create(p_image); + texture = RenderingServer::get_singleton()->texture_2d_create(p_image); } else { - RID new_texture = VisualServer::get_singleton()->texture_2d_create(p_image); - VisualServer::get_singleton()->texture_replace(texture, new_texture); + RID new_texture = RenderingServer::get_singleton()->texture_2d_create(p_image); + RenderingServer::get_singleton()->texture_replace(texture, new_texture); } _change_notify(); emit_changed(); @@ -199,9 +199,9 @@ void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) { ERR_FAIL_COND(mipmaps != p_image->has_mipmaps()); if (p_immediate) { - VisualServer::get_singleton()->texture_2d_update_immediate(texture, p_image); + RenderingServer::get_singleton()->texture_2d_update_immediate(texture, p_image); } else { - VisualServer::get_singleton()->texture_2d_update(texture, p_image); + RenderingServer::get_singleton()->texture_2d_update(texture, p_image); } _change_notify(); @@ -219,7 +219,7 @@ void ImageTexture::_resource_path_changed() { Ref<Image> ImageTexture::get_data() const { if (image_stored) { - return VisualServer::get_singleton()->texture_2d_get(texture); + return RenderingServer::get_singleton()->texture_2d_get(texture); } else { return Ref<Image>(); } @@ -239,7 +239,7 @@ RID ImageTexture::get_rid() const { if (texture.is_null()) { //we are in trouble, create something temporary - texture = VisualServer::get_singleton()->texture_2d_placeholder_create(); + texture = RenderingServer::get_singleton()->texture_2d_placeholder_create(); } return texture; } @@ -249,29 +249,29 @@ bool ImageTexture::has_alpha() const { return (format == Image::FORMAT_LA8 || format == Image::FORMAT_RGBA8); } -void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { +void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat); } bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const { @@ -316,13 +316,13 @@ void ImageTexture::set_size_override(const Size2 &p_size) { w = s.x; if (s.y != 0) h = s.y; - VisualServer::get_singleton()->texture_set_size_override(texture, w, h); + RenderingServer::get_singleton()->texture_set_size_override(texture, w, h); } void ImageTexture::set_path(const String &p_path, bool p_take_over) { if (texture.is_valid()) { - VisualServer::get_singleton()->texture_set_path(texture, p_path); + RenderingServer::get_singleton()->texture_set_path(texture, p_path); } Resource::set_path(p_path, p_take_over); @@ -349,7 +349,7 @@ ImageTexture::ImageTexture() { ImageTexture::~ImageTexture() { if (texture.is_valid()) { - VisualServer::get_singleton()->free(texture); + RenderingServer::get_singleton()->free(texture); } } @@ -495,7 +495,7 @@ Ref<Image> StreamTexture::load_image_from_file(FileAccess *f, int p_size_limit) void StreamTexture::set_path(const String &p_path, bool p_take_over) { if (texture.is_valid()) { - VisualServer::get_singleton()->texture_set_path(texture, p_path); + RenderingServer::get_singleton()->texture_set_path(texture, p_path); } Resource::set_path(p_path, p_take_over); @@ -509,7 +509,7 @@ void StreamTexture::_requested_3d(void *p_ud) { request_3d_callback(stex); } -void StreamTexture::_requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel) { +void StreamTexture::_requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel) { StreamTexture *st = (StreamTexture *)p_ud; Ref<StreamTexture> stex(st); @@ -525,9 +525,9 @@ void StreamTexture::_requested_normal(void *p_ud) { request_normal_callback(stex); } -StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = NULL; -StreamTexture::TextureFormatRoughnessRequestCallback StreamTexture::request_roughness_callback = NULL; -StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = NULL; +StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = nullptr; +StreamTexture::TextureFormatRoughnessRequestCallback StreamTexture::request_roughness_callback = nullptr; +StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = nullptr; Image::Format StreamTexture::get_format() const { @@ -611,13 +611,13 @@ Error StreamTexture::load(const String &p_path) { return err; if (texture.is_valid()) { - RID new_texture = VS::get_singleton()->texture_2d_create(image); - VS::get_singleton()->texture_replace(texture, new_texture); + RID new_texture = RS::get_singleton()->texture_2d_create(image); + RS::get_singleton()->texture_replace(texture, new_texture); } else { - texture = VS::get_singleton()->texture_2d_create(image); + texture = RS::get_singleton()->texture_2d_create(image); } if (lwc || lhc) { - VS::get_singleton()->texture_set_size_override(texture, lwc, lhc); + RS::get_singleton()->texture_set_size_override(texture, lwc, lhc); } w = lwc ? lwc : lw; @@ -627,33 +627,33 @@ Error StreamTexture::load(const String &p_path) { if (get_path() == String()) { //temporarily set path if no path set for resource, helps find errors - VisualServer::get_singleton()->texture_set_path(texture, p_path); + RenderingServer::get_singleton()->texture_set_path(texture, p_path); } #ifdef TOOLS_ENABLED if (request_3d) { //print_line("request detect 3D at " + p_path); - VS::get_singleton()->texture_set_detect_3d_callback(texture, _requested_3d, this); + RS::get_singleton()->texture_set_detect_3d_callback(texture, _requested_3d, this); } else { //print_line("not requesting detect 3D at " + p_path); - VS::get_singleton()->texture_set_detect_3d_callback(texture, NULL, NULL); + RS::get_singleton()->texture_set_detect_3d_callback(texture, nullptr, nullptr); } if (request_roughness) { //print_line("request detect srgb at " + p_path); - VS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this); + RS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this); } else { //print_line("not requesting detect srgb at " + p_path); - VS::get_singleton()->texture_set_detect_roughness_callback(texture, NULL, NULL); + RS::get_singleton()->texture_set_detect_roughness_callback(texture, nullptr, nullptr); } if (request_normal) { //print_line("request detect srgb at " + p_path); - VS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this); + RS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this); } else { //print_line("not requesting detect normal at " + p_path); - VS::get_singleton()->texture_set_detect_normal_callback(texture, NULL, NULL); + RS::get_singleton()->texture_set_detect_normal_callback(texture, nullptr, nullptr); } #endif @@ -677,34 +677,34 @@ int StreamTexture::get_height() const { RID StreamTexture::get_rid() const { if (!texture.is_valid()) { - texture = VS::get_singleton()->texture_2d_placeholder_create(); + texture = RS::get_singleton()->texture_2d_placeholder_create(); } return texture; } -void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { +void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { if ((w | h) == 0) return; RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat); } bool StreamTexture::has_alpha() const { @@ -715,7 +715,7 @@ bool StreamTexture::has_alpha() const { Ref<Image> StreamTexture::get_data() const { if (texture.is_valid()) { - return VS::get_singleton()->texture_2d_get(texture); + return RS::get_singleton()->texture_2d_get(texture); } else { return Ref<Image>(); } @@ -792,7 +792,7 @@ StreamTexture::StreamTexture() { StreamTexture::~StreamTexture() { if (texture.is_valid()) { - VS::get_singleton()->free(texture); + RS::get_singleton()->free(texture); } } @@ -935,7 +935,7 @@ void AtlasTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_clip"), "set_filter_clip", "has_filter_clip"); } -void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if (!atlas.is_valid()) return; @@ -952,10 +952,10 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat); + RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat); } -void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if (!atlas.is_valid()) return; @@ -975,9 +975,9 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat); + RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat); } -void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { +void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { //this might not necessarily work well if using a rect, needs to be fixed properly if (!atlas.is_valid()) @@ -989,7 +989,7 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat); + RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat); } bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const { @@ -1087,7 +1087,7 @@ Ref<Texture2D> MeshTexture::get_base_texture() const { return base_texture; } -void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if (mesh.is_null() || base_texture.is_null()) { return; @@ -1100,9 +1100,9 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo } RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { if (mesh.is_null() || base_texture.is_null()) { return; } @@ -1123,9 +1123,9 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, } RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } -void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { +void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { if (mesh.is_null() || base_texture.is_null()) { return; @@ -1147,7 +1147,7 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const } RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID(); RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID(); - VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); + RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } bool MeshTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const { r_rect = p_rect; @@ -1300,7 +1300,7 @@ void LargeTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data"); } -void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { for (int i = 0; i < pieces.size(); i++) { @@ -1309,7 +1309,7 @@ void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m } } -void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat) const { +void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const { //tiling not supported for this if (size.x == 0 || size.y == 0) @@ -1323,7 +1323,7 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat); } } -void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, VS::CanvasItemTextureFilter p_texture_filter, VS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { +void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const { //tiling not supported for this if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0) @@ -1445,10 +1445,10 @@ void CurveTexture::_update() { Ref<Image> image = memnew(Image(_width, 1, false, Image::FORMAT_RF, data)); if (_texture.is_valid()) { - RID new_texture = VS::get_singleton()->texture_2d_create(image); - VS::get_singleton()->texture_replace(_texture, new_texture); + RID new_texture = RS::get_singleton()->texture_2d_create(image); + RS::get_singleton()->texture_replace(_texture, new_texture); } else { - _texture = VS::get_singleton()->texture_2d_create(image); + _texture = RS::get_singleton()->texture_2d_create(image); } emit_changed(); @@ -1462,7 +1462,7 @@ Ref<Curve> CurveTexture::get_curve() const { RID CurveTexture::get_rid() const { if (!_texture.is_valid()) { - _texture = VS::get_singleton()->texture_2d_placeholder_create(); + _texture = RS::get_singleton()->texture_2d_placeholder_create(); } return _texture; } @@ -1472,7 +1472,7 @@ CurveTexture::CurveTexture() { } CurveTexture::~CurveTexture() { if (_texture.is_valid()) { - VS::get_singleton()->free(_texture); + RS::get_singleton()->free(_texture); } } ////////////////// @@ -1492,7 +1492,7 @@ GradientTexture::GradientTexture() { GradientTexture::~GradientTexture() { if (texture.is_valid()) { - VS::get_singleton()->free(texture); + RS::get_singleton()->free(texture); } } @@ -1564,10 +1564,10 @@ void GradientTexture::_update() { Ref<Image> image = memnew(Image(width, 1, false, Image::FORMAT_RGBA8, data)); if (texture.is_valid()) { - RID new_texture = VS::get_singleton()->texture_2d_create(image); - VS::get_singleton()->texture_replace(texture, new_texture); + RID new_texture = RS::get_singleton()->texture_2d_create(image); + RS::get_singleton()->texture_replace(texture, new_texture); } else { - texture = VS::get_singleton()->texture_2d_create(image); + texture = RS::get_singleton()->texture_2d_create(image); } emit_changed(); @@ -1587,7 +1587,7 @@ Ref<Image> GradientTexture::get_data() const { if (!texture.is_valid()) { return Ref<Image>(); } - return VisualServer::get_singleton()->texture_2d_get(texture); + return RenderingServer::get_singleton()->texture_2d_get(texture); } ////////////////////////////////////// @@ -1607,13 +1607,13 @@ void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) { base = p_texture; if (base.is_valid()) { if (proxy_ph.is_valid()) { - VS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); - VS::get_singleton()->free(proxy_ph); + RS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); + RS::get_singleton()->free(proxy_ph); proxy_ph = RID(); } else if (proxy.is_valid()) { - VS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); + RS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); } else { - proxy = VS::get_singleton()->texture_proxy_create(base->get_rid()); + proxy = RS::get_singleton()->texture_proxy_create(base->get_rid()); } } } @@ -1638,8 +1638,8 @@ int ProxyTexture::get_height() const { RID ProxyTexture::get_rid() const { if (proxy.is_null()) { - proxy_ph = VS::get_singleton()->texture_2d_placeholder_create(); - proxy = VS::get_singleton()->texture_proxy_create(proxy_ph); + proxy_ph = RS::get_singleton()->texture_2d_placeholder_create(); + proxy = RS::get_singleton()->texture_proxy_create(proxy_ph); } return proxy; } @@ -1653,16 +1653,16 @@ bool ProxyTexture::has_alpha() const { ProxyTexture::ProxyTexture() { - //proxy = VS::get_singleton()->texture_create(); + //proxy = RS::get_singleton()->texture_create(); } ProxyTexture::~ProxyTexture() { if (proxy_ph.is_valid()) { - VS::get_singleton()->free(proxy_ph); + RS::get_singleton()->free(proxy_ph); } if (proxy.is_valid()) { - VS::get_singleton()->free(proxy); + RS::get_singleton()->free(proxy); } } ////////////////////////////////////////////// @@ -1708,7 +1708,7 @@ void AnimatedTexture::_update_proxy() { } if (frames[current_frame].texture.is_valid()) { - VisualServer::get_singleton()->texture_proxy_update(proxy, frames[current_frame].texture->get_rid()); + RenderingServer::get_singleton()->texture_proxy_update(proxy, frames[current_frame].texture->get_rid()); } } @@ -1854,28 +1854,28 @@ void AnimatedTexture::_bind_methods() { } AnimatedTexture::AnimatedTexture() { - //proxy = VS::get_singleton()->texture_create(); - proxy_ph = VS::get_singleton()->texture_2d_placeholder_create(); - proxy = VS::get_singleton()->texture_proxy_create(proxy_ph); + //proxy = RS::get_singleton()->texture_create(); + proxy_ph = RS::get_singleton()->texture_2d_placeholder_create(); + proxy = RS::get_singleton()->texture_proxy_create(proxy_ph); - VisualServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true); + RenderingServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true); time = 0; frame_count = 1; fps = 4; prev_ticks = 0; current_frame = 0; - VisualServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy)); + RenderingServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy)); #ifndef NO_THREADS rw_lock = RWLock::create(); #else - rw_lock = NULL; + rw_lock = nullptr; #endif } AnimatedTexture::~AnimatedTexture() { - VS::get_singleton()->free(proxy); - VS::get_singleton()->free(proxy_ph); + RS::get_singleton()->free(proxy); + RS::get_singleton()->free(proxy_ph); if (rw_lock) { memdelete(rw_lock); } @@ -1921,10 +1921,10 @@ Error TextureLayered::create_from_images(Vector<Ref<Image>> p_images) { int new_layers = p_images.size(); ERR_FAIL_COND_V(new_layers == 0, ERR_INVALID_PARAMETER); - if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP) { + if (layered_type == RS::TEXTURE_LAYERED_CUBEMAP) { ERR_FAIL_COND_V_MSG(new_layers != 6, ERR_INVALID_PARAMETER, "Cubemaps require exactly 6 layers"); - } else if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) { + } else if (layered_type == RS::TEXTURE_LAYERED_CUBEMAP_ARRAY) { ERR_FAIL_COND_V_MSG((new_layers % 6) != 0, ERR_INVALID_PARAMETER, "Cubemap array layers must be a multiple of 6"); } @@ -1946,11 +1946,11 @@ Error TextureLayered::create_from_images(Vector<Ref<Image>> p_images) { } if (texture.is_valid()) { - RID new_texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type); + RID new_texture = RS::get_singleton()->texture_2d_layered_create(p_images, layered_type); ERR_FAIL_COND_V(!new_texture.is_valid(), ERR_CANT_CREATE); - VS::get_singleton()->texture_replace(texture, new_texture); + RS::get_singleton()->texture_replace(texture, new_texture); } else { - texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type); + texture = RS::get_singleton()->texture_2d_layered_create(p_images, layered_type); ERR_FAIL_COND_V(!texture.is_valid(), ERR_CANT_CREATE); } @@ -1969,24 +1969,24 @@ void TextureLayered::update_layer(const Ref<Image> &p_image, int p_layer) { ERR_FAIL_COND(p_image->get_width() != width || p_image->get_height() != height); ERR_FAIL_INDEX(p_layer, layers); ERR_FAIL_COND(p_image->has_mipmaps() != mipmaps); - VS::get_singleton()->texture_2d_update(texture, p_image, p_layer); + RS::get_singleton()->texture_2d_update(texture, p_image, p_layer); } Ref<Image> TextureLayered::get_layer_data(int p_layer) const { ERR_FAIL_INDEX_V(p_layer, layers, Ref<Image>()); - return VS::get_singleton()->texture_2d_layer_get(texture, p_layer); + return RS::get_singleton()->texture_2d_layer_get(texture, p_layer); } RID TextureLayered::get_rid() const { if (texture.is_null()) { - texture = VS::get_singleton()->texture_2d_layered_placeholder_create(); + texture = RS::get_singleton()->texture_2d_layered_placeholder_create(); } return texture; } void TextureLayered::set_path(const String &p_path, bool p_take_over) { if (texture.is_valid()) { - VS::get_singleton()->texture_set_path(texture, p_path); + RS::get_singleton()->texture_set_path(texture, p_path); } Resource::set_path(p_path, p_take_over); @@ -2009,7 +2009,7 @@ void TextureLayered::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_INTERNAL), "create_from_images", "_get_images"); } -TextureLayered::TextureLayered(VisualServer::TextureLayeredType p_layered_type) { +TextureLayered::TextureLayered(RenderingServer::TextureLayeredType p_layered_type) { layered_type = p_layered_type; format = Image::FORMAT_MAX; @@ -2020,7 +2020,7 @@ TextureLayered::TextureLayered(VisualServer::TextureLayeredType p_layered_type) TextureLayered::~TextureLayered() { if (texture.is_valid()) { - VS::get_singleton()->free(texture); + RS::get_singleton()->free(texture); } } diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 1fb8742cec..18f70baa07 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -41,7 +41,7 @@ #include "scene/resources/curve.h" #include "scene/resources/gradient.h" #include "servers/camera_server.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class Texture : public Resource { GDCLASS(Texture, Resource); @@ -68,9 +68,9 @@ public: virtual bool has_alpha() const = 0; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; virtual Ref<Image> get_data() const { return Ref<Image>(); } @@ -118,9 +118,9 @@ public: virtual RID get_rid() const; bool has_alpha() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -171,7 +171,7 @@ private: virtual void reload_from_file(); static void _requested_3d(void *p_ud); - static void _requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel); + static void _requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel); static void _requested_normal(void *p_ud); protected: @@ -182,7 +182,7 @@ public: static Ref<Image> load_image_from_file(FileAccess *p_file, int p_size_limit); typedef void (*TextureFormatRequestCallback)(const Ref<StreamTexture> &); - typedef void (*TextureFormatRoughnessRequestCallback)(const Ref<StreamTexture> &, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel); + typedef void (*TextureFormatRoughnessRequestCallback)(const Ref<StreamTexture> &, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel); static TextureFormatRequestCallback request_3d_callback; static TextureFormatRoughnessRequestCallback request_roughness_callback; @@ -198,9 +198,9 @@ public: virtual void set_path(const String &p_path, bool p_take_over); - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; virtual bool has_alpha() const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -213,7 +213,7 @@ public: class ResourceFormatLoaderStreamTexture : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; @@ -251,9 +251,9 @@ public: void set_filter_clip(const bool p_enable); bool has_filter_clip() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -291,9 +291,9 @@ public: void set_base_texture(const Ref<Texture2D> &p_texture); Ref<Texture2D> get_base_texture() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -339,9 +339,9 @@ public: Ref<Texture2D> get_piece_texture(int p_idx) const; Ref<Image> to_image() const; - virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; - virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), VS::CanvasItemTextureFilter p_texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; + virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const; + virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const; bool is_pixel_opaque(int p_x, int p_y) const; @@ -352,7 +352,7 @@ class TextureLayered : public Texture { GDCLASS(TextureLayered, Texture); - VS::TextureLayeredType layered_type; + RS::TextureLayeredType layered_type; mutable RID texture; Image::Format format; @@ -383,7 +383,7 @@ public: virtual RID get_rid() const; virtual void set_path(const String &p_path, bool p_take_over = false); - TextureLayered(VS::TextureLayeredType p_layered_type); + TextureLayered(RS::TextureLayeredType p_layered_type); ~TextureLayered(); }; @@ -392,7 +392,7 @@ class Texture2DArray : public TextureLayered { GDCLASS(Texture2DArray, TextureLayered) public: Texture2DArray() : - TextureLayered(VS::TEXTURE_LAYERED_2D_ARRAY) {} + TextureLayered(RS::TEXTURE_LAYERED_2D_ARRAY) {} }; class Cubemap : public TextureLayered { @@ -401,7 +401,7 @@ class Cubemap : public TextureLayered { public: Cubemap() : - TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP) {} + TextureLayered(RS::TEXTURE_LAYERED_CUBEMAP) {} }; class CubemapArray : public TextureLayered { @@ -410,7 +410,7 @@ class CubemapArray : public TextureLayered { public: CubemapArray() : - TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {} + TextureLayered(RS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {} }; class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader { @@ -421,7 +421,7 @@ public: COMPRESSION_UNCOMPRESSED }; - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index d67f5f9ff2..98ebf048dc 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -230,11 +230,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> list; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = icon_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = icon_map[*key].next(key2))) { @@ -242,11 +242,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = style_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = style_map[*key].next(key2))) { @@ -254,11 +254,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = font_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = font_map[*key].next(key2))) { @@ -266,11 +266,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = color_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = color_map[*key].next(key2))) { @@ -278,11 +278,11 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const { } } - key = NULL; + key = nullptr; while ((key = constant_map.next(key))) { - const StringName *key2 = NULL; + const StringName *key2 = nullptr; while ((key2 = constant_map[*key].next(key2))) { @@ -417,7 +417,7 @@ void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const { if (!icon_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = icon_map[p_type].next(key))) { @@ -440,7 +440,7 @@ Ref<Shader> Theme::get_shader(const StringName &p_name, const StringName &p_type if (shader_map.has(p_type) && shader_map[p_type].has(p_name) && shader_map[p_type][p_name].is_valid()) { return shader_map[p_type][p_name]; } else { - return NULL; + return nullptr; } } @@ -464,7 +464,7 @@ void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list) if (!shader_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = shader_map[p_type].next(key))) { @@ -530,7 +530,7 @@ void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const if (!style_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = style_map[p_type].next(key))) { @@ -541,7 +541,7 @@ void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const void Theme::get_stylebox_types(List<StringName> *p_list) const { ERR_FAIL_NULL(p_list); - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = style_map.next(key))) { p_list->push_back(*key); } @@ -604,7 +604,7 @@ void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const { if (!font_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = font_map[p_type].next(key))) { @@ -654,7 +654,7 @@ void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const { if (!color_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = color_map[p_type].next(key))) { @@ -704,7 +704,7 @@ void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const if (!constant_map.has(p_type)) return; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = constant_map[p_type].next(key))) { @@ -716,9 +716,9 @@ void Theme::clear() { //these need disconnecting { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = icon_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = icon_map[*K].next(L))) { Ref<Texture2D> icon = icon_map[*K][*L]; if (icon.is_valid()) { @@ -729,9 +729,9 @@ void Theme::clear() { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = style_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = style_map[*K].next(L))) { Ref<StyleBox> style = style_map[*K][*L]; if (style.is_valid()) { @@ -742,9 +742,9 @@ void Theme::clear() { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = font_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = font_map[*K].next(L))) { Ref<Font> font = font_map[*K][*L]; if (font.is_valid()) { @@ -781,9 +781,9 @@ void Theme::copy_theme(const Ref<Theme> &p_other) { //these need reconnecting, so add normally { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = p_other->icon_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = p_other->icon_map[*K].next(L))) { set_icon(*L, *K, p_other->icon_map[*K][*L]); } @@ -791,9 +791,9 @@ void Theme::copy_theme(const Ref<Theme> &p_other) { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = p_other->style_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = p_other->style_map[*K].next(L))) { set_stylebox(*L, *K, p_other->style_map[*K][*L]); } @@ -801,9 +801,9 @@ void Theme::copy_theme(const Ref<Theme> &p_other) { } { - const StringName *K = NULL; + const StringName *K = nullptr; while ((K = p_other->font_map.next(K))) { - const StringName *L = NULL; + const StringName *L = nullptr; while ((L = p_other->font_map[*K].next(L))) { set_font(*L, *K, p_other->font_map[*K][*L]); } @@ -825,35 +825,35 @@ void Theme::get_type_list(List<StringName> *p_list) const { ERR_FAIL_NULL(p_list); Set<StringName> types; - const StringName *key = NULL; + const StringName *key = nullptr; while ((key = icon_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = style_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = font_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = color_map.next(key))) { types.insert(*key); } - key = NULL; + key = nullptr; while ((key = constant_map.next(key))) { diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index b312aa054c..6f8a53be1a 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -362,7 +362,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::BOOL, pre + "shape_one_way", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::FLOAT, pre + "shape_one_way_margin", PROPERTY_HINT_RANGE, "0,128,0.01", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "shapes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::INT, pre + "z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::INT, pre + "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1", PROPERTY_USAGE_NOEDITOR)); } } @@ -620,7 +620,7 @@ Vector2 TileSet::autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2()); //First try to forward selection to script if (p_tilemap_node->get_class_name() == "TileMap") { - if (get_script_instance() != NULL) { + if (get_script_instance() != nullptr) { if (get_script_instance()->has_method("_forward_subtile_selection")) { Variant ret = get_script_instance()->call("_forward_subtile_selection", p_id, p_bitmask, p_tilemap_node, p_tile_location); if (ret.get_type() == Variant::VECTOR2) { @@ -681,7 +681,7 @@ Vector2 TileSet::atlastile_get_subtile_by_priority(int p_id, const Node *p_tilem ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2()); //First try to forward selection to script - if (get_script_instance() != NULL) { + if (get_script_instance() != nullptr) { if (get_script_instance()->has_method("_forward_atlas_subtile_selection")) { Variant ret = get_script_instance()->call("_forward_atlas_subtile_selection", p_id, p_tilemap_node, p_tile_location); if (ret.get_type() == Variant::VECTOR2) { @@ -1108,7 +1108,7 @@ bool TileSet::is_tile_bound(int p_drawn_id, int p_neighbor_id) { if (p_drawn_id == p_neighbor_id) { return true; - } else if (get_script_instance() != NULL) { + } else if (get_script_instance() != nullptr) { if (get_script_instance()->has_method("_is_tile_bound")) { Variant ret = get_script_instance()->call("_is_tile_bound", p_drawn_id, p_neighbor_id); if (ret.get_type() == Variant::BOOL) { diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 5252c560a4..05b43dfb89 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -194,8 +194,8 @@ public: void autotile_set_bitmask(int p_id, Vector2 p_coord, uint32_t p_flag); uint32_t autotile_get_bitmask(int p_id, Vector2 p_coord); const Map<Vector2, uint32_t> &autotile_get_bitmask_map(int p_id); - Vector2 autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node = NULL, const Vector2 &p_tile_location = Vector2()); - Vector2 atlastile_get_subtile_by_priority(int p_id, const Node *p_tilemap_node = NULL, const Vector2 &p_tile_location = Vector2()); + Vector2 autotile_get_subtile_for_bitmask(int p_id, uint16_t p_bitmask, const Node *p_tilemap_node = nullptr, const Vector2 &p_tile_location = Vector2()); + Vector2 atlastile_get_subtile_by_priority(int p_id, const Node *p_tilemap_node = nullptr, const Vector2 &p_tile_location = Vector2()); void tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape); Ref<Shape2D> tile_get_shape(int p_id, int p_shape_id) const; diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index c4a019c728..f70f54412b 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -31,7 +31,7 @@ #include "visual_shader.h" #include "core/vmap.h" -#include "servers/visual/shader_types.h" +#include "servers/rendering/shader_types.h" #include "visual_shader_nodes.h" bool VisualShaderNode::is_simple_decl() const { @@ -881,7 +881,7 @@ VisualShader::RenderModeEnums VisualShader::render_mode_enums[] = { { Shader::MODE_SPATIAL, "diffuse" }, { Shader::MODE_SPATIAL, "specular" }, { Shader::MODE_CANVAS_ITEM, "blend" }, - { Shader::MODE_CANVAS_ITEM, NULL } + { Shader::MODE_CANVAS_ITEM, nullptr } }; static const char *type_string[VisualShader::TYPE_MAX] = { @@ -1040,8 +1040,8 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const { Map<String, String> blend_mode_enums; Set<String> toggles; - for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode)).size(); i++) { - String mode = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode))[i]; + for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) { + String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i]; int idx = 0; bool in_enum = false; while (render_mode_enums[idx].string) { @@ -1085,12 +1085,12 @@ void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const { } p_list->push_back(PropertyInfo(Variant::VECTOR2, prop_name + "/position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - if (Object::cast_to<VisualShaderNodeGroupBase>(E->get().node.ptr()) != NULL) { + if (Object::cast_to<VisualShaderNodeGroupBase>(E->get().node.ptr()) != nullptr) { p_list->push_back(PropertyInfo(Variant::VECTOR2, prop_name + "/size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::STRING, prop_name + "/input_ports", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::STRING, prop_name + "/output_ports", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } - if (Object::cast_to<VisualShaderNodeExpression>(E->get().node.ptr()) != NULL) { + if (Object::cast_to<VisualShaderNodeExpression>(E->get().node.ptr()) != nullptr) { p_list->push_back(PropertyInfo(Variant::STRING, prop_name + "/expression", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } } @@ -1317,8 +1317,8 @@ void VisualShader::_update_shader() const { int which = modes[render_mode_enums[idx].string]; int count = 0; - for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode)).size(); i++) { - String mode = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode))[i]; + for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) { + String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i]; if (mode.begins_with(render_mode_enums[idx].string)) { if (count == which) { if (render_mode != String()) { @@ -1336,9 +1336,9 @@ void VisualShader::_update_shader() const { } //fill render mode flags - for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode)).size(); i++) { + for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode)).size(); i++) { - String mode = ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader_mode))[i]; + String mode = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader_mode))[i]; if (flags.has(mode)) { if (render_mode != String()) { render_mode += ", "; @@ -1358,7 +1358,7 @@ 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])) { + if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) { continue; } @@ -1378,7 +1378,7 @@ 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])) { + if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) { continue; } @@ -1417,7 +1417,7 @@ 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])) { + if (!ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader_mode)).has(func_name[i])) { continue; } tcode = tcode.insert(insertion_pos[i], global_code_per_func[Type(i)]); @@ -1478,7 +1478,7 @@ void VisualShader::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_node", "type", "id"), &VisualShader::remove_node); ClassDB::bind_method(D_METHOD("is_node_connection", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::is_node_connection); - ClassDB::bind_method(D_METHOD("can_connect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::is_node_connection); + ClassDB::bind_method(D_METHOD("can_connect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::can_connect_nodes); ClassDB::bind_method(D_METHOD("connect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::connect_nodes); ClassDB::bind_method(D_METHOD("disconnect_nodes", "type", "from_node", "from_port", "to_node", "to_port"), &VisualShader::disconnect_nodes); @@ -1687,7 +1687,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::ports[] = { { 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 }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, nullptr, nullptr }, }; const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = { @@ -1736,7 +1736,7 @@ const VisualShaderNodeInput::Port VisualShaderNodeInput::preview_ports[] = { { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "alpha", "1.0" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_VECTOR, "velocity", "vec3(0.0, 0.0, 1.0)" }, { Shader::MODE_PARTICLES, VisualShader::TYPE_VERTEX, VisualShaderNode::PORT_TYPE_SCALAR, "time", "TIME" }, - { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, NULL, NULL }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, nullptr, nullptr }, }; int VisualShaderNodeInput::get_input_port_count() const { @@ -2034,7 +2034,7 @@ const VisualShaderNodeOutput::Port VisualShaderNodeOutput::ports[] = { { 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 }, + { Shader::MODE_MAX, VisualShader::TYPE_MAX, VisualShaderNode::PORT_TYPE_TRANSFORM, nullptr, nullptr }, }; int VisualShaderNodeOutput::get_input_port_count() const { @@ -2565,7 +2565,7 @@ void VisualShaderNodeGroupBase::set_control(Control *p_control, int p_index) { } Control *VisualShaderNodeGroupBase::get_control(int p_index) { - ERR_FAIL_COND_V(!controls.has(p_index), NULL); + ERR_FAIL_COND_V(!controls.has(p_index), nullptr); return controls[p_index]; } diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 75bdeeac07..742ef106d9 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -34,8 +34,8 @@ #include "scene/2d/camera_2d.h" #include "scene/2d/visibility_notifier_2d.h" #include "scene/main/window.h" -#include "servers/physics_2d_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_2d.h" +#include "servers/rendering_server.h" struct SpatialIndexer2D { @@ -376,33 +376,33 @@ void World2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::_RID, "canvas", PROPERTY_HINT_NONE, "", 0), "", "get_canvas"); ADD_PROPERTY(PropertyInfo(Variant::_RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "Physics2DDirectSpaceState", 0), "", "get_direct_space_state"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", 0), "", "get_direct_space_state"); } -Physics2DDirectSpaceState *World2D::get_direct_space_state() { +PhysicsDirectSpaceState2D *World2D::get_direct_space_state() { - return Physics2DServer::get_singleton()->space_get_direct_state(space); + return PhysicsServer2D::get_singleton()->space_get_direct_state(space); } World2D::World2D() { - canvas = VisualServer::get_singleton()->canvas_create(); - space = Physics2DServer::get_singleton()->space_create(); + canvas = RenderingServer::get_singleton()->canvas_create(); + space = PhysicsServer2D::get_singleton()->space_create(); //set space2D to be more friendly with pixels than meters, by adjusting some constants - Physics2DServer::get_singleton()->space_set_active(space, true); - Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/2d/default_gravity", 98)); - Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/2d/default_gravity_vector", Vector2(0, 1))); - Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/2d/default_linear_damp", 0.1)); + PhysicsServer2D::get_singleton()->space_set_active(space, true); + PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/2d/default_gravity", 98)); + PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/2d/default_gravity_vector", Vector2(0, 1))); + PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/2d/default_linear_damp", 0.1)); ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/default_linear_damp", PropertyInfo(Variant::FLOAT, "physics/2d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); - Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/2d/default_angular_damp", 1.0)); + PhysicsServer2D::get_singleton()->area_set_param(space, PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/2d/default_angular_damp", 1.0)); ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/2d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); indexer = memnew(SpatialIndexer2D); } World2D::~World2D() { - VisualServer::get_singleton()->free(canvas); - Physics2DServer::get_singleton()->free(space); + RenderingServer::get_singleton()->free(canvas); + PhysicsServer2D::get_singleton()->free(space); memdelete(indexer); } diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h index d837ef58c2..88b4c2594c 100644 --- a/scene/resources/world_2d.h +++ b/scene/resources/world_2d.h @@ -33,7 +33,7 @@ #include "core/project_settings.h" #include "core/resource.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" class VisibilityNotifier2D; class Viewport; @@ -67,7 +67,7 @@ public: RID get_canvas(); RID get_space(); - Physics2DDirectSpaceState *get_direct_space_state(); + PhysicsDirectSpaceState2D *get_direct_space_state(); void get_viewport_list(List<Viewport *> *r_viewports); diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp index 0a687af803..dee00dd82a 100644 --- a/scene/resources/world_3d.cpp +++ b/scene/resources/world_3d.cpp @@ -275,9 +275,9 @@ void World3D::set_environment(const Ref<Environment> &p_environment) { environment = p_environment; if (environment.is_valid()) - VS::get_singleton()->scenario_set_environment(scenario, environment->get_rid()); + RS::get_singleton()->scenario_set_environment(scenario, environment->get_rid()); else - VS::get_singleton()->scenario_set_environment(scenario, RID()); + RS::get_singleton()->scenario_set_environment(scenario, RID()); emit_changed(); } @@ -294,9 +294,9 @@ void World3D::set_fallback_environment(const Ref<Environment> &p_environment) { fallback_environment = p_environment; if (fallback_environment.is_valid()) - VS::get_singleton()->scenario_set_fallback_environment(scenario, p_environment->get_rid()); + RS::get_singleton()->scenario_set_fallback_environment(scenario, p_environment->get_rid()); else - VS::get_singleton()->scenario_set_fallback_environment(scenario, RID()); + RS::get_singleton()->scenario_set_fallback_environment(scenario, RID()); emit_changed(); } @@ -310,9 +310,9 @@ void World3D::set_camera_effects(const Ref<CameraEffects> &p_camera_effects) { camera_effects = p_camera_effects; if (camera_effects.is_valid()) - VS::get_singleton()->scenario_set_camera_effects(scenario, camera_effects->get_rid()); + RS::get_singleton()->scenario_set_camera_effects(scenario, camera_effects->get_rid()); else - VS::get_singleton()->scenario_set_camera_effects(scenario, RID()); + RS::get_singleton()->scenario_set_camera_effects(scenario, RID()); } Ref<CameraEffects> World3D::get_camera_effects() const { @@ -320,9 +320,9 @@ Ref<CameraEffects> World3D::get_camera_effects() const { return camera_effects; } -PhysicsDirectSpaceState *World3D::get_direct_space_state() { +PhysicsDirectSpaceState3D *World3D::get_direct_space_state() { - return PhysicsServer::get_singleton()->space_get_direct_state(space); + return PhysicsServer3D::get_singleton()->space_get_direct_state(space); } void World3D::get_camera_list(List<Camera3D *> *r_cameras) { @@ -348,24 +348,24 @@ void World3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_effects", PROPERTY_HINT_RESOURCE_TYPE, "CameraEffects"), "set_camera_effects", "get_camera_effects"); ADD_PROPERTY(PropertyInfo(Variant::_RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space"); ADD_PROPERTY(PropertyInfo(Variant::_RID, "scenario", PROPERTY_HINT_NONE, "", 0), "", "get_scenario"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState", 0), "", "get_direct_space_state"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", 0), "", "get_direct_space_state"); } World3D::World3D() { - space = PhysicsServer::get_singleton()->space_create(); - scenario = VisualServer::get_singleton()->scenario_create(); + space = PhysicsServer3D::get_singleton()->space_create(); + scenario = RenderingServer::get_singleton()->scenario_create(); - PhysicsServer::get_singleton()->space_set_active(space, true); - PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/3d/default_gravity", 9.8)); - PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/3d/default_gravity_vector", Vector3(0, -1, 0))); - PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/3d/default_linear_damp", 0.1)); + PhysicsServer3D::get_singleton()->space_set_active(space, true); + PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/3d/default_gravity", 9.8)); + PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/3d/default_gravity_vector", Vector3(0, -1, 0))); + PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/3d/default_linear_damp", 0.1)); ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/default_linear_damp", PropertyInfo(Variant::FLOAT, "physics/3d/default_linear_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); - PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/3d/default_angular_damp", 0.1)); + PhysicsServer3D::get_singleton()->area_set_param(space, PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/3d/default_angular_damp", 0.1)); ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/default_angular_damp", PropertyInfo(Variant::FLOAT, "physics/3d/default_angular_damp", PROPERTY_HINT_RANGE, "-1,100,0.001,or_greater")); #ifdef _3D_DISABLED - indexer = NULL; + indexer = nullptr; #else indexer = memnew(SpatialIndexer); #endif @@ -373,8 +373,8 @@ World3D::World3D() { World3D::~World3D() { - PhysicsServer::get_singleton()->free(space); - VisualServer::get_singleton()->free(scenario); + PhysicsServer3D::get_singleton()->free(space); + RenderingServer::get_singleton()->free(scenario); #ifndef _3D_DISABLED memdelete(indexer); diff --git a/scene/resources/world_3d.h b/scene/resources/world_3d.h index 4c18ba9cea..81a27a7349 100644 --- a/scene/resources/world_3d.h +++ b/scene/resources/world_3d.h @@ -33,8 +33,8 @@ #include "core/resource.h" #include "scene/resources/environment.h" -#include "servers/physics_server.h" -#include "servers/visual_server.h" +#include "servers/physics_server_3d.h" +#include "servers/rendering_server.h" class Camera3D; class VisibilityNotifier3D; @@ -82,7 +82,7 @@ public: void get_camera_list(List<Camera3D *> *r_cameras); - PhysicsDirectSpaceState *get_direct_space_state(); + PhysicsDirectSpaceState3D *get_direct_space_state(); World3D(); ~World3D(); diff --git a/scene/resources/world_margin_shape_3d.cpp b/scene/resources/world_margin_shape_3d.cpp index 3bea3111ef..aa96f8aa68 100644 --- a/scene/resources/world_margin_shape_3d.cpp +++ b/scene/resources/world_margin_shape_3d.cpp @@ -30,7 +30,7 @@ #include "world_margin_shape_3d.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() { @@ -63,7 +63,7 @@ Vector<Vector3> WorldMarginShape3D::get_debug_mesh_lines() { void WorldMarginShape3D::_update_shape() { - PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane); + PhysicsServer3D::get_singleton()->shape_set_data(get_shape(), plane); Shape3D::_update_shape(); } @@ -89,7 +89,7 @@ void WorldMarginShape3D::_bind_methods() { } WorldMarginShape3D::WorldMarginShape3D() : - Shape3D(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) { + Shape3D(PhysicsServer3D::get_singleton()->shape_create(PhysicsServer3D::SHAPE_PLANE)) { set_plane(Plane(0, 1, 0, 0)); } diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 1f0365dab9..ad996e7d50 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -30,7 +30,7 @@ #include "scene_string_names.h" -SceneStringNames *SceneStringNames::singleton = NULL; +SceneStringNames *SceneStringNames::singleton = nullptr; SceneStringNames::SceneStringNames() { diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index e255ebb3cb..58e8c28454 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -44,7 +44,7 @@ class SceneStringNames { static void create() { singleton = memnew(SceneStringNames); } static void free() { memdelete(singleton); - singleton = NULL; + singleton = nullptr; } SceneStringNames(); diff --git a/servers/SCsub b/servers/SCsub index 34ba70b8cb..7080a110da 100644 --- a/servers/SCsub +++ b/servers/SCsub @@ -1,16 +1,16 @@ #!/usr/bin/env python -Import('env') +Import("env") env.servers_sources = [] env.add_source_files(env.servers_sources, "*.cpp") -SConscript('arvr/SCsub') -SConscript('camera/SCsub') -SConscript('physics/SCsub') -SConscript('physics_2d/SCsub') -SConscript('visual/SCsub') -SConscript('audio/SCsub') +SConscript("arvr/SCsub") +SConscript("camera/SCsub") +SConscript("physics_3d/SCsub") +SConscript("physics_2d/SCsub") +SConscript("rendering/SCsub") +SConscript("audio/SCsub") lib = env.add_library("servers", env.servers_sources) diff --git a/servers/arvr/SCsub b/servers/arvr/SCsub index d730144861..86681f9c74 100644 --- a/servers/arvr/SCsub +++ b/servers/arvr/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 4b3417db6c..f5597d8974 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -33,7 +33,7 @@ #include "arvr/arvr_positional_tracker.h" #include "core/project_settings.h" -ARVRServer *ARVRServer::singleton = NULL; +ARVRServer *ARVRServer::singleton = nullptr; ARVRServer *ARVRServer::get_singleton() { return singleton; @@ -109,7 +109,7 @@ Transform ARVRServer::get_reference_frame() const { }; void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) { - if (primary_interface != NULL) { + if (primary_interface != nullptr) { // clear our current reference frame or we'll end up double adjusting it reference_frame = Transform(); @@ -142,7 +142,7 @@ void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) Transform ARVRServer::get_hmd_transform() { Transform hmd_transform; - if (primary_interface != NULL) { + if (primary_interface != nullptr) { hmd_transform = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, hmd_transform); }; return hmd_transform; @@ -189,7 +189,7 @@ int ARVRServer::get_interface_count() const { }; Ref<ARVRInterface> ARVRServer::get_interface(int p_index) const { - ERR_FAIL_INDEX_V(p_index, interfaces.size(), NULL); + ERR_FAIL_INDEX_V(p_index, interfaces.size(), nullptr); return interfaces[p_index]; }; @@ -205,7 +205,7 @@ Ref<ARVRInterface> ARVRServer::find_interface(const String &p_name) const { }; }; - ERR_FAIL_COND_V(idx == -1, NULL); + ERR_FAIL_COND_V(idx == -1, nullptr); return interfaces[idx]; }; @@ -296,13 +296,13 @@ int ARVRServer::get_tracker_count() const { }; ARVRPositionalTracker *ARVRServer::get_tracker(int p_index) const { - ERR_FAIL_INDEX_V(p_index, trackers.size(), NULL); + ERR_FAIL_INDEX_V(p_index, trackers.size(), nullptr); return trackers[p_index]; }; ARVRPositionalTracker *ARVRServer::find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const { - ERR_FAIL_COND_V(p_tracker_id == 0, NULL); + ERR_FAIL_COND_V(p_tracker_id == 0, nullptr); for (int i = 0; i < trackers.size(); i++) { if (trackers[i]->get_type() == p_tracker_type && trackers[i]->get_tracker_id() == p_tracker_id) { @@ -310,7 +310,7 @@ ARVRPositionalTracker *ARVRServer::find_by_type_and_id(TrackerType p_tracker_typ }; }; - return NULL; + return nullptr; }; Ref<ARVRInterface> ARVRServer::get_primary_interface() const { @@ -343,7 +343,7 @@ uint64_t ARVRServer::get_last_frame_usec() { }; void ARVRServer::_process() { - /* called from visual_server_viewport.draw_viewports right before we start drawing our viewports */ + /* called from rendering_server_viewport.draw_viewports right before we start drawing our viewports */ /* mark for our frame timing */ last_process_usec = OS::get_singleton()->get_ticks_usec(); @@ -382,5 +382,5 @@ ARVRServer::~ARVRServer() { trackers.remove(0); } - singleton = NULL; + singleton = nullptr; }; diff --git a/servers/audio/SCsub b/servers/audio/SCsub index 3c18c18043..5021e578c3 100644 --- a/servers/audio/SCsub +++ b/servers/audio/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 69b098edfc..ed67e8902a 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -38,7 +38,7 @@ Error AudioDriverDummy::init() { active = false; thread_exited = false; exit_thread = false; - samples_in = NULL; + samples_in = nullptr; mix_rate = DEFAULT_MIX_RATE; speaker_mode = SPEAKER_MODE_STEREO; @@ -119,12 +119,12 @@ void AudioDriverDummy::finish() { }; memdelete(thread); - thread = NULL; + thread = nullptr; }; AudioDriverDummy::AudioDriverDummy() { - thread = NULL; + thread = nullptr; }; AudioDriverDummy::~AudioDriverDummy(){ diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp index c0bf4f3a55..2771fc177b 100644 --- a/servers/audio/audio_filter_sw.cpp +++ b/servers/audio/audio_filter_sw.cpp @@ -237,7 +237,7 @@ AudioFilterSW::AudioFilterSW() { AudioFilterSW::Processor::Processor() { - set_filter(NULL); + set_filter(nullptr); } void AudioFilterSW::Processor::set_filter(AudioFilterSW *p_filter, bool p_clear_history) { diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp index 092c3315ee..0ac7ddc7a9 100644 --- a/servers/audio/audio_rb_resampler.cpp +++ b/servers/audio/audio_rb_resampler.cpp @@ -203,18 +203,18 @@ void AudioRBResampler::clear() { //should be stopped at this point but just in case memdelete_arr(rb); memdelete_arr(read_buf); - rb = NULL; + rb = nullptr; offset = 0; rb_read_pos = 0; rb_write_pos = 0; - read_buf = NULL; + read_buf = nullptr; } AudioRBResampler::AudioRBResampler() { - rb = NULL; + rb = nullptr; offset = 0; - read_buf = NULL; + read_buf = nullptr; rb_read_pos = 0; rb_write_pos = 0; diff --git a/servers/audio/audio_rb_resampler.h b/servers/audio/audio_rb_resampler.h index 8cd9714d57..40cf3e4cd7 100644 --- a/servers/audio/audio_rb_resampler.h +++ b/servers/audio/audio_rb_resampler.h @@ -69,7 +69,7 @@ public: } _FORCE_INLINE_ bool is_ready() const { - return rb != NULL; + return rb != nullptr; } _FORCE_INLINE_ int get_total() const { diff --git a/servers/audio/effects/SCsub b/servers/audio/effects/SCsub index d730144861..86681f9c74 100644 --- a/servers/audio/effects/SCsub +++ b/servers/audio/effects/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index 56529e208e..a74ac3c007 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -363,4 +363,7 @@ AudioEffectPitchShift::AudioEffectPitchShift() { pitch_scale = 1.0; oversampling = 4; fft_size = FFT_SIZE_2048; + wet = 0.0; + dry = 0.0; + filter = false; } diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp index 8f0c55ad83..f2784679b5 100644 --- a/servers/audio/effects/audio_effect_record.cpp +++ b/servers/audio/effects/audio_effect_record.cpp @@ -178,14 +178,14 @@ Ref<AudioEffectInstance> AudioEffectRecord::instance() { void AudioEffectRecord::ensure_thread_stopped() { recording_active = false; - if (current_instance != 0) { + if (current_instance != nullptr) { current_instance->finish(); } } void AudioEffectRecord::set_recording_active(bool p_record) { if (p_record) { - if (current_instance == 0) { + if (current_instance == nullptr) { WARN_PRINT("Recording should not be set as active before Godot has initialized."); recording_active = false; return; @@ -217,8 +217,8 @@ Ref<AudioStreamSample> AudioEffectRecord::get_recording() const { Vector<uint8_t> dst_data; - ERR_FAIL_COND_V(current_instance.is_null(), NULL); - ERR_FAIL_COND_V(current_instance->recording_data.size() == 0, NULL); + ERR_FAIL_COND_V(current_instance.is_null(), nullptr); + ERR_FAIL_COND_V(current_instance->recording_data.size() == 0, nullptr); if (dst_format == AudioStreamSample::FORMAT_8_BITS) { int data_size = current_instance->recording_data.size(); diff --git a/servers/audio/effects/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp index 5f24cf3d6b..d272a2cdf7 100644 --- a/servers/audio/effects/audio_stream_generator.cpp +++ b/servers/audio/effects/audio_stream_generator.cpp @@ -205,7 +205,7 @@ void AudioStreamGeneratorPlayback::_bind_methods() { } AudioStreamGeneratorPlayback::AudioStreamGeneratorPlayback() { - generator = NULL; + generator = nullptr; skips = 0; active = false; mixed = 0; diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp index 9946a5eeef..ea2174f1d4 100644 --- a/servers/audio/effects/reverb.cpp +++ b/servers/audio/effects/reverb.cpp @@ -314,7 +314,7 @@ void Reverb::clear_buffers() { if (comb[i].buffer) memdelete_arr(comb[i].buffer); - comb[i].buffer = 0; + comb[i].buffer = nullptr; } for (int i = 0; i < MAX_ALLPASS; i++) { @@ -322,7 +322,7 @@ void Reverb::clear_buffers() { if (allpass[i].buffer) memdelete_arr(allpass[i].buffer); - allpass[i].buffer = 0; + allpass[i].buffer = nullptr; } } @@ -342,7 +342,7 @@ Reverb::Reverb() { hpf_h2 = 0; input_buffer = memnew_arr(float, INPUT_BUFFER_MAX_SIZE); - echo_buffer = 0; + echo_buffer = nullptr; configure_buffers(); update_parameters(); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 0e68c8a543..90033d4a87 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -45,7 +45,7 @@ #define MARK_EDITED #endif -AudioDriver *AudioDriver::singleton = NULL; +AudioDriver *AudioDriver::singleton = nullptr; AudioDriver *AudioDriver::get_singleton() { return singleton; @@ -215,7 +215,7 @@ void AudioDriverManager::initialize(int p_driver) { AudioDriver *AudioDriverManager::get_driver(int p_driver) { - ERR_FAIL_INDEX_V(p_driver, driver_count, NULL); + ERR_FAIL_INDEX_V(p_driver, driver_count, nullptr); return drivers[p_driver]; } @@ -322,7 +322,7 @@ void AudioServer::_mix_step() { bus->soloed = true; } else { - bus = NULL; + bus = nullptr; } } while (bus); @@ -388,7 +388,7 @@ void AudioServer::_mix_step() { //process send - Bus *send = NULL; + Bus *send = nullptr; if (i > 0) { //everything has a send save for master bus @@ -476,8 +476,8 @@ bool AudioServer::thread_has_channel_mix_buffer(int p_bus, int p_buffer) const { AudioFrame *AudioServer::thread_get_channel_mix_buffer(int p_bus, int p_buffer) { - ERR_FAIL_INDEX_V(p_bus, buses.size(), NULL); - ERR_FAIL_INDEX_V(p_buffer, buses[p_bus]->channels.size(), NULL); + ERR_FAIL_INDEX_V(p_bus, buses.size(), nullptr); + ERR_FAIL_INDEX_V(p_buffer, buses[p_bus]->channels.size(), nullptr); AudioFrame *data = buses.write[p_bus]->channels.write[p_buffer].buffer.ptrw(); @@ -1129,48 +1129,7 @@ double AudioServer::get_time_since_last_mix() const { return AudioDriver::get_singleton()->get_time_since_last_mix(); } -AudioServer *AudioServer::singleton = NULL; - -void *AudioServer::audio_data_alloc(uint32_t p_data_len, const uint8_t *p_from_data) { - - void *ad = memalloc(p_data_len); - ERR_FAIL_COND_V(!ad, NULL); - if (p_from_data) { - copymem(ad, p_from_data, p_data_len); - } - - { - MutexLock lock(audio_data_lock); - - audio_data[ad] = p_data_len; - audio_data_total_mem += p_data_len; - audio_data_max_mem = MAX(audio_data_total_mem, audio_data_max_mem); - } - - return ad; -} - -void AudioServer::audio_data_free(void *p_data) { - - MutexLock lock(audio_data_lock); - - if (!audio_data.has(p_data)) { - ERR_FAIL(); - } - - audio_data_total_mem -= audio_data[p_data]; - audio_data.erase(p_data); - memfree(p_data); -} - -size_t AudioServer::audio_data_get_total_memory_usage() const { - - return audio_data_total_mem; -} -size_t AudioServer::audio_data_get_max_memory_usage() const { - - return audio_data_max_mem; -} +AudioServer *AudioServer::singleton = nullptr; void AudioServer::add_callback(AudioCallback p_callback, void *p_userdata) { lock(); @@ -1400,8 +1359,6 @@ void AudioServer::_bind_methods() { AudioServer::AudioServer() { singleton = this; - audio_data_total_mem = 0; - audio_data_max_mem = 0; mix_frames = 0; channel_count = 0; to_mix = 0; @@ -1415,7 +1372,7 @@ AudioServer::AudioServer() { AudioServer::~AudioServer() { - singleton = NULL; + singleton = nullptr; } ///////////////////////////////// diff --git a/servers/audio_server.h b/servers/audio_server.h index 8df0172750..a1a3dde719 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -232,14 +232,6 @@ private: static AudioServer *singleton; - // TODO create an audiodata pool to optimize memory - - Map<void *, uint32_t> audio_data; - size_t audio_data_total_mem; - size_t audio_data_max_mem; - - Mutex audio_data_lock; - void init_channels_and_buffers(); void _mix_step(); @@ -350,12 +342,6 @@ public: virtual double get_time_to_next_mix() const; virtual double get_time_since_last_mix() const; - void *audio_data_alloc(uint32_t p_data_len, const uint8_t *p_from_data = NULL); - void audio_data_free(void *p_data); - - size_t audio_data_get_total_memory_usage() const; - size_t audio_data_get_max_memory_usage() const; - void add_callback(AudioCallback p_callback, void *p_userdata); void remove_callback(AudioCallback p_callback, void *p_userdata); diff --git a/servers/camera/SCsub b/servers/camera/SCsub index ccc76e823f..c949f3bb25 100644 --- a/servers/camera/SCsub +++ b/servers/camera/SCsub @@ -1,7 +1,7 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") -Export('env') +Export("env") diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp index e8537950ec..41f44abae8 100644 --- a/servers/camera/camera_feed.cpp +++ b/servers/camera/camera_feed.cpp @@ -30,7 +30,7 @@ #include "camera_feed.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" void CameraFeed::_bind_methods() { // FIXME: Disabled during Vulkan refactoring, should be ported. @@ -148,7 +148,7 @@ CameraFeed::CameraFeed() { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 // create a texture object - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); #endif @@ -168,7 +168,7 @@ CameraFeed::CameraFeed(String p_name, FeedPosition p_position) { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 // create a texture object - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); texture[CameraServer::FEED_Y_IMAGE] = vs->texture_create(); // also used for RGBA texture[CameraServer::FEED_CBCR_IMAGE] = vs->texture_create(); #endif @@ -178,7 +178,7 @@ CameraFeed::~CameraFeed() { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 // Free our textures - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); vs->free(texture[CameraServer::FEED_Y_IMAGE]); vs->free(texture[CameraServer::FEED_CBCR_IMAGE]); #endif @@ -188,7 +188,7 @@ void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 if (active) { - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); int new_width = p_rgb_img->get_width(); int new_height = p_rgb_img->get_height(); @@ -198,7 +198,7 @@ void CameraFeed::set_RGB_img(Ref<Image> p_rgb_img) { base_width = new_width; base_height = new_height; - vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAGS_DEFAULT); + vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAGS_DEFAULT); } vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_rgb_img); @@ -211,7 +211,7 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 if (active) { - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); int new_width = p_ycbcr_img->get_width(); int new_height = p_ycbcr_img->get_height(); @@ -221,7 +221,7 @@ void CameraFeed::set_YCbCr_img(Ref<Image> p_ycbcr_img) { base_width = new_width; base_height = new_height; - vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAGS_DEFAULT); + vs->texture_allocate(texture[CameraServer::FEED_RGBA_IMAGE], new_width, new_height, 0, Image::FORMAT_RGB8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAGS_DEFAULT); } vs->texture_set_data(texture[CameraServer::FEED_RGBA_IMAGE], p_ycbcr_img); @@ -234,7 +234,7 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 if (active) { - VisualServer *vs = VisualServer::get_singleton(); + RenderingServer *vs = RenderingServer::get_singleton(); ///@TODO investigate whether we can use thirdparty/misc/yuv2rgb.h here to convert our YUV data to RGB, our shader approach is potentially faster though.. // Wondering about including that into multiple projects, may cause issues. @@ -250,10 +250,10 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { base_width = new_y_width; base_height = new_y_height; - vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); + vs->texture_allocate(texture[CameraServer::FEED_Y_IMAGE], new_y_width, new_y_height, 0, Image::FORMAT_R8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAG_USED_FOR_STREAMING); ///@TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion - vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_USED_FOR_STREAMING); + vs->texture_allocate(texture[CameraServer::FEED_CBCR_IMAGE], new_cbcr_width, new_cbcr_height, 0, Image::FORMAT_RG8, RS::TEXTURE_TYPE_2D, RS::TEXTURE_FLAG_USED_FOR_STREAMING); } vs->texture_set_data(texture[CameraServer::FEED_Y_IMAGE], p_y_img); @@ -265,15 +265,15 @@ void CameraFeed::set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img) { // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 -void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type) { - VisualServer *vs = VisualServer::get_singleton(); +void CameraFeed::allocate_texture(int p_width, int p_height, Image::Format p_format, RenderingServer::TextureType p_texture_type, FeedDataType p_data_type) { + RenderingServer *vs = RenderingServer::get_singleton(); if ((base_width != p_width) || (base_height != p_height)) { // We're assuming here that our camera image doesn't change around formats etc, allocate the whole lot... base_width = p_width; base_height = p_height; - vs->texture_allocate(texture[0], p_width, p_height, 0, p_format, p_texture_type, VS::TEXTURE_FLAGS_DEFAULT); + vs->texture_allocate(texture[0], p_width, p_height, 0, p_format, p_texture_type, RS::TEXTURE_FLAGS_DEFAULT); } datatype = p_data_type; diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h index b99ded68e4..52a737cd8d 100644 --- a/servers/camera/camera_feed.h +++ b/servers/camera/camera_feed.h @@ -34,7 +34,7 @@ #include "core/image.h" #include "core/math/transform_2d.h" #include "servers/camera_server.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" /** @author Bastiaan Olij <mux213@gmail.com> @@ -105,7 +105,7 @@ public: void set_YCbCr_imgs(Ref<Image> p_y_img, Ref<Image> p_cbcr_img); // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 - void allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type); + void allocate_texture(int p_width, int p_height, Image::Format p_format, RenderingServer::TextureType p_texture_type, FeedDataType p_data_type); #endif virtual bool activate_feed(); diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index fd88d15e58..3caea6b7c3 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -29,13 +29,13 @@ /*************************************************************************/ #include "camera_server.h" +#include "rendering_server.h" #include "servers/camera/camera_feed.h" -#include "visual_server.h" //////////////////////////////////////////////////////// // CameraServer -CameraServer::CreateFunc CameraServer::create_func = NULL; +CameraServer::CreateFunc CameraServer::create_func = nullptr; void CameraServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_feed", "index"), &CameraServer::get_feed); @@ -54,7 +54,7 @@ void CameraServer::_bind_methods() { BIND_ENUM_CONSTANT(FEED_CBCR_IMAGE); }; -CameraServer *CameraServer::singleton = NULL; +CameraServer *CameraServer::singleton = nullptr; CameraServer *CameraServer::get_singleton() { return singleton; @@ -92,7 +92,7 @@ Ref<CameraFeed> CameraServer::get_feed_by_id(int p_id) { int index = get_feed_index(p_id); if (index == -1) { - return NULL; + return nullptr; } else { return feeds[index]; } @@ -132,7 +132,7 @@ void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { }; Ref<CameraFeed> CameraServer::get_feed(int p_index) { - ERR_FAIL_INDEX_V(p_index, feeds.size(), NULL); + ERR_FAIL_INDEX_V(p_index, feeds.size(), nullptr); return feeds[p_index]; }; @@ -167,5 +167,5 @@ CameraServer::CameraServer() { }; CameraServer::~CameraServer() { - singleton = NULL; + singleton = nullptr; }; diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 9798c57707..da1a68a179 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "display_server.h" + #include "core/input/input_filter.h" #include "scene/resources/texture.h" @@ -434,7 +435,7 @@ void DisplayServer::_bind_methods() { ClassDB::bind_method(D_METHOD("native_video_unpause"), &DisplayServer::native_video_unpause); ClassDB::bind_method(D_METHOD("dialog_show", "title", "description", "buttons", "callback"), &DisplayServer::dialog_show); - ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_show); + ClassDB::bind_method(D_METHOD("dialog_input_text", "title", "description", "existing_text", "callback"), &DisplayServer::dialog_input_text); ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &DisplayServer::get_latin_keyboard_variant); @@ -517,11 +518,6 @@ void DisplayServer::_bind_methods() { BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT); BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS); BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX); - BIND_ENUM_CONSTANT(WINDOW_FLAG_RESIZE_DISABLED_BIT); - BIND_ENUM_CONSTANT(WINDOW_FLAG_BORDERLESS_BIT); - BIND_ENUM_CONSTANT(WINDOW_FLAG_ALWAYS_ON_TOP_BIT); - BIND_ENUM_CONSTANT(WINDOW_FLAG_TRANSPARENT_BIT); - BIND_ENUM_CONSTANT(WINDOW_FLAG_NO_FOCUS_BIT); BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTY); BIND_ENUM_CONSTANT(LATIN_KEYBOARD_QWERTZ); diff --git a/servers/display_server.h b/servers/display_server.h index 4803eeb084..1956bcafca 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -83,7 +83,7 @@ protected: static DisplayServerCreate server_create_functions[MAX_SERVERS]; static int server_create_count; - friend class VisualServerRaster; + friend class RenderingServerRaster; virtual void _set_use_vsync(bool p_enable); public: @@ -200,6 +200,10 @@ public: WINDOW_FLAG_TRANSPARENT, WINDOW_FLAG_NO_FOCUS, WINDOW_FLAG_MAX, + }; + + // Separate enum otherwise we get warnings in switches not handling all values. + enum WindowFlagsBit { WINDOW_FLAG_RESIZE_DISABLED_BIT = (1 << WINDOW_FLAG_RESIZE_DISABLED), WINDOW_FLAG_BORDERLESS_BIT = (1 << WINDOW_FLAG_BORDERLESS), WINDOW_FLAG_ALWAYS_ON_TOP_BIT = (1 << WINDOW_FLAG_ALWAYS_ON_TOP), diff --git a/servers/navigation_2d_server.cpp b/servers/navigation_server_2d.cpp index d9b53122e2..17f2232c72 100644 --- a/servers/navigation_2d_server.cpp +++ b/servers/navigation_server_2d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* navigation_2d_server.cpp */ +/* navigation_server_2d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,77 +28,77 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "servers/navigation_2d_server.h" +#include "servers/navigation_server_2d.h" #include "core/math/transform.h" #include "core/math/transform_2d.h" -#include "servers/navigation_server.h" +#include "servers/navigation_server_3d.h" /** @author AndreaCatania */ -Navigation2DServer *Navigation2DServer::singleton = NULL; +NavigationServer2D *NavigationServer2D::singleton = nullptr; -#define FORWARD_0_C(FUNC_NAME) \ - Navigation2DServer::FUNC_NAME() \ - const { \ - return NavigationServer::get_singleton()->FUNC_NAME(); \ +#define FORWARD_0_C(FUNC_NAME) \ + NavigationServer2D::FUNC_NAME() \ + const { \ + return NavigationServer3D::get_singleton()->FUNC_NAME(); \ } -#define FORWARD_1(FUNC_NAME, T_0, D_0, CONV_0) \ - Navigation2DServer::FUNC_NAME(T_0 D_0) { \ - return NavigationServer::get_singleton_mut()->FUNC_NAME(CONV_0(D_0)); \ +#define FORWARD_1(FUNC_NAME, T_0, D_0, CONV_0) \ + NavigationServer2D::FUNC_NAME(T_0 D_0) { \ + return NavigationServer3D::get_singleton_mut()->FUNC_NAME(CONV_0(D_0)); \ } -#define FORWARD_1_C(FUNC_NAME, T_0, D_0, CONV_0) \ - Navigation2DServer::FUNC_NAME(T_0 D_0) \ - const { \ - return NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0)); \ +#define FORWARD_1_C(FUNC_NAME, T_0, D_0, CONV_0) \ + NavigationServer2D::FUNC_NAME(T_0 D_0) \ + const { \ + return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0)); \ } -#define FORWARD_2_C(FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \ - Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1) \ - const { \ - return NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1)); \ +#define FORWARD_2_C(FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \ + NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1) \ + const { \ + return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1)); \ } -#define FORWARD_2_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \ - Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1) \ - const { \ - return CONV_R(NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1))); \ +#define FORWARD_2_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, CONV_0, CONV_1) \ + NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1) \ + const { \ + return CONV_R(NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1))); \ } -#define FORWARD_4_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \ - Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \ - const { \ - return CONV_R(NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3))); \ +#define FORWARD_4_R_C(CONV_R, FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \ + NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \ + const { \ + return CONV_R(NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3))); \ } -#define FORWARD_4_C(FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \ - Navigation2DServer::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \ - const { \ - return NavigationServer::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3)); \ +#define FORWARD_4_C(FUNC_NAME, T_0, D_0, T_1, D_1, T_2, D_2, T_3, D_3, CONV_0, CONV_1, CONV_2, CONV_3) \ + NavigationServer2D::FUNC_NAME(T_0 D_0, T_1 D_1, T_2 D_2, T_3 D_3) \ + const { \ + return NavigationServer3D::get_singleton()->FUNC_NAME(CONV_0(D_0), CONV_1(D_1), CONV_2(D_2), CONV_3(D_3)); \ } -RID rid_to_rid(const RID d) { +static RID rid_to_rid(const RID d) { return d; } -bool bool_to_bool(const bool d) { +static bool bool_to_bool(const bool d) { return d; } -int int_to_int(const int d) { +static int int_to_int(const int d) { return d; } -real_t real_to_real(const real_t d) { +static real_t real_to_real(const real_t d) { return d; } -Vector3 v2_to_v3(const Vector2 d) { +static Vector3 v2_to_v3(const Vector2 d) { return Vector3(d.x, 0.0, d.y); } -Vector2 v3_to_v2(const Vector3 &d) { +static Vector2 v3_to_v2(const Vector3 &d) { return Vector2(d.x, d.z); } -Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) { +static Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) { Vector<Vector2> nd; nd.resize(d.size()); for (int i(0); i < nd.size(); i++) { @@ -106,22 +106,22 @@ Vector<Vector2> vector_v3_to_v2(const Vector<Vector3> &d) { } return nd; } -Transform trf2_to_trf3(const Transform2D &d) { +static Transform trf2_to_trf3(const Transform2D &d) { Vector3 o(v2_to_v3(d.get_origin())); Basis b; b.rotate(Vector3(0, 1, 0), d.get_rotation()); return Transform(b, o); } -Object *obj_to_obj(Object *d) { +static Object *obj_to_obj(Object *d) { return d; } -StringName sn_to_sn(StringName &d) { +static StringName sn_to_sn(StringName &d) { return d; } -Variant var_to_var(Variant &d) { +static Variant var_to_var(Variant &d) { return d; } -Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) { +static Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) { if (d.is_valid()) { return d->get_mesh(); } else { @@ -129,45 +129,45 @@ Ref<NavigationMesh> poly_to_mesh(Ref<NavigationPolygon> d) { } } -void Navigation2DServer::_bind_methods() { - ClassDB::bind_method(D_METHOD("map_create"), &Navigation2DServer::map_create); - ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &Navigation2DServer::map_set_active); - ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &Navigation2DServer::map_is_active); - ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &Navigation2DServer::map_set_cell_size); - ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &Navigation2DServer::map_get_cell_size); - ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &Navigation2DServer::map_set_edge_connection_margin); - ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &Navigation2DServer::map_get_edge_connection_margin); - ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &Navigation2DServer::map_get_path); - ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &Navigation2DServer::map_get_closest_point); - ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &Navigation2DServer::map_get_closest_point_owner); - - ClassDB::bind_method(D_METHOD("region_create"), &Navigation2DServer::region_create); - ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &Navigation2DServer::region_set_map); - ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &Navigation2DServer::region_set_transform); - ClassDB::bind_method(D_METHOD("region_set_navpoly", "region", "nav_poly"), &Navigation2DServer::region_set_navpoly); - - ClassDB::bind_method(D_METHOD("agent_create"), &Navigation2DServer::agent_create); - ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &Navigation2DServer::agent_set_map); - ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &Navigation2DServer::agent_set_neighbor_dist); - ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &Navigation2DServer::agent_set_max_neighbors); - ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &Navigation2DServer::agent_set_time_horizon); - ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &Navigation2DServer::agent_set_radius); - ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &Navigation2DServer::agent_set_max_speed); - ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &Navigation2DServer::agent_set_velocity); - ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &Navigation2DServer::agent_set_target_velocity); - ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &Navigation2DServer::agent_set_position); - ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &Navigation2DServer::agent_is_map_changed); - ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &Navigation2DServer::agent_set_callback, DEFVAL(Variant())); - - ClassDB::bind_method(D_METHOD("free", "object"), &Navigation2DServer::free); -} - -Navigation2DServer::Navigation2DServer() { +void NavigationServer2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer2D::map_create); + ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer2D::map_set_active); + ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer2D::map_is_active); + ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer2D::map_set_cell_size); + ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer2D::map_get_cell_size); + ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer2D::map_set_edge_connection_margin); + ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer2D::map_get_edge_connection_margin); + ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer2D::map_get_path); + ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer2D::map_get_closest_point); + ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer2D::map_get_closest_point_owner); + + ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer2D::region_create); + ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer2D::region_set_map); + ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer2D::region_set_transform); + ClassDB::bind_method(D_METHOD("region_set_navpoly", "region", "nav_poly"), &NavigationServer2D::region_set_navpoly); + + ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer2D::agent_create); + ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer2D::agent_set_map); + ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &NavigationServer2D::agent_set_neighbor_dist); + ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer2D::agent_set_max_neighbors); + ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &NavigationServer2D::agent_set_time_horizon); + ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer2D::agent_set_radius); + ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer2D::agent_set_max_speed); + ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer2D::agent_set_velocity); + ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer2D::agent_set_target_velocity); + ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer2D::agent_set_position); + ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer2D::agent_is_map_changed); + ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer2D::agent_set_callback, DEFVAL(Variant())); + + ClassDB::bind_method(D_METHOD("free", "object"), &NavigationServer2D::free); +} + +NavigationServer2D::NavigationServer2D() { singleton = this; } -Navigation2DServer::~Navigation2DServer() { - singleton = NULL; +NavigationServer2D::~NavigationServer2D() { + singleton = nullptr; } RID FORWARD_0_C(map_create); @@ -192,13 +192,13 @@ void FORWARD_2_C(region_set_map, RID, p_region, RID, p_map, rid_to_rid, rid_to_r void FORWARD_2_C(region_set_transform, RID, p_region, Transform2D, p_transform, rid_to_rid, trf2_to_trf3); -void Navigation2DServer::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) const { - NavigationServer::get_singleton()->region_set_navmesh(p_region, poly_to_mesh(p_nav_mesh)); +void NavigationServer2D::region_set_navpoly(RID p_region, Ref<NavigationPolygon> p_nav_mesh) const { + NavigationServer3D::get_singleton()->region_set_navmesh(p_region, poly_to_mesh(p_nav_mesh)); } -RID Navigation2DServer::agent_create() const { - RID agent = NavigationServer::get_singleton()->agent_create(); - NavigationServer::get_singleton()->agent_set_ignore_y(agent, true); +RID NavigationServer2D::agent_create() const { + RID agent = NavigationServer3D::get_singleton()->agent_create(); + NavigationServer3D::get_singleton()->agent_set_ignore_y(agent, true); return agent; } diff --git a/servers/navigation_2d_server.h b/servers/navigation_server_2d.h index 35902f83d4..d7384bae74 100644 --- a/servers/navigation_2d_server.h +++ b/servers/navigation_server_2d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* navigation_2d_server.h */ +/* navigation_server_2d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -39,21 +39,21 @@ #include "core/rid.h" #include "scene/2d/navigation_region_2d.h" -// This server exposes the 3D `NavigationServer` features in the 2D world. -class Navigation2DServer : public Object { - GDCLASS(Navigation2DServer, Object); +// This server exposes the `NavigationServer3D` features in the 2D world. +class NavigationServer2D : public Object { + GDCLASS(NavigationServer2D, Object); - static Navigation2DServer *singleton; + static NavigationServer2D *singleton; protected: static void _bind_methods(); public: /// Thread safe, can be used across many threads. - static const Navigation2DServer *get_singleton() { return singleton; } + static const NavigationServer2D *get_singleton() { return singleton; } /// MUST be used in single thread! - static Navigation2DServer *get_singleton_mut() { return singleton; } + static NavigationServer2D *get_singleton_mut() { return singleton; } /// Create a new map. virtual RID map_create() const; @@ -156,8 +156,8 @@ public: /// Destroy the `RID` virtual void free(RID p_object) const; - Navigation2DServer(); - virtual ~Navigation2DServer(); + NavigationServer2D(); + virtual ~NavigationServer2D(); }; #endif diff --git a/servers/navigation_server.cpp b/servers/navigation_server_3d.cpp index f2b727ac47..67a4d0e413 100644 --- a/servers/navigation_server.cpp +++ b/servers/navigation_server_3d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* navigation_server.cpp */ +/* navigation_server_3d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -32,76 +32,76 @@ @author AndreaCatania */ -#include "navigation_server.h" - -NavigationServer *NavigationServer::singleton = NULL; - -void NavigationServer::_bind_methods() { - - ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer::map_create); - ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer::map_set_active); - ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer::map_is_active); - ClassDB::bind_method(D_METHOD("map_set_up", "map", "up"), &NavigationServer::map_set_up); - ClassDB::bind_method(D_METHOD("map_get_up", "map"), &NavigationServer::map_get_up); - ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer::map_set_cell_size); - ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer::map_get_cell_size); - ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer::map_set_edge_connection_margin); - ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer::map_get_edge_connection_margin); - ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer::map_get_path); - ClassDB::bind_method(D_METHOD("map_get_closest_point_to_segment", "map", "start", "end", "use_collision"), &NavigationServer::map_get_closest_point_to_segment, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer::map_get_closest_point); - ClassDB::bind_method(D_METHOD("map_get_closest_point_normal", "map", "to_point"), &NavigationServer::map_get_closest_point_normal); - ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer::map_get_closest_point_owner); - - ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer::region_create); - ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer::region_set_map); - ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer::region_set_transform); - ClassDB::bind_method(D_METHOD("region_set_navmesh", "region", "nav_mesh"), &NavigationServer::region_set_navmesh); - ClassDB::bind_method(D_METHOD("region_bake_navmesh", "mesh", "node"), &NavigationServer::region_bake_navmesh); - - ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer::agent_create); - ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer::agent_set_map); - ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &NavigationServer::agent_set_neighbor_dist); - ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer::agent_set_max_neighbors); - ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &NavigationServer::agent_set_time_horizon); - ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer::agent_set_radius); - ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer::agent_set_max_speed); - ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer::agent_set_velocity); - ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer::agent_set_target_velocity); - ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer::agent_set_position); - ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer::agent_is_map_changed); - ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer::agent_set_callback, DEFVAL(Variant())); - - ClassDB::bind_method(D_METHOD("free", "object"), &NavigationServer::free); - - ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer::set_active); - ClassDB::bind_method(D_METHOD("process", "delta_time"), &NavigationServer::process); +#include "navigation_server_3d.h" + +NavigationServer3D *NavigationServer3D::singleton = nullptr; + +void NavigationServer3D::_bind_methods() { + + ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer3D::map_create); + ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer3D::map_set_active); + ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer3D::map_is_active); + ClassDB::bind_method(D_METHOD("map_set_up", "map", "up"), &NavigationServer3D::map_set_up); + ClassDB::bind_method(D_METHOD("map_get_up", "map"), &NavigationServer3D::map_get_up); + ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer3D::map_set_cell_size); + ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer3D::map_get_cell_size); + ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer3D::map_set_edge_connection_margin); + ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer3D::map_get_edge_connection_margin); + ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize"), &NavigationServer3D::map_get_path); + ClassDB::bind_method(D_METHOD("map_get_closest_point_to_segment", "map", "start", "end", "use_collision"), &NavigationServer3D::map_get_closest_point_to_segment, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer3D::map_get_closest_point); + ClassDB::bind_method(D_METHOD("map_get_closest_point_normal", "map", "to_point"), &NavigationServer3D::map_get_closest_point_normal); + ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer3D::map_get_closest_point_owner); + + ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer3D::region_create); + ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer3D::region_set_map); + ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer3D::region_set_transform); + ClassDB::bind_method(D_METHOD("region_set_navmesh", "region", "nav_mesh"), &NavigationServer3D::region_set_navmesh); + ClassDB::bind_method(D_METHOD("region_bake_navmesh", "mesh", "node"), &NavigationServer3D::region_bake_navmesh); + + ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer3D::agent_create); + ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer3D::agent_set_map); + ClassDB::bind_method(D_METHOD("agent_set_neighbor_dist", "agent", "dist"), &NavigationServer3D::agent_set_neighbor_dist); + ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer3D::agent_set_max_neighbors); + ClassDB::bind_method(D_METHOD("agent_set_time_horizon", "agent", "time"), &NavigationServer3D::agent_set_time_horizon); + ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer3D::agent_set_radius); + ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer3D::agent_set_max_speed); + ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer3D::agent_set_velocity); + ClassDB::bind_method(D_METHOD("agent_set_target_velocity", "agent", "target_velocity"), &NavigationServer3D::agent_set_target_velocity); + ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer3D::agent_set_position); + ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer3D::agent_is_map_changed); + ClassDB::bind_method(D_METHOD("agent_set_callback", "agent", "receiver", "method", "userdata"), &NavigationServer3D::agent_set_callback, DEFVAL(Variant())); + + ClassDB::bind_method(D_METHOD("free", "object"), &NavigationServer3D::free); + + ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer3D::set_active); + ClassDB::bind_method(D_METHOD("process", "delta_time"), &NavigationServer3D::process); } -const NavigationServer *NavigationServer::get_singleton() { +const NavigationServer3D *NavigationServer3D::get_singleton() { return singleton; } -NavigationServer *NavigationServer::get_singleton_mut() { +NavigationServer3D *NavigationServer3D::get_singleton_mut() { return singleton; } -NavigationServer::NavigationServer() { - ERR_FAIL_COND(singleton != NULL); +NavigationServer3D::NavigationServer3D() { + ERR_FAIL_COND(singleton != nullptr); singleton = this; } -NavigationServer::~NavigationServer() { - singleton = NULL; +NavigationServer3D::~NavigationServer3D() { + singleton = nullptr; } -NavigationServerCallback NavigationServerManager::create_callback = NULL; +NavigationServer3DCallback NavigationServer3DManager::create_callback = nullptr; -void NavigationServerManager::set_default_server(NavigationServerCallback p_callback) { +void NavigationServer3DManager::set_default_server(NavigationServer3DCallback p_callback) { create_callback = p_callback; } -NavigationServer *NavigationServerManager::new_default_server() { - ERR_FAIL_COND_V(create_callback == NULL, NULL); +NavigationServer3D *NavigationServer3DManager::new_default_server() { + ERR_FAIL_COND_V(create_callback == nullptr, nullptr); return create_callback(); } diff --git a/servers/navigation_server.h b/servers/navigation_server_3d.h index 2ea8e787cf..c34bd2391b 100644 --- a/servers/navigation_server.h +++ b/servers/navigation_server_3d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* navigation_server.h */ +/* navigation_server_3d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -45,20 +45,20 @@ /// /// Note: All the `set` functions are commands executed during the `sync` phase, /// don't expect that a change is immediately propagated. -class NavigationServer : public Object { - GDCLASS(NavigationServer, Object); +class NavigationServer3D : public Object { + GDCLASS(NavigationServer3D, Object); - static NavigationServer *singleton; + static NavigationServer3D *singleton; protected: static void _bind_methods(); public: /// Thread safe, can be used across many threads. - static const NavigationServer *get_singleton(); + static const NavigationServer3D *get_singleton(); /// MUST be used in single thread! - static NavigationServer *get_singleton_mut(); + static NavigationServer3D *get_singleton_mut(); /// Create a new map. virtual RID map_create() const = 0; @@ -181,19 +181,19 @@ public: /// Note: This function is not thread safe. virtual void process(real_t delta_time) = 0; - NavigationServer(); - virtual ~NavigationServer(); + NavigationServer3D(); + virtual ~NavigationServer3D(); }; -typedef NavigationServer *(*NavigationServerCallback)(); +typedef NavigationServer3D *(*NavigationServer3DCallback)(); /// Manager used for the server singleton registration -class NavigationServerManager { - static NavigationServerCallback create_callback; +class NavigationServer3DManager { + static NavigationServer3DCallback create_callback; public: - static void set_default_server(NavigationServerCallback p_callback); - static NavigationServer *new_default_server(); + static void set_default_server(NavigationServer3DCallback p_callback); + static NavigationServer3D *new_default_server(); }; #endif diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp deleted file mode 100644 index 25b21a5394..0000000000 --- a/servers/physics/physics_server_sw.cpp +++ /dev/null @@ -1,1589 +0,0 @@ -/*************************************************************************/ -/* physics_server_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "physics_server_sw.h" - -#include "broad_phase_basic.h" -#include "broad_phase_octree.h" -#include "core/debugger/engine_debugger.h" -#include "core/os/os.h" -#include "joints/cone_twist_joint_sw.h" -#include "joints/generic_6dof_joint_sw.h" -#include "joints/hinge_joint_sw.h" -#include "joints/pin_joint_sw.h" -#include "joints/slider_joint_sw.h" - -#define FLUSH_QUERY_CHECK(m_object) \ - ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead."); - -RID PhysicsServerSW::shape_create(ShapeType p_shape) { - - ShapeSW *shape = NULL; - switch (p_shape) { - - case SHAPE_PLANE: { - - shape = memnew(PlaneShapeSW); - } break; - case SHAPE_RAY: { - - shape = memnew(RayShapeSW); - } break; - case SHAPE_SPHERE: { - - shape = memnew(SphereShapeSW); - } break; - case SHAPE_BOX: { - - shape = memnew(BoxShapeSW); - } break; - case SHAPE_CAPSULE: { - - shape = memnew(CapsuleShapeSW); - } break; - case SHAPE_CYLINDER: { - - ERR_FAIL_V_MSG(RID(), "CylinderShape is not supported in GodotPhysics. Please switch to Bullet in the Project Settings."); - } break; - case SHAPE_CONVEX_POLYGON: { - - shape = memnew(ConvexPolygonShapeSW); - } break; - case SHAPE_CONCAVE_POLYGON: { - - shape = memnew(ConcavePolygonShapeSW); - } break; - case SHAPE_HEIGHTMAP: { - - shape = memnew(HeightMapShapeSW); - } break; - case SHAPE_CUSTOM: { - - ERR_FAIL_V(RID()); - - } break; - } - - RID id = shape_owner.make_rid(shape); - shape->set_self(id); - - return id; -}; - -void PhysicsServerSW::shape_set_data(RID p_shape, const Variant &p_data) { - - ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND(!shape); - shape->set_data(p_data); -}; - -void PhysicsServerSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { - - ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND(!shape); - shape->set_custom_bias(p_bias); -} - -PhysicsServer::ShapeType PhysicsServerSW::shape_get_type(RID p_shape) const { - - const ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM); - return shape->get_type(); -}; - -Variant PhysicsServerSW::shape_get_data(RID p_shape) const { - - const ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND_V(!shape, Variant()); - ERR_FAIL_COND_V(!shape->is_configured(), Variant()); - return shape->get_data(); -}; - -void PhysicsServerSW::shape_set_margin(RID p_shape, real_t p_margin) { -} - -real_t PhysicsServerSW::shape_get_margin(RID p_shape) const { - return 0.0; -} - -real_t PhysicsServerSW::shape_get_custom_solver_bias(RID p_shape) const { - - const ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND_V(!shape, 0); - return shape->get_custom_bias(); -} - -RID PhysicsServerSW::space_create() { - - SpaceSW *space = memnew(SpaceSW); - RID id = space_owner.make_rid(space); - space->set_self(id); - RID area_id = area_create(); - AreaSW *area = area_owner.getornull(area_id); - ERR_FAIL_COND_V(!area, RID()); - space->set_default_area(area); - area->set_space(space); - area->set_priority(-1); - RID sgb = body_create(); - body_set_space(sgb, id); - body_set_mode(sgb, BODY_MODE_STATIC); - space->set_static_global_body(sgb); - - return id; -}; - -void PhysicsServerSW::space_set_active(RID p_space, bool p_active) { - - SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND(!space); - if (p_active) - active_spaces.insert(space); - else - active_spaces.erase(space); -} - -bool PhysicsServerSW::space_is_active(RID p_space) const { - - const SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, false); - - return active_spaces.has(space); -} - -void PhysicsServerSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { - - SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND(!space); - - space->set_param(p_param, p_value); -} - -real_t PhysicsServerSW::space_get_param(RID p_space, SpaceParameter p_param) const { - - const SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, 0); - return space->get_param(p_param); -} - -PhysicsDirectSpaceState *PhysicsServerSW::space_get_direct_state(RID p_space) { - - SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, NULL); - ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification."); - - return space->get_direct_state(); -} - -void PhysicsServerSW::space_set_debug_contacts(RID p_space, int p_max_contacts) { - - SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND(!space); - space->set_debug_contacts(p_max_contacts); -} - -Vector<Vector3> PhysicsServerSW::space_get_contacts(RID p_space) const { - - SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, Vector<Vector3>()); - return space->get_debug_contacts(); -} - -int PhysicsServerSW::space_get_contact_count(RID p_space) const { - - SpaceSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, 0); - return space->get_debug_contact_count(); -} - -RID PhysicsServerSW::area_create() { - - AreaSW *area = memnew(AreaSW); - RID rid = area_owner.make_rid(area); - area->set_self(rid); - return rid; -}; - -void PhysicsServerSW::area_set_space(RID p_area, RID p_space) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - SpaceSW *space = NULL; - if (p_space.is_valid()) { - space = space_owner.getornull(p_space); - ERR_FAIL_COND(!space); - } - - if (area->get_space() == space) - return; //pointless - - area->clear_constraints(); - area->set_space(space); -}; - -RID PhysicsServerSW::area_get_space(RID p_area) const { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, RID()); - - SpaceSW *space = area->get_space(); - if (!space) - return RID(); - return space->get_self(); -}; - -void PhysicsServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_space_override_mode(p_mode); -} - -PhysicsServer::AreaSpaceOverrideMode PhysicsServerSW::area_get_space_override_mode(RID p_area) const { - - const AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED); - - return area->get_space_override_mode(); -} - -void PhysicsServerSW::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND(!shape); - - area->add_shape(shape, p_transform, p_disabled); -} - -void PhysicsServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND(!shape); - ERR_FAIL_COND(!shape->is_configured()); - - area->set_shape(p_shape_idx, shape); -} - -void PhysicsServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_shape_transform(p_shape_idx, p_transform); -} - -int PhysicsServerSW::area_get_shape_count(RID p_area) const { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, -1); - - return area->get_shape_count(); -} -RID PhysicsServerSW::area_get_shape(RID p_area, int p_shape_idx) const { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, RID()); - - ShapeSW *shape = area->get_shape(p_shape_idx); - ERR_FAIL_COND_V(!shape, RID()); - - return shape->get_self(); -} -Transform PhysicsServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, Transform()); - - return area->get_shape_transform(p_shape_idx); -} - -void PhysicsServerSW::area_remove_shape(RID p_area, int p_shape_idx) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->remove_shape(p_shape_idx); -} - -void PhysicsServerSW::area_clear_shapes(RID p_area) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - while (area->get_shape_count()) - area->remove_shape(0); -} - -void PhysicsServerSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count()); - FLUSH_QUERY_CHECK(area); - area->set_shape_as_disabled(p_shape_idx, p_disabled); -} - -void PhysicsServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) { - - if (space_owner.owns(p_area)) { - SpaceSW *space = space_owner.getornull(p_area); - p_area = space->get_default_area()->get_self(); - } - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - area->set_instance_id(p_id); -} -ObjectID PhysicsServerSW::area_get_object_instance_id(RID p_area) const { - - if (space_owner.owns(p_area)) { - SpaceSW *space = space_owner.getornull(p_area); - p_area = space->get_default_area()->get_self(); - } - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, ObjectID()); - return area->get_instance_id(); -} - -void PhysicsServerSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { - - if (space_owner.owns(p_area)) { - SpaceSW *space = space_owner.getornull(p_area); - p_area = space->get_default_area()->get_self(); - } - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - area->set_param(p_param, p_value); -}; - -void PhysicsServerSW::area_set_transform(RID p_area, const Transform &p_transform) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - area->set_transform(p_transform); -}; - -Variant PhysicsServerSW::area_get_param(RID p_area, AreaParameter p_param) const { - - if (space_owner.owns(p_area)) { - SpaceSW *space = space_owner.getornull(p_area); - p_area = space->get_default_area()->get_self(); - } - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, Variant()); - - return area->get_param(p_param); -}; - -Transform PhysicsServerSW::area_get_transform(RID p_area) const { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, Transform()); - - return area->get_transform(); -}; - -void PhysicsServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_collision_layer(p_layer); -} - -void PhysicsServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_collision_mask(p_mask); -} - -void PhysicsServerSW::area_set_monitorable(RID p_area, bool p_monitorable) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - FLUSH_QUERY_CHECK(area); - - area->set_monitorable(p_monitorable); -} - -void PhysicsServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); -} - -void PhysicsServerSW::area_set_ray_pickable(RID p_area, bool p_enable) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_ray_pickable(p_enable); -} - -bool PhysicsServerSW::area_is_ray_pickable(RID p_area) const { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND_V(!area, false); - - return area->is_ray_pickable(); -} - -void PhysicsServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { - - AreaSW *area = area_owner.getornull(p_area); - ERR_FAIL_COND(!area); - - area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); -} - -/* BODY API */ - -RID PhysicsServerSW::body_create(BodyMode p_mode, bool p_init_sleeping) { - - BodySW *body = memnew(BodySW); - if (p_mode != BODY_MODE_RIGID) - body->set_mode(p_mode); - if (p_init_sleeping) - body->set_state(BODY_STATE_SLEEPING, p_init_sleeping); - RID rid = body_owner.make_rid(body); - body->set_self(rid); - return rid; -}; - -void PhysicsServerSW::body_set_space(RID p_body, RID p_space) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - SpaceSW *space = NULL; - if (p_space.is_valid()) { - space = space_owner.getornull(p_space); - ERR_FAIL_COND(!space); - } - - if (body->get_space() == space) - return; //pointless - - body->clear_constraint_map(); - body->set_space(space); -}; - -RID PhysicsServerSW::body_get_space(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, RID()); - - SpaceSW *space = body->get_space(); - if (!space) - return RID(); - return space->get_self(); -}; - -void PhysicsServerSW::body_set_mode(RID p_body, BodyMode p_mode) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_mode(p_mode); -}; - -PhysicsServer::BodyMode PhysicsServerSW::body_get_mode(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, BODY_MODE_STATIC); - - return body->get_mode(); -}; - -void PhysicsServerSW::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND(!shape); - - body->add_shape(shape, p_transform, p_disabled); -} - -void PhysicsServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - ShapeSW *shape = shape_owner.getornull(p_shape); - ERR_FAIL_COND(!shape); - ERR_FAIL_COND(!shape->is_configured()); - - body->set_shape(p_shape_idx, shape); -} -void PhysicsServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_shape_transform(p_shape_idx, p_transform); -} - -int PhysicsServerSW::body_get_shape_count(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, -1); - - return body->get_shape_count(); -} -RID PhysicsServerSW::body_get_shape(RID p_body, int p_shape_idx) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, RID()); - - ShapeSW *shape = body->get_shape(p_shape_idx); - ERR_FAIL_COND_V(!shape, RID()); - - return shape->get_self(); -} - -void PhysicsServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); - FLUSH_QUERY_CHECK(body); - - body->set_shape_as_disabled(p_shape_idx, p_disabled); -} - -Transform PhysicsServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, Transform()); - - return body->get_shape_transform(p_shape_idx); -} - -void PhysicsServerSW::body_remove_shape(RID p_body, int p_shape_idx) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->remove_shape(p_shape_idx); -} - -void PhysicsServerSW::body_clear_shapes(RID p_body) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - while (body->get_shape_count()) - body->remove_shape(0); -} - -void PhysicsServerSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_continuous_collision_detection(p_enable); -} - -bool PhysicsServerSW::body_is_continuous_collision_detection_enabled(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, false); - - return body->is_continuous_collision_detection_enabled(); -} - -void PhysicsServerSW::body_set_collision_layer(RID p_body, uint32_t p_layer) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_collision_layer(p_layer); - body->wakeup(); -} - -uint32_t PhysicsServerSW::body_get_collision_layer(RID p_body) const { - - const BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - - return body->get_collision_layer(); -} - -void PhysicsServerSW::body_set_collision_mask(RID p_body, uint32_t p_mask) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_collision_mask(p_mask); - body->wakeup(); -} - -uint32_t PhysicsServerSW::body_get_collision_mask(RID p_body) const { - - const BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - - return body->get_collision_mask(); -} - -void PhysicsServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_instance_id(p_id); -}; - -ObjectID PhysicsServerSW::body_get_object_instance_id(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, ObjectID()); - - return body->get_instance_id(); -}; - -void PhysicsServerSW::body_set_user_flags(RID p_body, uint32_t p_flags) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); -}; - -uint32_t PhysicsServerSW::body_get_user_flags(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - - return 0; -}; - -void PhysicsServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_param(p_param, p_value); -}; - -real_t PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - - return body->get_param(p_param); -}; - -void PhysicsServerSW::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - body->set_kinematic_margin(p_margin); -} - -real_t PhysicsServerSW::body_get_kinematic_safe_margin(RID p_body) const { - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - - return body->get_kinematic_margin(); -} - -void PhysicsServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_state(p_state, p_variant); -}; - -Variant PhysicsServerSW::body_get_state(RID p_body, BodyState p_state) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, Variant()); - - return body->get_state(p_state); -}; - -void PhysicsServerSW::body_set_applied_force(RID p_body, const Vector3 &p_force) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_applied_force(p_force); - body->wakeup(); -}; - -Vector3 PhysicsServerSW::body_get_applied_force(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, Vector3()); - return body->get_applied_force(); -}; - -void PhysicsServerSW::body_set_applied_torque(RID p_body, const Vector3 &p_torque) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_applied_torque(p_torque); - body->wakeup(); -}; - -Vector3 PhysicsServerSW::body_get_applied_torque(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, Vector3()); - - return body->get_applied_torque(); -}; - -void PhysicsServerSW::body_add_central_force(RID p_body, const Vector3 &p_force) { - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->add_central_force(p_force); - body->wakeup(); -} - -void PhysicsServerSW::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) { - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->add_force(p_force, p_pos); - body->wakeup(); -}; - -void PhysicsServerSW::body_add_torque(RID p_body, const Vector3 &p_torque) { - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->add_torque(p_torque); - body->wakeup(); -}; - -void PhysicsServerSW::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) { - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - _update_shapes(); - - body->apply_central_impulse(p_impulse); - body->wakeup(); -} - -void PhysicsServerSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - _update_shapes(); - - body->apply_impulse(p_pos, p_impulse); - body->wakeup(); -}; - -void PhysicsServerSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - _update_shapes(); - - body->apply_torque_impulse(p_impulse); - body->wakeup(); -}; - -void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - _update_shapes(); - - Vector3 v = body->get_linear_velocity(); - Vector3 axis = p_axis_velocity.normalized(); - v -= axis * axis.dot(v); - v += p_axis_velocity; - body->set_linear_velocity(v); - body->wakeup(); -}; - -void PhysicsServerSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_axis_lock(p_axis, p_lock); - body->wakeup(); -} - -bool PhysicsServerSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { - - const BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - return body->is_axis_locked(p_axis); -} - -void PhysicsServerSW::body_add_collision_exception(RID p_body, RID p_body_b) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->add_exception(p_body_b); - body->wakeup(); -}; - -void PhysicsServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->remove_exception(p_body_b); - body->wakeup(); -}; - -void PhysicsServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - for (int i = 0; i < body->get_exceptions().size(); i++) { - p_exceptions->push_back(body->get_exceptions()[i]); - } -}; - -void PhysicsServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); -}; - -real_t PhysicsServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, 0); - return 0; -}; - -void PhysicsServerSW::body_set_omit_force_integration(RID p_body, bool p_omit) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - - body->set_omit_force_integration(p_omit); -}; - -bool PhysicsServerSW::body_is_omitting_force_integration(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, false); - return body->get_omit_force_integration(); -}; - -void PhysicsServerSW::body_set_max_contacts_reported(RID p_body, int p_contacts) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - body->set_max_contacts_reported(p_contacts); -} - -int PhysicsServerSW::body_get_max_contacts_reported(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, -1); - return body->get_max_contacts_reported(); -} - -void PhysicsServerSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata); -} - -void PhysicsServerSW::body_set_ray_pickable(RID p_body, bool p_enable) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - body->set_ray_pickable(p_enable); -} - -bool PhysicsServerSW::body_is_ray_pickable(RID p_body) const { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, false); - return body->is_ray_pickable(); -} - -bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, false); - ERR_FAIL_COND_V(!body->get_space(), false); - ERR_FAIL_COND_V(body->get_space()->is_locked(), false); - - _update_shapes(); - - return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, body->get_kinematic_margin(), r_result, p_exclude_raycast_shapes); -} - -int PhysicsServerSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, false); - ERR_FAIL_COND_V(!body->get_space(), false); - ERR_FAIL_COND_V(body->get_space()->is_locked(), false); - - _update_shapes(); - - return body->get_space()->test_body_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin); -} - -PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) { - - BodySW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, NULL); - ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification."); - - direct_state->body = body; - return direct_state; -} - -/* JOINT API */ - -RID PhysicsServerSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) { - - BodySW *body_A = body_owner.getornull(p_body_A); - ERR_FAIL_COND_V(!body_A, RID()); - - if (!p_body_B.is_valid()) { - ERR_FAIL_COND_V(!body_A->get_space(), RID()); - p_body_B = body_A->get_space()->get_static_global_body(); - } - - BodySW *body_B = body_owner.getornull(p_body_B); - ERR_FAIL_COND_V(!body_B, RID()); - - ERR_FAIL_COND_V(body_A == body_B, RID()); - - JointSW *joint = memnew(PinJointSW(body_A, p_local_A, body_B, p_local_B)); - RID rid = joint_owner.make_rid(joint); - joint->set_self(rid); - return rid; -} - -void PhysicsServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_PIN); - PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); - pin_joint->set_param(p_param, p_value); -} -real_t PhysicsServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, 0); - ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0); - PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); - return pin_joint->get_param(p_param); -} - -void PhysicsServerSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_PIN); - PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); - pin_joint->set_pos_a(p_A); -} -Vector3 PhysicsServerSW::pin_joint_get_local_a(RID p_joint) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, Vector3()); - ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); - PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); - return pin_joint->get_position_a(); -} - -void PhysicsServerSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_PIN); - PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); - pin_joint->set_pos_b(p_B); -} -Vector3 PhysicsServerSW::pin_joint_get_local_b(RID p_joint) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, Vector3()); - ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); - PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); - return pin_joint->get_position_b(); -} - -RID PhysicsServerSW::joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B) { - - BodySW *body_A = body_owner.getornull(p_body_A); - ERR_FAIL_COND_V(!body_A, RID()); - - if (!p_body_B.is_valid()) { - ERR_FAIL_COND_V(!body_A->get_space(), RID()); - p_body_B = body_A->get_space()->get_static_global_body(); - } - - BodySW *body_B = body_owner.getornull(p_body_B); - ERR_FAIL_COND_V(!body_B, RID()); - - ERR_FAIL_COND_V(body_A == body_B, RID()); - - JointSW *joint = memnew(HingeJointSW(body_A, body_B, p_frame_A, p_frame_B)); - RID rid = joint_owner.make_rid(joint); - joint->set_self(rid); - return rid; -} - -RID PhysicsServerSW::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) { - - BodySW *body_A = body_owner.getornull(p_body_A); - ERR_FAIL_COND_V(!body_A, RID()); - - if (!p_body_B.is_valid()) { - ERR_FAIL_COND_V(!body_A->get_space(), RID()); - p_body_B = body_A->get_space()->get_static_global_body(); - } - - BodySW *body_B = body_owner.getornull(p_body_B); - ERR_FAIL_COND_V(!body_B, RID()); - - ERR_FAIL_COND_V(body_A == body_B, RID()); - - JointSW *joint = memnew(HingeJointSW(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B)); - RID rid = joint_owner.make_rid(joint); - joint->set_self(rid); - return rid; -} - -void PhysicsServerSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); - HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); - hinge_joint->set_param(p_param, p_value); -} -real_t PhysicsServerSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, 0); - ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0); - HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); - return hinge_joint->get_param(p_param); -} - -void PhysicsServerSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); - HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); - hinge_joint->set_flag(p_flag, p_value); -} -bool PhysicsServerSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, false); - ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false); - HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); - return hinge_joint->get_flag(p_flag); -} - -void PhysicsServerSW::joint_set_solver_priority(RID p_joint, int p_priority) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - joint->set_priority(p_priority); -} - -int PhysicsServerSW::joint_get_solver_priority(RID p_joint) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, 0); - return joint->get_priority(); -} - -void PhysicsServerSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - - joint->disable_collisions_between_bodies(p_disable); - - if (2 == joint->get_body_count()) { - BodySW *body_a = *joint->get_body_ptr(); - BodySW *body_b = *(joint->get_body_ptr() + 1); - - if (p_disable) { - body_add_collision_exception(body_a->get_self(), body_b->get_self()); - body_add_collision_exception(body_b->get_self(), body_a->get_self()); - } else { - body_remove_collision_exception(body_a->get_self(), body_b->get_self()); - body_remove_collision_exception(body_b->get_self(), body_a->get_self()); - } - } -} - -bool PhysicsServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const { - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, true); - - return joint->is_disabled_collisions_between_bodies(); -} - -PhysicsServerSW::JointType PhysicsServerSW::joint_get_type(RID p_joint) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, JOINT_PIN); - return joint->get_type(); -} - -RID PhysicsServerSW::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { - - BodySW *body_A = body_owner.getornull(p_body_A); - ERR_FAIL_COND_V(!body_A, RID()); - - if (!p_body_B.is_valid()) { - ERR_FAIL_COND_V(!body_A->get_space(), RID()); - p_body_B = body_A->get_space()->get_static_global_body(); - } - - BodySW *body_B = body_owner.getornull(p_body_B); - ERR_FAIL_COND_V(!body_B, RID()); - - ERR_FAIL_COND_V(body_A == body_B, RID()); - - JointSW *joint = memnew(SliderJointSW(body_A, body_B, p_local_frame_A, p_local_frame_B)); - RID rid = joint_owner.make_rid(joint); - joint->set_self(rid); - return rid; -} - -void PhysicsServerSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER); - SliderJointSW *slider_joint = static_cast<SliderJointSW *>(joint); - slider_joint->set_param(p_param, p_value); -} -real_t PhysicsServerSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, 0); - ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0); - SliderJointSW *slider_joint = static_cast<SliderJointSW *>(joint); - return slider_joint->get_param(p_param); -} - -RID PhysicsServerSW::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { - - BodySW *body_A = body_owner.getornull(p_body_A); - ERR_FAIL_COND_V(!body_A, RID()); - - if (!p_body_B.is_valid()) { - ERR_FAIL_COND_V(!body_A->get_space(), RID()); - p_body_B = body_A->get_space()->get_static_global_body(); - } - - BodySW *body_B = body_owner.getornull(p_body_B); - ERR_FAIL_COND_V(!body_B, RID()); - - ERR_FAIL_COND_V(body_A == body_B, RID()); - - JointSW *joint = memnew(ConeTwistJointSW(body_A, body_B, p_local_frame_A, p_local_frame_B)); - RID rid = joint_owner.make_rid(joint); - joint->set_self(rid); - return rid; -} - -void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST); - ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW *>(joint); - cone_twist_joint->set_param(p_param, p_value); -} -real_t PhysicsServerSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, 0); - ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0); - ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW *>(joint); - return cone_twist_joint->get_param(p_param); -} - -RID PhysicsServerSW::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { - - BodySW *body_A = body_owner.getornull(p_body_A); - ERR_FAIL_COND_V(!body_A, RID()); - - if (!p_body_B.is_valid()) { - ERR_FAIL_COND_V(!body_A->get_space(), RID()); - p_body_B = body_A->get_space()->get_static_global_body(); - } - - BodySW *body_B = body_owner.getornull(p_body_B); - ERR_FAIL_COND_V(!body_B, RID()); - - ERR_FAIL_COND_V(body_A == body_B, RID()); - - JointSW *joint = memnew(Generic6DOFJointSW(body_A, body_B, p_local_frame_A, p_local_frame_B, true)); - RID rid = joint_owner.make_rid(joint); - joint->set_self(rid); - return rid; -} - -void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); - Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint); - generic_6dof_joint->set_param(p_axis, p_param, p_value); -} -real_t PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, 0); - ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); - Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint); - return generic_6dof_joint->get_param(p_axis, p_param); -} - -void PhysicsServerSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND(!joint); - ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); - Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint); - generic_6dof_joint->set_flag(p_axis, p_flag, p_enable); -} -bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) { - - JointSW *joint = joint_owner.getornull(p_joint); - ERR_FAIL_COND_V(!joint, false); - ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false); - Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW *>(joint); - return generic_6dof_joint->get_flag(p_axis, p_flag); -} - -void PhysicsServerSW::free(RID p_rid) { - - _update_shapes(); //just in case - - if (shape_owner.owns(p_rid)) { - - ShapeSW *shape = shape_owner.getornull(p_rid); - - while (shape->get_owners().size()) { - ShapeOwnerSW *so = shape->get_owners().front()->key(); - so->remove_shape(shape); - } - - shape_owner.free(p_rid); - memdelete(shape); - } else if (body_owner.owns(p_rid)) { - - BodySW *body = body_owner.getornull(p_rid); - - /* - if (body->get_state_query()) - _clear_query(body->get_state_query()); - - if (body->get_direct_state_query()) - _clear_query(body->get_direct_state_query()); - */ - - body->set_space(NULL); - - while (body->get_shape_count()) { - - body->remove_shape(0); - } - - body_owner.free(p_rid); - memdelete(body); - - } else if (area_owner.owns(p_rid)) { - - AreaSW *area = area_owner.getornull(p_rid); - - /* - if (area->get_monitor_query()) - _clear_query(area->get_monitor_query()); - */ - - area->set_space(NULL); - - while (area->get_shape_count()) { - - area->remove_shape(0); - } - - area_owner.free(p_rid); - memdelete(area); - } else if (space_owner.owns(p_rid)) { - - SpaceSW *space = space_owner.getornull(p_rid); - - while (space->get_objects().size()) { - CollisionObjectSW *co = (CollisionObjectSW *)space->get_objects().front()->get(); - co->set_space(NULL); - } - - active_spaces.erase(space); - free(space->get_default_area()->get_self()); - free(space->get_static_global_body()); - - space_owner.free(p_rid); - memdelete(space); - } else if (joint_owner.owns(p_rid)) { - - JointSW *joint = joint_owner.getornull(p_rid); - - for (int i = 0; i < joint->get_body_count(); i++) { - - joint->get_body_ptr()[i]->remove_constraint(joint); - } - joint_owner.free(p_rid); - memdelete(joint); - - } else { - - ERR_FAIL_MSG("Invalid ID."); - } -}; - -void PhysicsServerSW::set_active(bool p_active) { - - active = p_active; -}; - -void PhysicsServerSW::init() { - - doing_sync = true; - last_step = 0.001; - iterations = 8; // 8? - stepper = memnew(StepSW); - direct_state = memnew(PhysicsDirectBodyStateSW); -}; - -void PhysicsServerSW::step(real_t p_step) { - -#ifndef _3D_DISABLED - - if (!active) - return; - - _update_shapes(); - - doing_sync = false; - - last_step = p_step; - PhysicsDirectBodyStateSW::singleton->step = p_step; - - island_count = 0; - active_objects = 0; - collision_pairs = 0; - for (Set<const SpaceSW *>::Element *E = active_spaces.front(); E; E = E->next()) { - - stepper->step((SpaceSW *)E->get(), p_step, iterations); - island_count += E->get()->get_island_count(); - active_objects += E->get()->get_active_objects(); - collision_pairs += E->get()->get_collision_pairs(); - } -#endif -} - -void PhysicsServerSW::sync(){ - -}; - -void PhysicsServerSW::flush_queries() { - -#ifndef _3D_DISABLED - - if (!active) - return; - - doing_sync = true; - - flushing_queries = true; - - uint64_t time_beg = OS::get_singleton()->get_ticks_usec(); - - for (Set<const SpaceSW *>::Element *E = active_spaces.front(); E; E = E->next()) { - - SpaceSW *space = (SpaceSW *)E->get(); - space->call_queries(); - } - - flushing_queries = false; - - if (EngineDebugger::is_profiling("servers")) { - - uint64_t total_time[SpaceSW::ELAPSED_TIME_MAX]; - static const char *time_name[SpaceSW::ELAPSED_TIME_MAX] = { - "integrate_forces", - "generate_islands", - "setup_constraints", - "solve_constraints", - "integrate_velocities" - }; - - for (int i = 0; i < SpaceSW::ELAPSED_TIME_MAX; i++) { - total_time[i] = 0; - } - - for (Set<const SpaceSW *>::Element *E = active_spaces.front(); E; E = E->next()) { - - for (int i = 0; i < SpaceSW::ELAPSED_TIME_MAX; i++) { - total_time[i] += E->get()->get_elapsed_time(SpaceSW::ElapsedTime(i)); - } - } - - Array values; - values.resize(SpaceSW::ELAPSED_TIME_MAX * 2); - for (int i = 0; i < SpaceSW::ELAPSED_TIME_MAX; i++) { - values[i * 2 + 0] = time_name[i]; - values[i * 2 + 1] = USEC_TO_SEC(total_time[i]); - } - values.push_back("flush_queries"); - values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec() - time_beg)); - - values.push_front("physics"); - EngineDebugger::profiler_add_frame_data("server", values); - } -#endif -}; - -void PhysicsServerSW::finish() { - - memdelete(stepper); - memdelete(direct_state); -}; - -int PhysicsServerSW::get_process_info(ProcessInfo p_info) { - - switch (p_info) { - - case INFO_ACTIVE_OBJECTS: { - - return active_objects; - } break; - case INFO_COLLISION_PAIRS: { - return collision_pairs; - } break; - case INFO_ISLAND_COUNT: { - - return island_count; - } break; - } - - return 0; -} - -void PhysicsServerSW::_update_shapes() { - - while (pending_shape_update_list.first()) { - pending_shape_update_list.first()->self()->_shape_changed(); - pending_shape_update_list.remove(pending_shape_update_list.first()); - } -} - -void PhysicsServerSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) { - - CollCbkData *cbk = (CollCbkData *)p_userdata; - - if (cbk->max == 0) - return; - - if (cbk->amount == cbk->max) { - //find least deep - real_t min_depth = 1e20; - int min_depth_idx = 0; - for (int i = 0; i < cbk->amount; i++) { - - real_t d = cbk->ptr[i * 2 + 0].distance_squared_to(cbk->ptr[i * 2 + 1]); - if (d < min_depth) { - min_depth = d; - min_depth_idx = i; - } - } - - real_t d = p_point_A.distance_squared_to(p_point_B); - if (d < min_depth) - return; - cbk->ptr[min_depth_idx * 2 + 0] = p_point_A; - cbk->ptr[min_depth_idx * 2 + 1] = p_point_B; - - } else { - - cbk->ptr[cbk->amount * 2 + 0] = p_point_A; - cbk->ptr[cbk->amount * 2 + 1] = p_point_B; - cbk->amount++; - } -} - -PhysicsServerSW *PhysicsServerSW::singleton = NULL; -PhysicsServerSW::PhysicsServerSW() { - singleton = this; - BroadPhaseSW::create_func = BroadPhaseOctree::_create; - island_count = 0; - active_objects = 0; - collision_pairs = 0; - - active = true; - flushing_queries = false; -}; - -PhysicsServerSW::~PhysicsServerSW(){ - -}; diff --git a/servers/physics_2d/SCsub b/servers/physics_2d/SCsub index d730144861..86681f9c74 100644 --- a/servers/physics_2d/SCsub +++ b/servers/physics_2d/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index 45666d9d09..85ec2aae47 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -117,40 +117,40 @@ void Area2DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_meth get_space()->area_add_to_moved_list(&moved_list); } -void Area2DSW::set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_mode) { - bool do_override = p_mode != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED; - if (do_override == (space_override_mode != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED)) +void Area2DSW::set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode) { + bool do_override = p_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED; + if (do_override == (space_override_mode != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED)) return; _unregister_shapes(); space_override_mode = p_mode; _shape_changed(); } -void Area2DSW::set_param(Physics2DServer::AreaParameter p_param, const Variant &p_value) { +void Area2DSW::set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value) { switch (p_param) { - case Physics2DServer::AREA_PARAM_GRAVITY: gravity = p_value; break; - case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break; - case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break; - case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break; - case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break; - case Physics2DServer::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break; - case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break; - case Physics2DServer::AREA_PARAM_PRIORITY: priority = p_value; break; + case PhysicsServer2D::AREA_PARAM_GRAVITY: gravity = p_value; break; + case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break; + case PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break; + case PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break; + case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break; + case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break; + case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break; + case PhysicsServer2D::AREA_PARAM_PRIORITY: priority = p_value; break; } } -Variant Area2DSW::get_param(Physics2DServer::AreaParameter p_param) const { +Variant Area2DSW::get_param(PhysicsServer2D::AreaParameter p_param) const { switch (p_param) { - case Physics2DServer::AREA_PARAM_GRAVITY: return gravity; - case Physics2DServer::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector; - case Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point; - case Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale; - case Physics2DServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation; - case Physics2DServer::AREA_PARAM_LINEAR_DAMP: return linear_damp; - case Physics2DServer::AREA_PARAM_ANGULAR_DAMP: return angular_damp; - case Physics2DServer::AREA_PARAM_PRIORITY: return priority; + case PhysicsServer2D::AREA_PARAM_GRAVITY: return gravity; + case PhysicsServer2D::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector; + case PhysicsServer2D::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point; + case PhysicsServer2D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale; + case PhysicsServer2D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation; + case PhysicsServer2D::AREA_PARAM_LINEAR_DAMP: return linear_damp; + case PhysicsServer2D::AREA_PARAM_ANGULAR_DAMP: return angular_damp; + case PhysicsServer2D::AREA_PARAM_PRIORITY: return priority; } return Variant(); @@ -194,7 +194,7 @@ void Area2DSW::call_queries() { if (E->get().state == 0) continue; //nothing happened - res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED; + res[0] = E->get().state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED; res[1] = E->key().rid; res[2] = E->key().instance_id; res[3] = E->key().body_shape; @@ -226,7 +226,7 @@ void Area2DSW::call_queries() { if (E->get().state == 0) continue; //nothing happened - res[0] = E->get().state > 0 ? Physics2DServer::AREA_BODY_ADDED : Physics2DServer::AREA_BODY_REMOVED; + res[0] = E->get().state > 0 ? PhysicsServer2D::AREA_BODY_ADDED : PhysicsServer2D::AREA_BODY_REMOVED; res[1] = E->key().rid; res[2] = E->key().instance_id; res[3] = E->key().body_shape; @@ -248,7 +248,7 @@ Area2DSW::Area2DSW() : moved_list(this) { _set_static(true); //areas are not active by default - space_override_mode = Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED; + space_override_mode = PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED; gravity = 9.80665; gravity_vector = Vector2(0, -1); gravity_is_point = false; diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h index 54ffd9763d..ae2a8ff995 100644 --- a/servers/physics_2d/area_2d_sw.h +++ b/servers/physics_2d/area_2d_sw.h @@ -33,8 +33,8 @@ #include "collision_object_2d_sw.h" #include "core/self_list.h" -#include "servers/physics_2d_server.h" -//#include "servers/physics/query_sw.h" +#include "servers/physics_server_2d.h" +//#include "servers/physics_3d/query_sw.h" class Space2DSW; class Body2DSW; @@ -42,7 +42,7 @@ class Constraint2DSW; class Area2DSW : public CollisionObject2DSW { - Physics2DServer::AreaSpaceOverrideMode space_override_mode; + PhysicsServer2D::AreaSpaceOverrideMode space_override_mode; real_t gravity; Vector2 gravity_vector; bool gravity_is_point; @@ -121,11 +121,11 @@ public: _FORCE_INLINE_ void add_area_to_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape); _FORCE_INLINE_ void remove_area_from_query(Area2DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape); - void set_param(Physics2DServer::AreaParameter p_param, const Variant &p_value); - Variant get_param(Physics2DServer::AreaParameter p_param) const; + void set_param(PhysicsServer2D::AreaParameter p_param, const Variant &p_value); + Variant get_param(PhysicsServer2D::AreaParameter p_param) const; - void set_space_override_mode(Physics2DServer::AreaSpaceOverrideMode p_mode); - Physics2DServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; } + void set_space_override_mode(PhysicsServer2D::AreaSpaceOverrideMode p_mode); + PhysicsServer2D::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; } _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; } _FORCE_INLINE_ real_t get_gravity() const { return gravity; } diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp index 05d71cfabe..0e70a626c2 100644 --- a/servers/physics_2d/area_pair_2d_sw.cpp +++ b/servers/physics_2d/area_pair_2d_sw.cpp @@ -37,7 +37,7 @@ bool AreaPair2DSW::setup(real_t p_step) { if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) { result = false; - } else if (area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), Vector2(), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), Vector2(), NULL, this)) { + } else if (area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), Vector2(), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), Vector2(), nullptr, this)) { result = true; } @@ -45,14 +45,14 @@ bool AreaPair2DSW::setup(real_t p_step) { if (result) { - if (area->get_space_override_mode() != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED) + if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) body->add_area(area); if (area->has_monitor_callback()) area->add_body_to_query(body, body_shape, area_shape); } else { - if (area->get_space_override_mode() != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED) + if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) body->remove_area(area); if (area->has_monitor_callback()) area->remove_body_from_query(body, body_shape, area_shape); @@ -76,7 +76,7 @@ AreaPair2DSW::AreaPair2DSW(Body2DSW *p_body, int p_body_shape, Area2DSW *p_area, colliding = false; body->add_constraint(this, 0); area->add_constraint(this); - if (p_body->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) //need to be active to process pair + if (p_body->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) //need to be active to process pair p_body->set_active(true); } @@ -84,7 +84,7 @@ AreaPair2DSW::~AreaPair2DSW() { if (colliding) { - if (area->get_space_override_mode() != Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED) + if (area->get_space_override_mode() != PhysicsServer2D::AREA_SPACE_OVERRIDE_DISABLED) body->remove_area(area); if (area->has_monitor_callback()) area->remove_body_from_query(body, body_shape, area_shape); @@ -100,7 +100,7 @@ bool Area2Pair2DSW::setup(real_t p_step) { bool result = false; if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) { result = false; - } else if (area_a->test_collision_mask(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), Vector2(), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), Vector2(), NULL, this)) { + } else if (area_a->test_collision_mask(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), Vector2(), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), Vector2(), nullptr, this)) { result = true; } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 863b422996..39e28fd002 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -30,7 +30,7 @@ #include "body_2d_sw.h" #include "area_2d_sw.h" -#include "physics_2d_server_sw.h" +#include "physics_server_2d_sw.h" #include "space_2d_sw.h" void Body2DSW::_update_inertia() { @@ -45,7 +45,7 @@ void Body2DSW::update_inertias() { switch (mode) { - case Physics2DServer::BODY_MODE_RIGID: { + case PhysicsServer2D::BODY_MODE_RIGID: { if (user_inertia) { _inv_inertia = inertia > 0 ? (1.0 / inertia) : 0; @@ -86,13 +86,13 @@ void Body2DSW::update_inertias() { _inv_mass = 0; } break; - case Physics2DServer::BODY_MODE_KINEMATIC: - case Physics2DServer::BODY_MODE_STATIC: { + case PhysicsServer2D::BODY_MODE_KINEMATIC: + case PhysicsServer2D::BODY_MODE_STATIC: { _inv_inertia = 0; _inv_mass = 0; } break; - case Physics2DServer::BODY_MODE_CHARACTER: { + case PhysicsServer2D::BODY_MODE_CHARACTER: { _inv_inertia = 0; _inv_mass = 1.0 / mass; @@ -114,7 +114,7 @@ void Body2DSW::set_active(bool p_active) { if (get_space()) get_space()->body_remove_from_active_list(&active_list); } else { - if (mode == Physics2DServer::BODY_MODE_STATIC) + if (mode == PhysicsServer2D::BODY_MODE_STATIC) return; //static bodies can't become active if (get_space()) get_space()->body_add_to_active_list(&active_list); @@ -134,24 +134,24 @@ void Body2DSW::set_active(bool p_active) { */ } -void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value) { +void Body2DSW::set_param(PhysicsServer2D::BodyParameter p_param, real_t p_value) { switch (p_param) { - case Physics2DServer::BODY_PARAM_BOUNCE: { + case PhysicsServer2D::BODY_PARAM_BOUNCE: { bounce = p_value; } break; - case Physics2DServer::BODY_PARAM_FRICTION: { + case PhysicsServer2D::BODY_PARAM_FRICTION: { friction = p_value; } break; - case Physics2DServer::BODY_PARAM_MASS: { + case PhysicsServer2D::BODY_PARAM_MASS: { ERR_FAIL_COND(p_value <= 0); mass = p_value; _update_inertia(); } break; - case Physics2DServer::BODY_PARAM_INERTIA: { + case PhysicsServer2D::BODY_PARAM_INERTIA: { if (p_value <= 0) { user_inertia = false; _update_inertia(); @@ -161,14 +161,14 @@ void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value) _inv_inertia = 1.0 / p_value; } } break; - case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: { + case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: { gravity_scale = p_value; } break; - case Physics2DServer::BODY_PARAM_LINEAR_DAMP: { + case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: { linear_damp = p_value; } break; - case Physics2DServer::BODY_PARAM_ANGULAR_DAMP: { + case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: { angular_damp = p_value; } break; @@ -177,31 +177,31 @@ void Body2DSW::set_param(Physics2DServer::BodyParameter p_param, real_t p_value) } } -real_t Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const { +real_t Body2DSW::get_param(PhysicsServer2D::BodyParameter p_param) const { switch (p_param) { - case Physics2DServer::BODY_PARAM_BOUNCE: { + case PhysicsServer2D::BODY_PARAM_BOUNCE: { return bounce; } - case Physics2DServer::BODY_PARAM_FRICTION: { + case PhysicsServer2D::BODY_PARAM_FRICTION: { return friction; } - case Physics2DServer::BODY_PARAM_MASS: { + case PhysicsServer2D::BODY_PARAM_MASS: { return mass; } - case Physics2DServer::BODY_PARAM_INERTIA: { + case PhysicsServer2D::BODY_PARAM_INERTIA: { return inertia; } - case Physics2DServer::BODY_PARAM_GRAVITY_SCALE: { + case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: { return gravity_scale; } - case Physics2DServer::BODY_PARAM_LINEAR_DAMP: { + case PhysicsServer2D::BODY_PARAM_LINEAR_DAMP: { return linear_damp; } - case Physics2DServer::BODY_PARAM_ANGULAR_DAMP: { + case PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP: { return angular_damp; } @@ -212,28 +212,28 @@ real_t Body2DSW::get_param(Physics2DServer::BodyParameter p_param) const { return 0; } -void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) { +void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) { - Physics2DServer::BodyMode prev = mode; + PhysicsServer2D::BodyMode prev = mode; mode = p_mode; switch (p_mode) { //CLEAR UP EVERYTHING IN CASE IT NOT WORKS! - case Physics2DServer::BODY_MODE_STATIC: - case Physics2DServer::BODY_MODE_KINEMATIC: { + case PhysicsServer2D::BODY_MODE_STATIC: + case PhysicsServer2D::BODY_MODE_KINEMATIC: { _set_inv_transform(get_transform().affine_inverse()); _inv_mass = 0; _inv_inertia = 0; - _set_static(p_mode == Physics2DServer::BODY_MODE_STATIC); - set_active(p_mode == Physics2DServer::BODY_MODE_KINEMATIC && contacts.size()); + _set_static(p_mode == PhysicsServer2D::BODY_MODE_STATIC); + set_active(p_mode == PhysicsServer2D::BODY_MODE_KINEMATIC && contacts.size()); linear_velocity = Vector2(); angular_velocity = 0; - if (mode == Physics2DServer::BODY_MODE_KINEMATIC && prev != mode) { + if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && prev != mode) { first_time_kinematic = true; } } break; - case Physics2DServer::BODY_MODE_RIGID: { + case PhysicsServer2D::BODY_MODE_RIGID: { _inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_inertia = inertia > 0 ? (1.0 / inertia) : 0; @@ -241,7 +241,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) { set_active(true); } break; - case Physics2DServer::BODY_MODE_CHARACTER: { + case PhysicsServer2D::BODY_MODE_CHARACTER: { _inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_inertia = 0; @@ -250,7 +250,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) { angular_velocity = 0; } break; } - if (p_mode == Physics2DServer::BODY_MODE_RIGID && _inv_inertia == 0) { + if (p_mode == PhysicsServer2D::BODY_MODE_RIGID && _inv_inertia == 0) { _update_inertia(); } /* @@ -258,7 +258,7 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) { _update_queries(); */ } -Physics2DServer::BodyMode Body2DSW::get_mode() const { +PhysicsServer2D::BodyMode Body2DSW::get_mode() const { return mode; } @@ -269,12 +269,12 @@ void Body2DSW::_shapes_changed() { wakeup_neighbours(); } -void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_variant) { +void Body2DSW::set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant) { switch (p_state) { - case Physics2DServer::BODY_STATE_TRANSFORM: { + case PhysicsServer2D::BODY_STATE_TRANSFORM: { - if (mode == Physics2DServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) { new_transform = p_variant; //wakeup_neighbours(); @@ -284,7 +284,7 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_va _set_inv_transform(get_transform().affine_inverse()); first_time_kinematic = false; } - } else if (mode == Physics2DServer::BODY_MODE_STATIC) { + } else if (mode == PhysicsServer2D::BODY_MODE_STATIC) { _set_transform(p_variant); _set_inv_transform(get_transform().affine_inverse()); wakeup_neighbours(); @@ -300,28 +300,28 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_va wakeup(); } break; - case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: { + case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: { /* - if (mode==Physics2DServer::BODY_MODE_STATIC) + if (mode==PhysicsServer2D::BODY_MODE_STATIC) break; */ linear_velocity = p_variant; wakeup(); } break; - case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: { + case PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY: { /* - if (mode!=Physics2DServer::BODY_MODE_RIGID) + if (mode!=PhysicsServer2D::BODY_MODE_RIGID) break; */ angular_velocity = p_variant; wakeup(); } break; - case Physics2DServer::BODY_STATE_SLEEPING: { + case PhysicsServer2D::BODY_STATE_SLEEPING: { //? - if (mode == Physics2DServer::BODY_MODE_STATIC || mode == Physics2DServer::BODY_MODE_KINEMATIC) + if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) break; bool do_sleep = p_variant; if (do_sleep) { @@ -331,34 +331,34 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant &p_va //biased_angular_velocity=Vector3(); set_active(false); } else { - if (mode != Physics2DServer::BODY_MODE_STATIC) + if (mode != PhysicsServer2D::BODY_MODE_STATIC) set_active(true); } } break; - case Physics2DServer::BODY_STATE_CAN_SLEEP: { + case PhysicsServer2D::BODY_STATE_CAN_SLEEP: { can_sleep = p_variant; - if (mode == Physics2DServer::BODY_MODE_RIGID && !active && !can_sleep) + if (mode == PhysicsServer2D::BODY_MODE_RIGID && !active && !can_sleep) set_active(true); } break; } } -Variant Body2DSW::get_state(Physics2DServer::BodyState p_state) const { +Variant Body2DSW::get_state(PhysicsServer2D::BodyState p_state) const { switch (p_state) { - case Physics2DServer::BODY_STATE_TRANSFORM: { + case PhysicsServer2D::BODY_STATE_TRANSFORM: { return get_transform(); } - case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: { + case PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY: { return linear_velocity; } - case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: { + case PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY: { return angular_velocity; } - case Physics2DServer::BODY_STATE_SLEEPING: { + case PhysicsServer2D::BODY_STATE_SLEEPING: { return !is_active(); } - case Physics2DServer::BODY_STATE_CAN_SLEEP: { + case PhysicsServer2D::BODY_STATE_CAN_SLEEP: { return can_sleep; } } @@ -418,7 +418,7 @@ void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) { void Body2DSW::integrate_forces(real_t p_step) { - if (mode == Physics2DServer::BODY_MODE_STATIC) + if (mode == PhysicsServer2D::BODY_MODE_STATIC) return; Area2DSW *def_area = get_space()->get_default_area(); @@ -435,20 +435,20 @@ void Body2DSW::integrate_forces(real_t p_step) { const AreaCMP *aa = &areas[0]; // damp_area = aa[ac-1].area; for (int i = ac - 1; i >= 0 && !stopped; i--) { - Physics2DServer::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); + PhysicsServer2D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); switch (mode) { - case Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE: - case Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { + case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE: + case PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { _compute_area_gravity_and_dampenings(aa[i].area); - stopped = mode == Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; + stopped = mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; } break; - case Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE: - case Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { + case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE: + case PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { gravity = Vector2(0, 0); area_angular_damp = 0; area_linear_damp = 0; _compute_area_gravity_and_dampenings(aa[i].area); - stopped = mode == Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE; + stopped = mode == PhysicsServer2D::AREA_SPACE_OVERRIDE_REPLACE; } break; default: { } @@ -478,7 +478,7 @@ void Body2DSW::integrate_forces(real_t p_step) { Vector2 motion; bool do_motion = false; - if (mode == Physics2DServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) { //compute motion, angular and etc. velocities from prev transform motion = new_transform.get_origin() - get_transform().get_origin(); @@ -521,7 +521,7 @@ void Body2DSW::integrate_forces(real_t p_step) { angular_velocity += _inv_inertia * torque * p_step; } - if (continuous_cd_mode != Physics2DServer::CCD_MODE_DISABLED) { + if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) { motion = linear_velocity * p_step; do_motion = true; @@ -538,20 +538,20 @@ void Body2DSW::integrate_forces(real_t p_step) { _update_shapes_with_motion(motion); } - // damp_area=NULL; // clear the area, so it is set in the next frame - def_area = NULL; // clear the area, so it is set in the next frame + // damp_area=nullptr; // clear the area, so it is set in the next frame + def_area = nullptr; // clear the area, so it is set in the next frame contact_count = 0; } void Body2DSW::integrate_velocities(real_t p_step) { - if (mode == Physics2DServer::BODY_MODE_STATIC) + if (mode == PhysicsServer2D::BODY_MODE_STATIC) return; if (fi_callback) get_space()->body_add_to_state_query_list(&direct_state_query_list); - if (mode == Physics2DServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) { _set_transform(new_transform, false); _set_inv_transform(new_transform.affine_inverse()); @@ -566,10 +566,10 @@ void Body2DSW::integrate_velocities(real_t p_step) { real_t angle = get_transform().get_rotation() + total_angular_velocity * p_step; Vector2 pos = get_transform().get_origin() + total_linear_velocity * p_step; - _set_transform(Transform2D(angle, pos), continuous_cd_mode == Physics2DServer::CCD_MODE_DISABLED); + _set_transform(Transform2D(angle, pos), continuous_cd_mode == PhysicsServer2D::CCD_MODE_DISABLED); _set_inv_transform(get_transform().inverse()); - if (continuous_cd_mode != Physics2DServer::CCD_MODE_DISABLED) + if (continuous_cd_mode != PhysicsServer2D::CCD_MODE_DISABLED) new_transform = get_transform(); //_update_inertia_tensor(); @@ -588,7 +588,7 @@ void Body2DSW::wakeup_neighbours() { if (i == E->get()) continue; Body2DSW *b = n[i]; - if (b->mode != Physics2DServer::BODY_MODE_RIGID) + if (b->mode != PhysicsServer2D::BODY_MODE_RIGID) continue; if (!b->is_active()) @@ -601,7 +601,7 @@ void Body2DSW::call_queries() { if (fi_callback) { - Physics2DDirectBodyStateSW *dbs = Physics2DDirectBodyStateSW::singleton; + PhysicsDirectBodyState2DSW *dbs = PhysicsDirectBodyState2DSW::singleton; dbs->body = this; Variant v = dbs; @@ -626,9 +626,9 @@ void Body2DSW::call_queries() { bool Body2DSW::sleep_test(real_t p_step) { - if (mode == Physics2DServer::BODY_MODE_STATIC || mode == Physics2DServer::BODY_MODE_KINEMATIC) + if (mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) return true; // - else if (mode == Physics2DServer::BODY_MODE_CHARACTER) + else if (mode == PhysicsServer2D::BODY_MODE_CHARACTER) return !active; // characters and kinematic bodies don't sleep unless asked to sleep else if (!can_sleep) return false; @@ -650,7 +650,7 @@ void Body2DSW::set_force_integration_callback(ObjectID p_id, const StringName &p if (fi_callback) { memdelete(fi_callback); - fi_callback = NULL; + fi_callback = nullptr; } if (p_id.is_valid()) { @@ -668,7 +668,7 @@ Body2DSW::Body2DSW() : inertia_update_list(this), direct_state_query_list(this) { - mode = Physics2DServer::BODY_MODE_RIGID; + mode = PhysicsServer2D::BODY_MODE_RIGID; active = true; angular_velocity = 0; biased_angular_velocity = 0; @@ -682,8 +682,8 @@ Body2DSW::Body2DSW() : omit_force_integration = false; applied_torque = 0; island_step = 0; - island_next = NULL; - island_list_next = NULL; + island_next = nullptr; + island_list_next = nullptr; _set_static(false); first_time_kinematic = false; linear_damp = -1; @@ -695,9 +695,9 @@ Body2DSW::Body2DSW() : first_integration = false; still_time = 0; - continuous_cd_mode = Physics2DServer::CCD_MODE_DISABLED; + continuous_cd_mode = PhysicsServer2D::CCD_MODE_DISABLED; can_sleep = true; - fi_callback = NULL; + fi_callback = nullptr; } Body2DSW::~Body2DSW() { @@ -706,22 +706,22 @@ Body2DSW::~Body2DSW() { memdelete(fi_callback); } -Physics2DDirectBodyStateSW *Physics2DDirectBodyStateSW::singleton = NULL; +PhysicsDirectBodyState2DSW *PhysicsDirectBodyState2DSW::singleton = nullptr; -Physics2DDirectSpaceState *Physics2DDirectBodyStateSW::get_space_state() { +PhysicsDirectSpaceState2D *PhysicsDirectBodyState2DSW::get_space_state() { return body->get_space()->get_direct_state(); } -Variant Physics2DDirectBodyStateSW::get_contact_collider_shape_metadata(int p_contact_idx) const { +Variant PhysicsDirectBodyState2DSW::get_contact_collider_shape_metadata(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Variant()); - if (!Physics2DServerSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) { + if (!PhysicsServer2DSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) { return Variant(); } - Body2DSW *other = Physics2DServerSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider); + Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider); int sidx = body->contacts[p_contact_idx].collider_shape; if (sidx < 0 || sidx >= other->get_shape_count()) { diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index ea07b8260c..0514b263b4 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -39,7 +39,7 @@ class Constraint2DSW; class Body2DSW : public CollisionObject2DSW { - Physics2DServer::BodyMode mode; + PhysicsServer2D::BodyMode mode; Vector2 biased_linear_velocity; real_t biased_angular_velocity; @@ -74,7 +74,7 @@ class Body2DSW : public CollisionObject2DSW { SelfList<Body2DSW> direct_state_query_list; VSet<RID> exceptions; - Physics2DServer::CCDMode continuous_cd_mode; + PhysicsServer2D::CCDMode continuous_cd_mode; bool omit_force_integration; bool active; bool can_sleep; @@ -132,7 +132,7 @@ class Body2DSW : public CollisionObject2DSW { _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const Area2DSW *p_area); - friend class Physics2DDirectBodyStateSW; // i give up, too many functions to expose + friend class PhysicsDirectBodyState2DSW; // i give up, too many functions to expose public: void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant()); @@ -158,7 +158,7 @@ public: _FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count = 0; - if (mode == Physics2DServer::BODY_MODE_KINEMATIC && p_size) set_active(true); + if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC && p_size) set_active(true); } _FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); } @@ -224,19 +224,19 @@ public: _FORCE_INLINE_ bool is_active() const { return active; } _FORCE_INLINE_ void wakeup() { - if ((!get_space()) || mode == Physics2DServer::BODY_MODE_STATIC || mode == Physics2DServer::BODY_MODE_KINEMATIC) + if ((!get_space()) || mode == PhysicsServer2D::BODY_MODE_STATIC || mode == PhysicsServer2D::BODY_MODE_KINEMATIC) return; set_active(true); } - void set_param(Physics2DServer::BodyParameter p_param, real_t); - real_t get_param(Physics2DServer::BodyParameter p_param) const; + void set_param(PhysicsServer2D::BodyParameter p_param, real_t); + real_t get_param(PhysicsServer2D::BodyParameter p_param) const; - void set_mode(Physics2DServer::BodyMode p_mode); - Physics2DServer::BodyMode get_mode() const; + void set_mode(PhysicsServer2D::BodyMode p_mode); + PhysicsServer2D::BodyMode get_mode() const; - void set_state(Physics2DServer::BodyState p_state, const Variant &p_variant); - Variant get_state(Physics2DServer::BodyState p_state) const; + void set_state(PhysicsServer2D::BodyState p_state, const Variant &p_variant); + Variant get_state(PhysicsServer2D::BodyState p_state) const; void set_applied_force(const Vector2 &p_force) { applied_force = p_force; } Vector2 get_applied_force() const { return applied_force; } @@ -258,8 +258,8 @@ public: applied_torque += p_torque; } - _FORCE_INLINE_ void set_continuous_collision_detection_mode(Physics2DServer::CCDMode p_mode) { continuous_cd_mode = p_mode; } - _FORCE_INLINE_ Physics2DServer::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; } + _FORCE_INLINE_ void set_continuous_collision_detection_mode(PhysicsServer2D::CCDMode p_mode) { continuous_cd_mode = p_mode; } + _FORCE_INLINE_ PhysicsServer2D::CCDMode get_continuous_collision_detection_mode() const { return continuous_cd_mode; } void set_space(Space2DSW *p_space); @@ -278,9 +278,9 @@ public: _FORCE_INLINE_ Vector2 get_motion() const { - if (mode > Physics2DServer::BODY_MODE_KINEMATIC) { + if (mode > PhysicsServer2D::BODY_MODE_KINEMATIC) { return new_transform.get_origin() - get_transform().get_origin(); - } else if (mode == Physics2DServer::BODY_MODE_KINEMATIC) { + } else if (mode == PhysicsServer2D::BODY_MODE_KINEMATIC) { return get_transform().get_origin() - new_transform.get_origin(); //kinematic simulates forward } return Vector2(); @@ -341,12 +341,12 @@ void Body2DSW::add_contact(const Vector2 &p_local_pos, const Vector2 &p_local_no c[idx].collider_velocity_at_pos = p_collider_velocity_at_pos; } -class Physics2DDirectBodyStateSW : public Physics2DDirectBodyState { +class PhysicsDirectBodyState2DSW : public PhysicsDirectBodyState2D { - GDCLASS(Physics2DDirectBodyStateSW, Physics2DDirectBodyState); + GDCLASS(PhysicsDirectBodyState2DSW, PhysicsDirectBodyState2D); public: - static Physics2DDirectBodyStateSW *singleton; + static PhysicsDirectBodyState2DSW *singleton; Body2DSW *body; real_t step; @@ -363,7 +363,7 @@ public: virtual void set_angular_velocity(real_t p_velocity) { body->set_angular_velocity(p_velocity); } virtual real_t get_angular_velocity() const { return body->get_angular_velocity(); } - virtual void set_transform(const Transform2D &p_transform) { body->set_state(Physics2DServer::BODY_STATE_TRANSFORM, p_transform); } + virtual void set_transform(const Transform2D &p_transform) { body->set_state(PhysicsServer2D::BODY_STATE_TRANSFORM, p_transform); } virtual Transform2D get_transform() const { return body->get_transform(); } virtual void add_central_force(const Vector2 &p_force) { body->add_central_force(p_force); } @@ -414,12 +414,12 @@ public: return body->contacts[p_contact_idx].collider_velocity_at_pos; } - virtual Physics2DDirectSpaceState *get_space_state(); + virtual PhysicsDirectSpaceState2D *get_space_state(); virtual real_t get_step() const { return step; } - Physics2DDirectBodyStateSW() { + PhysicsDirectBodyState2DSW() { singleton = this; - body = NULL; + body = nullptr; } }; diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 38f33134a5..f38a76cff6 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -230,7 +230,7 @@ real_t combine_friction(Body2DSW *A, Body2DSW *B) { bool BodyPair2DSW::setup(real_t p_step) { //cannot collide - if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) { + if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) { collided = false; return false; } @@ -258,10 +258,10 @@ bool BodyPair2DSW::setup(real_t p_step) { Vector2 motion_A, motion_B; - if (A->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_SHAPE) { + if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_SHAPE) { motion_A = A->get_motion(); } - if (B->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_SHAPE) { + if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_SHAPE) { motion_B = B->get_motion(); } //faster to set than to check.. @@ -273,12 +273,12 @@ bool BodyPair2DSW::setup(real_t p_step) { //test ccd (currently just a raycast) - if (A->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_RAY && A->get_mode() > Physics2DServer::BODY_MODE_KINEMATIC) { + if (A->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && A->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) { if (_test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B)) collided = true; } - if (B->get_continuous_collision_detection_mode() == Physics2DServer::CCD_MODE_CAST_RAY && B->get_mode() > Physics2DServer::BODY_MODE_KINEMATIC) { + if (B->get_continuous_collision_detection_mode() == PhysicsServer2D::CCD_MODE_CAST_RAY && B->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) { if (_test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A, true)) collided = true; } @@ -405,7 +405,7 @@ bool BodyPair2DSW::setup(real_t p_step) { } } - if ((A->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode() <= Physics2DServer::BODY_MODE_KINEMATIC)) { + if ((A->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer2D::BODY_MODE_KINEMATIC)) { c.active = false; collided = false; continue; diff --git a/servers/physics_2d/broad_phase_2d_basic.cpp b/servers/physics_2d/broad_phase_2d_basic.cpp index 11bf8712ac..5e3a13f4dd 100644 --- a/servers/physics_2d/broad_phase_2d_basic.cpp +++ b/servers/physics_2d/broad_phase_2d_basic.cpp @@ -65,7 +65,7 @@ void BroadPhase2DBasic::remove(ID p_id) { CollisionObject2DSW *BroadPhase2DBasic::get_object(ID p_id) const { const Map<ID, Element>::Element *E = element_map.find(p_id); - ERR_FAIL_COND_V(!E, NULL); + ERR_FAIL_COND_V(!E, nullptr); return E->get().owner; } bool BroadPhase2DBasic::is_static(ID p_id) const { @@ -158,7 +158,7 @@ void BroadPhase2DBasic::update() { if (pair_ok && !E) { - void *data = NULL; + void *data = nullptr; if (pair_callback) data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata); pair_map.insert(key, data); @@ -175,8 +175,8 @@ BroadPhase2DSW *BroadPhase2DBasic::_create() { BroadPhase2DBasic::BroadPhase2DBasic() { current = 1; - unpair_callback = NULL; - unpair_userdata = NULL; - pair_callback = NULL; - pair_userdata = NULL; + unpair_callback = nullptr; + unpair_userdata = nullptr; + pair_callback = nullptr; + pair_userdata = nullptr; } diff --git a/servers/physics_2d/broad_phase_2d_basic.h b/servers/physics_2d/broad_phase_2d_basic.h index fea5668c89..7d02590af9 100644 --- a/servers/physics_2d/broad_phase_2d_basic.h +++ b/servers/physics_2d/broad_phase_2d_basic.h @@ -91,8 +91,8 @@ public: virtual bool is_static(ID p_id) const; virtual int get_subindex(ID p_id) const; - virtual int cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = nullptr); + virtual int cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = nullptr); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index 711ff9f1f7..2cb021258a 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -394,7 +394,7 @@ void BroadPhase2DHashGrid::remove(ID p_id) { CollisionObject2DSW *BroadPhase2DHashGrid::get_object(ID p_id) const { const Map<ID, Element>::Element *E = element_map.find(p_id); - ERR_FAIL_COND_V(!E, NULL); + ERR_FAIL_COND_V(!E, nullptr); return E->get().owner; } bool BroadPhase2DHashGrid::is_static(ID p_id) const { @@ -646,7 +646,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() { ProjectSettings::get_singleton()->set_custom_property_info("physics/2d/large_object_surface_threshold_in_cells", PropertyInfo(Variant::INT, "physics/2d/large_object_surface_threshold_in_cells", PROPERTY_HINT_RANGE, "0,1024,1,or_greater")); for (uint32_t i = 0; i < hash_table_size; i++) - hash_table[i] = NULL; + hash_table[i] = nullptr; pass = 1; current = 0; diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.h b/servers/physics_2d/broad_phase_2d_hash_grid.h index e75b51c19d..dc29d0c619 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.h +++ b/servers/physics_2d/broad_phase_2d_hash_grid.h @@ -44,7 +44,7 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW { PairData() { colliding = false; rc = 1; - ud = NULL; + ud = nullptr; } }; @@ -177,8 +177,8 @@ public: virtual bool is_static(ID p_id) const; virtual int get_subindex(ID p_id) const; - virtual int cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = nullptr); + virtual int cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = nullptr); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); diff --git a/servers/physics_2d/broad_phase_2d_sw.cpp b/servers/physics_2d/broad_phase_2d_sw.cpp index c9e1dd8758..5ba557e70a 100644 --- a/servers/physics_2d/broad_phase_2d_sw.cpp +++ b/servers/physics_2d/broad_phase_2d_sw.cpp @@ -30,7 +30,7 @@ #include "broad_phase_2d_sw.h" -BroadPhase2DSW::CreateFunction BroadPhase2DSW::create_func = NULL; +BroadPhase2DSW::CreateFunction BroadPhase2DSW::create_func = nullptr; BroadPhase2DSW::~BroadPhase2DSW() { } diff --git a/servers/physics_2d/broad_phase_2d_sw.h b/servers/physics_2d/broad_phase_2d_sw.h index c7777d9d92..5e42c72d83 100644 --- a/servers/physics_2d/broad_phase_2d_sw.h +++ b/servers/physics_2d/broad_phase_2d_sw.h @@ -58,8 +58,8 @@ public: virtual bool is_static(ID p_id) const = 0; virtual int get_subindex(ID p_id) const = 0; - virtual int cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; - virtual int cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; + virtual int cull_segment(const Vector2 &p_from, const Vector2 &p_to, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0; + virtual int cull_aabb(const Rect2 &p_aabb, CollisionObject2DSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0; virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0; virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0; diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp index 8fb3296be6..0ec293c042 100644 --- a/servers/physics_2d/collision_object_2d_sw.cpp +++ b/servers/physics_2d/collision_object_2d_sw.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "collision_object_2d_sw.h" -#include "servers/physics_2d/physics_2d_server_sw.h" +#include "servers/physics_2d/physics_server_2d_sw.h" #include "space_2d_sw.h" void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_transform, bool p_disabled) { @@ -46,7 +46,7 @@ void CollisionObject2DSW::add_shape(Shape2DSW *p_shape, const Transform2D &p_tra p_shape->add_owner(this); if (!pending_shape_update_list.in_list()) { - Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); } // _update_shapes(); // _shapes_changed(); @@ -61,7 +61,7 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) { p_shape->add_owner(this); if (!pending_shape_update_list.in_list()) { - Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); } // _update_shapes(); // _shapes_changed(); @@ -81,7 +81,7 @@ void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_ shapes.write[p_index].xform_inv = p_transform.affine_inverse(); if (!pending_shape_update_list.in_list()) { - Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); } // _update_shapes(); // _shapes_changed(); @@ -103,12 +103,12 @@ void CollisionObject2DSW::set_shape_as_disabled(int p_idx, bool p_disabled) { space->get_broadphase()->remove(shape.bpid); shape.bpid = 0; if (!pending_shape_update_list.in_list()) { - Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); } //_update_shapes(); } else if (!p_disabled && shape.bpid == 0) { if (!pending_shape_update_list.in_list()) { - Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); } //_update_shapes(); // automatically adds shape with bpid == 0 } @@ -142,7 +142,7 @@ void CollisionObject2DSW::remove_shape(int p_index) { shapes.remove(p_index); if (!pending_shape_update_list.in_list()) { - Physics2DServerSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer2DSW::singletonsw->pending_shape_update_list.add(&pending_shape_update_list); } // _update_shapes(); // _shapes_changed(); @@ -266,7 +266,7 @@ CollisionObject2DSW::CollisionObject2DSW(Type p_type) : _static = true; type = p_type; - space = NULL; + space = nullptr; collision_mask = 1; collision_layer = 1; pickable = true; diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index 3f9d19bbab..98105a7c0e 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -33,7 +33,7 @@ #include "broad_phase_2d_sw.h" #include "core/self_list.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" #include "shape_2d_sw.h" class Space2DSW; diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index da67fcc770..a954cb3de3 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -145,7 +145,7 @@ static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_po _generate_contacts_point_edge, }, { - 0, + nullptr, _generate_contacts_edge_edge, } }; @@ -1042,16 +1042,16 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW *p_a, const bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) { - Physics2DServer::ShapeType type_A = p_shape_A->get_type(); + PhysicsServer2D::ShapeType type_A = p_shape_A->get_type(); - ERR_FAIL_COND_V(type_A == Physics2DServer::SHAPE_LINE, false); - //ERR_FAIL_COND_V(type_A==Physics2DServer::SHAPE_RAY,false); + ERR_FAIL_COND_V(type_A == PhysicsServer2D::SHAPE_LINE, false); + //ERR_FAIL_COND_V(type_A==PhysicsServer2D::SHAPE_RAY,false); ERR_FAIL_COND_V(p_shape_A->is_concave(), false); - Physics2DServer::ShapeType type_B = p_shape_B->get_type(); + PhysicsServer2D::ShapeType type_B = p_shape_B->get_type(); - ERR_FAIL_COND_V(type_B == Physics2DServer::SHAPE_LINE, false); - //ERR_FAIL_COND_V(type_B==Physics2DServer::SHAPE_RAY,false); + ERR_FAIL_COND_V(type_B == PhysicsServer2D::SHAPE_LINE, false); + //ERR_FAIL_COND_V(type_B==PhysicsServer2D::SHAPE_RAY,false); ERR_FAIL_COND_V(p_shape_B->is_concave(), false); static const CollisionFunc collision_table[5][5] = { @@ -1060,25 +1060,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<false, false, false>, _collision_segment_capsule<false, false, false>, _collision_segment_convex_polygon<false, false, false> }, - { 0, + { nullptr, _collision_circle_circle<false, false, false>, _collision_circle_rectangle<false, false, false>, _collision_circle_capsule<false, false, false>, _collision_circle_convex_polygon<false, false, false> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<false, false, false>, _collision_rectangle_capsule<false, false, false>, _collision_rectangle_convex_polygon<false, false, false> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<false, false, false>, _collision_capsule_convex_polygon<false, false, false> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<false, false, false> } }; @@ -1089,25 +1089,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<true, false, false>, _collision_segment_capsule<true, false, false>, _collision_segment_convex_polygon<true, false, false> }, - { 0, + { nullptr, _collision_circle_circle<true, false, false>, _collision_circle_rectangle<true, false, false>, _collision_circle_capsule<true, false, false>, _collision_circle_convex_polygon<true, false, false> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<true, false, false>, _collision_rectangle_capsule<true, false, false>, _collision_rectangle_convex_polygon<true, false, false> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<true, false, false>, _collision_capsule_convex_polygon<true, false, false> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<true, false, false> } }; @@ -1118,25 +1118,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<false, true, false>, _collision_segment_capsule<false, true, false>, _collision_segment_convex_polygon<false, true, false> }, - { 0, + { nullptr, _collision_circle_circle<false, true, false>, _collision_circle_rectangle<false, true, false>, _collision_circle_capsule<false, true, false>, _collision_circle_convex_polygon<false, true, false> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<false, true, false>, _collision_rectangle_capsule<false, true, false>, _collision_rectangle_convex_polygon<false, true, false> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<false, true, false>, _collision_capsule_convex_polygon<false, true, false> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<false, true, false> } }; @@ -1147,25 +1147,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<true, true, false>, _collision_segment_capsule<true, true, false>, _collision_segment_convex_polygon<true, true, false> }, - { 0, + { nullptr, _collision_circle_circle<true, true, false>, _collision_circle_rectangle<true, true, false>, _collision_circle_capsule<true, true, false>, _collision_circle_convex_polygon<true, true, false> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<true, true, false>, _collision_rectangle_capsule<true, true, false>, _collision_rectangle_convex_polygon<true, true, false> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<true, true, false>, _collision_capsule_convex_polygon<true, true, false> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<true, true, false> } }; @@ -1176,25 +1176,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<false, false, true>, _collision_segment_capsule<false, false, true>, _collision_segment_convex_polygon<false, false, true> }, - { 0, + { nullptr, _collision_circle_circle<false, false, true>, _collision_circle_rectangle<false, false, true>, _collision_circle_capsule<false, false, true>, _collision_circle_convex_polygon<false, false, true> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<false, false, true>, _collision_rectangle_capsule<false, false, true>, _collision_rectangle_convex_polygon<false, false, true> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<false, false, true>, _collision_capsule_convex_polygon<false, false, true> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<false, false, true> } }; @@ -1205,25 +1205,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<true, false, true>, _collision_segment_capsule<true, false, true>, _collision_segment_convex_polygon<true, false, true> }, - { 0, + { nullptr, _collision_circle_circle<true, false, true>, _collision_circle_rectangle<true, false, true>, _collision_circle_capsule<true, false, true>, _collision_circle_convex_polygon<true, false, true> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<true, false, true>, _collision_rectangle_capsule<true, false, true>, _collision_rectangle_convex_polygon<true, false, true> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<true, false, true>, _collision_capsule_convex_polygon<true, false, true> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<true, false, true> } }; @@ -1234,25 +1234,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<false, true, true>, _collision_segment_capsule<false, true, true>, _collision_segment_convex_polygon<false, true, true> }, - { 0, + { nullptr, _collision_circle_circle<false, true, true>, _collision_circle_rectangle<false, true, true>, _collision_circle_capsule<false, true, true>, _collision_circle_convex_polygon<false, true, true> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<false, true, true>, _collision_rectangle_capsule<false, true, true>, _collision_rectangle_convex_polygon<false, true, true> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<false, true, true>, _collision_capsule_convex_polygon<false, true, true> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<false, true, true> } }; @@ -1263,25 +1263,25 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D _collision_segment_rectangle<true, true, true>, _collision_segment_capsule<true, true, true>, _collision_segment_convex_polygon<true, true, true> }, - { 0, + { nullptr, _collision_circle_circle<true, true, true>, _collision_circle_rectangle<true, true, true>, _collision_circle_capsule<true, true, true>, _collision_circle_convex_polygon<true, true, true> }, - { 0, - 0, + { nullptr, + nullptr, _collision_rectangle_rectangle<true, true, true>, _collision_rectangle_capsule<true, true, true>, _collision_rectangle_convex_polygon<true, true, true> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_capsule_capsule<true, true, true>, _collision_capsule_convex_polygon<true, true, true> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<true, true, true> } }; diff --git a/servers/physics_2d/collision_solver_2d_sat.h b/servers/physics_2d/collision_solver_2d_sat.h index 105cb9104d..6bb485f561 100644 --- a/servers/physics_2d/collision_solver_2d_sat.h +++ b/servers/physics_2d/collision_solver_2d_sat.h @@ -33,6 +33,6 @@ #include "collision_solver_2d_sw.h" -bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector2 *sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0); +bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector2 *sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0); #endif // COLLISION_SOLVER_2D_SAT_H diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp index 60cca6f825..f117dcbfe5 100644 --- a/servers/physics_2d/collision_solver_2d_sw.cpp +++ b/servers/physics_2d/collision_solver_2d_sw.cpp @@ -37,7 +37,7 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) { const LineShape2DSW *line = static_cast<const LineShape2DSW *>(p_shape_A); - if (p_shape_B->get_type() == Physics2DServer::SHAPE_LINE) + if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_LINE) return false; Vector2 n = p_transform_A.basis_xform(line->get_normal()).normalized(); @@ -75,7 +75,7 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Tr bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis) { const RayShape2DSW *ray = static_cast<const RayShape2DSW *>(p_shape_A); - if (p_shape_B->get_type() == Physics2DServer::SHAPE_RAY) + if (p_shape_B->get_type() == PhysicsServer2D::SHAPE_RAY) return false; Vector2 from = p_transform_A.get_origin(); @@ -195,8 +195,8 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A, const Transf bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *sep_axis, real_t p_margin_A, real_t p_margin_B) { - Physics2DServer::ShapeType type_A = p_shape_A->get_type(); - Physics2DServer::ShapeType type_B = p_shape_B->get_type(); + PhysicsServer2D::ShapeType type_A = p_shape_A->get_type(); + PhysicsServer2D::ShapeType type_B = p_shape_B->get_type(); bool concave_A = p_shape_A->is_concave(); bool concave_B = p_shape_B->is_concave(); real_t margin_A = p_margin_A, margin_B = p_margin_B; @@ -210,9 +210,9 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p swap = true; } - if (type_A == Physics2DServer::SHAPE_LINE) { + if (type_A == PhysicsServer2D::SHAPE_LINE) { - if (type_B == Physics2DServer::SHAPE_LINE || type_B == Physics2DServer::SHAPE_RAY) { + if (type_B == PhysicsServer2D::SHAPE_LINE || type_B == PhysicsServer2D::SHAPE_RAY) { return false; } @@ -222,9 +222,9 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p return solve_static_line(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false); } - } else if (type_A == Physics2DServer::SHAPE_RAY) { + } else if (type_A == PhysicsServer2D::SHAPE_RAY) { - if (type_B == Physics2DServer::SHAPE_RAY) { + if (type_B == PhysicsServer2D::SHAPE_RAY) { return false; //no ray-ray } diff --git a/servers/physics_2d/collision_solver_2d_sw.h b/servers/physics_2d/collision_solver_2d_sw.h index e73ee8fd7e..f39cfee0a9 100644 --- a/servers/physics_2d/collision_solver_2d_sw.h +++ b/servers/physics_2d/collision_solver_2d_sw.h @@ -40,11 +40,11 @@ public: private: static bool solve_static_line(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result); static void concave_callback(void *p_userdata, Shape2DSW *p_convex); - static bool solve_concave(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0); - static bool solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis = NULL); + static bool solve_concave(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0); + static bool solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis = nullptr); public: - static bool solve(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0); + static bool solve(const Shape2DSW *p_shape_A, const Transform2D &p_transform_A, const Vector2 &p_motion_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, const Vector2 &p_motion_B, CallbackResult p_result_callback, void *p_userdata, Vector2 *sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0); }; #endif // COLLISION_SOLVER_2D_SW_H diff --git a/servers/physics_2d/constraint_2d_sw.h b/servers/physics_2d/constraint_2d_sw.h index b5c994cbdd..f8eb16214f 100644 --- a/servers/physics_2d/constraint_2d_sw.h +++ b/servers/physics_2d/constraint_2d_sw.h @@ -45,7 +45,7 @@ class Constraint2DSW { RID self; protected: - Constraint2DSW(Body2DSW **p_body_ptr = NULL, int p_body_count = 0) { + Constraint2DSW(Body2DSW **p_body_ptr = nullptr, int p_body_count = 0) { _body_ptr = p_body_ptr; _body_count = p_body_count; island_step = 0; diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index 02b3502242..4524629d50 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -171,15 +171,15 @@ void PinJoint2DSW::solve(real_t p_step) { P += impulse; } -void PinJoint2DSW::set_param(Physics2DServer::PinJointParam p_param, real_t p_value) { +void PinJoint2DSW::set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value) { - if (p_param == Physics2DServer::PIN_JOINT_SOFTNESS) + if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS) softness = p_value; } -real_t PinJoint2DSW::get_param(Physics2DServer::PinJointParam p_param) const { +real_t PinJoint2DSW::get_param(PhysicsServer2D::PinJointParam p_param) const { - if (p_param == Physics2DServer::PIN_JOINT_SOFTNESS) + if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS) return softness; ERR_FAIL_V(0); } @@ -396,38 +396,38 @@ void DampedSpringJoint2DSW::solve(real_t p_step) { B->apply_impulse(rB, j); } -void DampedSpringJoint2DSW::set_param(Physics2DServer::DampedStringParam p_param, real_t p_value) { +void DampedSpringJoint2DSW::set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value) { switch (p_param) { - case Physics2DServer::DAMPED_STRING_REST_LENGTH: { + case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: { rest_length = p_value; } break; - case Physics2DServer::DAMPED_STRING_DAMPING: { + case PhysicsServer2D::DAMPED_STRING_DAMPING: { damping = p_value; } break; - case Physics2DServer::DAMPED_STRING_STIFFNESS: { + case PhysicsServer2D::DAMPED_STRING_STIFFNESS: { stiffness = p_value; } break; } } -real_t DampedSpringJoint2DSW::get_param(Physics2DServer::DampedStringParam p_param) const { +real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedStringParam p_param) const { switch (p_param) { - case Physics2DServer::DAMPED_STRING_REST_LENGTH: { + case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: { return rest_length; } break; - case Physics2DServer::DAMPED_STRING_DAMPING: { + case PhysicsServer2D::DAMPED_STRING_DAMPING: { return damping; } break; - case Physics2DServer::DAMPED_STRING_STIFFNESS: { + case PhysicsServer2D::DAMPED_STRING_STIFFNESS: { return stiffness; } break; diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h index 3e8fc1a29f..a0d25dc70d 100644 --- a/servers/physics_2d/joints_2d_sw.h +++ b/servers/physics_2d/joints_2d_sw.h @@ -50,8 +50,8 @@ public: _FORCE_INLINE_ void set_max_bias(real_t p_bias) { max_bias = p_bias; } _FORCE_INLINE_ real_t get_max_bias() const { return max_bias; } - virtual Physics2DServer::JointType get_type() const = 0; - Joint2DSW(Body2DSW **p_body_ptr = NULL, int p_body_count = 0) : + virtual PhysicsServer2D::JointType get_type() const = 0; + Joint2DSW(Body2DSW **p_body_ptr = nullptr, int p_body_count = 0) : Constraint2DSW(p_body_ptr, p_body_count) { bias = 0; max_force = max_bias = 3.40282e+38; @@ -78,15 +78,15 @@ class PinJoint2DSW : public Joint2DSW { real_t softness; public: - virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_PIN; } + virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_PIN; } virtual bool setup(real_t p_step); virtual void solve(real_t p_step); - void set_param(Physics2DServer::PinJointParam p_param, real_t p_value); - real_t get_param(Physics2DServer::PinJointParam p_param) const; + void set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer2D::PinJointParam p_param) const; - PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b = NULL); + PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b = nullptr); ~PinJoint2DSW(); }; @@ -116,7 +116,7 @@ class GrooveJoint2DSW : public Joint2DSW { bool correct; public: - virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_GROOVE; } + virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_GROOVE; } virtual bool setup(real_t p_step); virtual void solve(real_t p_step); @@ -150,13 +150,13 @@ class DampedSpringJoint2DSW : public Joint2DSW { real_t v_coef; public: - virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_DAMPED_SPRING; } + virtual PhysicsServer2D::JointType get_type() const { return PhysicsServer2D::JOINT_DAMPED_SPRING; } virtual bool setup(real_t p_step); virtual void solve(real_t p_step); - void set_param(Physics2DServer::DampedStringParam p_param, real_t p_value); - real_t get_param(Physics2DServer::DampedStringParam p_param) const; + void set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value); + real_t get_param(PhysicsServer2D::DampedStringParam p_param) const; DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b); ~DampedSpringJoint2DSW(); diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp index baeb3f76b0..871e2aba1d 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_server_2d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_2d_server_sw.cpp */ +/* physics_server_2d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "physics_2d_server_sw.h" +#include "physics_server_2d_sw.h" + #include "broad_phase_2d_basic.h" #include "broad_phase_2d_hash_grid.h" #include "collision_solver_2d_sw.h" @@ -39,9 +40,9 @@ #define FLUSH_QUERY_CHECK(m_object) \ ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead."); -RID Physics2DServerSW::_shape_create(ShapeType p_shape) { +RID PhysicsServer2DSW::_shape_create(ShapeType p_shape) { - Shape2DSW *shape = NULL; + Shape2DSW *shape = nullptr; switch (p_shape) { case SHAPE_LINE: { @@ -89,63 +90,63 @@ RID Physics2DServerSW::_shape_create(ShapeType p_shape) { return id; } -RID Physics2DServerSW::line_shape_create() { +RID PhysicsServer2DSW::line_shape_create() { return _shape_create(SHAPE_LINE); } -RID Physics2DServerSW::ray_shape_create() { +RID PhysicsServer2DSW::ray_shape_create() { return _shape_create(SHAPE_RAY); } -RID Physics2DServerSW::segment_shape_create() { +RID PhysicsServer2DSW::segment_shape_create() { return _shape_create(SHAPE_SEGMENT); } -RID Physics2DServerSW::circle_shape_create() { +RID PhysicsServer2DSW::circle_shape_create() { return _shape_create(SHAPE_CIRCLE); } -RID Physics2DServerSW::rectangle_shape_create() { +RID PhysicsServer2DSW::rectangle_shape_create() { return _shape_create(SHAPE_RECTANGLE); } -RID Physics2DServerSW::capsule_shape_create() { +RID PhysicsServer2DSW::capsule_shape_create() { return _shape_create(SHAPE_CAPSULE); } -RID Physics2DServerSW::convex_polygon_shape_create() { +RID PhysicsServer2DSW::convex_polygon_shape_create() { return _shape_create(SHAPE_CONVEX_POLYGON); } -RID Physics2DServerSW::concave_polygon_shape_create() { +RID PhysicsServer2DSW::concave_polygon_shape_create() { return _shape_create(SHAPE_CONCAVE_POLYGON); } -void Physics2DServerSW::shape_set_data(RID p_shape, const Variant &p_data) { +void PhysicsServer2DSW::shape_set_data(RID p_shape, const Variant &p_data) { Shape2DSW *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); shape->set_data(p_data); }; -void Physics2DServerSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { +void PhysicsServer2DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { Shape2DSW *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND(!shape); shape->set_custom_bias(p_bias); } -Physics2DServer::ShapeType Physics2DServerSW::shape_get_type(RID p_shape) const { +PhysicsServer2D::ShapeType PhysicsServer2DSW::shape_get_type(RID p_shape) const { const Shape2DSW *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM); return shape->get_type(); }; -Variant Physics2DServerSW::shape_get_data(RID p_shape) const { +Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const { const Shape2DSW *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, Variant()); @@ -153,14 +154,14 @@ Variant Physics2DServerSW::shape_get_data(RID p_shape) const { return shape->get_data(); }; -real_t Physics2DServerSW::shape_get_custom_solver_bias(RID p_shape) const { +real_t PhysicsServer2DSW::shape_get_custom_solver_bias(RID p_shape) const { const Shape2DSW *shape = shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); return shape->get_custom_bias(); } -void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) { +void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) { CollCbkData *cbk = (CollCbkData *)p_userdata; @@ -217,7 +218,7 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 & } } -bool Physics2DServerSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) { +bool PhysicsServer2DSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) { Shape2DSW *shape_A = shape_owner.getornull(p_shape_A); ERR_FAIL_COND_V(!shape_A, false); @@ -226,7 +227,7 @@ bool Physics2DServerSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_ if (p_result_max == 0) { - return CollisionSolver2DSW::solve(shape_A, p_xform_A, p_motion_A, shape_B, p_xform_B, p_motion_B, NULL, NULL); + return CollisionSolver2DSW::solve(shape_A, p_xform_A, p_motion_A, shape_B, p_xform_B, p_motion_B, nullptr, nullptr); } CollCbkData cbk; @@ -240,7 +241,7 @@ bool Physics2DServerSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_ return res; } -RID Physics2DServerSW::space_create() { +RID PhysicsServer2DSW::space_create() { Space2DSW *space = memnew(Space2DSW); RID id = space_owner.make_rid(space); @@ -255,7 +256,7 @@ RID Physics2DServerSW::space_create() { return id; }; -void Physics2DServerSW::space_set_active(RID p_space, bool p_active) { +void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) { Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -265,7 +266,7 @@ void Physics2DServerSW::space_set_active(RID p_space, bool p_active) { active_spaces.erase(space); } -bool Physics2DServerSW::space_is_active(RID p_space) const { +bool PhysicsServer2DSW::space_is_active(RID p_space) const { const Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, false); @@ -273,7 +274,7 @@ bool Physics2DServerSW::space_is_active(RID p_space) const { return active_spaces.has(space); } -void Physics2DServerSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { +void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -281,44 +282,44 @@ void Physics2DServerSW::space_set_param(RID p_space, SpaceParameter p_param, rea space->set_param(p_param, p_value); } -real_t Physics2DServerSW::space_get_param(RID p_space, SpaceParameter p_param) const { +real_t PhysicsServer2DSW::space_get_param(RID p_space, SpaceParameter p_param) const { const Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_param(p_param); } -void Physics2DServerSW::space_set_debug_contacts(RID p_space, int p_max_contacts) { +void PhysicsServer2DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) { Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); space->set_debug_contacts(p_max_contacts); } -Vector<Vector2> Physics2DServerSW::space_get_contacts(RID p_space) const { +Vector<Vector2> PhysicsServer2DSW::space_get_contacts(RID p_space) const { Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, Vector<Vector2>()); return space->get_debug_contacts(); } -int Physics2DServerSW::space_get_contact_count(RID p_space) const { +int PhysicsServer2DSW::space_get_contact_count(RID p_space) const { Space2DSW *space = space_owner.getornull(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_debug_contact_count(); } -Physics2DDirectSpaceState *Physics2DServerSW::space_get_direct_state(RID p_space) { +PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space) { Space2DSW *space = space_owner.getornull(p_space); - ERR_FAIL_COND_V(!space, NULL); - ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification."); + ERR_FAIL_COND_V(!space, nullptr); + ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification."); return space->get_direct_state(); } -RID Physics2DServerSW::area_create() { +RID PhysicsServer2DSW::area_create() { Area2DSW *area = memnew(Area2DSW); RID rid = area_owner.make_rid(area); @@ -326,12 +327,12 @@ RID Physics2DServerSW::area_create() { return rid; }; -void Physics2DServerSW::area_set_space(RID p_area, RID p_space) { +void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); - Space2DSW *space = NULL; + Space2DSW *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -344,7 +345,7 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) { area->set_space(space); }; -RID Physics2DServerSW::area_get_space(RID p_area) const { +RID PhysicsServer2DSW::area_get_space(RID p_area) const { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, RID()); @@ -355,7 +356,7 @@ RID Physics2DServerSW::area_get_space(RID p_area) const { return space->get_self(); }; -void Physics2DServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { +void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -363,7 +364,7 @@ void Physics2DServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverri area->set_space_override_mode(p_mode); } -Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_override_mode(RID p_area) const { +PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_override_mode(RID p_area) const { const Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED); @@ -371,7 +372,7 @@ Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_overrid return area->get_space_override_mode(); } -void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) { +void PhysicsServer2DSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -382,7 +383,7 @@ void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2 area->add_shape(shape, p_transform, p_disabled); } -void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { +void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -393,7 +394,7 @@ void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) area->set_shape(p_shape_idx, shape); } -void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) { +void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -401,7 +402,7 @@ void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, co area->set_shape_transform(p_shape_idx, p_transform); } -void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) { +void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -411,14 +412,14 @@ void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_ area->set_shape_as_disabled(p_shape, p_disabled); } -int Physics2DServerSW::area_get_shape_count(RID p_area) const { +int PhysicsServer2DSW::area_get_shape_count(RID p_area) const { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, -1); return area->get_shape_count(); } -RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const { +RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, RID()); @@ -428,7 +429,7 @@ RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const { return shape->get_self(); } -Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { +Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Transform2D()); @@ -436,7 +437,7 @@ Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_ return area->get_shape_transform(p_shape_idx); } -void Physics2DServerSW::area_remove_shape(RID p_area, int p_shape_idx) { +void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -444,7 +445,7 @@ void Physics2DServerSW::area_remove_shape(RID p_area, int p_shape_idx) { area->remove_shape(p_shape_idx); } -void Physics2DServerSW::area_clear_shapes(RID p_area) { +void PhysicsServer2DSW::area_clear_shapes(RID p_area) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -453,7 +454,7 @@ void Physics2DServerSW::area_clear_shapes(RID p_area) { area->remove_shape(0); } -void Physics2DServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) { +void PhysicsServer2DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) { if (space_owner.owns(p_area)) { Space2DSW *space = space_owner.getornull(p_area); @@ -463,7 +464,7 @@ void Physics2DServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id ERR_FAIL_COND(!area); area->set_instance_id(p_id); } -ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const { +ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { Space2DSW *space = space_owner.getornull(p_area); @@ -474,7 +475,7 @@ ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const { return area->get_instance_id(); } -void Physics2DServerSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) { +void PhysicsServer2DSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) { if (space_owner.owns(p_area)) { Space2DSW *space = space_owner.getornull(p_area); @@ -484,7 +485,7 @@ void Physics2DServerSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id ERR_FAIL_COND(!area); area->set_canvas_instance_id(p_id); } -ObjectID Physics2DServerSW::area_get_canvas_instance_id(RID p_area) const { +ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { Space2DSW *space = space_owner.getornull(p_area); @@ -495,7 +496,7 @@ ObjectID Physics2DServerSW::area_get_canvas_instance_id(RID p_area) const { return area->get_canvas_instance_id(); } -void Physics2DServerSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { +void PhysicsServer2DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { if (space_owner.owns(p_area)) { Space2DSW *space = space_owner.getornull(p_area); @@ -506,14 +507,14 @@ void Physics2DServerSW::area_set_param(RID p_area, AreaParameter p_param, const area->set_param(p_param, p_value); }; -void Physics2DServerSW::area_set_transform(RID p_area, const Transform2D &p_transform) { +void PhysicsServer2DSW::area_set_transform(RID p_area, const Transform2D &p_transform) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_transform(p_transform); }; -Variant Physics2DServerSW::area_get_param(RID p_area, AreaParameter p_param) const { +Variant PhysicsServer2DSW::area_get_param(RID p_area, AreaParameter p_param) const { if (space_owner.owns(p_area)) { Space2DSW *space = space_owner.getornull(p_area); @@ -525,7 +526,7 @@ Variant Physics2DServerSW::area_get_param(RID p_area, AreaParameter p_param) con return area->get_param(p_param); }; -Transform2D Physics2DServerSW::area_get_transform(RID p_area) const { +Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND_V(!area, Transform2D()); @@ -533,14 +534,14 @@ Transform2D Physics2DServerSW::area_get_transform(RID p_area) const { return area->get_transform(); }; -void Physics2DServerSW::area_set_pickable(RID p_area, bool p_pickable) { +void PhysicsServer2DSW::area_set_pickable(RID p_area, bool p_pickable) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); area->set_pickable(p_pickable); } -void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) { +void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -549,7 +550,7 @@ void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) { area->set_monitorable(p_monitorable); } -void Physics2DServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { +void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -557,7 +558,7 @@ void Physics2DServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { area->set_collision_mask(p_mask); } -void Physics2DServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) { +void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -565,7 +566,7 @@ void Physics2DServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) { area->set_collision_layer(p_layer); } -void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { +void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -573,7 +574,7 @@ void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); } -void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { +void PhysicsServer2DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { Area2DSW *area = area_owner.getornull(p_area); ERR_FAIL_COND(!area); @@ -583,7 +584,7 @@ void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_rec /* BODY API */ -RID Physics2DServerSW::body_create() { +RID PhysicsServer2DSW::body_create() { Body2DSW *body = memnew(Body2DSW); RID rid = body_owner.make_rid(body); @@ -591,11 +592,11 @@ RID Physics2DServerSW::body_create() { return rid; } -void Physics2DServerSW::body_set_space(RID p_body, RID p_space) { +void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); - Space2DSW *space = NULL; + Space2DSW *space = nullptr; if (p_space.is_valid()) { space = space_owner.getornull(p_space); ERR_FAIL_COND(!space); @@ -608,7 +609,7 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) { body->set_space(space); }; -RID Physics2DServerSW::body_get_space(RID p_body) const { +RID PhysicsServer2DSW::body_get_space(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); @@ -619,7 +620,7 @@ RID Physics2DServerSW::body_get_space(RID p_body) const { return space->get_self(); }; -void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) { +void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -628,7 +629,7 @@ void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) { body->set_mode(p_mode); }; -Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const { +PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, BODY_MODE_STATIC); @@ -636,7 +637,7 @@ Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const { return body->get_mode(); }; -void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) { +void PhysicsServer2DSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -647,7 +648,7 @@ void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2 body->add_shape(shape, p_transform, p_disabled); } -void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { +void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -658,7 +659,7 @@ void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) body->set_shape(p_shape_idx, shape); } -void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) { +void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -666,28 +667,28 @@ void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, co body->set_shape_transform(p_shape_idx, p_transform); } -void Physics2DServerSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) { +void PhysicsServer2DSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_shape_metadata(p_shape_idx, p_metadata); } -Variant Physics2DServerSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const { +Variant PhysicsServer2DSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Variant()); return body->get_shape_metadata(p_shape_idx); } -int Physics2DServerSW::body_get_shape_count(RID p_body) const { +int PhysicsServer2DSW::body_get_shape_count(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, -1); return body->get_shape_count(); } -RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const { +RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, RID()); @@ -697,7 +698,7 @@ RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const { return shape->get_self(); } -Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { +Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Transform2D()); @@ -705,7 +706,7 @@ Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_ return body->get_shape_transform(p_shape_idx); } -void Physics2DServerSW::body_remove_shape(RID p_body, int p_shape_idx) { +void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -713,7 +714,7 @@ void Physics2DServerSW::body_remove_shape(RID p_body, int p_shape_idx) { body->remove_shape(p_shape_idx); } -void Physics2DServerSW::body_clear_shapes(RID p_body) { +void PhysicsServer2DSW::body_clear_shapes(RID p_body) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -722,7 +723,7 @@ void Physics2DServerSW::body_clear_shapes(RID p_body) { body->remove_shape(0); } -void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { +void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -731,7 +732,7 @@ void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo body->set_shape_as_disabled(p_shape_idx, p_disabled); } -void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) { +void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -741,14 +742,14 @@ void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh body->set_shape_as_one_way_collision(p_shape_idx, p_enable, p_margin); } -void Physics2DServerSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) { +void PhysicsServer2DSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_continuous_collision_detection_mode(p_mode); } -Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_detection_mode(RID p_body) const { +PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_detection_mode(RID p_body) const { const Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED); @@ -756,7 +757,7 @@ Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_dete return body->get_continuous_collision_detection_mode(); } -void Physics2DServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) { +void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -764,7 +765,7 @@ void Physics2DServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id body->set_instance_id(p_id); }; -ObjectID Physics2DServerSW::body_get_object_instance_id(RID p_body) const { +ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, ObjectID()); @@ -772,7 +773,7 @@ ObjectID Physics2DServerSW::body_get_object_instance_id(RID p_body) const { return body->get_instance_id(); }; -void Physics2DServerSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) { +void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -780,7 +781,7 @@ void Physics2DServerSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id body->set_canvas_instance_id(p_id); }; -ObjectID Physics2DServerSW::body_get_canvas_instance_id(RID p_body) const { +ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, ObjectID()); @@ -788,14 +789,14 @@ ObjectID Physics2DServerSW::body_get_canvas_instance_id(RID p_body) const { return body->get_canvas_instance_id(); }; -void Physics2DServerSW::body_set_collision_layer(RID p_body, uint32_t p_layer) { +void PhysicsServer2DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_layer(p_layer); }; -uint32_t Physics2DServerSW::body_get_collision_layer(RID p_body) const { +uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); @@ -803,14 +804,14 @@ uint32_t Physics2DServerSW::body_get_collision_layer(RID p_body) const { return body->get_collision_layer(); }; -void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_mask) { +void PhysicsServer2DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_collision_mask(p_mask); }; -uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const { +uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); @@ -818,7 +819,7 @@ uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const { return body->get_collision_mask(); }; -void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) { +void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -826,7 +827,7 @@ void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t body->set_param(p_param, p_value); }; -real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) const { +real_t PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); @@ -834,7 +835,7 @@ real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) cons return body->get_param(p_param); }; -void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { +void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -842,7 +843,7 @@ void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Vari body->set_state(p_state, p_variant); }; -Variant Physics2DServerSW::body_get_state(RID p_body, BodyState p_state) const { +Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Variant()); @@ -850,7 +851,7 @@ Variant Physics2DServerSW::body_get_state(RID p_body, BodyState p_state) const { return body->get_state(p_state); }; -void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2 &p_force) { +void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_force) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -859,14 +860,14 @@ void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2 &p_forc body->wakeup(); }; -Vector2 Physics2DServerSW::body_get_applied_force(RID p_body) const { +Vector2 PhysicsServer2DSW::body_get_applied_force(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, Vector2()); return body->get_applied_force(); }; -void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) { +void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -875,7 +876,7 @@ void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) { body->wakeup(); }; -real_t Physics2DServerSW::body_get_applied_torque(RID p_body) const { +real_t PhysicsServer2DSW::body_get_applied_torque(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); @@ -883,7 +884,7 @@ real_t Physics2DServerSW::body_get_applied_torque(RID p_body) const { return body->get_applied_torque(); }; -void Physics2DServerSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) { +void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -891,7 +892,7 @@ void Physics2DServerSW::body_apply_central_impulse(RID p_body, const Vector2 &p_ body->wakeup(); } -void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) { +void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -900,7 +901,7 @@ void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) { body->apply_torque_impulse(p_torque); } -void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, const Vector2 &p_impulse) { +void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, const Vector2 &p_impulse) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -911,7 +912,7 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, con body->wakeup(); }; -void Physics2DServerSW::body_add_central_force(RID p_body, const Vector2 &p_force) { +void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_force) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -919,7 +920,7 @@ void Physics2DServerSW::body_add_central_force(RID p_body, const Vector2 &p_forc body->wakeup(); }; -void Physics2DServerSW::body_add_force(RID p_body, const Vector2 &p_offset, const Vector2 &p_force) { +void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_offset, const Vector2 &p_force) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -928,7 +929,7 @@ void Physics2DServerSW::body_add_force(RID p_body, const Vector2 &p_offset, cons body->wakeup(); }; -void Physics2DServerSW::body_add_torque(RID p_body, real_t p_torque) { +void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -936,7 +937,7 @@ void Physics2DServerSW::body_add_torque(RID p_body, real_t p_torque) { body->wakeup(); }; -void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) { +void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -951,7 +952,7 @@ void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis body->wakeup(); }; -void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) { +void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -960,7 +961,7 @@ void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) { body->wakeup(); }; -void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) { +void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -969,7 +970,7 @@ void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b body->wakeup(); }; -void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { +void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -979,20 +980,20 @@ void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e } }; -void Physics2DServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { +void PhysicsServer2DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); }; -real_t Physics2DServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const { +real_t PhysicsServer2DSW::body_get_contacts_reported_depth_threshold(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, 0); return 0; }; -void Physics2DServerSW::body_set_omit_force_integration(RID p_body, bool p_omit) { +void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); @@ -1000,35 +1001,35 @@ void Physics2DServerSW::body_set_omit_force_integration(RID p_body, bool p_omit) body->set_omit_force_integration(p_omit); }; -bool Physics2DServerSW::body_is_omitting_force_integration(RID p_body) const { +bool PhysicsServer2DSW::body_is_omitting_force_integration(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); return body->get_omit_force_integration(); }; -void Physics2DServerSW::body_set_max_contacts_reported(RID p_body, int p_contacts) { +void PhysicsServer2DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_max_contacts_reported(p_contacts); } -int Physics2DServerSW::body_get_max_contacts_reported(RID p_body) const { +int PhysicsServer2DSW::body_get_max_contacts_reported(RID p_body) const { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, -1); return body->get_max_contacts_reported(); } -void Physics2DServerSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { +void PhysicsServer2DSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata); } -bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) { +bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); @@ -1037,14 +1038,14 @@ bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s return shape_collide(body->get_shape(p_body_shape)->get_self(), body->get_transform() * body->get_shape_transform(p_body_shape), Vector2(), p_shape, p_shape_xform, p_motion, r_results, p_result_max, r_result_count); } -void Physics2DServerSW::body_set_pickable(RID p_body, bool p_pickable) { +void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND(!body); body->set_pickable(p_pickable); } -bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); @@ -1056,7 +1057,7 @@ bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes); } -int Physics2DServerSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { +int PhysicsServer2DSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { Body2DSW *body = body_owner.getornull(p_body); ERR_FAIL_COND_V(!body, false); @@ -1066,17 +1067,17 @@ int Physics2DServerSW::body_test_ray_separation(RID p_body, const Transform2D &p return body->get_space()->test_body_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin); } -Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) { +PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) { - ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification."); + ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification."); if (!body_owner.owns(p_body)) - return NULL; + return nullptr; Body2DSW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, NULL); - ERR_FAIL_COND_V(!body->get_space(), NULL); - ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification."); + ERR_FAIL_COND_V(!body, nullptr); + ERR_FAIL_COND_V(!body->get_space(), nullptr); + ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification."); direct_state->body = body; return direct_state; @@ -1084,7 +1085,7 @@ Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) { /* JOINT API */ -void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) { +void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) { Joint2DSW *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); @@ -1096,7 +1097,7 @@ void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t } } -real_t Physics2DServerSW::joint_get_param(RID p_joint, JointParam p_param) const { +real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const { const Joint2DSW *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, -1); @@ -1110,7 +1111,7 @@ real_t Physics2DServerSW::joint_get_param(RID p_joint, JointParam p_param) const return 0; } -void Physics2DServerSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { +void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { Joint2DSW *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND(!joint); @@ -1130,18 +1131,18 @@ void Physics2DServerSW::joint_disable_collisions_between_bodies(RID p_joint, con } } -bool Physics2DServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const { +bool PhysicsServer2DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const { const Joint2DSW *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, true); return joint->is_disabled_collisions_between_bodies(); } -RID Physics2DServerSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID p_body_b) { +RID PhysicsServer2DSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID p_body_b) { Body2DSW *A = body_owner.getornull(p_body_a); ERR_FAIL_COND_V(!A, RID()); - Body2DSW *B = NULL; + Body2DSW *B = nullptr; if (body_owner.owns(p_body_b)) { B = body_owner.getornull(p_body_b); ERR_FAIL_COND_V(!B, RID()); @@ -1154,7 +1155,7 @@ RID Physics2DServerSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID return self; } -RID Physics2DServerSW::groove_joint_create(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) { +RID PhysicsServer2DSW::groove_joint_create(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) { Body2DSW *A = body_owner.getornull(p_body_a); ERR_FAIL_COND_V(!A, RID()); @@ -1168,7 +1169,7 @@ RID Physics2DServerSW::groove_joint_create(const Vector2 &p_a_groove1, const Vec return self; } -RID Physics2DServerSW::damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) { +RID PhysicsServer2DSW::damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) { Body2DSW *A = body_owner.getornull(p_body_a); ERR_FAIL_COND_V(!A, RID()); @@ -1182,7 +1183,7 @@ RID Physics2DServerSW::damped_spring_joint_create(const Vector2 &p_anchor_a, con return self; } -void Physics2DServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { +void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { Joint2DSW *j = joint_owner.getornull(p_joint); ERR_FAIL_COND(!j); @@ -1192,7 +1193,7 @@ void Physics2DServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, pin_joint->set_param(p_param, p_value); } -real_t Physics2DServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { +real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { Joint2DSW *j = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!j, 0); ERR_FAIL_COND_V(j->get_type() != JOINT_PIN, 0); @@ -1201,7 +1202,7 @@ real_t Physics2DServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param return pin_joint->get_param(p_param); } -void Physics2DServerSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) { +void PhysicsServer2DSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) { Joint2DSW *j = joint_owner.getornull(p_joint); ERR_FAIL_COND(!j); @@ -1211,7 +1212,7 @@ void Physics2DServerSW::damped_string_joint_set_param(RID p_joint, DampedStringP dsj->set_param(p_param, p_value); } -real_t Physics2DServerSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const { +real_t PhysicsServer2DSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const { Joint2DSW *j = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!j, 0); @@ -1221,7 +1222,7 @@ real_t Physics2DServerSW::damped_string_joint_get_param(RID p_joint, DampedStrin return dsj->get_param(p_param); } -Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const { +PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const { Joint2DSW *joint = joint_owner.getornull(p_joint); ERR_FAIL_COND_V(!joint, JOINT_PIN); @@ -1229,7 +1230,7 @@ Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const return joint->get_type(); } -void Physics2DServerSW::free(RID p_rid) { +void PhysicsServer2DSW::free(RID p_rid) { _update_shapes(); // just in case @@ -1275,7 +1276,7 @@ void Physics2DServerSW::free(RID p_rid) { _clear_query(area->get_monitor_query()); */ - area->set_space(NULL); + area->set_space(nullptr); while (area->get_shape_count()) { @@ -1290,7 +1291,7 @@ void Physics2DServerSW::free(RID p_rid) { while (space->get_objects().size()) { CollisionObject2DSW *co = (CollisionObject2DSW *)space->get_objects().front()->get(); - co->set_space(NULL); + co->set_space(nullptr); } active_spaces.erase(space); @@ -1310,21 +1311,21 @@ void Physics2DServerSW::free(RID p_rid) { } }; -void Physics2DServerSW::set_active(bool p_active) { +void PhysicsServer2DSW::set_active(bool p_active) { active = p_active; }; -void Physics2DServerSW::init() { +void PhysicsServer2DSW::init() { doing_sync = false; last_step = 0.001; iterations = 8; // 8? stepper = memnew(Step2DSW); - direct_state = memnew(Physics2DDirectBodyStateSW); + direct_state = memnew(PhysicsDirectBodyState2DSW); }; -void Physics2DServerSW::step(real_t p_step) { +void PhysicsServer2DSW::step(real_t p_step) { if (!active) return; @@ -1334,7 +1335,7 @@ void Physics2DServerSW::step(real_t p_step) { doing_sync = false; last_step = p_step; - Physics2DDirectBodyStateSW::singleton->step = p_step; + PhysicsDirectBodyState2DSW::singleton->step = p_step; island_count = 0; active_objects = 0; collision_pairs = 0; @@ -1347,12 +1348,12 @@ void Physics2DServerSW::step(real_t p_step) { } }; -void Physics2DServerSW::sync() { +void PhysicsServer2DSW::sync() { doing_sync = true; }; -void Physics2DServerSW::flush_queries() { +void PhysicsServer2DSW::flush_queries() { if (!active) return; @@ -1405,17 +1406,17 @@ void Physics2DServerSW::flush_queries() { } } -void Physics2DServerSW::end_sync() { +void PhysicsServer2DSW::end_sync() { doing_sync = false; } -void Physics2DServerSW::finish() { +void PhysicsServer2DSW::finish() { memdelete(stepper); memdelete(direct_state); }; -void Physics2DServerSW::_update_shapes() { +void PhysicsServer2DSW::_update_shapes() { while (pending_shape_update_list.first()) { pending_shape_update_list.first()->self()->_shape_changed(); @@ -1423,7 +1424,7 @@ void Physics2DServerSW::_update_shapes() { } } -int Physics2DServerSW::get_process_info(ProcessInfo p_info) { +int PhysicsServer2DSW::get_process_info(ProcessInfo p_info) { switch (p_info) { @@ -1443,9 +1444,9 @@ int Physics2DServerSW::get_process_info(ProcessInfo p_info) { return 0; } -Physics2DServerSW *Physics2DServerSW::singletonsw = NULL; +PhysicsServer2DSW *PhysicsServer2DSW::singletonsw = nullptr; -Physics2DServerSW::Physics2DServerSW() { +PhysicsServer2DSW::PhysicsServer2DSW() { singletonsw = this; BroadPhase2DSW::create_func = BroadPhase2DHashGrid::_create; @@ -1459,6 +1460,6 @@ Physics2DServerSW::Physics2DServerSW() { flushing_queries = false; }; -Physics2DServerSW::~Physics2DServerSW(){ +PhysicsServer2DSW::~PhysicsServer2DSW(){ }; diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_server_2d_sw.h index a95a2ea0dd..918958ffe2 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_server_2d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_2d_server_sw.h */ +/* physics_server_2d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,17 +33,17 @@ #include "core/rid_owner.h" #include "joints_2d_sw.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" #include "shape_2d_sw.h" #include "space_2d_sw.h" #include "step_2d_sw.h" -class Physics2DServerSW : public Physics2DServer { +class PhysicsServer2DSW : public PhysicsServer2D { - GDCLASS(Physics2DServerSW, Physics2DServer); + GDCLASS(PhysicsServer2DSW, PhysicsServer2D); - friend class Physics2DDirectSpaceStateSW; - friend class Physics2DDirectBodyStateSW; + friend class PhysicsDirectSpaceState2DSW; + friend class PhysicsDirectBodyState2DSW; bool active; int iterations; bool doing_sync; @@ -60,7 +60,7 @@ class Physics2DServerSW : public Physics2DServer { Step2DSW *stepper; Set<const Space2DSW *> active_spaces; - Physics2DDirectBodyStateSW *direct_state; + PhysicsDirectBodyState2DSW *direct_state; mutable RID_PtrOwner<Shape2DSW> shape_owner; mutable RID_PtrOwner<Space2DSW> space_owner; @@ -68,7 +68,7 @@ class Physics2DServerSW : public Physics2DServer { mutable RID_PtrOwner<Body2DSW> body_owner; mutable RID_PtrOwner<Joint2DSW> joint_owner; - static Physics2DServerSW *singletonsw; + static PhysicsServer2DSW *singletonsw; //void _clear_query(Query2DSW *p_query); friend class CollisionObject2DSW; @@ -123,7 +123,7 @@ public: virtual int space_get_contact_count(RID p_space) const; // this function only works on physics process, errors and returns null otherwise - virtual Physics2DDirectSpaceState *space_get_direct_state(RID p_space); + virtual PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space); /* AREA API */ @@ -249,11 +249,11 @@ public: virtual void body_set_pickable(RID p_body, bool p_pickable); - virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true); + virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true); virtual int body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001); // this function only works on physics process, errors and returns null otherwise - virtual Physics2DDirectBodyState *body_get_direct_state(RID p_body); + virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body); /* JOINT API */ @@ -289,8 +289,8 @@ public: int get_process_info(ProcessInfo p_info); - Physics2DServerSW(); - ~Physics2DServerSW(); + PhysicsServer2DSW(); + ~PhysicsServer2DSW(); }; #endif diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_server_2d_wrap_mt.cpp index 76036930c6..0a89a76615 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_server_2d_wrap_mt.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_2d_server_wrap_mt.cpp */ +/* physics_server_2d_wrap_mt.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,29 +28,29 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "physics_2d_server_wrap_mt.h" +#include "physics_server_2d_wrap_mt.h" #include "core/os/os.h" -void Physics2DServerWrapMT::thread_exit() { +void PhysicsServer2DWrapMT::thread_exit() { exit = true; } -void Physics2DServerWrapMT::thread_step(real_t p_delta) { +void PhysicsServer2DWrapMT::thread_step(real_t p_delta) { physics_2d_server->step(p_delta); step_sem.post(); } -void Physics2DServerWrapMT::_thread_callback(void *_instance) { +void PhysicsServer2DWrapMT::_thread_callback(void *_instance) { - Physics2DServerWrapMT *vsmt = reinterpret_cast<Physics2DServerWrapMT *>(_instance); + PhysicsServer2DWrapMT *vsmt = reinterpret_cast<PhysicsServer2DWrapMT *>(_instance); vsmt->thread_loop(); } -void Physics2DServerWrapMT::thread_loop() { +void PhysicsServer2DWrapMT::thread_loop() { server_thread = Thread::get_caller_id(); @@ -70,11 +70,11 @@ void Physics2DServerWrapMT::thread_loop() { /* EVENT QUEUING */ -void Physics2DServerWrapMT::step(real_t p_step) { +void PhysicsServer2DWrapMT::step(real_t p_step) { if (create_thread) { - command_queue.push(this, &Physics2DServerWrapMT::thread_step, p_step); + command_queue.push(this, &PhysicsServer2DWrapMT::thread_step, p_step); } else { command_queue.flush_all(); //flush all pending from other threads @@ -82,7 +82,7 @@ void Physics2DServerWrapMT::step(real_t p_step) { } } -void Physics2DServerWrapMT::sync() { +void PhysicsServer2DWrapMT::sync() { if (thread) { if (first_frame) @@ -93,17 +93,17 @@ void Physics2DServerWrapMT::sync() { physics_2d_server->sync(); } -void Physics2DServerWrapMT::flush_queries() { +void PhysicsServer2DWrapMT::flush_queries() { physics_2d_server->flush_queries(); } -void Physics2DServerWrapMT::end_sync() { +void PhysicsServer2DWrapMT::end_sync() { physics_2d_server->end_sync(); } -void Physics2DServerWrapMT::init() { +void PhysicsServer2DWrapMT::init() { if (create_thread) { @@ -118,15 +118,15 @@ void Physics2DServerWrapMT::init() { } } -void Physics2DServerWrapMT::finish() { +void PhysicsServer2DWrapMT::finish() { if (thread) { - command_queue.push(this, &Physics2DServerWrapMT::thread_exit); + command_queue.push(this, &PhysicsServer2DWrapMT::thread_exit); Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } else { physics_2d_server->finish(); } @@ -145,12 +145,12 @@ void Physics2DServerWrapMT::finish() { body_free_cached_ids(); } -Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread) : +PhysicsServer2DWrapMT::PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread) : command_queue(p_create_thread) { physics_2d_server = p_contained; create_thread = p_create_thread; - thread = NULL; + thread = nullptr; step_pending = 0; step_thread_up = false; @@ -166,7 +166,7 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool first_frame = true; } -Physics2DServerWrapMT::~Physics2DServerWrapMT() { +PhysicsServer2DWrapMT::~PhysicsServer2DWrapMT() { memdelete(physics_2d_server); //finish(); diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h index 4d5e317c8c..7e61927378 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_server_2d_wrap_mt.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_2d_server_wrap_mt.h */ +/* physics_server_2d_wrap_mt.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -34,7 +34,7 @@ #include "core/command_queue_mt.h" #include "core/os/thread.h" #include "core/project_settings.h" -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__)); @@ -42,9 +42,9 @@ #define SYNC_DEBUG #endif -class Physics2DServerWrapMT : public Physics2DServer { +class PhysicsServer2DWrapMT : public PhysicsServer2D { - mutable Physics2DServer *physics_2d_server; + mutable PhysicsServer2D *physics_2d_server; mutable CommandQueueMT command_queue; @@ -71,8 +71,8 @@ class Physics2DServerWrapMT : public Physics2DServer { int pool_max_size; public: -#define ServerName Physics2DServer -#define ServerNameWrapMT Physics2DServerWrapMT +#define ServerName PhysicsServer2D +#define ServerNameWrapMT PhysicsServer2DWrapMT #define server_name physics_2d_server #include "servers/server_wrap_mt_common.h" @@ -110,9 +110,9 @@ public: FUNC2RC(real_t, space_get_param, RID, SpaceParameter); // this function only works on physics process, errors and returns null otherwise - Physics2DDirectSpaceState *space_get_direct_state(RID p_space) { + PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) { - ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), NULL); + ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr); return physics_2d_server->space_get_direct_state(p_space); } @@ -255,7 +255,7 @@ public: FUNC2(body_set_pickable, RID, bool); - bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true) { + bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) { ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false); return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r_result, p_exclude_raycast_shapes); @@ -268,9 +268,9 @@ public: } // this function only works on physics process, errors and returns null otherwise - Physics2DDirectBodyState *body_get_direct_state(RID p_body) { + PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) { - ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), NULL); + ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr); return physics_2d_server->body_get_direct_state(p_body); } @@ -320,19 +320,19 @@ public: return physics_2d_server->get_process_info(p_info); } - Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread); - ~Physics2DServerWrapMT(); + PhysicsServer2DWrapMT(PhysicsServer2D *p_contained, bool p_create_thread); + ~PhysicsServer2DWrapMT(); template <class T> - static Physics2DServer *init_server() { + static PhysicsServer2D *init_server() { int tm = GLOBAL_DEF("physics/2d/thread_model", 1); if (tm == 0) // single unsafe return memnew(T); else if (tm == 1) // single safe - return memnew(Physics2DServerWrapMT(memnew(T), false)); + return memnew(PhysicsServer2DWrapMT(memnew(T), false)); else // multi threaded - return memnew(Physics2DServerWrapMT(memnew(T), true)); + return memnew(PhysicsServer2DWrapMT(memnew(T), true)); } #undef ServerNameWrapMT diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 5fefb9595f..06096d674a 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -643,7 +643,7 @@ void ConvexPolygonShape2DSW::set_data(const Variant &p_data) { if (points) memdelete_arr(points); - points = NULL; + points = nullptr; point_count = 0; if (p_data.get_type() == Variant::PACKED_VECTOR2_ARRAY) { @@ -706,7 +706,7 @@ Variant ConvexPolygonShape2DSW::get_data() const { ConvexPolygonShape2DSW::ConvexPolygonShape2DSW() { - points = NULL; + points = nullptr; point_count = 0; } diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h index fa56f2a250..48f3bea1e1 100644 --- a/servers/physics_2d/shape_2d_sw.h +++ b/servers/physics_2d/shape_2d_sw.h @@ -31,7 +31,7 @@ #ifndef SHAPE_2D_2DSW_H #define SHAPE_2D_2DSW_H -#include "servers/physics_2d_server.h" +#include "servers/physics_server_2d.h" #define _SEGMENT_IS_VALID_SUPPORT_THRESHOLD 0.99998 /* @@ -72,7 +72,7 @@ public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } _FORCE_INLINE_ RID get_self() const { return self; } - virtual Physics2DServer::ShapeType get_type() const = 0; + virtual PhysicsServer2D::ShapeType get_type() const = 0; _FORCE_INLINE_ Rect2 get_aabb() const { return aabb; } _FORCE_INLINE_ bool is_configured() const { return configured; } @@ -165,7 +165,7 @@ public: _FORCE_INLINE_ Vector2 get_normal() const { return normal; } _FORCE_INLINE_ real_t get_d() const { return d; } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_LINE; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_LINE; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; @@ -203,7 +203,7 @@ public: _FORCE_INLINE_ real_t get_length() const { return length; } _FORCE_INLINE_ bool get_slips_on_slope() const { return slips_on_slope; } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_RAY; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_RAY; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; @@ -242,7 +242,7 @@ public: _FORCE_INLINE_ const Vector2 &get_b() const { return b; } _FORCE_INLINE_ const Vector2 &get_normal() const { return n; } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_SEGMENT; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_SEGMENT; } _FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D &p_xform) const { @@ -285,7 +285,7 @@ class CircleShape2DSW : public Shape2DSW { public: _FORCE_INLINE_ const real_t &get_radius() const { return radius; } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CIRCLE; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CIRCLE; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; @@ -319,7 +319,7 @@ class RectangleShape2DSW : public Shape2DSW { public: _FORCE_INLINE_ const Vector2 &get_half_extents() const { return half_extents; } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_RECTANGLE; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_RECTANGLE; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; @@ -395,7 +395,7 @@ public: _FORCE_INLINE_ const real_t &get_radius() const { return radius; } _FORCE_INLINE_ const real_t &get_height() const { return height; } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CAPSULE; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CAPSULE; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; @@ -452,7 +452,7 @@ public: return (p_xform.xform(b) - p_xform.xform(a)).normalized().tangent(); } - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CONVEX_POLYGON; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONVEX_POLYGON; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal, p_transform, r_min, r_max); } virtual void get_supports(const Vector2 &p_normal, Vector2 *r_supports, int &r_amount) const; @@ -531,7 +531,7 @@ class ConcavePolygonShape2DSW : public ConcaveShape2DSW { int _generate_bvh(BVH *p_bvh, int p_len, int p_depth); public: - virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CONCAVE_POLYGON; } + virtual PhysicsServer2D::ShapeType get_type() const { return PhysicsServer2D::SHAPE_CONCAVE_POLYGON; } virtual void project_rangev(const Vector2 &p_normal, const Transform2D &p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/ } diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 2009cb823d..7ae2e9769f 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -33,7 +33,7 @@ #include "collision_solver_2d_sw.h" #include "core/os/os.h" #include "core/pair.h" -#include "physics_2d_server_sw.h" +#include "physics_server_2d_sw.h" _FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (!(p_object->get_collision_layer() & p_collision_mask)) { @@ -49,7 +49,7 @@ _FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint return true; } -int Physics2DDirectSpaceStateSW::_intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) { +int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) { if (p_result_max <= 0) return 0; @@ -103,17 +103,17 @@ int Physics2DDirectSpaceStateSW::_intersect_point_impl(const Vector2 &p_point, S return cc; } -int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) { +int PhysicsDirectSpaceState2DSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) { return _intersect_point_impl(p_point, r_results, p_result_max, p_exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_point); } -int Physics2DDirectSpaceStateSW::intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_instance_id, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) { +int PhysicsDirectSpaceState2DSW::intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_instance_id, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point) { return _intersect_point_impl(p_point, r_results, p_result_max, p_exclude, p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_point, true, p_canvas_instance_id); } -bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { ERR_FAIL_COND_V(space->locked, false); @@ -193,12 +193,12 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec return true; } -int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (p_result_max <= 0) return 0; - Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); Rect2 aabb = p_xform.xform(shape->get_aabb()); @@ -222,7 +222,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans const CollisionObject2DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; - if (!CollisionSolver2DSW::solve(shape, p_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), NULL, NULL, NULL, p_margin)) + if (!CollisionSolver2DSW::solve(shape, p_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), nullptr, nullptr, nullptr, p_margin)) continue; r_results[cc].collider_id = col_obj->get_instance_id(); @@ -238,9 +238,9 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans return cc; } -bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, false); Rect2 aabb = p_xform.xform(shape->get_aabb()); @@ -265,12 +265,12 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? - if (!CollisionSolver2DSW::solve(shape, p_xform, p_motion, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), NULL, NULL, NULL, p_margin)) { + if (!CollisionSolver2DSW::solve(shape, p_xform, p_motion, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, nullptr, p_margin)) { continue; } //test initial overlap - if (CollisionSolver2DSW::solve(shape, p_xform, Vector2(), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), NULL, NULL, NULL, p_margin)) { + if (CollisionSolver2DSW::solve(shape, p_xform, Vector2(), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, nullptr, p_margin)) { return false; } @@ -285,7 +285,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor real_t ofs = (low + hi) * 0.5; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(shape, p_xform, p_motion * ofs, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), NULL, NULL, &sep, p_margin); + bool collided = CollisionSolver2DSW::solve(shape, p_xform, p_motion * ofs, col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), nullptr, nullptr, &sep, p_margin); if (collided) { @@ -308,12 +308,12 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor return true; } -bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (p_result_max <= 0) return 0; - Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); Rect2 aabb = p_shape_xform.xform(shape->get_aabb()); @@ -325,14 +325,14 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D & bool collided = false; r_result_count = 0; - Physics2DServerSW::CollCbkData cbk; + PhysicsServer2DSW::CollCbkData cbk; cbk.max = p_result_max; cbk.amount = 0; cbk.passed = 0; cbk.ptr = r_results; - CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk; + CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk; - Physics2DServerSW::CollCbkData *cbkptr = &cbk; + PhysicsServer2DSW::CollCbkData *cbkptr = &cbk; for (int i = 0; i < amount; i++) { @@ -348,7 +348,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D & cbk.valid_dir = Vector2(); cbk.valid_depth = 0; - if (CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), cbkres, cbkptr, NULL, p_margin)) { + if (CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), cbkres, cbkptr, nullptr, p_margin)) { collided = cbk.amount > 0; } } @@ -402,9 +402,9 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B, rd->best_local_shape = rd->local_shape; } -bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); Rect2 aabb = p_shape_xform.xform(shape->get_aabb()); @@ -415,7 +415,7 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh _RestCallbackData2D rcd; rcd.best_len = 0; - rcd.best_object = NULL; + rcd.best_object = nullptr; rcd.best_shape = 0; rcd.min_allowed_depth = space->test_motion_min_contact_depth; @@ -435,7 +435,7 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh rcd.object = col_obj; rcd.shape = shape_idx; rcd.local_shape = 0; - bool sc = CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), _rest_cbk_result, &rcd, NULL, p_margin); + bool sc = CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), _rest_cbk_result, &rcd, nullptr, p_margin); if (!sc) continue; } @@ -462,9 +462,9 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh return true; } -Physics2DDirectSpaceStateSW::Physics2DDirectSpaceStateSW() { +PhysicsDirectSpaceState2DSW::PhysicsDirectSpaceState2DSW() { - space = NULL; + space = nullptr; } //////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -503,7 +503,7 @@ int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body, const Rect2 &p_aabb) { return amount; } -int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, Physics2DServer::SeparationResult *r_results, int p_result_max, real_t p_margin) { +int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, PhysicsServer2D::SeparationResult *r_results, int p_result_max, real_t p_margin) { Rect2 body_aabb; @@ -514,7 +514,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t if (p_body->is_shape_set_as_disabled(i)) continue; - if (p_body->get_shape(i)->get_type() != Physics2DServer::SHAPE_RAY) + if (p_body->get_shape(i)->get_type() != PhysicsServer2D::SHAPE_RAY) continue; if (!shapes_found) { @@ -548,10 +548,10 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t const int max_results = 32; int recover_attempts = 4; Vector2 sr[max_results * 2]; - Physics2DServerSW::CollCbkData cbk; + PhysicsServer2DSW::CollCbkData cbk; cbk.max = max_results; - Physics2DServerSW::CollCbkData *cbkptr = &cbk; - CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk; + PhysicsServer2DSW::CollCbkData *cbkptr = &cbk; + CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk; do { @@ -567,7 +567,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t Shape2DSW *body_shape = p_body->get_shape(j); - if (body_shape->get_type() != Physics2DServer::SHAPE_RAY) + if (body_shape->get_type() != PhysicsServer2D::SHAPE_RAY) continue; Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j); @@ -584,7 +584,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) { const Body2DSW *b = static_cast<const Body2DSW *>(col_obj); - if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) { + if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) { continue; } } @@ -613,7 +613,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t */ Shape2DSW *against_shape = col_obj->get_shape(shape_idx); - if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), cbkres, cbkptr, NULL, p_margin)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), cbkres, cbkptr, nullptr, p_margin)) { if (cbk.amount > 0) { collided = true; } @@ -632,7 +632,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t if (ray_index != -1) { - Physics2DServer::SeparationResult &result = r_results[ray_index]; + PhysicsServer2D::SeparationResult &result = r_results[ray_index]; for (int k = 0; k < cbk.amount; k++) { Vector2 a = sr[k * 2 + 0]; @@ -687,7 +687,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t return rays_found; } -bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, Physics2DServer::MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes) { //give me back regular physics engine logic //this is madness @@ -709,7 +709,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (p_body->is_shape_set_as_disabled(i)) continue; - if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == Physics2DServer::SHAPE_RAY) + if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == PhysicsServer2D::SHAPE_RAY) continue; if (!shapes_found) { @@ -722,7 +722,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (!shapes_found) { if (r_result) { - *r_result = Physics2DServer::MotionResult(); + *r_result = PhysicsServer2D::MotionResult(); r_result->motion = p_motion; } return false; @@ -749,7 +749,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co do { - Physics2DServerSW::CollCbkData cbk; + PhysicsServer2DSW::CollCbkData cbk; cbk.max = max_results; cbk.amount = 0; cbk.passed = 0; @@ -757,8 +757,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.invalid_by_dir = 0; excluded_shape_pair_count = 0; //last step is the one valid - Physics2DServerSW::CollCbkData *cbkptr = &cbk; - CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk; + PhysicsServer2DSW::CollCbkData *cbkptr = &cbk; + CollisionSolver2DSW::CallbackResult cbkres = PhysicsServer2DSW::_shape_col_cbk; bool collided = false; @@ -769,7 +769,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co continue; Shape2DSW *body_shape = p_body->get_shape(j); - if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) { + if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) { continue; } @@ -781,7 +781,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) { const Body2DSW *b = static_cast<const Body2DSW *>(col_obj); - if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) { + if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) { continue; } } @@ -798,11 +798,11 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (col_obj->get_type() == CollisionObject2DSW::TYPE_BODY) { const Body2DSW *b = static_cast<const Body2DSW *>(col_obj); - if (b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC || b->get_mode() == Physics2DServer::BODY_MODE_RIGID) { + if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_RIGID) { //fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction Vector2 lv = b->get_linear_velocity(); //compute displacement from linear velocity - Vector2 motion = lv * Physics2DDirectBodyStateSW::singleton->step; + Vector2 motion = lv * PhysicsDirectBodyState2DSW::singleton->step; float motion_len = motion.length(); motion.normalize(); cbk.valid_depth += motion_len * MAX(motion.dot(-cbk.valid_dir), 0.0); @@ -818,7 +818,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co bool did_collide = false; Shape2DSW *against_shape = col_obj->get_shape(shape_idx); - if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), cbkres, cbkptr, NULL, separation_margin)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), cbkres, cbkptr, nullptr, separation_margin)) { did_collide = cbk.passed > current_passed; //more passed, so collision actually existed } @@ -884,7 +884,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co continue; Shape2DSW *body_shape = p_body->get_shape(body_shape_idx); - if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) { + if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) { continue; } @@ -903,7 +903,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) { const Body2DSW *b = static_cast<const Body2DSW *>(col_obj); - if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) { + if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) { continue; } } @@ -925,12 +925,12 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co Transform2D col_obj_shape_xform = col_obj->get_transform() * col_obj->get_shape_transform(col_shape_idx); //test initial overlap, does it collide if going all the way? - if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, against_shape, col_obj_shape_xform, Vector2(), NULL, NULL, NULL, 0)) { + if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, nullptr, 0)) { continue; } //test initial overlap - if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), NULL, NULL, NULL, 0)) { + if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, nullptr, 0)) { if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) { continue; @@ -950,7 +950,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co real_t ofs = (low + hi) * 0.5; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, against_shape, col_obj_shape_xform, Vector2(), NULL, NULL, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * ofs, against_shape, col_obj_shape_xform, Vector2(), nullptr, nullptr, &sep, 0); if (collided) { @@ -964,7 +964,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) { Vector2 cd[2]; - Physics2DServerSW::CollCbkData cbk; + PhysicsServer2DSW::CollCbkData cbk; cbk.max = 1; cbk.amount = 0; cbk.passed = 0; @@ -974,7 +974,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.valid_depth = 10e20; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_shape_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_shape_xform, Vector2(), PhysicsServer2DSW::_shape_col_cbk, &cbk, &sep, 0); if (!collided || cbk.amount == 0) { continue; } @@ -1018,7 +1018,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co _RestCallbackData2D rcd; rcd.best_len = 0; - rcd.best_object = NULL; + rcd.best_object = nullptr; rcd.best_shape = 0; rcd.min_allowed_depth = test_motion_min_contact_depth; @@ -1034,7 +1034,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co Transform2D body_shape_xform = ugt * p_body->get_shape_transform(j); Shape2DSW *body_shape = p_body->get_shape(j); - if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) { + if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer2D::SHAPE_RAY) { continue; } @@ -1049,7 +1049,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co if (CollisionObject2DSW::TYPE_BODY == col_obj->get_type()) { const Body2DSW *b = static_cast<const Body2DSW *>(col_obj); - if (p_infinite_inertia && Physics2DServer::BODY_MODE_STATIC != b->get_mode() && Physics2DServer::BODY_MODE_KINEMATIC != b->get_mode()) { + if (p_infinite_inertia && PhysicsServer2D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer2D::BODY_MODE_KINEMATIC != b->get_mode()) { continue; } } @@ -1081,7 +1081,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co rcd.object = col_obj; rcd.shape = shape_idx; rcd.local_shape = j; - bool sc = CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), _rest_cbk_result, &rcd, NULL, p_margin); + bool sc = CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_shape_xform, Vector2(), _rest_cbk_result, &rcd, nullptr, p_margin); if (!sc) continue; } @@ -1156,7 +1156,7 @@ void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, Coll return b; } - return NULL; + return nullptr; } void Space2DSW::_broadphase_unpair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_data, void *p_self) { @@ -1277,33 +1277,33 @@ void Space2DSW::update() { broadphase->update(); } -void Space2DSW::set_param(Physics2DServer::SpaceParameter p_param, real_t p_value) { +void Space2DSW::set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value) { switch (p_param) { - case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break; - case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break; - case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break; - case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; - case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; - case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break; - case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break; - case Physics2DServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break; + case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break; + case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break; + case PhysicsServer2D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break; + case PhysicsServer2D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; + case PhysicsServer2D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; + case PhysicsServer2D::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break; + case PhysicsServer2D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break; + case PhysicsServer2D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break; } } -real_t Space2DSW::get_param(Physics2DServer::SpaceParameter p_param) const { +real_t Space2DSW::get_param(PhysicsServer2D::SpaceParameter p_param) const { switch (p_param) { - case Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; - case Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; - case Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; - case Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold; - case Physics2DServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold; - case Physics2DServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; - case Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; - case Physics2DServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth; + case PhysicsServer2D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; + case PhysicsServer2D::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; + case PhysicsServer2D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; + case PhysicsServer2D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold; + case PhysicsServer2D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold; + case PhysicsServer2D::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; + case PhysicsServer2D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; + case PhysicsServer2D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth; } return 0; } @@ -1323,7 +1323,7 @@ bool Space2DSW::is_locked() const { return locked; } -Physics2DDirectSpaceStateSW *Space2DSW::get_direct_state() { +PhysicsDirectSpaceState2DSW *Space2DSW::get_direct_state() { return direct_access; } @@ -1351,9 +1351,9 @@ Space2DSW::Space2DSW() { broadphase = BroadPhase2DSW::create_func(); broadphase->set_pair_callback(_broadphase_pair, this); broadphase->set_unpair_callback(_broadphase_unpair, this); - area = NULL; + area = nullptr; - direct_access = memnew(Physics2DDirectSpaceStateSW); + direct_access = memnew(PhysicsDirectSpaceState2DSW); direct_access->space = this; for (int i = 0; i < ELAPSED_TIME_MAX; i++) diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 919c65d849..c6b324c928 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -41,9 +41,9 @@ #include "core/project_settings.h" #include "core/typedefs.h" -class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState { +class PhysicsDirectSpaceState2DSW : public PhysicsDirectSpaceState2D { - GDCLASS(Physics2DDirectSpaceStateSW, Physics2DDirectSpaceState); + GDCLASS(PhysicsDirectSpaceState2DSW, PhysicsDirectSpaceState2D); int _intersect_point_impl(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_point, bool p_filter_by_canvas = false, ObjectID p_canvas_instance_id = ObjectID()); @@ -58,7 +58,7 @@ public: virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); - Physics2DDirectSpaceStateSW(); + PhysicsDirectSpaceState2DSW(); }; class Space2DSW { @@ -83,7 +83,7 @@ private: uint64_t elapsed_time[ELAPSED_TIME_MAX]; - Physics2DDirectSpaceStateSW *direct_access; + PhysicsDirectSpaceState2DSW *direct_access; RID self; BroadPhase2DSW *broadphase; @@ -129,7 +129,7 @@ private: Vector<Vector2> contact_debug; int contact_debug_count; - friend class Physics2DDirectSpaceStateSW; + friend class PhysicsDirectSpaceState2DSW; public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } @@ -175,8 +175,8 @@ public: void lock(); void unlock(); - void set_param(Physics2DServer::SpaceParameter p_param, real_t p_value); - real_t get_param(Physics2DServer::SpaceParameter p_param) const; + void set_param(PhysicsServer2D::SpaceParameter p_param, real_t p_value); + real_t get_param(PhysicsServer2D::SpaceParameter p_param) const; void set_island_count(int p_island_count) { island_count = p_island_count; } int get_island_count() const { return island_count; } @@ -186,8 +186,8 @@ public: int get_collision_pairs() const { return collision_pairs; } - bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, Physics2DServer::MotionResult *r_result, bool p_exclude_raycast_shapes = true); - int test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, Physics2DServer::SeparationResult *r_results, int p_result_max, real_t p_margin); + bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer2D::MotionResult *r_result, bool p_exclude_raycast_shapes = true); + int test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, PhysicsServer2D::SeparationResult *r_results, int p_result_max, real_t p_margin); void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); } _FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.empty(); } @@ -197,7 +197,7 @@ public: _FORCE_INLINE_ Vector<Vector2> get_debug_contacts() { return contact_debug; } _FORCE_INLINE_ int get_debug_contact_count() { return contact_debug_count; } - Physics2DDirectSpaceStateSW *get_direct_state(); + PhysicsDirectSpaceState2DSW *get_direct_state(); void set_elapsed_time(ElapsedTime p_time, uint64_t p_msec) { elapsed_time[p_time] = p_msec; } uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; } diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index 21f18229e7..6f3bcfec13 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -50,7 +50,7 @@ void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constrain if (i == E->get()) continue; Body2DSW *b = c->get_body_ptr()[i]; - if (b->get_island_step() == _step || b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) + if (b->get_island_step() == _step || b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) continue; //no go _populate_island(c->get_body_ptr()[i], p_island, p_constraint_island); } @@ -60,7 +60,7 @@ void Step2DSW::_populate_island(Body2DSW *p_body, Body2DSW **p_island, Constrain bool Step2DSW::_setup_island(Constraint2DSW *p_island, real_t p_delta) { Constraint2DSW *ci = p_island; - Constraint2DSW *prev_ci = NULL; + Constraint2DSW *prev_ci = nullptr; bool removed_root = false; while (ci) { bool process = ci->setup(p_delta); @@ -101,7 +101,7 @@ void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) { Body2DSW *b = p_island; while (b) { - if (b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) { + if (b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) { b = b->get_island_next(); continue; //ignore for static } @@ -117,7 +117,7 @@ void Step2DSW::_check_suspend(Body2DSW *p_island, real_t p_delta) { b = p_island; while (b) { - if (b->get_mode() == Physics2DServer::BODY_MODE_STATIC || b->get_mode() == Physics2DServer::BODY_MODE_KINEMATIC) { + if (b->get_mode() == PhysicsServer2D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC) { b = b->get_island_next(); continue; //ignore for static } @@ -164,8 +164,8 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) { /* GENERATE CONSTRAINT ISLANDS */ - Body2DSW *island_list = NULL; - Constraint2DSW *constraint_island_list = NULL; + Body2DSW *island_list = nullptr; + Constraint2DSW *constraint_island_list = nullptr; b = body_list->first(); int island_count = 0; @@ -175,8 +175,8 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) { if (body->get_island_step() != _step) { - Body2DSW *island = NULL; - Constraint2DSW *constraint_island = NULL; + Body2DSW *island = nullptr; + Constraint2DSW *constraint_island = nullptr; _populate_island(body, &island, &constraint_island); island->set_island_list_next(island_list); @@ -202,7 +202,7 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) { if (c->get_island_step() == _step) continue; c->set_island_step(_step); - c->set_island_next(NULL); + c->set_island_next(nullptr); c->set_island_list_next(constraint_island_list); constraint_island_list = c; } @@ -219,7 +219,7 @@ void Step2DSW::step(Space2DSW *p_space, real_t p_delta, int p_iterations) { { Constraint2DSW *ci = constraint_island_list; - Constraint2DSW *prev_ci = NULL; + Constraint2DSW *prev_ci = nullptr; while (ci) { if (_setup_island(ci, p_delta)) { diff --git a/servers/physics/SCsub b/servers/physics_3d/SCsub index c5cc889112..df7b521693 100644 --- a/servers/physics/SCsub +++ b/servers/physics_3d/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/physics/area_sw.cpp b/servers/physics_3d/area_3d_sw.cpp index 4b54a56253..911a664a10 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics_3d/area_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* area_sw.cpp */ +/* area_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,30 +28,30 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "area_sw.h" -#include "body_sw.h" -#include "space_sw.h" +#include "area_3d_sw.h" +#include "body_3d_sw.h" +#include "space_3d_sw.h" -AreaSW::BodyKey::BodyKey(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { +Area3DSW::BodyKey::BodyKey(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { rid = p_body->get_self(); instance_id = p_body->get_instance_id(); body_shape = p_body_shape; area_shape = p_area_shape; } -AreaSW::BodyKey::BodyKey(AreaSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { +Area3DSW::BodyKey::BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { rid = p_body->get_self(); instance_id = p_body->get_instance_id(); body_shape = p_body_shape; area_shape = p_area_shape; } -void AreaSW::_shapes_changed() { +void Area3DSW::_shapes_changed() { if (!moved_list.in_list() && get_space()) get_space()->area_add_to_moved_list(&moved_list); } -void AreaSW::set_transform(const Transform &p_transform) { +void Area3DSW::set_transform(const Transform &p_transform) { if (!moved_list.in_list() && get_space()) get_space()->area_add_to_moved_list(&moved_list); @@ -60,7 +60,7 @@ void AreaSW::set_transform(const Transform &p_transform) { _set_inv_transform(p_transform.affine_inverse()); } -void AreaSW::set_space(SpaceSW *p_space) { +void Area3DSW::set_space(Space3DSW *p_space) { if (get_space()) { if (monitor_query_list.in_list()) @@ -75,7 +75,7 @@ void AreaSW::set_space(SpaceSW *p_space) { _set_space(p_space); } -void AreaSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) { +void Area3DSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) { if (p_id == monitor_callback_id) { monitor_callback_method = p_method; @@ -96,7 +96,7 @@ void AreaSW::set_monitor_callback(ObjectID p_id, const StringName &p_method) { get_space()->area_add_to_moved_list(&moved_list); } -void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method) { +void Area3DSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method) { if (p_id == area_monitor_callback_id) { area_monitor_callback_method = p_method; @@ -117,46 +117,46 @@ void AreaSW::set_area_monitor_callback(ObjectID p_id, const StringName &p_method get_space()->area_add_to_moved_list(&moved_list); } -void AreaSW::set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode) { - bool do_override = p_mode != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED; - if (do_override == (space_override_mode != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED)) +void Area3DSW::set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode) { + bool do_override = p_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; + if (do_override == (space_override_mode != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED)) return; _unregister_shapes(); space_override_mode = p_mode; _shape_changed(); } -void AreaSW::set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value) { +void Area3DSW::set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value) { switch (p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: gravity = p_value; break; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break; - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break; - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break; - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break; - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break; - case PhysicsServer::AREA_PARAM_PRIORITY: priority = p_value; break; + case PhysicsServer3D::AREA_PARAM_GRAVITY: gravity = p_value; break; + case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: gravity_vector = p_value; break; + case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: gravity_is_point = p_value; break; + case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: gravity_distance_scale = p_value; break; + case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: point_attenuation = p_value; break; + case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: linear_damp = p_value; break; + case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: angular_damp = p_value; break; + case PhysicsServer3D::AREA_PARAM_PRIORITY: priority = p_value; break; } } -Variant AreaSW::get_param(PhysicsServer::AreaParameter p_param) const { +Variant Area3DSW::get_param(PhysicsServer3D::AreaParameter p_param) const { switch (p_param) { - case PhysicsServer::AREA_PARAM_GRAVITY: return gravity; - case PhysicsServer::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector; - case PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point; - case PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale; - case PhysicsServer::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation; - case PhysicsServer::AREA_PARAM_LINEAR_DAMP: return linear_damp; - case PhysicsServer::AREA_PARAM_ANGULAR_DAMP: return angular_damp; - case PhysicsServer::AREA_PARAM_PRIORITY: return priority; + case PhysicsServer3D::AREA_PARAM_GRAVITY: return gravity; + case PhysicsServer3D::AREA_PARAM_GRAVITY_VECTOR: return gravity_vector; + case PhysicsServer3D::AREA_PARAM_GRAVITY_IS_POINT: return gravity_is_point; + case PhysicsServer3D::AREA_PARAM_GRAVITY_DISTANCE_SCALE: return gravity_distance_scale; + case PhysicsServer3D::AREA_PARAM_GRAVITY_POINT_ATTENUATION: return point_attenuation; + case PhysicsServer3D::AREA_PARAM_LINEAR_DAMP: return linear_damp; + case PhysicsServer3D::AREA_PARAM_ANGULAR_DAMP: return angular_damp; + case PhysicsServer3D::AREA_PARAM_PRIORITY: return priority; } return Variant(); } -void AreaSW::_queue_monitor_update() { +void Area3DSW::_queue_monitor_update() { ERR_FAIL_COND(!get_space()); @@ -164,7 +164,7 @@ void AreaSW::_queue_monitor_update() { get_space()->area_add_to_monitor_query_list(&monitor_query_list); } -void AreaSW::set_monitorable(bool p_monitorable) { +void Area3DSW::set_monitorable(bool p_monitorable) { if (monitorable == p_monitorable) return; @@ -173,7 +173,7 @@ void AreaSW::set_monitorable(bool p_monitorable) { _set_static(!monitorable); } -void AreaSW::call_queries() { +void Area3DSW::call_queries() { if (monitor_callback_id.is_valid() && !monitored_bodies.empty()) { @@ -194,7 +194,7 @@ void AreaSW::call_queries() { if (E->get().state == 0) continue; //nothing happened - res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED; + res[0] = E->get().state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED; res[1] = E->key().rid; res[2] = E->key().instance_id; res[3] = E->key().body_shape; @@ -226,7 +226,7 @@ void AreaSW::call_queries() { if (E->get().state == 0) continue; //nothing happened - res[0] = E->get().state > 0 ? PhysicsServer::AREA_BODY_ADDED : PhysicsServer::AREA_BODY_REMOVED; + res[0] = E->get().state > 0 ? PhysicsServer3D::AREA_BODY_ADDED : PhysicsServer3D::AREA_BODY_REMOVED; res[1] = E->key().rid; res[2] = E->key().instance_id; res[3] = E->key().body_shape; @@ -241,13 +241,13 @@ void AreaSW::call_queries() { //get_space()->area_remove_from_monitor_query_list(&monitor_query_list); } -AreaSW::AreaSW() : - CollisionObjectSW(TYPE_AREA), +Area3DSW::Area3DSW() : + CollisionObject3DSW(TYPE_AREA), monitor_query_list(this), moved_list(this) { _set_static(true); //areas are never active - space_override_mode = PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED; + space_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED; gravity = 9.80665; gravity_vector = Vector3(0, -1, 0); gravity_is_point = false; @@ -260,5 +260,5 @@ AreaSW::AreaSW() : monitorable = false; } -AreaSW::~AreaSW() { +Area3DSW::~Area3DSW() { } diff --git a/servers/physics/area_sw.h b/servers/physics_3d/area_3d_sw.h index 4da2b00d20..05e74e63dc 100644 --- a/servers/physics/area_sw.h +++ b/servers/physics_3d/area_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* area_sw.h */ +/* area_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,18 +31,18 @@ #ifndef AREA_SW_H #define AREA_SW_H -#include "collision_object_sw.h" +#include "collision_object_3d_sw.h" #include "core/self_list.h" -#include "servers/physics_server.h" -//#include "servers/physics/query_sw.h" +#include "servers/physics_server_3d.h" +//#include "servers/physics_3d/query_sw.h" -class SpaceSW; -class BodySW; -class ConstraintSW; +class Space3DSW; +class Body3DSW; +class Constraint3DSW; -class AreaSW : public CollisionObjectSW { +class Area3DSW : public CollisionObject3DSW { - PhysicsServer::AreaSpaceOverrideMode space_override_mode; + PhysicsServer3D::AreaSpaceOverrideMode space_override_mode; real_t gravity; Vector3 gravity_vector; bool gravity_is_point; @@ -59,8 +59,8 @@ class AreaSW : public CollisionObjectSW { ObjectID area_monitor_callback_id; StringName area_monitor_callback_method; - SelfList<AreaSW> monitor_query_list; - SelfList<AreaSW> moved_list; + SelfList<Area3DSW> monitor_query_list; + SelfList<Area3DSW> moved_list; struct BodyKey { @@ -83,8 +83,8 @@ class AreaSW : public CollisionObjectSW { } _FORCE_INLINE_ BodyKey() {} - BodyKey(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); - BodyKey(AreaSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); + BodyKey(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); + BodyKey(Area3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); }; struct BodyState { @@ -101,7 +101,7 @@ class AreaSW : public CollisionObjectSW { //virtual void shape_changed_notify(ShapeSW *p_shape); //virtual void shape_deleted_notify(ShapeSW *p_shape); - Set<ConstraintSW *> constraints; + Set<Constraint3DSW *> constraints; virtual void _shapes_changed(); void _queue_monitor_update(); @@ -116,17 +116,17 @@ public: void set_area_monitor_callback(ObjectID p_id, const StringName &p_method); _FORCE_INLINE_ bool has_area_monitor_callback() const { return area_monitor_callback_id.is_valid(); } - _FORCE_INLINE_ void add_body_to_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); - _FORCE_INLINE_ void remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); + _FORCE_INLINE_ void add_body_to_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); + _FORCE_INLINE_ void remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape); - _FORCE_INLINE_ void add_area_to_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape); - _FORCE_INLINE_ void remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape); + _FORCE_INLINE_ void add_area_to_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape); + _FORCE_INLINE_ void remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape); - void set_param(PhysicsServer::AreaParameter p_param, const Variant &p_value); - Variant get_param(PhysicsServer::AreaParameter p_param) const; + void set_param(PhysicsServer3D::AreaParameter p_param, const Variant &p_value); + Variant get_param(PhysicsServer3D::AreaParameter p_param) const; - void set_space_override_mode(PhysicsServer::AreaSpaceOverrideMode p_mode); - PhysicsServer::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; } + void set_space_override_mode(PhysicsServer3D::AreaSpaceOverrideMode p_mode); + PhysicsServer3D::AreaSpaceOverrideMode get_space_override_mode() const { return space_override_mode; } _FORCE_INLINE_ void set_gravity(real_t p_gravity) { gravity = p_gravity; } _FORCE_INLINE_ real_t get_gravity() const { return gravity; } @@ -152,9 +152,9 @@ public: _FORCE_INLINE_ void set_priority(int p_priority) { priority = p_priority; } _FORCE_INLINE_ int get_priority() const { return priority; } - _FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint) { constraints.insert(p_constraint); } - _FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraints.erase(p_constraint); } - _FORCE_INLINE_ const Set<ConstraintSW *> &get_constraints() const { return constraints; } + _FORCE_INLINE_ void add_constraint(Constraint3DSW *p_constraint) { constraints.insert(p_constraint); } + _FORCE_INLINE_ void remove_constraint(Constraint3DSW *p_constraint) { constraints.erase(p_constraint); } + _FORCE_INLINE_ const Set<Constraint3DSW *> &get_constraints() const { return constraints; } _FORCE_INLINE_ void clear_constraints() { constraints.clear(); } void set_monitorable(bool p_monitorable); @@ -162,22 +162,22 @@ public: void set_transform(const Transform &p_transform); - void set_space(SpaceSW *p_space); + void set_space(Space3DSW *p_space); void call_queries(); - AreaSW(); - ~AreaSW(); + Area3DSW(); + ~Area3DSW(); }; -void AreaSW::add_body_to_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { +void Area3DSW::add_body_to_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { BodyKey bk(p_body, p_body_shape, p_area_shape); monitored_bodies[bk].inc(); if (!monitor_query_list.in_list()) _queue_monitor_update(); } -void AreaSW::remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { +void Area3DSW::remove_body_from_query(Body3DSW *p_body, uint32_t p_body_shape, uint32_t p_area_shape) { BodyKey bk(p_body, p_body_shape, p_area_shape); monitored_bodies[bk].dec(); @@ -185,14 +185,14 @@ void AreaSW::remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint3 _queue_monitor_update(); } -void AreaSW::add_area_to_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) { +void Area3DSW::add_area_to_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) { BodyKey bk(p_area, p_area_shape, p_self_shape); monitored_areas[bk].inc(); if (!monitor_query_list.in_list()) _queue_monitor_update(); } -void AreaSW::remove_area_from_query(AreaSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) { +void Area3DSW::remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, uint32_t p_self_shape) { BodyKey bk(p_area, p_area_shape, p_self_shape); monitored_areas[bk].dec(); diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics_3d/area_pair_3d_sw.cpp index 966a440930..fa2fb2dabb 100644 --- a/servers/physics/area_pair_sw.cpp +++ b/servers/physics_3d/area_pair_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* area_pair_sw.cpp */ +/* area_pair_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,16 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "area_pair_sw.h" -#include "collision_solver_sw.h" +#include "area_pair_3d_sw.h" +#include "collision_solver_3d_sw.h" -bool AreaPairSW::setup(real_t p_step) { +bool AreaPair3DSW::setup(real_t p_step) { bool result = false; if (area->is_shape_set_as_disabled(area_shape) || body->is_shape_set_as_disabled(body_shape)) { result = false; - } else if (area->test_collision_mask(body) && CollisionSolverSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), NULL, this)) { + } else if (area->test_collision_mask(body) && CollisionSolver3DSW::solve_static(body->get_shape(body_shape), body->get_transform() * body->get_shape_transform(body_shape), area->get_shape(area_shape), area->get_transform() * area->get_shape_transform(area_shape), nullptr, this)) { result = true; } @@ -45,14 +45,14 @@ bool AreaPairSW::setup(real_t p_step) { if (result) { - if (area->get_space_override_mode() != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED) + if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) body->add_area(area); if (area->has_monitor_callback()) area->add_body_to_query(body, body_shape, area_shape); } else { - if (area->get_space_override_mode() != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED) + if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) body->remove_area(area); if (area->has_monitor_callback()) area->remove_body_from_query(body, body_shape, area_shape); @@ -64,10 +64,10 @@ bool AreaPairSW::setup(real_t p_step) { return false; //never do any post solving } -void AreaPairSW::solve(real_t p_step) { +void AreaPair3DSW::solve(real_t p_step) { } -AreaPairSW::AreaPairSW(BodySW *p_body, int p_body_shape, AreaSW *p_area, int p_area_shape) { +AreaPair3DSW::AreaPair3DSW(Body3DSW *p_body, int p_body_shape, Area3DSW *p_area, int p_area_shape) { body = p_body; area = p_area; @@ -76,15 +76,15 @@ AreaPairSW::AreaPairSW(BodySW *p_body, int p_body_shape, AreaSW *p_area, int p_a colliding = false; body->add_constraint(this, 0); area->add_constraint(this); - if (p_body->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC) + if (p_body->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) p_body->set_active(true); } -AreaPairSW::~AreaPairSW() { +AreaPair3DSW::~AreaPair3DSW() { if (colliding) { - if (area->get_space_override_mode() != PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED) + if (area->get_space_override_mode() != PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED) body->remove_area(area); if (area->has_monitor_callback()) area->remove_body_from_query(body, body_shape, area_shape); @@ -95,12 +95,12 @@ AreaPairSW::~AreaPairSW() { //////////////////////////////////////////////////// -bool Area2PairSW::setup(real_t p_step) { +bool Area2Pair3DSW::setup(real_t p_step) { bool result = false; if (area_a->is_shape_set_as_disabled(shape_a) || area_b->is_shape_set_as_disabled(shape_b)) { result = false; - } else if (area_a->test_collision_mask(area_b) && CollisionSolverSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), NULL, this)) { + } else if (area_a->test_collision_mask(area_b) && CollisionSolver3DSW::solve_static(area_a->get_shape(shape_a), area_a->get_transform() * area_a->get_shape_transform(shape_a), area_b->get_shape(shape_b), area_b->get_transform() * area_b->get_shape_transform(shape_b), nullptr, this)) { result = true; } @@ -129,10 +129,10 @@ bool Area2PairSW::setup(real_t p_step) { return false; //never do any post solving } -void Area2PairSW::solve(real_t p_step) { +void Area2Pair3DSW::solve(real_t p_step) { } -Area2PairSW::Area2PairSW(AreaSW *p_area_a, int p_shape_a, AreaSW *p_area_b, int p_shape_b) { +Area2Pair3DSW::Area2Pair3DSW(Area3DSW *p_area_a, int p_shape_a, Area3DSW *p_area_b, int p_shape_b) { area_a = p_area_a; area_b = p_area_b; @@ -143,7 +143,7 @@ Area2PairSW::Area2PairSW(AreaSW *p_area_a, int p_shape_a, AreaSW *p_area_b, int area_b->add_constraint(this); } -Area2PairSW::~Area2PairSW() { +Area2Pair3DSW::~Area2Pair3DSW() { if (colliding) { diff --git a/servers/physics/area_pair_sw.h b/servers/physics_3d/area_pair_3d_sw.h index 97a37ebf90..3490f41c26 100644 --- a/servers/physics/area_pair_sw.h +++ b/servers/physics_3d/area_pair_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* area_pair_sw.h */ +/* area_pair_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,14 +31,14 @@ #ifndef AREA_PAIR_SW_H #define AREA_PAIR_SW_H -#include "area_sw.h" -#include "body_sw.h" -#include "constraint_sw.h" +#include "area_3d_sw.h" +#include "body_3d_sw.h" +#include "constraint_3d_sw.h" -class AreaPairSW : public ConstraintSW { +class AreaPair3DSW : public Constraint3DSW { - BodySW *body; - AreaSW *area; + Body3DSW *body; + Area3DSW *area; int body_shape; int area_shape; bool colliding; @@ -47,14 +47,14 @@ public: bool setup(real_t p_step); void solve(real_t p_step); - AreaPairSW(BodySW *p_body, int p_body_shape, AreaSW *p_area, int p_area_shape); - ~AreaPairSW(); + AreaPair3DSW(Body3DSW *p_body, int p_body_shape, Area3DSW *p_area, int p_area_shape); + ~AreaPair3DSW(); }; -class Area2PairSW : public ConstraintSW { +class Area2Pair3DSW : public Constraint3DSW { - AreaSW *area_a; - AreaSW *area_b; + Area3DSW *area_a; + Area3DSW *area_b; int shape_a; int shape_b; bool colliding; @@ -63,8 +63,8 @@ public: bool setup(real_t p_step); void solve(real_t p_step); - Area2PairSW(AreaSW *p_area_a, int p_shape_a, AreaSW *p_area_b, int p_shape_b); - ~Area2PairSW(); + Area2Pair3DSW(Area3DSW *p_area_a, int p_shape_a, Area3DSW *p_area_b, int p_shape_b); + ~Area2Pair3DSW(); }; #endif // AREA_PAIR__SW_H diff --git a/servers/physics/body_sw.cpp b/servers/physics_3d/body_3d_sw.cpp index 8819941f04..fea5aed6ad 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics_3d/body_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* body_sw.cpp */ +/* body_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,17 +28,17 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "body_sw.h" -#include "area_sw.h" -#include "space_sw.h" +#include "body_3d_sw.h" +#include "area_3d_sw.h" +#include "space_3d_sw.h" -void BodySW::_update_inertia() { +void Body3DSW::_update_inertia() { if (get_space() && !inertia_update_list.in_list()) get_space()->body_add_to_inertia_update_list(&inertia_update_list); } -void BodySW::_update_transform_dependant() { +void Body3DSW::_update_transform_dependant() { center_of_mass = get_transform().basis.xform(center_of_mass_local); principal_inertia_axes = get_transform().basis * principal_inertia_axes_local; @@ -51,13 +51,13 @@ void BodySW::_update_transform_dependant() { _inv_inertia_tensor = tb * diag * tbt; } -void BodySW::update_inertias() { +void Body3DSW::update_inertias() { //update shapes and motions switch (mode) { - case PhysicsServer::BODY_MODE_RIGID: { + case PhysicsServer3D::BODY_MODE_RIGID: { //update tensor for all shapes, not the best way but should be somehow OK. (inspired from bullet) real_t total_area = 0; @@ -91,7 +91,7 @@ void BodySW::update_inertias() { continue; } - const ShapeSW *shape = get_shape(i); + const Shape3DSW *shape = get_shape(i); real_t area = get_shape_area(i); @@ -119,13 +119,13 @@ void BodySW::update_inertias() { } break; - case PhysicsServer::BODY_MODE_KINEMATIC: - case PhysicsServer::BODY_MODE_STATIC: { + case PhysicsServer3D::BODY_MODE_KINEMATIC: + case PhysicsServer3D::BODY_MODE_STATIC: { _inv_inertia_tensor.set_zero(); _inv_mass = 0; } break; - case PhysicsServer::BODY_MODE_CHARACTER: { + case PhysicsServer3D::BODY_MODE_CHARACTER: { _inv_inertia_tensor.set_zero(); _inv_mass = 1.0 / mass; @@ -138,7 +138,7 @@ void BodySW::update_inertias() { _update_transform_dependant(); } -void BodySW::set_active(bool p_active) { +void Body3DSW::set_active(bool p_active) { if (active == p_active) return; @@ -148,7 +148,7 @@ void BodySW::set_active(bool p_active) { if (get_space()) get_space()->body_remove_from_active_list(&active_list); } else { - if (mode == PhysicsServer::BODY_MODE_STATIC) + if (mode == PhysicsServer3D::BODY_MODE_STATIC) return; //static bodies can't become active if (get_space()) get_space()->body_add_to_active_list(&active_list); @@ -168,31 +168,31 @@ void BodySW::set_active(bool p_active) { */ } -void BodySW::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) { +void Body3DSW::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::BODY_PARAM_BOUNCE: { + case PhysicsServer3D::BODY_PARAM_BOUNCE: { bounce = p_value; } break; - case PhysicsServer::BODY_PARAM_FRICTION: { + case PhysicsServer3D::BODY_PARAM_FRICTION: { friction = p_value; } break; - case PhysicsServer::BODY_PARAM_MASS: { + case PhysicsServer3D::BODY_PARAM_MASS: { ERR_FAIL_COND(p_value <= 0); mass = p_value; _update_inertia(); } break; - case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: { + case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: { gravity_scale = p_value; } break; - case PhysicsServer::BODY_PARAM_LINEAR_DAMP: { + case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: { linear_damp = p_value; } break; - case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: { + case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: { angular_damp = p_value; } break; @@ -201,28 +201,28 @@ void BodySW::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) { } } -real_t BodySW::get_param(PhysicsServer::BodyParameter p_param) const { +real_t Body3DSW::get_param(PhysicsServer3D::BodyParameter p_param) const { switch (p_param) { - case PhysicsServer::BODY_PARAM_BOUNCE: { + case PhysicsServer3D::BODY_PARAM_BOUNCE: { return bounce; } break; - case PhysicsServer::BODY_PARAM_FRICTION: { + case PhysicsServer3D::BODY_PARAM_FRICTION: { return friction; } break; - case PhysicsServer::BODY_PARAM_MASS: { + case PhysicsServer3D::BODY_PARAM_MASS: { return mass; } break; - case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: { + case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: { return gravity_scale; } break; - case PhysicsServer::BODY_PARAM_LINEAR_DAMP: { + case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: { return linear_damp; } break; - case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: { + case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: { return angular_damp; } break; @@ -234,36 +234,36 @@ real_t BodySW::get_param(PhysicsServer::BodyParameter p_param) const { return 0; } -void BodySW::set_mode(PhysicsServer::BodyMode p_mode) { +void Body3DSW::set_mode(PhysicsServer3D::BodyMode p_mode) { - PhysicsServer::BodyMode prev = mode; + PhysicsServer3D::BodyMode prev = mode; mode = p_mode; switch (p_mode) { //CLEAR UP EVERYTHING IN CASE IT NOT WORKS! - case PhysicsServer::BODY_MODE_STATIC: - case PhysicsServer::BODY_MODE_KINEMATIC: { + case PhysicsServer3D::BODY_MODE_STATIC: + case PhysicsServer3D::BODY_MODE_KINEMATIC: { _set_inv_transform(get_transform().affine_inverse()); _inv_mass = 0; - _set_static(p_mode == PhysicsServer::BODY_MODE_STATIC); - //set_active(p_mode==PhysicsServer::BODY_MODE_KINEMATIC); - set_active(p_mode == PhysicsServer::BODY_MODE_KINEMATIC && contacts.size()); + _set_static(p_mode == PhysicsServer3D::BODY_MODE_STATIC); + //set_active(p_mode==PhysicsServer3D::BODY_MODE_KINEMATIC); + set_active(p_mode == PhysicsServer3D::BODY_MODE_KINEMATIC && contacts.size()); linear_velocity = Vector3(); angular_velocity = Vector3(); - if (mode == PhysicsServer::BODY_MODE_KINEMATIC && prev != mode) { + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && prev != mode) { first_time_kinematic = true; } } break; - case PhysicsServer::BODY_MODE_RIGID: { + case PhysicsServer3D::BODY_MODE_RIGID: { _inv_mass = mass > 0 ? (1.0 / mass) : 0; _set_static(false); set_active(true); } break; - case PhysicsServer::BODY_MODE_CHARACTER: { + case PhysicsServer3D::BODY_MODE_CHARACTER: { _inv_mass = mass > 0 ? (1.0 / mass) : 0; _set_static(false); @@ -278,22 +278,22 @@ void BodySW::set_mode(PhysicsServer::BodyMode p_mode) { _update_queries(); */ } -PhysicsServer::BodyMode BodySW::get_mode() const { +PhysicsServer3D::BodyMode Body3DSW::get_mode() const { return mode; } -void BodySW::_shapes_changed() { +void Body3DSW::_shapes_changed() { _update_inertia(); } -void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) { +void Body3DSW::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) { switch (p_state) { - case PhysicsServer::BODY_STATE_TRANSFORM: { + case PhysicsServer3D::BODY_STATE_TRANSFORM: { - if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) { new_transform = p_variant; //wakeup_neighbours(); set_active(true); @@ -303,7 +303,7 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian first_time_kinematic = false; } - } else if (mode == PhysicsServer::BODY_MODE_STATIC) { + } else if (mode == PhysicsServer3D::BODY_MODE_STATIC) { _set_transform(p_variant); _set_inv_transform(get_transform().affine_inverse()); wakeup_neighbours(); @@ -319,27 +319,27 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian wakeup(); } break; - case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: { + case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: { /* - if (mode==PhysicsServer::BODY_MODE_STATIC) + if (mode==PhysicsServer3D::BODY_MODE_STATIC) break; */ linear_velocity = p_variant; wakeup(); } break; - case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: { + case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: { /* - if (mode!=PhysicsServer::BODY_MODE_RIGID) + if (mode!=PhysicsServer3D::BODY_MODE_RIGID) break; */ angular_velocity = p_variant; wakeup(); } break; - case PhysicsServer::BODY_STATE_SLEEPING: { + case PhysicsServer3D::BODY_STATE_SLEEPING: { //? - if (mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC) + if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) break; bool do_sleep = p_variant; if (do_sleep) { @@ -352,30 +352,30 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant &p_varian set_active(true); } } break; - case PhysicsServer::BODY_STATE_CAN_SLEEP: { + case PhysicsServer3D::BODY_STATE_CAN_SLEEP: { can_sleep = p_variant; - if (mode == PhysicsServer::BODY_MODE_RIGID && !active && !can_sleep) + if (mode == PhysicsServer3D::BODY_MODE_RIGID && !active && !can_sleep) set_active(true); } break; } } -Variant BodySW::get_state(PhysicsServer::BodyState p_state) const { +Variant Body3DSW::get_state(PhysicsServer3D::BodyState p_state) const { switch (p_state) { - case PhysicsServer::BODY_STATE_TRANSFORM: { + case PhysicsServer3D::BODY_STATE_TRANSFORM: { return get_transform(); } break; - case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: { + case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: { return linear_velocity; } break; - case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: { + case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: { return angular_velocity; } break; - case PhysicsServer::BODY_STATE_SLEEPING: { + case PhysicsServer3D::BODY_STATE_SLEEPING: { return !is_active(); } break; - case PhysicsServer::BODY_STATE_CAN_SLEEP: { + case PhysicsServer3D::BODY_STATE_CAN_SLEEP: { return can_sleep; } break; } @@ -383,7 +383,7 @@ Variant BodySW::get_state(PhysicsServer::BodyState p_state) const { return Variant(); } -void BodySW::set_space(SpaceSW *p_space) { +void Body3DSW::set_space(Space3DSW *p_space) { if (get_space()) { @@ -414,7 +414,7 @@ void BodySW::set_space(SpaceSW *p_space) { first_integration = true; } -void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) { +void Body3DSW::_compute_area_gravity_and_dampenings(const Area3DSW *p_area) { if (p_area->is_gravity_point()) { if (p_area->get_gravity_distance_scale() > 0) { @@ -431,7 +431,7 @@ void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) { area_angular_damp += p_area->get_angular_damp(); } -void BodySW::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) { +void Body3DSW::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) { if (lock) { locked_axis |= p_axis; } else { @@ -439,16 +439,16 @@ void BodySW::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) { } } -bool BodySW::is_axis_locked(PhysicsServer::BodyAxis p_axis) const { +bool Body3DSW::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const { return locked_axis & p_axis; } -void BodySW::integrate_forces(real_t p_step) { +void Body3DSW::integrate_forces(real_t p_step) { - if (mode == PhysicsServer::BODY_MODE_STATIC) + if (mode == PhysicsServer3D::BODY_MODE_STATIC) return; - AreaSW *def_area = get_space()->get_default_area(); + Area3DSW *def_area = get_space()->get_default_area(); // AreaSW *damp_area = def_area; ERR_FAIL_COND(!def_area); @@ -463,20 +463,20 @@ void BodySW::integrate_forces(real_t p_step) { const AreaCMP *aa = &areas[0]; // damp_area = aa[ac-1].area; for (int i = ac - 1; i >= 0 && !stopped; i--) { - PhysicsServer::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); + PhysicsServer3D::AreaSpaceOverrideMode mode = aa[i].area->get_space_override_mode(); switch (mode) { - case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE: - case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { + case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: { _compute_area_gravity_and_dampenings(aa[i].area); - stopped = mode == PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; + stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE; } break; - case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE: - case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { + case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: { gravity = Vector3(0, 0, 0); area_angular_damp = 0; area_linear_damp = 0; _compute_area_gravity_and_dampenings(aa[i].area); - stopped = mode == PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE; + stopped = mode == PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE; } break; default: { } @@ -508,7 +508,7 @@ void BodySW::integrate_forces(real_t p_step) { Vector3 motion; bool do_motion = false; - if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) { //compute motion, angular and etc. velocities from prev transform linear_velocity = (new_transform.origin - get_transform().origin) / p_step; @@ -569,13 +569,13 @@ void BodySW::integrate_forces(real_t p_step) { _update_shapes_with_motion(motion); } - def_area = NULL; // clear the area, so it is set in the next frame + def_area = nullptr; // clear the area, so it is set in the next frame contact_count = 0; } -void BodySW::integrate_velocities(real_t p_step) { +void Body3DSW::integrate_velocities(real_t p_step) { - if (mode == PhysicsServer::BODY_MODE_STATIC) + if (mode == PhysicsServer3D::BODY_MODE_STATIC) return; if (fi_callback) @@ -583,7 +583,7 @@ void BodySW::integrate_velocities(real_t p_step) { //apply axis lock linear for (int i = 0; i < 3; i++) { - if (is_axis_locked((PhysicsServer::BodyAxis)(1 << i))) { + if (is_axis_locked((PhysicsServer3D::BodyAxis)(1 << i))) { linear_velocity[i] = 0; biased_linear_velocity[i] = 0; new_transform.origin[i] = get_transform().origin[i]; @@ -591,13 +591,13 @@ void BodySW::integrate_velocities(real_t p_step) { } //apply axis lock angular for (int i = 0; i < 3; i++) { - if (is_axis_locked((PhysicsServer::BodyAxis)(1 << (i + 3)))) { + if (is_axis_locked((PhysicsServer3D::BodyAxis)(1 << (i + 3)))) { angular_velocity[i] = 0; biased_angular_velocity[i] = 0; } } - if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) { _set_transform(new_transform, false); _set_inv_transform(new_transform.affine_inverse()); @@ -675,20 +675,20 @@ void BodySW::simulate_motion(const Transform& p_xform,real_t p_step) { } */ -void BodySW::wakeup_neighbours() { +void Body3DSW::wakeup_neighbours() { - for (Map<ConstraintSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) { + for (Map<Constraint3DSW *, int>::Element *E = constraint_map.front(); E; E = E->next()) { - const ConstraintSW *c = E->key(); - BodySW **n = c->get_body_ptr(); + const Constraint3DSW *c = E->key(); + Body3DSW **n = c->get_body_ptr(); int bc = c->get_body_count(); for (int i = 0; i < bc; i++) { if (i == E->get()) continue; - BodySW *b = n[i]; - if (b->mode != PhysicsServer::BODY_MODE_RIGID) + Body3DSW *b = n[i]; + if (b->mode != PhysicsServer3D::BODY_MODE_RIGID) continue; if (!b->is_active()) @@ -697,11 +697,11 @@ void BodySW::wakeup_neighbours() { } } -void BodySW::call_queries() { +void Body3DSW::call_queries() { if (fi_callback) { - PhysicsDirectBodyStateSW *dbs = PhysicsDirectBodyStateSW::singleton; + PhysicsDirectBodyState3DSW *dbs = PhysicsDirectBodyState3DSW::singleton; dbs->body = this; Variant v = dbs; @@ -720,11 +720,11 @@ void BodySW::call_queries() { } } -bool BodySW::sleep_test(real_t p_step) { +bool Body3DSW::sleep_test(real_t p_step) { - if (mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC) + if (mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) return true; // - else if (mode == PhysicsServer::BODY_MODE_CHARACTER) + else if (mode == PhysicsServer3D::BODY_MODE_CHARACTER) return !active; // characters don't sleep unless asked to sleep else if (!can_sleep) return false; @@ -741,12 +741,12 @@ bool BodySW::sleep_test(real_t p_step) { } } -void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) { +void Body3DSW::set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata) { if (fi_callback) { memdelete(fi_callback); - fi_callback = NULL; + fi_callback = nullptr; } if (p_id.is_valid()) { @@ -758,18 +758,18 @@ void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_m } } -void BodySW::set_kinematic_margin(real_t p_margin) { +void Body3DSW::set_kinematic_margin(real_t p_margin) { kinematic_safe_margin = p_margin; } -BodySW::BodySW() : - CollisionObjectSW(TYPE_BODY), +Body3DSW::Body3DSW() : + CollisionObject3DSW(TYPE_BODY), locked_axis(0), active_list(this), inertia_update_list(this), direct_state_query_list(this) { - mode = PhysicsServer::BODY_MODE_RIGID; + mode = PhysicsServer3D::BODY_MODE_RIGID; active = true; mass = 1; @@ -781,8 +781,8 @@ BodySW::BodySW() : omit_force_integration = false; //applied_torque=0; island_step = 0; - island_next = NULL; - island_list_next = NULL; + island_next = nullptr; + island_list_next = nullptr; first_time_kinematic = false; first_integration = false; _set_static(false); @@ -797,18 +797,18 @@ BodySW::BodySW() : still_time = 0; continuous_cd = false; can_sleep = true; - fi_callback = NULL; + fi_callback = nullptr; } -BodySW::~BodySW() { +Body3DSW::~Body3DSW() { if (fi_callback) memdelete(fi_callback); } -PhysicsDirectBodyStateSW *PhysicsDirectBodyStateSW::singleton = NULL; +PhysicsDirectBodyState3DSW *PhysicsDirectBodyState3DSW::singleton = nullptr; -PhysicsDirectSpaceState *PhysicsDirectBodyStateSW::get_space_state() { +PhysicsDirectSpaceState3D *PhysicsDirectBodyState3DSW::get_space_state() { return body->get_space()->get_direct_state(); } diff --git a/servers/physics/body_sw.h b/servers/physics_3d/body_3d_sw.h index d712b09878..b553cf0670 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics_3d/body_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* body_sw.h */ +/* body_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,15 +31,15 @@ #ifndef BODY_SW_H #define BODY_SW_H -#include "area_sw.h" -#include "collision_object_sw.h" +#include "area_3d_sw.h" +#include "collision_object_3d_sw.h" #include "core/vset.h" -class ConstraintSW; +class Constraint3DSW; -class BodySW : public CollisionObjectSW { +class Body3DSW : public CollisionObject3DSW { - PhysicsServer::BodyMode mode; + PhysicsServer3D::BodyMode mode; Vector3 linear_velocity; Vector3 angular_velocity; @@ -79,9 +79,9 @@ class BodySW : public CollisionObjectSW { real_t area_angular_damp; real_t area_linear_damp; - SelfList<BodySW> active_list; - SelfList<BodySW> inertia_update_list; - SelfList<BodySW> direct_state_query_list; + SelfList<Body3DSW> active_list; + SelfList<Body3DSW> inertia_update_list; + SelfList<Body3DSW> direct_state_query_list; VSet<RID> exceptions; bool omit_force_integration; @@ -96,16 +96,16 @@ class BodySW : public CollisionObjectSW { virtual void _shapes_changed(); Transform new_transform; - Map<ConstraintSW *, int> constraint_map; + Map<Constraint3DSW *, int> constraint_map; struct AreaCMP { - AreaSW *area; + Area3DSW *area; int refCount; _FORCE_INLINE_ bool operator==(const AreaCMP &p_cmp) const { return area->get_self() == p_cmp.area->get_self(); } _FORCE_INLINE_ bool operator<(const AreaCMP &p_cmp) const { return area->get_priority() < p_cmp.area->get_priority(); } _FORCE_INLINE_ AreaCMP() {} - _FORCE_INLINE_ AreaCMP(AreaSW *p_area) { + _FORCE_INLINE_ AreaCMP(Area3DSW *p_area) { area = p_area; refCount = 1; } @@ -139,14 +139,14 @@ class BodySW : public CollisionObjectSW { ForceIntegrationCallback *fi_callback; uint64_t island_step; - BodySW *island_next; - BodySW *island_list_next; + Body3DSW *island_next; + Body3DSW *island_list_next; - _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const AreaSW *p_area); + _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const Area3DSW *p_area); _FORCE_INLINE_ void _update_transform_dependant(); - friend class PhysicsDirectBodyStateSW; // i give up, too many functions to expose + friend class PhysicsDirectBodyState3DSW; // i give up, too many functions to expose public: void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant()); @@ -154,7 +154,7 @@ public: void set_kinematic_margin(real_t p_margin); _FORCE_INLINE_ real_t get_kinematic_margin() { return kinematic_safe_margin; } - _FORCE_INLINE_ void add_area(AreaSW *p_area) { + _FORCE_INLINE_ void add_area(Area3DSW *p_area) { int index = areas.find(AreaCMP(p_area)); if (index > -1) { areas.write[index].refCount += 1; @@ -163,7 +163,7 @@ public: } } - _FORCE_INLINE_ void remove_area(AreaSW *p_area) { + _FORCE_INLINE_ void remove_area(Area3DSW *p_area) { int index = areas.find(AreaCMP(p_area)); if (index > -1) { areas.write[index].refCount -= 1; @@ -175,7 +175,7 @@ public: _FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count = 0; - if (mode == PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true); + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC && p_size) set_active(true); } _FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); } @@ -190,15 +190,15 @@ public: _FORCE_INLINE_ uint64_t get_island_step() const { return island_step; } _FORCE_INLINE_ void set_island_step(uint64_t p_step) { island_step = p_step; } - _FORCE_INLINE_ BodySW *get_island_next() const { return island_next; } - _FORCE_INLINE_ void set_island_next(BodySW *p_next) { island_next = p_next; } + _FORCE_INLINE_ Body3DSW *get_island_next() const { return island_next; } + _FORCE_INLINE_ void set_island_next(Body3DSW *p_next) { island_next = p_next; } - _FORCE_INLINE_ BodySW *get_island_list_next() const { return island_list_next; } - _FORCE_INLINE_ void set_island_list_next(BodySW *p_next) { island_list_next = p_next; } + _FORCE_INLINE_ Body3DSW *get_island_list_next() const { return island_list_next; } + _FORCE_INLINE_ void set_island_list_next(Body3DSW *p_next) { island_list_next = p_next; } - _FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; } - _FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraint_map.erase(p_constraint); } - const Map<ConstraintSW *, int> &get_constraint_map() const { return constraint_map; } + _FORCE_INLINE_ void add_constraint(Constraint3DSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; } + _FORCE_INLINE_ void remove_constraint(Constraint3DSW *p_constraint) { constraint_map.erase(p_constraint); } + const Map<Constraint3DSW *, int> &get_constraint_map() const { return constraint_map; } _FORCE_INLINE_ void clear_constraint_map() { constraint_map.clear(); } _FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration = p_omit_force_integration; } @@ -268,19 +268,19 @@ public: _FORCE_INLINE_ bool is_active() const { return active; } _FORCE_INLINE_ void wakeup() { - if ((!get_space()) || mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC) + if ((!get_space()) || mode == PhysicsServer3D::BODY_MODE_STATIC || mode == PhysicsServer3D::BODY_MODE_KINEMATIC) return; set_active(true); } - void set_param(PhysicsServer::BodyParameter p_param, real_t); - real_t get_param(PhysicsServer::BodyParameter p_param) const; + void set_param(PhysicsServer3D::BodyParameter p_param, real_t); + real_t get_param(PhysicsServer3D::BodyParameter p_param) const; - void set_mode(PhysicsServer::BodyMode p_mode); - PhysicsServer::BodyMode get_mode() const; + void set_mode(PhysicsServer3D::BodyMode p_mode); + PhysicsServer3D::BodyMode get_mode() const; - void set_state(PhysicsServer::BodyState p_state, const Variant &p_variant); - Variant get_state(PhysicsServer::BodyState p_state) const; + void set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant); + Variant get_state(PhysicsServer3D::BodyState p_state) const; void set_applied_force(const Vector3 &p_force) { applied_force = p_force; } Vector3 get_applied_force() const { return applied_force; } @@ -291,7 +291,7 @@ public: _FORCE_INLINE_ void set_continuous_collision_detection(bool p_enable) { continuous_cd = p_enable; } _FORCE_INLINE_ bool is_continuous_collision_detection_enabled() const { return continuous_cd; } - void set_space(SpaceSW *p_space); + void set_space(Space3DSW *p_space); void update_inertias(); @@ -302,8 +302,8 @@ public: _FORCE_INLINE_ Vector3 get_gravity() const { return gravity; } _FORCE_INLINE_ real_t get_bounce() const { return bounce; } - void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock); - bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const; + void set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock); + bool is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const; void integrate_forces(real_t p_step); void integrate_velocities(real_t p_step); @@ -335,13 +335,13 @@ public: bool sleep_test(real_t p_step); - BodySW(); - ~BodySW(); + Body3DSW(); + ~Body3DSW(); }; //add contact inline -void BodySW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos) { +void Body3DSW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos) { int c_max = contacts.size(); @@ -385,13 +385,13 @@ void BodySW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_norm c[idx].collider_velocity_at_pos = p_collider_velocity_at_pos; } -class PhysicsDirectBodyStateSW : public PhysicsDirectBodyState { +class PhysicsDirectBodyState3DSW : public PhysicsDirectBodyState3D { - GDCLASS(PhysicsDirectBodyStateSW, PhysicsDirectBodyState); + GDCLASS(PhysicsDirectBodyState3DSW, PhysicsDirectBodyState3D); public: - static PhysicsDirectBodyStateSW *singleton; - BodySW *body; + static PhysicsDirectBodyState3DSW *singleton; + Body3DSW *body; real_t step; virtual Vector3 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area @@ -411,7 +411,7 @@ public: virtual void set_angular_velocity(const Vector3 &p_velocity) { body->set_angular_velocity(p_velocity); } virtual Vector3 get_angular_velocity() const { return body->get_angular_velocity(); } - virtual void set_transform(const Transform &p_transform) { body->set_state(PhysicsServer::BODY_STATE_TRANSFORM, p_transform); } + virtual void set_transform(const Transform &p_transform) { body->set_state(PhysicsServer3D::BODY_STATE_TRANSFORM, p_transform); } virtual Transform get_transform() const { return body->get_transform(); } virtual void add_central_force(const Vector3 &p_force) { body->add_central_force(p_force); } @@ -463,12 +463,12 @@ public: return body->contacts[p_contact_idx].collider_velocity_at_pos; } - virtual PhysicsDirectSpaceState *get_space_state(); + virtual PhysicsDirectSpaceState3D *get_space_state(); virtual real_t get_step() const { return step; } - PhysicsDirectBodyStateSW() { + PhysicsDirectBodyState3DSW() { singleton = this; - body = NULL; + body = nullptr; } }; diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics_3d/body_pair_3d_sw.cpp index 31fc1b07d9..245fb3449c 100644 --- a/servers/physics/body_pair_sw.cpp +++ b/servers/physics_3d/body_pair_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* body_pair_sw.cpp */ +/* body_pair_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,11 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "body_pair_sw.h" +#include "body_pair_3d_sw.h" -#include "collision_solver_sw.h" +#include "collision_solver_3d_sw.h" #include "core/os/os.h" -#include "space_sw.h" +#include "space_3d_sw.h" /* #define NO_ACCUMULATE_IMPULSES @@ -49,13 +49,13 @@ #define MIN_VELOCITY 0.0001 #define MAX_BIAS_ROTATION (Math_PI / 8) -void BodyPairSW::_contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) { +void BodyPair3DSW::_contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) { - BodyPairSW *pair = (BodyPairSW *)p_userdata; + BodyPair3DSW *pair = (BodyPair3DSW *)p_userdata; pair->contact_added_callback(p_point_A, p_point_B); } -void BodyPairSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B) { +void BodyPair3DSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B) { // check if we already have the contact @@ -141,7 +141,7 @@ void BodyPairSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 } } -void BodyPairSW::validate_contacts() { +void BodyPair3DSW::validate_contacts() { //make sure to erase contacts that are no longer valid @@ -169,7 +169,7 @@ void BodyPairSW::validate_contacts() { } } -bool BodyPairSW::_test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Transform &p_xform_A, BodySW *p_B, int p_shape_B, const Transform &p_xform_B) { +bool BodyPair3DSW::_test_ccd(real_t p_step, Body3DSW *p_A, int p_shape_A, const Transform &p_xform_A, Body3DSW *p_B, int p_shape_B, const Transform &p_xform_B) { Vector3 motion = p_A->get_linear_velocity() * p_step; real_t mlen = motion.length(); @@ -211,18 +211,18 @@ bool BodyPairSW::_test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Tran return true; } -real_t combine_bounce(BodySW *A, BodySW *B) { +real_t combine_bounce(Body3DSW *A, Body3DSW *B) { return CLAMP(A->get_bounce() + B->get_bounce(), 0, 1); } -real_t combine_friction(BodySW *A, BodySW *B) { +real_t combine_friction(Body3DSW *A, Body3DSW *B) { return ABS(MIN(A->get_friction(), B->get_friction())); } -bool BodyPairSW::setup(real_t p_step) { +bool BodyPair3DSW::setup(real_t p_step) { //cannot collide - if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) { + if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC && A->get_max_contacts_reported() == 0 && B->get_max_contacts_reported() == 0)) { collided = false; return false; } @@ -244,21 +244,21 @@ bool BodyPairSW::setup(real_t p_step) { xform_Bu.origin -= offset_A; Transform xform_B = xform_Bu * B->get_shape_transform(shape_B); - ShapeSW *shape_A_ptr = A->get_shape(shape_A); - ShapeSW *shape_B_ptr = B->get_shape(shape_B); + Shape3DSW *shape_A_ptr = A->get_shape(shape_A); + Shape3DSW *shape_B_ptr = B->get_shape(shape_B); - bool collided = CollisionSolverSW::solve_static(shape_A_ptr, xform_A, shape_B_ptr, xform_B, _contact_added_callback, this, &sep_axis); + bool collided = CollisionSolver3DSW::solve_static(shape_A_ptr, xform_A, shape_B_ptr, xform_B, _contact_added_callback, this, &sep_axis); this->collided = collided; if (!collided) { //test ccd (currently just a raycast) - if (A->is_continuous_collision_detection_enabled() && A->get_mode() > PhysicsServer::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC) { + if (A->is_continuous_collision_detection_enabled() && A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC && B->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC) { _test_ccd(p_step, A, shape_A, xform_A, B, shape_B, xform_B); } - if (B->is_continuous_collision_detection_enabled() && B->get_mode() > PhysicsServer::BODY_MODE_KINEMATIC && A->get_mode() <= PhysicsServer::BODY_MODE_KINEMATIC) { + if (B->is_continuous_collision_detection_enabled() && B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC && A->get_mode() <= PhysicsServer3D::BODY_MODE_KINEMATIC) { _test_ccd(p_step, B, shape_B, xform_B, A, shape_A, xform_A); } @@ -353,7 +353,7 @@ bool BodyPairSW::setup(real_t p_step) { return true; } -void BodyPairSW::solve(real_t p_step) { +void BodyPair3DSW::solve(real_t p_step) { if (!collided) return; @@ -474,8 +474,8 @@ void BodyPairSW::solve(real_t p_step) { } } -BodyPairSW::BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B) : - ConstraintSW(_arr, 2) { +BodyPair3DSW::BodyPair3DSW(Body3DSW *p_A, int p_shape_A, Body3DSW *p_B, int p_shape_B) : + Constraint3DSW(_arr, 2) { A = p_A; B = p_B; @@ -488,7 +488,7 @@ BodyPairSW::BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B) : collided = false; } -BodyPairSW::~BodyPairSW() { +BodyPair3DSW::~BodyPair3DSW() { A->remove_constraint(this); B->remove_constraint(this); diff --git a/servers/physics/body_pair_sw.h b/servers/physics_3d/body_pair_3d_sw.h index 235aab23b5..7f4afb9dca 100644 --- a/servers/physics/body_pair_sw.h +++ b/servers/physics_3d/body_pair_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* body_pair_sw.h */ +/* body_pair_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,10 +31,10 @@ #ifndef BODY_PAIR_SW_H #define BODY_PAIR_SW_H -#include "body_sw.h" -#include "constraint_sw.h" +#include "body_3d_sw.h" +#include "constraint_3d_sw.h" -class BodyPairSW : public ConstraintSW { +class BodyPair3DSW : public Constraint3DSW { enum { MAX_CONTACTS = 4 @@ -42,11 +42,11 @@ class BodyPairSW : public ConstraintSW { union { struct { - BodySW *A; - BodySW *B; + Body3DSW *A; + Body3DSW *B; }; - BodySW *_arr[2]; + Body3DSW *_arr[2]; }; int shape_A; @@ -82,16 +82,16 @@ class BodyPairSW : public ConstraintSW { void contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B); void validate_contacts(); - bool _test_ccd(real_t p_step, BodySW *p_A, int p_shape_A, const Transform &p_xform_A, BodySW *p_B, int p_shape_B, const Transform &p_xform_B); + bool _test_ccd(real_t p_step, Body3DSW *p_A, int p_shape_A, const Transform &p_xform_A, Body3DSW *p_B, int p_shape_B, const Transform &p_xform_B); - SpaceSW *space; + Space3DSW *space; public: bool setup(real_t p_step); void solve(real_t p_step); - BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B); - ~BodyPairSW(); + BodyPair3DSW(Body3DSW *p_A, int p_shape_A, Body3DSW *p_B, int p_shape_B); + ~BodyPair3DSW(); }; #endif // BODY_PAIR__SW_H diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics_3d/broad_phase_3d_basic.cpp index f49bf9d4cc..08ea219869 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics_3d/broad_phase_3d_basic.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* broad_phase_basic.cpp */ +/* broad_phase_3d_basic.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "broad_phase_basic.h" +#include "broad_phase_3d_basic.h" #include "core/list.h" #include "core/print_string.h" -BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) { +BroadPhase3DSW::ID BroadPhase3DBasic::create(CollisionObject3DSW *p_object, int p_subindex) { - ERR_FAIL_COND_V(p_object == NULL, 0); + ERR_FAIL_COND_V(p_object == nullptr, 0); current++; @@ -47,19 +47,19 @@ BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subi return current; } -void BroadPhaseBasic::move(ID p_id, const AABB &p_aabb) { +void BroadPhase3DBasic::move(ID p_id, const AABB &p_aabb) { Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND(!E); E->get().aabb = p_aabb; } -void BroadPhaseBasic::set_static(ID p_id, bool p_static) { +void BroadPhase3DBasic::set_static(ID p_id, bool p_static) { Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND(!E); E->get()._static = p_static; } -void BroadPhaseBasic::remove(ID p_id) { +void BroadPhase3DBasic::remove(ID p_id) { Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND(!E); @@ -85,26 +85,26 @@ void BroadPhaseBasic::remove(ID p_id) { element_map.erase(E); } -CollisionObjectSW *BroadPhaseBasic::get_object(ID p_id) const { +CollisionObject3DSW *BroadPhase3DBasic::get_object(ID p_id) const { const Map<ID, Element>::Element *E = element_map.find(p_id); - ERR_FAIL_COND_V(!E, NULL); + ERR_FAIL_COND_V(!E, nullptr); return E->get().owner; } -bool BroadPhaseBasic::is_static(ID p_id) const { +bool BroadPhase3DBasic::is_static(ID p_id) const { const Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND_V(!E, false); return E->get()._static; } -int BroadPhaseBasic::get_subindex(ID p_id) const { +int BroadPhase3DBasic::get_subindex(ID p_id) const { const Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND_V(!E, -1); return E->get().subindex; } -int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhase3DBasic::cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) { int rc = 0; @@ -124,7 +124,7 @@ int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_re return rc; } -int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhase3DBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) { int rc = 0; @@ -143,7 +143,7 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co return rc; } -int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhase3DBasic::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) { int rc = 0; @@ -163,18 +163,18 @@ int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results return rc; } -void BroadPhaseBasic::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) { +void BroadPhase3DBasic::set_pair_callback(PairCallback p_pair_callback, void *p_userdata) { pair_userdata = p_userdata; pair_callback = p_pair_callback; } -void BroadPhaseBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) { +void BroadPhase3DBasic::set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) { unpair_userdata = p_userdata; unpair_callback = p_unpair_callback; } -void BroadPhaseBasic::update() { +void BroadPhase3DBasic::update() { // recompute pairs for (Map<ID, Element>::Element *I = element_map.front(); I; I = I->next()) { @@ -201,7 +201,7 @@ void BroadPhaseBasic::update() { if (pair_ok && !E) { - void *data = NULL; + void *data = nullptr; if (pair_callback) data = pair_callback(elem_A->owner, elem_A->subindex, elem_B->owner, elem_B->subindex, unpair_userdata); pair_map.insert(key, data); @@ -210,16 +210,16 @@ void BroadPhaseBasic::update() { } } -BroadPhaseSW *BroadPhaseBasic::_create() { +BroadPhase3DSW *BroadPhase3DBasic::_create() { - return memnew(BroadPhaseBasic); + return memnew(BroadPhase3DBasic); } -BroadPhaseBasic::BroadPhaseBasic() { +BroadPhase3DBasic::BroadPhase3DBasic() { current = 1; - unpair_callback = NULL; - unpair_userdata = NULL; - pair_callback = NULL; - pair_userdata = NULL; + unpair_callback = nullptr; + unpair_userdata = nullptr; + pair_callback = nullptr; + pair_userdata = nullptr; } diff --git a/servers/physics/broad_phase_basic.h b/servers/physics_3d/broad_phase_3d_basic.h index 424889d8aa..563dda6931 100644 --- a/servers/physics/broad_phase_basic.h +++ b/servers/physics_3d/broad_phase_3d_basic.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* broad_phase_basic.h */ +/* broad_phase_3d_basic.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,14 +31,14 @@ #ifndef BROAD_PHASE_BASIC_H #define BROAD_PHASE_BASIC_H -#include "broad_phase_sw.h" +#include "broad_phase_3d_sw.h" #include "core/map.h" -class BroadPhaseBasic : public BroadPhaseSW { +class BroadPhase3DBasic : public BroadPhase3DSW { struct Element { - CollisionObjectSW *owner; + CollisionObject3DSW *owner; bool _static; AABB aabb; int subindex; @@ -83,26 +83,26 @@ class BroadPhaseBasic : public BroadPhaseSW { public: // 0 is an invalid ID - virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0); + virtual ID create(CollisionObject3DSW *p_object, int p_subindex = 0); virtual void move(ID p_id, const AABB &p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); - virtual CollisionObjectSW *get_object(ID p_id) const; + virtual CollisionObject3DSW *get_object(ID p_id) const; virtual bool is_static(ID p_id) const; virtual int get_subindex(ID p_id) const; - virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr); + virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr); + virtual int cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); virtual void update(); - static BroadPhaseSW *_create(); - BroadPhaseBasic(); + static BroadPhase3DSW *_create(); + BroadPhase3DBasic(); }; #endif // BROAD_PHASE_BASIC_H diff --git a/servers/physics/broad_phase_sw.cpp b/servers/physics_3d/broad_phase_3d_sw.cpp index a6fc253b1b..1a20fdd0cb 100644 --- a/servers/physics/broad_phase_sw.cpp +++ b/servers/physics_3d/broad_phase_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* broad_phase_sw.cpp */ +/* broad_phase_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,9 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "broad_phase_sw.h" +#include "broad_phase_3d_sw.h" -BroadPhaseSW::CreateFunction BroadPhaseSW::create_func = NULL; +BroadPhase3DSW::CreateFunction BroadPhase3DSW::create_func = nullptr; -BroadPhaseSW::~BroadPhaseSW() { +BroadPhase3DSW::~BroadPhase3DSW() { } diff --git a/servers/physics/broad_phase_sw.h b/servers/physics_3d/broad_phase_3d_sw.h index e69a2d24ed..5950489619 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics_3d/broad_phase_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* broad_phase_sw.h */ +/* broad_phase_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -34,40 +34,40 @@ #include "core/math/aabb.h" #include "core/math/math_funcs.h" -class CollisionObjectSW; +class CollisionObject3DSW; -class BroadPhaseSW { +class BroadPhase3DSW { public: - typedef BroadPhaseSW *(*CreateFunction)(); + typedef BroadPhase3DSW *(*CreateFunction)(); static CreateFunction create_func; typedef uint32_t ID; - typedef void *(*PairCallback)(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_userdata); - typedef void (*UnpairCallback)(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_userdata); + typedef void *(*PairCallback)(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_userdata); + typedef void (*UnpairCallback)(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_userdata); // 0 is an invalid ID - virtual ID create(CollisionObjectSW *p_object_, int p_subindex = 0) = 0; + virtual ID create(CollisionObject3DSW *p_object_, int p_subindex = 0) = 0; virtual void move(ID p_id, const AABB &p_aabb) = 0; virtual void set_static(ID p_id, bool p_static) = 0; virtual void remove(ID p_id) = 0; - virtual CollisionObjectSW *get_object(ID p_id) const = 0; + virtual CollisionObject3DSW *get_object(ID p_id) const = 0; virtual bool is_static(ID p_id) const = 0; virtual int get_subindex(ID p_id) const = 0; - virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; - virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; - virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; + virtual int cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0; + virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0; + virtual int cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr) = 0; virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0; virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0; virtual void update() = 0; - virtual ~BroadPhaseSW(); + virtual ~BroadPhase3DSW(); }; #endif // BROAD_PHASE__SW_H diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics_3d/broad_phase_octree.cpp index a9aa662abf..264ab21e1e 100644 --- a/servers/physics/broad_phase_octree.cpp +++ b/servers/physics_3d/broad_phase_octree.cpp @@ -29,9 +29,9 @@ /*************************************************************************/ #include "broad_phase_octree.h" -#include "collision_object_sw.h" +#include "collision_object_3d_sw.h" -BroadPhaseSW::ID BroadPhaseOctree::create(CollisionObjectSW *p_object, int p_subindex) { +BroadPhase3DSW::ID BroadPhaseOctree::create(CollisionObject3DSW *p_object, int p_subindex) { ID oid = octree.create(p_object, AABB(), p_subindex, false, 1 << p_object->get_type(), 0); return oid; @@ -44,7 +44,7 @@ void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) { void BroadPhaseOctree::set_static(ID p_id, bool p_static) { - CollisionObjectSW *it = octree.get(p_id); + CollisionObject3DSW *it = octree.get(p_id); octree.set_pairable(p_id, !p_static, 1 << it->get_type(), p_static ? 0 : 0xFFFFF); //pair everything, don't care 1? } void BroadPhaseOctree::remove(ID p_id) { @@ -52,10 +52,10 @@ void BroadPhaseOctree::remove(ID p_id) { octree.erase(p_id); } -CollisionObjectSW *BroadPhaseOctree::get_object(ID p_id) const { +CollisionObject3DSW *BroadPhaseOctree::get_object(ID p_id) const { - CollisionObjectSW *it = octree.get(p_id); - ERR_FAIL_COND_V(!it, NULL); + CollisionObject3DSW *it = octree.get(p_id); + ERR_FAIL_COND_V(!it, nullptr); return it; } bool BroadPhaseOctree::is_static(ID p_id) const { @@ -67,31 +67,31 @@ int BroadPhaseOctree::get_subindex(ID p_id) const { return octree.get_subindex(p_id); } -int BroadPhaseOctree::cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseOctree::cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) { return octree.cull_point(p_point, p_results, p_max_results, p_result_indices); } -int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) { return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices); } -int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices) { return octree.cull_aabb(p_aabb, p_results, p_max_results, p_result_indices); } -void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, CollisionObjectSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObjectSW *p_object_B, int subindex_B) { +void *BroadPhaseOctree::_pair_callback(void *self, OctreeElementID p_A, CollisionObject3DSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObject3DSW *p_object_B, int subindex_B) { BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self); if (!bpo->pair_callback) - return NULL; + return nullptr; return bpo->pair_callback(p_object_A, subindex_A, p_object_B, subindex_B, bpo->pair_userdata); } -void BroadPhaseOctree::_unpair_callback(void *self, OctreeElementID p_A, CollisionObjectSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObjectSW *p_object_B, int subindex_B, void *pairdata) { +void BroadPhaseOctree::_unpair_callback(void *self, OctreeElementID p_A, CollisionObject3DSW *p_object_A, int subindex_A, OctreeElementID p_B, CollisionObject3DSW *p_object_B, int subindex_B, void *pairdata) { BroadPhaseOctree *bpo = (BroadPhaseOctree *)(self); if (!bpo->unpair_callback) @@ -115,7 +115,7 @@ void BroadPhaseOctree::update() { // does.. not? } -BroadPhaseSW *BroadPhaseOctree::_create() { +BroadPhase3DSW *BroadPhaseOctree::_create() { return memnew(BroadPhaseOctree); } @@ -123,7 +123,7 @@ BroadPhaseSW *BroadPhaseOctree::_create() { BroadPhaseOctree::BroadPhaseOctree() { octree.set_pair_callback(_pair_callback, this); octree.set_unpair_callback(_unpair_callback, this); - pair_callback = NULL; - pair_userdata = NULL; - unpair_userdata = NULL; + pair_callback = nullptr; + pair_userdata = nullptr; + unpair_userdata = nullptr; } diff --git a/servers/physics/broad_phase_octree.h b/servers/physics_3d/broad_phase_octree.h index e2a1d82b69..0ad59d8b0c 100644 --- a/servers/physics/broad_phase_octree.h +++ b/servers/physics_3d/broad_phase_octree.h @@ -31,15 +31,15 @@ #ifndef BROAD_PHASE_OCTREE_H #define BROAD_PHASE_OCTREE_H -#include "broad_phase_sw.h" +#include "broad_phase_3d_sw.h" #include "core/math/octree.h" -class BroadPhaseOctree : public BroadPhaseSW { +class BroadPhaseOctree : public BroadPhase3DSW { - Octree<CollisionObjectSW, true> octree; + Octree<CollisionObject3DSW, true> octree; - static void *_pair_callback(void *, OctreeElementID, CollisionObjectSW *, int, OctreeElementID, CollisionObjectSW *, int); - static void _unpair_callback(void *, OctreeElementID, CollisionObjectSW *, int, OctreeElementID, CollisionObjectSW *, int, void *); + static void *_pair_callback(void *, OctreeElementID, CollisionObject3DSW *, int, OctreeElementID, CollisionObject3DSW *, int); + static void _unpair_callback(void *, OctreeElementID, CollisionObject3DSW *, int, OctreeElementID, CollisionObject3DSW *, int, void *); PairCallback pair_callback; void *pair_userdata; @@ -48,25 +48,25 @@ class BroadPhaseOctree : public BroadPhaseSW { public: // 0 is an invalid ID - virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0); + virtual ID create(CollisionObject3DSW *p_object, int p_subindex = 0); virtual void move(ID p_id, const AABB &p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); - virtual CollisionObjectSW *get_object(ID p_id) const; + virtual CollisionObject3DSW *get_object(ID p_id) const; virtual bool is_static(ID p_id) const; virtual int get_subindex(ID p_id) const; - virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_point(const Vector3 &p_point, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr); + virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr); + virtual int cull_aabb(const AABB &p_aabb, CollisionObject3DSW **p_results, int p_max_results, int *p_result_indices = nullptr); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); virtual void update(); - static BroadPhaseSW *_create(); + static BroadPhase3DSW *_create(); BroadPhaseOctree(); }; diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics_3d/collision_object_3d_sw.cpp index 3cabf75ab6..24715d211d 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics_3d/collision_object_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_object_sw.cpp */ +/* collision_object_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,11 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "collision_object_sw.h" -#include "servers/physics/physics_server_sw.h" -#include "space_sw.h" +#include "collision_object_3d_sw.h" +#include "servers/physics_3d/physics_server_3d_sw.h" +#include "space_3d_sw.h" -void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform, bool p_disabled) { +void CollisionObject3DSW::add_shape(Shape3DSW *p_shape, const Transform &p_transform, bool p_disabled) { Shape s; s.shape = p_shape; @@ -44,13 +44,13 @@ void CollisionObjectSW::add_shape(ShapeSW *p_shape, const Transform &p_transform p_shape->add_owner(this); if (!pending_shape_update_list.in_list()) { - PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); } //_update_shapes(); //_shapes_changed(); } -void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) { +void CollisionObject3DSW::set_shape(int p_index, Shape3DSW *p_shape) { ERR_FAIL_INDEX(p_index, shapes.size()); shapes[p_index].shape->remove_owner(this); @@ -58,32 +58,32 @@ void CollisionObjectSW::set_shape(int p_index, ShapeSW *p_shape) { p_shape->add_owner(this); if (!pending_shape_update_list.in_list()) { - PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); } //_update_shapes(); //_shapes_changed(); } -void CollisionObjectSW::set_shape_transform(int p_index, const Transform &p_transform) { +void CollisionObject3DSW::set_shape_transform(int p_index, const Transform &p_transform) { ERR_FAIL_INDEX(p_index, shapes.size()); shapes.write[p_index].xform = p_transform; shapes.write[p_index].xform_inv = p_transform.affine_inverse(); if (!pending_shape_update_list.in_list()) { - PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); } //_update_shapes(); //_shapes_changed(); } -void CollisionObjectSW::set_shape_as_disabled(int p_idx, bool p_enable) { +void CollisionObject3DSW::set_shape_as_disabled(int p_idx, bool p_enable) { shapes.write[p_idx].disabled = p_enable; if (!pending_shape_update_list.in_list()) { - PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); } } -void CollisionObjectSW::remove_shape(ShapeSW *p_shape) { +void CollisionObject3DSW::remove_shape(Shape3DSW *p_shape) { //remove a shape, all the times it appears for (int i = 0; i < shapes.size(); i++) { @@ -95,7 +95,7 @@ void CollisionObjectSW::remove_shape(ShapeSW *p_shape) { } } -void CollisionObjectSW::remove_shape(int p_index) { +void CollisionObject3DSW::remove_shape(int p_index) { //remove anything from shape to be erased to end, so subindices don't change ERR_FAIL_INDEX(p_index, shapes.size()); @@ -111,13 +111,13 @@ void CollisionObjectSW::remove_shape(int p_index) { shapes.remove(p_index); if (!pending_shape_update_list.in_list()) { - PhysicsServerSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); + PhysicsServer3DSW::singleton->pending_shape_update_list.add(&pending_shape_update_list); } //_update_shapes(); //_shapes_changed(); } -void CollisionObjectSW::_set_static(bool p_static) { +void CollisionObject3DSW::_set_static(bool p_static) { if (_static == p_static) return; _static = p_static; @@ -132,7 +132,7 @@ void CollisionObjectSW::_set_static(bool p_static) { } } -void CollisionObjectSW::_unregister_shapes() { +void CollisionObject3DSW::_unregister_shapes() { for (int i = 0; i < shapes.size(); i++) { @@ -144,7 +144,7 @@ void CollisionObjectSW::_unregister_shapes() { } } -void CollisionObjectSW::_update_shapes() { +void CollisionObject3DSW::_update_shapes() { if (!space) return; @@ -171,7 +171,7 @@ void CollisionObjectSW::_update_shapes() { } } -void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) { +void CollisionObject3DSW::_update_shapes_with_motion(const Vector3 &p_motion) { if (!space) return; @@ -195,7 +195,7 @@ void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) { } } -void CollisionObjectSW::_set_space(SpaceSW *p_space) { +void CollisionObject3DSW::_set_space(Space3DSW *p_space) { if (space) { @@ -220,18 +220,18 @@ void CollisionObjectSW::_set_space(SpaceSW *p_space) { } } -void CollisionObjectSW::_shape_changed() { +void CollisionObject3DSW::_shape_changed() { _update_shapes(); _shapes_changed(); } -CollisionObjectSW::CollisionObjectSW(Type p_type) : +CollisionObject3DSW::CollisionObject3DSW(Type p_type) : pending_shape_update_list(this) { _static = true; type = p_type; - space = NULL; + space = nullptr; collision_layer = 1; collision_mask = 1; diff --git a/servers/physics/collision_object_sw.h b/servers/physics_3d/collision_object_3d_sw.h index 7c0e66ff90..c5773d0c61 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics_3d/collision_object_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_object_sw.h */ +/* collision_object_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,10 +31,10 @@ #ifndef COLLISION_OBJECT_SW_H #define COLLISION_OBJECT_SW_H -#include "broad_phase_sw.h" +#include "broad_phase_3d_sw.h" #include "core/self_list.h" -#include "servers/physics_server.h" -#include "shape_sw.h" +#include "servers/physics_server_3d.h" +#include "shape_3d_sw.h" #ifdef DEBUG_ENABLED #define MAX_OBJECT_DISTANCE 3.1622776601683791e+18 @@ -42,9 +42,9 @@ #define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE * MAX_OBJECT_DISTANCE) #endif -class SpaceSW; +class Space3DSW; -class CollisionObjectSW : public ShapeOwnerSW { +class CollisionObject3DSW : public ShapeOwner3DSW { public: enum Type { TYPE_AREA, @@ -62,22 +62,22 @@ private: Transform xform; Transform xform_inv; - BroadPhaseSW::ID bpid; + BroadPhase3DSW::ID bpid; AABB aabb_cache; //for rayqueries real_t area_cache; - ShapeSW *shape; + Shape3DSW *shape; bool disabled; Shape() { disabled = false; } }; Vector<Shape> shapes; - SpaceSW *space; + Space3DSW *space; Transform transform; Transform inv_transform; bool _static; - SelfList<CollisionObjectSW> pending_shape_update_list; + SelfList<CollisionObject3DSW> pending_shape_update_list; void _update_shapes(); @@ -98,11 +98,11 @@ protected: void _set_static(bool p_static); virtual void _shapes_changed() = 0; - void _set_space(SpaceSW *p_space); + void _set_space(Space3DSW *p_space); bool ray_pickable; - CollisionObjectSW(Type p_type); + CollisionObject3DSW(Type p_type); public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } @@ -114,15 +114,15 @@ public: void _shape_changed(); _FORCE_INLINE_ Type get_type() const { return type; } - void add_shape(ShapeSW *p_shape, const Transform &p_transform = Transform(), bool p_disabled = false); - void set_shape(int p_index, ShapeSW *p_shape); + void add_shape(Shape3DSW *p_shape, const Transform &p_transform = Transform(), bool p_disabled = false); + void set_shape(int p_index, Shape3DSW *p_shape); void set_shape_transform(int p_index, const Transform &p_transform); _FORCE_INLINE_ int get_shape_count() const { return shapes.size(); } _FORCE_INLINE_ bool is_shape_disabled(int p_index) const { CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].disabled; } - _FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; } + _FORCE_INLINE_ Shape3DSW *get_shape(int p_index) const { return shapes[p_index].shape; } _FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; } _FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } _FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } @@ -130,7 +130,7 @@ public: _FORCE_INLINE_ Transform get_transform() const { return transform; } _FORCE_INLINE_ Transform get_inv_transform() const { return inv_transform; } - _FORCE_INLINE_ SpaceSW *get_space() const { return space; } + _FORCE_INLINE_ Space3DSW *get_space() const { return space; } _FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable = p_enable; } _FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; } @@ -147,18 +147,18 @@ public: _FORCE_INLINE_ void set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; } _FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; } - _FORCE_INLINE_ bool test_collision_mask(CollisionObjectSW *p_other) const { + _FORCE_INLINE_ bool test_collision_mask(CollisionObject3DSW *p_other) const { return collision_layer & p_other->collision_mask || p_other->collision_layer & collision_mask; } - void remove_shape(ShapeSW *p_shape); + void remove_shape(Shape3DSW *p_shape); void remove_shape(int p_index); - virtual void set_space(SpaceSW *p_space) = 0; + virtual void set_space(Space3DSW *p_space) = 0; _FORCE_INLINE_ bool is_static() const { return _static; } - virtual ~CollisionObjectSW() {} + virtual ~CollisionObject3DSW() {} }; #endif // COLLISION_OBJECT_SW_H diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics_3d/collision_solver_3d_sat.cpp index 0e0dfd3cf2..5096b080ab 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics_3d/collision_solver_3d_sat.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_solver_sat.cpp */ +/* collision_solver_3d_sat.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "collision_solver_sat.h" +#include "collision_solver_3d_sat.h" #include "core/math/geometry.h" #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.02 struct _CollectorCallback { - CollisionSolverSW::CallbackResult callback; + CollisionSolver3DSW::CallbackResult callback; void *userdata; bool swap; bool collided; @@ -241,13 +241,13 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po _generate_contacts_point_face, }, { - 0, + nullptr, _generate_contacts_edge_edge, _generate_contacts_face_face, }, { - 0, - 0, + nullptr, + nullptr, _generate_contacts_face_face, } }; @@ -426,15 +426,15 @@ public: /****** SAT TESTS *******/ -typedef void (*CollisionFunc)(const ShapeSW *, const Transform &, const ShapeSW *, const Transform &, _CollectorCallback *p_callback, real_t, real_t); +typedef void (*CollisionFunc)(const Shape3DSW *, const Transform &, const Shape3DSW *, const Transform &, _CollectorCallback *p_callback, real_t, real_t); template <bool withMargin> -static void _collision_sphere_sphere(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_sphere_sphere(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a); - const SphereShapeSW *sphere_B = static_cast<const SphereShapeSW *>(p_b); + const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a); + const SphereShape3DSW *sphere_B = static_cast<const SphereShape3DSW *>(p_b); - SeparatorAxisTest<SphereShapeSW, SphereShapeSW, withMargin> separator(sphere_A, p_transform_a, sphere_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<SphereShape3DSW, SphereShape3DSW, withMargin> separator(sphere_A, p_transform_a, sphere_B, p_transform_b, p_collector, p_margin_a, p_margin_b); // previous axis @@ -448,12 +448,12 @@ static void _collision_sphere_sphere(const ShapeSW *p_a, const Transform &p_tran } template <bool withMargin> -static void _collision_sphere_box(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_sphere_box(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a); - const BoxShapeSW *box_B = static_cast<const BoxShapeSW *>(p_b); + const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a); + const BoxShape3DSW *box_B = static_cast<const BoxShape3DSW *>(p_b); - SeparatorAxisTest<SphereShapeSW, BoxShapeSW, withMargin> separator(sphere_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<SphereShape3DSW, BoxShape3DSW, withMargin> separator(sphere_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -498,12 +498,12 @@ static void _collision_sphere_box(const ShapeSW *p_a, const Transform &p_transfo } template <bool withMargin> -static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_sphere_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a); - const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b); + const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a); + const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b); - SeparatorAxisTest<SphereShapeSW, CapsuleShapeSW, withMargin> separator(sphere_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<SphereShape3DSW, CapsuleShape3DSW, withMargin> separator(sphere_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -537,16 +537,16 @@ static void _collision_sphere_capsule(const ShapeSW *p_a, const Transform &p_tra } template <bool withMargin> -static void _collision_sphere_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_sphere_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { } template <bool withMargin> -static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_sphere_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a); - const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b); + const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a); + const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b); - SeparatorAxisTest<SphereShapeSW, ConvexPolygonShapeSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<SphereShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -601,12 +601,12 @@ static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform } template <bool withMargin> -static void _collision_sphere_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_sphere_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a); - const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b); + const SphereShape3DSW *sphere_A = static_cast<const SphereShape3DSW *>(p_a); + const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b); - SeparatorAxisTest<SphereShapeSW, FaceShapeSW, withMargin> separator(sphere_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<SphereShape3DSW, FaceShape3DSW, withMargin> separator(sphere_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); Vector3 vertex[3] = { p_transform_b.xform(face_B->vertex[0]), @@ -639,12 +639,12 @@ static void _collision_sphere_face(const ShapeSW *p_a, const Transform &p_transf } template <bool withMargin> -static void _collision_box_box(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_box_box(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a); - const BoxShapeSW *box_B = static_cast<const BoxShapeSW *>(p_b); + const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a); + const BoxShape3DSW *box_B = static_cast<const BoxShape3DSW *>(p_b); - SeparatorAxisTest<BoxShapeSW, BoxShapeSW, withMargin> separator(box_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<BoxShape3DSW, BoxShape3DSW, withMargin> separator(box_A, p_transform_a, box_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -737,12 +737,12 @@ static void _collision_box_box(const ShapeSW *p_a, const Transform &p_transform_ } template <bool withMargin> -static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_box_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a); - const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b); + const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a); + const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b); - SeparatorAxisTest<BoxShapeSW, CapsuleShapeSW, withMargin> separator(box_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<BoxShape3DSW, CapsuleShape3DSW, withMargin> separator(box_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -832,16 +832,16 @@ static void _collision_box_capsule(const ShapeSW *p_a, const Transform &p_transf } template <bool withMargin> -static void _collision_box_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_box_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { } template <bool withMargin> -static void _collision_box_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_box_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a); - const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b); + const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a); + const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b); - SeparatorAxisTest<BoxShapeSW, ConvexPolygonShapeSW, withMargin> separator(box_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<BoxShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(box_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -953,12 +953,12 @@ static void _collision_box_convex_polygon(const ShapeSW *p_a, const Transform &p } template <bool withMargin> -static void _collision_box_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_box_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const BoxShapeSW *box_A = static_cast<const BoxShapeSW *>(p_a); - const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b); + const BoxShape3DSW *box_A = static_cast<const BoxShape3DSW *>(p_a); + const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b); - SeparatorAxisTest<BoxShapeSW, FaceShapeSW, withMargin> separator(box_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<BoxShape3DSW, FaceShape3DSW, withMargin> separator(box_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); Vector3 vertex[3] = { p_transform_b.xform(face_B->vertex[0]), @@ -1057,12 +1057,12 @@ static void _collision_box_face(const ShapeSW *p_a, const Transform &p_transform } template <bool withMargin> -static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_capsule_capsule(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a); - const CapsuleShapeSW *capsule_B = static_cast<const CapsuleShapeSW *>(p_b); + const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a); + const CapsuleShape3DSW *capsule_B = static_cast<const CapsuleShape3DSW *>(p_b); - SeparatorAxisTest<CapsuleShapeSW, CapsuleShapeSW, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<CapsuleShape3DSW, CapsuleShape3DSW, withMargin> separator(capsule_A, p_transform_a, capsule_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -1112,16 +1112,16 @@ static void _collision_capsule_capsule(const ShapeSW *p_a, const Transform &p_tr } template <bool withMargin> -static void _collision_capsule_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_capsule_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { } template <bool withMargin> -static void _collision_capsule_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_capsule_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a); - const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b); + const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a); + const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b); - SeparatorAxisTest<CapsuleShapeSW, ConvexPolygonShapeSW, withMargin> separator(capsule_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<CapsuleShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(capsule_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -1181,12 +1181,12 @@ static void _collision_capsule_convex_polygon(const ShapeSW *p_a, const Transfor } template <bool withMargin> -static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_capsule_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const CapsuleShapeSW *capsule_A = static_cast<const CapsuleShapeSW *>(p_a); - const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b); + const CapsuleShape3DSW *capsule_A = static_cast<const CapsuleShape3DSW *>(p_a); + const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b); - SeparatorAxisTest<CapsuleShapeSW, FaceShapeSW, withMargin> separator(capsule_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<CapsuleShape3DSW, FaceShape3DSW, withMargin> separator(capsule_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); Vector3 vertex[3] = { p_transform_b.xform(face_B->vertex[0]), @@ -1236,24 +1236,24 @@ static void _collision_capsule_face(const ShapeSW *p_a, const Transform &p_trans } template <bool withMargin> -static void _collision_cylinder_cylinder(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_cylinder_cylinder(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { } template <bool withMargin> -static void _collision_cylinder_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_cylinder_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { } template <bool withMargin> -static void _collision_cylinder_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_cylinder_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { } template <bool withMargin> -static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_convex_polygon_convex_polygon(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW *>(p_a); - const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b); + const ConvexPolygonShape3DSW *convex_polygon_A = static_cast<const ConvexPolygonShape3DSW *>(p_a); + const ConvexPolygonShape3DSW *convex_polygon_B = static_cast<const ConvexPolygonShape3DSW *>(p_b); - SeparatorAxisTest<ConvexPolygonShapeSW, ConvexPolygonShapeSW, withMargin> separator(convex_polygon_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<ConvexPolygonShape3DSW, ConvexPolygonShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b); if (!separator.test_previous_axis()) return; @@ -1362,12 +1362,12 @@ static void _collision_convex_polygon_convex_polygon(const ShapeSW *p_a, const T } template <bool withMargin> -static void _collision_convex_polygon_face(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { +static void _collision_convex_polygon_face(const Shape3DSW *p_a, const Transform &p_transform_a, const Shape3DSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) { - const ConvexPolygonShapeSW *convex_polygon_A = static_cast<const ConvexPolygonShapeSW *>(p_a); - const FaceShapeSW *face_B = static_cast<const FaceShapeSW *>(p_b); + const ConvexPolygonShape3DSW *convex_polygon_A = static_cast<const ConvexPolygonShape3DSW *>(p_a); + const FaceShape3DSW *face_B = static_cast<const FaceShape3DSW *>(p_b); - SeparatorAxisTest<ConvexPolygonShapeSW, FaceShapeSW, withMargin> separator(convex_polygon_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); + SeparatorAxisTest<ConvexPolygonShape3DSW, FaceShape3DSW, withMargin> separator(convex_polygon_A, p_transform_a, face_B, p_transform_b, p_collector, p_margin_a, p_margin_b); const Geometry::MeshData &mesh = convex_polygon_A->get_mesh(); @@ -1462,18 +1462,18 @@ static void _collision_convex_polygon_face(const ShapeSW *p_a, const Transform & separator.generate_contacts(); } -bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) { +bool sat_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap, Vector3 *r_prev_axis, real_t p_margin_a, real_t p_margin_b) { - PhysicsServer::ShapeType type_A = p_shape_A->get_type(); + PhysicsServer3D::ShapeType type_A = p_shape_A->get_type(); - ERR_FAIL_COND_V(type_A == PhysicsServer::SHAPE_PLANE, false); - ERR_FAIL_COND_V(type_A == PhysicsServer::SHAPE_RAY, false); + ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_PLANE, false); + ERR_FAIL_COND_V(type_A == PhysicsServer3D::SHAPE_RAY, false); ERR_FAIL_COND_V(p_shape_A->is_concave(), false); - PhysicsServer::ShapeType type_B = p_shape_B->get_type(); + PhysicsServer3D::ShapeType type_B = p_shape_B->get_type(); - ERR_FAIL_COND_V(type_B == PhysicsServer::SHAPE_PLANE, false); - ERR_FAIL_COND_V(type_B == PhysicsServer::SHAPE_RAY, false); + ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_PLANE, false); + ERR_FAIL_COND_V(type_B == PhysicsServer3D::SHAPE_RAY, false); ERR_FAIL_COND_V(p_shape_B->is_concave(), false); static const CollisionFunc collision_table[6][6] = { @@ -1483,36 +1483,36 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran _collision_sphere_cylinder<false>, _collision_sphere_convex_polygon<false>, _collision_sphere_face<false> }, - { 0, + { nullptr, _collision_box_box<false>, _collision_box_capsule<false>, _collision_box_cylinder<false>, _collision_box_convex_polygon<false>, _collision_box_face<false> }, - { 0, - 0, + { nullptr, + nullptr, _collision_capsule_capsule<false>, _collision_capsule_cylinder<false>, _collision_capsule_convex_polygon<false>, _collision_capsule_face<false> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_cylinder_cylinder<false>, _collision_cylinder_convex_polygon<false>, _collision_cylinder_face<false> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<false>, _collision_convex_polygon_face<false> }, - { 0, - 0, - 0, - 0, - 0, - 0 }, + { nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr }, }; static const CollisionFunc collision_table_margin[6][6] = { @@ -1522,36 +1522,36 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran _collision_sphere_cylinder<true>, _collision_sphere_convex_polygon<true>, _collision_sphere_face<true> }, - { 0, + { nullptr, _collision_box_box<true>, _collision_box_capsule<true>, _collision_box_cylinder<true>, _collision_box_convex_polygon<true>, _collision_box_face<true> }, - { 0, - 0, + { nullptr, + nullptr, _collision_capsule_capsule<true>, _collision_capsule_cylinder<true>, _collision_capsule_convex_polygon<true>, _collision_capsule_face<true> }, - { 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, _collision_cylinder_cylinder<true>, _collision_cylinder_convex_polygon<true>, _collision_cylinder_face<true> }, - { 0, - 0, - 0, - 0, + { nullptr, + nullptr, + nullptr, + nullptr, _collision_convex_polygon_convex_polygon<true>, _collision_convex_polygon_face<true> }, - { 0, - 0, - 0, - 0, - 0, - 0 }, + { nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr }, }; _CollectorCallback callback; @@ -1561,8 +1561,8 @@ bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_tran callback.collided = false; callback.prev_axis = r_prev_axis; - const ShapeSW *A = p_shape_A; - const ShapeSW *B = p_shape_B; + const Shape3DSW *A = p_shape_A; + const Shape3DSW *B = p_shape_B; const Transform *transform_A = &p_transform_A; const Transform *transform_B = &p_transform_B; real_t margin_A = p_margin_a; diff --git a/servers/physics/collision_solver_sat.h b/servers/physics_3d/collision_solver_3d_sat.h index 31895231f0..5eccfda9ac 100644 --- a/servers/physics/collision_solver_sat.h +++ b/servers/physics_3d/collision_solver_3d_sat.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_solver_sat.h */ +/* collision_solver_3d_sat.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,8 +31,8 @@ #ifndef COLLISION_SOLVER_SAT_H #define COLLISION_SOLVER_SAT_H -#include "collision_solver_sw.h" +#include "collision_solver_3d_sw.h" -bool sat_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector3 *r_prev_axis = NULL, real_t p_margin_a = 0, real_t p_margin_b = 0); +bool sat_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false, Vector3 *r_prev_axis = nullptr, real_t p_margin_a = 0, real_t p_margin_b = 0); #endif // COLLISION_SOLVER_SAT_H diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics_3d/collision_solver_3d_sw.cpp index ce24ba6bca..5d31e1f546 100644 --- a/servers/physics/collision_solver_sw.cpp +++ b/servers/physics_3d/collision_solver_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_solver_sw.cpp */ +/* collision_solver_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,18 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "collision_solver_sw.h" -#include "collision_solver_sat.h" +#include "collision_solver_3d_sw.h" +#include "collision_solver_3d_sat.h" #include "gjk_epa.h" #define collision_solver sat_calculate_penetration //#define collision_solver gjk_epa_calculate_penetration -bool CollisionSolverSW::solve_static_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) { +bool CollisionSolver3DSW::solve_static_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) { - const PlaneShapeSW *plane = static_cast<const PlaneShapeSW *>(p_shape_A); - if (p_shape_B->get_type() == PhysicsServer::SHAPE_PLANE) + const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A); + if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) return false; Plane p = p_transform_A.xform(plane->get_plane()); @@ -71,9 +71,9 @@ bool CollisionSolverSW::solve_static_plane(const ShapeSW *p_shape_A, const Trans return found; } -bool CollisionSolverSW::solve_ray(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) { +bool CollisionSolver3DSW::solve_ray(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result) { - const RayShapeSW *ray = static_cast<const RayShapeSW *>(p_shape_A); + const RayShape3DSW *ray = static_cast<const RayShape3DSW *>(p_shape_A); Vector3 from = p_transform_A.origin; Vector3 to = from + p_transform_A.basis.get_axis(2) * ray->get_length(); @@ -106,9 +106,9 @@ bool CollisionSolverSW::solve_ray(const ShapeSW *p_shape_A, const Transform &p_t struct _ConcaveCollisionInfo { const Transform *transform_A; - const ShapeSW *shape_A; + const Shape3DSW *shape_A; const Transform *transform_B; - CollisionSolverSW::CallbackResult result_callback; + CollisionSolver3DSW::CallbackResult result_callback; void *userdata; bool swap_result; bool collided; @@ -120,12 +120,12 @@ struct _ConcaveCollisionInfo { Vector3 close_A, close_B; }; -void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) { +void CollisionSolver3DSW::concave_callback(void *p_userdata, Shape3DSW *p_convex) { _ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata); cinfo.aabb_tests++; - bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, NULL, cinfo.margin_A, cinfo.margin_B); + bool collided = collision_solver(cinfo.shape_A, *cinfo.transform_A, p_convex, *cinfo.transform_B, cinfo.result_callback, cinfo.userdata, cinfo.swap_result, nullptr, cinfo.margin_A, cinfo.margin_B); if (!collided) return; @@ -133,9 +133,9 @@ void CollisionSolverSW::concave_callback(void *p_userdata, ShapeSW *p_convex) { cinfo.collisions++; } -bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A, real_t p_margin_B) { +bool CollisionSolver3DSW::solve_concave(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A, real_t p_margin_B) { - const ConcaveShapeSW *concave_B = static_cast<const ConcaveShapeSW *>(p_shape_B); + const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B); _ConcaveCollisionInfo cinfo; cinfo.transform_A = &p_transform_A; @@ -179,10 +179,10 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform return cinfo.collided; } -bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) { +bool CollisionSolver3DSW::solve_static(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis, real_t p_margin_A, real_t p_margin_B) { - PhysicsServer::ShapeType type_A = p_shape_A->get_type(); - PhysicsServer::ShapeType type_B = p_shape_B->get_type(); + PhysicsServer3D::ShapeType type_A = p_shape_A->get_type(); + PhysicsServer3D::ShapeType type_B = p_shape_B->get_type(); bool concave_A = p_shape_A->is_concave(); bool concave_B = p_shape_B->is_concave(); @@ -194,11 +194,11 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform & swap = true; } - if (type_A == PhysicsServer::SHAPE_PLANE) { + if (type_A == PhysicsServer3D::SHAPE_PLANE) { - if (type_B == PhysicsServer::SHAPE_PLANE) + if (type_B == PhysicsServer3D::SHAPE_PLANE) return false; - if (type_B == PhysicsServer::SHAPE_RAY) { + if (type_B == PhysicsServer3D::SHAPE_RAY) { return false; } @@ -208,9 +208,9 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform & return solve_static_plane(p_shape_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false); } - } else if (type_A == PhysicsServer::SHAPE_RAY) { + } else if (type_A == PhysicsServer3D::SHAPE_RAY) { - if (type_B == PhysicsServer::SHAPE_RAY) + if (type_B == PhysicsServer3D::SHAPE_RAY) return false; if (swap) { @@ -235,7 +235,7 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform & } } -void CollisionSolverSW::concave_distance_callback(void *p_userdata, ShapeSW *p_convex) { +void CollisionSolver3DSW::concave_distance_callback(void *p_userdata, Shape3DSW *p_convex) { _ConcaveCollisionInfo &cinfo = *(_ConcaveCollisionInfo *)(p_userdata); cinfo.aabb_tests++; @@ -257,10 +257,10 @@ void CollisionSolverSW::concave_distance_callback(void *p_userdata, ShapeSW *p_c cinfo.collisions++; } -bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) { +bool CollisionSolver3DSW::solve_distance_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B) { - const PlaneShapeSW *plane = static_cast<const PlaneShapeSW *>(p_shape_A); - if (p_shape_B->get_type() == PhysicsServer::SHAPE_PLANE) + const PlaneShape3DSW *plane = static_cast<const PlaneShape3DSW *>(p_shape_A); + if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) return false; Plane p = p_transform_A.xform(plane->get_plane()); @@ -292,12 +292,12 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Tra return collided; } -bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) { +bool CollisionSolver3DSW::solve_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) { if (p_shape_A->is_concave()) return false; - if (p_shape_B->get_type() == PhysicsServer::SHAPE_PLANE) { + if (p_shape_B->get_type() == PhysicsServer3D::SHAPE_PLANE) { Vector3 a, b; bool col = solve_distance_plane(p_shape_B, p_transform_B, p_shape_A, p_transform_A, a, b); @@ -310,14 +310,14 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform if (p_shape_A->is_concave()) return false; - const ConcaveShapeSW *concave_B = static_cast<const ConcaveShapeSW *>(p_shape_B); + const ConcaveShape3DSW *concave_B = static_cast<const ConcaveShape3DSW *>(p_shape_B); _ConcaveCollisionInfo cinfo; cinfo.transform_A = &p_transform_A; cinfo.shape_A = p_shape_A; cinfo.transform_B = &p_transform_B; - cinfo.result_callback = NULL; - cinfo.userdata = NULL; + cinfo.result_callback = nullptr; + cinfo.userdata = nullptr; cinfo.swap_result = false; cinfo.collided = false; cinfo.collisions = 0; diff --git a/servers/physics/collision_solver_sw.h b/servers/physics_3d/collision_solver_3d_sw.h index d4dc1ac2a2..13f54ca8fb 100644 --- a/servers/physics/collision_solver_sw.h +++ b/servers/physics_3d/collision_solver_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_solver_sw.h */ +/* collision_solver_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,23 +31,23 @@ #ifndef COLLISION_SOLVER_SW_H #define COLLISION_SOLVER_SW_H -#include "shape_sw.h" +#include "shape_3d_sw.h" -class CollisionSolverSW { +class CollisionSolver3DSW { public: typedef void (*CallbackResult)(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata); private: - static void concave_callback(void *p_userdata, ShapeSW *p_convex); - static bool solve_static_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result); - static bool solve_ray(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result); - static bool solve_concave(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A = 0, real_t p_margin_B = 0); - static void concave_distance_callback(void *p_userdata, ShapeSW *p_convex); - static bool solve_distance_plane(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B); + static void concave_callback(void *p_userdata, Shape3DSW *p_convex); + static bool solve_static_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result); + static bool solve_ray(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result); + static bool solve_concave(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, real_t p_margin_A = 0, real_t p_margin_B = 0); + static void concave_distance_callback(void *p_userdata, Shape3DSW *p_convex); + static bool solve_distance_plane(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B); public: - static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0); - static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL); + static bool solve_static(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = nullptr, real_t p_margin_A = 0, real_t p_margin_B = 0); + static bool solve_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = nullptr); }; #endif // COLLISION_SOLVER__SW_H diff --git a/servers/physics/constraint_sw.h b/servers/physics_3d/constraint_3d_sw.h index 22f31b411b..5e2b00404b 100644 --- a/servers/physics/constraint_sw.h +++ b/servers/physics_3d/constraint_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* constraint_sw.h */ +/* constraint_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,22 +31,22 @@ #ifndef CONSTRAINT_SW_H #define CONSTRAINT_SW_H -#include "body_sw.h" +#include "body_3d_sw.h" -class ConstraintSW { +class Constraint3DSW { - BodySW **_body_ptr; + Body3DSW **_body_ptr; int _body_count; uint64_t island_step; - ConstraintSW *island_next; - ConstraintSW *island_list_next; + Constraint3DSW *island_next; + Constraint3DSW *island_list_next; int priority; bool disabled_collisions_between_bodies; RID self; protected: - ConstraintSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) { + Constraint3DSW(Body3DSW **p_body_ptr = nullptr, int p_body_count = 0) { _body_ptr = p_body_ptr; _body_count = p_body_count; island_step = 0; @@ -61,13 +61,13 @@ public: _FORCE_INLINE_ uint64_t get_island_step() const { return island_step; } _FORCE_INLINE_ void set_island_step(uint64_t p_step) { island_step = p_step; } - _FORCE_INLINE_ ConstraintSW *get_island_next() const { return island_next; } - _FORCE_INLINE_ void set_island_next(ConstraintSW *p_next) { island_next = p_next; } + _FORCE_INLINE_ Constraint3DSW *get_island_next() const { return island_next; } + _FORCE_INLINE_ void set_island_next(Constraint3DSW *p_next) { island_next = p_next; } - _FORCE_INLINE_ ConstraintSW *get_island_list_next() const { return island_list_next; } - _FORCE_INLINE_ void set_island_list_next(ConstraintSW *p_next) { island_list_next = p_next; } + _FORCE_INLINE_ Constraint3DSW *get_island_list_next() const { return island_list_next; } + _FORCE_INLINE_ void set_island_list_next(Constraint3DSW *p_next) { island_list_next = p_next; } - _FORCE_INLINE_ BodySW **get_body_ptr() const { return _body_ptr; } + _FORCE_INLINE_ Body3DSW **get_body_ptr() const { return _body_ptr; } _FORCE_INLINE_ int get_body_count() const { return _body_count; } _FORCE_INLINE_ void set_priority(int p_priority) { priority = p_priority; } @@ -79,7 +79,7 @@ public: virtual bool setup(real_t p_step) = 0; virtual void solve(real_t p_step) = 0; - virtual ~ConstraintSW() {} + virtual ~Constraint3DSW() {} }; #endif // CONSTRAINT__SW_H diff --git a/servers/physics/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp index abf0c0dc15..db37f261ce 100644 --- a/servers/physics/gjk_epa.cpp +++ b/servers/physics_3d/gjk_epa.cpp @@ -103,7 +103,7 @@ typedef unsigned char U1; // MinkowskiDiff struct MinkowskiDiff { - const ShapeSW* m_shapes[2]; + const Shape3DSW* m_shapes[2]; Transform transform_A; Transform transform_B; @@ -515,14 +515,14 @@ struct GJK { sFace* root; U count; - sList() : root(0),count(0) {} + sList() : root(nullptr),count(0) {} }; struct sHorizon { sFace* cf; sFace* ff; U nf; - sHorizon() : cf(0),ff(0),nf(0) {} + sHorizon() : cf(nullptr),ff(nullptr),nf(0) {} }; struct eStatus { enum _ { Valid, @@ -559,7 +559,7 @@ struct GJK } static inline void append(sList& list,sFace* face) { - face->l[0] = 0; + face->l[0] = nullptr; face->l[1] = list.root; if(list.root) list.root->l[0]=face; list.root = face; @@ -720,13 +720,13 @@ struct GJK } else m_status=eStatus::Degenerated; remove(m_hull,face); append(m_stock,face); - return(0); + return(nullptr); } // -- GODOT start -- //m_status=m_stock.root?eStatus::OutOfVertices:eStatus::OutOfFaces; m_status=eStatus::OutOfFaces; // -- GODOT end -- - return(0); + return(nullptr); } sFace* findbest() { @@ -783,8 +783,8 @@ struct GJK }; // - static void Initialize( const ShapeSW* shape0,const Transform& wtrs0, - const ShapeSW* shape1,const Transform& wtrs1, + static void Initialize( const Shape3DSW* shape0,const Transform& wtrs0, + const Shape3DSW* shape1,const Transform& wtrs1, sResults& results, tShape& shape, bool withmargins) @@ -810,9 +810,9 @@ struct GJK // // -bool Distance( const ShapeSW* shape0, +bool Distance( const Shape3DSW* shape0, const Transform& wtrs0, - const ShapeSW* shape1, + const Shape3DSW* shape1, const Transform& wtrs1, const Vector3& guess, sResults& results) @@ -848,9 +848,9 @@ bool Distance( const ShapeSW* shape0, } // -bool Penetration( const ShapeSW* shape0, +bool Penetration( const Shape3DSW* shape0, const Transform& wtrs0, - const ShapeSW* shape1, + const Shape3DSW* shape1, const Transform& wtrs1, const Vector3& guess, sResults& results @@ -914,7 +914,7 @@ bool Penetration( const ShapeSW* shape0, /* clang-format on */ -bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B) { +bool gjk_epa_calculate_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B) { GjkEpa2::sResults res; @@ -928,7 +928,7 @@ bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_tra return false; } -bool gjk_epa_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap) { +bool gjk_epa_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap) { GjkEpa2::sResults res; diff --git a/servers/physics/gjk_epa.h b/servers/physics_3d/gjk_epa.h index 38c616cde0..dec0f269e1 100644 --- a/servers/physics/gjk_epa.h +++ b/servers/physics_3d/gjk_epa.h @@ -31,10 +31,10 @@ #ifndef GJK_EPA_H #define GJK_EPA_H -#include "collision_solver_sw.h" -#include "shape_sw.h" +#include "collision_solver_3d_sw.h" +#include "shape_3d_sw.h" -bool gjk_epa_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false); -bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B); +bool gjk_epa_calculate_penetration(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, CollisionSolver3DSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false); +bool gjk_epa_calculate_distance(const Shape3DSW *p_shape_A, const Transform &p_transform_A, const Shape3DSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B); #endif diff --git a/servers/physics/joints/SCsub b/servers/physics_3d/joints/SCsub index d730144861..86681f9c74 100644 --- a/servers/physics/joints/SCsub +++ b/servers/physics_3d/joints/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp index 58f66f7ea2..a072c1f3a0 100644 --- a/servers/physics/joints/cone_twist_joint_sw.cpp +++ b/servers/physics_3d/joints/cone_twist_joint_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* cone_twist_joint_sw.cpp */ +/* cone_twist_joint_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -49,7 +49,7 @@ subject to the following restrictions: Written by: Marcus Hennix */ -#include "cone_twist_joint_sw.h" +#include "cone_twist_joint_3d_sw.h" static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) { @@ -85,8 +85,8 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) { return (y < 0.0f) ? -angle : angle; } -ConeTwistJointSW::ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : - JointSW(_arr, 2) { +ConeTwistJoint3DSW::ConeTwistJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : + Joint3DSW(_arr, 2) { A = rbA; B = rbB; @@ -110,7 +110,7 @@ ConeTwistJointSW::ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rb m_appliedImpulse = 0; } -bool ConeTwistJointSW::setup(real_t p_timestep) { +bool ConeTwistJoint3DSW::setup(real_t p_timestep) { m_appliedImpulse = real_t(0.); //set bias, sign, clear accumulator @@ -136,7 +136,7 @@ bool ConeTwistJointSW::setup(real_t p_timestep) { plane_space(normal[0], normal[1], normal[2]); for (int i = 0; i < 3; i++) { - memnew_placement(&m_jac[i], JacobianEntrySW( + memnew_placement(&m_jac[i], JacobianEntry3DSW( A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), pivotAInW - A->get_transform().origin - A->get_center_of_mass(), @@ -237,7 +237,7 @@ bool ConeTwistJointSW::setup(real_t p_timestep) { return true; } -void ConeTwistJointSW::solve(real_t p_timestep) { +void ConeTwistJoint3DSW::solve(real_t p_timestep) { Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin); Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin); @@ -308,58 +308,58 @@ void ConeTwistJointSW::solve(real_t p_timestep) { } } -void ConeTwistJointSW::set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value) { +void ConeTwistJoint3DSW::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: { + case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: { m_swingSpan1 = p_value; m_swingSpan2 = p_value; } break; - case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN: { + case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: { m_twistSpan = p_value; } break; - case PhysicsServer::CONE_TWIST_JOINT_BIAS: { + case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: { m_biasFactor = p_value; } break; - case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS: { + case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: { m_limitSoftness = p_value; } break; - case PhysicsServer::CONE_TWIST_JOINT_RELAXATION: { + case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: { m_relaxationFactor = p_value; } break; - case PhysicsServer::CONE_TWIST_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::CONE_TWIST_MAX: break; // Can't happen, but silences warning } } -real_t ConeTwistJointSW::get_param(PhysicsServer::ConeTwistJointParam p_param) const { +real_t ConeTwistJoint3DSW::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const { switch (p_param) { - case PhysicsServer::CONE_TWIST_JOINT_SWING_SPAN: { + case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: { return m_swingSpan1; } break; - case PhysicsServer::CONE_TWIST_JOINT_TWIST_SPAN: { + case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: { return m_twistSpan; } break; - case PhysicsServer::CONE_TWIST_JOINT_BIAS: { + case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: { return m_biasFactor; } break; - case PhysicsServer::CONE_TWIST_JOINT_SOFTNESS: { + case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: { return m_limitSoftness; } break; - case PhysicsServer::CONE_TWIST_JOINT_RELAXATION: { + case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: { return m_relaxationFactor; } break; - case PhysicsServer::CONE_TWIST_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::CONE_TWIST_MAX: break; // Can't happen, but silences warning } return 0; diff --git a/servers/physics/joints/cone_twist_joint_sw.h b/servers/physics_3d/joints/cone_twist_joint_3d_sw.h index 857aaa0d86..c713d8cf17 100644 --- a/servers/physics/joints/cone_twist_joint_sw.h +++ b/servers/physics_3d/joints/cone_twist_joint_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* cone_twist_joint_sw.h */ +/* cone_twist_joint_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -52,25 +52,25 @@ Written by: Marcus Hennix #ifndef CONE_TWIST_JOINT_SW_H #define CONE_TWIST_JOINT_SW_H -#include "servers/physics/joints/jacobian_entry_sw.h" -#include "servers/physics/joints_sw.h" +#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h" +#include "servers/physics_3d/joints_3d_sw.h" ///ConeTwistJointSW can be used to simulate ragdoll joints (upper arm, leg etc) -class ConeTwistJointSW : public JointSW { +class ConeTwistJoint3DSW : public Joint3DSW { #ifdef IN_PARALLELL_SOLVER public: #endif union { struct { - BodySW *A; - BodySW *B; + Body3DSW *A; + Body3DSW *B; }; - BodySW *_arr[2]; + Body3DSW *_arr[2]; }; - JacobianEntrySW m_jac[3]; //3 orthogonal linear constraints + JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints real_t m_appliedImpulse; Transform m_rbAFrame; @@ -102,12 +102,12 @@ public: bool m_solveSwingLimit; public: - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_CONE_TWIST; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_CONE_TWIST; } virtual bool setup(real_t p_timestep); virtual void solve(real_t p_timestep); - ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rbAFrame, const Transform &rbBFrame); + ConeTwistJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &rbAFrame, const Transform &rbBFrame); void setAngularOnly(bool angularOnly) { m_angularOnly = angularOnly; @@ -135,8 +135,8 @@ public: return m_twistLimitSign; } - void set_param(PhysicsServer::ConeTwistJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::ConeTwistJointParam p_param) const; + void set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::ConeTwistJointParam p_param) const; }; #endif // CONE_TWIST_JOINT_SW_H diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp index 8f0ccab7f7..1f433ec6a5 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.cpp +++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* generic_6dof_joint_sw.cpp */ +/* generic_6dof_joint_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -54,13 +54,13 @@ email: projectileman@yahoo.com http://gimpact.sf.net */ -#include "generic_6dof_joint_sw.h" +#include "generic_6dof_joint_3d_sw.h" #define GENERIC_D6_DISABLE_WARMSTARTING 1 //////////////////////////// G6DOFRotationalLimitMotorSW //////////////////////////////////// -int G6DOFRotationalLimitMotorSW::testLimitValue(real_t test_value) { +int G6DOFRotationalLimitMotor3DSW::testLimitValue(real_t test_value) { if (m_loLimit > m_hiLimit) { m_currentLimit = 0; //Free from violation return 0; @@ -80,9 +80,9 @@ int G6DOFRotationalLimitMotorSW::testLimitValue(real_t test_value) { return 0; } -real_t G6DOFRotationalLimitMotorSW::solveAngularLimits( +real_t G6DOFRotationalLimitMotor3DSW::solveAngularLimits( real_t timeStep, Vector3 &axis, real_t jacDiagABInv, - BodySW *body0, BodySW *body1) { + Body3DSW *body0, Body3DSW *body1) { if (!needApplyTorques()) return 0.0f; real_t target_velocity = m_targetVelocity; @@ -145,11 +145,11 @@ real_t G6DOFRotationalLimitMotorSW::solveAngularLimits( //////////////////////////// End G6DOFRotationalLimitMotorSW //////////////////////////////////// //////////////////////////// G6DOFTranslationalLimitMotorSW //////////////////////////////////// -real_t G6DOFTranslationalLimitMotorSW::solveLinearAxis( +real_t G6DOFTranslationalLimitMotor3DSW::solveLinearAxis( real_t timeStep, real_t jacDiagABInv, - BodySW *body1, const Vector3 &pointInA, - BodySW *body2, const Vector3 &pointInB, + Body3DSW *body1, const Vector3 &pointInA, + Body3DSW *body2, const Vector3 &pointInB, int limit_index, const Vector3 &axis_normal_on_a, const Vector3 &anchorPos) { @@ -209,8 +209,8 @@ real_t G6DOFTranslationalLimitMotorSW::solveLinearAxis( //////////////////////////// G6DOFTranslationalLimitMotorSW //////////////////////////////////// -Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) : - JointSW(_arr, 2), +Generic6DOFJoint3DSW::Generic6DOFJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) : + Joint3DSW(_arr, 2), m_frameInA(frameInA), m_frameInB(frameInB), m_useLinearReferenceFrameA(useLinearReferenceFrameA) { @@ -220,7 +220,7 @@ Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform B->add_constraint(this, 1); } -void Generic6DOFJointSW::calculateAngleInfo() { +void Generic6DOFJoint3DSW::calculateAngleInfo() { Basis relative_frame = m_calculatedTransformB.basis.inverse() * m_calculatedTransformA.basis; m_calculatedAxisAngleDiff = relative_frame.get_euler_xyz(); @@ -261,17 +261,17 @@ void Generic6DOFJointSW::calculateAngleInfo() { */ } -void Generic6DOFJointSW::calculateTransforms() { +void Generic6DOFJoint3DSW::calculateTransforms() { m_calculatedTransformA = A->get_transform() * m_frameInA; m_calculatedTransformB = B->get_transform() * m_frameInB; calculateAngleInfo(); } -void Generic6DOFJointSW::buildLinearJacobian( - JacobianEntrySW &jacLinear, const Vector3 &normalWorld, +void Generic6DOFJoint3DSW::buildLinearJacobian( + JacobianEntry3DSW &jacLinear, const Vector3 &normalWorld, const Vector3 &pivotAInW, const Vector3 &pivotBInW) { - memnew_placement(&jacLinear, JacobianEntrySW( + memnew_placement(&jacLinear, JacobianEntry3DSW( A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), pivotAInW - A->get_transform().origin - A->get_center_of_mass(), @@ -283,16 +283,16 @@ void Generic6DOFJointSW::buildLinearJacobian( B->get_inv_mass())); } -void Generic6DOFJointSW::buildAngularJacobian( - JacobianEntrySW &jacAngular, const Vector3 &jointAxisW) { - memnew_placement(&jacAngular, JacobianEntrySW(jointAxisW, +void Generic6DOFJoint3DSW::buildAngularJacobian( + JacobianEntry3DSW &jacAngular, const Vector3 &jointAxisW) { + memnew_placement(&jacAngular, JacobianEntry3DSW(jointAxisW, A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), A->get_inv_inertia(), B->get_inv_inertia())); } -bool Generic6DOFJointSW::testAngularLimitMotor(int axis_index) { +bool Generic6DOFJoint3DSW::testAngularLimitMotor(int axis_index) { real_t angle = m_calculatedAxisAngleDiff[axis_index]; //test limits @@ -300,7 +300,7 @@ bool Generic6DOFJointSW::testAngularLimitMotor(int axis_index) { return m_angularLimits[axis_index].needApplyTorques(); } -bool Generic6DOFJointSW::setup(real_t p_timestep) { +bool Generic6DOFJoint3DSW::setup(real_t p_timestep) { // Clear accumulated impulses for the next simulation step m_linearLimits.m_accumulatedImpulse = Vector3(real_t(0.), real_t(0.), real_t(0.)); @@ -349,7 +349,7 @@ bool Generic6DOFJointSW::setup(real_t p_timestep) { return true; } -void Generic6DOFJointSW::solve(real_t p_timestep) { +void Generic6DOFJoint3DSW::solve(real_t p_timestep) { m_timeStep = p_timestep; //calculateTransforms(); @@ -397,19 +397,19 @@ void Generic6DOFJointSW::solve(real_t p_timestep) { } } -void Generic6DOFJointSW::updateRHS(real_t timeStep) { +void Generic6DOFJoint3DSW::updateRHS(real_t timeStep) { (void)timeStep; } -Vector3 Generic6DOFJointSW::getAxis(int axis_index) const { +Vector3 Generic6DOFJoint3DSW::getAxis(int axis_index) const { return m_calculatedAxis[axis_index]; } -real_t Generic6DOFJointSW::getAngle(int axis_index) const { +real_t Generic6DOFJoint3DSW::getAngle(int axis_index) const { return m_calculatedAxisAngleDiff[axis_index]; } -void Generic6DOFJointSW::calcAnchorPos(void) { +void Generic6DOFJoint3DSW::calcAnchorPos(void) { real_t imA = A->get_inv_mass(); real_t imB = B->get_inv_mass(); real_t weight; @@ -423,263 +423,263 @@ void Generic6DOFJointSW::calcAnchorPos(void) { m_AnchorPos = pA * weight + pB * (real_t(1.0) - weight); } // Generic6DOFJointSW::calcAnchorPos() -void Generic6DOFJointSW::set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value) { +void Generic6DOFJoint3DSW::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) { ERR_FAIL_INDEX(p_axis, 3); switch (p_param) { - case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: { m_linearLimits.m_lowerLimit[p_axis] = p_value; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: { m_linearLimits.m_upperLimit[p_axis] = p_value; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: { m_linearLimits.m_limitSoftness[p_axis] = p_value; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: { m_linearLimits.m_restitution[p_axis] = p_value; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: { m_linearLimits.m_damping[p_axis] = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: { m_angularLimits[p_axis].m_loLimit = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: { m_angularLimits[p_axis].m_hiLimit = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: { m_angularLimits[p_axis].m_limitSoftness = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: { m_angularLimits[p_axis].m_damping = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: { m_angularLimits[p_axis].m_bounce = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: { m_angularLimits[p_axis].m_maxLimitForce = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: { m_angularLimits[p_axis].m_ERP = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: { m_angularLimits[p_axis].m_targetVelocity = p_value; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: { m_angularLimits[p_axis].m_maxLimitForce = p_value; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning } } -real_t Generic6DOFJointSW::get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const { +real_t Generic6DOFJoint3DSW::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const { ERR_FAIL_INDEX_V(p_axis, 3, 0); switch (p_param) { - case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT: { return m_linearLimits.m_lowerLimit[p_axis]; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT: { return m_linearLimits.m_upperLimit[p_axis]; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: { return m_linearLimits.m_limitSoftness[p_axis]; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_RESTITUTION: { return m_linearLimits.m_restitution[p_axis]; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_DAMPING: { return m_linearLimits.m_damping[p_axis]; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: { return m_angularLimits[p_axis].m_loLimit; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: { return m_angularLimits[p_axis].m_hiLimit; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: { return m_angularLimits[p_axis].m_limitSoftness; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_DAMPING: { return m_angularLimits[p_axis].m_damping; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION: { return m_angularLimits[p_axis].m_bounce; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_FORCE_LIMIT: { return m_angularLimits[p_axis].m_maxLimitForce; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_ERP: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP: { return m_angularLimits[p_axis].m_ERP; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY: { return m_angularLimits[p_axis].m_targetVelocity; } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT: { return m_angularLimits[p_axis].m_maxMotorForce; } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: { + case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: { + case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::G6DOF_JOINT_MAX: break; // Can't happen, but silences warning } return 0; } -void Generic6DOFJointSW::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value) { +void Generic6DOFJoint3DSW::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) { ERR_FAIL_INDEX(p_axis, 3); switch (p_flag) { - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: { m_linearLimits.enable_limit[p_axis] = p_value; } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: { m_angularLimits[p_axis].m_enableLimit = p_value; } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: { m_angularLimits[p_axis].m_enableMotor = p_value; } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } } -bool Generic6DOFJointSW::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const { +bool Generic6DOFJoint3DSW::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const { ERR_FAIL_INDEX_V(p_axis, 3, 0); switch (p_flag) { - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: { return m_linearLimits.enable_limit[p_axis]; } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: { return m_angularLimits[p_axis].m_enableLimit; } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR: { return m_angularLimits[p_axis].m_enableMotor; } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: { + case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING: { // Not implemented in GodotPhysics backend } break; - case PhysicsServer::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } return 0; diff --git a/servers/physics/joints/generic_6dof_joint_sw.h b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h index 07626ffa97..f7aa607901 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.h +++ b/servers/physics_3d/joints/generic_6dof_joint_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* generic_6dof_joint_sw.h */ +/* generic_6dof_joint_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library. #ifndef GENERIC_6DOF_JOINT_SW_H #define GENERIC_6DOF_JOINT_SW_H -#include "servers/physics/joints/jacobian_entry_sw.h" -#include "servers/physics/joints_sw.h" +#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h" +#include "servers/physics_3d/joints_3d_sw.h" /* Bullet Continuous Collision Detection and Physics Library @@ -61,7 +61,7 @@ http://gimpact.sf.net */ //! Rotation Limit structure for generic joints -class G6DOFRotationalLimitMotorSW { +class G6DOFRotationalLimitMotor3DSW { public: //! limit_parameters //!@{ @@ -86,7 +86,7 @@ public: real_t m_accumulatedImpulse; //!@} - G6DOFRotationalLimitMotorSW() { + G6DOFRotationalLimitMotor3DSW() { m_accumulatedImpulse = 0.f; m_targetVelocity = 0; m_maxMotorForce = 0.1f; @@ -103,7 +103,7 @@ public: m_enableLimit = false; } - G6DOFRotationalLimitMotorSW(const G6DOFRotationalLimitMotorSW &limot) { + G6DOFRotationalLimitMotor3DSW(const G6DOFRotationalLimitMotor3DSW &limot) { m_targetVelocity = limot.m_targetVelocity; m_maxMotorForce = limot.m_maxMotorForce; m_limitSoftness = limot.m_limitSoftness; @@ -133,10 +133,10 @@ public: int testLimitValue(real_t test_value); //! apply the correction impulses for two bodies - real_t solveAngularLimits(real_t timeStep, Vector3 &axis, real_t jacDiagABInv, BodySW *body0, BodySW *body1); + real_t solveAngularLimits(real_t timeStep, Vector3 &axis, real_t jacDiagABInv, Body3DSW *body0, Body3DSW *body1); }; -class G6DOFTranslationalLimitMotorSW { +class G6DOFTranslationalLimitMotor3DSW { public: Vector3 m_lowerLimit; //!< the constraint lower limits Vector3 m_upperLimit; //!< the constraint upper limits @@ -149,7 +149,7 @@ public: //!@} bool enable_limit[3]; - G6DOFTranslationalLimitMotorSW() { + G6DOFTranslationalLimitMotor3DSW() { m_lowerLimit = Vector3(0.f, 0.f, 0.f); m_upperLimit = Vector3(0.f, 0.f, 0.f); m_accumulatedImpulse = Vector3(0.f, 0.f, 0.f); @@ -163,7 +163,7 @@ public: enable_limit[2] = true; } - G6DOFTranslationalLimitMotorSW(const G6DOFTranslationalLimitMotorSW &other) { + G6DOFTranslationalLimitMotor3DSW(const G6DOFTranslationalLimitMotor3DSW &other) { m_lowerLimit = other.m_lowerLimit; m_upperLimit = other.m_upperLimit; m_accumulatedImpulse = other.m_accumulatedImpulse; @@ -187,22 +187,22 @@ public: real_t solveLinearAxis( real_t timeStep, real_t jacDiagABInv, - BodySW *body1, const Vector3 &pointInA, - BodySW *body2, const Vector3 &pointInB, + Body3DSW *body1, const Vector3 &pointInA, + Body3DSW *body2, const Vector3 &pointInB, int limit_index, const Vector3 &axis_normal_on_a, const Vector3 &anchorPos); }; -class Generic6DOFJointSW : public JointSW { +class Generic6DOFJoint3DSW : public Joint3DSW { protected: union { struct { - BodySW *A; - BodySW *B; + Body3DSW *A; + Body3DSW *B; }; - BodySW *_arr[2]; + Body3DSW *_arr[2]; }; //! relative_frames @@ -213,18 +213,18 @@ protected: //! Jacobians //!@{ - JacobianEntrySW m_jacLinear[3]; //!< 3 orthogonal linear constraints - JacobianEntrySW m_jacAng[3]; //!< 3 orthogonal angular constraints + JacobianEntry3DSW m_jacLinear[3]; //!< 3 orthogonal linear constraints + JacobianEntry3DSW m_jacAng[3]; //!< 3 orthogonal angular constraints //!@} //! Linear_Limit_parameters //!@{ - G6DOFTranslationalLimitMotorSW m_linearLimits; + G6DOFTranslationalLimitMotor3DSW m_linearLimits; //!@} //! hinge_parameters //!@{ - G6DOFRotationalLimitMotorSW m_angularLimits[3]; + G6DOFRotationalLimitMotor3DSW m_angularLimits[3]; //!@} protected: @@ -242,25 +242,25 @@ protected: //!@} - Generic6DOFJointSW &operator=(Generic6DOFJointSW &other) { + Generic6DOFJoint3DSW &operator=(Generic6DOFJoint3DSW &other) { ERR_PRINT("pito"); (void)other; return *this; } void buildLinearJacobian( - JacobianEntrySW &jacLinear, const Vector3 &normalWorld, + JacobianEntry3DSW &jacLinear, const Vector3 &normalWorld, const Vector3 &pivotAInW, const Vector3 &pivotBInW); - void buildAngularJacobian(JacobianEntrySW &jacAngular, const Vector3 &jointAxisW); + void buildAngularJacobian(JacobianEntry3DSW &jacAngular, const Vector3 &jointAxisW); //! calcs the euler angles between the two bodies. void calculateAngleInfo(); public: - Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA); + Generic6DOFJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_6DOF; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; } virtual bool setup(real_t p_timestep); virtual void solve(real_t p_timestep); @@ -348,12 +348,12 @@ public: } //! Retrieves the angular limit informacion - G6DOFRotationalLimitMotorSW *getRotationalLimitMotor(int index) { + G6DOFRotationalLimitMotor3DSW *getRotationalLimitMotor(int index) { return &m_angularLimits[index]; } //! Retrieves the limit informacion - G6DOFTranslationalLimitMotorSW *getTranslationalLimitMotor() { + G6DOFTranslationalLimitMotor3DSW *getTranslationalLimitMotor() { return &m_linearLimits; } @@ -382,20 +382,20 @@ public: return m_angularLimits[limitIndex - 3].isLimited(); } - const BodySW *getRigidBodyA() const { + const Body3DSW *getRigidBodyA() const { return A; } - const BodySW *getRigidBodyB() const { + const Body3DSW *getRigidBodyB() const { return B; } virtual void calcAnchorPos(void); // overridable - void set_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param, real_t p_value); - real_t get_param(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisParam p_param) const; + void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value); + real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const; - void set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value); - bool get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const; + void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value); + bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const; }; #endif // GENERIC_6DOF_JOINT_SW_H diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp index 1ad3e738ba..e76d366422 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics_3d/joints/hinge_joint_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* hinge_joint_sw.cpp */ +/* hinge_joint_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -47,7 +47,7 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "hinge_joint_sw.h" +#include "hinge_joint_3d_sw.h" static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) { @@ -68,8 +68,8 @@ static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) { } } -HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, const Transform &frameB) : - JointSW(_arr, 2) { +HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameA, const Transform &frameB) : + Joint3DSW(_arr, 2) { A = rbA; B = rbB; @@ -100,9 +100,9 @@ HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, co B->add_constraint(this, 1); } -HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, +HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB) : - JointSW(_arr, 2) { + Joint3DSW(_arr, 2) { A = rbA; B = rbB; @@ -157,7 +157,7 @@ HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, co B->add_constraint(this, 1); } -bool HingeJointSW::setup(real_t p_step) { +bool HingeJoint3DSW::setup(real_t p_step) { m_appliedImpulse = real_t(0.); @@ -176,7 +176,7 @@ bool HingeJointSW::setup(real_t p_step) { plane_space(normal[0], normal[1], normal[2]); for (int i = 0; i < 3; i++) { - memnew_placement(&m_jac[i], JacobianEntrySW( + memnew_placement(&m_jac[i], JacobianEntry3DSW( A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), pivotAInW - A->get_transform().origin - A->get_center_of_mass(), @@ -202,19 +202,19 @@ bool HingeJointSW::setup(real_t p_step) { Vector3 jointAxis1 = A->get_transform().basis.xform(jointAxis1local); Vector3 hingeAxisWorld = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(2)); - memnew_placement(&m_jacAng[0], JacobianEntrySW(jointAxis0, + memnew_placement(&m_jacAng[0], JacobianEntry3DSW(jointAxis0, A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), A->get_inv_inertia(), B->get_inv_inertia())); - memnew_placement(&m_jacAng[1], JacobianEntrySW(jointAxis1, + memnew_placement(&m_jacAng[1], JacobianEntry3DSW(jointAxis1, A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), A->get_inv_inertia(), B->get_inv_inertia())); - memnew_placement(&m_jacAng[2], JacobianEntrySW(hingeAxisWorld, + memnew_placement(&m_jacAng[2], JacobianEntry3DSW(hingeAxisWorld, A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), A->get_inv_inertia(), @@ -253,7 +253,7 @@ bool HingeJointSW::setup(real_t p_step) { return true; } -void HingeJointSW::solve(real_t p_step) { +void HingeJoint3DSW::solve(real_t p_step) { Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin); Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin); @@ -388,7 +388,7 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) { return (y < 0.0f) ? -angle : angle; } -real_t HingeJointSW::get_hinge_angle() { +real_t HingeJoint3DSW::get_hinge_angle() { const Vector3 refAxis0 = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(0)); const Vector3 refAxis1 = A->get_transform().basis.xform(m_rbAFrame.basis.get_axis(1)); const Vector3 swingAxis = B->get_transform().basis.xform(m_rbBFrame.basis.get_axis(1)); @@ -396,54 +396,54 @@ real_t HingeJointSW::get_hinge_angle() { return atan2fast(swingAxis.dot(refAxis0), swingAxis.dot(refAxis1)); } -void HingeJointSW::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) { +void HingeJoint3DSW::set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::HINGE_JOINT_BIAS: tau = p_value; break; - case PhysicsServer::HINGE_JOINT_LIMIT_UPPER: m_upperLimit = p_value; break; - case PhysicsServer::HINGE_JOINT_LIMIT_LOWER: m_lowerLimit = p_value; break; - case PhysicsServer::HINGE_JOINT_LIMIT_BIAS: m_biasFactor = p_value; break; - case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS: m_limitSoftness = p_value; break; - case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: m_relaxationFactor = p_value; break; - case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: m_motorTargetVelocity = p_value; break; - case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: m_maxMotorImpulse = p_value; break; - case PhysicsServer::HINGE_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::HINGE_JOINT_BIAS: tau = p_value; break; + case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: m_upperLimit = p_value; break; + case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: m_lowerLimit = p_value; break; + case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: m_biasFactor = p_value; break; + case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: m_limitSoftness = p_value; break; + case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: m_relaxationFactor = p_value; break; + case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: m_motorTargetVelocity = p_value; break; + case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: m_maxMotorImpulse = p_value; break; + case PhysicsServer3D::HINGE_JOINT_MAX: break; // Can't happen, but silences warning } } -real_t HingeJointSW::get_param(PhysicsServer::HingeJointParam p_param) const { +real_t HingeJoint3DSW::get_param(PhysicsServer3D::HingeJointParam p_param) const { switch (p_param) { - case PhysicsServer::HINGE_JOINT_BIAS: return tau; - case PhysicsServer::HINGE_JOINT_LIMIT_UPPER: return m_upperLimit; - case PhysicsServer::HINGE_JOINT_LIMIT_LOWER: return m_lowerLimit; - case PhysicsServer::HINGE_JOINT_LIMIT_BIAS: return m_biasFactor; - case PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS: return m_limitSoftness; - case PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION: return m_relaxationFactor; - case PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY: return m_motorTargetVelocity; - case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE: return m_maxMotorImpulse; - case PhysicsServer::HINGE_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::HINGE_JOINT_BIAS: return tau; + case PhysicsServer3D::HINGE_JOINT_LIMIT_UPPER: return m_upperLimit; + case PhysicsServer3D::HINGE_JOINT_LIMIT_LOWER: return m_lowerLimit; + case PhysicsServer3D::HINGE_JOINT_LIMIT_BIAS: return m_biasFactor; + case PhysicsServer3D::HINGE_JOINT_LIMIT_SOFTNESS: return m_limitSoftness; + case PhysicsServer3D::HINGE_JOINT_LIMIT_RELAXATION: return m_relaxationFactor; + case PhysicsServer3D::HINGE_JOINT_MOTOR_TARGET_VELOCITY: return m_motorTargetVelocity; + case PhysicsServer3D::HINGE_JOINT_MOTOR_MAX_IMPULSE: return m_maxMotorImpulse; + case PhysicsServer3D::HINGE_JOINT_MAX: break; // Can't happen, but silences warning } return 0; } -void HingeJointSW::set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value) { +void HingeJoint3DSW::set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value) { switch (p_flag) { - case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: m_useLimit = p_value; break; - case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: m_enableAngularMotor = p_value; break; - case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: m_useLimit = p_value; break; + case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: m_enableAngularMotor = p_value; break; + case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } } -bool HingeJointSW::get_flag(PhysicsServer::HingeJointFlag p_flag) const { +bool HingeJoint3DSW::get_flag(PhysicsServer3D::HingeJointFlag p_flag) const { switch (p_flag) { - case PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT: return m_useLimit; - case PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR: return m_enableAngularMotor; - case PhysicsServer::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::HINGE_JOINT_FLAG_USE_LIMIT: return m_useLimit; + case PhysicsServer3D::HINGE_JOINT_FLAG_ENABLE_MOTOR: return m_enableAngularMotor; + case PhysicsServer3D::HINGE_JOINT_FLAG_MAX: break; // Can't happen, but silences warning } return false; diff --git a/servers/physics/joints/hinge_joint_sw.h b/servers/physics_3d/joints/hinge_joint_3d_sw.h index 1c160cfc09..eebead20b8 100644 --- a/servers/physics/joints/hinge_joint_sw.h +++ b/servers/physics_3d/joints/hinge_joint_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* hinge_joint_sw.h */ +/* hinge_joint_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library. #ifndef HINGE_JOINT_SW_H #define HINGE_JOINT_SW_H -#include "servers/physics/joints/jacobian_entry_sw.h" -#include "servers/physics/joints_sw.h" +#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h" +#include "servers/physics_3d/joints_3d_sw.h" /* Bullet Continuous Collision Detection and Physics Library @@ -53,19 +53,19 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -class HingeJointSW : public JointSW { +class HingeJoint3DSW : public Joint3DSW { union { struct { - BodySW *A; - BodySW *B; + Body3DSW *A; + Body3DSW *B; }; - BodySW *_arr[2]; + Body3DSW *_arr[2]; }; - JacobianEntrySW m_jac[3]; //3 orthogonal linear constraints - JacobianEntrySW m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor + JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints + JacobianEntry3DSW m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor Transform m_rbAFrame; // constraint axii. Assumes z is hinge axis. Transform m_rbBFrame; @@ -97,21 +97,21 @@ class HingeJointSW : public JointSW { real_t m_appliedImpulse; public: - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_HINGE; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_HINGE; } virtual bool setup(real_t p_step); virtual void solve(real_t p_step); real_t get_hinge_angle(); - void set_param(PhysicsServer::HingeJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::HingeJointParam p_param) const; + void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::HingeJointParam p_param) const; - void set_flag(PhysicsServer::HingeJointFlag p_flag, bool p_value); - bool get_flag(PhysicsServer::HingeJointFlag p_flag) const; + void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value); + bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const; - HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, const Transform &frameB); - HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB); + HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameA, const Transform &frameB); + HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB); }; #endif // HINGE_JOINT_SW_H diff --git a/servers/physics/joints/jacobian_entry_sw.h b/servers/physics_3d/joints/jacobian_entry_3d_sw.h index a17175e6de..7e605ab173 100644 --- a/servers/physics/joints/jacobian_entry_sw.h +++ b/servers/physics_3d/joints/jacobian_entry_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* jacobian_entry_sw.h */ +/* jacobian_entry_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -52,11 +52,11 @@ subject to the following restrictions: #include "core/math/transform.h" -class JacobianEntrySW { +class JacobianEntry3DSW { public: - JacobianEntrySW(){}; + JacobianEntry3DSW(){}; //constraint between two different rigidbodies - JacobianEntrySW( + JacobianEntry3DSW( const Basis &world2A, const Basis &world2B, const Vector3 &rel_pos1, const Vector3 &rel_pos2, @@ -76,7 +76,7 @@ public: } //angular constraint between two different rigidbodies - JacobianEntrySW(const Vector3 &jointAxis, + JacobianEntry3DSW(const Vector3 &jointAxis, const Basis &world2A, const Basis &world2B, const Vector3 &inertiaInvA, @@ -92,7 +92,7 @@ public: } //angular constraint between two different rigidbodies - JacobianEntrySW(const Vector3 &axisInA, + JacobianEntry3DSW(const Vector3 &axisInA, const Vector3 &axisInB, const Vector3 &inertiaInvA, const Vector3 &inertiaInvB) : @@ -107,7 +107,7 @@ public: } //constraint on one rigidbody - JacobianEntrySW( + JacobianEntry3DSW( const Basis &world2A, const Vector3 &rel_pos1, const Vector3 &rel_pos2, const Vector3 &jointAxis, @@ -126,16 +126,16 @@ public: real_t getDiagonal() const { return m_Adiag; } // for two constraints on the same rigidbody (for example vehicle friction) - real_t getNonDiagonal(const JacobianEntrySW &jacB, const real_t massInvA) const { - const JacobianEntrySW &jacA = *this; + real_t getNonDiagonal(const JacobianEntry3DSW &jacB, const real_t massInvA) const { + const JacobianEntry3DSW &jacA = *this; real_t lin = massInvA * jacA.m_linearJointAxis.dot(jacB.m_linearJointAxis); real_t ang = jacA.m_0MinvJt.dot(jacB.m_aJ); return lin + ang; } // for two constraints on sharing two same rigidbodies (for example two contact points between two rigidbodies) - real_t getNonDiagonal(const JacobianEntrySW &jacB, const real_t massInvA, const real_t massInvB) const { - const JacobianEntrySW &jacA = *this; + real_t getNonDiagonal(const JacobianEntry3DSW &jacB, const real_t massInvA, const real_t massInvB) const { + const JacobianEntry3DSW &jacA = *this; Vector3 lin = jacA.m_linearJointAxis * jacB.m_linearJointAxis; Vector3 ang0 = jacA.m_0MinvJt * jacB.m_aJ; Vector3 ang1 = jacA.m_1MinvJt * jacB.m_bJ; diff --git a/servers/physics/joints/pin_joint_sw.cpp b/servers/physics_3d/joints/pin_joint_3d_sw.cpp index fe994aa172..95c01bc463 100644 --- a/servers/physics/joints/pin_joint_sw.cpp +++ b/servers/physics_3d/joints/pin_joint_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* pin_joint_sw.cpp */ +/* pin_joint_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -47,9 +47,9 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -#include "pin_joint_sw.h" +#include "pin_joint_3d_sw.h" -bool PinJointSW::setup(real_t p_step) { +bool PinJoint3DSW::setup(real_t p_step) { m_appliedImpulse = real_t(0.); @@ -57,7 +57,7 @@ bool PinJointSW::setup(real_t p_step) { for (int i = 0; i < 3; i++) { normal[i] = 1; - memnew_placement(&m_jac[i], JacobianEntrySW( + memnew_placement(&m_jac[i], JacobianEntry3DSW( A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), A->get_transform().xform(m_pivotInA) - A->get_transform().origin - A->get_center_of_mass(), @@ -73,7 +73,7 @@ bool PinJointSW::setup(real_t p_step) { return true; } -void PinJointSW::solve(real_t p_step) { +void PinJoint3DSW::solve(real_t p_step) { Vector3 pivotAInW = A->get_transform().xform(m_pivotInA); Vector3 pivotBInW = B->get_transform().xform(m_pivotInB); @@ -126,28 +126,28 @@ void PinJointSW::solve(real_t p_step) { } } -void PinJointSW::set_param(PhysicsServer::PinJointParam p_param, real_t p_value) { +void PinJoint3DSW::set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::PIN_JOINT_BIAS: m_tau = p_value; break; - case PhysicsServer::PIN_JOINT_DAMPING: m_damping = p_value; break; - case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP: m_impulseClamp = p_value; break; + case PhysicsServer3D::PIN_JOINT_BIAS: m_tau = p_value; break; + case PhysicsServer3D::PIN_JOINT_DAMPING: m_damping = p_value; break; + case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: m_impulseClamp = p_value; break; } } -real_t PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const { +real_t PinJoint3DSW::get_param(PhysicsServer3D::PinJointParam p_param) const { switch (p_param) { - case PhysicsServer::PIN_JOINT_BIAS: return m_tau; - case PhysicsServer::PIN_JOINT_DAMPING: return m_damping; - case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP: return m_impulseClamp; + case PhysicsServer3D::PIN_JOINT_BIAS: return m_tau; + case PhysicsServer3D::PIN_JOINT_DAMPING: return m_damping; + case PhysicsServer3D::PIN_JOINT_IMPULSE_CLAMP: return m_impulseClamp; } return 0; } -PinJointSW::PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b) : - JointSW(_arr, 2) { +PinJoint3DSW::PinJoint3DSW(Body3DSW *p_body_a, const Vector3 &p_pos_a, Body3DSW *p_body_b, const Vector3 &p_pos_b) : + Joint3DSW(_arr, 2) { A = p_body_a; B = p_body_b; @@ -163,5 +163,5 @@ PinJointSW::PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_ B->add_constraint(this, 1); } -PinJointSW::~PinJointSW() { +PinJoint3DSW::~PinJoint3DSW() { } diff --git a/servers/physics/joints/pin_joint_sw.h b/servers/physics_3d/joints/pin_joint_3d_sw.h index 42884e4940..8e81ccf5e0 100644 --- a/servers/physics/joints/pin_joint_sw.h +++ b/servers/physics_3d/joints/pin_joint_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* pin_joint_sw.h */ +/* pin_joint_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library. #ifndef PIN_JOINT_SW_H #define PIN_JOINT_SW_H -#include "servers/physics/joints/jacobian_entry_sw.h" -#include "servers/physics/joints_sw.h" +#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h" +#include "servers/physics_3d/joints_3d_sw.h" /* Bullet Continuous Collision Detection and Physics Library @@ -53,15 +53,15 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -class PinJointSW : public JointSW { +class PinJoint3DSW : public Joint3DSW { union { struct { - BodySW *A; - BodySW *B; + Body3DSW *A; + Body3DSW *B; }; - BodySW *_arr[2]; + Body3DSW *_arr[2]; }; real_t m_tau; //bias @@ -69,19 +69,19 @@ class PinJointSW : public JointSW { real_t m_impulseClamp; real_t m_appliedImpulse; - JacobianEntrySW m_jac[3]; //3 orthogonal linear constraints + JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints Vector3 m_pivotInA; Vector3 m_pivotInB; public: - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_PIN; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_PIN; } virtual bool setup(real_t p_step); virtual void solve(real_t p_step); - void set_param(PhysicsServer::PinJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::PinJointParam p_param) const; + void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::PinJointParam p_param) const; void set_pos_a(const Vector3 &p_pos) { m_pivotInA = p_pos; } void set_pos_b(const Vector3 &p_pos) { m_pivotInB = p_pos; } @@ -89,8 +89,8 @@ public: Vector3 get_position_a() { return m_pivotInA; } Vector3 get_position_b() { return m_pivotInB; } - PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b); - ~PinJointSW(); + PinJoint3DSW(Body3DSW *p_body_a, const Vector3 &p_pos_a, Body3DSW *p_body_b, const Vector3 &p_pos_b); + ~PinJoint3DSW(); }; #endif // PIN_JOINT_SW_H diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics_3d/joints/slider_joint_3d_sw.cpp index 9963c7ae89..066c30e0f3 100644 --- a/servers/physics/joints/slider_joint_sw.cpp +++ b/servers/physics_3d/joints/slider_joint_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* slider_joint_sw.cpp */ +/* slider_joint_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -53,7 +53,7 @@ April 04, 2008 */ -#include "slider_joint_sw.h" +#include "slider_joint_3d_sw.h" //----------------------------------------------------------------------------- @@ -72,7 +72,7 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) { return (y < 0.0f) ? -angle : angle; } -void SliderJointSW::initParams() { +void SliderJoint3DSW::initParams() { m_lowerLinLimit = real_t(1.0); m_upperLinLimit = real_t(-1.0); m_lowerAngLimit = real_t(0.); @@ -112,8 +112,8 @@ void SliderJointSW::initParams() { //----------------------------------------------------------------------------- -SliderJointSW::SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB) : - JointSW(_arr, 2), +SliderJoint3DSW::SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB) : + Joint3DSW(_arr, 2), m_frameInA(frameInA), m_frameInB(frameInB) { @@ -128,7 +128,7 @@ SliderJointSW::SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA //----------------------------------------------------------------------------- -bool SliderJointSW::setup(real_t p_step) { +bool SliderJoint3DSW::setup(real_t p_step) { //calculate transforms m_calculatedTransformA = A->get_transform() * m_frameInA; @@ -145,7 +145,7 @@ bool SliderJointSW::setup(real_t p_step) { //linear part for (i = 0; i < 3; i++) { normalWorld = m_calculatedTransformA.basis.get_axis(i); - memnew_placement(&m_jacLin[i], JacobianEntrySW( + memnew_placement(&m_jacLin[i], JacobianEntry3DSW( A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), m_relPosA - A->get_center_of_mass(), @@ -162,7 +162,7 @@ bool SliderJointSW::setup(real_t p_step) { // angular part for (i = 0; i < 3; i++) { normalWorld = m_calculatedTransformA.basis.get_axis(i); - memnew_placement(&m_jacAng[i], JacobianEntrySW( + memnew_placement(&m_jacAng[i], JacobianEntry3DSW( normalWorld, A->get_principal_inertia_axes().transposed(), B->get_principal_inertia_axes().transposed(), @@ -181,7 +181,7 @@ bool SliderJointSW::setup(real_t p_step) { //----------------------------------------------------------------------------- -void SliderJointSW::solve(real_t p_step) { +void SliderJoint3DSW::solve(real_t p_step) { int i; // linear @@ -304,7 +304,7 @@ void SliderJointSW::solve(real_t p_step) { //----------------------------------------------------------------------------- -void SliderJointSW::calculateTransforms(void) { +void SliderJoint3DSW::calculateTransforms(void) { m_calculatedTransformA = A->get_transform() * m_frameInA; m_calculatedTransformB = B->get_transform() * m_frameInB; m_realPivotAInW = m_calculatedTransformA.origin; @@ -323,7 +323,7 @@ void SliderJointSW::calculateTransforms(void) { //----------------------------------------------------------------------------- -void SliderJointSW::testLinLimits(void) { +void SliderJoint3DSW::testLinLimits(void) { m_solveLinLim = false; m_linPos = m_depth[0]; if (m_lowerLinLimit <= m_upperLinLimit) { @@ -343,7 +343,7 @@ void SliderJointSW::testLinLimits(void) { //----------------------------------------------------------------------------- -void SliderJointSW::testAngLimits(void) { +void SliderJoint3DSW::testAngLimits(void) { m_angDepth = real_t(0.); m_solveAngLim = false; if (m_lowerAngLimit <= m_upperAngLimit) { @@ -363,7 +363,7 @@ void SliderJointSW::testAngLimits(void) { //----------------------------------------------------------------------------- -Vector3 SliderJointSW::getAncorInA(void) { +Vector3 SliderJoint3DSW::getAncorInA(void) { Vector3 ancorInA; ancorInA = m_realPivotAInW + (m_lowerLinLimit + m_upperLinLimit) * real_t(0.5) * m_sliderAxis; ancorInA = A->get_transform().inverse().xform(ancorInA); @@ -372,71 +372,71 @@ Vector3 SliderJointSW::getAncorInA(void) { //----------------------------------------------------------------------------- -Vector3 SliderJointSW::getAncorInB(void) { +Vector3 SliderJoint3DSW::getAncorInB(void) { Vector3 ancorInB; ancorInB = m_frameInB.origin; return ancorInB; } // SliderJointSW::getAncorInB(); -void SliderJointSW::set_param(PhysicsServer::SliderJointParam p_param, real_t p_value) { +void SliderJoint3DSW::set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: m_upperLinLimit = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: m_lowerLinLimit = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: m_softnessLimLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: m_restitutionLimLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: m_dampingLimLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: m_softnessDirLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: m_restitutionDirLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: m_dampingDirLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoLin = p_value; break; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: m_dampingOrthoLin = p_value; break; - - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: m_upperAngLimit = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: m_lowerAngLimit = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: m_softnessLimAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: m_restitutionLimAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: m_dampingLimAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: m_softnessDirAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: m_restitutionDirAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: m_dampingDirAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoAng = p_value; break; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: m_dampingOrthoAng = p_value; break; - - case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: m_upperLinLimit = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: m_lowerLinLimit = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: m_softnessLimLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: m_restitutionLimLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: m_dampingLimLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: m_softnessDirLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: m_restitutionDirLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: m_dampingDirLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoLin = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: m_dampingOrthoLin = p_value; break; + + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: m_upperAngLimit = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: m_lowerAngLimit = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: m_softnessLimAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: m_restitutionLimAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: m_dampingLimAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: m_softnessDirAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: m_restitutionDirAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: m_dampingDirAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: m_softnessOrthoAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: m_restitutionOrthoAng = p_value; break; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: m_dampingOrthoAng = p_value; break; + + case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning } } -real_t SliderJointSW::get_param(PhysicsServer::SliderJointParam p_param) const { +real_t SliderJoint3DSW::get_param(PhysicsServer3D::SliderJointParam p_param) const { switch (p_param) { - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return m_upperLinLimit; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return m_lowerLinLimit; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return m_softnessLimLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return m_restitutionLimLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return m_dampingLimLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return m_softnessDirLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return m_restitutionDirLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return m_dampingDirLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoLin; - case PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return m_dampingOrthoLin; - - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return m_upperAngLimit; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return m_lowerAngLimit; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return m_softnessLimAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return m_restitutionLimAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return m_dampingLimAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return m_softnessDirAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return m_restitutionDirAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return m_dampingDirAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoAng; - case PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return m_dampingOrthoAng; - - case PhysicsServer::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_UPPER: return m_upperLinLimit; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_LOWER: return m_lowerLinLimit; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS: return m_softnessLimLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION: return m_restitutionLimLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_LIMIT_DAMPING: return m_dampingLimLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS: return m_softnessDirLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION: return m_restitutionDirLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_MOTION_DAMPING: return m_dampingDirLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoLin; + case PhysicsServer3D::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING: return m_dampingOrthoLin; + + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_UPPER: return m_upperAngLimit; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_LOWER: return m_lowerAngLimit; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS: return m_softnessLimAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION: return m_restitutionLimAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING: return m_dampingLimAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS: return m_softnessDirAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION: return m_restitutionDirAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_MOTION_DAMPING: return m_dampingDirAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS: return m_softnessOrthoAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION: return m_restitutionOrthoAng; + case PhysicsServer3D::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING: return m_dampingOrthoAng; + + case PhysicsServer3D::SLIDER_JOINT_MAX: break; // Can't happen, but silences warning } return 0; diff --git a/servers/physics/joints/slider_joint_sw.h b/servers/physics_3d/joints/slider_joint_3d_sw.h index 8b416eafc9..18287db9c2 100644 --- a/servers/physics/joints/slider_joint_sw.h +++ b/servers/physics_3d/joints/slider_joint_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* slider_joint_sw.h */ +/* slider_joint_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -35,8 +35,8 @@ Adapted to Godot from the Bullet library. #ifndef SLIDER_JOINT_SW_H #define SLIDER_JOINT_SW_H -#include "servers/physics/joints/jacobian_entry_sw.h" -#include "servers/physics/joints_sw.h" +#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h" +#include "servers/physics_3d/joints_3d_sw.h" /* Bullet Continuous Collision Detection and Physics Library @@ -65,15 +65,15 @@ April 04, 2008 //----------------------------------------------------------------------------- -class SliderJointSW : public JointSW { +class SliderJoint3DSW : public Joint3DSW { protected: union { struct { - BodySW *A; - BodySW *B; + Body3DSW *A; + Body3DSW *B; }; - BodySW *_arr[2]; + Body3DSW *_arr[2]; }; Transform m_frameInA; @@ -114,10 +114,10 @@ protected: bool m_solveLinLim; bool m_solveAngLim; - JacobianEntrySW m_jacLin[3]; + JacobianEntry3DSW m_jacLin[3]; real_t m_jacLinDiagABInv[3]; - JacobianEntrySW m_jacAng[3]; + JacobianEntry3DSW m_jacAng[3]; real_t m_timeStep; Transform m_calculatedTransformA; @@ -152,13 +152,13 @@ protected: public: // constructors - SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB); + SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB); //SliderJointSW(); // overrides // access - const BodySW *getRigidBodyA() const { return A; } - const BodySW *getRigidBodyB() const { return B; } + const Body3DSW *getRigidBodyA() const { return A; } + const Body3DSW *getRigidBodyB() const { return B; } const Transform &getCalculatedTransformA() const { return m_calculatedTransformA; } const Transform &getCalculatedTransformB() const { return m_calculatedTransformB; } const Transform &getFrameOffsetA() const { return m_frameInA; } @@ -237,13 +237,13 @@ public: Vector3 getAncorInA(void); Vector3 getAncorInB(void); - void set_param(PhysicsServer::SliderJointParam p_param, real_t p_value); - real_t get_param(PhysicsServer::SliderJointParam p_param) const; + void set_param(PhysicsServer3D::SliderJointParam p_param, real_t p_value); + real_t get_param(PhysicsServer3D::SliderJointParam p_param) const; bool setup(real_t p_step); void solve(real_t p_step); - virtual PhysicsServer::JointType get_type() const { return PhysicsServer::JOINT_SLIDER; } + virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_SLIDER; } }; #endif // SLIDER_JOINT_SW_H diff --git a/servers/physics/joints_sw.h b/servers/physics_3d/joints_3d_sw.h index c284d541e3..0f2d4892a8 100644 --- a/servers/physics/joints_sw.h +++ b/servers/physics_3d/joints_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joints_sw.h */ +/* joints_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,15 +31,15 @@ #ifndef JOINTS_SW_H #define JOINTS_SW_H -#include "body_sw.h" -#include "constraint_sw.h" +#include "body_3d_sw.h" +#include "constraint_3d_sw.h" -class JointSW : public ConstraintSW { +class Joint3DSW : public Constraint3DSW { public: - virtual PhysicsServer::JointType get_type() const = 0; - _FORCE_INLINE_ JointSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) : - ConstraintSW(p_body_ptr, p_body_count) { + virtual PhysicsServer3D::JointType get_type() const = 0; + _FORCE_INLINE_ Joint3DSW(Body3DSW **p_body_ptr = nullptr, int p_body_count = 0) : + Constraint3DSW(p_body_ptr, p_body_count) { } }; diff --git a/servers/physics_3d/physics_server_3d_sw.cpp b/servers/physics_3d/physics_server_3d_sw.cpp new file mode 100644 index 0000000000..bc42c2fd9e --- /dev/null +++ b/servers/physics_3d/physics_server_3d_sw.cpp @@ -0,0 +1,1589 @@ +/*************************************************************************/ +/* physics_server_3d_sw.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "physics_server_3d_sw.h" + +#include "broad_phase_3d_basic.h" +#include "broad_phase_octree.h" +#include "core/debugger/engine_debugger.h" +#include "core/os/os.h" +#include "joints/cone_twist_joint_3d_sw.h" +#include "joints/generic_6dof_joint_3d_sw.h" +#include "joints/hinge_joint_3d_sw.h" +#include "joints/pin_joint_3d_sw.h" +#include "joints/slider_joint_3d_sw.h" + +#define FLUSH_QUERY_CHECK(m_object) \ + ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead."); + +RID PhysicsServer3DSW::shape_create(ShapeType p_shape) { + + Shape3DSW *shape = nullptr; + switch (p_shape) { + + case SHAPE_PLANE: { + + shape = memnew(PlaneShape3DSW); + } break; + case SHAPE_RAY: { + + shape = memnew(RayShape3DSW); + } break; + case SHAPE_SPHERE: { + + shape = memnew(SphereShape3DSW); + } break; + case SHAPE_BOX: { + + shape = memnew(BoxShape3DSW); + } break; + case SHAPE_CAPSULE: { + + shape = memnew(CapsuleShape3DSW); + } break; + case SHAPE_CYLINDER: { + + ERR_FAIL_V_MSG(RID(), "CylinderShape3D is not supported in GodotPhysics. Please switch to Bullet in the Project Settings."); + } break; + case SHAPE_CONVEX_POLYGON: { + + shape = memnew(ConvexPolygonShape3DSW); + } break; + case SHAPE_CONCAVE_POLYGON: { + + shape = memnew(ConcavePolygonShape3DSW); + } break; + case SHAPE_HEIGHTMAP: { + + shape = memnew(HeightMapShape3DSW); + } break; + case SHAPE_CUSTOM: { + + ERR_FAIL_V(RID()); + + } break; + } + + RID id = shape_owner.make_rid(shape); + shape->set_self(id); + + return id; +}; + +void PhysicsServer3DSW::shape_set_data(RID p_shape, const Variant &p_data) { + + Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND(!shape); + shape->set_data(p_data); +}; + +void PhysicsServer3DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { + + Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND(!shape); + shape->set_custom_bias(p_bias); +} + +PhysicsServer3D::ShapeType PhysicsServer3DSW::shape_get_type(RID p_shape) const { + + const Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM); + return shape->get_type(); +}; + +Variant PhysicsServer3DSW::shape_get_data(RID p_shape) const { + + const Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND_V(!shape, Variant()); + ERR_FAIL_COND_V(!shape->is_configured(), Variant()); + return shape->get_data(); +}; + +void PhysicsServer3DSW::shape_set_margin(RID p_shape, real_t p_margin) { +} + +real_t PhysicsServer3DSW::shape_get_margin(RID p_shape) const { + return 0.0; +} + +real_t PhysicsServer3DSW::shape_get_custom_solver_bias(RID p_shape) const { + + const Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND_V(!shape, 0); + return shape->get_custom_bias(); +} + +RID PhysicsServer3DSW::space_create() { + + Space3DSW *space = memnew(Space3DSW); + RID id = space_owner.make_rid(space); + space->set_self(id); + RID area_id = area_create(); + Area3DSW *area = area_owner.getornull(area_id); + ERR_FAIL_COND_V(!area, RID()); + space->set_default_area(area); + area->set_space(space); + area->set_priority(-1); + RID sgb = body_create(); + body_set_space(sgb, id); + body_set_mode(sgb, BODY_MODE_STATIC); + space->set_static_global_body(sgb); + + return id; +}; + +void PhysicsServer3DSW::space_set_active(RID p_space, bool p_active) { + + Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND(!space); + if (p_active) + active_spaces.insert(space); + else + active_spaces.erase(space); +} + +bool PhysicsServer3DSW::space_is_active(RID p_space) const { + + const Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND_V(!space, false); + + return active_spaces.has(space); +} + +void PhysicsServer3DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { + + Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND(!space); + + space->set_param(p_param, p_value); +} + +real_t PhysicsServer3DSW::space_get_param(RID p_space, SpaceParameter p_param) const { + + const Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND_V(!space, 0); + return space->get_param(p_param); +} + +PhysicsDirectSpaceState3D *PhysicsServer3DSW::space_get_direct_state(RID p_space) { + + Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND_V(!space, nullptr); + ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification."); + + return space->get_direct_state(); +} + +void PhysicsServer3DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) { + + Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND(!space); + space->set_debug_contacts(p_max_contacts); +} + +Vector<Vector3> PhysicsServer3DSW::space_get_contacts(RID p_space) const { + + Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND_V(!space, Vector<Vector3>()); + return space->get_debug_contacts(); +} + +int PhysicsServer3DSW::space_get_contact_count(RID p_space) const { + + Space3DSW *space = space_owner.getornull(p_space); + ERR_FAIL_COND_V(!space, 0); + return space->get_debug_contact_count(); +} + +RID PhysicsServer3DSW::area_create() { + + Area3DSW *area = memnew(Area3DSW); + RID rid = area_owner.make_rid(area); + area->set_self(rid); + return rid; +}; + +void PhysicsServer3DSW::area_set_space(RID p_area, RID p_space) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + Space3DSW *space = nullptr; + if (p_space.is_valid()) { + space = space_owner.getornull(p_space); + ERR_FAIL_COND(!space); + } + + if (area->get_space() == space) + return; //pointless + + area->clear_constraints(); + area->set_space(space); +}; + +RID PhysicsServer3DSW::area_get_space(RID p_area) const { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, RID()); + + Space3DSW *space = area->get_space(); + if (!space) + return RID(); + return space->get_self(); +}; + +void PhysicsServer3DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_space_override_mode(p_mode); +} + +PhysicsServer3D::AreaSpaceOverrideMode PhysicsServer3DSW::area_get_space_override_mode(RID p_area) const { + + const Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED); + + return area->get_space_override_mode(); +} + +void PhysicsServer3DSW::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform, bool p_disabled) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND(!shape); + + area->add_shape(shape, p_transform, p_disabled); +} + +void PhysicsServer3DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND(!shape); + ERR_FAIL_COND(!shape->is_configured()); + + area->set_shape(p_shape_idx, shape); +} + +void PhysicsServer3DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform &p_transform) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_shape_transform(p_shape_idx, p_transform); +} + +int PhysicsServer3DSW::area_get_shape_count(RID p_area) const { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, -1); + + return area->get_shape_count(); +} +RID PhysicsServer3DSW::area_get_shape(RID p_area, int p_shape_idx) const { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, RID()); + + Shape3DSW *shape = area->get_shape(p_shape_idx); + ERR_FAIL_COND_V(!shape, RID()); + + return shape->get_self(); +} +Transform PhysicsServer3DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, Transform()); + + return area->get_shape_transform(p_shape_idx); +} + +void PhysicsServer3DSW::area_remove_shape(RID p_area, int p_shape_idx) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->remove_shape(p_shape_idx); +} + +void PhysicsServer3DSW::area_clear_shapes(RID p_area) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + while (area->get_shape_count()) + area->remove_shape(0); +} + +void PhysicsServer3DSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count()); + FLUSH_QUERY_CHECK(area); + area->set_shape_as_disabled(p_shape_idx, p_disabled); +} + +void PhysicsServer3DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) { + + if (space_owner.owns(p_area)) { + Space3DSW *space = space_owner.getornull(p_area); + p_area = space->get_default_area()->get_self(); + } + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + area->set_instance_id(p_id); +} +ObjectID PhysicsServer3DSW::area_get_object_instance_id(RID p_area) const { + + if (space_owner.owns(p_area)) { + Space3DSW *space = space_owner.getornull(p_area); + p_area = space->get_default_area()->get_self(); + } + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, ObjectID()); + return area->get_instance_id(); +} + +void PhysicsServer3DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { + + if (space_owner.owns(p_area)) { + Space3DSW *space = space_owner.getornull(p_area); + p_area = space->get_default_area()->get_self(); + } + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + area->set_param(p_param, p_value); +}; + +void PhysicsServer3DSW::area_set_transform(RID p_area, const Transform &p_transform) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + area->set_transform(p_transform); +}; + +Variant PhysicsServer3DSW::area_get_param(RID p_area, AreaParameter p_param) const { + + if (space_owner.owns(p_area)) { + Space3DSW *space = space_owner.getornull(p_area); + p_area = space->get_default_area()->get_self(); + } + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, Variant()); + + return area->get_param(p_param); +}; + +Transform PhysicsServer3DSW::area_get_transform(RID p_area) const { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, Transform()); + + return area->get_transform(); +}; + +void PhysicsServer3DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_collision_layer(p_layer); +} + +void PhysicsServer3DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_collision_mask(p_mask); +} + +void PhysicsServer3DSW::area_set_monitorable(RID p_area, bool p_monitorable) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + FLUSH_QUERY_CHECK(area); + + area->set_monitorable(p_monitorable); +} + +void PhysicsServer3DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); +} + +void PhysicsServer3DSW::area_set_ray_pickable(RID p_area, bool p_enable) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_ray_pickable(p_enable); +} + +bool PhysicsServer3DSW::area_is_ray_pickable(RID p_area) const { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND_V(!area, false); + + return area->is_ray_pickable(); +} + +void PhysicsServer3DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { + + Area3DSW *area = area_owner.getornull(p_area); + ERR_FAIL_COND(!area); + + area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); +} + +/* BODY API */ + +RID PhysicsServer3DSW::body_create(BodyMode p_mode, bool p_init_sleeping) { + + Body3DSW *body = memnew(Body3DSW); + if (p_mode != BODY_MODE_RIGID) + body->set_mode(p_mode); + if (p_init_sleeping) + body->set_state(BODY_STATE_SLEEPING, p_init_sleeping); + RID rid = body_owner.make_rid(body); + body->set_self(rid); + return rid; +}; + +void PhysicsServer3DSW::body_set_space(RID p_body, RID p_space) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + Space3DSW *space = nullptr; + if (p_space.is_valid()) { + space = space_owner.getornull(p_space); + ERR_FAIL_COND(!space); + } + + if (body->get_space() == space) + return; //pointless + + body->clear_constraint_map(); + body->set_space(space); +}; + +RID PhysicsServer3DSW::body_get_space(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, RID()); + + Space3DSW *space = body->get_space(); + if (!space) + return RID(); + return space->get_self(); +}; + +void PhysicsServer3DSW::body_set_mode(RID p_body, BodyMode p_mode) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_mode(p_mode); +}; + +PhysicsServer3D::BodyMode PhysicsServer3DSW::body_get_mode(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, BODY_MODE_STATIC); + + return body->get_mode(); +}; + +void PhysicsServer3DSW::body_add_shape(RID p_body, RID p_shape, const Transform &p_transform, bool p_disabled) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND(!shape); + + body->add_shape(shape, p_transform, p_disabled); +} + +void PhysicsServer3DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + Shape3DSW *shape = shape_owner.getornull(p_shape); + ERR_FAIL_COND(!shape); + ERR_FAIL_COND(!shape->is_configured()); + + body->set_shape(p_shape_idx, shape); +} +void PhysicsServer3DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform &p_transform) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_shape_transform(p_shape_idx, p_transform); +} + +int PhysicsServer3DSW::body_get_shape_count(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, -1); + + return body->get_shape_count(); +} +RID PhysicsServer3DSW::body_get_shape(RID p_body, int p_shape_idx) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, RID()); + + Shape3DSW *shape = body->get_shape(p_shape_idx); + ERR_FAIL_COND_V(!shape, RID()); + + return shape->get_self(); +} + +void PhysicsServer3DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); + FLUSH_QUERY_CHECK(body); + + body->set_shape_as_disabled(p_shape_idx, p_disabled); +} + +Transform PhysicsServer3DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, Transform()); + + return body->get_shape_transform(p_shape_idx); +} + +void PhysicsServer3DSW::body_remove_shape(RID p_body, int p_shape_idx) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->remove_shape(p_shape_idx); +} + +void PhysicsServer3DSW::body_clear_shapes(RID p_body) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + while (body->get_shape_count()) + body->remove_shape(0); +} + +void PhysicsServer3DSW::body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_continuous_collision_detection(p_enable); +} + +bool PhysicsServer3DSW::body_is_continuous_collision_detection_enabled(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, false); + + return body->is_continuous_collision_detection_enabled(); +} + +void PhysicsServer3DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_collision_layer(p_layer); + body->wakeup(); +} + +uint32_t PhysicsServer3DSW::body_get_collision_layer(RID p_body) const { + + const Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + + return body->get_collision_layer(); +} + +void PhysicsServer3DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_collision_mask(p_mask); + body->wakeup(); +} + +uint32_t PhysicsServer3DSW::body_get_collision_mask(RID p_body) const { + + const Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + + return body->get_collision_mask(); +} + +void PhysicsServer3DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_instance_id(p_id); +}; + +ObjectID PhysicsServer3DSW::body_get_object_instance_id(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, ObjectID()); + + return body->get_instance_id(); +}; + +void PhysicsServer3DSW::body_set_user_flags(RID p_body, uint32_t p_flags) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); +}; + +uint32_t PhysicsServer3DSW::body_get_user_flags(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + + return 0; +}; + +void PhysicsServer3DSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_param(p_param, p_value); +}; + +real_t PhysicsServer3DSW::body_get_param(RID p_body, BodyParameter p_param) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + + return body->get_param(p_param); +}; + +void PhysicsServer3DSW::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + body->set_kinematic_margin(p_margin); +} + +real_t PhysicsServer3DSW::body_get_kinematic_safe_margin(RID p_body) const { + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + + return body->get_kinematic_margin(); +} + +void PhysicsServer3DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_state(p_state, p_variant); +}; + +Variant PhysicsServer3DSW::body_get_state(RID p_body, BodyState p_state) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, Variant()); + + return body->get_state(p_state); +}; + +void PhysicsServer3DSW::body_set_applied_force(RID p_body, const Vector3 &p_force) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_applied_force(p_force); + body->wakeup(); +}; + +Vector3 PhysicsServer3DSW::body_get_applied_force(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, Vector3()); + return body->get_applied_force(); +}; + +void PhysicsServer3DSW::body_set_applied_torque(RID p_body, const Vector3 &p_torque) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_applied_torque(p_torque); + body->wakeup(); +}; + +Vector3 PhysicsServer3DSW::body_get_applied_torque(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, Vector3()); + + return body->get_applied_torque(); +}; + +void PhysicsServer3DSW::body_add_central_force(RID p_body, const Vector3 &p_force) { + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->add_central_force(p_force); + body->wakeup(); +} + +void PhysicsServer3DSW::body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_pos) { + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->add_force(p_force, p_pos); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_add_torque(RID p_body, const Vector3 &p_torque) { + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->add_torque(p_torque); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) { + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + _update_shapes(); + + body->apply_central_impulse(p_impulse); + body->wakeup(); +} + +void PhysicsServer3DSW::body_apply_impulse(RID p_body, const Vector3 &p_pos, const Vector3 &p_impulse) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + _update_shapes(); + + body->apply_impulse(p_pos, p_impulse); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + _update_shapes(); + + body->apply_torque_impulse(p_impulse); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + _update_shapes(); + + Vector3 v = body->get_linear_velocity(); + Vector3 axis = p_axis_velocity.normalized(); + v -= axis * axis.dot(v); + v += p_axis_velocity; + body->set_linear_velocity(v); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_axis_lock(p_axis, p_lock); + body->wakeup(); +} + +bool PhysicsServer3DSW::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { + + const Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + return body->is_axis_locked(p_axis); +} + +void PhysicsServer3DSW::body_add_collision_exception(RID p_body, RID p_body_b) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->add_exception(p_body_b); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_remove_collision_exception(RID p_body, RID p_body_b) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->remove_exception(p_body_b); + body->wakeup(); +}; + +void PhysicsServer3DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + for (int i = 0; i < body->get_exceptions().size(); i++) { + p_exceptions->push_back(body->get_exceptions()[i]); + } +}; + +void PhysicsServer3DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); +}; + +real_t PhysicsServer3DSW::body_get_contacts_reported_depth_threshold(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, 0); + return 0; +}; + +void PhysicsServer3DSW::body_set_omit_force_integration(RID p_body, bool p_omit) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + + body->set_omit_force_integration(p_omit); +}; + +bool PhysicsServer3DSW::body_is_omitting_force_integration(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, false); + return body->get_omit_force_integration(); +}; + +void PhysicsServer3DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + body->set_max_contacts_reported(p_contacts); +} + +int PhysicsServer3DSW::body_get_max_contacts_reported(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, -1); + return body->get_max_contacts_reported(); +} + +void PhysicsServer3DSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata); +} + +void PhysicsServer3DSW::body_set_ray_pickable(RID p_body, bool p_enable) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND(!body); + body->set_ray_pickable(p_enable); +} + +bool PhysicsServer3DSW::body_is_ray_pickable(RID p_body) const { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, false); + return body->is_ray_pickable(); +} + +bool PhysicsServer3DSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result, bool p_exclude_raycast_shapes) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, false); + ERR_FAIL_COND_V(!body->get_space(), false); + ERR_FAIL_COND_V(body->get_space()->is_locked(), false); + + _update_shapes(); + + return body->get_space()->test_body_motion(body, p_from, p_motion, p_infinite_inertia, body->get_kinematic_margin(), r_result, p_exclude_raycast_shapes); +} + +int PhysicsServer3DSW::body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, false); + ERR_FAIL_COND_V(!body->get_space(), false); + ERR_FAIL_COND_V(body->get_space()->is_locked(), false); + + _update_shapes(); + + return body->get_space()->test_body_ray_separation(body, p_transform, p_infinite_inertia, r_recover_motion, r_results, p_result_max, p_margin); +} + +PhysicsDirectBodyState3D *PhysicsServer3DSW::body_get_direct_state(RID p_body) { + + Body3DSW *body = body_owner.getornull(p_body); + ERR_FAIL_COND_V(!body, nullptr); + ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification."); + + direct_state->body = body; + return direct_state; +} + +/* JOINT API */ + +RID PhysicsServer3DSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) { + + Body3DSW *body_A = body_owner.getornull(p_body_A); + ERR_FAIL_COND_V(!body_A, RID()); + + if (!p_body_B.is_valid()) { + ERR_FAIL_COND_V(!body_A->get_space(), RID()); + p_body_B = body_A->get_space()->get_static_global_body(); + } + + Body3DSW *body_B = body_owner.getornull(p_body_B); + ERR_FAIL_COND_V(!body_B, RID()); + + ERR_FAIL_COND_V(body_A == body_B, RID()); + + Joint3DSW *joint = memnew(PinJoint3DSW(body_A, p_local_A, body_B, p_local_B)); + RID rid = joint_owner.make_rid(joint); + joint->set_self(rid); + return rid; +} + +void PhysicsServer3DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_PIN); + PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint); + pin_joint->set_param(p_param, p_value); +} +real_t PhysicsServer3DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, 0); + ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0); + PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint); + return pin_joint->get_param(p_param); +} + +void PhysicsServer3DSW::pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_PIN); + PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint); + pin_joint->set_pos_a(p_A); +} +Vector3 PhysicsServer3DSW::pin_joint_get_local_a(RID p_joint) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, Vector3()); + ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); + PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint); + return pin_joint->get_position_a(); +} + +void PhysicsServer3DSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_PIN); + PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint); + pin_joint->set_pos_b(p_B); +} +Vector3 PhysicsServer3DSW::pin_joint_get_local_b(RID p_joint) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, Vector3()); + ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); + PinJoint3DSW *pin_joint = static_cast<PinJoint3DSW *>(joint); + return pin_joint->get_position_b(); +} + +RID PhysicsServer3DSW::joint_create_hinge(RID p_body_A, const Transform &p_frame_A, RID p_body_B, const Transform &p_frame_B) { + + Body3DSW *body_A = body_owner.getornull(p_body_A); + ERR_FAIL_COND_V(!body_A, RID()); + + if (!p_body_B.is_valid()) { + ERR_FAIL_COND_V(!body_A->get_space(), RID()); + p_body_B = body_A->get_space()->get_static_global_body(); + } + + Body3DSW *body_B = body_owner.getornull(p_body_B); + ERR_FAIL_COND_V(!body_B, RID()); + + ERR_FAIL_COND_V(body_A == body_B, RID()); + + Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_frame_A, p_frame_B)); + RID rid = joint_owner.make_rid(joint); + joint->set_self(rid); + return rid; +} + +RID PhysicsServer3DSW::joint_create_hinge_simple(RID p_body_A, const Vector3 &p_pivot_A, const Vector3 &p_axis_A, RID p_body_B, const Vector3 &p_pivot_B, const Vector3 &p_axis_B) { + + Body3DSW *body_A = body_owner.getornull(p_body_A); + ERR_FAIL_COND_V(!body_A, RID()); + + if (!p_body_B.is_valid()) { + ERR_FAIL_COND_V(!body_A->get_space(), RID()); + p_body_B = body_A->get_space()->get_static_global_body(); + } + + Body3DSW *body_B = body_owner.getornull(p_body_B); + ERR_FAIL_COND_V(!body_B, RID()); + + ERR_FAIL_COND_V(body_A == body_B, RID()); + + Joint3DSW *joint = memnew(HingeJoint3DSW(body_A, body_B, p_pivot_A, p_pivot_B, p_axis_A, p_axis_B)); + RID rid = joint_owner.make_rid(joint); + joint->set_self(rid); + return rid; +} + +void PhysicsServer3DSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); + HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint); + hinge_joint->set_param(p_param, p_value); +} +real_t PhysicsServer3DSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, 0); + ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0); + HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint); + return hinge_joint->get_param(p_param); +} + +void PhysicsServer3DSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); + HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint); + hinge_joint->set_flag(p_flag, p_value); +} +bool PhysicsServer3DSW::hinge_joint_get_flag(RID p_joint, HingeJointFlag p_flag) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, false); + ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, false); + HingeJoint3DSW *hinge_joint = static_cast<HingeJoint3DSW *>(joint); + return hinge_joint->get_flag(p_flag); +} + +void PhysicsServer3DSW::joint_set_solver_priority(RID p_joint, int p_priority) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + joint->set_priority(p_priority); +} + +int PhysicsServer3DSW::joint_get_solver_priority(RID p_joint) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, 0); + return joint->get_priority(); +} + +void PhysicsServer3DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + + joint->disable_collisions_between_bodies(p_disable); + + if (2 == joint->get_body_count()) { + Body3DSW *body_a = *joint->get_body_ptr(); + Body3DSW *body_b = *(joint->get_body_ptr() + 1); + + if (p_disable) { + body_add_collision_exception(body_a->get_self(), body_b->get_self()); + body_add_collision_exception(body_b->get_self(), body_a->get_self()); + } else { + body_remove_collision_exception(body_a->get_self(), body_b->get_self()); + body_remove_collision_exception(body_b->get_self(), body_a->get_self()); + } + } +} + +bool PhysicsServer3DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const { + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, true); + + return joint->is_disabled_collisions_between_bodies(); +} + +PhysicsServer3DSW::JointType PhysicsServer3DSW::joint_get_type(RID p_joint) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, JOINT_PIN); + return joint->get_type(); +} + +RID PhysicsServer3DSW::joint_create_slider(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { + + Body3DSW *body_A = body_owner.getornull(p_body_A); + ERR_FAIL_COND_V(!body_A, RID()); + + if (!p_body_B.is_valid()) { + ERR_FAIL_COND_V(!body_A->get_space(), RID()); + p_body_B = body_A->get_space()->get_static_global_body(); + } + + Body3DSW *body_B = body_owner.getornull(p_body_B); + ERR_FAIL_COND_V(!body_B, RID()); + + ERR_FAIL_COND_V(body_A == body_B, RID()); + + Joint3DSW *joint = memnew(SliderJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B)); + RID rid = joint_owner.make_rid(joint); + joint->set_self(rid); + return rid; +} + +void PhysicsServer3DSW::slider_joint_set_param(RID p_joint, SliderJointParam p_param, real_t p_value) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_SLIDER); + SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint); + slider_joint->set_param(p_param, p_value); +} +real_t PhysicsServer3DSW::slider_joint_get_param(RID p_joint, SliderJointParam p_param) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, 0); + ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0); + SliderJoint3DSW *slider_joint = static_cast<SliderJoint3DSW *>(joint); + return slider_joint->get_param(p_param); +} + +RID PhysicsServer3DSW::joint_create_cone_twist(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { + + Body3DSW *body_A = body_owner.getornull(p_body_A); + ERR_FAIL_COND_V(!body_A, RID()); + + if (!p_body_B.is_valid()) { + ERR_FAIL_COND_V(!body_A->get_space(), RID()); + p_body_B = body_A->get_space()->get_static_global_body(); + } + + Body3DSW *body_B = body_owner.getornull(p_body_B); + ERR_FAIL_COND_V(!body_B, RID()); + + ERR_FAIL_COND_V(body_A == body_B, RID()); + + Joint3DSW *joint = memnew(ConeTwistJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B)); + RID rid = joint_owner.make_rid(joint); + joint->set_self(rid); + return rid; +} + +void PhysicsServer3DSW::cone_twist_joint_set_param(RID p_joint, ConeTwistJointParam p_param, real_t p_value) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_CONE_TWIST); + ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint); + cone_twist_joint->set_param(p_param, p_value); +} +real_t PhysicsServer3DSW::cone_twist_joint_get_param(RID p_joint, ConeTwistJointParam p_param) const { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, 0); + ERR_FAIL_COND_V(joint->get_type() != JOINT_CONE_TWIST, 0); + ConeTwistJoint3DSW *cone_twist_joint = static_cast<ConeTwistJoint3DSW *>(joint); + return cone_twist_joint->get_param(p_param); +} + +RID PhysicsServer3DSW::joint_create_generic_6dof(RID p_body_A, const Transform &p_local_frame_A, RID p_body_B, const Transform &p_local_frame_B) { + + Body3DSW *body_A = body_owner.getornull(p_body_A); + ERR_FAIL_COND_V(!body_A, RID()); + + if (!p_body_B.is_valid()) { + ERR_FAIL_COND_V(!body_A->get_space(), RID()); + p_body_B = body_A->get_space()->get_static_global_body(); + } + + Body3DSW *body_B = body_owner.getornull(p_body_B); + ERR_FAIL_COND_V(!body_B, RID()); + + ERR_FAIL_COND_V(body_A == body_B, RID()); + + Joint3DSW *joint = memnew(Generic6DOFJoint3DSW(body_A, body_B, p_local_frame_A, p_local_frame_B, true)); + RID rid = joint_owner.make_rid(joint); + joint->set_self(rid); + return rid; +} + +void PhysicsServer3DSW::generic_6dof_joint_set_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param, real_t p_value) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); + Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint); + generic_6dof_joint->set_param(p_axis, p_param, p_value); +} +real_t PhysicsServer3DSW::generic_6dof_joint_get_param(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisParam p_param) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, 0); + ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0); + Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint); + return generic_6dof_joint->get_param(p_axis, p_param); +} + +void PhysicsServer3DSW::generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND(!joint); + ERR_FAIL_COND(joint->get_type() != JOINT_6DOF); + Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint); + generic_6dof_joint->set_flag(p_axis, p_flag, p_enable); +} +bool PhysicsServer3DSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag) { + + Joint3DSW *joint = joint_owner.getornull(p_joint); + ERR_FAIL_COND_V(!joint, false); + ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, false); + Generic6DOFJoint3DSW *generic_6dof_joint = static_cast<Generic6DOFJoint3DSW *>(joint); + return generic_6dof_joint->get_flag(p_axis, p_flag); +} + +void PhysicsServer3DSW::free(RID p_rid) { + + _update_shapes(); //just in case + + if (shape_owner.owns(p_rid)) { + + Shape3DSW *shape = shape_owner.getornull(p_rid); + + while (shape->get_owners().size()) { + ShapeOwner3DSW *so = shape->get_owners().front()->key(); + so->remove_shape(shape); + } + + shape_owner.free(p_rid); + memdelete(shape); + } else if (body_owner.owns(p_rid)) { + + Body3DSW *body = body_owner.getornull(p_rid); + + /* + if (body->get_state_query()) + _clear_query(body->get_state_query()); + + if (body->get_direct_state_query()) + _clear_query(body->get_direct_state_query()); + */ + + body->set_space(nullptr); + + while (body->get_shape_count()) { + + body->remove_shape(0); + } + + body_owner.free(p_rid); + memdelete(body); + + } else if (area_owner.owns(p_rid)) { + + Area3DSW *area = area_owner.getornull(p_rid); + + /* + if (area->get_monitor_query()) + _clear_query(area->get_monitor_query()); + */ + + area->set_space(nullptr); + + while (area->get_shape_count()) { + + area->remove_shape(0); + } + + area_owner.free(p_rid); + memdelete(area); + } else if (space_owner.owns(p_rid)) { + + Space3DSW *space = space_owner.getornull(p_rid); + + while (space->get_objects().size()) { + CollisionObject3DSW *co = (CollisionObject3DSW *)space->get_objects().front()->get(); + co->set_space(nullptr); + } + + active_spaces.erase(space); + free(space->get_default_area()->get_self()); + free(space->get_static_global_body()); + + space_owner.free(p_rid); + memdelete(space); + } else if (joint_owner.owns(p_rid)) { + + Joint3DSW *joint = joint_owner.getornull(p_rid); + + for (int i = 0; i < joint->get_body_count(); i++) { + + joint->get_body_ptr()[i]->remove_constraint(joint); + } + joint_owner.free(p_rid); + memdelete(joint); + + } else { + + ERR_FAIL_MSG("Invalid ID."); + } +}; + +void PhysicsServer3DSW::set_active(bool p_active) { + + active = p_active; +}; + +void PhysicsServer3DSW::init() { + + doing_sync = true; + last_step = 0.001; + iterations = 8; // 8? + stepper = memnew(Step3DSW); + direct_state = memnew(PhysicsDirectBodyState3DSW); +}; + +void PhysicsServer3DSW::step(real_t p_step) { + +#ifndef _3D_DISABLED + + if (!active) + return; + + _update_shapes(); + + doing_sync = false; + + last_step = p_step; + PhysicsDirectBodyState3DSW::singleton->step = p_step; + + island_count = 0; + active_objects = 0; + collision_pairs = 0; + for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) { + + stepper->step((Space3DSW *)E->get(), p_step, iterations); + island_count += E->get()->get_island_count(); + active_objects += E->get()->get_active_objects(); + collision_pairs += E->get()->get_collision_pairs(); + } +#endif +} + +void PhysicsServer3DSW::sync(){ + +}; + +void PhysicsServer3DSW::flush_queries() { + +#ifndef _3D_DISABLED + + if (!active) + return; + + doing_sync = true; + + flushing_queries = true; + + uint64_t time_beg = OS::get_singleton()->get_ticks_usec(); + + for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) { + + Space3DSW *space = (Space3DSW *)E->get(); + space->call_queries(); + } + + flushing_queries = false; + + if (EngineDebugger::is_profiling("servers")) { + + uint64_t total_time[Space3DSW::ELAPSED_TIME_MAX]; + static const char *time_name[Space3DSW::ELAPSED_TIME_MAX] = { + "integrate_forces", + "generate_islands", + "setup_constraints", + "solve_constraints", + "integrate_velocities" + }; + + for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) { + total_time[i] = 0; + } + + for (Set<const Space3DSW *>::Element *E = active_spaces.front(); E; E = E->next()) { + + for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) { + total_time[i] += E->get()->get_elapsed_time(Space3DSW::ElapsedTime(i)); + } + } + + Array values; + values.resize(Space3DSW::ELAPSED_TIME_MAX * 2); + for (int i = 0; i < Space3DSW::ELAPSED_TIME_MAX; i++) { + values[i * 2 + 0] = time_name[i]; + values[i * 2 + 1] = USEC_TO_SEC(total_time[i]); + } + values.push_back("flush_queries"); + values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec() - time_beg)); + + values.push_front("physics"); + EngineDebugger::profiler_add_frame_data("server", values); + } +#endif +}; + +void PhysicsServer3DSW::finish() { + + memdelete(stepper); + memdelete(direct_state); +}; + +int PhysicsServer3DSW::get_process_info(ProcessInfo p_info) { + + switch (p_info) { + + case INFO_ACTIVE_OBJECTS: { + + return active_objects; + } break; + case INFO_COLLISION_PAIRS: { + return collision_pairs; + } break; + case INFO_ISLAND_COUNT: { + + return island_count; + } break; + } + + return 0; +} + +void PhysicsServer3DSW::_update_shapes() { + + while (pending_shape_update_list.first()) { + pending_shape_update_list.first()->self()->_shape_changed(); + pending_shape_update_list.remove(pending_shape_update_list.first()); + } +} + +void PhysicsServer3DSW::_shape_col_cbk(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) { + + CollCbkData *cbk = (CollCbkData *)p_userdata; + + if (cbk->max == 0) + return; + + if (cbk->amount == cbk->max) { + //find least deep + real_t min_depth = 1e20; + int min_depth_idx = 0; + for (int i = 0; i < cbk->amount; i++) { + + real_t d = cbk->ptr[i * 2 + 0].distance_squared_to(cbk->ptr[i * 2 + 1]); + if (d < min_depth) { + min_depth = d; + min_depth_idx = i; + } + } + + real_t d = p_point_A.distance_squared_to(p_point_B); + if (d < min_depth) + return; + cbk->ptr[min_depth_idx * 2 + 0] = p_point_A; + cbk->ptr[min_depth_idx * 2 + 1] = p_point_B; + + } else { + + cbk->ptr[cbk->amount * 2 + 0] = p_point_A; + cbk->ptr[cbk->amount * 2 + 1] = p_point_B; + cbk->amount++; + } +} + +PhysicsServer3DSW *PhysicsServer3DSW::singleton = nullptr; +PhysicsServer3DSW::PhysicsServer3DSW() { + singleton = this; + BroadPhase3DSW::create_func = BroadPhaseOctree::_create; + island_count = 0; + active_objects = 0; + collision_pairs = 0; + + active = true; + flushing_queries = false; +}; + +PhysicsServer3DSW::~PhysicsServer3DSW(){ + +}; diff --git a/servers/physics/physics_server_sw.h b/servers/physics_3d/physics_server_3d_sw.h index 459c7688f0..6e79d9eceb 100644 --- a/servers/physics/physics_server_sw.h +++ b/servers/physics_3d/physics_server_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_server_sw.h */ +/* physics_server_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -32,17 +32,17 @@ #define PHYSICS_SERVER_SW #include "core/rid_owner.h" -#include "joints_sw.h" -#include "servers/physics_server.h" -#include "shape_sw.h" -#include "space_sw.h" -#include "step_sw.h" +#include "joints_3d_sw.h" +#include "servers/physics_server_3d.h" +#include "shape_3d_sw.h" +#include "space_3d_sw.h" +#include "step_3d_sw.h" -class PhysicsServerSW : public PhysicsServer { +class PhysicsServer3DSW : public PhysicsServer3D { - GDCLASS(PhysicsServerSW, PhysicsServer); + GDCLASS(PhysicsServer3DSW, PhysicsServer3D); - friend class PhysicsDirectSpaceStateSW; + friend class PhysicsDirectSpaceState3DSW; bool active; int iterations; bool doing_sync; @@ -54,24 +54,24 @@ class PhysicsServerSW : public PhysicsServer { bool flushing_queries; - StepSW *stepper; - Set<const SpaceSW *> active_spaces; + Step3DSW *stepper; + Set<const Space3DSW *> active_spaces; - PhysicsDirectBodyStateSW *direct_state; + PhysicsDirectBodyState3DSW *direct_state; - mutable RID_PtrOwner<ShapeSW> shape_owner; - mutable RID_PtrOwner<SpaceSW> space_owner; - mutable RID_PtrOwner<AreaSW> area_owner; - mutable RID_PtrOwner<BodySW> body_owner; - mutable RID_PtrOwner<JointSW> joint_owner; + mutable RID_PtrOwner<Shape3DSW> shape_owner; + mutable RID_PtrOwner<Space3DSW> space_owner; + mutable RID_PtrOwner<Area3DSW> area_owner; + mutable RID_PtrOwner<Body3DSW> body_owner; + mutable RID_PtrOwner<Joint3DSW> joint_owner; //void _clear_query(QuerySW *p_query); - friend class CollisionObjectSW; - SelfList<CollisionObjectSW>::List pending_shape_update_list; + friend class CollisionObject3DSW; + SelfList<CollisionObject3DSW>::List pending_shape_update_list; void _update_shapes(); public: - static PhysicsServerSW *singleton; + static PhysicsServer3DSW *singleton; struct CollCbkData { @@ -104,7 +104,7 @@ public: virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const; // this function only works on physics process, errors and returns null otherwise - virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space); + virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space); virtual void space_set_debug_contacts(RID p_space, int p_max_contacts); virtual Vector<Vector3> space_get_contacts(RID p_space) const; @@ -237,17 +237,17 @@ public: virtual void body_set_ray_pickable(RID p_body, bool p_enable); virtual bool body_is_ray_pickable(RID p_body) const; - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true); + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true); virtual int body_test_ray_separation(RID p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin = 0.001); // this function only works on physics process, errors and returns null otherwise - virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body); + virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body); /* SOFT BODY */ virtual RID soft_body_create(bool p_init_sleeping = false) { return RID(); } - virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) {} + virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) {} virtual void soft_body_set_space(RID p_body, RID p_space) {} virtual RID soft_body_get_space(RID p_body) const { return RID(); } @@ -375,8 +375,8 @@ public: int get_process_info(ProcessInfo p_info); - PhysicsServerSW(); - ~PhysicsServerSW(); + PhysicsServer3DSW(); + ~PhysicsServer3DSW(); }; #endif diff --git a/servers/physics/shape_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp index 4a6ed6be58..61c32b779a 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics_3d/shape_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* shape_sw.cpp */ +/* shape_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "shape_sw.h" +#include "shape_3d_sw.h" #include "core/math/geometry.h" #include "core/math/quick_hull.h" @@ -38,16 +38,16 @@ #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 #define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998 -void ShapeSW::configure(const AABB &p_aabb) { +void Shape3DSW::configure(const AABB &p_aabb) { aabb = p_aabb; configured = true; - for (Map<ShapeOwnerSW *, int>::Element *E = owners.front(); E; E = E->next()) { - ShapeOwnerSW *co = (ShapeOwnerSW *)E->key(); + for (Map<ShapeOwner3DSW *, int>::Element *E = owners.front(); E; E = E->next()) { + ShapeOwner3DSW *co = (ShapeOwner3DSW *)E->key(); co->_shape_changed(); } } -Vector3 ShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 Shape3DSW::get_support(const Vector3 &p_normal) const { Vector3 res; int amnt; @@ -55,9 +55,9 @@ Vector3 ShapeSW::get_support(const Vector3 &p_normal) const { return res; } -void ShapeSW::add_owner(ShapeOwnerSW *p_owner) { +void Shape3DSW::add_owner(ShapeOwner3DSW *p_owner) { - Map<ShapeOwnerSW *, int>::Element *E = owners.find(p_owner); + Map<ShapeOwner3DSW *, int>::Element *E = owners.find(p_owner); if (E) { E->get()++; } else { @@ -65,9 +65,9 @@ void ShapeSW::add_owner(ShapeOwnerSW *p_owner) { } } -void ShapeSW::remove_owner(ShapeOwnerSW *p_owner) { +void Shape3DSW::remove_owner(ShapeOwner3DSW *p_owner) { - Map<ShapeOwnerSW *, int>::Element *E = owners.find(p_owner); + Map<ShapeOwner3DSW *, int>::Element *E = owners.find(p_owner); ERR_FAIL_COND(!E); E->get()--; if (E->get() == 0) { @@ -75,44 +75,44 @@ void ShapeSW::remove_owner(ShapeOwnerSW *p_owner) { } } -bool ShapeSW::is_owner(ShapeOwnerSW *p_owner) const { +bool Shape3DSW::is_owner(ShapeOwner3DSW *p_owner) const { return owners.has(p_owner); } -const Map<ShapeOwnerSW *, int> &ShapeSW::get_owners() const { +const Map<ShapeOwner3DSW *, int> &Shape3DSW::get_owners() const { return owners; } -ShapeSW::ShapeSW() { +Shape3DSW::Shape3DSW() { custom_bias = 0; configured = false; } -ShapeSW::~ShapeSW() { +Shape3DSW::~Shape3DSW() { ERR_FAIL_COND(owners.size()); } -Plane PlaneShapeSW::get_plane() const { +Plane PlaneShape3DSW::get_plane() const { return plane; } -void PlaneShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void PlaneShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { // gibberish, a plane is infinity r_min = -1e7; r_max = 1e7; } -Vector3 PlaneShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 PlaneShape3DSW::get_support(const Vector3 &p_normal) const { return p_normal * 1e15; } -bool PlaneShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool PlaneShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { bool inters = plane.intersects_segment(p_begin, p_end, &r_result); if (inters) @@ -120,12 +120,12 @@ bool PlaneShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_en return inters; } -bool PlaneShapeSW::intersect_point(const Vector3 &p_point) const { +bool PlaneShape3DSW::intersect_point(const Vector3 &p_point) const { return plane.distance_to(p_point) < 0; } -Vector3 PlaneShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 PlaneShape3DSW::get_closest_point_to(const Vector3 &p_point) const { if (plane.is_point_over(p_point)) { return plane.project(p_point); @@ -134,49 +134,49 @@ Vector3 PlaneShapeSW::get_closest_point_to(const Vector3 &p_point) const { } } -Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 PlaneShape3DSW::get_moment_of_inertia(real_t p_mass) const { return Vector3(); //wtf } -void PlaneShapeSW::_setup(const Plane &p_plane) { +void PlaneShape3DSW::_setup(const Plane &p_plane) { plane = p_plane; configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2))); } -void PlaneShapeSW::set_data(const Variant &p_data) { +void PlaneShape3DSW::set_data(const Variant &p_data) { _setup(p_data); } -Variant PlaneShapeSW::get_data() const { +Variant PlaneShape3DSW::get_data() const { return plane; } -PlaneShapeSW::PlaneShapeSW() { +PlaneShape3DSW::PlaneShape3DSW() { } // -real_t RayShapeSW::get_length() const { +real_t RayShape3DSW::get_length() const { return length; } -bool RayShapeSW::get_slips_on_slope() const { +bool RayShape3DSW::get_slips_on_slope() const { return slips_on_slope; } -void RayShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void RayShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { // don't think this will be even used r_min = 0; r_max = 1; } -Vector3 RayShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 RayShape3DSW::get_support(const Vector3 &p_normal) const { if (p_normal.z > 0) return Vector3(0, 0, length); @@ -184,7 +184,7 @@ Vector3 RayShapeSW::get_support(const Vector3 &p_normal) const { return Vector3(0, 0, 0); } -void RayShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { +void RayShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { if (Math::abs(p_normal.z) < _EDGE_IS_VALID_SUPPORT_THRESHOLD) { @@ -200,17 +200,17 @@ void RayShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup } } -bool RayShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool RayShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { return false; //simply not possible } -bool RayShapeSW::intersect_point(const Vector3 &p_point) const { +bool RayShape3DSW::intersect_point(const Vector3 &p_point) const { return false; //simply not possible } -Vector3 RayShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 RayShape3DSW::get_closest_point_to(const Vector3 &p_point) const { Vector3 s[2] = { Vector3(0, 0, 0), @@ -220,25 +220,25 @@ Vector3 RayShapeSW::get_closest_point_to(const Vector3 &p_point) const { return Geometry::get_closest_point_to_segment(p_point, s); } -Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 RayShape3DSW::get_moment_of_inertia(real_t p_mass) const { return Vector3(); } -void RayShapeSW::_setup(real_t p_length, bool p_slips_on_slope) { +void RayShape3DSW::_setup(real_t p_length, bool p_slips_on_slope) { length = p_length; slips_on_slope = p_slips_on_slope; configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length))); } -void RayShapeSW::set_data(const Variant &p_data) { +void RayShape3DSW::set_data(const Variant &p_data) { Dictionary d = p_data; _setup(d["length"], d["slips_on_slope"]); } -Variant RayShapeSW::get_data() const { +Variant RayShape3DSW::get_data() const { Dictionary d; d["length"] = length; @@ -246,7 +246,7 @@ Variant RayShapeSW::get_data() const { return d; } -RayShapeSW::RayShapeSW() { +RayShape3DSW::RayShape3DSW() { length = 1; slips_on_slope = false; @@ -254,12 +254,12 @@ RayShapeSW::RayShapeSW() { /********** SPHERE *************/ -real_t SphereShapeSW::get_radius() const { +real_t SphereShape3DSW::get_radius() const { return radius; } -void SphereShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void SphereShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { real_t d = p_normal.dot(p_transform.origin); @@ -271,28 +271,28 @@ void SphereShapeSW::project_range(const Vector3 &p_normal, const Transform &p_tr r_max = d + (radius)*scale; } -Vector3 SphereShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 SphereShape3DSW::get_support(const Vector3 &p_normal) const { return p_normal * radius; } -void SphereShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { +void SphereShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { *r_supports = p_normal * radius; r_amount = 1; } -bool SphereShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool SphereShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { return Geometry::segment_intersects_sphere(p_begin, p_end, Vector3(), radius, &r_result, &r_normal); } -bool SphereShapeSW::intersect_point(const Vector3 &p_point) const { +bool SphereShape3DSW::intersect_point(const Vector3 &p_point) const { return p_point.length() < radius; } -Vector3 SphereShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 SphereShape3DSW::get_closest_point_to(const Vector3 &p_point) const { Vector3 p = p_point; float l = p.length(); @@ -301,36 +301,36 @@ Vector3 SphereShapeSW::get_closest_point_to(const Vector3 &p_point) const { return (p / l) * radius; } -Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 SphereShape3DSW::get_moment_of_inertia(real_t p_mass) const { real_t s = 0.4 * p_mass * radius * radius; return Vector3(s, s, s); } -void SphereShapeSW::_setup(real_t p_radius) { +void SphereShape3DSW::_setup(real_t p_radius) { radius = p_radius; configure(AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0))); } -void SphereShapeSW::set_data(const Variant &p_data) { +void SphereShape3DSW::set_data(const Variant &p_data) { _setup(p_data); } -Variant SphereShapeSW::get_data() const { +Variant SphereShape3DSW::get_data() const { return radius; } -SphereShapeSW::SphereShapeSW() { +SphereShape3DSW::SphereShape3DSW() { radius = 0; } /********** BOX *************/ -void BoxShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void BoxShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { // no matter the angle, the box is mirrored anyway Vector3 local_normal = p_transform.basis.xform_inv(p_normal); @@ -342,7 +342,7 @@ void BoxShapeSW::project_range(const Vector3 &p_normal, const Transform &p_trans r_max = distance + length; } -Vector3 BoxShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 BoxShape3DSW::get_support(const Vector3 &p_normal) const { Vector3 point( (p_normal.x < 0) ? -half_extents.x : half_extents.x, @@ -352,7 +352,7 @@ Vector3 BoxShapeSW::get_support(const Vector3 &p_normal) const { return point; } -void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { +void BoxShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { static const int next[3] = { 1, 2, 0 }; static const int next2[3] = { 2, 0, 1 }; @@ -439,19 +439,19 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup r_supports[0] = point; } -bool BoxShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool BoxShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { AABB aabb(-half_extents, half_extents * 2.0); return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal); } -bool BoxShapeSW::intersect_point(const Vector3 &p_point) const { +bool BoxShape3DSW::intersect_point(const Vector3 &p_point) const { return (Math::abs(p_point.x) < half_extents.x && Math::abs(p_point.y) < half_extents.y && Math::abs(p_point.z) < half_extents.z); } -Vector3 BoxShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 BoxShape3DSW::get_closest_point_to(const Vector3 &p_point) const { int outside = 0; Vector3 min_point; @@ -502,7 +502,7 @@ Vector3 BoxShapeSW::get_closest_point_to(const Vector3 &p_point) const { return min_point; } -Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 BoxShape3DSW::get_moment_of_inertia(real_t p_mass) const { real_t lx = half_extents.x; real_t ly = half_extents.y; @@ -511,29 +511,29 @@ Vector3 BoxShapeSW::get_moment_of_inertia(real_t p_mass) const { return Vector3((p_mass / 3.0) * (ly * ly + lz * lz), (p_mass / 3.0) * (lx * lx + lz * lz), (p_mass / 3.0) * (lx * lx + ly * ly)); } -void BoxShapeSW::_setup(const Vector3 &p_half_extents) { +void BoxShape3DSW::_setup(const Vector3 &p_half_extents) { half_extents = p_half_extents.abs(); configure(AABB(-half_extents, half_extents * 2)); } -void BoxShapeSW::set_data(const Variant &p_data) { +void BoxShape3DSW::set_data(const Variant &p_data) { _setup(p_data); } -Variant BoxShapeSW::get_data() const { +Variant BoxShape3DSW::get_data() const { return half_extents; } -BoxShapeSW::BoxShapeSW() { +BoxShape3DSW::BoxShape3DSW() { } /********** CAPSULE *************/ -void CapsuleShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void CapsuleShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { Vector3 n = p_transform.basis.xform_inv(p_normal).normalized(); real_t h = (n.z > 0) ? height : -height; @@ -545,7 +545,7 @@ void CapsuleShapeSW::project_range(const Vector3 &p_normal, const Transform &p_t r_min = p_normal.dot(p_transform.xform(-n)); } -Vector3 CapsuleShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 CapsuleShape3DSW::get_support(const Vector3 &p_normal) const { Vector3 n = p_normal; @@ -556,7 +556,7 @@ Vector3 CapsuleShapeSW::get_support(const Vector3 &p_normal) const { return n; } -void CapsuleShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { +void CapsuleShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { Vector3 n = p_normal; @@ -586,7 +586,7 @@ void CapsuleShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r } } -bool CapsuleShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool CapsuleShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { Vector3 norm = (p_end - p_begin).normalized(); real_t min_d = 1e20; @@ -644,7 +644,7 @@ bool CapsuleShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_ return collision; } -bool CapsuleShapeSW::intersect_point(const Vector3 &p_point) const { +bool CapsuleShape3DSW::intersect_point(const Vector3 &p_point) const { if (Math::abs(p_point.z) < height * 0.5) { return Vector3(p_point.x, p_point.y, 0).length() < radius; @@ -655,7 +655,7 @@ bool CapsuleShapeSW::intersect_point(const Vector3 &p_point) const { } } -Vector3 CapsuleShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 CapsuleShape3DSW::get_closest_point_to(const Vector3 &p_point) const { Vector3 s[2] = { Vector3(0, 0, -height * 0.5), @@ -670,7 +670,7 @@ Vector3 CapsuleShapeSW::get_closest_point_to(const Vector3 &p_point) const { return p + (p_point - p).normalized() * radius; } -Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 CapsuleShape3DSW::get_moment_of_inertia(real_t p_mass) const { // use bad AABB approximation Vector3 extents = get_aabb().size * 0.5; @@ -681,14 +681,14 @@ Vector3 CapsuleShapeSW::get_moment_of_inertia(real_t p_mass) const { (p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y)); } -void CapsuleShapeSW::_setup(real_t p_height, real_t p_radius) { +void CapsuleShape3DSW::_setup(real_t p_height, real_t p_radius) { height = p_height; radius = p_radius; configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0))); } -void CapsuleShapeSW::set_data(const Variant &p_data) { +void CapsuleShape3DSW::set_data(const Variant &p_data) { Dictionary d = p_data; ERR_FAIL_COND(!d.has("radius")); @@ -696,7 +696,7 @@ void CapsuleShapeSW::set_data(const Variant &p_data) { _setup(d["height"], d["radius"]); } -Variant CapsuleShapeSW::get_data() const { +Variant CapsuleShape3DSW::get_data() const { Dictionary d; d["radius"] = radius; @@ -704,14 +704,14 @@ Variant CapsuleShapeSW::get_data() const { return d; } -CapsuleShapeSW::CapsuleShapeSW() { +CapsuleShape3DSW::CapsuleShape3DSW() { height = radius = 0; } /********** CONVEX POLYGON *************/ -void ConvexPolygonShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void ConvexPolygonShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { int vertex_count = mesh.vertices.size(); if (vertex_count == 0) @@ -730,7 +730,7 @@ void ConvexPolygonShapeSW::project_range(const Vector3 &p_normal, const Transfor } } -Vector3 ConvexPolygonShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 ConvexPolygonShape3DSW::get_support(const Vector3 &p_normal) const { Vector3 n = p_normal; @@ -756,7 +756,7 @@ Vector3 ConvexPolygonShapeSW::get_support(const Vector3 &p_normal) const { return vrts[vert_support_idx]; } -void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { +void ConvexPolygonShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { const Geometry::MeshData::Face *faces = mesh.faces.ptr(); int fc = mesh.faces.size(); @@ -826,7 +826,7 @@ void ConvexPolygonShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vect r_amount = 1; } -bool ConvexPolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool ConvexPolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { const Geometry::MeshData::Face *faces = mesh.faces.ptr(); int fc = mesh.faces.size(); @@ -866,7 +866,7 @@ bool ConvexPolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vecto return col; } -bool ConvexPolygonShapeSW::intersect_point(const Vector3 &p_point) const { +bool ConvexPolygonShape3DSW::intersect_point(const Vector3 &p_point) const { const Geometry::MeshData::Face *faces = mesh.faces.ptr(); int fc = mesh.faces.size(); @@ -880,7 +880,7 @@ bool ConvexPolygonShapeSW::intersect_point(const Vector3 &p_point) const { return true; } -Vector3 ConvexPolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 ConvexPolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const { const Geometry::MeshData::Face *faces = mesh.faces.ptr(); int fc = mesh.faces.size(); @@ -941,7 +941,7 @@ Vector3 ConvexPolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const return min_point; } -Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 ConvexPolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const { // use bad AABB approximation Vector3 extents = get_aabb().size * 0.5; @@ -952,7 +952,7 @@ Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(real_t p_mass) const { (p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y)); } -void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) { +void ConvexPolygonShape3DSW::_setup(const Vector<Vector3> &p_vertices) { Error err = QuickHull::build(p_vertices, mesh); if (err != OK) @@ -971,22 +971,22 @@ void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) { configure(_aabb); } -void ConvexPolygonShapeSW::set_data(const Variant &p_data) { +void ConvexPolygonShape3DSW::set_data(const Variant &p_data) { _setup(p_data); } -Variant ConvexPolygonShapeSW::get_data() const { +Variant ConvexPolygonShape3DSW::get_data() const { return mesh.vertices; } -ConvexPolygonShapeSW::ConvexPolygonShapeSW() { +ConvexPolygonShape3DSW::ConvexPolygonShape3DSW() { } /********** FACE POLYGON *************/ -void FaceShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void FaceShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { for (int i = 0; i < 3; i++) { @@ -1001,7 +1001,7 @@ void FaceShapeSW::project_range(const Vector3 &p_normal, const Transform &p_tran } } -Vector3 FaceShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 FaceShape3DSW::get_support(const Vector3 &p_normal) const { int vert_support_idx = -1; real_t support_max = 0; @@ -1019,7 +1019,7 @@ Vector3 FaceShapeSW::get_support(const Vector3 &p_normal) const { return vertex[vert_support_idx]; } -void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { +void FaceShape3DSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { Vector3 n = p_normal; @@ -1073,7 +1073,7 @@ void FaceShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_su r_supports[0] = vertex[vert_support_idx]; } -bool FaceShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool FaceShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { bool c = Geometry::segment_intersects_triangle(p_begin, p_end, vertex[0], vertex[1], vertex[2], &r_result); if (c) { @@ -1086,27 +1086,27 @@ bool FaceShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end return c; } -bool FaceShapeSW::intersect_point(const Vector3 &p_point) const { +bool FaceShape3DSW::intersect_point(const Vector3 &p_point) const { return false; //face is flat } -Vector3 FaceShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 FaceShape3DSW::get_closest_point_to(const Vector3 &p_point) const { return Face3(vertex[0], vertex[1], vertex[2]).get_closest_point_to(p_point); } -Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 FaceShape3DSW::get_moment_of_inertia(real_t p_mass) const { return Vector3(); // Sorry, but i don't think anyone cares, FaceShape! } -FaceShapeSW::FaceShapeSW() { +FaceShape3DSW::FaceShape3DSW() { configure(AABB()); } -Vector<Vector3> ConcavePolygonShapeSW::get_faces() const { +Vector<Vector3> ConcavePolygonShape3DSW::get_faces() const { Vector<Vector3> rfaces; rfaces.resize(faces.size() * 3); @@ -1124,7 +1124,7 @@ Vector<Vector3> ConcavePolygonShapeSW::get_faces() const { return rfaces; } -void ConcavePolygonShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void ConcavePolygonShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { int count = vertices.size(); if (count == 0) { @@ -1145,7 +1145,7 @@ void ConcavePolygonShapeSW::project_range(const Vector3 &p_normal, const Transfo } } -Vector3 ConcavePolygonShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 ConcavePolygonShape3DSW::get_support(const Vector3 &p_normal) const { int count = vertices.size(); if (count == 0) @@ -1171,7 +1171,7 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3 &p_normal) const { return vptr[vert_support_idx]; } -void ConcavePolygonShapeSW::_cull_segment(int p_idx, _SegmentCullParams *p_params) const { +void ConcavePolygonShape3DSW::_cull_segment(int p_idx, _SegmentCullParams *p_params) const { const BVH *bvh = &p_params->bvh[p_idx]; @@ -1223,7 +1223,7 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx, _SegmentCullParams *p_param } } -bool ConcavePolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { +bool ConcavePolygonShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { if (faces.size() == 0) return false; @@ -1258,17 +1258,17 @@ bool ConcavePolygonShapeSW::intersect_segment(const Vector3 &p_begin, const Vect } } -bool ConcavePolygonShapeSW::intersect_point(const Vector3 &p_point) const { +bool ConcavePolygonShape3DSW::intersect_point(const Vector3 &p_point) const { return false; //face is flat } -Vector3 ConcavePolygonShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 ConcavePolygonShape3DSW::get_closest_point_to(const Vector3 &p_point) const { return Vector3(); } -void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const { +void ConcavePolygonShape3DSW::_cull(int p_idx, _CullParams *p_params) const { const BVH *bvh = &p_params->bvh[p_idx]; @@ -1278,7 +1278,7 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const { if (bvh->face_index >= 0) { const Face *f = &p_params->faces[bvh->face_index]; - FaceShapeSW *face = p_params->face; + FaceShape3DSW *face = p_params->face; face->normal = f->normal; face->vertex[0] = p_params->vertices[f->indices[0]]; face->vertex[1] = p_params->vertices[f->indices[1]]; @@ -1299,7 +1299,7 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const { } } -void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { +void ConcavePolygonShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { // make matrix local to concave if (faces.size() == 0) @@ -1312,7 +1312,7 @@ void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, const Vector3 *vr = vertices.ptr(); const BVH *br = bvh.ptr(); - FaceShapeSW face; // use this to send in the callback + FaceShape3DSW face; // use this to send in the callback _CullParams params; params.aabb = local_aabb; @@ -1327,7 +1327,7 @@ void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, _cull(0, ¶ms); } -Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 ConcavePolygonShape3DSW::get_moment_of_inertia(real_t p_mass) const { // use bad AABB approximation Vector3 extents = get_aabb().size * 0.5; @@ -1385,8 +1385,8 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz if (p_size == 1) { //leaf bvh->aabb = p_elements[0].aabb; - bvh->left = NULL; - bvh->right = NULL; + bvh->left = nullptr; + bvh->right = nullptr; bvh->face_index = p_elements->face_index; count++; return bvh; @@ -1433,7 +1433,7 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz return bvh; } -void ConcavePolygonShapeSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx) { +void ConcavePolygonShape3DSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_array, int &p_idx) { int idx = p_idx; @@ -1462,7 +1462,7 @@ void ConcavePolygonShapeSW::_fill_bvh(_VolumeSW_BVH *p_bvh_tree, BVH *p_bvh_arra memdelete(p_bvh_tree); } -void ConcavePolygonShapeSW::_setup(Vector<Vector3> p_faces) { +void ConcavePolygonShape3DSW::_setup(Vector<Vector3> p_faces) { int src_face_count = p_faces.size(); if (src_face_count == 0) { @@ -1521,68 +1521,68 @@ void ConcavePolygonShapeSW::_setup(Vector<Vector3> p_faces) { configure(_aabb); // this type of shape has no margin } -void ConcavePolygonShapeSW::set_data(const Variant &p_data) { +void ConcavePolygonShape3DSW::set_data(const Variant &p_data) { _setup(p_data); } -Variant ConcavePolygonShapeSW::get_data() const { +Variant ConcavePolygonShape3DSW::get_data() const { return get_faces(); } -ConcavePolygonShapeSW::ConcavePolygonShapeSW() { +ConcavePolygonShape3DSW::ConcavePolygonShape3DSW() { } /* HEIGHT MAP SHAPE */ -Vector<real_t> HeightMapShapeSW::get_heights() const { +Vector<real_t> HeightMapShape3DSW::get_heights() const { return heights; } -int HeightMapShapeSW::get_width() const { +int HeightMapShape3DSW::get_width() const { return width; } -int HeightMapShapeSW::get_depth() const { +int HeightMapShape3DSW::get_depth() const { return depth; } -real_t HeightMapShapeSW::get_cell_size() const { +real_t HeightMapShape3DSW::get_cell_size() const { return cell_size; } -void HeightMapShapeSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { +void HeightMapShape3DSW::project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { //not very useful, but not very used either p_transform.xform(get_aabb()).project_range_in_plane(Plane(p_normal, 0), r_min, r_max); } -Vector3 HeightMapShapeSW::get_support(const Vector3 &p_normal) const { +Vector3 HeightMapShape3DSW::get_support(const Vector3 &p_normal) const { //not very useful, but not very used either return get_aabb().get_support(p_normal); } -bool HeightMapShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const { +bool HeightMapShape3DSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const { return false; } -bool HeightMapShapeSW::intersect_point(const Vector3 &p_point) const { +bool HeightMapShape3DSW::intersect_point(const Vector3 &p_point) const { return false; } -Vector3 HeightMapShapeSW::get_closest_point_to(const Vector3 &p_point) const { +Vector3 HeightMapShape3DSW::get_closest_point_to(const Vector3 &p_point) const { return Vector3(); } -void HeightMapShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { +void HeightMapShape3DSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { } -Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const { +Vector3 HeightMapShape3DSW::get_moment_of_inertia(real_t p_mass) const { // use bad AABB approximation Vector3 extents = get_aabb().size * 0.5; @@ -1593,7 +1593,7 @@ Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const { (p_mass / 3.0) * (extents.y * extents.y + extents.y * extents.y)); } -void HeightMapShapeSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) { +void HeightMapShape3DSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth, real_t p_cell_size) { heights = p_heights; width = p_width; @@ -1621,7 +1621,7 @@ void HeightMapShapeSW::_setup(Vector<real_t> p_heights, int p_width, int p_depth configure(aabb); } -void HeightMapShapeSW::set_data(const Variant &p_data) { +void HeightMapShape3DSW::set_data(const Variant &p_data) { ERR_FAIL_COND(p_data.get_type() != Variant::DICTIONARY); Dictionary d = p_data; @@ -1642,12 +1642,12 @@ void HeightMapShapeSW::set_data(const Variant &p_data) { _setup(heights, width, depth, cell_size); } -Variant HeightMapShapeSW::get_data() const { +Variant HeightMapShape3DSW::get_data() const { ERR_FAIL_V(Variant()); } -HeightMapShapeSW::HeightMapShapeSW() { +HeightMapShape3DSW::HeightMapShape3DSW() { width = 0; depth = 0; diff --git a/servers/physics/shape_sw.h b/servers/physics_3d/shape_3d_sw.h index eaae64be66..dd29ec849b 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics_3d/shape_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* shape_sw.h */ +/* shape_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -32,7 +32,7 @@ #define SHAPE_SW_H #include "core/math/geometry.h" -#include "servers/physics_server.h" +#include "servers/physics_server_3d.h" /* SHAPE_LINE, ///< plane:"plane" @@ -45,24 +45,24 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat */ -class ShapeSW; +class Shape3DSW; -class ShapeOwnerSW { +class ShapeOwner3DSW { public: virtual void _shape_changed() = 0; - virtual void remove_shape(ShapeSW *p_shape) = 0; + virtual void remove_shape(Shape3DSW *p_shape) = 0; - virtual ~ShapeOwnerSW() {} + virtual ~ShapeOwner3DSW() {} }; -class ShapeSW { +class Shape3DSW { RID self; AABB aabb; bool configured; real_t custom_bias; - Map<ShapeOwnerSW *, int> owners; + Map<ShapeOwner3DSW *, int> owners; protected: void configure(const AABB &p_aabb); @@ -77,7 +77,7 @@ public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } _FORCE_INLINE_ RID get_self() const { return self; } - virtual PhysicsServer::ShapeType get_type() const = 0; + virtual PhysicsServer3D::ShapeType get_type() const = 0; _FORCE_INLINE_ AABB get_aabb() const { return aabb; } _FORCE_INLINE_ bool is_configured() const { return configured; } @@ -98,28 +98,28 @@ public: _FORCE_INLINE_ void set_custom_bias(real_t p_bias) { custom_bias = p_bias; } _FORCE_INLINE_ real_t get_custom_bias() const { return custom_bias; } - void add_owner(ShapeOwnerSW *p_owner); - void remove_owner(ShapeOwnerSW *p_owner); - bool is_owner(ShapeOwnerSW *p_owner) const; - const Map<ShapeOwnerSW *, int> &get_owners() const; + void add_owner(ShapeOwner3DSW *p_owner); + void remove_owner(ShapeOwner3DSW *p_owner); + bool is_owner(ShapeOwner3DSW *p_owner) const; + const Map<ShapeOwner3DSW *, int> &get_owners() const; - ShapeSW(); - virtual ~ShapeSW(); + Shape3DSW(); + virtual ~Shape3DSW(); }; -class ConcaveShapeSW : public ShapeSW { +class ConcaveShape3DSW : public Shape3DSW { public: virtual bool is_concave() const { return true; } - typedef void (*Callback)(void *p_userdata, ShapeSW *p_convex); + typedef void (*Callback)(void *p_userdata, Shape3DSW *p_convex); virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; } virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; - ConcaveShapeSW() {} + ConcaveShape3DSW() {} }; -class PlaneShapeSW : public ShapeSW { +class PlaneShape3DSW : public Shape3DSW { Plane plane; @@ -129,7 +129,7 @@ public: Plane get_plane() const; virtual real_t get_area() const { return Math_INF; } - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_PLANE; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_PLANE; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; } @@ -142,10 +142,10 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - PlaneShapeSW(); + PlaneShape3DSW(); }; -class RayShapeSW : public ShapeSW { +class RayShape3DSW : public Shape3DSW { real_t length; bool slips_on_slope; @@ -157,7 +157,7 @@ public: bool get_slips_on_slope() const; virtual real_t get_area() const { return 0.0; } - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_RAY; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_RAY; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const; @@ -171,10 +171,10 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - RayShapeSW(); + RayShape3DSW(); }; -class SphereShapeSW : public ShapeSW { +class SphereShape3DSW : public Shape3DSW { real_t radius; @@ -185,7 +185,7 @@ public: virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius; } - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_SPHERE; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_SPHERE; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; @@ -199,10 +199,10 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - SphereShapeSW(); + SphereShape3DSW(); }; -class BoxShapeSW : public ShapeSW { +class BoxShape3DSW : public Shape3DSW { Vector3 half_extents; void _setup(const Vector3 &p_half_extents); @@ -211,7 +211,7 @@ public: _FORCE_INLINE_ Vector3 get_half_extents() const { return half_extents; } virtual real_t get_area() const { return 8 * half_extents.x * half_extents.y * half_extents.z; } - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_BOX; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_BOX; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; @@ -225,10 +225,10 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - BoxShapeSW(); + BoxShape3DSW(); }; -class CapsuleShapeSW : public ShapeSW { +class CapsuleShape3DSW : public Shape3DSW { real_t height; real_t radius; @@ -241,7 +241,7 @@ public: virtual real_t get_area() const { return 4.0 / 3.0 * Math_PI * radius * radius * radius + height * Math_PI * radius * radius; } - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CAPSULE; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CAPSULE; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; @@ -255,10 +255,10 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - CapsuleShapeSW(); + CapsuleShape3DSW(); }; -struct ConvexPolygonShapeSW : public ShapeSW { +struct ConvexPolygonShape3DSW : public Shape3DSW { Geometry::MeshData mesh; @@ -267,7 +267,7 @@ struct ConvexPolygonShapeSW : public ShapeSW { public: const Geometry::MeshData &get_mesh() const { return mesh; } - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; @@ -281,13 +281,13 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - ConvexPolygonShapeSW(); + ConvexPolygonShape3DSW(); }; struct _VolumeSW_BVH; -struct FaceShapeSW; +struct FaceShape3DSW; -struct ConcavePolygonShapeSW : public ConcaveShapeSW { +struct ConcavePolygonShape3DSW : public ConcaveShape3DSW { // always a trimesh struct Face { @@ -318,7 +318,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { const Face *faces; const Vector3 *vertices; const BVH *bvh; - FaceShapeSW *face; + FaceShape3DSW *face; }; struct _SegmentCullParams { @@ -346,7 +346,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { public: Vector<Vector3> get_faces() const; - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; @@ -362,10 +362,10 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - ConcavePolygonShapeSW(); + ConcavePolygonShape3DSW(); }; -struct HeightMapShapeSW : public ConcaveShapeSW { +struct HeightMapShape3DSW : public ConcaveShape3DSW { Vector<real_t> heights; int width; @@ -383,7 +383,7 @@ public: int get_depth() const; real_t get_cell_size() const; - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_HEIGHTMAP; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_HEIGHTMAP; } virtual void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; virtual Vector3 get_support(const Vector3 &p_normal) const; @@ -398,16 +398,16 @@ public: virtual void set_data(const Variant &p_data); virtual Variant get_data() const; - HeightMapShapeSW(); + HeightMapShape3DSW(); }; //used internally -struct FaceShapeSW : public ShapeSW { +struct FaceShape3DSW : public Shape3DSW { Vector3 normal; //cache Vector3 vertex[3]; - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONCAVE_POLYGON; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONCAVE_POLYGON; } const Vector3 &get_vertex(int p_idx) const { return vertex[p_idx]; } @@ -423,15 +423,15 @@ struct FaceShapeSW : public ShapeSW { virtual void set_data(const Variant &p_data) {} virtual Variant get_data() const { return Variant(); } - FaceShapeSW(); + FaceShape3DSW(); }; -struct MotionShapeSW : public ShapeSW { +struct MotionShape3DSW : public Shape3DSW { - ShapeSW *shape; + Shape3DSW *shape; Vector3 motion; - virtual PhysicsServer::ShapeType get_type() const { return PhysicsServer::SHAPE_CONVEX_POLYGON; } + virtual PhysicsServer3D::ShapeType get_type() const { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; } void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const { @@ -464,7 +464,7 @@ struct MotionShapeSW : public ShapeSW { virtual void set_data(const Variant &p_data) {} virtual Variant get_data() const { return Variant(); } - MotionShapeSW() { configure(AABB()); } + MotionShape3DSW() { configure(AABB()); } }; #endif // SHAPE_SW_H diff --git a/servers/physics/space_sw.cpp b/servers/physics_3d/space_3d_sw.cpp index 110520db5a..bd8e89a8f5 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics_3d/space_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* space_sw.cpp */ +/* space_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,31 +28,31 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "space_sw.h" +#include "space_3d_sw.h" -#include "collision_solver_sw.h" +#include "collision_solver_3d_sw.h" #include "core/project_settings.h" -#include "physics_server_sw.h" +#include "physics_server_3d_sw.h" -_FORCE_INLINE_ static bool _can_collide_with(CollisionObjectSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +_FORCE_INLINE_ static bool _can_collide_with(CollisionObject3DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (!(p_object->get_collision_layer() & p_collision_mask)) { return false; } - if (p_object->get_type() == CollisionObjectSW::TYPE_AREA && !p_collide_with_areas) + if (p_object->get_type() == CollisionObject3DSW::TYPE_AREA && !p_collide_with_areas) return false; - if (p_object->get_type() == CollisionObjectSW::TYPE_BODY && !p_collide_with_bodies) + if (p_object->get_type() == CollisionObject3DSW::TYPE_BODY && !p_collide_with_bodies) return false; return true; } -int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +int PhysicsDirectSpaceState3DSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { ERR_FAIL_COND_V(space->locked, false); - int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); int cc = 0; //Transform ai = p_xform.affine_inverse(); @@ -70,7 +70,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu if (p_exclude.has(space->intersection_query_results[i]->get_self())) continue; - const CollisionObjectSW *col_obj = space->intersection_query_results[i]; + const CollisionObject3DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; Transform inv_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); @@ -83,7 +83,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu if (r_results[cc].collider_id.is_valid()) r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id); else - r_results[cc].collider = NULL; + r_results[cc].collider = nullptr; r_results[cc].rid = col_obj->get_self(); r_results[cc].shape = shape_idx; @@ -93,7 +93,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu return cc; } -bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_ray) { +bool PhysicsDirectSpaceState3DSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_pick_ray) { ERR_FAIL_COND_V(space->locked, false); @@ -103,14 +103,14 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto end = p_to; normal = (end - begin).normalized(); - int amount = space->broadphase->cull_segment(begin, end, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_segment(begin, end, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); //todo, create another array that references results, compute AABBs and check closest point to ray origin, sort, and stop evaluating results when beyond first collision bool collided = false; Vector3 res_point, res_normal; int res_shape; - const CollisionObjectSW *res_obj; + const CollisionObject3DSW *res_obj; real_t min_d = 1e10; for (int i = 0; i < amount; i++) { @@ -124,7 +124,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto if (p_exclude.has(space->intersection_query_results[i]->get_self())) continue; - const CollisionObjectSW *col_obj = space->intersection_query_results[i]; + const CollisionObject3DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; Transform inv_xform = col_obj->get_shape_inv_transform(shape_idx) * col_obj->get_inv_transform(); @@ -132,7 +132,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto Vector3 local_from = inv_xform.xform(begin); Vector3 local_to = inv_xform.xform(end); - const ShapeSW *shape = col_obj->get_shape(shape_idx); + const Shape3DSW *shape = col_obj->get_shape(shape_idx); Vector3 shape_point, shape_normal; @@ -162,7 +162,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto if (r_result.collider_id.is_valid()) r_result.collider = ObjectDB::get_instance(r_result.collider_id); else - r_result.collider = NULL; + r_result.collider = nullptr; r_result.normal = res_normal; r_result.position = res_point; r_result.rid = res_obj->get_self(); @@ -171,17 +171,17 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto return true; } -int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +int PhysicsDirectSpaceState3DSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (p_result_max <= 0) return 0; - ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape); + Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); AABB aabb = p_xform.xform(shape->get_aabb()); - int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); int cc = 0; @@ -200,10 +200,10 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo if (p_exclude.has(space->intersection_query_results[i]->get_self())) continue; - const CollisionObjectSW *col_obj = space->intersection_query_results[i]; + const CollisionObject3DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; - if (!CollisionSolverSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), NULL, NULL, NULL, p_margin, 0)) + if (!CollisionSolver3DSW::solve_static(shape, p_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), nullptr, nullptr, nullptr, p_margin, 0)) continue; if (r_results) { @@ -211,7 +211,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo if (r_results[cc].collider_id.is_valid()) r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id); else - r_results[cc].collider = NULL; + r_results[cc].collider = nullptr; r_results[cc].rid = col_obj->get_self(); r_results[cc].shape = shape_idx; } @@ -222,22 +222,22 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo return cc; } -bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) { +bool PhysicsDirectSpaceState3DSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, ShapeRestInfo *r_info) { - ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape); + Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, false); AABB aabb = p_xform.xform(shape->get_aabb()); aabb = aabb.merge(AABB(aabb.position + p_motion, aabb.size)); //motion aabb = aabb.grow(p_margin); - int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); real_t best_safe = 1; real_t best_unsafe = 1; Transform xform_inv = p_xform.affine_inverse(); - MotionShapeSW mshape; + MotionShape3DSW mshape; mshape.shape = shape; mshape.motion = xform_inv.basis.xform(p_motion); @@ -253,7 +253,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform if (p_exclude.has(space->intersection_query_results[i]->get_self())) continue; //ignore excluded - const CollisionObjectSW *col_obj = space->intersection_query_results[i]; + const CollisionObject3DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; Vector3 point_A, point_B; @@ -261,14 +261,14 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform Transform col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? - if (CollisionSolverSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) { + if (CollisionSolver3DSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) { continue; } //test initial overlap sep_axis = p_motion.normalized(); - if (!CollisionSolverSW::solve_distance(shape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) { + if (!CollisionSolver3DSW::solve_distance(shape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) { return false; } @@ -287,7 +287,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform Vector3 lA, lB; - bool collided = !CollisionSolverSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, aabb, &sep); + bool collided = !CollisionSolver3DSW::solve_distance(&mshape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, aabb, &sep); if (collided) { @@ -315,8 +315,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform r_info->point = closest_B; r_info->normal = (closest_A - closest_B).normalized(); best_first = false; - if (col_obj->get_type() == CollisionObjectSW::TYPE_BODY) { - const BodySW *body = static_cast<const BodySW *>(col_obj); + if (col_obj->get_type() == CollisionObject3DSW::TYPE_BODY) { + const Body3DSW *body = static_cast<const Body3DSW *>(col_obj); r_info->linear_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(body->get_transform().origin - closest_B); } } @@ -328,43 +328,43 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform return true; } -bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool PhysicsDirectSpaceState3DSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { if (p_result_max <= 0) return 0; - ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape); + Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); AABB aabb = p_shape_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); - int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); bool collided = false; r_result_count = 0; - PhysicsServerSW::CollCbkData cbk; + PhysicsServer3DSW::CollCbkData cbk; cbk.max = p_result_max; cbk.amount = 0; cbk.ptr = r_results; - CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk; + CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk; - PhysicsServerSW::CollCbkData *cbkptr = &cbk; + PhysicsServer3DSW::CollCbkData *cbkptr = &cbk; for (int i = 0; i < amount; i++) { if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) continue; - const CollisionObjectSW *col_obj = space->intersection_query_results[i]; + const CollisionObject3DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; if (p_exclude.has(col_obj->get_self())) { continue; } - if (CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) { + if (CollisionSolver3DSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) { collided = true; } } @@ -376,8 +376,8 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh struct _RestCallbackData { - const CollisionObjectSW *object; - const CollisionObjectSW *best_object; + const CollisionObject3DSW *object; + const CollisionObject3DSW *best_object; int shape; int best_shape; Vector3 best_contact; @@ -403,19 +403,19 @@ static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B, rd->best_object = rd->object; rd->best_shape = rd->shape; } -bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +bool PhysicsDirectSpaceState3DSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.getornull(p_shape); + Shape3DSW *shape = static_cast<PhysicsServer3DSW *>(PhysicsServer3D::get_singleton())->shape_owner.getornull(p_shape); ERR_FAIL_COND_V(!shape, 0); AABB aabb = p_shape_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); - int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); + int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, Space3DSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); _RestCallbackData rcd; rcd.best_len = 0; - rcd.best_object = NULL; + rcd.best_object = nullptr; rcd.best_shape = 0; rcd.min_allowed_depth = space->test_motion_min_contact_depth; @@ -424,7 +424,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas)) continue; - const CollisionObjectSW *col_obj = space->intersection_query_results[i]; + const CollisionObject3DSW *col_obj = space->intersection_query_results[i]; int shape_idx = space->intersection_query_subindex_results[i]; if (p_exclude.has(col_obj->get_self())) @@ -432,7 +432,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ rcd.object = col_obj; rcd.shape = shape_idx; - bool sc = CollisionSolverSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin); + bool sc = CollisionSolver3DSW::solve_static(shape, p_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, nullptr, p_margin); if (!sc) continue; } @@ -445,9 +445,9 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ r_info->normal = rcd.best_normal; r_info->point = rcd.best_contact; r_info->rid = rcd.best_object->get_self(); - if (rcd.best_object->get_type() == CollisionObjectSW::TYPE_BODY) { + if (rcd.best_object->get_type() == CollisionObject3DSW::TYPE_BODY) { - const BodySW *body = static_cast<const BodySW *>(rcd.best_object); + const Body3DSW *body = static_cast<const Body3DSW *>(rcd.best_object); r_info->linear_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(body->get_transform().origin - rcd.best_contact); // * mPos); @@ -458,11 +458,11 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ return true; } -Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const { +Vector3 PhysicsDirectSpaceState3DSW::get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const { - CollisionObjectSW *obj = PhysicsServerSW::singleton->area_owner.getornull(p_object); + CollisionObject3DSW *obj = PhysicsServer3DSW::singleton->area_owner.getornull(p_object); if (!obj) { - obj = PhysicsServerSW::singleton->body_owner.getornull(p_object); + obj = PhysicsServer3DSW::singleton->body_owner.getornull(p_object); } ERR_FAIL_COND_V(!obj, Vector3()); @@ -479,7 +479,7 @@ Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_obje continue; Transform shape_xform = obj->get_transform() * obj->get_shape_transform(i); - ShapeSW *shape = obj->get_shape(i); + Shape3DSW *shape = obj->get_shape(i); Vector3 point = shape->get_closest_point_to(shape_xform.affine_inverse().xform(p_point)); point = shape_xform.xform(point); @@ -499,14 +499,14 @@ Vector3 PhysicsDirectSpaceStateSW::get_closest_point_to_object_volume(RID p_obje } } -PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() { +PhysicsDirectSpaceState3DSW::PhysicsDirectSpaceState3DSW() { - space = NULL; + space = nullptr; } //////////////////////////////////////////////////////////////////////////////////////////////////////////// -int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) { +int Space3DSW::_cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb) { int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results); @@ -516,13 +516,13 @@ int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) { if (intersection_query_results[i] == p_body) keep = false; - else if (intersection_query_results[i]->get_type() == CollisionObjectSW::TYPE_AREA) + else if (intersection_query_results[i]->get_type() == CollisionObject3DSW::TYPE_AREA) keep = false; - else if ((static_cast<BodySW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0) + else if ((static_cast<Body3DSW *>(intersection_query_results[i])->test_collision_mask(p_body)) == 0) keep = false; - else if (static_cast<BodySW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) + else if (static_cast<Body3DSW *>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self())) keep = false; - else if (static_cast<BodySW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i])) + else if (static_cast<Body3DSW *>(intersection_query_results[i])->is_shape_set_as_disabled(intersection_query_subindex_results[i])) keep = false; if (!keep) { @@ -540,7 +540,7 @@ int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) { return amount; } -int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, real_t p_margin) { +int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin) { AABB body_aabb; @@ -581,10 +581,10 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo const int max_results = 32; int recover_attempts = 4; Vector3 sr[max_results * 2]; - PhysicsServerSW::CollCbkData cbk; + PhysicsServer3DSW::CollCbkData cbk; cbk.max = max_results; - PhysicsServerSW::CollCbkData *cbkptr = &cbk; - CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk; + PhysicsServer3DSW::CollCbkData *cbkptr = &cbk; + CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk; do { @@ -598,30 +598,30 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo if (p_body->is_shape_set_as_disabled(j)) continue; - ShapeSW *body_shape = p_body->get_shape(j); + Shape3DSW *body_shape = p_body->get_shape(j); - if (body_shape->get_type() != PhysicsServer::SHAPE_RAY) + if (body_shape->get_type() != PhysicsServer3D::SHAPE_RAY) continue; Transform body_shape_xform = body_transform * p_body->get_shape_transform(j); for (int i = 0; i < amount; i++) { - const CollisionObjectSW *col_obj = intersection_query_results[i]; + const CollisionObject3DSW *col_obj = intersection_query_results[i]; int shape_idx = intersection_query_subindex_results[i]; cbk.amount = 0; cbk.ptr = sr; - if (CollisionObjectSW::TYPE_BODY == col_obj->get_type()) { - const BodySW *b = static_cast<const BodySW *>(col_obj); - if (p_infinite_inertia && PhysicsServer::BODY_MODE_STATIC != b->get_mode() && PhysicsServer::BODY_MODE_KINEMATIC != b->get_mode()) { + if (CollisionObject3DSW::TYPE_BODY == col_obj->get_type()) { + const Body3DSW *b = static_cast<const Body3DSW *>(col_obj); + if (p_infinite_inertia && PhysicsServer3D::BODY_MODE_STATIC != b->get_mode() && PhysicsServer3D::BODY_MODE_KINEMATIC != b->get_mode()) { continue; } } - ShapeSW *against_shape = col_obj->get_shape(shape_idx); - if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) { + Shape3DSW *against_shape = col_obj->get_shape(shape_idx); + if (CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, against_shape, col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) { if (cbk.amount > 0) { collided = true; } @@ -639,7 +639,7 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo } if (ray_index != -1) { - PhysicsServer::SeparationResult &result = r_results[ray_index]; + PhysicsServer3D::SeparationResult &result = r_results[ray_index]; for (int k = 0; k < cbk.amount; k++) { Vector3 a = sr[k * 2 + 0]; @@ -658,8 +658,8 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo result.collider_id = col_obj->get_instance_id(); result.collider_shape = shape_idx; //result.collider_metadata = col_obj->get_shape_metadata(shape_idx); - if (col_obj->get_type() == CollisionObjectSW::TYPE_BODY) { - BodySW *body = (BodySW *)col_obj; + if (col_obj->get_type() == CollisionObject3DSW::TYPE_BODY) { + Body3DSW *body = (Body3DSW *)col_obj; Vector3 rel_vec = b - body->get_transform().get_origin(); //result.collider_velocity = Vector3(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity(); @@ -695,7 +695,7 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo return rays_found; } -bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) { +bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes) { //give me back regular physics engine logic //this is madness @@ -726,7 +726,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve if (!shapes_found) { if (r_result) { - *r_result = PhysicsServer::MotionResult(); + *r_result = PhysicsServer3D::MotionResult(); r_result->motion = p_motion; } @@ -748,13 +748,13 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve do { - PhysicsServerSW::CollCbkData cbk; + PhysicsServer3DSW::CollCbkData cbk; cbk.max = max_results; cbk.amount = 0; cbk.ptr = sr; - PhysicsServerSW::CollCbkData *cbkptr = &cbk; - CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk; + PhysicsServer3DSW::CollCbkData *cbkptr = &cbk; + CollisionSolver3DSW::CallbackResult cbkres = PhysicsServer3DSW::_shape_col_cbk; bool collided = false; @@ -765,17 +765,17 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve continue; Transform body_shape_xform = body_transform * p_body->get_shape_transform(j); - ShapeSW *body_shape = p_body->get_shape(j); - if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer::SHAPE_RAY) { + Shape3DSW *body_shape = p_body->get_shape(j); + if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer3D::SHAPE_RAY) { continue; } for (int i = 0; i < amount; i++) { - const CollisionObjectSW *col_obj = intersection_query_results[i]; + const CollisionObject3DSW *col_obj = intersection_query_results[i]; int shape_idx = intersection_query_subindex_results[i]; - if (CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, NULL, p_margin)) { + if (CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), cbkres, cbkptr, nullptr, p_margin)) { collided = cbk.amount > 0; } } @@ -826,14 +826,14 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve continue; Transform body_shape_xform = body_transform * p_body->get_shape_transform(j); - ShapeSW *body_shape = p_body->get_shape(j); + Shape3DSW *body_shape = p_body->get_shape(j); - if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer::SHAPE_RAY) { + if (p_exclude_raycast_shapes && body_shape->get_type() == PhysicsServer3D::SHAPE_RAY) { continue; } Transform body_shape_xform_inv = body_shape_xform.affine_inverse(); - MotionShapeSW mshape; + MotionShape3DSW mshape; mshape.shape = body_shape; mshape.motion = body_shape_xform_inv.basis.xform(p_motion); @@ -844,7 +844,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve for (int i = 0; i < amount; i++) { - const CollisionObjectSW *col_obj = intersection_query_results[i]; + const CollisionObject3DSW *col_obj = intersection_query_results[i]; int shape_idx = intersection_query_subindex_results[i]; //test initial overlap, does it collide if going all the way? @@ -853,12 +853,12 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve Transform col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? - if (CollisionSolverSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) { + if (CollisionSolver3DSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) { continue; } sep_axis = p_motion.normalized(); - if (!CollisionSolverSW::solve_distance(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) { + if (!CollisionSolver3DSW::solve_distance(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, motion_aabb, &sep_axis)) { stuck = true; break; } @@ -878,7 +878,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve Vector3 lA, lB; - bool collided = !CollisionSolverSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep); + bool collided = !CollisionSolver3DSW::solve_distance(&mshape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj_xform, lA, lB, motion_aabb, &sep); if (collided) { @@ -935,12 +935,12 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve _RestCallbackData rcd; rcd.best_len = 0; - rcd.best_object = NULL; + rcd.best_object = nullptr; rcd.best_shape = 0; rcd.min_allowed_depth = test_motion_min_contact_depth; Transform body_shape_xform = ugt * p_body->get_shape_transform(best_shape); - ShapeSW *body_shape = p_body->get_shape(best_shape); + Shape3DSW *body_shape = p_body->get_shape(best_shape); body_aabb.position += p_motion * unsafe; @@ -948,12 +948,12 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve for (int i = 0; i < amount; i++) { - const CollisionObjectSW *col_obj = intersection_query_results[i]; + const CollisionObject3DSW *col_obj = intersection_query_results[i]; int shape_idx = intersection_query_subindex_results[i]; rcd.object = col_obj; rcd.shape = shape_idx; - bool sc = CollisionSolverSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, NULL, p_margin); + bool sc = CollisionSolver3DSW::solve_static(body_shape, body_shape_xform, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), _rest_cbk_result, &rcd, nullptr, p_margin); if (!sc) continue; } @@ -969,7 +969,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve r_result->collision_point = rcd.best_contact; //r_result->collider_metadata = rcd.best_object->get_shape_metadata(rcd.best_shape); - const BodySW *body = static_cast<const BodySW *>(rcd.best_object); + const Body3DSW *body = static_cast<const Body3DSW *>(rcd.best_object); //Vector3 rel_vec = r_result->collision_point - body->get_transform().get_origin(); // r_result->collider_velocity = Vector3(-body->get_angular_velocity() * rel_vec.y, body->get_angular_velocity() * rel_vec.x) + body->get_linear_velocity(); r_result->collider_velocity = body->get_linear_velocity() + (body->get_angular_velocity()).cross(body->get_transform().origin - rcd.best_contact); // * mPos); @@ -995,10 +995,10 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve return collided; } -void *SpaceSW::_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_self) { +void *Space3DSW::_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self) { - CollisionObjectSW::Type type_A = A->get_type(); - CollisionObjectSW::Type type_B = B->get_type(); + CollisionObject3DSW::Type type_A = A->get_type(); + CollisionObject3DSW::Type type_B = B->get_type(); if (type_A > type_B) { SWAP(A, B); @@ -1006,137 +1006,137 @@ void *SpaceSW::_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, Collisio SWAP(type_A, type_B); } - SpaceSW *self = (SpaceSW *)p_self; + Space3DSW *self = (Space3DSW *)p_self; self->collision_pairs++; - if (type_A == CollisionObjectSW::TYPE_AREA) { + if (type_A == CollisionObject3DSW::TYPE_AREA) { - AreaSW *area = static_cast<AreaSW *>(A); - if (type_B == CollisionObjectSW::TYPE_AREA) { + Area3DSW *area = static_cast<Area3DSW *>(A); + if (type_B == CollisionObject3DSW::TYPE_AREA) { - AreaSW *area_b = static_cast<AreaSW *>(B); - Area2PairSW *area2_pair = memnew(Area2PairSW(area_b, p_subindex_B, area, p_subindex_A)); + Area3DSW *area_b = static_cast<Area3DSW *>(B); + Area2Pair3DSW *area2_pair = memnew(Area2Pair3DSW(area_b, p_subindex_B, area, p_subindex_A)); return area2_pair; } else { - BodySW *body = static_cast<BodySW *>(B); - AreaPairSW *area_pair = memnew(AreaPairSW(body, p_subindex_B, area, p_subindex_A)); + Body3DSW *body = static_cast<Body3DSW *>(B); + AreaPair3DSW *area_pair = memnew(AreaPair3DSW(body, p_subindex_B, area, p_subindex_A)); return area_pair; } } else { - BodyPairSW *b = memnew(BodyPairSW((BodySW *)A, p_subindex_A, (BodySW *)B, p_subindex_B)); + BodyPair3DSW *b = memnew(BodyPair3DSW((Body3DSW *)A, p_subindex_A, (Body3DSW *)B, p_subindex_B)); return b; } - return NULL; + return nullptr; } -void SpaceSW::_broadphase_unpair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_self) { +void Space3DSW::_broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_self) { - SpaceSW *self = (SpaceSW *)p_self; + Space3DSW *self = (Space3DSW *)p_self; self->collision_pairs--; - ConstraintSW *c = (ConstraintSW *)p_data; + Constraint3DSW *c = (Constraint3DSW *)p_data; memdelete(c); } -const SelfList<BodySW>::List &SpaceSW::get_active_body_list() const { +const SelfList<Body3DSW>::List &Space3DSW::get_active_body_list() const { return active_list; } -void SpaceSW::body_add_to_active_list(SelfList<BodySW> *p_body) { +void Space3DSW::body_add_to_active_list(SelfList<Body3DSW> *p_body) { active_list.add(p_body); } -void SpaceSW::body_remove_from_active_list(SelfList<BodySW> *p_body) { +void Space3DSW::body_remove_from_active_list(SelfList<Body3DSW> *p_body) { active_list.remove(p_body); } -void SpaceSW::body_add_to_inertia_update_list(SelfList<BodySW> *p_body) { +void Space3DSW::body_add_to_inertia_update_list(SelfList<Body3DSW> *p_body) { inertia_update_list.add(p_body); } -void SpaceSW::body_remove_from_inertia_update_list(SelfList<BodySW> *p_body) { +void Space3DSW::body_remove_from_inertia_update_list(SelfList<Body3DSW> *p_body) { inertia_update_list.remove(p_body); } -BroadPhaseSW *SpaceSW::get_broadphase() { +BroadPhase3DSW *Space3DSW::get_broadphase() { return broadphase; } -void SpaceSW::add_object(CollisionObjectSW *p_object) { +void Space3DSW::add_object(CollisionObject3DSW *p_object) { ERR_FAIL_COND(objects.has(p_object)); objects.insert(p_object); } -void SpaceSW::remove_object(CollisionObjectSW *p_object) { +void Space3DSW::remove_object(CollisionObject3DSW *p_object) { ERR_FAIL_COND(!objects.has(p_object)); objects.erase(p_object); } -const Set<CollisionObjectSW *> &SpaceSW::get_objects() const { +const Set<CollisionObject3DSW *> &Space3DSW::get_objects() const { return objects; } -void SpaceSW::body_add_to_state_query_list(SelfList<BodySW> *p_body) { +void Space3DSW::body_add_to_state_query_list(SelfList<Body3DSW> *p_body) { state_query_list.add(p_body); } -void SpaceSW::body_remove_from_state_query_list(SelfList<BodySW> *p_body) { +void Space3DSW::body_remove_from_state_query_list(SelfList<Body3DSW> *p_body) { state_query_list.remove(p_body); } -void SpaceSW::area_add_to_monitor_query_list(SelfList<AreaSW> *p_area) { +void Space3DSW::area_add_to_monitor_query_list(SelfList<Area3DSW> *p_area) { monitor_query_list.add(p_area); } -void SpaceSW::area_remove_from_monitor_query_list(SelfList<AreaSW> *p_area) { +void Space3DSW::area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area) { monitor_query_list.remove(p_area); } -void SpaceSW::area_add_to_moved_list(SelfList<AreaSW> *p_area) { +void Space3DSW::area_add_to_moved_list(SelfList<Area3DSW> *p_area) { area_moved_list.add(p_area); } -void SpaceSW::area_remove_from_moved_list(SelfList<AreaSW> *p_area) { +void Space3DSW::area_remove_from_moved_list(SelfList<Area3DSW> *p_area) { area_moved_list.remove(p_area); } -const SelfList<AreaSW>::List &SpaceSW::get_moved_area_list() const { +const SelfList<Area3DSW>::List &Space3DSW::get_moved_area_list() const { return area_moved_list; } -void SpaceSW::call_queries() { +void Space3DSW::call_queries() { while (state_query_list.first()) { - BodySW *b = state_query_list.first()->self(); + Body3DSW *b = state_query_list.first()->self(); state_query_list.remove(state_query_list.first()); b->call_queries(); } while (monitor_query_list.first()) { - AreaSW *a = monitor_query_list.first()->self(); + Area3DSW *a = monitor_query_list.first()->self(); monitor_query_list.remove(monitor_query_list.first()); a->call_queries(); } } -void SpaceSW::setup() { +void Space3DSW::setup() { contact_debug_count = 0; while (inertia_update_list.first()) { @@ -1145,65 +1145,65 @@ void SpaceSW::setup() { } } -void SpaceSW::update() { +void Space3DSW::update() { broadphase->update(); } -void SpaceSW::set_param(PhysicsServer::SpaceParameter p_param, real_t p_value) { +void Space3DSW::set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break; - case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio = p_value; break; - case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break; - case PhysicsServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break; + case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: contact_recycle_radius = p_value; break; + case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: contact_max_separation = p_value; break; + case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: contact_max_allowed_penetration = p_value; break; + case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: body_linear_velocity_sleep_threshold = p_value; break; + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: body_angular_velocity_sleep_threshold = p_value; break; + case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: body_time_to_sleep = p_value; break; + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: body_angular_velocity_damp_ratio = p_value; break; + case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: constraint_bias = p_value; break; + case PhysicsServer3D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: test_motion_min_contact_depth = p_value; break; } } -real_t SpaceSW::get_param(PhysicsServer::SpaceParameter p_param) const { +real_t Space3DSW::get_param(PhysicsServer3D::SpaceParameter p_param) const { switch (p_param) { - case PhysicsServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; - case PhysicsServer::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; - case PhysicsServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; - case PhysicsServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold; - case PhysicsServer::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; - case PhysicsServer::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio; - case PhysicsServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; - case PhysicsServer::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth; + case PhysicsServer3D::SPACE_PARAM_CONTACT_RECYCLE_RADIUS: return contact_recycle_radius; + case PhysicsServer3D::SPACE_PARAM_CONTACT_MAX_SEPARATION: return contact_max_separation; + case PhysicsServer3D::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION: return contact_max_allowed_penetration; + case PhysicsServer3D::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD: return body_linear_velocity_sleep_threshold; + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD: return body_angular_velocity_sleep_threshold; + case PhysicsServer3D::SPACE_PARAM_BODY_TIME_TO_SLEEP: return body_time_to_sleep; + case PhysicsServer3D::SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO: return body_angular_velocity_damp_ratio; + case PhysicsServer3D::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS: return constraint_bias; + case PhysicsServer3D::SPACE_PARAM_TEST_MOTION_MIN_CONTACT_DEPTH: return test_motion_min_contact_depth; } return 0; } -void SpaceSW::lock() { +void Space3DSW::lock() { locked = true; } -void SpaceSW::unlock() { +void Space3DSW::unlock() { locked = false; } -bool SpaceSW::is_locked() const { +bool Space3DSW::is_locked() const { return locked; } -PhysicsDirectSpaceStateSW *SpaceSW::get_direct_state() { +PhysicsDirectSpaceState3DSW *Space3DSW::get_direct_state() { return direct_access; } -SpaceSW::SpaceSW() { +Space3DSW::Space3DSW() { collision_pairs = 0; active_objects = 0; @@ -1223,19 +1223,19 @@ SpaceSW::SpaceSW() { ProjectSettings::get_singleton()->set_custom_property_info("physics/3d/time_before_sleep", PropertyInfo(Variant::FLOAT, "physics/3d/time_before_sleep", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); body_angular_velocity_damp_ratio = 10; - broadphase = BroadPhaseSW::create_func(); + broadphase = BroadPhase3DSW::create_func(); broadphase->set_pair_callback(_broadphase_pair, this); broadphase->set_unpair_callback(_broadphase_unpair, this); - area = NULL; + area = nullptr; - direct_access = memnew(PhysicsDirectSpaceStateSW); + direct_access = memnew(PhysicsDirectSpaceState3DSW); direct_access->space = this; for (int i = 0; i < ELAPSED_TIME_MAX; i++) elapsed_time[i] = 0; } -SpaceSW::~SpaceSW() { +Space3DSW::~Space3DSW() { memdelete(broadphase); memdelete(direct_access); diff --git a/servers/physics/space_sw.h b/servers/physics_3d/space_3d_sw.h index 9e82720a75..3634834952 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics_3d/space_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* space_sw.h */ +/* space_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,35 +31,35 @@ #ifndef SPACE_SW_H #define SPACE_SW_H -#include "area_pair_sw.h" -#include "area_sw.h" -#include "body_pair_sw.h" -#include "body_sw.h" -#include "broad_phase_sw.h" -#include "collision_object_sw.h" +#include "area_3d_sw.h" +#include "area_pair_3d_sw.h" +#include "body_3d_sw.h" +#include "body_pair_3d_sw.h" +#include "broad_phase_3d_sw.h" +#include "collision_object_3d_sw.h" #include "core/hash_map.h" #include "core/project_settings.h" #include "core/typedefs.h" -class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState { +class PhysicsDirectSpaceState3DSW : public PhysicsDirectSpaceState3D { - GDCLASS(PhysicsDirectSpaceStateSW, PhysicsDirectSpaceState); + GDCLASS(PhysicsDirectSpaceState3DSW, PhysicsDirectSpaceState3D); public: - SpaceSW *space; + Space3DSW *space; virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_ray = false); virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = NULL); + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr); virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const; - PhysicsDirectSpaceStateSW(); + PhysicsDirectSpaceState3DSW(); }; -class SpaceSW { +class Space3DSW { public: enum ElapsedTime { @@ -75,22 +75,22 @@ public: private: uint64_t elapsed_time[ELAPSED_TIME_MAX]; - PhysicsDirectSpaceStateSW *direct_access; + PhysicsDirectSpaceState3DSW *direct_access; RID self; - BroadPhaseSW *broadphase; - SelfList<BodySW>::List active_list; - SelfList<BodySW>::List inertia_update_list; - SelfList<BodySW>::List state_query_list; - SelfList<AreaSW>::List monitor_query_list; - SelfList<AreaSW>::List area_moved_list; + BroadPhase3DSW *broadphase; + SelfList<Body3DSW>::List active_list; + SelfList<Body3DSW>::List inertia_update_list; + SelfList<Body3DSW>::List state_query_list; + SelfList<Area3DSW>::List monitor_query_list; + SelfList<Area3DSW>::List area_moved_list; - static void *_broadphase_pair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_self); - static void _broadphase_unpair(CollisionObjectSW *A, int p_subindex_A, CollisionObjectSW *B, int p_subindex_B, void *p_data, void *p_self); + static void *_broadphase_pair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_self); + static void _broadphase_unpair(CollisionObject3DSW *A, int p_subindex_A, CollisionObject3DSW *B, int p_subindex_B, void *p_data, void *p_self); - Set<CollisionObjectSW *> objects; + Set<CollisionObject3DSW *> objects; - AreaSW *area; + Area3DSW *area; real_t contact_recycle_radius; real_t contact_max_separation; @@ -103,7 +103,7 @@ private: INTERSECTION_QUERY_MAX = 2048 }; - CollisionObjectSW *intersection_query_results[INTERSECTION_QUERY_MAX]; + CollisionObject3DSW *intersection_query_results[INTERSECTION_QUERY_MAX]; int intersection_query_subindex_results[INTERSECTION_QUERY_MAX]; real_t body_linear_velocity_sleep_threshold; @@ -122,37 +122,37 @@ private: Vector<Vector3> contact_debug; int contact_debug_count; - friend class PhysicsDirectSpaceStateSW; + friend class PhysicsDirectSpaceState3DSW; - int _cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb); + int _cull_aabb_for_body(Body3DSW *p_body, const AABB &p_aabb); public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } _FORCE_INLINE_ RID get_self() const { return self; } - void set_default_area(AreaSW *p_area) { area = p_area; } - AreaSW *get_default_area() const { return area; } + void set_default_area(Area3DSW *p_area) { area = p_area; } + Area3DSW *get_default_area() const { return area; } - const SelfList<BodySW>::List &get_active_body_list() const; - void body_add_to_active_list(SelfList<BodySW> *p_body); - void body_remove_from_active_list(SelfList<BodySW> *p_body); - void body_add_to_inertia_update_list(SelfList<BodySW> *p_body); - void body_remove_from_inertia_update_list(SelfList<BodySW> *p_body); + const SelfList<Body3DSW>::List &get_active_body_list() const; + void body_add_to_active_list(SelfList<Body3DSW> *p_body); + void body_remove_from_active_list(SelfList<Body3DSW> *p_body); + void body_add_to_inertia_update_list(SelfList<Body3DSW> *p_body); + void body_remove_from_inertia_update_list(SelfList<Body3DSW> *p_body); - void body_add_to_state_query_list(SelfList<BodySW> *p_body); - void body_remove_from_state_query_list(SelfList<BodySW> *p_body); + void body_add_to_state_query_list(SelfList<Body3DSW> *p_body); + void body_remove_from_state_query_list(SelfList<Body3DSW> *p_body); - void area_add_to_monitor_query_list(SelfList<AreaSW> *p_area); - void area_remove_from_monitor_query_list(SelfList<AreaSW> *p_area); - void area_add_to_moved_list(SelfList<AreaSW> *p_area); - void area_remove_from_moved_list(SelfList<AreaSW> *p_area); - const SelfList<AreaSW>::List &get_moved_area_list() const; + void area_add_to_monitor_query_list(SelfList<Area3DSW> *p_area); + void area_remove_from_monitor_query_list(SelfList<Area3DSW> *p_area); + void area_add_to_moved_list(SelfList<Area3DSW> *p_area); + void area_remove_from_moved_list(SelfList<Area3DSW> *p_area); + const SelfList<Area3DSW>::List &get_moved_area_list() const; - BroadPhaseSW *get_broadphase(); + BroadPhase3DSW *get_broadphase(); - void add_object(CollisionObjectSW *p_object); - void remove_object(CollisionObjectSW *p_object); - const Set<CollisionObjectSW *> &get_objects() const; + void add_object(CollisionObject3DSW *p_object); + void remove_object(CollisionObject3DSW *p_object); + const Set<CollisionObject3DSW *> &get_objects() const; _FORCE_INLINE_ real_t get_contact_recycle_radius() const { return contact_recycle_radius; } _FORCE_INLINE_ real_t get_contact_max_separation() const { return contact_max_separation; } @@ -171,8 +171,8 @@ public: void lock(); void unlock(); - void set_param(PhysicsServer::SpaceParameter p_param, real_t p_value); - real_t get_param(PhysicsServer::SpaceParameter p_param) const; + void set_param(PhysicsServer3D::SpaceParameter p_param, real_t p_value); + real_t get_param(PhysicsServer3D::SpaceParameter p_param) const; void set_island_count(int p_island_count) { island_count = p_island_count; } int get_island_count() const { return island_count; } @@ -182,7 +182,7 @@ public: int get_collision_pairs() const { return collision_pairs; } - PhysicsDirectSpaceStateSW *get_direct_state(); + PhysicsDirectSpaceState3DSW *get_direct_state(); void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); } _FORCE_INLINE_ bool is_debugging_contacts() const { return !contact_debug.empty(); } @@ -198,11 +198,11 @@ public: void set_elapsed_time(ElapsedTime p_time, uint64_t p_msec) { elapsed_time[p_time] = p_msec; } uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; } - int test_body_ray_separation(BodySW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer::SeparationResult *r_results, int p_result_max, real_t p_margin); - bool test_body_motion(BodySW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes); + int test_body_ray_separation(Body3DSW *p_body, const Transform &p_transform, bool p_infinite_inertia, Vector3 &r_recover_motion, PhysicsServer3D::SeparationResult *r_results, int p_result_max, real_t p_margin); + bool test_body_motion(Body3DSW *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, real_t p_margin, PhysicsServer3D::MotionResult *r_result, bool p_exclude_raycast_shapes); - SpaceSW(); - ~SpaceSW(); + Space3DSW(); + ~Space3DSW(); }; #endif // SPACE__SW_H diff --git a/servers/physics/step_sw.cpp b/servers/physics_3d/step_3d_sw.cpp index f4055ecff7..1a7d5f8cec 100644 --- a/servers/physics/step_sw.cpp +++ b/servers/physics_3d/step_3d_sw.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* step_sw.cpp */ +/* step_3d_sw.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,20 +28,20 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "step_sw.h" -#include "joints_sw.h" +#include "step_3d_sw.h" +#include "joints_3d_sw.h" #include "core/os/os.h" -void StepSW::_populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW **p_constraint_island) { +void Step3DSW::_populate_island(Body3DSW *p_body, Body3DSW **p_island, Constraint3DSW **p_constraint_island) { p_body->set_island_step(_step); p_body->set_island_next(*p_island); *p_island = p_body; - for (Map<ConstraintSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) { + for (Map<Constraint3DSW *, int>::Element *E = p_body->get_constraint_map().front(); E; E = E->next()) { - ConstraintSW *c = (ConstraintSW *)E->key(); + Constraint3DSW *c = (Constraint3DSW *)E->key(); if (c->get_island_step() == _step) continue; //already processed c->set_island_step(_step); @@ -51,17 +51,17 @@ void StepSW::_populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW ** for (int i = 0; i < c->get_body_count(); i++) { if (i == E->get()) continue; - BodySW *b = c->get_body_ptr()[i]; - if (b->get_island_step() == _step || b->get_mode() == PhysicsServer::BODY_MODE_STATIC || b->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC) + Body3DSW *b = c->get_body_ptr()[i]; + if (b->get_island_step() == _step || b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) continue; //no go _populate_island(c->get_body_ptr()[i], p_island, p_constraint_island); } } } -void StepSW::_setup_island(ConstraintSW *p_island, real_t p_delta) { +void Step3DSW::_setup_island(Constraint3DSW *p_island, real_t p_delta) { - ConstraintSW *ci = p_island; + Constraint3DSW *ci = p_island; while (ci) { ci->setup(p_delta); //todo remove from island if process fails @@ -69,7 +69,7 @@ void StepSW::_setup_island(ConstraintSW *p_island, real_t p_delta) { } } -void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_delta) { +void Step3DSW::_solve_island(Constraint3DSW *p_island, int p_iterations, real_t p_delta) { int at_priority = 1; @@ -77,7 +77,7 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de for (int i = 0; i < p_iterations; i++) { - ConstraintSW *ci = p_island; + Constraint3DSW *ci = p_island; while (ci) { ci->solve(p_delta); ci = ci->get_island_next(); @@ -87,8 +87,8 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de at_priority++; { - ConstraintSW *ci = p_island; - ConstraintSW *prev = NULL; + Constraint3DSW *ci = p_island; + Constraint3DSW *prev = nullptr; while (ci) { if (ci->get_priority() < at_priority) { if (prev) { @@ -107,14 +107,14 @@ void StepSW::_solve_island(ConstraintSW *p_island, int p_iterations, real_t p_de } } -void StepSW::_check_suspend(BodySW *p_island, real_t p_delta) { +void Step3DSW::_check_suspend(Body3DSW *p_island, real_t p_delta) { bool can_sleep = true; - BodySW *b = p_island; + Body3DSW *b = p_island; while (b) { - if (b->get_mode() == PhysicsServer::BODY_MODE_STATIC || b->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC) { + if (b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) { b = b->get_island_next(); continue; //ignore for static } @@ -130,7 +130,7 @@ void StepSW::_check_suspend(BodySW *p_island, real_t p_delta) { b = p_island; while (b) { - if (b->get_mode() == PhysicsServer::BODY_MODE_STATIC || b->get_mode() == PhysicsServer::BODY_MODE_KINEMATIC) { + if (b->get_mode() == PhysicsServer3D::BODY_MODE_STATIC || b->get_mode() == PhysicsServer3D::BODY_MODE_KINEMATIC) { b = b->get_island_next(); continue; //ignore for static } @@ -144,13 +144,13 @@ void StepSW::_check_suspend(BodySW *p_island, real_t p_delta) { } } -void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { +void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) { p_space->lock(); // can't access space during this p_space->setup(); //update inertias, etc - const SelfList<BodySW>::List *body_list = &p_space->get_active_body_list(); + const SelfList<Body3DSW>::List *body_list = &p_space->get_active_body_list(); /* INTEGRATE FORCES */ @@ -159,7 +159,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { int active_count = 0; - const SelfList<BodySW> *b = body_list->first(); + const SelfList<Body3DSW> *b = body_list->first(); while (b) { b->self()->integrate_forces(p_delta); @@ -171,25 +171,25 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { { //profile profile_endtime = OS::get_singleton()->get_ticks_usec(); - p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_INTEGRATE_FORCES, profile_endtime - profile_begtime); + p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_INTEGRATE_FORCES, profile_endtime - profile_begtime); profile_begtime = profile_endtime; } /* GENERATE CONSTRAINT ISLANDS */ - BodySW *island_list = NULL; - ConstraintSW *constraint_island_list = NULL; + Body3DSW *island_list = nullptr; + Constraint3DSW *constraint_island_list = nullptr; b = body_list->first(); int island_count = 0; while (b) { - BodySW *body = b->self(); + Body3DSW *body = b->self(); if (body->get_island_step() != _step) { - BodySW *island = NULL; - ConstraintSW *constraint_island = NULL; + Body3DSW *island = nullptr; + Constraint3DSW *constraint_island = nullptr; _populate_island(body, &island, &constraint_island); island->set_island_list_next(island_list); @@ -206,32 +206,32 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { p_space->set_island_count(island_count); - const SelfList<AreaSW>::List &aml = p_space->get_moved_area_list(); + const SelfList<Area3DSW>::List &aml = p_space->get_moved_area_list(); while (aml.first()) { - for (const Set<ConstraintSW *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) { + for (const Set<Constraint3DSW *>::Element *E = aml.first()->self()->get_constraints().front(); E; E = E->next()) { - ConstraintSW *c = E->get(); + Constraint3DSW *c = E->get(); if (c->get_island_step() == _step) continue; c->set_island_step(_step); - c->set_island_next(NULL); + c->set_island_next(nullptr); c->set_island_list_next(constraint_island_list); constraint_island_list = c; } - p_space->area_remove_from_moved_list((SelfList<AreaSW> *)aml.first()); //faster to remove here + p_space->area_remove_from_moved_list((SelfList<Area3DSW> *)aml.first()); //faster to remove here } { //profile profile_endtime = OS::get_singleton()->get_ticks_usec(); - p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_GENERATE_ISLANDS, profile_endtime - profile_begtime); + p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_GENERATE_ISLANDS, profile_endtime - profile_begtime); profile_begtime = profile_endtime; } /* SETUP CONSTRAINT ISLANDS */ { - ConstraintSW *ci = constraint_island_list; + Constraint3DSW *ci = constraint_island_list; while (ci) { _setup_island(ci, p_delta); @@ -241,14 +241,14 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { { //profile profile_endtime = OS::get_singleton()->get_ticks_usec(); - p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_SETUP_CONSTRAINTS, profile_endtime - profile_begtime); + p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_SETUP_CONSTRAINTS, profile_endtime - profile_begtime); profile_begtime = profile_endtime; } /* SOLVE CONSTRAINT ISLANDS */ { - ConstraintSW *ci = constraint_island_list; + Constraint3DSW *ci = constraint_island_list; while (ci) { //iterating each island separatedly improves cache efficiency _solve_island(ci, p_iterations, p_delta); @@ -258,7 +258,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { { //profile profile_endtime = OS::get_singleton()->get_ticks_usec(); - p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_SOLVE_CONSTRAINTS, profile_endtime - profile_begtime); + p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_SOLVE_CONSTRAINTS, profile_endtime - profile_begtime); profile_begtime = profile_endtime; } @@ -266,7 +266,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { b = body_list->first(); while (b) { - const SelfList<BodySW> *n = b->next(); + const SelfList<Body3DSW> *n = b->next(); b->self()->integrate_velocities(p_delta); b = n; } @@ -274,7 +274,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { /* SLEEP / WAKE UP ISLANDS */ { - BodySW *bi = island_list; + Body3DSW *bi = island_list; while (bi) { _check_suspend(bi, p_delta); @@ -284,7 +284,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { { //profile profile_endtime = OS::get_singleton()->get_ticks_usec(); - p_space->set_elapsed_time(SpaceSW::ELAPSED_TIME_INTEGRATE_VELOCITIES, profile_endtime - profile_begtime); + p_space->set_elapsed_time(Space3DSW::ELAPSED_TIME_INTEGRATE_VELOCITIES, profile_endtime - profile_begtime); profile_begtime = profile_endtime; } @@ -293,7 +293,7 @@ void StepSW::step(SpaceSW *p_space, real_t p_delta, int p_iterations) { _step++; } -StepSW::StepSW() { +Step3DSW::Step3DSW() { _step = 1; } diff --git a/servers/physics/step_sw.h b/servers/physics_3d/step_3d_sw.h index 40022ef8b9..c735688a9e 100644 --- a/servers/physics/step_sw.h +++ b/servers/physics_3d/step_3d_sw.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* step_sw.h */ +/* step_3d_sw.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,20 +31,20 @@ #ifndef STEP_SW_H #define STEP_SW_H -#include "space_sw.h" +#include "space_3d_sw.h" -class StepSW { +class Step3DSW { uint64_t _step; - void _populate_island(BodySW *p_body, BodySW **p_island, ConstraintSW **p_constraint_island); - void _setup_island(ConstraintSW *p_island, real_t p_delta); - void _solve_island(ConstraintSW *p_island, int p_iterations, real_t p_delta); - void _check_suspend(BodySW *p_island, real_t p_delta); + void _populate_island(Body3DSW *p_body, Body3DSW **p_island, Constraint3DSW **p_constraint_island); + void _setup_island(Constraint3DSW *p_island, real_t p_delta); + void _solve_island(Constraint3DSW *p_island, int p_iterations, real_t p_delta); + void _check_suspend(Body3DSW *p_island, real_t p_delta); public: - void step(SpaceSW *p_space, real_t p_delta, int p_iterations); - StepSW(); + void step(Space3DSW *p_space, real_t p_delta, int p_iterations); + Step3DSW(); }; #endif // STEP__SW_H diff --git a/servers/physics_2d_server.cpp b/servers/physics_server_2d.cpp index 1f92d6e419..48c51b5350 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_server_2d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_2d_server.cpp */ +/* physics_server_2d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "physics_2d_server.h" +#include "physics_server_2d.h" #include "core/method_bind_ext.gen.inc" #include "core/print_string.h" #include "core/project_settings.h" -Physics2DServer *Physics2DServer::singleton = NULL; +PhysicsServer2D *PhysicsServer2D::singleton = nullptr; -void Physics2DDirectBodyState::integrate_forces() { +void PhysicsDirectBodyState2D::integrate_forces() { real_t step = get_step(); Vector2 lv = get_linear_velocity(); @@ -62,61 +62,61 @@ void Physics2DDirectBodyState::integrate_forces() { set_angular_velocity(av); } -Object *Physics2DDirectBodyState::get_contact_collider_object(int p_contact_idx) const { +Object *PhysicsDirectBodyState2D::get_contact_collider_object(int p_contact_idx) const { ObjectID objid = get_contact_collider_id(p_contact_idx); Object *obj = ObjectDB::get_instance(objid); return obj; } -Physics2DServer *Physics2DServer::get_singleton() { +PhysicsServer2D *PhysicsServer2D::get_singleton() { return singleton; } -void Physics2DDirectBodyState::_bind_methods() { +void PhysicsDirectBodyState2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_total_gravity"), &Physics2DDirectBodyState::get_total_gravity); - ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &Physics2DDirectBodyState::get_total_linear_damp); - ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &Physics2DDirectBodyState::get_total_angular_damp); + ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState2D::get_total_gravity); + ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState2D::get_total_linear_damp); + ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp); - ClassDB::bind_method(D_METHOD("get_inverse_mass"), &Physics2DDirectBodyState::get_inverse_mass); - ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &Physics2DDirectBodyState::get_inverse_inertia); + ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState2D::get_inverse_mass); + ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState2D::get_inverse_inertia); - ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &Physics2DDirectBodyState::set_linear_velocity); - ClassDB::bind_method(D_METHOD("get_linear_velocity"), &Physics2DDirectBodyState::get_linear_velocity); + ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState2D::set_linear_velocity); + ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState2D::get_linear_velocity); - ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &Physics2DDirectBodyState::set_angular_velocity); - ClassDB::bind_method(D_METHOD("get_angular_velocity"), &Physics2DDirectBodyState::get_angular_velocity); + ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState2D::set_angular_velocity); + ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState2D::get_angular_velocity); - ClassDB::bind_method(D_METHOD("set_transform", "transform"), &Physics2DDirectBodyState::set_transform); - ClassDB::bind_method(D_METHOD("get_transform"), &Physics2DDirectBodyState::get_transform); + ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState2D::set_transform); + ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState2D::get_transform); - ClassDB::bind_method(D_METHOD("add_central_force", "force"), &Physics2DDirectBodyState::add_central_force); - ClassDB::bind_method(D_METHOD("add_force", "offset", "force"), &Physics2DDirectBodyState::add_force); - ClassDB::bind_method(D_METHOD("add_torque", "torque"), &Physics2DDirectBodyState::add_torque); - ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &Physics2DDirectBodyState::apply_central_impulse); - ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &Physics2DDirectBodyState::apply_torque_impulse); - ClassDB::bind_method(D_METHOD("apply_impulse", "offset", "impulse"), &Physics2DDirectBodyState::apply_impulse); + ClassDB::bind_method(D_METHOD("add_central_force", "force"), &PhysicsDirectBodyState2D::add_central_force); + ClassDB::bind_method(D_METHOD("add_force", "offset", "force"), &PhysicsDirectBodyState2D::add_force); + ClassDB::bind_method(D_METHOD("add_torque", "torque"), &PhysicsDirectBodyState2D::add_torque); + ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_central_impulse); + ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &PhysicsDirectBodyState2D::apply_torque_impulse); + ClassDB::bind_method(D_METHOD("apply_impulse", "offset", "impulse"), &PhysicsDirectBodyState2D::apply_impulse); - ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &Physics2DDirectBodyState::set_sleep_state); - ClassDB::bind_method(D_METHOD("is_sleeping"), &Physics2DDirectBodyState::is_sleeping); + ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState2D::set_sleep_state); + ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState2D::is_sleeping); - ClassDB::bind_method(D_METHOD("get_contact_count"), &Physics2DDirectBodyState::get_contact_count); + ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState2D::get_contact_count); - ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &Physics2DDirectBodyState::get_contact_local_position); - ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &Physics2DDirectBodyState::get_contact_local_normal); - ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &Physics2DDirectBodyState::get_contact_local_shape); - ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider); - ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_position); - ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_id); - ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_object); - ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_shape); - ClassDB::bind_method(D_METHOD("get_contact_collider_shape_metadata", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_shape_metadata); - ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &Physics2DDirectBodyState::get_contact_collider_velocity_at_position); - ClassDB::bind_method(D_METHOD("get_step"), &Physics2DDirectBodyState::get_step); - ClassDB::bind_method(D_METHOD("integrate_forces"), &Physics2DDirectBodyState::integrate_forces); - ClassDB::bind_method(D_METHOD("get_space_state"), &Physics2DDirectBodyState::get_space_state); + ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_position); + ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_normal); + ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_local_shape); + ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider); + ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_position); + ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_id); + ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_object); + ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape); + ClassDB::bind_method(D_METHOD("get_contact_collider_shape_metadata", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_shape_metadata); + ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState2D::get_contact_collider_velocity_at_position); + ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState2D::get_step); + ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState2D::integrate_forces); + ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState2D::get_space_state); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass"); @@ -130,70 +130,70 @@ void Physics2DDirectBodyState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform"); } -Physics2DDirectBodyState::Physics2DDirectBodyState() {} +PhysicsDirectBodyState2D::PhysicsDirectBodyState2D() {} /////////////////////////////////////////////////////// -void Physics2DShapeQueryParameters::set_shape(const RES &p_shape) { +void PhysicsShapeQueryParameters2D::set_shape(const RES &p_shape) { ERR_FAIL_COND(p_shape.is_null()); shape = p_shape->get_rid(); } -void Physics2DShapeQueryParameters::set_shape_rid(const RID &p_shape) { +void PhysicsShapeQueryParameters2D::set_shape_rid(const RID &p_shape) { shape = p_shape; } -RID Physics2DShapeQueryParameters::get_shape_rid() const { +RID PhysicsShapeQueryParameters2D::get_shape_rid() const { return shape; } -void Physics2DShapeQueryParameters::set_transform(const Transform2D &p_transform) { +void PhysicsShapeQueryParameters2D::set_transform(const Transform2D &p_transform) { transform = p_transform; } -Transform2D Physics2DShapeQueryParameters::get_transform() const { +Transform2D PhysicsShapeQueryParameters2D::get_transform() const { return transform; } -void Physics2DShapeQueryParameters::set_motion(const Vector2 &p_motion) { +void PhysicsShapeQueryParameters2D::set_motion(const Vector2 &p_motion) { motion = p_motion; } -Vector2 Physics2DShapeQueryParameters::get_motion() const { +Vector2 PhysicsShapeQueryParameters2D::get_motion() const { return motion; } -void Physics2DShapeQueryParameters::set_margin(float p_margin) { +void PhysicsShapeQueryParameters2D::set_margin(float p_margin) { margin = p_margin; } -float Physics2DShapeQueryParameters::get_margin() const { +float PhysicsShapeQueryParameters2D::get_margin() const { return margin; } -void Physics2DShapeQueryParameters::set_collision_mask(int p_collision_mask) { +void PhysicsShapeQueryParameters2D::set_collision_mask(int p_collision_mask) { collision_mask = p_collision_mask; } -int Physics2DShapeQueryParameters::get_collision_mask() const { +int PhysicsShapeQueryParameters2D::get_collision_mask() const { return collision_mask; } -void Physics2DShapeQueryParameters::set_exclude(const Vector<RID> &p_exclude) { +void PhysicsShapeQueryParameters2D::set_exclude(const Vector<RID> &p_exclude) { exclude.clear(); for (int i = 0; i < p_exclude.size(); i++) exclude.insert(p_exclude[i]); } -Vector<RID> Physics2DShapeQueryParameters::get_exclude() const { +Vector<RID> PhysicsShapeQueryParameters2D::get_exclude() const { Vector<RID> ret; ret.resize(exclude.size()); @@ -204,48 +204,48 @@ Vector<RID> Physics2DShapeQueryParameters::get_exclude() const { return ret; } -void Physics2DShapeQueryParameters::set_collide_with_bodies(bool p_enable) { +void PhysicsShapeQueryParameters2D::set_collide_with_bodies(bool p_enable) { collide_with_bodies = p_enable; } -bool Physics2DShapeQueryParameters::is_collide_with_bodies_enabled() const { +bool PhysicsShapeQueryParameters2D::is_collide_with_bodies_enabled() const { return collide_with_bodies; } -void Physics2DShapeQueryParameters::set_collide_with_areas(bool p_enable) { +void PhysicsShapeQueryParameters2D::set_collide_with_areas(bool p_enable) { collide_with_areas = p_enable; } -bool Physics2DShapeQueryParameters::is_collide_with_areas_enabled() const { +bool PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled() const { return collide_with_areas; } -void Physics2DShapeQueryParameters::_bind_methods() { +void PhysicsShapeQueryParameters2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_shape", "shape"), &Physics2DShapeQueryParameters::set_shape); - ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &Physics2DShapeQueryParameters::set_shape_rid); - ClassDB::bind_method(D_METHOD("get_shape_rid"), &Physics2DShapeQueryParameters::get_shape_rid); + ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters2D::set_shape); + ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters2D::set_shape_rid); + ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters2D::get_shape_rid); - ClassDB::bind_method(D_METHOD("set_transform", "transform"), &Physics2DShapeQueryParameters::set_transform); - ClassDB::bind_method(D_METHOD("get_transform"), &Physics2DShapeQueryParameters::get_transform); + ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters2D::set_transform); + ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters2D::get_transform); - ClassDB::bind_method(D_METHOD("set_motion", "motion"), &Physics2DShapeQueryParameters::set_motion); - ClassDB::bind_method(D_METHOD("get_motion"), &Physics2DShapeQueryParameters::get_motion); + ClassDB::bind_method(D_METHOD("set_motion", "motion"), &PhysicsShapeQueryParameters2D::set_motion); + ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsShapeQueryParameters2D::get_motion); - ClassDB::bind_method(D_METHOD("set_margin", "margin"), &Physics2DShapeQueryParameters::set_margin); - ClassDB::bind_method(D_METHOD("get_margin"), &Physics2DShapeQueryParameters::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters2D::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters2D::get_margin); - ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &Physics2DShapeQueryParameters::set_collision_mask); - ClassDB::bind_method(D_METHOD("get_collision_layer"), &Physics2DShapeQueryParameters::get_collision_mask); + ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &PhysicsShapeQueryParameters2D::set_collision_mask); + ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsShapeQueryParameters2D::get_collision_mask); - ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &Physics2DShapeQueryParameters::set_exclude); - ClassDB::bind_method(D_METHOD("get_exclude"), &Physics2DShapeQueryParameters::get_exclude); + ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters2D::set_exclude); + ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters2D::get_exclude); - ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &Physics2DShapeQueryParameters::set_collide_with_bodies); - ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &Physics2DShapeQueryParameters::is_collide_with_bodies_enabled); + ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_bodies); + ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_bodies_enabled); - ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &Physics2DShapeQueryParameters::set_collide_with_areas); - ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &Physics2DShapeQueryParameters::is_collide_with_areas_enabled); + ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters2D::set_collide_with_areas); + ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters2D::is_collide_with_areas_enabled); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_NONE, itos(Variant::_RID) + ":"), "set_exclude", "get_exclude"); @@ -258,7 +258,7 @@ void Physics2DShapeQueryParameters::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled"); } -Physics2DShapeQueryParameters::Physics2DShapeQueryParameters() { +PhysicsShapeQueryParameters2D::PhysicsShapeQueryParameters2D() { margin = 0; collision_mask = 0x7FFFFFFF; @@ -266,7 +266,7 @@ Physics2DShapeQueryParameters::Physics2DShapeQueryParameters() { collide_with_areas = false; } -Dictionary Physics2DDirectSpaceState::_intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) { +Dictionary PhysicsDirectSpaceState2D::_intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) { RayResult inters; Set<RID> exclude; @@ -290,7 +290,7 @@ Dictionary Physics2DDirectSpaceState::_intersect_ray(const Vector2 &p_from, cons return d; } -Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) { +Array PhysicsDirectSpaceState2D::_intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); @@ -313,7 +313,7 @@ Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryP return ret; } -Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParameters> &p_shape_query) { +Array PhysicsDirectSpaceState2D::_cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); @@ -328,7 +328,7 @@ Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParam return ret; } -Array Physics2DDirectSpaceState::_intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) { +Array PhysicsDirectSpaceState2D::_intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas, ObjectID p_canvas_instance_id) { Set<RID> exclude; for (int i = 0; i < p_exclude.size(); i++) @@ -361,17 +361,17 @@ Array Physics2DDirectSpaceState::_intersect_point_impl(const Vector2 &p_point, i return r; } -Array Physics2DDirectSpaceState::_intersect_point(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) { +Array PhysicsDirectSpaceState2D::_intersect_point(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) { return _intersect_point_impl(p_point, p_max_results, p_exclude, p_layers, p_collide_with_bodies, p_collide_with_areas); } -Array Physics2DDirectSpaceState::_intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) { +Array PhysicsDirectSpaceState2D::_intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results, const Vector<RID> &p_exclude, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas) { return _intersect_point_impl(p_point, p_max_results, p_exclude, p_layers, p_collide_with_bodies, p_collide_with_areas, true, p_canvas_intance_id); } -Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) { +Array PhysicsDirectSpaceState2D::_collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); @@ -387,7 +387,7 @@ Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryPar r[i] = ret[i]; return r; } -Dictionary Physics2DDirectSpaceState::_get_rest_info(const Ref<Physics2DShapeQueryParameters> &p_shape_query) { +Dictionary PhysicsDirectSpaceState2D::_get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary()); @@ -409,105 +409,105 @@ Dictionary Physics2DDirectSpaceState::_get_rest_info(const Ref<Physics2DShapeQue return r; } -Physics2DDirectSpaceState::Physics2DDirectSpaceState() { +PhysicsDirectSpaceState2D::PhysicsDirectSpaceState2D() { } -void Physics2DDirectSpaceState::_bind_methods() { +void PhysicsDirectSpaceState2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("intersect_point", "point", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &Physics2DDirectSpaceState::_intersect_point, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("intersect_point_on_canvas", "point", "canvas_instance_id", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &Physics2DDirectSpaceState::_intersect_point_on_canvas, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &Physics2DDirectSpaceState::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &Physics2DDirectSpaceState::_intersect_shape, DEFVAL(32)); - ClassDB::bind_method(D_METHOD("cast_motion", "shape"), &Physics2DDirectSpaceState::_cast_motion); - ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &Physics2DDirectSpaceState::_collide_shape, DEFVAL(32)); - ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &Physics2DDirectSpaceState::_get_rest_info); + ClassDB::bind_method(D_METHOD("intersect_point", "point", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("intersect_point_on_canvas", "point", "canvas_instance_id", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point_on_canvas, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState2D::_intersect_shape, DEFVAL(32)); + ClassDB::bind_method(D_METHOD("cast_motion", "shape"), &PhysicsDirectSpaceState2D::_cast_motion); + ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState2D::_collide_shape, DEFVAL(32)); + ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState2D::_get_rest_info); } -int Physics2DShapeQueryResult::get_result_count() const { +int PhysicsShapeQueryResult2D::get_result_count() const { return result.size(); } -RID Physics2DShapeQueryResult::get_result_rid(int p_idx) const { +RID PhysicsShapeQueryResult2D::get_result_rid(int p_idx) const { return result[p_idx].rid; } -ObjectID Physics2DShapeQueryResult::get_result_object_id(int p_idx) const { +ObjectID PhysicsShapeQueryResult2D::get_result_object_id(int p_idx) const { return result[p_idx].collider_id; } -Object *Physics2DShapeQueryResult::get_result_object(int p_idx) const { +Object *PhysicsShapeQueryResult2D::get_result_object(int p_idx) const { return result[p_idx].collider; } -int Physics2DShapeQueryResult::get_result_object_shape(int p_idx) const { +int PhysicsShapeQueryResult2D::get_result_object_shape(int p_idx) const { return result[p_idx].shape; } -Physics2DShapeQueryResult::Physics2DShapeQueryResult() { +PhysicsShapeQueryResult2D::PhysicsShapeQueryResult2D() { } -void Physics2DShapeQueryResult::_bind_methods() { +void PhysicsShapeQueryResult2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_result_count"), &Physics2DShapeQueryResult::get_result_count); - ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &Physics2DShapeQueryResult::get_result_rid); - ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &Physics2DShapeQueryResult::get_result_object_id); - ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &Physics2DShapeQueryResult::get_result_object); - ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &Physics2DShapeQueryResult::get_result_object_shape); + ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult2D::get_result_count); + ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult2D::get_result_rid); + ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult2D::get_result_object_id); + ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult2D::get_result_object); + ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult2D::get_result_object_shape); } /////////////////////////////// -Vector2 Physics2DTestMotionResult::get_motion() const { +Vector2 PhysicsTestMotionResult2D::get_motion() const { return result.motion; } -Vector2 Physics2DTestMotionResult::get_motion_remainder() const { +Vector2 PhysicsTestMotionResult2D::get_motion_remainder() const { return result.remainder; } -Vector2 Physics2DTestMotionResult::get_collision_point() const { +Vector2 PhysicsTestMotionResult2D::get_collision_point() const { return result.collision_point; } -Vector2 Physics2DTestMotionResult::get_collision_normal() const { +Vector2 PhysicsTestMotionResult2D::get_collision_normal() const { return result.collision_normal; } -Vector2 Physics2DTestMotionResult::get_collider_velocity() const { +Vector2 PhysicsTestMotionResult2D::get_collider_velocity() const { return result.collider_velocity; } -ObjectID Physics2DTestMotionResult::get_collider_id() const { +ObjectID PhysicsTestMotionResult2D::get_collider_id() const { return result.collider_id; } -RID Physics2DTestMotionResult::get_collider_rid() const { +RID PhysicsTestMotionResult2D::get_collider_rid() const { return result.collider; } -Object *Physics2DTestMotionResult::get_collider() const { +Object *PhysicsTestMotionResult2D::get_collider() const { return ObjectDB::get_instance(result.collider_id); } -int Physics2DTestMotionResult::get_collider_shape() const { +int PhysicsTestMotionResult2D::get_collider_shape() const { return result.collider_shape; } -void Physics2DTestMotionResult::_bind_methods() { +void PhysicsTestMotionResult2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_motion"), &Physics2DTestMotionResult::get_motion); - ClassDB::bind_method(D_METHOD("get_motion_remainder"), &Physics2DTestMotionResult::get_motion_remainder); - ClassDB::bind_method(D_METHOD("get_collision_point"), &Physics2DTestMotionResult::get_collision_point); - ClassDB::bind_method(D_METHOD("get_collision_normal"), &Physics2DTestMotionResult::get_collision_normal); - ClassDB::bind_method(D_METHOD("get_collider_velocity"), &Physics2DTestMotionResult::get_collider_velocity); - ClassDB::bind_method(D_METHOD("get_collider_id"), &Physics2DTestMotionResult::get_collider_id); - ClassDB::bind_method(D_METHOD("get_collider_rid"), &Physics2DTestMotionResult::get_collider_rid); - ClassDB::bind_method(D_METHOD("get_collider"), &Physics2DTestMotionResult::get_collider); - ClassDB::bind_method(D_METHOD("get_collider_shape"), &Physics2DTestMotionResult::get_collider_shape); + ClassDB::bind_method(D_METHOD("get_motion"), &PhysicsTestMotionResult2D::get_motion); + ClassDB::bind_method(D_METHOD("get_motion_remainder"), &PhysicsTestMotionResult2D::get_motion_remainder); + ClassDB::bind_method(D_METHOD("get_collision_point"), &PhysicsTestMotionResult2D::get_collision_point); + ClassDB::bind_method(D_METHOD("get_collision_normal"), &PhysicsTestMotionResult2D::get_collision_normal); + ClassDB::bind_method(D_METHOD("get_collider_velocity"), &PhysicsTestMotionResult2D::get_collider_velocity); + ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsTestMotionResult2D::get_collider_id); + ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsTestMotionResult2D::get_collider_rid); + ClassDB::bind_method(D_METHOD("get_collider"), &PhysicsTestMotionResult2D::get_collider); + ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsTestMotionResult2D::get_collider_shape); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion"), "", "get_motion"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion_remainder"), "", "get_motion_remainder"); @@ -520,7 +520,7 @@ void Physics2DTestMotionResult::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape"); } -Physics2DTestMotionResult::Physics2DTestMotionResult() { +PhysicsTestMotionResult2D::PhysicsTestMotionResult2D() { colliding = false; @@ -529,162 +529,162 @@ Physics2DTestMotionResult::Physics2DTestMotionResult() { /////////////////////////////////////// -bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) { +bool PhysicsServer2D::_body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin, const Ref<PhysicsTestMotionResult2D> &p_result) { - MotionResult *r = NULL; + MotionResult *r = nullptr; if (p_result.is_valid()) r = p_result->get_result_ptr(); return body_test_motion(p_body, p_from, p_motion, p_infinite_inertia, p_margin, r); } -void Physics2DServer::_bind_methods() { +void PhysicsServer2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("line_shape_create"), &Physics2DServer::line_shape_create); - ClassDB::bind_method(D_METHOD("ray_shape_create"), &Physics2DServer::ray_shape_create); - ClassDB::bind_method(D_METHOD("segment_shape_create"), &Physics2DServer::segment_shape_create); - ClassDB::bind_method(D_METHOD("circle_shape_create"), &Physics2DServer::circle_shape_create); - ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &Physics2DServer::rectangle_shape_create); - ClassDB::bind_method(D_METHOD("capsule_shape_create"), &Physics2DServer::capsule_shape_create); - ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &Physics2DServer::convex_polygon_shape_create); - ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &Physics2DServer::concave_polygon_shape_create); + ClassDB::bind_method(D_METHOD("line_shape_create"), &PhysicsServer2D::line_shape_create); + ClassDB::bind_method(D_METHOD("ray_shape_create"), &PhysicsServer2D::ray_shape_create); + ClassDB::bind_method(D_METHOD("segment_shape_create"), &PhysicsServer2D::segment_shape_create); + ClassDB::bind_method(D_METHOD("circle_shape_create"), &PhysicsServer2D::circle_shape_create); + ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &PhysicsServer2D::rectangle_shape_create); + ClassDB::bind_method(D_METHOD("capsule_shape_create"), &PhysicsServer2D::capsule_shape_create); + ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &PhysicsServer2D::convex_polygon_shape_create); + ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &PhysicsServer2D::concave_polygon_shape_create); - ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &Physics2DServer::shape_set_data); + ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer2D::shape_set_data); - ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &Physics2DServer::shape_get_type); - ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &Physics2DServer::shape_get_data); + ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer2D::shape_get_type); + ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer2D::shape_get_data); - ClassDB::bind_method(D_METHOD("space_create"), &Physics2DServer::space_create); - ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &Physics2DServer::space_set_active); - ClassDB::bind_method(D_METHOD("space_is_active", "space"), &Physics2DServer::space_is_active); - ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &Physics2DServer::space_set_param); - ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &Physics2DServer::space_get_param); - ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &Physics2DServer::space_get_direct_state); + ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer2D::space_create); + ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer2D::space_set_active); + ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer2D::space_is_active); + ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer2D::space_set_param); + ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer2D::space_get_param); + ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer2D::space_get_direct_state); - ClassDB::bind_method(D_METHOD("area_create"), &Physics2DServer::area_create); - ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &Physics2DServer::area_set_space); - ClassDB::bind_method(D_METHOD("area_get_space", "area"), &Physics2DServer::area_get_space); + ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer2D::area_create); + ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer2D::area_set_space); + ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer2D::area_get_space); - ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &Physics2DServer::area_set_space_override_mode); - ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &Physics2DServer::area_get_space_override_mode); + ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer2D::area_set_space_override_mode); + ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer2D::area_get_space_override_mode); - ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &Physics2DServer::area_add_shape, DEFVAL(Transform2D()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &Physics2DServer::area_set_shape); - ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &Physics2DServer::area_set_shape_transform); - ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &Physics2DServer::area_set_shape_disabled); + ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer2D::area_add_shape, DEFVAL(Transform2D()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer2D::area_set_shape); + ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer2D::area_set_shape_transform); + ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &PhysicsServer2D::area_set_shape_disabled); - ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &Physics2DServer::area_get_shape_count); - ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &Physics2DServer::area_get_shape); - ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &Physics2DServer::area_get_shape_transform); + ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer2D::area_get_shape_count); + ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer2D::area_get_shape); + ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer2D::area_get_shape_transform); - ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &Physics2DServer::area_remove_shape); - ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &Physics2DServer::area_clear_shapes); + ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer2D::area_remove_shape); + ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer2D::area_clear_shapes); - ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &Physics2DServer::area_set_collision_layer); - ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &Physics2DServer::area_set_collision_mask); + ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer2D::area_set_collision_layer); + ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer2D::area_set_collision_mask); - ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &Physics2DServer::area_set_param); - ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &Physics2DServer::area_set_transform); + ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer2D::area_set_param); + ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer2D::area_set_transform); - ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &Physics2DServer::area_get_param); - ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &Physics2DServer::area_get_transform); + ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer2D::area_get_param); + ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer2D::area_get_transform); - ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &Physics2DServer::area_attach_object_instance_id); - ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &Physics2DServer::area_get_object_instance_id); + ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer2D::area_attach_object_instance_id); + ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer2D::area_get_object_instance_id); - ClassDB::bind_method(D_METHOD("area_attach_canvas_instance_id", "area", "id"), &Physics2DServer::area_attach_canvas_instance_id); - ClassDB::bind_method(D_METHOD("area_get_canvas_instance_id", "area"), &Physics2DServer::area_get_canvas_instance_id); + ClassDB::bind_method(D_METHOD("area_attach_canvas_instance_id", "area", "id"), &PhysicsServer2D::area_attach_canvas_instance_id); + ClassDB::bind_method(D_METHOD("area_get_canvas_instance_id", "area"), &PhysicsServer2D::area_get_canvas_instance_id); - ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &Physics2DServer::area_set_monitor_callback); - ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &Physics2DServer::area_set_area_monitor_callback); - ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &Physics2DServer::area_set_monitorable); + ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer2D::area_set_monitor_callback); + ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &PhysicsServer2D::area_set_area_monitor_callback); + ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &PhysicsServer2D::area_set_monitorable); - ClassDB::bind_method(D_METHOD("body_create"), &Physics2DServer::body_create); + ClassDB::bind_method(D_METHOD("body_create"), &PhysicsServer2D::body_create); - ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &Physics2DServer::body_set_space); - ClassDB::bind_method(D_METHOD("body_get_space", "body"), &Physics2DServer::body_get_space); + ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer2D::body_set_space); + ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer2D::body_get_space); - ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &Physics2DServer::body_set_mode); - ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &Physics2DServer::body_get_mode); + ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer2D::body_set_mode); + ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer2D::body_get_mode); - ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &Physics2DServer::body_add_shape, DEFVAL(Transform2D()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &Physics2DServer::body_set_shape); - ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &Physics2DServer::body_set_shape_transform); - ClassDB::bind_method(D_METHOD("body_set_shape_metadata", "body", "shape_idx", "metadata"), &Physics2DServer::body_set_shape_metadata); + ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer2D::body_add_shape, DEFVAL(Transform2D()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer2D::body_set_shape); + ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer2D::body_set_shape_transform); + ClassDB::bind_method(D_METHOD("body_set_shape_metadata", "body", "shape_idx", "metadata"), &PhysicsServer2D::body_set_shape_metadata); - ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &Physics2DServer::body_get_shape_count); - ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &Physics2DServer::body_get_shape); - ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &Physics2DServer::body_get_shape_transform); - ClassDB::bind_method(D_METHOD("body_get_shape_metadata", "body", "shape_idx"), &Physics2DServer::body_get_shape_metadata); + ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer2D::body_get_shape_count); + ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer2D::body_get_shape); + ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer2D::body_get_shape_transform); + ClassDB::bind_method(D_METHOD("body_get_shape_metadata", "body", "shape_idx"), &PhysicsServer2D::body_get_shape_metadata); - ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &Physics2DServer::body_remove_shape); - ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &Physics2DServer::body_clear_shapes); + ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer2D::body_remove_shape); + ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer2D::body_clear_shapes); - ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &Physics2DServer::body_set_shape_disabled); - ClassDB::bind_method(D_METHOD("body_set_shape_as_one_way_collision", "body", "shape_idx", "enable", "margin"), &Physics2DServer::body_set_shape_as_one_way_collision); + ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &PhysicsServer2D::body_set_shape_disabled); + ClassDB::bind_method(D_METHOD("body_set_shape_as_one_way_collision", "body", "shape_idx", "enable", "margin"), &PhysicsServer2D::body_set_shape_as_one_way_collision); - ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &Physics2DServer::body_attach_object_instance_id); - ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &Physics2DServer::body_get_object_instance_id); + ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer2D::body_attach_object_instance_id); + ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer2D::body_get_object_instance_id); - ClassDB::bind_method(D_METHOD("body_attach_canvas_instance_id", "body", "id"), &Physics2DServer::body_attach_canvas_instance_id); - ClassDB::bind_method(D_METHOD("body_get_canvas_instance_id", "body"), &Physics2DServer::body_get_canvas_instance_id); + ClassDB::bind_method(D_METHOD("body_attach_canvas_instance_id", "body", "id"), &PhysicsServer2D::body_attach_canvas_instance_id); + ClassDB::bind_method(D_METHOD("body_get_canvas_instance_id", "body"), &PhysicsServer2D::body_get_canvas_instance_id); - ClassDB::bind_method(D_METHOD("body_set_continuous_collision_detection_mode", "body", "mode"), &Physics2DServer::body_set_continuous_collision_detection_mode); - ClassDB::bind_method(D_METHOD("body_get_continuous_collision_detection_mode", "body"), &Physics2DServer::body_get_continuous_collision_detection_mode); + ClassDB::bind_method(D_METHOD("body_set_continuous_collision_detection_mode", "body", "mode"), &PhysicsServer2D::body_set_continuous_collision_detection_mode); + ClassDB::bind_method(D_METHOD("body_get_continuous_collision_detection_mode", "body"), &PhysicsServer2D::body_get_continuous_collision_detection_mode); - ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &Physics2DServer::body_set_collision_layer); - ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &Physics2DServer::body_get_collision_layer); + ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer2D::body_set_collision_layer); + ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer2D::body_get_collision_layer); - ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &Physics2DServer::body_set_collision_mask); - ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &Physics2DServer::body_get_collision_mask); + ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer2D::body_set_collision_mask); + ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer2D::body_get_collision_mask); - ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &Physics2DServer::body_set_param); - ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &Physics2DServer::body_get_param); + ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer2D::body_set_param); + ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer2D::body_get_param); - ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &Physics2DServer::body_set_state); - ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &Physics2DServer::body_get_state); + ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer2D::body_set_state); + ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer2D::body_get_state); - ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &Physics2DServer::body_apply_central_impulse); - ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &Physics2DServer::body_apply_torque_impulse); - ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &Physics2DServer::body_apply_impulse); - ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &Physics2DServer::body_add_central_force); - ClassDB::bind_method(D_METHOD("body_add_force", "body", "offset", "force"), &Physics2DServer::body_add_force); - ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &Physics2DServer::body_add_torque); - ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &Physics2DServer::body_set_axis_velocity); + ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &PhysicsServer2D::body_apply_central_impulse); + ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer2D::body_apply_torque_impulse); + ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer2D::body_apply_impulse); + ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &PhysicsServer2D::body_add_central_force); + ClassDB::bind_method(D_METHOD("body_add_force", "body", "offset", "force"), &PhysicsServer2D::body_add_force); + ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &PhysicsServer2D::body_add_torque); + ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer2D::body_set_axis_velocity); - ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &Physics2DServer::body_add_collision_exception); - ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &Physics2DServer::body_remove_collision_exception); + ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer2D::body_add_collision_exception); + ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer2D::body_remove_collision_exception); - ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &Physics2DServer::body_set_max_contacts_reported); - ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &Physics2DServer::body_get_max_contacts_reported); + ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer2D::body_set_max_contacts_reported); + ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer2D::body_get_max_contacts_reported); - ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &Physics2DServer::body_set_omit_force_integration); - ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &Physics2DServer::body_is_omitting_force_integration); + ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer2D::body_set_omit_force_integration); + ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer2D::body_is_omitting_force_integration); - ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &Physics2DServer::body_set_force_integration_callback, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer2D::body_set_force_integration_callback, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &Physics2DServer::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "infinite_inertia", "margin", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &Physics2DServer::body_get_direct_state); + ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer2D::body_get_direct_state); /* JOINT API */ - ClassDB::bind_method(D_METHOD("joint_set_param", "joint", "param", "value"), &Physics2DServer::joint_set_param); - ClassDB::bind_method(D_METHOD("joint_get_param", "joint", "param"), &Physics2DServer::joint_get_param); + ClassDB::bind_method(D_METHOD("joint_set_param", "joint", "param", "value"), &PhysicsServer2D::joint_set_param); + ClassDB::bind_method(D_METHOD("joint_get_param", "joint", "param"), &PhysicsServer2D::joint_get_param); - ClassDB::bind_method(D_METHOD("pin_joint_create", "anchor", "body_a", "body_b"), &Physics2DServer::pin_joint_create, DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("groove_joint_create", "groove1_a", "groove2_a", "anchor_b", "body_a", "body_b"), &Physics2DServer::groove_joint_create, DEFVAL(RID()), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("damped_spring_joint_create", "anchor_a", "anchor_b", "body_a", "body_b"), &Physics2DServer::damped_spring_joint_create, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("pin_joint_create", "anchor", "body_a", "body_b"), &PhysicsServer2D::pin_joint_create, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("groove_joint_create", "groove1_a", "groove2_a", "anchor_b", "body_a", "body_b"), &PhysicsServer2D::groove_joint_create, DEFVAL(RID()), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("damped_spring_joint_create", "anchor_a", "anchor_b", "body_a", "body_b"), &PhysicsServer2D::damped_spring_joint_create, DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("damped_string_joint_set_param", "joint", "param", "value"), &Physics2DServer::damped_string_joint_set_param); - ClassDB::bind_method(D_METHOD("damped_string_joint_get_param", "joint", "param"), &Physics2DServer::damped_string_joint_get_param); + ClassDB::bind_method(D_METHOD("damped_string_joint_set_param", "joint", "param", "value"), &PhysicsServer2D::damped_string_joint_set_param); + ClassDB::bind_method(D_METHOD("damped_string_joint_get_param", "joint", "param"), &PhysicsServer2D::damped_string_joint_get_param); - ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &Physics2DServer::joint_get_type); + ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer2D::joint_get_type); - ClassDB::bind_method(D_METHOD("free_rid", "rid"), &Physics2DServer::free); + ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer2D::free); - ClassDB::bind_method(D_METHOD("set_active", "active"), &Physics2DServer::set_active); + ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer2D::set_active); - ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &Physics2DServer::get_process_info); + ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer2D::get_process_info); BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS); BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION); @@ -764,22 +764,22 @@ void Physics2DServer::_bind_methods() { BIND_ENUM_CONSTANT(INFO_ISLAND_COUNT); } -Physics2DServer::Physics2DServer() { +PhysicsServer2D::PhysicsServer2D() { singleton = this; } -Physics2DServer::~Physics2DServer() { +PhysicsServer2D::~PhysicsServer2D() { - singleton = NULL; + singleton = nullptr; } -Vector<Physics2DServerManager::ClassInfo> Physics2DServerManager::physics_2d_servers; -int Physics2DServerManager::default_server_id = -1; -int Physics2DServerManager::default_server_priority = -1; -const String Physics2DServerManager::setting_property_name("physics/2d/physics_engine"); +Vector<PhysicsServer2DManager::ClassInfo> PhysicsServer2DManager::physics_2d_servers; +int PhysicsServer2DManager::default_server_id = -1; +int PhysicsServer2DManager::default_server_priority = -1; +const String PhysicsServer2DManager::setting_property_name("physics/2d/physics_engine"); -void Physics2DServerManager::on_servers_changed() { +void PhysicsServer2DManager::on_servers_changed() { String physics_servers("DEFAULT"); for (int i = get_servers_count() - 1; 0 <= i; --i) { @@ -788,7 +788,7 @@ void Physics2DServerManager::on_servers_changed() { ProjectSettings::get_singleton()->set_custom_property_info(setting_property_name, PropertyInfo(Variant::STRING, setting_property_name, PROPERTY_HINT_ENUM, physics_servers)); } -void Physics2DServerManager::register_server(const String &p_name, CreatePhysics2DServerCallback p_creat_callback) { +void PhysicsServer2DManager::register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback) { ERR_FAIL_COND(!p_creat_callback); ERR_FAIL_COND(find_server_id(p_name) != -1); @@ -796,7 +796,7 @@ void Physics2DServerManager::register_server(const String &p_name, CreatePhysics on_servers_changed(); } -void Physics2DServerManager::set_default_server(const String &p_name, int p_priority) { +void PhysicsServer2DManager::set_default_server(const String &p_name, int p_priority) { const int id = find_server_id(p_name); ERR_FAIL_COND(id == -1); // Not found @@ -806,7 +806,7 @@ void Physics2DServerManager::set_default_server(const String &p_name, int p_prio } } -int Physics2DServerManager::find_server_id(const String &p_name) { +int PhysicsServer2DManager::find_server_id(const String &p_name) { for (int i = physics_2d_servers.size() - 1; 0 <= i; --i) { if (p_name == physics_2d_servers[i].name) { @@ -816,24 +816,24 @@ int Physics2DServerManager::find_server_id(const String &p_name) { return -1; } -int Physics2DServerManager::get_servers_count() { +int PhysicsServer2DManager::get_servers_count() { return physics_2d_servers.size(); } -String Physics2DServerManager::get_server_name(int p_id) { +String PhysicsServer2DManager::get_server_name(int p_id) { ERR_FAIL_INDEX_V(p_id, get_servers_count(), ""); return physics_2d_servers[p_id].name; } -Physics2DServer *Physics2DServerManager::new_default_server() { - ERR_FAIL_COND_V(default_server_id == -1, NULL); +PhysicsServer2D *PhysicsServer2DManager::new_default_server() { + ERR_FAIL_COND_V(default_server_id == -1, nullptr); return physics_2d_servers[default_server_id].create_callback(); } -Physics2DServer *Physics2DServerManager::new_server(const String &p_name) { +PhysicsServer2D *PhysicsServer2DManager::new_server(const String &p_name) { int id = find_server_id(p_name); if (id == -1) { - return NULL; + return nullptr; } else { return physics_2d_servers[id].create_callback(); } diff --git a/servers/physics_2d_server.h b/servers/physics_server_2d.h index c923ef16b7..8c833b390f 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_server_2d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_2d_server.h */ +/* physics_server_2d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -35,11 +35,11 @@ #include "core/reference.h" #include "core/resource.h" -class Physics2DDirectSpaceState; +class PhysicsDirectSpaceState2D; -class Physics2DDirectBodyState : public Object { +class PhysicsDirectBodyState2D : public Object { - GDCLASS(Physics2DDirectBodyState, Object); + GDCLASS(PhysicsDirectBodyState2D, Object); protected: static void _bind_methods(); @@ -88,18 +88,18 @@ public: virtual real_t get_step() const = 0; virtual void integrate_forces(); - virtual Physics2DDirectSpaceState *get_space_state() = 0; + virtual PhysicsDirectSpaceState2D *get_space_state() = 0; - Physics2DDirectBodyState(); + PhysicsDirectBodyState2D(); }; -class Physics2DShapeQueryResult; +class PhysicsShapeQueryResult2D; //used for script -class Physics2DShapeQueryParameters : public Reference { +class PhysicsShapeQueryParameters2D : public Reference { - GDCLASS(Physics2DShapeQueryParameters, Reference); - friend class Physics2DDirectSpaceState; + GDCLASS(PhysicsShapeQueryParameters2D, Reference); + friend class PhysicsDirectSpaceState2D; RID shape; Transform2D transform; Vector2 motion; @@ -139,21 +139,21 @@ public: void set_exclude(const Vector<RID> &p_exclude); Vector<RID> get_exclude() const; - Physics2DShapeQueryParameters(); + PhysicsShapeQueryParameters2D(); }; -class Physics2DDirectSpaceState : public Object { +class PhysicsDirectSpaceState2D : public Object { - GDCLASS(Physics2DDirectSpaceState, Object); + GDCLASS(PhysicsDirectSpaceState2D, Object); Dictionary _intersect_ray(const Vector2 &p_from, const Vector2 &p_to, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); Array _intersect_point(const Vector2 &p_point, int p_max_results = 32, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); Array _intersect_point_on_canvas(const Vector2 &p_point, ObjectID p_canvas_intance_id, int p_max_results = 32, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_layers = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); Array _intersect_point_impl(const Vector2 &p_point, int p_max_results, const Vector<RID> &p_exclud, uint32_t p_layers, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_filter_by_canvas = false, ObjectID p_canvas_instance_id = ObjectID()); - Array _intersect_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results = 32); - Array _cast_motion(const Ref<Physics2DShapeQueryParameters> &p_shape_query); - Array _collide_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results = 32); - Dictionary _get_rest_info(const Ref<Physics2DShapeQueryParameters> &p_shape_query); + Array _intersect_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32); + Array _cast_motion(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query); + Array _collide_shape(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query, int p_max_results = 32); + Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters2D> &p_shape_query); protected: static void _bind_methods(); @@ -203,16 +203,16 @@ public: virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0; - Physics2DDirectSpaceState(); + PhysicsDirectSpaceState2D(); }; -class Physics2DShapeQueryResult : public Reference { +class PhysicsShapeQueryResult2D : public Reference { - GDCLASS(Physics2DShapeQueryResult, Reference); + GDCLASS(PhysicsShapeQueryResult2D, Reference); - Vector<Physics2DDirectSpaceState::ShapeResult> result; + Vector<PhysicsDirectSpaceState2D::ShapeResult> result; - friend class Physics2DDirectSpaceState; + friend class PhysicsDirectSpaceState2D; protected: static void _bind_methods(); @@ -224,24 +224,24 @@ public: Object *get_result_object(int p_idx) const; int get_result_object_shape(int p_idx) const; - Physics2DShapeQueryResult(); + PhysicsShapeQueryResult2D(); }; -class Physics2DTestMotionResult; +class PhysicsTestMotionResult2D; -class Physics2DServer : public Object { +class PhysicsServer2D : public Object { - GDCLASS(Physics2DServer, Object); + GDCLASS(PhysicsServer2D, Object); - static Physics2DServer *singleton; + static PhysicsServer2D *singleton; - virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>()); + virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.08, const Ref<PhysicsTestMotionResult2D> &p_result = Ref<PhysicsTestMotionResult2D>()); protected: static void _bind_methods(); public: - static Physics2DServer *get_singleton(); + static PhysicsServer2D *get_singleton(); enum ShapeType { SHAPE_LINE, ///< plane:"plane" @@ -296,7 +296,7 @@ public: virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0; // this function only works on physics process, errors and returns null otherwise - virtual Physics2DDirectSpaceState *space_get_direct_state(RID p_space) = 0; + virtual PhysicsDirectSpaceState2D *space_get_direct_state(RID p_space) = 0; virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) = 0; virtual Vector<Vector2> space_get_contacts(RID p_space) const = 0; @@ -490,7 +490,7 @@ public: virtual void body_set_pickable(RID p_body, bool p_pickable) = 0; // this function only works on physics process, errors and returns null otherwise - virtual Physics2DDirectBodyState *body_get_direct_state(RID p_body) = 0; + virtual PhysicsDirectBodyState2D *body_get_direct_state(RID p_body) = 0; struct MotionResult { @@ -513,7 +513,7 @@ public: } }; - virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.001, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true) = 0; + virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, float p_margin = 0.001, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0; struct SeparationResult { @@ -602,23 +602,23 @@ public: virtual int get_process_info(ProcessInfo p_info) = 0; - Physics2DServer(); - ~Physics2DServer(); + PhysicsServer2D(); + ~PhysicsServer2D(); }; -class Physics2DTestMotionResult : public Reference { +class PhysicsTestMotionResult2D : public Reference { - GDCLASS(Physics2DTestMotionResult, Reference); + GDCLASS(PhysicsTestMotionResult2D, Reference); - Physics2DServer::MotionResult result; + PhysicsServer2D::MotionResult result; bool colliding; - friend class Physics2DServer; + friend class PhysicsServer2D; protected: static void _bind_methods(); public: - Physics2DServer::MotionResult *get_result_ptr() const { return const_cast<Physics2DServer::MotionResult *>(&result); } + PhysicsServer2D::MotionResult *get_result_ptr() const { return const_cast<PhysicsServer2D::MotionResult *>(&result); } //bool is_colliding() const; Vector2 get_motion() const; @@ -632,21 +632,21 @@ public: Object *get_collider() const; int get_collider_shape() const; - Physics2DTestMotionResult(); + PhysicsTestMotionResult2D(); }; -typedef Physics2DServer *(*CreatePhysics2DServerCallback)(); +typedef PhysicsServer2D *(*CreatePhysicsServer2DCallback)(); -class Physics2DServerManager { +class PhysicsServer2DManager { struct ClassInfo { String name; - CreatePhysics2DServerCallback create_callback; + CreatePhysicsServer2DCallback create_callback; ClassInfo() : name(""), - create_callback(NULL) {} + create_callback(nullptr) {} - ClassInfo(String p_name, CreatePhysics2DServerCallback p_create_callback) : + ClassInfo(String p_name, CreatePhysicsServer2DCallback p_create_callback) : name(p_name), create_callback(p_create_callback) {} @@ -672,28 +672,28 @@ private: static void on_servers_changed(); public: - static void register_server(const String &p_name, CreatePhysics2DServerCallback p_creat_callback); + static void register_server(const String &p_name, CreatePhysicsServer2DCallback p_creat_callback); static void set_default_server(const String &p_name, int p_priority = 0); static int find_server_id(const String &p_name); static int get_servers_count(); static String get_server_name(int p_id); - static Physics2DServer *new_default_server(); - static Physics2DServer *new_server(const String &p_name); + static PhysicsServer2D *new_default_server(); + static PhysicsServer2D *new_server(const String &p_name); }; -VARIANT_ENUM_CAST(Physics2DServer::ShapeType); -VARIANT_ENUM_CAST(Physics2DServer::SpaceParameter); -VARIANT_ENUM_CAST(Physics2DServer::AreaParameter); -VARIANT_ENUM_CAST(Physics2DServer::AreaSpaceOverrideMode); -VARIANT_ENUM_CAST(Physics2DServer::BodyMode); -VARIANT_ENUM_CAST(Physics2DServer::BodyParameter); -VARIANT_ENUM_CAST(Physics2DServer::BodyState); -VARIANT_ENUM_CAST(Physics2DServer::CCDMode); -VARIANT_ENUM_CAST(Physics2DServer::JointParam); -VARIANT_ENUM_CAST(Physics2DServer::JointType); -VARIANT_ENUM_CAST(Physics2DServer::DampedStringParam); -//VARIANT_ENUM_CAST( Physics2DServer::ObjectType ); -VARIANT_ENUM_CAST(Physics2DServer::AreaBodyStatus); -VARIANT_ENUM_CAST(Physics2DServer::ProcessInfo); +VARIANT_ENUM_CAST(PhysicsServer2D::ShapeType); +VARIANT_ENUM_CAST(PhysicsServer2D::SpaceParameter); +VARIANT_ENUM_CAST(PhysicsServer2D::AreaParameter); +VARIANT_ENUM_CAST(PhysicsServer2D::AreaSpaceOverrideMode); +VARIANT_ENUM_CAST(PhysicsServer2D::BodyMode); +VARIANT_ENUM_CAST(PhysicsServer2D::BodyParameter); +VARIANT_ENUM_CAST(PhysicsServer2D::BodyState); +VARIANT_ENUM_CAST(PhysicsServer2D::CCDMode); +VARIANT_ENUM_CAST(PhysicsServer2D::JointParam); +VARIANT_ENUM_CAST(PhysicsServer2D::JointType); +VARIANT_ENUM_CAST(PhysicsServer2D::DampedStringParam); +//VARIANT_ENUM_CAST( PhysicsServer2D::ObjectType ); +VARIANT_ENUM_CAST(PhysicsServer2D::AreaBodyStatus); +VARIANT_ENUM_CAST(PhysicsServer2D::ProcessInfo); #endif diff --git a/servers/physics_server.cpp b/servers/physics_server_3d.cpp index 57f3a7979e..a5a02fd1bd 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server_3d.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_server.cpp */ +/* physics_server_3d.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,15 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "physics_server.h" +#include "physics_server_3d.h" #include "core/method_bind_ext.gen.inc" #include "core/print_string.h" #include "core/project_settings.h" -PhysicsServer *PhysicsServer::singleton = NULL; +PhysicsServer3D *PhysicsServer3D::singleton = nullptr; -void PhysicsDirectBodyState::integrate_forces() { +void PhysicsDirectBodyState3D::integrate_forces() { real_t step = get_step(); Vector3 lv = get_linear_velocity(); @@ -61,64 +61,64 @@ void PhysicsDirectBodyState::integrate_forces() { set_angular_velocity(av); } -Object *PhysicsDirectBodyState::get_contact_collider_object(int p_contact_idx) const { +Object *PhysicsDirectBodyState3D::get_contact_collider_object(int p_contact_idx) const { ObjectID objid = get_contact_collider_id(p_contact_idx); Object *obj = ObjectDB::get_instance(objid); return obj; } -PhysicsServer *PhysicsServer::get_singleton() { +PhysicsServer3D *PhysicsServer3D::get_singleton() { return singleton; } -void PhysicsDirectBodyState::_bind_methods() { +void PhysicsDirectBodyState3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState::get_total_gravity); - ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState::get_total_linear_damp); - ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState::get_total_angular_damp); + ClassDB::bind_method(D_METHOD("get_total_gravity"), &PhysicsDirectBodyState3D::get_total_gravity); + ClassDB::bind_method(D_METHOD("get_total_linear_damp"), &PhysicsDirectBodyState3D::get_total_linear_damp); + ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp); - ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState::get_center_of_mass); - ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState::get_principal_inertia_axes); + ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState3D::get_center_of_mass); + ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState3D::get_principal_inertia_axes); - ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState::get_inverse_mass); - ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState::get_inverse_inertia); + ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState3D::get_inverse_mass); + ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState3D::get_inverse_inertia); - ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState::set_linear_velocity); - ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState::get_linear_velocity); + ClassDB::bind_method(D_METHOD("set_linear_velocity", "velocity"), &PhysicsDirectBodyState3D::set_linear_velocity); + ClassDB::bind_method(D_METHOD("get_linear_velocity"), &PhysicsDirectBodyState3D::get_linear_velocity); - ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState::set_angular_velocity); - ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState::get_angular_velocity); + ClassDB::bind_method(D_METHOD("set_angular_velocity", "velocity"), &PhysicsDirectBodyState3D::set_angular_velocity); + ClassDB::bind_method(D_METHOD("get_angular_velocity"), &PhysicsDirectBodyState3D::get_angular_velocity); - ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState::set_transform); - ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState::get_transform); + ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsDirectBodyState3D::set_transform); + ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsDirectBodyState3D::get_transform); - ClassDB::bind_method(D_METHOD("add_central_force", "force"), &PhysicsDirectBodyState::add_central_force); - ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &PhysicsDirectBodyState::add_force); - ClassDB::bind_method(D_METHOD("add_torque", "torque"), &PhysicsDirectBodyState::add_torque); - ClassDB::bind_method(D_METHOD("apply_central_impulse", "j"), &PhysicsDirectBodyState::apply_central_impulse); - ClassDB::bind_method(D_METHOD("apply_impulse", "position", "j"), &PhysicsDirectBodyState::apply_impulse); - ClassDB::bind_method(D_METHOD("apply_torque_impulse", "j"), &PhysicsDirectBodyState::apply_torque_impulse); + ClassDB::bind_method(D_METHOD("add_central_force", "force"), &PhysicsDirectBodyState3D::add_central_force); + ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &PhysicsDirectBodyState3D::add_force); + ClassDB::bind_method(D_METHOD("add_torque", "torque"), &PhysicsDirectBodyState3D::add_torque); + ClassDB::bind_method(D_METHOD("apply_central_impulse", "j"), &PhysicsDirectBodyState3D::apply_central_impulse); + ClassDB::bind_method(D_METHOD("apply_impulse", "position", "j"), &PhysicsDirectBodyState3D::apply_impulse); + ClassDB::bind_method(D_METHOD("apply_torque_impulse", "j"), &PhysicsDirectBodyState3D::apply_torque_impulse); - ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState::set_sleep_state); - ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState::is_sleeping); + ClassDB::bind_method(D_METHOD("set_sleep_state", "enabled"), &PhysicsDirectBodyState3D::set_sleep_state); + ClassDB::bind_method(D_METHOD("is_sleeping"), &PhysicsDirectBodyState3D::is_sleeping); - ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState::get_contact_count); + ClassDB::bind_method(D_METHOD("get_contact_count"), &PhysicsDirectBodyState3D::get_contact_count); - ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_position); - ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_normal); - ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState::get_contact_impulse); - ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState::get_contact_local_shape); - ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider); - ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_position); - ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_id); - ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_object); - ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_shape); - ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState::get_contact_collider_velocity_at_position); - ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState::get_step); - ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState::integrate_forces); - ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState::get_space_state); + ClassDB::bind_method(D_METHOD("get_contact_local_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_position); + ClassDB::bind_method(D_METHOD("get_contact_local_normal", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_normal); + ClassDB::bind_method(D_METHOD("get_contact_impulse", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_impulse); + ClassDB::bind_method(D_METHOD("get_contact_local_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_local_shape); + ClassDB::bind_method(D_METHOD("get_contact_collider", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider); + ClassDB::bind_method(D_METHOD("get_contact_collider_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_position); + ClassDB::bind_method(D_METHOD("get_contact_collider_id", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_id); + ClassDB::bind_method(D_METHOD("get_contact_collider_object", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_object); + ClassDB::bind_method(D_METHOD("get_contact_collider_shape", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_shape); + ClassDB::bind_method(D_METHOD("get_contact_collider_velocity_at_position", "contact_idx"), &PhysicsDirectBodyState3D::get_contact_collider_velocity_at_position); + ClassDB::bind_method(D_METHOD("get_step"), &PhysicsDirectBodyState3D::get_step); + ClassDB::bind_method(D_METHOD("integrate_forces"), &PhysicsDirectBodyState3D::integrate_forces); + ClassDB::bind_method(D_METHOD("get_space_state"), &PhysicsDirectBodyState3D::get_space_state); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "", "get_step"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inverse_mass"), "", "get_inverse_mass"); @@ -134,62 +134,62 @@ void PhysicsDirectBodyState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform"); } -PhysicsDirectBodyState::PhysicsDirectBodyState() {} +PhysicsDirectBodyState3D::PhysicsDirectBodyState3D() {} /////////////////////////////////////////////////////// -void PhysicsShapeQueryParameters::set_shape(const RES &p_shape) { +void PhysicsShapeQueryParameters3D::set_shape(const RES &p_shape) { ERR_FAIL_COND(p_shape.is_null()); shape = p_shape->get_rid(); } -void PhysicsShapeQueryParameters::set_shape_rid(const RID &p_shape) { +void PhysicsShapeQueryParameters3D::set_shape_rid(const RID &p_shape) { shape = p_shape; } -RID PhysicsShapeQueryParameters::get_shape_rid() const { +RID PhysicsShapeQueryParameters3D::get_shape_rid() const { return shape; } -void PhysicsShapeQueryParameters::set_transform(const Transform &p_transform) { +void PhysicsShapeQueryParameters3D::set_transform(const Transform &p_transform) { transform = p_transform; } -Transform PhysicsShapeQueryParameters::get_transform() const { +Transform PhysicsShapeQueryParameters3D::get_transform() const { return transform; } -void PhysicsShapeQueryParameters::set_margin(float p_margin) { +void PhysicsShapeQueryParameters3D::set_margin(float p_margin) { margin = p_margin; } -float PhysicsShapeQueryParameters::get_margin() const { +float PhysicsShapeQueryParameters3D::get_margin() const { return margin; } -void PhysicsShapeQueryParameters::set_collision_mask(int p_collision_mask) { +void PhysicsShapeQueryParameters3D::set_collision_mask(int p_collision_mask) { collision_mask = p_collision_mask; } -int PhysicsShapeQueryParameters::get_collision_mask() const { +int PhysicsShapeQueryParameters3D::get_collision_mask() const { return collision_mask; } -void PhysicsShapeQueryParameters::set_exclude(const Vector<RID> &p_exclude) { +void PhysicsShapeQueryParameters3D::set_exclude(const Vector<RID> &p_exclude) { exclude.clear(); for (int i = 0; i < p_exclude.size(); i++) exclude.insert(p_exclude[i]); } -Vector<RID> PhysicsShapeQueryParameters::get_exclude() const { +Vector<RID> PhysicsShapeQueryParameters3D::get_exclude() const { Vector<RID> ret; ret.resize(exclude.size()); @@ -200,45 +200,45 @@ Vector<RID> PhysicsShapeQueryParameters::get_exclude() const { return ret; } -void PhysicsShapeQueryParameters::set_collide_with_bodies(bool p_enable) { +void PhysicsShapeQueryParameters3D::set_collide_with_bodies(bool p_enable) { collide_with_bodies = p_enable; } -bool PhysicsShapeQueryParameters::is_collide_with_bodies_enabled() const { +bool PhysicsShapeQueryParameters3D::is_collide_with_bodies_enabled() const { return collide_with_bodies; } -void PhysicsShapeQueryParameters::set_collide_with_areas(bool p_enable) { +void PhysicsShapeQueryParameters3D::set_collide_with_areas(bool p_enable) { collide_with_areas = p_enable; } -bool PhysicsShapeQueryParameters::is_collide_with_areas_enabled() const { +bool PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled() const { return collide_with_areas; } -void PhysicsShapeQueryParameters::_bind_methods() { +void PhysicsShapeQueryParameters3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters::set_shape); - ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters::set_shape_rid); - ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters::get_shape_rid); + ClassDB::bind_method(D_METHOD("set_shape", "shape"), &PhysicsShapeQueryParameters3D::set_shape); + ClassDB::bind_method(D_METHOD("set_shape_rid", "shape"), &PhysicsShapeQueryParameters3D::set_shape_rid); + ClassDB::bind_method(D_METHOD("get_shape_rid"), &PhysicsShapeQueryParameters3D::get_shape_rid); - ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters::set_transform); - ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters::get_transform); + ClassDB::bind_method(D_METHOD("set_transform", "transform"), &PhysicsShapeQueryParameters3D::set_transform); + ClassDB::bind_method(D_METHOD("get_transform"), &PhysicsShapeQueryParameters3D::get_transform); - ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters::set_margin); - ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "margin"), &PhysicsShapeQueryParameters3D::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &PhysicsShapeQueryParameters3D::get_margin); - ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters::set_collision_mask); - ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters::get_collision_mask); + ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &PhysicsShapeQueryParameters3D::set_collision_mask); + ClassDB::bind_method(D_METHOD("get_collision_mask"), &PhysicsShapeQueryParameters3D::get_collision_mask); - ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters::set_exclude); - ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters::get_exclude); + ClassDB::bind_method(D_METHOD("set_exclude", "exclude"), &PhysicsShapeQueryParameters3D::set_exclude); + ClassDB::bind_method(D_METHOD("get_exclude"), &PhysicsShapeQueryParameters3D::get_exclude); - ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters::set_collide_with_bodies); - ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters::is_collide_with_bodies_enabled); + ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_bodies); + ClassDB::bind_method(D_METHOD("is_collide_with_bodies_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_bodies_enabled); - ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters::set_collide_with_areas); - ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters::is_collide_with_areas_enabled); + ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &PhysicsShapeQueryParameters3D::set_collide_with_areas); + ClassDB::bind_method(D_METHOD("is_collide_with_areas_enabled"), &PhysicsShapeQueryParameters3D::is_collide_with_areas_enabled); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "exclude", PROPERTY_HINT_NONE, itos(Variant::_RID) + ":"), "set_exclude", "get_exclude"); @@ -250,7 +250,7 @@ void PhysicsShapeQueryParameters::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "is_collide_with_areas_enabled"); } -PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() { +PhysicsShapeQueryParameters3D::PhysicsShapeQueryParameters3D() { margin = 0; collision_mask = 0x7FFFFFFF; @@ -260,7 +260,7 @@ PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() { ///////////////////////////////////// -Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { +Dictionary PhysicsDirectSpaceState3D::_intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { RayResult inters; Set<RID> exclude; @@ -283,7 +283,7 @@ Dictionary PhysicsDirectSpaceState::_intersect_ray(const Vector3 &p_from, const return d; } -Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) { +Array PhysicsDirectSpaceState3D::_intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); @@ -305,7 +305,7 @@ Array PhysicsDirectSpaceState::_intersect_shape(const Ref<PhysicsShapeQueryParam return ret; } -Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameters> &p_shape_query, const Vector3 &p_motion) { +Array PhysicsDirectSpaceState3D::_cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, const Vector3 &p_motion) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); @@ -319,7 +319,7 @@ Array PhysicsDirectSpaceState::_cast_motion(const Ref<PhysicsShapeQueryParameter ret[1] = closest_unsafe; return ret; } -Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results) { +Array PhysicsDirectSpaceState3D::_collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); @@ -335,7 +335,7 @@ Array PhysicsDirectSpaceState::_collide_shape(const Ref<PhysicsShapeQueryParamet r[i] = ret[i]; return r; } -Dictionary PhysicsDirectSpaceState::_get_rest_info(const Ref<PhysicsShapeQueryParameters> &p_shape_query) { +Dictionary PhysicsDirectSpaceState3D::_get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query) { ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary()); @@ -356,176 +356,176 @@ Dictionary PhysicsDirectSpaceState::_get_rest_info(const Ref<PhysicsShapeQueryPa return r; } -PhysicsDirectSpaceState::PhysicsDirectSpaceState() { +PhysicsDirectSpaceState3D::PhysicsDirectSpaceState3D() { } -void PhysicsDirectSpaceState::_bind_methods() { +void PhysicsDirectSpaceState3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_mask", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_intersect_shape, DEFVAL(32)); - ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState::_cast_motion); - ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState::_collide_shape, DEFVAL(32)); - ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState::_get_rest_info); + ClassDB::bind_method(D_METHOD("intersect_ray", "from", "to", "exclude", "collision_mask", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState3D::_intersect_ray, DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("intersect_shape", "shape", "max_results"), &PhysicsDirectSpaceState3D::_intersect_shape, DEFVAL(32)); + ClassDB::bind_method(D_METHOD("cast_motion", "shape", "motion"), &PhysicsDirectSpaceState3D::_cast_motion); + ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &PhysicsDirectSpaceState3D::_collide_shape, DEFVAL(32)); + ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &PhysicsDirectSpaceState3D::_get_rest_info); } -int PhysicsShapeQueryResult::get_result_count() const { +int PhysicsShapeQueryResult3D::get_result_count() const { return result.size(); } -RID PhysicsShapeQueryResult::get_result_rid(int p_idx) const { +RID PhysicsShapeQueryResult3D::get_result_rid(int p_idx) const { return result[p_idx].rid; } -ObjectID PhysicsShapeQueryResult::get_result_object_id(int p_idx) const { +ObjectID PhysicsShapeQueryResult3D::get_result_object_id(int p_idx) const { return result[p_idx].collider_id; } -Object *PhysicsShapeQueryResult::get_result_object(int p_idx) const { +Object *PhysicsShapeQueryResult3D::get_result_object(int p_idx) const { return result[p_idx].collider; } -int PhysicsShapeQueryResult::get_result_object_shape(int p_idx) const { +int PhysicsShapeQueryResult3D::get_result_object_shape(int p_idx) const { return result[p_idx].shape; } -PhysicsShapeQueryResult::PhysicsShapeQueryResult() { +PhysicsShapeQueryResult3D::PhysicsShapeQueryResult3D() { } -void PhysicsShapeQueryResult::_bind_methods() { +void PhysicsShapeQueryResult3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult::get_result_count); - ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult::get_result_rid); - ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult::get_result_object_id); - ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult::get_result_object); - ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult::get_result_object_shape); + ClassDB::bind_method(D_METHOD("get_result_count"), &PhysicsShapeQueryResult3D::get_result_count); + ClassDB::bind_method(D_METHOD("get_result_rid", "idx"), &PhysicsShapeQueryResult3D::get_result_rid); + ClassDB::bind_method(D_METHOD("get_result_object_id", "idx"), &PhysicsShapeQueryResult3D::get_result_object_id); + ClassDB::bind_method(D_METHOD("get_result_object", "idx"), &PhysicsShapeQueryResult3D::get_result_object); + ClassDB::bind_method(D_METHOD("get_result_object_shape", "idx"), &PhysicsShapeQueryResult3D::get_result_object_shape); } /////////////////////////////////////// -void PhysicsServer::_bind_methods() { +void PhysicsServer3D::_bind_methods() { #ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer::shape_create); - ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer::shape_set_data); + ClassDB::bind_method(D_METHOD("shape_create", "type"), &PhysicsServer3D::shape_create); + ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &PhysicsServer3D::shape_set_data); - ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer::shape_get_type); - ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer::shape_get_data); + ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &PhysicsServer3D::shape_get_type); + ClassDB::bind_method(D_METHOD("shape_get_data", "shape"), &PhysicsServer3D::shape_get_data); - ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer::space_create); - ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer::space_set_active); - ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer::space_is_active); - ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer::space_set_param); - ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer::space_get_param); - ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer::space_get_direct_state); + ClassDB::bind_method(D_METHOD("space_create"), &PhysicsServer3D::space_create); + ClassDB::bind_method(D_METHOD("space_set_active", "space", "active"), &PhysicsServer3D::space_set_active); + ClassDB::bind_method(D_METHOD("space_is_active", "space"), &PhysicsServer3D::space_is_active); + ClassDB::bind_method(D_METHOD("space_set_param", "space", "param", "value"), &PhysicsServer3D::space_set_param); + ClassDB::bind_method(D_METHOD("space_get_param", "space", "param"), &PhysicsServer3D::space_get_param); + ClassDB::bind_method(D_METHOD("space_get_direct_state", "space"), &PhysicsServer3D::space_get_direct_state); - ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer::area_create); - ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer::area_set_space); - ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer::area_get_space); + ClassDB::bind_method(D_METHOD("area_create"), &PhysicsServer3D::area_create); + ClassDB::bind_method(D_METHOD("area_set_space", "area", "space"), &PhysicsServer3D::area_set_space); + ClassDB::bind_method(D_METHOD("area_get_space", "area"), &PhysicsServer3D::area_get_space); - ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer::area_set_space_override_mode); - ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer::area_get_space_override_mode); + ClassDB::bind_method(D_METHOD("area_set_space_override_mode", "area", "mode"), &PhysicsServer3D::area_set_space_override_mode); + ClassDB::bind_method(D_METHOD("area_get_space_override_mode", "area"), &PhysicsServer3D::area_get_space_override_mode); - ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer::area_add_shape, DEFVAL(Transform()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer::area_set_shape); - ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer::area_set_shape_transform); - ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &PhysicsServer::area_set_shape_disabled); + ClassDB::bind_method(D_METHOD("area_add_shape", "area", "shape", "transform", "disabled"), &PhysicsServer3D::area_add_shape, DEFVAL(Transform()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("area_set_shape", "area", "shape_idx", "shape"), &PhysicsServer3D::area_set_shape); + ClassDB::bind_method(D_METHOD("area_set_shape_transform", "area", "shape_idx", "transform"), &PhysicsServer3D::area_set_shape_transform); + ClassDB::bind_method(D_METHOD("area_set_shape_disabled", "area", "shape_idx", "disabled"), &PhysicsServer3D::area_set_shape_disabled); - ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer::area_get_shape_count); - ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer::area_get_shape); - ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer::area_get_shape_transform); + ClassDB::bind_method(D_METHOD("area_get_shape_count", "area"), &PhysicsServer3D::area_get_shape_count); + ClassDB::bind_method(D_METHOD("area_get_shape", "area", "shape_idx"), &PhysicsServer3D::area_get_shape); + ClassDB::bind_method(D_METHOD("area_get_shape_transform", "area", "shape_idx"), &PhysicsServer3D::area_get_shape_transform); - ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer::area_remove_shape); - ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer::area_clear_shapes); + ClassDB::bind_method(D_METHOD("area_remove_shape", "area", "shape_idx"), &PhysicsServer3D::area_remove_shape); + ClassDB::bind_method(D_METHOD("area_clear_shapes", "area"), &PhysicsServer3D::area_clear_shapes); - ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer::area_set_collision_layer); - ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer::area_set_collision_mask); + ClassDB::bind_method(D_METHOD("area_set_collision_layer", "area", "layer"), &PhysicsServer3D::area_set_collision_layer); + ClassDB::bind_method(D_METHOD("area_set_collision_mask", "area", "mask"), &PhysicsServer3D::area_set_collision_mask); - ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer::area_set_param); - ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer::area_set_transform); + ClassDB::bind_method(D_METHOD("area_set_param", "area", "param", "value"), &PhysicsServer3D::area_set_param); + ClassDB::bind_method(D_METHOD("area_set_transform", "area", "transform"), &PhysicsServer3D::area_set_transform); - ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer::area_get_param); - ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer::area_get_transform); + ClassDB::bind_method(D_METHOD("area_get_param", "area", "param"), &PhysicsServer3D::area_get_param); + ClassDB::bind_method(D_METHOD("area_get_transform", "area"), &PhysicsServer3D::area_get_transform); - ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer::area_attach_object_instance_id); - ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer::area_get_object_instance_id); + ClassDB::bind_method(D_METHOD("area_attach_object_instance_id", "area", "id"), &PhysicsServer3D::area_attach_object_instance_id); + ClassDB::bind_method(D_METHOD("area_get_object_instance_id", "area"), &PhysicsServer3D::area_get_object_instance_id); - ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer::area_set_monitor_callback); - ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &PhysicsServer::area_set_area_monitor_callback); - ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &PhysicsServer::area_set_monitorable); + ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &PhysicsServer3D::area_set_monitor_callback); + ClassDB::bind_method(D_METHOD("area_set_area_monitor_callback", "area", "receiver", "method"), &PhysicsServer3D::area_set_area_monitor_callback); + ClassDB::bind_method(D_METHOD("area_set_monitorable", "area", "monitorable"), &PhysicsServer3D::area_set_monitorable); - ClassDB::bind_method(D_METHOD("area_set_ray_pickable", "area", "enable"), &PhysicsServer::area_set_ray_pickable); - ClassDB::bind_method(D_METHOD("area_is_ray_pickable", "area"), &PhysicsServer::area_is_ray_pickable); + ClassDB::bind_method(D_METHOD("area_set_ray_pickable", "area", "enable"), &PhysicsServer3D::area_set_ray_pickable); + ClassDB::bind_method(D_METHOD("area_is_ray_pickable", "area"), &PhysicsServer3D::area_is_ray_pickable); - ClassDB::bind_method(D_METHOD("body_create", "mode", "init_sleeping"), &PhysicsServer::body_create, DEFVAL(BODY_MODE_RIGID), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("body_create", "mode", "init_sleeping"), &PhysicsServer3D::body_create, DEFVAL(BODY_MODE_RIGID), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer::body_set_space); - ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer::body_get_space); + ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &PhysicsServer3D::body_set_space); + ClassDB::bind_method(D_METHOD("body_get_space", "body"), &PhysicsServer3D::body_get_space); - ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer::body_set_mode); - ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer::body_get_mode); + ClassDB::bind_method(D_METHOD("body_set_mode", "body", "mode"), &PhysicsServer3D::body_set_mode); + ClassDB::bind_method(D_METHOD("body_get_mode", "body"), &PhysicsServer3D::body_get_mode); - ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer::body_set_collision_layer); - ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer::body_get_collision_layer); + ClassDB::bind_method(D_METHOD("body_set_collision_layer", "body", "layer"), &PhysicsServer3D::body_set_collision_layer); + ClassDB::bind_method(D_METHOD("body_get_collision_layer", "body"), &PhysicsServer3D::body_get_collision_layer); - ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer::body_set_collision_mask); - ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer::body_get_collision_mask); + ClassDB::bind_method(D_METHOD("body_set_collision_mask", "body", "mask"), &PhysicsServer3D::body_set_collision_mask); + ClassDB::bind_method(D_METHOD("body_get_collision_mask", "body"), &PhysicsServer3D::body_get_collision_mask); - ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer::body_add_shape, DEFVAL(Transform()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer::body_set_shape); - ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer::body_set_shape_transform); - ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &PhysicsServer::body_set_shape_disabled); + ClassDB::bind_method(D_METHOD("body_add_shape", "body", "shape", "transform", "disabled"), &PhysicsServer3D::body_add_shape, DEFVAL(Transform()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("body_set_shape", "body", "shape_idx", "shape"), &PhysicsServer3D::body_set_shape); + ClassDB::bind_method(D_METHOD("body_set_shape_transform", "body", "shape_idx", "transform"), &PhysicsServer3D::body_set_shape_transform); + ClassDB::bind_method(D_METHOD("body_set_shape_disabled", "body", "shape_idx", "disabled"), &PhysicsServer3D::body_set_shape_disabled); - ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer::body_get_shape_count); - ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer::body_get_shape); - ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer::body_get_shape_transform); + ClassDB::bind_method(D_METHOD("body_get_shape_count", "body"), &PhysicsServer3D::body_get_shape_count); + ClassDB::bind_method(D_METHOD("body_get_shape", "body", "shape_idx"), &PhysicsServer3D::body_get_shape); + ClassDB::bind_method(D_METHOD("body_get_shape_transform", "body", "shape_idx"), &PhysicsServer3D::body_get_shape_transform); - ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer::body_remove_shape); - ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer::body_clear_shapes); + ClassDB::bind_method(D_METHOD("body_remove_shape", "body", "shape_idx"), &PhysicsServer3D::body_remove_shape); + ClassDB::bind_method(D_METHOD("body_clear_shapes", "body"), &PhysicsServer3D::body_clear_shapes); - ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer::body_attach_object_instance_id); - ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer::body_get_object_instance_id); + ClassDB::bind_method(D_METHOD("body_attach_object_instance_id", "body", "id"), &PhysicsServer3D::body_attach_object_instance_id); + ClassDB::bind_method(D_METHOD("body_get_object_instance_id", "body"), &PhysicsServer3D::body_get_object_instance_id); - ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer::body_set_enable_continuous_collision_detection); - ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer::body_is_continuous_collision_detection_enabled); + ClassDB::bind_method(D_METHOD("body_set_enable_continuous_collision_detection", "body", "enable"), &PhysicsServer3D::body_set_enable_continuous_collision_detection); + ClassDB::bind_method(D_METHOD("body_is_continuous_collision_detection_enabled", "body"), &PhysicsServer3D::body_is_continuous_collision_detection_enabled); - ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer::body_set_param); - ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer::body_get_param); + ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer3D::body_set_param); + ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer3D::body_get_param); - ClassDB::bind_method(D_METHOD("body_set_kinematic_safe_margin", "body", "margin"), &PhysicsServer::body_set_kinematic_safe_margin); - ClassDB::bind_method(D_METHOD("body_get_kinematic_safe_margin", "body"), &PhysicsServer::body_get_kinematic_safe_margin); + ClassDB::bind_method(D_METHOD("body_set_kinematic_safe_margin", "body", "margin"), &PhysicsServer3D::body_set_kinematic_safe_margin); + ClassDB::bind_method(D_METHOD("body_get_kinematic_safe_margin", "body"), &PhysicsServer3D::body_get_kinematic_safe_margin); - ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer::body_set_state); - ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer::body_get_state); + ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer3D::body_set_state); + ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer3D::body_get_state); - ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &PhysicsServer::body_add_central_force); - ClassDB::bind_method(D_METHOD("body_add_force", "body", "force", "position"), &PhysicsServer::body_add_force); - ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &PhysicsServer::body_add_torque); + ClassDB::bind_method(D_METHOD("body_add_central_force", "body", "force"), &PhysicsServer3D::body_add_central_force); + ClassDB::bind_method(D_METHOD("body_add_force", "body", "force", "position"), &PhysicsServer3D::body_add_force); + ClassDB::bind_method(D_METHOD("body_add_torque", "body", "torque"), &PhysicsServer3D::body_add_torque); - ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &PhysicsServer::body_apply_central_impulse); - ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer::body_apply_impulse); - ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer::body_apply_torque_impulse); - ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer::body_set_axis_velocity); + ClassDB::bind_method(D_METHOD("body_apply_central_impulse", "body", "impulse"), &PhysicsServer3D::body_apply_central_impulse); + ClassDB::bind_method(D_METHOD("body_apply_impulse", "body", "position", "impulse"), &PhysicsServer3D::body_apply_impulse); + ClassDB::bind_method(D_METHOD("body_apply_torque_impulse", "body", "impulse"), &PhysicsServer3D::body_apply_torque_impulse); + ClassDB::bind_method(D_METHOD("body_set_axis_velocity", "body", "axis_velocity"), &PhysicsServer3D::body_set_axis_velocity); - ClassDB::bind_method(D_METHOD("body_set_axis_lock", "body", "axis", "lock"), &PhysicsServer::body_set_axis_lock); - ClassDB::bind_method(D_METHOD("body_is_axis_locked", "body", "axis"), &PhysicsServer::body_is_axis_locked); + ClassDB::bind_method(D_METHOD("body_set_axis_lock", "body", "axis", "lock"), &PhysicsServer3D::body_set_axis_lock); + ClassDB::bind_method(D_METHOD("body_is_axis_locked", "body", "axis"), &PhysicsServer3D::body_is_axis_locked); - ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer::body_add_collision_exception); - ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer::body_remove_collision_exception); + ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &PhysicsServer3D::body_add_collision_exception); + ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &PhysicsServer3D::body_remove_collision_exception); - ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer::body_set_max_contacts_reported); - ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer::body_get_max_contacts_reported); + ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &PhysicsServer3D::body_set_max_contacts_reported); + ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &PhysicsServer3D::body_get_max_contacts_reported); - ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer::body_set_omit_force_integration); - ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer::body_is_omitting_force_integration); + ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer3D::body_set_omit_force_integration); + ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer3D::body_is_omitting_force_integration); - ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer::body_set_force_integration_callback, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "receiver", "method", "userdata"), &PhysicsServer3D::body_set_force_integration_callback, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer::body_set_ray_pickable); - ClassDB::bind_method(D_METHOD("body_is_ray_pickable", "body"), &PhysicsServer::body_is_ray_pickable); + ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer3D::body_set_ray_pickable); + ClassDB::bind_method(D_METHOD("body_is_ray_pickable", "body"), &PhysicsServer3D::body_is_ray_pickable); - ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer::body_get_direct_state); + ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer3D::body_get_direct_state); /* JOINT API */ @@ -535,15 +535,15 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(JOINT_CONE_TWIST); BIND_ENUM_CONSTANT(JOINT_6DOF); - ClassDB::bind_method(D_METHOD("joint_create_pin", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer::joint_create_pin); - ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer::pin_joint_set_param); - ClassDB::bind_method(D_METHOD("pin_joint_get_param", "joint", "param"), &PhysicsServer::pin_joint_get_param); + ClassDB::bind_method(D_METHOD("joint_create_pin", "body_A", "local_A", "body_B", "local_B"), &PhysicsServer3D::joint_create_pin); + ClassDB::bind_method(D_METHOD("pin_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::pin_joint_set_param); + ClassDB::bind_method(D_METHOD("pin_joint_get_param", "joint", "param"), &PhysicsServer3D::pin_joint_get_param); - ClassDB::bind_method(D_METHOD("pin_joint_set_local_a", "joint", "local_A"), &PhysicsServer::pin_joint_set_local_a); - ClassDB::bind_method(D_METHOD("pin_joint_get_local_a", "joint"), &PhysicsServer::pin_joint_get_local_a); + ClassDB::bind_method(D_METHOD("pin_joint_set_local_a", "joint", "local_A"), &PhysicsServer3D::pin_joint_set_local_a); + ClassDB::bind_method(D_METHOD("pin_joint_get_local_a", "joint"), &PhysicsServer3D::pin_joint_get_local_a); - ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer::pin_joint_set_local_b); - ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer::pin_joint_get_local_b); + ClassDB::bind_method(D_METHOD("pin_joint_set_local_b", "joint", "local_B"), &PhysicsServer3D::pin_joint_set_local_b); + ClassDB::bind_method(D_METHOD("pin_joint_get_local_b", "joint"), &PhysicsServer3D::pin_joint_get_local_b); BIND_ENUM_CONSTANT(PIN_JOINT_BIAS); BIND_ENUM_CONSTANT(PIN_JOINT_DAMPING); @@ -561,18 +561,18 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_USE_LIMIT); BIND_ENUM_CONSTANT(HINGE_JOINT_FLAG_ENABLE_MOTOR); - ClassDB::bind_method(D_METHOD("joint_create_hinge", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer::joint_create_hinge); + ClassDB::bind_method(D_METHOD("joint_create_hinge", "body_A", "hinge_A", "body_B", "hinge_B"), &PhysicsServer3D::joint_create_hinge); - ClassDB::bind_method(D_METHOD("hinge_joint_set_param", "joint", "param", "value"), &PhysicsServer::hinge_joint_set_param); - ClassDB::bind_method(D_METHOD("hinge_joint_get_param", "joint", "param"), &PhysicsServer::hinge_joint_get_param); + ClassDB::bind_method(D_METHOD("hinge_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::hinge_joint_set_param); + ClassDB::bind_method(D_METHOD("hinge_joint_get_param", "joint", "param"), &PhysicsServer3D::hinge_joint_get_param); - ClassDB::bind_method(D_METHOD("hinge_joint_set_flag", "joint", "flag", "enabled"), &PhysicsServer::hinge_joint_set_flag); - ClassDB::bind_method(D_METHOD("hinge_joint_get_flag", "joint", "flag"), &PhysicsServer::hinge_joint_get_flag); + ClassDB::bind_method(D_METHOD("hinge_joint_set_flag", "joint", "flag", "enabled"), &PhysicsServer3D::hinge_joint_set_flag); + ClassDB::bind_method(D_METHOD("hinge_joint_get_flag", "joint", "flag"), &PhysicsServer3D::hinge_joint_get_flag); - ClassDB::bind_method(D_METHOD("joint_create_slider", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_slider); + ClassDB::bind_method(D_METHOD("joint_create_slider", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_create_slider); - ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer::slider_joint_set_param); - ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer::slider_joint_get_param); + ClassDB::bind_method(D_METHOD("slider_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::slider_joint_set_param); + ClassDB::bind_method(D_METHOD("slider_joint_get_param", "joint", "param"), &PhysicsServer3D::slider_joint_get_param); BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_UPPER); BIND_ENUM_CONSTANT(SLIDER_JOINT_LINEAR_LIMIT_LOWER); @@ -599,10 +599,10 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING); BIND_ENUM_CONSTANT(SLIDER_JOINT_MAX); - ClassDB::bind_method(D_METHOD("joint_create_cone_twist", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_cone_twist); + ClassDB::bind_method(D_METHOD("joint_create_cone_twist", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_create_cone_twist); - ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer::cone_twist_joint_set_param); - ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer::cone_twist_joint_get_param); + ClassDB::bind_method(D_METHOD("cone_twist_joint_set_param", "joint", "param", "value"), &PhysicsServer3D::cone_twist_joint_set_param); + ClassDB::bind_method(D_METHOD("cone_twist_joint_get_param", "joint", "param"), &PhysicsServer3D::cone_twist_joint_get_param); BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_SWING_SPAN); BIND_ENUM_CONSTANT(CONE_TWIST_JOINT_TWIST_SPAN); @@ -632,24 +632,24 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_MOTOR); BIND_ENUM_CONSTANT(G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR); - ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer::joint_get_type); + ClassDB::bind_method(D_METHOD("joint_get_type", "joint"), &PhysicsServer3D::joint_get_type); - ClassDB::bind_method(D_METHOD("joint_set_solver_priority", "joint", "priority"), &PhysicsServer::joint_set_solver_priority); - ClassDB::bind_method(D_METHOD("joint_get_solver_priority", "joint"), &PhysicsServer::joint_get_solver_priority); + ClassDB::bind_method(D_METHOD("joint_set_solver_priority", "joint", "priority"), &PhysicsServer3D::joint_set_solver_priority); + ClassDB::bind_method(D_METHOD("joint_get_solver_priority", "joint"), &PhysicsServer3D::joint_get_solver_priority); - ClassDB::bind_method(D_METHOD("joint_create_generic_6dof", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer::joint_create_generic_6dof); + ClassDB::bind_method(D_METHOD("joint_create_generic_6dof", "body_A", "local_ref_A", "body_B", "local_ref_B"), &PhysicsServer3D::joint_create_generic_6dof); - ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_param", "joint", "axis", "param", "value"), &PhysicsServer::generic_6dof_joint_set_param); - ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_param", "joint", "axis", "param"), &PhysicsServer::generic_6dof_joint_get_param); + ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_param", "joint", "axis", "param", "value"), &PhysicsServer3D::generic_6dof_joint_set_param); + ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_param", "joint", "axis", "param"), &PhysicsServer3D::generic_6dof_joint_get_param); - ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag", "joint", "axis", "flag", "enable"), &PhysicsServer::generic_6dof_joint_set_flag); - ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag", "joint", "axis", "flag"), &PhysicsServer::generic_6dof_joint_get_flag); + ClassDB::bind_method(D_METHOD("generic_6dof_joint_set_flag", "joint", "axis", "flag", "enable"), &PhysicsServer3D::generic_6dof_joint_set_flag); + ClassDB::bind_method(D_METHOD("generic_6dof_joint_get_flag", "joint", "axis", "flag"), &PhysicsServer3D::generic_6dof_joint_get_flag); - ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer::free); + ClassDB::bind_method(D_METHOD("free_rid", "rid"), &PhysicsServer3D::free); - ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer::set_active); + ClassDB::bind_method(D_METHOD("set_active", "active"), &PhysicsServer3D::set_active); - ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer::get_process_info); + ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &PhysicsServer3D::get_process_info); BIND_ENUM_CONSTANT(SHAPE_PLANE); BIND_ENUM_CONSTANT(SHAPE_RAY); @@ -723,23 +723,23 @@ void PhysicsServer::_bind_methods() { #endif } -PhysicsServer::PhysicsServer() { +PhysicsServer3D::PhysicsServer3D() { - ERR_FAIL_COND(singleton != NULL); + ERR_FAIL_COND(singleton != nullptr); singleton = this; } -PhysicsServer::~PhysicsServer() { +PhysicsServer3D::~PhysicsServer3D() { - singleton = NULL; + singleton = nullptr; } -Vector<PhysicsServerManager::ClassInfo> PhysicsServerManager::physics_servers; -int PhysicsServerManager::default_server_id = -1; -int PhysicsServerManager::default_server_priority = -1; -const String PhysicsServerManager::setting_property_name("physics/3d/physics_engine"); +Vector<PhysicsServer3DManager::ClassInfo> PhysicsServer3DManager::physics_servers; +int PhysicsServer3DManager::default_server_id = -1; +int PhysicsServer3DManager::default_server_priority = -1; +const String PhysicsServer3DManager::setting_property_name("physics/3d/physics_engine"); -void PhysicsServerManager::on_servers_changed() { +void PhysicsServer3DManager::on_servers_changed() { String physics_servers2("DEFAULT"); for (int i = get_servers_count() - 1; 0 <= i; --i) { @@ -748,7 +748,7 @@ void PhysicsServerManager::on_servers_changed() { ProjectSettings::get_singleton()->set_custom_property_info(setting_property_name, PropertyInfo(Variant::STRING, setting_property_name, PROPERTY_HINT_ENUM, physics_servers2)); } -void PhysicsServerManager::register_server(const String &p_name, CreatePhysicsServerCallback p_creat_callback) { +void PhysicsServer3DManager::register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback) { ERR_FAIL_COND(!p_creat_callback); ERR_FAIL_COND(find_server_id(p_name) != -1); @@ -756,7 +756,7 @@ void PhysicsServerManager::register_server(const String &p_name, CreatePhysicsSe on_servers_changed(); } -void PhysicsServerManager::set_default_server(const String &p_name, int p_priority) { +void PhysicsServer3DManager::set_default_server(const String &p_name, int p_priority) { const int id = find_server_id(p_name); ERR_FAIL_COND(id == -1); // Not found @@ -766,7 +766,7 @@ void PhysicsServerManager::set_default_server(const String &p_name, int p_priori } } -int PhysicsServerManager::find_server_id(const String &p_name) { +int PhysicsServer3DManager::find_server_id(const String &p_name) { for (int i = physics_servers.size() - 1; 0 <= i; --i) { if (p_name == physics_servers[i].name) { @@ -776,24 +776,24 @@ int PhysicsServerManager::find_server_id(const String &p_name) { return -1; } -int PhysicsServerManager::get_servers_count() { +int PhysicsServer3DManager::get_servers_count() { return physics_servers.size(); } -String PhysicsServerManager::get_server_name(int p_id) { +String PhysicsServer3DManager::get_server_name(int p_id) { ERR_FAIL_INDEX_V(p_id, get_servers_count(), ""); return physics_servers[p_id].name; } -PhysicsServer *PhysicsServerManager::new_default_server() { - ERR_FAIL_COND_V(default_server_id == -1, NULL); +PhysicsServer3D *PhysicsServer3DManager::new_default_server() { + ERR_FAIL_COND_V(default_server_id == -1, nullptr); return physics_servers[default_server_id].create_callback(); } -PhysicsServer *PhysicsServerManager::new_server(const String &p_name) { +PhysicsServer3D *PhysicsServer3DManager::new_server(const String &p_name) { int id = find_server_id(p_name); if (id == -1) { - return NULL; + return nullptr; } else { return physics_servers[id].create_callback(); } diff --git a/servers/physics_server.h b/servers/physics_server_3d.h index f1388c8758..a2f08b3ed8 100644 --- a/servers/physics_server.h +++ b/servers/physics_server_3d.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physics_server.h */ +/* physics_server_3d.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -34,11 +34,11 @@ #include "core/object.h" #include "core/resource.h" -class PhysicsDirectSpaceState; +class PhysicsDirectSpaceState3D; -class PhysicsDirectBodyState : public Object { +class PhysicsDirectBodyState3D : public Object { - GDCLASS(PhysicsDirectBodyState, Object); + GDCLASS(PhysicsDirectBodyState3D, Object); protected: static void _bind_methods(); @@ -90,17 +90,17 @@ public: virtual real_t get_step() const = 0; virtual void integrate_forces(); - virtual PhysicsDirectSpaceState *get_space_state() = 0; + virtual PhysicsDirectSpaceState3D *get_space_state() = 0; - PhysicsDirectBodyState(); + PhysicsDirectBodyState3D(); }; -class PhysicsShapeQueryResult; +class PhysicsShapeQueryResult3D; -class PhysicsShapeQueryParameters : public Reference { +class PhysicsShapeQueryParameters3D : public Reference { - GDCLASS(PhysicsShapeQueryParameters, Reference); - friend class PhysicsDirectSpaceState; + GDCLASS(PhysicsShapeQueryParameters3D, Reference); + friend class PhysicsDirectSpaceState3D; RID shape; Transform transform; @@ -137,19 +137,19 @@ public: void set_collide_with_areas(bool p_enable); bool is_collide_with_areas_enabled() const; - PhysicsShapeQueryParameters(); + PhysicsShapeQueryParameters3D(); }; -class PhysicsDirectSpaceState : public Object { +class PhysicsDirectSpaceState3D : public Object { - GDCLASS(PhysicsDirectSpaceState, Object); + GDCLASS(PhysicsDirectSpaceState3D, Object); private: Dictionary _intersect_ray(const Vector3 &p_from, const Vector3 &p_to, const Vector<RID> &p_exclude = Vector<RID>(), uint32_t p_collision_mask = 0, bool p_collide_with_bodies = true, bool p_collide_with_areas = false); - Array _intersect_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results = 32); - Array _cast_motion(const Ref<PhysicsShapeQueryParameters> &p_shape_query, const Vector3 &p_motion); - Array _collide_shape(const Ref<PhysicsShapeQueryParameters> &p_shape_query, int p_max_results = 32); - Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters> &p_shape_query); + Array _intersect_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32); + Array _cast_motion(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, const Vector3 &p_motion); + Array _collide_shape(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query, int p_max_results = 32); + Dictionary _get_rest_info(const Ref<PhysicsShapeQueryParameters3D> &p_shape_query); protected: static void _bind_methods(); @@ -189,7 +189,7 @@ public: Vector3 linear_velocity; //velocity at contact point }; - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = NULL) = 0; + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, ShapeRestInfo *r_info = nullptr) = 0; virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, bool p_collide_with_bodies = true, bool p_collide_with_areas = false) = 0; @@ -197,16 +197,16 @@ public: virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0; - PhysicsDirectSpaceState(); + PhysicsDirectSpaceState3D(); }; -class PhysicsShapeQueryResult : public Reference { +class PhysicsShapeQueryResult3D : public Reference { - GDCLASS(PhysicsShapeQueryResult, Reference); + GDCLASS(PhysicsShapeQueryResult3D, Reference); - Vector<PhysicsDirectSpaceState::ShapeResult> result; + Vector<PhysicsDirectSpaceState3D::ShapeResult> result; - friend class PhysicsDirectSpaceState; + friend class PhysicsDirectSpaceState3D; protected: static void _bind_methods(); @@ -218,20 +218,20 @@ public: Object *get_result_object(int p_idx) const; int get_result_object_shape(int p_idx) const; - PhysicsShapeQueryResult(); + PhysicsShapeQueryResult3D(); }; -class PhysicsServer : public Object { +class PhysicsServer3D : public Object { - GDCLASS(PhysicsServer, Object); + GDCLASS(PhysicsServer3D, Object); - static PhysicsServer *singleton; + static PhysicsServer3D *singleton; protected: static void _bind_methods(); public: - static PhysicsServer *get_singleton(); + static PhysicsServer3D *get_singleton(); enum ShapeType { SHAPE_PLANE, ///< plane:"plane" @@ -281,7 +281,7 @@ public: virtual real_t space_get_param(RID p_space, SpaceParameter p_param) const = 0; // this function only works on physics process, errors and returns null otherwise - virtual PhysicsDirectSpaceState *space_get_direct_state(RID p_space) = 0; + virtual PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) = 0; virtual void space_set_debug_contacts(RID p_space, int p_max_contacts) = 0; virtual Vector<Vector3> space_get_contacts(RID p_space) const = 0; @@ -478,7 +478,7 @@ public: virtual bool body_is_ray_pickable(RID p_body) const = 0; // this function only works on physics process, errors and returns null otherwise - virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body) = 0; + virtual PhysicsDirectBodyState3D *body_get_direct_state(RID p_body) = 0; struct MotionResult { @@ -500,7 +500,7 @@ public: } }; - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = NULL, bool p_exclude_raycast_shapes = true) = 0; + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, MotionResult *r_result = nullptr, bool p_exclude_raycast_shapes = true) = 0; struct SeparationResult { @@ -521,7 +521,7 @@ public: virtual RID soft_body_create(bool p_init_sleeping = false) = 0; - virtual void soft_body_update_visual_server(RID p_body, class SoftBodyVisualServerHandler *p_visual_server_handler) = 0; + virtual void soft_body_update_rendering_server(RID p_body, class SoftBodyRenderingServerHandler *p_rendering_server_handler) = 0; virtual void soft_body_set_space(RID p_body, RID p_space) = 0; virtual RID soft_body_get_space(RID p_body) const = 0; @@ -772,22 +772,22 @@ public: virtual int get_process_info(ProcessInfo p_info) = 0; - PhysicsServer(); - ~PhysicsServer(); + PhysicsServer3D(); + ~PhysicsServer3D(); }; -typedef PhysicsServer *(*CreatePhysicsServerCallback)(); +typedef PhysicsServer3D *(*CreatePhysicsServer3DCallback)(); -class PhysicsServerManager { +class PhysicsServer3DManager { struct ClassInfo { String name; - CreatePhysicsServerCallback create_callback; + CreatePhysicsServer3DCallback create_callback; ClassInfo() : name(""), - create_callback(NULL) {} + create_callback(nullptr) {} - ClassInfo(String p_name, CreatePhysicsServerCallback p_create_callback) : + ClassInfo(String p_name, CreatePhysicsServer3DCallback p_create_callback) : name(p_name), create_callback(p_create_callback) {} @@ -813,32 +813,32 @@ private: static void on_servers_changed(); public: - static void register_server(const String &p_name, CreatePhysicsServerCallback p_creat_callback); + static void register_server(const String &p_name, CreatePhysicsServer3DCallback p_creat_callback); static void set_default_server(const String &p_name, int p_priority = 0); static int find_server_id(const String &p_name); static int get_servers_count(); static String get_server_name(int p_id); - static PhysicsServer *new_default_server(); - static PhysicsServer *new_server(const String &p_name); + static PhysicsServer3D *new_default_server(); + static PhysicsServer3D *new_server(const String &p_name); }; -VARIANT_ENUM_CAST(PhysicsServer::ShapeType); -VARIANT_ENUM_CAST(PhysicsServer::SpaceParameter); -VARIANT_ENUM_CAST(PhysicsServer::AreaParameter); -VARIANT_ENUM_CAST(PhysicsServer::AreaSpaceOverrideMode); -VARIANT_ENUM_CAST(PhysicsServer::BodyMode); -VARIANT_ENUM_CAST(PhysicsServer::BodyParameter); -VARIANT_ENUM_CAST(PhysicsServer::BodyState); -VARIANT_ENUM_CAST(PhysicsServer::BodyAxis); -VARIANT_ENUM_CAST(PhysicsServer::PinJointParam); -VARIANT_ENUM_CAST(PhysicsServer::JointType); -VARIANT_ENUM_CAST(PhysicsServer::HingeJointParam); -VARIANT_ENUM_CAST(PhysicsServer::HingeJointFlag); -VARIANT_ENUM_CAST(PhysicsServer::SliderJointParam); -VARIANT_ENUM_CAST(PhysicsServer::ConeTwistJointParam); -VARIANT_ENUM_CAST(PhysicsServer::G6DOFJointAxisParam); -VARIANT_ENUM_CAST(PhysicsServer::G6DOFJointAxisFlag); -VARIANT_ENUM_CAST(PhysicsServer::AreaBodyStatus); -VARIANT_ENUM_CAST(PhysicsServer::ProcessInfo); +VARIANT_ENUM_CAST(PhysicsServer3D::ShapeType); +VARIANT_ENUM_CAST(PhysicsServer3D::SpaceParameter); +VARIANT_ENUM_CAST(PhysicsServer3D::AreaParameter); +VARIANT_ENUM_CAST(PhysicsServer3D::AreaSpaceOverrideMode); +VARIANT_ENUM_CAST(PhysicsServer3D::BodyMode); +VARIANT_ENUM_CAST(PhysicsServer3D::BodyParameter); +VARIANT_ENUM_CAST(PhysicsServer3D::BodyState); +VARIANT_ENUM_CAST(PhysicsServer3D::BodyAxis); +VARIANT_ENUM_CAST(PhysicsServer3D::PinJointParam); +VARIANT_ENUM_CAST(PhysicsServer3D::JointType); +VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointParam); +VARIANT_ENUM_CAST(PhysicsServer3D::HingeJointFlag); +VARIANT_ENUM_CAST(PhysicsServer3D::SliderJointParam); +VARIANT_ENUM_CAST(PhysicsServer3D::ConeTwistJointParam); +VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisParam); +VARIANT_ENUM_CAST(PhysicsServer3D::G6DOFJointAxisFlag); +VARIANT_ENUM_CAST(PhysicsServer3D::AreaBodyStatus); +VARIANT_ENUM_CAST(PhysicsServer3D::ProcessInfo); #endif diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 574b373c30..64b48bea50 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -58,30 +58,30 @@ #include "camera/camera_feed.h" #include "camera_server.h" #include "display_server.h" -#include "navigation_2d_server.h" -#include "navigation_server.h" -#include "physics/physics_server_sw.h" -#include "physics_2d/physics_2d_server_sw.h" -#include "physics_2d/physics_2d_server_wrap_mt.h" -#include "physics_2d_server.h" -#include "physics_server.h" -#include "visual/shader_types.h" -#include "visual_server.h" - -ShaderTypes *shader_types = NULL; - -PhysicsServer *_createGodotPhysicsCallback() { - return memnew(PhysicsServerSW); +#include "navigation_server_2d.h" +#include "navigation_server_3d.h" +#include "physics_2d/physics_server_2d_sw.h" +#include "physics_2d/physics_server_2d_wrap_mt.h" +#include "physics_3d/physics_server_3d_sw.h" +#include "physics_server_2d.h" +#include "physics_server_3d.h" +#include "rendering_server.h" +#include "servers/rendering/shader_types.h" + +ShaderTypes *shader_types = nullptr; + +PhysicsServer3D *_createGodotPhysics3DCallback() { + return memnew(PhysicsServer3DSW); } -Physics2DServer *_createGodotPhysics2DCallback() { - return Physics2DServerWrapMT::init_server<Physics2DServerSW>(); +PhysicsServer2D *_createGodotPhysics2DCallback() { + return PhysicsServer2DWrapMT::init_server<PhysicsServer2DSW>(); } static bool has_server_feature_callback(const String &p_feature) { - if (VisualServer::get_singleton()) { - if (VisualServer::get_singleton()->has_os_feature(p_feature)) { + if (RenderingServer::get_singleton()) { + if (RenderingServer::get_singleton()->has_os_feature(p_feature)) { return true; } } @@ -98,10 +98,10 @@ void register_server_types() { OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback); ClassDB::register_virtual_class<DisplayServer>(); - ClassDB::register_virtual_class<VisualServer>(); + ClassDB::register_virtual_class<RenderingServer>(); ClassDB::register_class<AudioServer>(); - ClassDB::register_virtual_class<PhysicsServer>(); - ClassDB::register_virtual_class<Physics2DServer>(); + ClassDB::register_virtual_class<PhysicsServer3D>(); + ClassDB::register_virtual_class<PhysicsServer2D>(); ClassDB::register_class<ARVRServer>(); ClassDB::register_class<CameraServer>(); @@ -159,30 +159,30 @@ void register_server_types() { ClassDB::register_class<CameraFeed>(); - ClassDB::register_virtual_class<Physics2DDirectBodyState>(); - ClassDB::register_virtual_class<Physics2DDirectSpaceState>(); - ClassDB::register_virtual_class<Physics2DShapeQueryResult>(); - ClassDB::register_class<Physics2DTestMotionResult>(); - ClassDB::register_class<Physics2DShapeQueryParameters>(); + ClassDB::register_virtual_class<PhysicsDirectBodyState2D>(); + ClassDB::register_virtual_class<PhysicsDirectSpaceState2D>(); + ClassDB::register_virtual_class<PhysicsShapeQueryResult2D>(); + ClassDB::register_class<PhysicsTestMotionResult2D>(); + ClassDB::register_class<PhysicsShapeQueryParameters2D>(); - ClassDB::register_class<PhysicsShapeQueryParameters>(); - ClassDB::register_virtual_class<PhysicsDirectBodyState>(); - ClassDB::register_virtual_class<PhysicsDirectSpaceState>(); - ClassDB::register_virtual_class<PhysicsShapeQueryResult>(); + ClassDB::register_class<PhysicsShapeQueryParameters3D>(); + ClassDB::register_virtual_class<PhysicsDirectBodyState3D>(); + ClassDB::register_virtual_class<PhysicsDirectSpaceState3D>(); + ClassDB::register_virtual_class<PhysicsShapeQueryResult3D>(); // Physics 2D - GLOBAL_DEF(Physics2DServerManager::setting_property_name, "DEFAULT"); - ProjectSettings::get_singleton()->set_custom_property_info(Physics2DServerManager::setting_property_name, PropertyInfo(Variant::STRING, Physics2DServerManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT")); + GLOBAL_DEF(PhysicsServer2DManager::setting_property_name, "DEFAULT"); + ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServer2DManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServer2DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT")); - Physics2DServerManager::register_server("GodotPhysics", &_createGodotPhysics2DCallback); - Physics2DServerManager::set_default_server("GodotPhysics"); + PhysicsServer2DManager::register_server("GodotPhysics", &_createGodotPhysics2DCallback); + PhysicsServer2DManager::set_default_server("GodotPhysics"); // Physics 3D - GLOBAL_DEF(PhysicsServerManager::setting_property_name, "DEFAULT"); - ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServerManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServerManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT")); + GLOBAL_DEF(PhysicsServer3DManager::setting_property_name, "DEFAULT"); + ProjectSettings::get_singleton()->set_custom_property_info(PhysicsServer3DManager::setting_property_name, PropertyInfo(Variant::STRING, PhysicsServer3DManager::setting_property_name, PROPERTY_HINT_ENUM, "DEFAULT")); - PhysicsServerManager::register_server("GodotPhysics", &_createGodotPhysicsCallback); - PhysicsServerManager::set_default_server("GodotPhysics"); + PhysicsServer3DManager::register_server("GodotPhysics", &_createGodotPhysics3DCallback); + PhysicsServer3DManager::set_default_server("GodotPhysics"); } void unregister_server_types() { @@ -192,12 +192,12 @@ void unregister_server_types() { void register_server_singletons() { - Engine::get_singleton()->add_singleton(Engine::Singleton("VisualServer", VisualServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton())); - Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer", PhysicsServer::get_singleton())); - Engine::get_singleton()->add_singleton(Engine::Singleton("Physics2DServer", Physics2DServer::get_singleton())); - Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer", NavigationServer::get_singleton_mut())); - Engine::get_singleton()->add_singleton(Engine::Singleton("Navigation2DServer", Navigation2DServer::get_singleton_mut())); + Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer2D", PhysicsServer2D::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton_mut())); + Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton_mut())); Engine::get_singleton()->add_singleton(Engine::Singleton("ARVRServer", ARVRServer::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton())); } diff --git a/servers/visual/SCsub b/servers/rendering/SCsub index fca18bfea0..5ea0d40486 100644 --- a/servers/visual/SCsub +++ b/servers/rendering/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/visual/rasterizer.cpp b/servers/rendering/rasterizer.cpp index a3f93a3f8c..f62e0a43a6 100644 --- a/servers/visual/rasterizer.cpp +++ b/servers/rendering/rasterizer.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "core/print_string.h" -Rasterizer *(*Rasterizer::_create_func)() = NULL; +Rasterizer *(*Rasterizer::_create_func)() = nullptr; void RasterizerScene::InstanceDependency::instance_notify_changed(bool p_aabb, bool p_dependencies) { for (Map<InstanceBase *, uint32_t>::Element *E = instances.front(); E; E = E->next()) { @@ -67,9 +67,9 @@ Rasterizer *Rasterizer::create() { return _create_func(); } -RasterizerCanvas *RasterizerCanvas::singleton = NULL; +RasterizerCanvas *RasterizerCanvas::singleton = nullptr; -RasterizerStorage *RasterizerStorage::base_singleton = NULL; +RasterizerStorage *RasterizerStorage::base_singleton = nullptr; RasterizerStorage::RasterizerStorage() { diff --git a/servers/visual/rasterizer.h b/servers/rendering/rasterizer.h index d5d32c8d47..6676b00723 100644 --- a/servers/visual/rasterizer.h +++ b/servers/rendering/rasterizer.h @@ -32,7 +32,7 @@ #define RASTERIZER_H #include "core/math/camera_matrix.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #include "core/pair.h" #include "core/self_list.h" @@ -55,35 +55,38 @@ public: virtual RID sky_create() = 0; virtual void sky_set_radiance_size(RID p_sky, int p_radiance_size) = 0; - virtual void sky_set_mode(RID p_sky, VS::SkyMode p_samples) = 0; + virtual void sky_set_mode(RID p_sky, RS::SkyMode p_samples) = 0; virtual void sky_set_material(RID p_sky, RID p_material) = 0; /* ENVIRONMENT API */ virtual RID environment_create() = 0; - virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg) = 0; + virtual void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) = 0; virtual void environment_set_sky(RID p_env, RID p_sky) = 0; virtual void environment_set_sky_custom_fov(RID p_env, float p_scale) = 0; virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) = 0; virtual void environment_set_bg_color(RID p_env, const Color &p_color) = 0; virtual void environment_set_bg_energy(RID p_env, float p_energy) = 0; virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer) = 0; - virtual void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) = 0; + virtual void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()) = 0; // FIXME: Disabled during Vulkan refactoring, should be ported. #if 0 virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id) = 0; #endif - virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) = 0; + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) = 0; + virtual void environment_glow_set_use_bicubic_upscale(bool p_enable) = 0; virtual void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) = 0; - virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0; - virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) = 0; + virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) = 0; + virtual void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) = 0; - virtual void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) = 0; + virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) = 0; - virtual void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) = 0; + virtual void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) = 0; + + virtual void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) = 0; virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) = 0; @@ -92,13 +95,13 @@ public: virtual void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve) = 0; virtual bool is_environment(RID p_env) const = 0; - virtual VS::EnvironmentBG environment_get_background(RID p_env) const = 0; + virtual RS::EnvironmentBG environment_get_background(RID p_env) const = 0; virtual int environment_get_canvas_max_layer(RID p_env) const = 0; virtual RID camera_effects_create() = 0; - virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) = 0; - virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) = 0; + virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) = 0; + virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) = 0; virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) = 0; virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) = 0; @@ -106,7 +109,6 @@ public: struct InstanceBase; struct InstanceDependency { - void instance_notify_changed(bool p_aabb, bool p_dependencies); void instance_notify_deleted(RID p_deleted); @@ -118,8 +120,7 @@ public: }; struct InstanceBase { - - VS::InstanceType base_type; + RS::InstanceType base_type; RID base; RID skeleton; @@ -142,7 +143,7 @@ public: Vector<float> blend_values; - VS::ShadowCastingSetting cast_shadows; + RS::ShadowCastingSetting cast_shadows; //fit in 32 bits bool mirror : 8; @@ -208,8 +209,8 @@ public: InstanceBase() : dependency_item(this) { - base_type = VS::INSTANCE_NONE; - cast_shadows = VS::SHADOW_CASTING_SETTING_ON; + base_type = RS::INSTANCE_NONE; + cast_shadows = RS::SHADOW_CASTING_SETTING_ON; receive_shadows = true; visible = true; depth_layer = 0; @@ -218,7 +219,7 @@ public: baked_light = false; dynamic_gi = false; redraw_if_visible = false; - lightmap_capture = NULL; + lightmap_capture = nullptr; } virtual ~InstanceBase() { @@ -230,7 +231,9 @@ public: virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform) = 0; virtual void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0) = 0; virtual void light_instance_mark_visible(RID p_light_instance) = 0; - virtual bool light_instances_can_render_shadow_cube() const { return true; } + virtual bool light_instances_can_render_shadow_cube() const { + return true; + } virtual RID reflection_atlas_create() = 0; virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) = 0; @@ -255,10 +258,10 @@ public: virtual void set_scene_pass(uint64_t p_pass) = 0; virtual void set_time(double p_time, double p_step) = 0; - virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) = 0; + virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) = 0; virtual RID render_buffers_create() = 0; - virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) = 0; + virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) = 0; virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_curve) = 0; virtual bool screen_space_roughness_limiter_is_active() const = 0; @@ -277,7 +280,7 @@ public: /* TEXTURE API */ virtual RID texture_2d_create(const Ref<Image> &p_image) = 0; - virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) = 0; + virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) = 0; virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) = 0; //all slices, then all the mipmaps, must be coherent virtual RID texture_proxy_create(RID p_base) = 0; //all slices, then all the mipmaps, must be coherent @@ -305,11 +308,11 @@ public: virtual void texture_set_path(RID p_texture, const String &p_path) = 0; virtual String texture_get_path(RID p_texture) const = 0; - virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) = 0; - virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) = 0; - virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0; + virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) = 0; + virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) = 0; + virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) = 0; - virtual void texture_debug_usage(List<VS::TextureInfo> *r_info) = 0; + virtual void texture_debug_usage(List<RS::TextureInfo> *r_info) = 0; virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0; @@ -349,19 +352,19 @@ public: virtual RID mesh_create() = 0; /// Returns stride - virtual void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) = 0; + virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; - virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0; - virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0; + virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) = 0; + virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0; virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0; virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0; - virtual VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0; + virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; @@ -376,7 +379,7 @@ public: virtual RID multimesh_create() = 0; - virtual void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0; + virtual void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0; virtual int multimesh_get_instance_count(RID p_multimesh) const = 0; @@ -404,7 +407,7 @@ public: /* IMMEDIATE API */ virtual RID immediate_create() = 0; - virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) = 0; + virtual void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) = 0; virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) = 0; virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal) = 0; virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent) = 0; @@ -430,14 +433,14 @@ public: /* Light API */ - virtual RID light_create(VS::LightType p_type) = 0; + virtual RID light_create(RS::LightType p_type) = 0; - RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); } - RID omni_light_create() { return light_create(VS::LIGHT_OMNI); } - RID spot_light_create() { return light_create(VS::LIGHT_SPOT); } + RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); } + RID omni_light_create() { return light_create(RS::LIGHT_OMNI); } + RID spot_light_create() { return light_create(RS::LIGHT_SPOT); } virtual void light_set_color(RID p_light, const Color &p_color) = 0; - virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value) = 0; + virtual void light_set_param(RID p_light, RS::LightParam p_param, float p_value) = 0; virtual void light_set_shadow(RID p_light, bool p_enabled) = 0; virtual void light_set_shadow_color(RID p_light, const Color &p_color) = 0; virtual void light_set_projector(RID p_light, RID p_texture) = 0; @@ -446,22 +449,22 @@ public: virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0; virtual void light_set_use_gi(RID p_light, bool p_enable) = 0; - virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) = 0; + virtual void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) = 0; - virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) = 0; + virtual void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) = 0; virtual void light_directional_set_blend_splits(RID p_light, bool p_enable) = 0; virtual bool light_directional_get_blend_splits(RID p_light) const = 0; - virtual void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) = 0; - virtual VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const = 0; + virtual void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) = 0; + virtual RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const = 0; - virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) = 0; - virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) = 0; + virtual RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) = 0; + virtual RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) = 0; virtual bool light_has_shadow(RID p_light) const = 0; - virtual VS::LightType light_get_type(RID p_light) const = 0; + virtual RS::LightType light_get_type(RID p_light) const = 0; virtual AABB light_get_aabb(RID p_light) const = 0; - virtual float light_get_param(RID p_light, VS::LightParam p_param) = 0; + virtual float light_get_param(RID p_light, RS::LightParam p_param) = 0; virtual Color light_get_color(RID p_light) = 0; virtual bool light_get_use_gi(RID p_light) = 0; virtual uint64_t light_get_version(RID p_light) const = 0; @@ -470,7 +473,7 @@ public: virtual RID reflection_probe_create() = 0; - virtual void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) = 0; + virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) = 0; virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0; virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0; virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) = 0; @@ -485,7 +488,7 @@ public: virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0; virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0; - virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0; + virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0; virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0; virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const = 0; @@ -591,7 +594,7 @@ public: virtual bool particles_is_inactive(RID p_particles) const = 0; - virtual void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) = 0; + virtual void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) = 0; virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0; virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0; @@ -628,7 +631,7 @@ public: virtual void render_target_disable_clear_request(RID p_render_target) = 0; virtual void render_target_do_clear_request(RID p_render_target) = 0; - virtual VS::InstanceType get_base_type(RID p_rid) const = 0; + virtual RS::InstanceType get_base_type(RID p_rid) const = 0; virtual bool free(RID p_rid) = 0; virtual bool has_os_feature(const String &p_feature) const = 0; @@ -639,9 +642,9 @@ public: virtual void render_info_begin_capture() = 0; virtual void render_info_end_capture() = 0; - virtual int get_captured_render_info(VS::RenderInfo p_info) = 0; + virtual int get_captured_render_info(RS::RenderInfo p_info) = 0; - virtual int get_render_info(VS::RenderInfo p_info) = 0; + virtual int get_render_info(RS::RenderInfo p_info) = 0; virtual String get_video_adapter_name() const = 0; virtual String get_video_adapter_vendor() const = 0; @@ -656,12 +659,12 @@ public: } #define TIMESTAMP_BEGIN() \ { \ - if (VSG::storage->capturing_timestamps) VSG::storage->capture_timestamps_begin(); \ + if (RSG::storage->capturing_timestamps) RSG::storage->capture_timestamps_begin(); \ } #define RENDER_TIMESTAMP(m_text) \ { \ - if (VSG::storage->capturing_timestamps) VSG::storage->capture_timestamp(m_text); \ + if (RSG::storage->capturing_timestamps) RSG::storage->capture_timestamp(m_text); \ } bool capturing_timestamps = false; @@ -706,13 +709,13 @@ public: int layer_max; int item_mask; int item_shadow_mask; - VS::CanvasLightMode mode; + RS::CanvasLightMode mode; RID texture; Vector2 texture_offset; RID canvas; bool use_shadow; int shadow_buffer_size; - VS::CanvasLightShadowFilter shadow_filter; + RS::CanvasLightShadowFilter shadow_filter; Color shadow_color; float shadow_smooth; @@ -749,14 +752,14 @@ public: scale = 1.0; energy = 1.0; item_shadow_mask = -1; - mode = VS::CANVAS_LIGHT_MODE_ADD; - // texture_cache = NULL; - next_ptr = NULL; - mask_next_ptr = NULL; - filter_next_ptr = NULL; + mode = RS::CANVAS_LIGHT_MODE_ADD; + // texture_cache = nullptr; + next_ptr = nullptr; + mask_next_ptr = nullptr; + filter_next_ptr = nullptr; use_shadow = false; shadow_buffer_size = 2048; - shadow_filter = VS::CANVAS_LIGHT_FILTER_NONE; + shadow_filter = RS::CANVAS_LIGHT_FILTER_NONE; shadow_smooth = 0.0; render_index_cache = -1; } @@ -764,7 +767,7 @@ public: typedef uint64_t TextureBindingID; - virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) = 0; + virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) = 0; virtual void free_texture_binding(TextureBindingID p_binding) = 0; //easier wrap to avoid mistakes @@ -775,14 +778,14 @@ public: TextureBindingID binding_id; - _FORCE_INLINE_ void create(VS::CanvasItemTextureFilter p_item_filter, VS::CanvasItemTextureRepeat p_item_repeat, RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { - if (p_filter == VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) { + _FORCE_INLINE_ void create(RS::CanvasItemTextureFilter p_item_filter, RS::CanvasItemTextureRepeat p_item_repeat, RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { + if (p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) { p_filter = p_item_filter; } - if (p_repeat == VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) { + if (p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) { p_repeat = p_item_repeat; } - if (p_texture != RID() || p_normalmap != RID() || p_specular != RID() || p_filter != VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT || p_repeat != VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT || p_multimesh.is_valid()) { + if (p_texture != RID() || p_normalmap != RID() || p_specular != RID() || p_filter != RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT || p_repeat != RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT || p_multimesh.is_valid()) { ERR_FAIL_COND(binding_id != 0); binding_id = singleton->request_texture_binding(p_texture, p_normalmap, p_specular, p_filter, p_repeat, p_multimesh); } @@ -882,8 +885,8 @@ public: float margin[4]; bool draw_center; Color color; - VS::NinePatchAxisMode axis_x; - VS::NinePatchAxisMode axis_y; + RS::NinePatchAxisMode axis_x; + RS::NinePatchAxisMode axis_y; Color specular_shininess; TextureBinding texture_binding; CommandNinePatch() { @@ -894,7 +897,7 @@ public: struct CommandPolygon : public Command { - VS::PrimitiveType primitive; + RS::PrimitiveType primitive; Polygon polygon; Color specular_shininess; TextureBinding texture_binding; @@ -958,7 +961,7 @@ public: }; struct ViewportRender { - VisualServer *owner; + RenderingServer *owner; void *udata; Rect2 rect; }; @@ -968,7 +971,7 @@ public: bool visible; bool behind; bool update_when_visible; - //VS::MaterialBlendMode blend_mode; + //RS::MaterialBlendMode blend_mode; int light_mask; int z_final; @@ -1004,7 +1007,7 @@ public: //must update rect - if (commands == NULL) { + if (commands == nullptr) { rect = Rect2(); rect_dirty = false; @@ -1114,12 +1117,12 @@ public: template <class T> T *alloc_command() { T *command; - if (commands == NULL) { + if (commands == nullptr) { // As the most common use case of canvas items is to // use only one command, the first is done with it's // own allocation. The rest of them use blocks. command = memnew(T); - command->next = NULL; + command->next = nullptr; commands = command; last_command = command; } else { @@ -1146,7 +1149,7 @@ public: //allocate block and add to the linked list void *memory = c->memory + c->usage; command = memnew_placement(memory, T); - command->next = NULL; + command->next = nullptr; last_command->next = command; last_command = command; c->usage += sizeof(T); @@ -1171,7 +1174,7 @@ public: Command *n = c->next; if (c == commands) { memdelete(commands); - commands = NULL; + commands = nullptr; } else { c->~Command(); } @@ -1185,36 +1188,36 @@ public: } } - last_command = NULL; - commands = NULL; + last_command = nullptr; + commands = nullptr; current_block = 0; clip = false; rect_dirty = true; - final_clip_owner = NULL; - material_owner = NULL; + final_clip_owner = nullptr; + material_owner = nullptr; light_masked = false; } Item() { - commands = NULL; - last_command = NULL; + commands = nullptr; + last_command = nullptr; current_block = 0; light_mask = 1; - vp_render = NULL; - next = NULL; - final_clip_owner = NULL; + vp_render = nullptr; + next = nullptr; + final_clip_owner = nullptr; clip = false; final_modulate = Color(1, 1, 1, 1); visible = true; rect_dirty = true; custom_rect = false; behind = false; - material_owner = NULL; - copy_back_buffer = NULL; + material_owner = nullptr; + copy_back_buffer = nullptr; distance_field = false; light_masked = false; update_when_visible = false; z_final = 0; - custom_data = NULL; + custom_data = nullptr; } virtual ~Item() { clear(); @@ -1241,15 +1244,15 @@ public: Transform2D xform; Transform2D xform_cache; int light_mask; - VS::CanvasOccluderPolygonCullMode cull_cache; + RS::CanvasOccluderPolygonCullMode cull_cache; LightOccluderInstance *next; LightOccluderInstance() { enabled = true; - next = NULL; + next = nullptr; light_mask = 1; - cull_cache = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; + cull_cache = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; } }; @@ -1260,7 +1263,7 @@ public: virtual RID occluder_polygon_create() = 0; virtual void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines) = 0; - virtual void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) = 0; + virtual void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) = 0; virtual void draw_window_margins(int *p_margins, RID *p_margin_textures) = 0; diff --git a/servers/visual/rasterizer_rd/SCsub b/servers/rendering/rasterizer_rd/SCsub index cc17feeb05..6a2e682c67 100644 --- a/servers/visual/rasterizer_rd/SCsub +++ b/servers/rendering/rasterizer_rd/SCsub @@ -1,6 +1,6 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.servers_sources, "*.cpp") diff --git a/servers/visual/rasterizer_rd/light_cluster_builder.cpp b/servers/rendering/rasterizer_rd/light_cluster_builder.cpp index 943ef1c7fa..943ef1c7fa 100644 --- a/servers/visual/rasterizer_rd/light_cluster_builder.cpp +++ b/servers/rendering/rasterizer_rd/light_cluster_builder.cpp diff --git a/servers/visual/rasterizer_rd/light_cluster_builder.h b/servers/rendering/rasterizer_rd/light_cluster_builder.h index 83014a7dd0..3411ed07a0 100644 --- a/servers/visual/rasterizer_rd/light_cluster_builder.h +++ b/servers/rendering/rasterizer_rd/light_cluster_builder.h @@ -31,7 +31,7 @@ #ifndef LIGHT_CLUSTER_BUILDER_H #define LIGHT_CLUSTER_BUILDER_H -#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h" class LightClusterBuilder { public: diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp index 38b1e3b3a6..ba4f4c4acb 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -104,7 +104,7 @@ void RasterizerCanvasRD::_update_specular_shininess(const Color &p_transform, ui *r_ss |= uint32_t(CLAMP(p_transform.r * 255.0, 0, 255)); } -RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { +RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { Vector<RD::Uniform> uniform_set; @@ -168,13 +168,13 @@ RID RasterizerCanvasRD::_create_texture_binding(RID p_texture, RID p_normalmap, return RD::get_singleton()->uniform_set_create(uniform_set, shader.default_version_rd_shader, 0); } -RasterizerCanvas::TextureBindingID RasterizerCanvasRD::request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { +RasterizerCanvas::TextureBindingID RasterizerCanvasRD::request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh) { - if (p_filter == VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) { + if (p_filter == RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) { p_filter = default_samplers.default_filter; } - if (p_repeat == VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) { + if (p_repeat == RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) { p_repeat = default_samplers.default_repeat; } @@ -287,7 +287,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; vd.offset = base_offset * sizeof(float); - vd.location = VS::ARRAY_VERTEX; + vd.location = RS::ARRAY_VERTEX; vd.stride = stride * sizeof(float); descriptions.write[0] = vd; @@ -307,7 +307,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; vd.offset = base_offset * sizeof(float); - vd.location = VS::ARRAY_COLOR; + vd.location = RS::ARRAY_COLOR; vd.stride = stride * sizeof(float); descriptions.write[1] = vd; @@ -335,7 +335,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; vd.offset = 0; - vd.location = VS::ARRAY_COLOR; + vd.location = RS::ARRAY_COLOR; vd.stride = 0; descriptions.write[1] = vd; @@ -347,7 +347,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; vd.offset = base_offset * sizeof(float); - vd.location = VS::ARRAY_TEX_UV; + vd.location = RS::ARRAY_TEX_UV; vd.stride = stride * sizeof(float); descriptions.write[2] = vd; @@ -363,7 +363,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; vd.offset = 0; - vd.location = VS::ARRAY_TEX_UV; + vd.location = RS::ARRAY_TEX_UV; vd.stride = 0; descriptions.write[2] = vd; @@ -375,7 +375,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT; vd.offset = base_offset * sizeof(float); - vd.location = VS::ARRAY_BONES; + vd.location = RS::ARRAY_BONES; vd.stride = stride * sizeof(float); descriptions.write[3] = vd; @@ -404,7 +404,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int RD::VertexDescription vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT; vd.offset = 0; - vd.location = VS::ARRAY_BONES; + vd.location = RS::ARRAY_BONES; vd.stride = 0; descriptions.write[3] = vd; @@ -558,7 +558,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ light_cache[light_count] = light; light_count++; - if (light->mode == VS::CANVAS_LIGHT_MODE_MASK) { + if (light->mode == RS::CANVAS_LIGHT_MODE_MASK) { base_flags |= FLAGS_USING_LIGHT_MASK; } if (light_count == state.max_lights_per_item) { @@ -888,13 +888,13 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ ERR_CONTINUE(!pb); //bind pipeline { - static const PipelineVariant variant[VS::PRIMITIVE_MAX] = { PIPELINE_VARIANT_ATTRIBUTE_POINTS, PIPELINE_VARIANT_ATTRIBUTE_LINES, PIPELINE_VARIANT_ATTRIBUTE_LINES_STRIP, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLES, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLE_STRIP }; - ERR_CONTINUE(polygon->primitive < 0 || polygon->primitive >= VS::PRIMITIVE_MAX); + static const PipelineVariant variant[RS::PRIMITIVE_MAX] = { PIPELINE_VARIANT_ATTRIBUTE_POINTS, PIPELINE_VARIANT_ATTRIBUTE_LINES, PIPELINE_VARIANT_ATTRIBUTE_LINES_STRIP, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLES, PIPELINE_VARIANT_ATTRIBUTE_TRIANGLE_STRIP }; + ERR_CONTINUE(polygon->primitive < 0 || polygon->primitive >= RS::PRIMITIVE_MAX); RID pipeline = pipeline_variants->variants[light_mode][variant[polygon->primitive]].get_render_pipeline(pb->vertex_format_id, p_framebuffer_format); RD::get_singleton()->draw_list_bind_render_pipeline(p_draw_list, pipeline); } - if (polygon->primitive == VS::PRIMITIVE_LINES) { + if (polygon->primitive == RS::PRIMITIVE_LINES) { //not supported in most hardware, so pointless //RD::get_singleton()->draw_list_set_line_width(p_draw_list, polygon->line_width); } @@ -1024,7 +1024,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ // materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing glBindVertexArray(s->array_id); - glVertexAttrib4f(VS::ARRAY_COLOR, mesh->modulate.r, mesh->modulate.g, mesh->modulate.b, mesh->modulate.a); + glVertexAttrib4f(RS::ARRAY_COLOR, mesh->modulate.r, mesh->modulate.g, mesh->modulate.b, mesh->modulate.a); if (s->index_array_len) { glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len >= (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); @@ -1054,7 +1054,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map); - state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != VS::MULTIMESH_CUSTOM_DATA_NONE); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE); state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCING, true); //reset shader and force rebind state.using_texture_rect = true; @@ -1088,7 +1088,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ int color_ofs; - if (multi_mesh->transform_format == VS::MULTIMESH_TRANSFORM_3D) { + if (multi_mesh->transform_format == RS::MULTIMESH_TRANSFORM_3D) { glEnableVertexAttribArray(10); glVertexAttribPointer(10, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(8 * 4)); glVertexAttribDivisor(10, 1); @@ -1103,18 +1103,18 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ switch (multi_mesh->color_format) { - case VS::MULTIMESH_COLOR_NONE: { + case RS::MULTIMESH_COLOR_NONE: { glDisableVertexAttribArray(11); glVertexAttrib4f(11, 1, 1, 1, 1); } break; - case VS::MULTIMESH_COLOR_8BIT: { + case RS::MULTIMESH_COLOR_8BIT: { glEnableVertexAttribArray(11); glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, CAST_INT_TO_UCHAR_PTR(color_ofs)); glVertexAttribDivisor(11, 1); custom_data_ofs += 4; } break; - case VS::MULTIMESH_COLOR_FLOAT: { + case RS::MULTIMESH_COLOR_FLOAT: { glEnableVertexAttribArray(11); glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(color_ofs)); glVertexAttribDivisor(11, 1); @@ -1124,17 +1124,17 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ switch (multi_mesh->custom_data_format) { - case VS::MULTIMESH_CUSTOM_DATA_NONE: { + case RS::MULTIMESH_CUSTOM_DATA_NONE: { glDisableVertexAttribArray(12); glVertexAttrib4f(12, 1, 1, 1, 1); } break; - case VS::MULTIMESH_CUSTOM_DATA_8BIT: { + case RS::MULTIMESH_CUSTOM_DATA_8BIT: { glEnableVertexAttribArray(12); glVertexAttribPointer(12, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, CAST_INT_TO_UCHAR_PTR(custom_data_ofs)); glVertexAttribDivisor(12, 1); } break; - case VS::MULTIMESH_CUSTOM_DATA_FLOAT: { + case RS::MULTIMESH_CUSTOM_DATA_FLOAT: { glEnableVertexAttribArray(12); glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(custom_data_ofs)); glVertexAttribDivisor(12, 1); @@ -1167,9 +1167,9 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ if (particles->inactive && !particles->emitting) break; - glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); //not used, so keep white + glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1); //not used, so keep white - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); storage->particles_request_process(particles_cmd->particles); //enable instancing @@ -1208,7 +1208,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ int amount = particles->amount; - if (particles->draw_order != VS::PARTICLES_DRAW_ORDER_LIFETIME) { + if (particles->draw_order != RS::PARTICLES_DRAW_ORDER_LIFETIME) { glEnableVertexAttribArray(8); //xform x glVertexAttribPointer(8, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 3)); @@ -1220,7 +1220,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ glVertexAttribPointer(10, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 5)); glVertexAttribDivisor(10, 1); glEnableVertexAttribArray(11); //color - glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, NULL); + glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, nullptr); glVertexAttribDivisor(11, 1); glEnableVertexAttribArray(12); //custom glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 2)); @@ -1262,7 +1262,7 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ glVertexAttribPointer(10, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 5)); glVertexAttribDivisor(10, 1); glEnableVertexAttribArray(11); //color - glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, NULL); + glVertexAttribPointer(11, 4, GL_FLOAT, GL_FALSE, stride, nullptr); glVertexAttribDivisor(11, 1); glEnableVertexAttribArray(12); //custom glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, stride, CAST_INT_TO_UCHAR_PTR(sizeof(float) * 4 * 2)); @@ -1314,13 +1314,13 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ if (current_clip && reclip) { //will make it re-enable clipping if needed afterwards - current_clip = NULL; + current_clip = nullptr; } } void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, RID p_screen_uniform_set) { - Item *current_clip = NULL; + Item *current_clip = nullptr; Transform2D canvas_transform_inverse = p_canvas_transform_inverse; @@ -1369,7 +1369,7 @@ void RasterizerCanvasRD::_render_items(RID p_to_render_target, int p_item_count, if (ci->material != prev_material) { - MaterialData *material_data = NULL; + MaterialData *material_data = nullptr; if (ci->material.is_valid()) { material_data = (MaterialData *)storage->material_get_data(ci->material, RasterizerStorageRD::SHADER_TYPE_2D); } @@ -1712,7 +1712,7 @@ RID RasterizerCanvasRD::occluder_polygon_create() { OccluderPolygon occluder; occluder.point_count = 0; - occluder.cull_mode = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; + occluder.cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; return occluder_polygon_owner.make_rid(occluder); } @@ -1805,7 +1805,7 @@ void RasterizerCanvasRD::occluder_polygon_set_shape_as_lines(RID p_occluder, con } } } -void RasterizerCanvasRD::occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode) { +void RasterizerCanvasRD::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) { OccluderPolygon *oc = occluder_polygon_owner.getornull(p_occluder); ERR_FAIL_COND(!oc); oc->cull_mode = p_mode; @@ -1849,7 +1849,7 @@ void RasterizerCanvasRD::ShaderData::set_code(const String &p_code) { RasterizerCanvasRD *canvas_singleton = (RasterizerCanvasRD *)RasterizerCanvas::singleton; - Error err = canvas_singleton->shader.compiler.compile(VS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code); + Error err = canvas_singleton->shader.compiler.compile(RS::SHADER_CANVAS_ITEM, code, &actions, path, gen_code); ERR_FAIL_COND(err != OK); @@ -2138,18 +2138,18 @@ void RasterizerCanvasRD::MaterialData::update_parameters(const Map<StringName, V u.binding = 0; u.ids.resize(12); RID *ids_ptr = u.ids.ptrw(); - ids_ptr[0] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[1] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[2] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[3] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[4] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[5] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[6] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[7] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[8] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[9] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[10] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[11] = canvas_singleton->storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[0] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[1] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[2] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[3] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[4] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[5] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[6] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[7] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[8] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[9] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[10] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[11] = canvas_singleton->storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); uniforms.push_back(u); } @@ -2204,8 +2204,8 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) { { //create default samplers - default_samplers.default_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; - default_samplers.default_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; + default_samplers.default_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; + default_samplers.default_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; } { //shader variants @@ -2418,7 +2418,7 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) { { //bindings bindings.id_generator = 0; //generate for 0 - bindings.default_empty = request_texture_binding(RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, RID()); + bindings.default_empty = request_texture_binding(RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, RID()); { //state allocate state.canvas_state_buffer = RD::get_singleton()->uniform_buffer_create(sizeof(State::Buffer)); @@ -2532,7 +2532,7 @@ RasterizerCanvasRD::~RasterizerCanvasRD() { //anything remains? if (bindings.texture_bindings.size()) { ERR_PRINT("Some texture bindings were not properly freed (leaked canvasitems?"); - const TextureBindingID *key = NULL; + const TextureBindingID *key = nullptr; while ((key = bindings.texture_bindings.next(key))) { TextureBinding *tb = bindings.texture_bindings[*key]; tb->reference_count = 1; diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h index 894a00a436..83b431eaf6 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h @@ -31,13 +31,13 @@ #ifndef RASTERIZER_CANVAS_RD_H #define RASTERIZER_CANVAS_RD_H -#include "servers/visual/rasterizer.h" -#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h" -#include "servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h" -#include "servers/visual/rasterizer_rd/shader_compiler_rd.h" -#include "servers/visual/rasterizer_rd/shaders/canvas.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl.gen.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h" +#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h" +#include "servers/rendering/rasterizer_rd/shader_compiler_rd.h" +#include "servers/rendering/rasterizer_rd/shaders/canvas.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl.gen.h" +#include "servers/rendering/rendering_device.h" class RasterizerCanvasRD : public RasterizerCanvas { @@ -229,8 +229,8 @@ class RasterizerCanvasRD : public RasterizerCanvas { RID normalmap; RID specular; RID multimesh; - VS::CanvasItemTextureFilter texture_filter; - VS::CanvasItemTextureRepeat texture_repeat; + RS::CanvasItemTextureFilter texture_filter; + RS::CanvasItemTextureRepeat texture_repeat; bool operator==(const TextureBindingKey &p_key) const { return texture == p_key.texture && normalmap == p_key.normalmap && specular == p_key.specular && multimesh == p_key.specular && texture_filter == p_key.texture_filter && texture_repeat == p_key.texture_repeat; } @@ -269,12 +269,12 @@ class RasterizerCanvasRD : public RasterizerCanvas { TextureBindingID default_empty; } bindings; - RID _create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh); + RID _create_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat, RID p_multimesh); void _dispose_bindings(); struct { - VS::CanvasItemTextureFilter default_filter; - VS::CanvasItemTextureRepeat default_repeat; + RS::CanvasItemTextureFilter default_filter; + RS::CanvasItemTextureRepeat default_repeat; } default_samplers; /******************/ @@ -332,7 +332,7 @@ class RasterizerCanvasRD : public RasterizerCanvas { struct OccluderPolygon { - VS::CanvasOccluderPolygonCullMode cull_mode; + RS::CanvasOccluderPolygonCullMode cull_mode; int point_count; RID vertex_buffer; RID vertex_array; @@ -383,7 +383,7 @@ class RasterizerCanvasRD : public RasterizerCanvas { for (int i = 0; i < DEFAULT_MAX_LIGHTS_PER_ITEM; i++) { light_cache[i].light_version = 0; - light_cache[i].light = NULL; + light_cache[i].light = nullptr; } light_cache_count = 0xFFFFFFFF; } @@ -470,7 +470,7 @@ class RasterizerCanvasRD : public RasterizerCanvas { _FORCE_INLINE_ void _update_specular_shininess(const Color &p_transform, uint32_t *r_ss); public: - TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh); + TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat, RID p_multimesh); void free_texture_binding(TextureBindingID p_binding); PolygonID request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>()); @@ -483,7 +483,7 @@ public: RID occluder_polygon_create(); void occluder_polygon_set_shape_as_lines(RID p_occluder, const Vector<Vector2> &p_lines); - void occluder_polygon_set_cull_mode(RID p_occluder, VS::CanvasOccluderPolygonCullMode p_mode); + void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode); void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform); diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp index 355ebfa409..3b22cb4d9d 100644 --- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.cpp @@ -29,9 +29,11 @@ /*************************************************************************/ #include "rasterizer_effects_rd.h" + #include "core/os/os.h" #include "core/project_settings.h" -#include "cubemap_coeffs.h" + +#include "thirdparty/misc/cubemap_coeffs.h" static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_array) { p_array[0] = p_basis.elements[0][0]; @@ -48,6 +50,16 @@ static _FORCE_INLINE_ void store_transform_3x3(const Basis &p_basis, float *p_ar p_array[11] = 0; } +static _FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array) { + + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + + p_array[i * 4 + j] = p_mtx.matrix[i][j]; + } + } +} + RID RasterizerEffectsRD::_get_uniform_set_from_image(RID p_image) { if (image_to_uniform_set_cache.has(p_image)) { @@ -118,6 +130,80 @@ RID RasterizerEffectsRD::_get_compute_uniform_set_from_texture(RID p_texture, bo return uniform_set; } +RID RasterizerEffectsRD::_get_compute_uniform_set_from_texture_pair(RID p_texture1, RID p_texture2, bool p_use_mipmaps) { + + TexturePair tp; + tp.texture1 = p_texture1; + tp.texture2 = p_texture2; + + if (texture_pair_to_compute_uniform_set_cache.has(tp)) { + RID uniform_set = texture_pair_to_compute_uniform_set_cache[tp]; + if (RD::get_singleton()->uniform_set_is_valid(uniform_set)) { + return uniform_set; + } + } + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.type = RD::UNIFORM_TYPE_SAMPLER_WITH_TEXTURE; + u.binding = 0; + u.ids.push_back(p_use_mipmaps ? default_mipmap_sampler : default_sampler); + u.ids.push_back(p_texture1); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.type = RD::UNIFORM_TYPE_SAMPLER_WITH_TEXTURE; + u.binding = 1; + u.ids.push_back(p_use_mipmaps ? default_mipmap_sampler : default_sampler); + u.ids.push_back(p_texture2); + uniforms.push_back(u); + } + //any thing with the same configuration (one texture in binding 0 for set 0), is good + RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssr_scale.shader.version_get_shader(ssr_scale.shader_version, 0), 1); + + texture_pair_to_compute_uniform_set_cache[tp] = uniform_set; + + return uniform_set; +} + +RID RasterizerEffectsRD::_get_compute_uniform_set_from_image_pair(RID p_texture1, RID p_texture2) { + + TexturePair tp; + tp.texture1 = p_texture1; + tp.texture2 = p_texture2; + + if (image_pair_to_compute_uniform_set_cache.has(tp)) { + RID uniform_set = image_pair_to_compute_uniform_set_cache[tp]; + if (RD::get_singleton()->uniform_set_is_valid(uniform_set)) { + return uniform_set; + } + } + + Vector<RD::Uniform> uniforms; + { + RD::Uniform u; + u.type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 0; + u.ids.push_back(p_texture1); + uniforms.push_back(u); + } + { + RD::Uniform u; + u.type = RD::UNIFORM_TYPE_IMAGE; + u.binding = 1; + u.ids.push_back(p_texture2); + uniforms.push_back(u); + } + //any thing with the same configuration (one texture in binding 0 for set 0), is good + RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, ssr_scale.shader.version_get_shader(ssr_scale.shader_version, 0), 3); + + image_pair_to_compute_uniform_set_cache[tp] = uniform_set; + + return uniform_set; +} + void RasterizerEffectsRD::copy_to_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_rect, bool p_flip_y, bool p_force_luminance) { zeromem(&blur.push_constant, sizeof(BlurPushConstant)); @@ -216,6 +302,7 @@ void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_framebuff blur.push_constant.glow_exposure = p_exposure; blur.push_constant.glow_white = 0; //actually unused blur.push_constant.glow_luminance_cap = p_luminance_cap; + blur.push_constant.glow_auto_exposure_grey = p_auto_exposure_grey; //unused also //HORIZONTAL @@ -248,6 +335,165 @@ void RasterizerEffectsRD::gaussian_glow(RID p_source_rd_texture, RID p_framebuff RD::get_singleton()->draw_list_end(); } +void RasterizerEffectsRD::screen_space_reflection(RID p_diffuse, RID p_normal, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_roughness, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera) { + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + + int32_t x_groups = (p_screen_size.width - 1) / 8 + 1; + int32_t y_groups = (p_screen_size.height - 1) / 8 + 1; + + { //scale color and depth to half + ssr_scale.push_constant.camera_z_far = p_camera.get_z_far(); + ssr_scale.push_constant.camera_z_near = p_camera.get_z_near(); + ssr_scale.push_constant.orthogonal = p_camera.is_orthogonal(); + ssr_scale.push_constant.filter = false; //enabling causes arctifacts + ssr_scale.push_constant.screen_size[0] = p_screen_size.x; + ssr_scale.push_constant.screen_size[1] = p_screen_size.y; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssr_scale.pipeline); + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_diffuse), 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture_pair(p_depth, p_normal), 1); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_output_blur), 2); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_scale_depth, p_scale_normal), 3); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ssr_scale.push_constant, sizeof(ScreenSpaceReflectionScalePushConstant)); + + RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1); + + RD::get_singleton()->compute_list_add_barrier(compute_list); + } + + { + + ssr.push_constant.camera_z_far = p_camera.get_z_far(); + ssr.push_constant.camera_z_near = p_camera.get_z_near(); + ssr.push_constant.orthogonal = p_camera.is_orthogonal(); + ssr.push_constant.screen_size[0] = p_screen_size.x; + ssr.push_constant.screen_size[1] = p_screen_size.y; + ssr.push_constant.curve_fade_in = p_fade_in; + ssr.push_constant.distance_fade = p_fade_out; + ssr.push_constant.num_steps = p_max_steps; + ssr.push_constant.depth_tolerance = p_tolerance; + ssr.push_constant.use_half_res = true; + ssr.push_constant.proj_info[0] = -2.0f / (p_screen_size.width * p_camera.matrix[0][0]); + ssr.push_constant.proj_info[1] = -2.0f / (p_screen_size.height * p_camera.matrix[1][1]); + ssr.push_constant.proj_info[2] = (1.0f - p_camera.matrix[0][2]) / p_camera.matrix[0][0]; + ssr.push_constant.proj_info[3] = (1.0f + p_camera.matrix[1][2]) / p_camera.matrix[1][1]; + ssr.push_constant.metallic_mask[0] = CLAMP(p_metallic_mask.r * 255.0, 0, 255); + ssr.push_constant.metallic_mask[1] = CLAMP(p_metallic_mask.g * 255.0, 0, 255); + ssr.push_constant.metallic_mask[2] = CLAMP(p_metallic_mask.b * 255.0, 0, 255); + ssr.push_constant.metallic_mask[3] = CLAMP(p_metallic_mask.a * 255.0, 0, 255); + store_camera(p_camera, ssr.push_constant.projection); + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssr.pipelines[(p_roughness_quality != RS::ENV_SSR_ROUGNESS_QUALITY_DISABLED) ? SCREEN_SPACE_REFLECTION_ROUGH : SCREEN_SPACE_REFLECTION_NORMAL]); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ssr.push_constant, sizeof(ScreenSpaceReflectionPushConstant)); + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_output_blur, p_scale_depth), 0); + + if (p_roughness_quality != RS::ENV_SSR_ROUGNESS_QUALITY_DISABLED) { + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_output, p_blur_radius), 1); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture_pair(p_metallic, p_roughness), 3); + } else { + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_output), 1); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_metallic), 3); + } + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_scale_normal), 2); + + RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1); + } + + if (p_roughness_quality != RS::ENV_SSR_ROUGNESS_QUALITY_DISABLED) { + + //blurr + + RD::get_singleton()->compute_list_add_barrier(compute_list); + + ssr_filter.push_constant.orthogonal = p_camera.is_orthogonal(); + ssr_filter.push_constant.edge_tolerance = Math::sin(Math::deg2rad(15.0)); + ssr_filter.push_constant.proj_info[0] = -2.0f / (p_screen_size.width * p_camera.matrix[0][0]); + ssr_filter.push_constant.proj_info[1] = -2.0f / (p_screen_size.height * p_camera.matrix[1][1]); + ssr_filter.push_constant.proj_info[2] = (1.0f - p_camera.matrix[0][2]) / p_camera.matrix[0][0]; + ssr_filter.push_constant.proj_info[3] = (1.0f + p_camera.matrix[1][2]) / p_camera.matrix[1][1]; + ssr_filter.push_constant.vertical = 0; + if (p_roughness_quality == RS::ENV_SSR_ROUGNESS_QUALITY_LOW) { + ssr_filter.push_constant.steps = p_max_steps / 3; + ssr_filter.push_constant.increment = 3; + } else if (p_roughness_quality == RS::ENV_SSR_ROUGNESS_QUALITY_MEDIUM) { + ssr_filter.push_constant.steps = p_max_steps / 2; + ssr_filter.push_constant.increment = 2; + } else { + ssr_filter.push_constant.steps = p_max_steps; + ssr_filter.push_constant.increment = 1; + } + + ssr_filter.push_constant.screen_size[0] = p_screen_size.width; + ssr_filter.push_constant.screen_size[1] = p_screen_size.height; + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssr_filter.pipelines[SCREEN_SPACE_REFLECTION_FILTER_HORIZONTAL]); + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_output, p_blur_radius), 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_scale_normal), 1); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_output_blur, p_blur_radius2), 2); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_scale_depth), 3); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ssr_filter.push_constant, sizeof(ScreenSpaceReflectionFilterPushConstant)); + + RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1); + + RD::get_singleton()->compute_list_add_barrier(compute_list); + + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssr_filter.pipelines[SCREEN_SPACE_REFLECTION_FILTER_VERTICAL]); + + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_image_pair(p_output_blur, p_blur_radius2), 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_scale_normal), 1); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_output), 2); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_scale_depth), 3); + + ssr_filter.push_constant.vertical = 1; + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &ssr_filter.push_constant, sizeof(ScreenSpaceReflectionFilterPushConstant)); + + RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1); + } + + RD::get_singleton()->compute_list_end(); +} + +void RasterizerEffectsRD::merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection) { + + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD, Vector<Color>()); + + if (p_reflection.is_valid()) { + + if (p_base.is_valid()) { + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, specular_merge.pipelines[SPECULAR_MERGE_SSR].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_base), 2); + } else { + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, specular_merge.pipelines[SPECULAR_MERGE_ADDITIVE_SSR].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + } + + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_specular), 0); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_reflection), 1); + + } else { + + if (p_base.is_valid()) { + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, specular_merge.pipelines[SPECULAR_MERGE_ADD].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_base), 2); + } else { + RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, specular_merge.pipelines[SPECULAR_MERGE_ADDITIVE_ADD].get_render_pipeline(RD::INVALID_ID, RD::get_singleton()->framebuffer_get_format(p_dest_framebuffer))); + } + + RD::get_singleton()->draw_list_bind_uniform_set(draw_list, _get_uniform_set_from_texture(p_specular), 0); + } + + RD::get_singleton()->draw_list_bind_index_array(draw_list, index_array); + RD::get_singleton()->draw_list_draw(draw_list, true); + RD::get_singleton()->draw_list_end(); +} + void RasterizerEffectsRD::make_mipmap(RID p_source_rd_texture, RID p_dest_framebuffer, const Vector2 &p_pixel_size) { zeromem(&blur.push_constant, sizeof(BlurPushConstant)); @@ -365,7 +611,7 @@ void RasterizerEffectsRD::luminance_reduction(RID p_source_texture, const Size2i RD::get_singleton()->compute_list_end(); } -void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, VisualServer::DOFBokehShape p_bokeh_shape, VS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) { +void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_halfsize_texture1, RID p_halfsize_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RenderingServer::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal) { bokeh.push_constant.blur_far_active = p_dof_far; bokeh.push_constant.blur_far_begin = p_dof_far_begin; @@ -408,16 +654,16 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1); RD::get_singleton()->compute_list_add_barrier(compute_list); - if (p_bokeh_shape == VS::DOF_BOKEH_BOX || p_bokeh_shape == VS::DOF_BOKEH_HEXAGON) { + if (p_bokeh_shape == RS::DOF_BOKEH_BOX || p_bokeh_shape == RS::DOF_BOKEH_HEXAGON) { //second pass - RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[p_bokeh_shape == VS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[p_bokeh_shape == RS::DOF_BOKEH_BOX ? BOKEH_GEN_BOKEH_BOX : BOKEH_GEN_BOKEH_HEXAGONAL]); static const int quality_samples[4] = { 6, 12, 12, 24 }; bokeh.push_constant.steps = quality_samples[p_quality]; - if (p_quality == VS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == VS::DOF_BLUR_QUALITY_LOW) { + if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) { //box and hexagon are more or less the same, and they can work in either half (very low and low quality) or full (medium and high quality_ sizes) RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture1), 0); @@ -444,7 +690,7 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con //third pass bokeh.push_constant.second_pass = true; - if (p_quality == VS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == VS::DOF_BLUR_QUALITY_LOW) { + if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) { RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_halfsize_texture2), 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_halfsize_texture1), 1); @@ -458,7 +704,7 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con RD::get_singleton()->compute_list_dispatch(compute_list, x_groups, y_groups, 1); RD::get_singleton()->compute_list_add_barrier(compute_list); - if (p_quality == VS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == VS::DOF_BLUR_QUALITY_LOW) { + if (p_quality == RS::DOF_BLUR_QUALITY_VERY_LOW || p_quality == RS::DOF_BLUR_QUALITY_LOW) { //forth pass, upscale for low quality RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, bokeh.pipelines[BOKEH_COMPOSITE]); @@ -528,7 +774,7 @@ void RasterizerEffectsRD::bokeh_dof(RID p_base_texture, RID p_depth_texture, con RD::get_singleton()->compute_list_end(); } -void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness) { +void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness) { //minify first ssao.minify_push_constant.orthogonal = p_projection.is_orthogonal(); @@ -628,7 +874,7 @@ void RasterizerEffectsRD::generate_ssao(RID p_depth_buffer, RID p_normal_buffer, ssao.blur_push_constant.axis[0] = 1; ssao.blur_push_constant.axis[1] = 0; - if (p_blur != VS::ENV_SSAO_BLUR_DISABLED) { + if (p_blur != RS::ENV_SSAO_BLUR_DISABLED) { RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, ssao.pipelines[p_half_size ? SSAO_BLUR_PASS_HALF : SSAO_BLUR_PASS]); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_ao1), 0); @@ -968,6 +1214,7 @@ RasterizerEffectsRD::RasterizerEffectsRD() { for (int i = SSAO_BLUR_PASS; i <= SSAO_BLUR_UPSCALE; i++) { ssao.pipelines[pipeline] = RD::get_singleton()->compute_pipeline_create(ssao.blur_shader.version_get_shader(ssao.blur_shader_version, i - SSAO_BLUR_PASS)); + pipeline++; } } @@ -1033,6 +1280,82 @@ RasterizerEffectsRD::RasterizerEffectsRD() { filter.uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.shader.version_get_shader(filter.shader_version, filter.use_high_quality ? 0 : 1), 1); } + { + Vector<String> specular_modes; + specular_modes.push_back("\n#define MODE_MERGE\n"); + specular_modes.push_back("\n#define MODE_MERGE\n#define MODE_SSR\n"); + specular_modes.push_back("\n"); + specular_modes.push_back("\n#define MODE_SSR\n"); + + specular_merge.shader.initialize(specular_modes); + + specular_merge.shader_version = specular_merge.shader.version_create(); + + //use additive + + RD::PipelineColorBlendState::Attachment ba; + ba.enable_blend = true; + ba.src_color_blend_factor = RD::BLEND_FACTOR_ONE; + ba.dst_color_blend_factor = RD::BLEND_FACTOR_ONE; + ba.src_alpha_blend_factor = RD::BLEND_FACTOR_ONE; + ba.dst_alpha_blend_factor = RD::BLEND_FACTOR_ONE; + ba.color_blend_op = RD::BLEND_OP_ADD; + ba.alpha_blend_op = RD::BLEND_OP_ADD; + + RD::PipelineColorBlendState blend_additive; + blend_additive.attachments.push_back(ba); + + for (int i = 0; i < SPECULAR_MERGE_MAX; i++) { + + RD::PipelineColorBlendState blend_state; + if (i == SPECULAR_MERGE_ADDITIVE_ADD || i == SPECULAR_MERGE_ADDITIVE_SSR) { + blend_state = blend_additive; + } else { + blend_state = RD::PipelineColorBlendState::create_disabled(); + } + specular_merge.pipelines[i].setup(specular_merge.shader.version_get_shader(specular_merge.shader_version, i), RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), blend_state, 0); + } + } + + { + Vector<String> ssr_modes; + ssr_modes.push_back("\n"); + ssr_modes.push_back("\n#define MODE_ROUGH\n"); + + ssr.shader.initialize(ssr_modes); + + ssr.shader_version = ssr.shader.version_create(); + + for (int i = 0; i < SCREEN_SPACE_REFLECTION_MAX; i++) { + ssr.pipelines[i] = RD::get_singleton()->compute_pipeline_create(ssr.shader.version_get_shader(ssr.shader_version, i)); + } + } + + { + Vector<String> ssr_filter_modes; + ssr_filter_modes.push_back("\n"); + ssr_filter_modes.push_back("\n#define VERTICAL_PASS\n"); + + ssr_filter.shader.initialize(ssr_filter_modes); + + ssr_filter.shader_version = ssr_filter.shader.version_create(); + + for (int i = 0; i < SCREEN_SPACE_REFLECTION_FILTER_MAX; i++) { + ssr_filter.pipelines[i] = RD::get_singleton()->compute_pipeline_create(ssr_filter.shader.version_get_shader(ssr_filter.shader_version, i)); + } + } + + { + Vector<String> ssr_scale_modes; + ssr_scale_modes.push_back("\n"); + + ssr_scale.shader.initialize(ssr_scale_modes); + + ssr_scale.shader_version = ssr_scale.shader.version_create(); + + ssr_scale.pipeline = RD::get_singleton()->compute_pipeline_create(ssr_scale.shader.version_get_shader(ssr_scale.shader_version, 0)); + } + RD::SamplerState sampler; sampler.mag_filter = RD::SAMPLER_FILTER_LINEAR; sampler.min_filter = RD::SAMPLER_FILTER_LINEAR; diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h index 562a7b674b..32eb8c8cda 100644 --- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_effects_rd.h @@ -32,21 +32,25 @@ #define RASTERIZER_EFFECTS_RD_H #include "core/math/camera_matrix.h" -#include "servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h" -#include "servers/visual/rasterizer_rd/shaders/blur.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/copy.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/ssao.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/ssao_blur.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/ssao_minify.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/tonemap.glsl.gen.h" - -#include "servers/visual_server.h" +#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h" +#include "servers/rendering/rasterizer_rd/shaders/blur.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/copy.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/specular_merge.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/ssao.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/tonemap.glsl.gen.h" + +#include "servers/rendering_server.h" class RasterizerEffectsRD { @@ -378,6 +382,104 @@ class RasterizerEffectsRD { float pad[3]; }; + enum SpecularMergeMode { + SPECULAR_MERGE_ADD, + SPECULAR_MERGE_SSR, + SPECULAR_MERGE_ADDITIVE_ADD, + SPECULAR_MERGE_ADDITIVE_SSR, + SPECULAR_MERGE_MAX + }; + + struct SpecularMerge { + + SpecularMergeShaderRD shader; + RID shader_version; + RenderPipelineVertexFormatCacheRD pipelines[SPECULAR_MERGE_MAX]; + + } specular_merge; + + enum ScreenSpaceReflectionMode { + SCREEN_SPACE_REFLECTION_NORMAL, + SCREEN_SPACE_REFLECTION_ROUGH, + SCREEN_SPACE_REFLECTION_MAX, + }; + + struct ScreenSpaceReflectionPushConstant { + + float proj_info[4]; + + int32_t screen_size[2]; + float camera_z_near; + float camera_z_far; + + int32_t num_steps; + float depth_tolerance; + float distance_fade; + float curve_fade_in; + + uint32_t orthogonal; + float filter_mipmap_levels; + uint32_t use_half_res; + uint8_t metallic_mask[4]; + + float projection[16]; + }; + + struct ScreenSpaceReflection { + + ScreenSpaceReflectionPushConstant push_constant; + ScreenSpaceReflectionShaderRD shader; + RID shader_version; + RID pipelines[SCREEN_SPACE_REFLECTION_MAX]; + + } ssr; + + struct ScreenSpaceReflectionFilterPushConstant { + + float proj_info[4]; + + uint32_t orthogonal; + float edge_tolerance; + int32_t increment; + uint32_t pad; + + int32_t screen_size[2]; + uint32_t vertical; + uint32_t steps; + }; + enum { + SCREEN_SPACE_REFLECTION_FILTER_HORIZONTAL, + SCREEN_SPACE_REFLECTION_FILTER_VERTICAL, + SCREEN_SPACE_REFLECTION_FILTER_MAX, + }; + + struct ScreenSpaceReflectionFilter { + + ScreenSpaceReflectionFilterPushConstant push_constant; + ScreenSpaceReflectionFilterShaderRD shader; + RID shader_version; + RID pipelines[SCREEN_SPACE_REFLECTION_FILTER_MAX]; + } ssr_filter; + + struct ScreenSpaceReflectionScalePushConstant { + + int32_t screen_size[2]; + float camera_z_near; + float camera_z_far; + + uint32_t orthogonal; + uint32_t filter; + uint32_t pad[2]; + }; + + struct ScreenSpaceReflectionScale { + + ScreenSpaceReflectionScalePushConstant push_constant; + ScreenSpaceReflectionScaleShaderRD shader; + RID shader_version; + RID pipeline; + } ssr_scale; + RID default_sampler; RID default_mipmap_sampler; RID index_buffer; @@ -386,11 +488,28 @@ class RasterizerEffectsRD { Map<RID, RID> texture_to_uniform_set_cache; Map<RID, RID> image_to_uniform_set_cache; + + struct TexturePair { + RID texture1; + RID texture2; + _FORCE_INLINE_ bool operator<(const TexturePair &p_pair) const { + if (texture1 == p_pair.texture1) { + return texture2 < p_pair.texture2; + } else { + return texture1 < p_pair.texture1; + } + } + }; + Map<RID, RID> texture_to_compute_uniform_set_cache; + Map<TexturePair, RID> texture_pair_to_compute_uniform_set_cache; + Map<TexturePair, RID> image_pair_to_compute_uniform_set_cache; RID _get_uniform_set_from_image(RID p_texture); RID _get_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false); RID _get_compute_uniform_set_from_texture(RID p_texture, bool p_use_mipmaps = false); + RID _get_compute_uniform_set_from_texture_pair(RID p_texture, RID p_texture2, bool p_use_mipmaps = false); + RID _get_compute_uniform_set_from_image_pair(RID p_texture, RID p_texture2); public: //TODO must re-do most of the shaders in compute @@ -404,7 +523,7 @@ public: void make_mipmap(RID p_source_rd_texture, RID p_framebuffer_half, const Vector2 &p_pixel_size); void copy_cubemap_to_dp(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_rect, float p_z_near, float p_z_far, float p_bias, bool p_dp_flip); void luminance_reduction(RID p_source_texture, const Size2i p_source_size, const Vector<RID> p_reduce, RID p_prev_luminance, float p_min_luminance, float p_max_luminance, float p_adjust, bool p_set = false); - void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, VS::DOFBokehShape p_bokeh_shape, VS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal); + void bokeh_dof(RID p_base_texture, RID p_depth_texture, const Size2i &p_base_texture_size, RID p_secondary_texture, RID p_bokeh_texture1, RID p_bokeh_texture2, bool p_dof_far, float p_dof_far_begin, float p_dof_far_size, bool p_dof_near, float p_dof_near_begin, float p_dof_near_size, float p_bokeh_size, RS::DOFBokehShape p_bokeh_shape, RS::DOFBlurQuality p_quality, bool p_use_jitter, float p_cam_znear, float p_cam_zfar, bool p_cam_orthogonal); struct TonemapSettings { @@ -424,7 +543,7 @@ public: bool glow_use_bicubic_upscale = false; RID glow_texture; - VS::EnvironmentToneMapper tonemap_mode = VS::ENV_TONE_MAPPER_LINEAR; + RS::EnvironmentToneMapper tonemap_mode = RS::ENV_TONE_MAPPER_LINEAR; float exposure = 1.0; float white = 1.0; @@ -443,13 +562,16 @@ public: void tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings); - void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, VS::EnvironmentSSAOQuality p_quality, VS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness); + void generate_ssao(RID p_depth_buffer, RID p_normal_buffer, const Size2i &p_depth_buffer_size, RID p_depth_mipmaps_texture, const Vector<RID> &depth_mipmaps, RID p_ao1, bool p_half_size, RID p_ao2, RID p_upscale_buffer, float p_intensity, float p_radius, float p_bias, const CameraMatrix &p_projection, RS::EnvironmentSSAOQuality p_quality, RS::EnvironmentSSAOBlur p_blur, float p_edge_sharpness); void roughness_limit(RID p_source_normal, RID p_roughness, const Size2i &p_size, float p_curve); void cubemap_downsample(RID p_source_cubemap, RID p_dest_cubemap, const Size2i &p_size); void cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array); void render_sky(RD::DrawListID p_list, float p_time, RID p_fb, RID p_samplers, RID p_lights, RenderPipelineVertexFormatCacheRD *p_pipeline, RID p_uniform_set, RID p_texture_set, const CameraMatrix &p_camera, const Basis &p_orientation, float p_multiplier, const Vector3 &p_position); + void screen_space_reflection(RID p_diffuse, RID p_normal, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, RID p_roughness, RID p_blur_radius, RID p_blur_radius2, RID p_metallic, const Color &p_metallic_mask, RID p_depth, RID p_scale_depth, RID p_scale_normal, RID p_output, RID p_output_blur, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const CameraMatrix &p_camera); + void merge_specular(RID p_dest_framebuffer, RID p_specular, RID p_base, RID p_reflection); + RasterizerEffectsRD(); ~RasterizerEffectsRD(); }; diff --git a/servers/visual/rasterizer_rd/rasterizer_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_rd.cpp index 9c54f0caae..9c54f0caae 100644 --- a/servers/visual/rasterizer_rd/rasterizer_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_rd.cpp diff --git a/servers/visual/rasterizer_rd/rasterizer_rd.h b/servers/rendering/rasterizer_rd/rasterizer_rd.h index bbcf9bfefe..756b9499ca 100644 --- a/servers/visual/rasterizer_rd/rasterizer_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_rd.h @@ -33,10 +33,10 @@ #include "core/os/os.h" #include "core/thread_work_pool.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual/rasterizer_rd/rasterizer_canvas_rd.h" -#include "servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h" -#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering/rasterizer_rd/rasterizer_canvas_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h" class RasterizerRD : public Rasterizer { protected: diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp index 70219a3981..6094fbb36f 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp @@ -30,8 +30,8 @@ #include "rasterizer_scene_high_end_rd.h" #include "core/project_settings.h" -#include "servers/visual/rendering_device.h" -#include "servers/visual/visual_server_raster.h" +#include "servers/rendering/rendering_device.h" +#include "servers/rendering/rendering_server_raster.h" static _FORCE_INLINE_ void store_transform(const Transform &p_mtx, float *p_array) { p_array[0] = p_mtx.basis.elements[0][0]; @@ -163,7 +163,7 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) { RasterizerSceneHighEndRD *scene_singleton = (RasterizerSceneHighEndRD *)RasterizerSceneHighEndRD::singleton; - Error err = scene_singleton->shader.compiler.compile(VS::SHADER_SPATIAL, code, &actions, path, gen_code); + Error err = scene_singleton->shader.compiler.compile(RS::SHADER_SPATIAL, code, &actions, path, gen_code); ERR_FAIL_COND(err != OK); @@ -273,9 +273,9 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) { RD::PolygonCullMode cull_mode_rd = cull_mode_rd_table[i][cull]; - for (int j = 0; j < VS::PRIMITIVE_MAX; j++) { + for (int j = 0; j < RS::PRIMITIVE_MAX; j++) { - RD::RenderPrimitive primitive_rd_table[VS::PRIMITIVE_MAX] = { + RD::RenderPrimitive primitive_rd_table[RS::PRIMITIVE_MAX] = { RD::RENDER_PRIMITIVE_POINTS, RD::RENDER_PRIMITIVE_LINES, RD::RENDER_PRIMITIVE_LINESTRIPS, @@ -321,7 +321,7 @@ void RasterizerSceneHighEndRD::ShaderData::set_code(const String &p_code) { } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL) { blend_state = blend_state_depth_normal; } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS) { - blend_state = blend_state_depth_normal; + blend_state = blend_state_depth_normal_roughness; } else if (k == SHADER_VERSION_DEPTH_PASS_WITH_MATERIAL) { blend_state = RD::PipelineColorBlendState::create_disabled(5); //writes to normal and roughness in opaque way @@ -413,7 +413,7 @@ RasterizerStorageRD::ShaderData *RasterizerSceneHighEndRD::_create_shader_func() } void RasterizerSceneHighEndRD::MaterialData::set_render_priority(int p_priority) { - priority = p_priority - VS::MATERIAL_RENDER_PRIORITY_MIN; //8 bits + priority = p_priority - RS::MATERIAL_RENDER_PRIORITY_MIN; //8 bits } void RasterizerSceneHighEndRD::MaterialData::set_next_pass(RID p_pass) { @@ -537,12 +537,20 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::ensure_specular() { specular = RD::get_singleton()->texture_create(tf, RD::TextureView()); - Vector<RID> fb; - fb.push_back(color); - fb.push_back(specular); - fb.push_back(depth); + { + Vector<RID> fb; + fb.push_back(color); + fb.push_back(specular); + fb.push_back(depth); + + color_specular_fb = RD::get_singleton()->framebuffer_create(fb); + } + { + Vector<RID> fb; + fb.push_back(specular); - color_specular_fb = RD::get_singleton()->framebuffer_create(fb); + specular_only_fb = RD::get_singleton()->framebuffer_create(fb); + } } } @@ -554,6 +562,7 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::clear() { } color_specular_fb = RID(); + specular_only_fb = RID(); color_fb = RID(); if (normal_buffer.is_valid()) { @@ -569,7 +578,7 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::clear() { } } -void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, VS::ViewportMSAA p_msaa) { +void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) { clear(); width = p_width; @@ -659,10 +668,10 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements, id.flags = 0; id.mask = e->instance->layer_mask; - if (e->instance->base_type == VS::INSTANCE_MULTIMESH) { + if (e->instance->base_type == RS::INSTANCE_MULTIMESH) { id.flags |= INSTANCE_DATA_FLAG_MULTIMESH; uint32_t stride; - if (storage->multimesh_get_transform_format(e->instance->base) == VS::MULTIMESH_TRANSFORM_2D) { + if (storage->multimesh_get_transform_format(e->instance->base) == RS::MULTIMESH_TRANSFORM_2D) { id.flags |= INSTANCE_DATA_FLAG_MULTIMESH_FORMAT_2D; stride = 2; } else { @@ -678,7 +687,7 @@ void RasterizerSceneHighEndRD::_fill_instances(RenderList::Element **p_elements, } id.flags |= (stride << INSTANCE_DATA_FLAGS_MULTIMESH_STRIDE_SHIFT); - } else if (e->instance->base_type == VS::INSTANCE_MESH) { + } else if (e->instance->base_type == RS::INSTANCE_MESH) { if (e->instance->skeleton.is_valid()) { id.flags |= INSTANCE_DATA_FLAG_SKELETON; } @@ -769,7 +778,7 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l //find cull variant ShaderData::CullVariant cull_variant; - if ((p_pass_mode == PASS_MODE_SHADOW || p_pass_mode == PASS_MODE_SHADOW_DP) && e->instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) { + if ((p_pass_mode == PASS_MODE_SHADOW || p_pass_mode == PASS_MODE_SHADOW_DP) && e->instance->cast_shadows == RS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) { cull_variant = ShaderData::CULL_VARIANT_DOUBLE_SIDED; } else { bool mirror = e->instance->mirror; @@ -780,16 +789,16 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l } //find primitive and vertex format - VS::PrimitiveType primitive; + RS::PrimitiveType primitive; switch (e->instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { primitive = storage->mesh_surface_get_primitive(e->instance->base, e->surface_index); if (e->instance->skeleton.is_valid()) { xforms_uniform_set = storage->skeleton_get_3d_uniform_set(e->instance->skeleton, default_shader_rd, TRANSFORMS_UNIFORM_SET); } } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { RID mesh = storage->multimesh_get_mesh(e->instance->base); ERR_CONTINUE(!mesh.is_valid()); //should be a bug primitive = storage->mesh_surface_get_primitive(mesh, e->surface_index); @@ -797,10 +806,10 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l xforms_uniform_set = storage->multimesh_get_3d_uniform_set(e->instance->base, default_shader_rd, TRANSFORMS_UNIFORM_SET); } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { ERR_CONTINUE(true); //should be a bug } break; - case VS::INSTANCE_PARTICLES: { + case RS::INSTANCE_PARTICLES: { ERR_CONTINUE(true); //should be a bug } break; default: { @@ -857,18 +866,18 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l RID index_array_rd; switch (e->instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { storage->mesh_surface_get_arrays_and_format(e->instance->base, e->surface_index, pipeline->get_vertex_input_mask(), vertex_array_rd, index_array_rd, vertex_format); } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { RID mesh = storage->multimesh_get_mesh(e->instance->base); ERR_CONTINUE(!mesh.is_valid()); //should be a bug storage->mesh_surface_get_arrays_and_format(mesh, e->surface_index, pipeline->get_vertex_input_mask(), vertex_array_rd, index_array_rd, vertex_format); } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { ERR_CONTINUE(true); //should be a bug } break; - case VS::INSTANCE_PARTICLES: { + case RS::INSTANCE_PARTICLES: { ERR_CONTINUE(true); //should be a bug } break; default: { @@ -915,17 +924,17 @@ void RasterizerSceneHighEndRD::_render_list(RenderingDevice::DrawListID p_draw_l RD::get_singleton()->draw_list_set_push_constant(draw_list, &push_constant, sizeof(PushConstant)); switch (e->instance->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { RD::get_singleton()->draw_list_draw(draw_list, index_array_rd.is_valid()); } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { uint32_t instances = storage->multimesh_get_instances_to_draw(e->instance->base); RD::get_singleton()->draw_list_draw(draw_list, index_array_rd.is_valid(), instances); } break; - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { } break; - case VS::INSTANCE_PARTICLES: { + case RS::INSTANCE_PARTICLES: { } break; default: { @@ -968,7 +977,7 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer //time global variables scene_state.ubo.time = time; - if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) { + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) { scene_state.ubo.use_ambient_light = true; scene_state.ubo.ambient_light_color_energy[0] = 1; @@ -981,8 +990,8 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer } else if (is_environment(p_environment)) { - VS::EnvironmentBG env_bg = environment_get_background(p_environment); - VS::EnvironmentAmbientSource ambient_src = environment_get_ambient_light_ambient_source(p_environment); + RS::EnvironmentBG env_bg = environment_get_background(p_environment); + RS::EnvironmentAmbientSource ambient_src = environment_get_ambient_light_ambient_source(p_environment); float bg_energy = environment_get_bg_energy(p_environment); scene_state.ubo.ambient_light_color_energy[3] = bg_energy; @@ -990,9 +999,9 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer scene_state.ubo.ambient_color_sky_mix = environment_get_ambient_sky_contribution(p_environment); //ambient - if (ambient_src == VS::ENV_AMBIENT_SOURCE_BG && (env_bg == VS::ENV_BG_CLEAR_COLOR || env_bg == VS::ENV_BG_COLOR)) { + if (ambient_src == RS::ENV_AMBIENT_SOURCE_BG && (env_bg == RS::ENV_BG_CLEAR_COLOR || env_bg == RS::ENV_BG_COLOR)) { - Color color = env_bg == VS::ENV_BG_CLEAR_COLOR ? p_default_bg_color : environment_get_bg_color(p_environment); + Color color = env_bg == RS::ENV_BG_CLEAR_COLOR ? p_default_bg_color : environment_get_bg_color(p_environment); color = color.to_linear(); scene_state.ubo.ambient_light_color_energy[0] = color.r * bg_energy; @@ -1013,13 +1022,13 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer sky_transform = sky_transform.inverse() * p_cam_transform.basis; store_transform_3x3(sky_transform, scene_state.ubo.radiance_inverse_xform); - scene_state.ubo.use_ambient_cubemap = (ambient_src == VS::ENV_AMBIENT_SOURCE_BG && env_bg == VS::ENV_BG_SKY) || ambient_src == VS::ENV_AMBIENT_SOURCE_SKY; - scene_state.ubo.use_ambient_light = scene_state.ubo.use_ambient_cubemap || ambient_src == VS::ENV_AMBIENT_SOURCE_COLOR; + scene_state.ubo.use_ambient_cubemap = (ambient_src == RS::ENV_AMBIENT_SOURCE_BG && env_bg == RS::ENV_BG_SKY) || ambient_src == RS::ENV_AMBIENT_SOURCE_SKY; + scene_state.ubo.use_ambient_light = scene_state.ubo.use_ambient_cubemap || ambient_src == RS::ENV_AMBIENT_SOURCE_COLOR; } //specular - VS::EnvironmentReflectionSource ref_src = environment_get_reflection_source(p_environment); - if ((ref_src == VS::ENV_REFLECTION_SOURCE_BG && env_bg == VS::ENV_BG_SKY) || ref_src == VS::ENV_REFLECTION_SOURCE_SKY) { + RS::EnvironmentReflectionSource ref_src = environment_get_reflection_source(p_environment); + if ((ref_src == RS::ENV_REFLECTION_SOURCE_BG && env_bg == RS::ENV_BG_SKY) || ref_src == RS::ENV_REFLECTION_SOURCE_SKY) { scene_state.ubo.use_reflection_cubemap = true; } else { scene_state.ubo.use_reflection_cubemap = false; @@ -1064,22 +1073,22 @@ void RasterizerSceneHighEndRD::_add_geometry(InstanceBase *p_instance, uint32_t m_src = p_instance->material_override.is_valid() ? p_instance->material_override : p_material; - if (unlikely(get_debug_draw_mode() != VS::VIEWPORT_DEBUG_DRAW_DISABLED)) { - if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { + if (unlikely(get_debug_draw_mode() != RS::VIEWPORT_DEBUG_DRAW_DISABLED)) { + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { m_src = overdraw_material; - } else if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_WIREFRAME) { + } else if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_WIREFRAME) { m_src = wireframe_material; - } else if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_LIGHTING) { + } else if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_LIGHTING) { m_src = default_material; } } - MaterialData *material = NULL; + MaterialData *material = nullptr; if (m_src.is_valid()) { material = (MaterialData *)storage->material_get_data(m_src, RasterizerStorageRD::SHADER_TYPE_3D); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -1126,7 +1135,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta if (p_pass_mode != PASS_MODE_COLOR && p_pass_mode != PASS_MODE_COLOR_SPECULAR) { - if (has_blend_alpha || has_read_screen_alpha || (has_base_alpha && !p_material->shader_data->uses_depth_pre_pass) || p_material->shader_data->depth_draw == ShaderData::DEPTH_DRAW_DISABLED || p_material->shader_data->depth_test == ShaderData::DEPTH_TEST_DISABLED || p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) { + if (has_blend_alpha || has_read_screen_alpha || (has_base_alpha && !p_material->shader_data->uses_depth_pre_pass) || p_material->shader_data->depth_draw == ShaderData::DEPTH_DRAW_DISABLED || p_material->shader_data->depth_test == ShaderData::DEPTH_TEST_DISABLED || p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_OFF) { //conditions in which no depth pass should be processed return; } @@ -1169,7 +1178,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta } e->geometry_index = p_geometry_index; e->material_index = e->material->index; - e->uses_instancing = e->instance->base_type == VS::INSTANCE_MULTIMESH; + e->uses_instancing = e->instance->base_type == RS::INSTANCE_MULTIMESH; e->uses_lightmap = e->instance->lightmap.is_valid(); e->uses_vct = e->instance->gi_probe_instances.size(); e->shader_index = e->shader_index; @@ -1177,7 +1186,7 @@ void RasterizerSceneHighEndRD::_add_geometry_with_material(InstanceBase *p_insta e->priority = p_material->priority; if (p_material->shader_data->uses_time) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } } @@ -1201,9 +1210,9 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i //add geometry for drawing switch (inst->base_type) { - case VS::INSTANCE_MESH: { + case RS::INSTANCE_MESH: { - const RID *materials = NULL; + const RID *materials = nullptr; uint32_t surface_count; materials = storage->mesh_get_surface_count_and_materials(inst->base, surface_count); @@ -1225,7 +1234,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i } break; - case VS::INSTANCE_MULTIMESH: { + case RS::INSTANCE_MULTIMESH: { if (storage->multimesh_get_instances_to_draw(inst->base) == 0) { //not visible, 0 instances @@ -1237,7 +1246,7 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i continue; } - const RID *materials = NULL; + const RID *materials = nullptr; uint32_t surface_count; materials = storage->mesh_get_surface_count_and_materials(mesh, surface_count); @@ -1253,15 +1262,15 @@ void RasterizerSceneHighEndRD::_fill_render_list(InstanceBase **p_cull_result, i } break; #if 0 - case VS::INSTANCE_IMMEDIATE: { + case RS::INSTANCE_IMMEDIATE: { RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.getornull(inst->base); ERR_CONTINUE(!immediate); - _add_geometry(immediate, inst, NULL, -1, p_depth_pass, p_shadow_pass); + _add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass); } break; - case VS::INSTANCE_PARTICLES: { + case RS::INSTANCE_PARTICLES: { RasterizerStorageGLES3::Particles *particles = storage->particles_owner.getornull(inst->base); ERR_CONTINUE(!particles); @@ -1439,10 +1448,10 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig ERR_CONTINUE(base.is_null()); - VS::LightType type = storage->light_get_type(base); + RS::LightType type = storage->light_get_type(base); switch (type) { - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { if (scene_state.ubo.directional_light_count >= scene_state.max_directional_lights) { continue; @@ -1460,14 +1469,14 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig float sign = storage->light_is_negative(base) ? -1 : 1; - light_data.energy = sign * storage->light_get_param(base, VS::LIGHT_PARAM_ENERGY) * Math_PI; + light_data.energy = sign * storage->light_get_param(base, RS::LIGHT_PARAM_ENERGY) * Math_PI; Color linear_col = storage->light_get_color(base).to_linear(); light_data.color[0] = linear_col.r; light_data.color[1] = linear_col.g; light_data.color[2] = linear_col.b; - light_data.specular = storage->light_get_param(base, VS::LIGHT_PARAM_SPECULAR); + light_data.specular = storage->light_get_param(base, RS::LIGHT_PARAM_SPECULAR); light_data.mask = storage->light_get_cull_mask(base); Color shadow_col = storage->light_get_shadow_color(base).to_linear(); @@ -1480,9 +1489,9 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig if (light_data.shadow_enabled) { - VS::LightDirectionalShadowMode smode = storage->light_directional_get_shadow_mode(base); + RS::LightDirectionalShadowMode smode = storage->light_directional_get_shadow_mode(base); - int limit = smode == VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL ? 0 : (smode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS ? 1 : 3); + int limit = smode == RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL ? 0 : (smode == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS ? 1 : 3); light_data.blend_splits = storage->light_directional_get_blend_splits(base); for (int j = 0; j < 4; j++) { Rect2 atlas_rect = light_instance_get_directional_shadow_atlas_rect(li, j); @@ -1501,7 +1510,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig store_camera(shadow_mtx, light_data.shadow_matrices[j]); } - float fade_start = storage->light_get_param(base, VS::LIGHT_PARAM_SHADOW_FADE_START); + float fade_start = storage->light_get_param(base, RS::LIGHT_PARAM_SHADOW_FADE_START); light_data.fade_from = -light_data.shadow_split_offsets[3] * MIN(fade_start, 0.999); //using 1.0 would break smoothstep light_data.fade_to = -light_data.shadow_split_offsets[3]; } @@ -1529,8 +1538,8 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig scene_state.ubo.directional_light_count++; } break; - case VS::LIGHT_SPOT: - case VS::LIGHT_OMNI: { + case RS::LIGHT_SPOT: + case RS::LIGHT_OMNI: { if (light_count >= scene_state.max_lights) { continue; @@ -1543,15 +1552,15 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig float sign = storage->light_is_negative(base) ? -1 : 1; Color linear_col = storage->light_get_color(base).to_linear(); - light_data.attenuation_energy[0] = Math::make_half_float(storage->light_get_param(base, VS::LIGHT_PARAM_ATTENUATION)); - light_data.attenuation_energy[1] = Math::make_half_float(sign * storage->light_get_param(base, VS::LIGHT_PARAM_ENERGY) * Math_PI); + light_data.attenuation_energy[0] = Math::make_half_float(storage->light_get_param(base, RS::LIGHT_PARAM_ATTENUATION)); + light_data.attenuation_energy[1] = Math::make_half_float(sign * storage->light_get_param(base, RS::LIGHT_PARAM_ENERGY) * Math_PI); light_data.color_specular[0] = MIN(uint32_t(linear_col.r * 255), 255); light_data.color_specular[1] = MIN(uint32_t(linear_col.g * 255), 255); light_data.color_specular[2] = MIN(uint32_t(linear_col.b * 255), 255); - light_data.color_specular[3] = MIN(uint32_t(storage->light_get_param(base, VS::LIGHT_PARAM_SPECULAR) * 255), 255); + light_data.color_specular[3] = MIN(uint32_t(storage->light_get_param(base, RS::LIGHT_PARAM_SPECULAR) * 255), 255); - float radius = MAX(0.001, storage->light_get_param(base, VS::LIGHT_PARAM_RANGE)); + float radius = MAX(0.001, storage->light_get_param(base, RS::LIGHT_PARAM_RANGE)); light_data.inv_radius = 1.0 / radius; Vector3 pos = p_camera_inverse_transform.xform(light_transform.origin); @@ -1566,8 +1575,8 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig light_data.direction[1] = direction.y; light_data.direction[2] = direction.z; - light_data.cone_attenuation_angle[0] = Math::make_half_float(storage->light_get_param(base, VS::LIGHT_PARAM_SPOT_ATTENUATION)); - float spot_angle = storage->light_get_param(base, VS::LIGHT_PARAM_SPOT_ANGLE); + light_data.cone_attenuation_angle[0] = Math::make_half_float(storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ATTENUATION)); + float spot_angle = storage->light_get_param(base, RS::LIGHT_PARAM_SPOT_ANGLE); light_data.cone_attenuation_angle[1] = Math::make_half_float(Math::cos(Math::deg2rad(spot_angle))); light_data.mask = storage->light_get_cull_mask(base); @@ -1590,7 +1599,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig Rect2 rect = light_instance_get_shadow_atlas_rect(li, p_shadow_atlas); - if (type == VS::LIGHT_OMNI) { + if (type == RS::LIGHT_OMNI) { light_data.atlas_rect[0] = rect.position.x; light_data.atlas_rect[1] = rect.position.y; @@ -1600,7 +1609,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig Transform proj = (p_camera_inverse_transform * light_transform).inverse(); store_transform(proj, light_data.shadow_matrix); - } else if (type == VS::LIGHT_SPOT) { + } else if (type == RS::LIGHT_SPOT) { Transform modelview = (p_camera_inverse_transform * light_transform).inverse(); CameraMatrix bias; @@ -1615,7 +1624,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig light_instance_set_index(li, light_count); - cluster_builder.add_light(type == VS::LIGHT_SPOT ? LightClusterBuilder::LIGHT_TYPE_SPOT : LightClusterBuilder::LIGHT_TYPE_OMNI, light_transform, radius, spot_angle); + cluster_builder.add_light(type == RS::LIGHT_SPOT ? LightClusterBuilder::LIGHT_TYPE_SPOT : LightClusterBuilder::LIGHT_TYPE_OMNI, light_transform, radius, spot_angle); light_count++; } break; @@ -1637,7 +1646,7 @@ void RasterizerSceneHighEndRD::_setup_lights(RID *p_light_cull_result, int p_lig void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transform &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID *p_gi_probe_cull_result, int p_gi_probe_cull_count, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, const Color &p_default_bg_color) { - RenderBufferDataHighEnd *render_buffer = NULL; + RenderBufferDataHighEnd *render_buffer = nullptr; if (p_render_buffer.is_valid()) { render_buffer = (RenderBufferDataHighEnd *)render_buffers_get_data(p_render_buffer); } @@ -1670,7 +1679,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor RENDER_TIMESTAMP("Setup 3D Scene"); - if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) { + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) { p_light_cull_count = 0; p_reflection_probe_cull_count = 0; p_gi_probe_cull_count = 0; @@ -1699,11 +1708,14 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor Size2 screen_pixel_size; Size2i screen_size; RID opaque_framebuffer; + RID opaque_specular_framebuffer; RID depth_framebuffer; RID alpha_framebuffer; PassMode depth_pass_mode = PASS_MODE_DEPTH; Vector<Color> depth_pass_clear; + bool using_separate_specular = false; + bool using_ssr = false; if (render_buffer) { screen_pixel_size.width = 1.0 / render_buffer->width; @@ -1715,12 +1727,16 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor if (p_environment.is_valid() && environment_is_ssr_enabled(p_environment)) { depth_pass_mode = PASS_MODE_DEPTH_NORMAL_ROUGHNESS; + render_buffer->ensure_specular(); + using_separate_specular = true; + using_ssr = true; + opaque_specular_framebuffer = render_buffer->color_specular_fb; } else if (screen_space_roughness_limiter_is_active()) { depth_pass_mode = PASS_MODE_DEPTH_NORMAL; //we need to allocate both these, if not allocated _allocate_normal_texture(render_buffer); _allocate_roughness_texture(render_buffer); - } else if (p_environment.is_valid() && (environment_is_ssao_enabled(p_environment) || get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER)) { + } else if (p_environment.is_valid() && (environment_is_ssao_enabled(p_environment) || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER)) { depth_pass_mode = PASS_MODE_DEPTH_NORMAL; } @@ -1785,25 +1801,25 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor Color clear_color; bool keep_color = false; - if (get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { clear_color = Color(0, 0, 0, 1); //in overdraw mode, BG should always be black } else if (is_environment(p_environment)) { - VS::EnvironmentBG bg_mode = environment_get_background(p_environment); + RS::EnvironmentBG bg_mode = environment_get_background(p_environment); float bg_energy = environment_get_bg_energy(p_environment); switch (bg_mode) { - case VS::ENV_BG_CLEAR_COLOR: { + case RS::ENV_BG_CLEAR_COLOR: { clear_color = p_default_bg_color; clear_color.r *= bg_energy; clear_color.g *= bg_energy; clear_color.b *= bg_energy; } break; - case VS::ENV_BG_COLOR: { + case RS::ENV_BG_COLOR: { clear_color = environment_get_bg_color(p_environment); clear_color.r *= bg_energy; clear_color.g *= bg_energy; clear_color.b *= bg_energy; } break; - case VS::ENV_BG_SKY: { + case RS::ENV_BG_SKY: { RID sky = environment_get_sky(p_environment); if (sky.is_valid()) { @@ -1822,13 +1838,13 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor draw_sky = true; } } break; - case VS::ENV_BG_CANVAS: { + case RS::ENV_BG_CANVAS: { keep_color = true; } break; - case VS::ENV_BG_KEEP: { + case RS::ENV_BG_KEEP: { keep_color = true; } break; - case VS::ENV_BG_CAMERA_FEED: { + case RS::ENV_BG_CAMERA_FEED: { } break; default: { @@ -1845,22 +1861,22 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor _fill_instances(render_list.elements, render_list.element_count, false); - bool can_continue = true; //unless the middle buffers are needed - bool debug_giprobes = get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO || get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING || get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION; - bool using_separate_specular = false; + bool debug_giprobes = get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_ALBEDO || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION; bool depth_pre_pass = depth_framebuffer.is_valid(); RID render_buffers_uniform_set; + bool using_ssao = depth_pre_pass && p_render_buffer.is_valid() && p_environment.is_valid() && environment_is_ssao_enabled(p_environment); + if (depth_pre_pass) { //depth pre pass RENDER_TIMESTAMP("Render Depth Pre-Pass"); - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(depth_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_CONTINUE, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_CONTINUE, depth_pass_clear); + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(depth_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, using_ssao ? RD::FINAL_ACTION_READ : RD::FINAL_ACTION_CONTINUE, depth_pass_clear); _render_list(draw_list, RD::get_singleton()->framebuffer_get_format(depth_framebuffer), render_list.elements, render_list.element_count, false, depth_pass_mode, render_buffer == nullptr, radiance_uniform_set, RID()); RD::get_singleton()->draw_list_end(); } - if (p_render_buffer.is_valid() && p_environment.is_valid() && environment_is_ssao_enabled(p_environment)) { + if (using_ssao) { _process_ssao(p_render_buffer, p_environment, render_buffer->normal_buffer, p_cam_projection); } @@ -1878,25 +1894,43 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor RENDER_TIMESTAMP("Render Opaque Pass"); + bool can_continue_color = !scene_state.used_screen_texture && !using_ssr && !scene_state.used_sss; + bool can_continue_depth = !scene_state.used_depth_texture && !using_ssr; + { - bool will_continue = (can_continue || draw_sky || debug_giprobes); + + bool will_continue_color = (can_continue_color || draw_sky || debug_giprobes); + bool will_continue_depth = (can_continue_depth || draw_sky || debug_giprobes); + //regular forward for now Vector<Color> c; c.push_back(clear_color.to_linear()); - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, keep_color ? RD::INITIAL_ACTION_KEEP : RD::INITIAL_ACTION_CLEAR, will_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, depth_pre_pass ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_CLEAR, will_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, c, 1.0, 0); - _render_list(draw_list, RD::get_singleton()->framebuffer_get_format(opaque_framebuffer), render_list.elements, render_list.element_count, false, PASS_MODE_COLOR, render_buffer == nullptr, radiance_uniform_set, render_buffers_uniform_set); + if (using_separate_specular) { + c.push_back(Color(0, 0, 0, 0)); + } + RID framebuffer = using_separate_specular ? opaque_specular_framebuffer : opaque_framebuffer; + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, keep_color ? RD::INITIAL_ACTION_KEEP : RD::INITIAL_ACTION_CLEAR, will_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, depth_pre_pass ? (using_ssao ? RD::INITIAL_ACTION_KEEP : RD::INITIAL_ACTION_CONTINUE) : RD::INITIAL_ACTION_CLEAR, will_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, c, 1.0, 0); + _render_list(draw_list, RD::get_singleton()->framebuffer_get_format(framebuffer), render_list.elements, render_list.element_count, false, using_separate_specular ? PASS_MODE_COLOR_SPECULAR : PASS_MODE_COLOR, render_buffer == nullptr, radiance_uniform_set, render_buffers_uniform_set); RD::get_singleton()->draw_list_end(); + + if (will_continue_color && using_separate_specular) { + // close the specular framebuffer, as it's no longer used + draw_list = RD::get_singleton()->draw_list_begin(render_buffer->specular_only_fb, RD::INITIAL_ACTION_CONTINUE, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, RD::FINAL_ACTION_CONTINUE); + RD::get_singleton()->draw_list_end(); + } } if (debug_giprobes) { //debug giprobes - bool will_continue = (can_continue || draw_sky); + bool will_continue_color = (can_continue_color || draw_sky); + bool will_continue_depth = (can_continue_depth || draw_sky); + CameraMatrix dc; dc.set_depth_correction(true); CameraMatrix cm = (dc * p_cam_projection) * CameraMatrix(p_cam_transform.affine_inverse()); - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, will_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, will_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(opaque_framebuffer, RD::INITIAL_ACTION_CONTINUE, will_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, will_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); for (int i = 0; i < p_gi_probe_cull_count; i++) { - _debug_giprobe(p_gi_probe_cull_result[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == VS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0); + _debug_giprobe(p_gi_probe_cull_result[i], draw_list, opaque_framebuffer, cm, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_LIGHTING, get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_GI_PROBE_EMISSION, 1.0); } RD::get_singleton()->draw_list_end(); } @@ -1911,12 +1945,24 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor projection = correction * p_cam_projection; } - _draw_sky(can_continue, opaque_framebuffer, p_environment, projection, p_cam_transform); + _draw_sky(can_continue_color, can_continue_depth, opaque_framebuffer, p_environment, projection, p_cam_transform); + } + + if (using_separate_specular) { + + if (scene_state.used_sss) { + RENDER_TIMESTAMP("Sub Surface Scattering"); - if (using_separate_specular && !can_continue) { - //can't continue, so close the buffers - //RD::get_singleton()->draw_list_begin(render_buffer->color_specular_fb, RD::INITIAL_ACTION_CONTINUE, RD::FINAL_ACTION_READ_COLOR_AND_DEPTH, c); - //RD::get_singleton()->draw_list_end(); + //_process_sss() + } + + if (using_ssr) { + RENDER_TIMESTAMP("Screen Space Reflection"); + _process_ssr(p_render_buffer, render_buffer->color_fb, render_buffer->normal_buffer, render_buffer->roughness_buffer, render_buffer->specular, render_buffer->specular, Color(0, 0, 0, 1), p_environment, p_cam_projection, true); + } else { + //just mix specular back + RENDER_TIMESTAMP("Merge Specular"); + storage->get_effects()->merge_specular(render_buffer->color_fb, render_buffer->specular, RID(), RID()); } } @@ -1929,7 +1975,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor _fill_instances(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, false); { - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(alpha_framebuffer, can_continue ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, can_continue ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ); + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(alpha_framebuffer, can_continue_color ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, can_continue_depth ? RD::INITIAL_ACTION_CONTINUE : RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ); _render_list(draw_list, RD::get_singleton()->framebuffer_get_format(alpha_framebuffer), &render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, false, PASS_MODE_COLOR, render_buffer == nullptr, radiance_uniform_set, render_buffers_uniform_set); RD::get_singleton()->draw_list_end(); } @@ -1937,13 +1983,13 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor //_render_list #if 0 if (state.directional_light_count == 0) { - directional_light = NULL; - _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, false, shadow_atlas != NULL); + directional_light = nullptr; + _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, false, shadow_atlas != nullptr); } else { for (int i = 0; i < state.directional_light_count; i++) { directional_light = directional_lights[i]; - _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL && shadow_atlas->size > 0); - _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, i > 0, shadow_atlas != NULL); + _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != nullptr && shadow_atlas->size > 0); + _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, i > 0, shadow_atlas != nullptr); } } #endif @@ -2105,18 +2151,18 @@ void RasterizerSceneHighEndRD::_update_render_base_uniform_set() { u.binding = 1; u.ids.resize(12); RID *ids_ptr = u.ids.ptrw(); - ids_ptr[0] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[1] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[2] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[3] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[4] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[5] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[6] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[7] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[8] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[9] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[10] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[11] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[0] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[1] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[2] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[3] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[4] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[5] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[6] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[7] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[8] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[9] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[10] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[11] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); uniforms.push_back(u); } @@ -2366,7 +2412,7 @@ void RasterizerSceneHighEndRD::_update_render_buffers_uniform_set(RID p_render_b } } -RasterizerSceneHighEndRD *RasterizerSceneHighEndRD::singleton = NULL; +RasterizerSceneHighEndRD *RasterizerSceneHighEndRD::singleton = nullptr; void RasterizerSceneHighEndRD::set_time(double p_time, double p_step) { time = p_time; diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h index 960b95ee86..e79bf2b378 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_high_end_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.h @@ -31,11 +31,11 @@ #ifndef RASTERIZER_SCENE_HIGHEND_RD_H #define RASTERIZER_SCENE_HIGHEND_RD_H -#include "servers/visual/rasterizer_rd/light_cluster_builder.h" -#include "servers/visual/rasterizer_rd/rasterizer_scene_rd.h" -#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h" -#include "servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h" -#include "servers/visual/rasterizer_rd/shaders/scene_high_end.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/light_cluster_builder.h" +#include "servers/rendering/rasterizer_rd/rasterizer_scene_rd.h" +#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h" +#include "servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h" +#include "servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl.gen.h" class RasterizerSceneHighEndRD : public RasterizerSceneRD { @@ -111,7 +111,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD { bool valid; RID version; uint32_t vertex_input_mask; - RenderPipelineVertexFormatCacheRD pipelines[CULL_VARIANT_MAX][VS::PRIMITIVE_MAX][SHADER_VERSION_MAX]; + RenderPipelineVertexFormatCacheRD pipelines[CULL_VARIANT_MAX][RS::PRIMITIVE_MAX][SHADER_VERSION_MAX]; String path; @@ -207,11 +207,12 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD { RID depth_normal_roughness_fb; RID color_fb; RID color_specular_fb; + RID specular_only_fb; int width, height; void ensure_specular(); void clear(); - virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, VS::ViewportMSAA p_msaa); + virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa); RID uniform_set; @@ -489,7 +490,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD { _FORCE_INLINE_ Element *add_element() { if (element_count + alpha_element_count >= max_elements) - return NULL; + return nullptr; elements[element_count] = &base_elements[element_count]; return elements[element_count++]; } @@ -497,7 +498,7 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD { _FORCE_INLINE_ Element *add_alpha_element() { if (element_count + alpha_element_count >= max_elements) - return NULL; + return nullptr; int idx = max_elements - alpha_element_count - 1; elements[idx] = &base_elements[idx]; alpha_element_count++; diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp index 395b73ca9b..af86d145ad 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp @@ -32,7 +32,7 @@ #include "core/os/os.h" #include "core/project_settings.h" -#include "servers/visual/visual_server_raster.h" +#include "servers/rendering/rendering_server_raster.h" uint64_t RasterizerSceneRD::auto_exposure_counter = 2; @@ -212,7 +212,7 @@ void RasterizerSceneRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) { } sky->radiance_size = p_radiance_size; - if (sky->mode == VS::SKY_MODE_REALTIME && sky->radiance_size != 256) { + if (sky->mode == RS::SKY_MODE_REALTIME && sky->radiance_size != 256) { WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally."); sky->radiance_size = 256; } @@ -225,7 +225,7 @@ void RasterizerSceneRD::sky_set_radiance_size(RID p_sky, int p_radiance_size) { _clear_reflection_data(sky->reflection); } -void RasterizerSceneRD::sky_set_mode(RID p_sky, VS::SkyMode p_mode) { +void RasterizerSceneRD::sky_set_mode(RID p_sky, RS::SkyMode p_mode) { Sky *sky = sky_owner.getornull(p_sky); ERR_FAIL_COND(!sky); @@ -235,7 +235,7 @@ void RasterizerSceneRD::sky_set_mode(RID p_sky, VS::SkyMode p_mode) { sky->mode = p_mode; - if (sky->mode == VS::SKY_MODE_REALTIME && sky->radiance_size != 256) { + if (sky->mode == RS::SKY_MODE_REALTIME && sky->radiance_size != 256) { WARN_PRINT("Realtime Skies can only use a radiance size of 256. Radiance size will be set to 256 internally."); sky_set_radiance_size(p_sky, 256); } @@ -267,7 +267,7 @@ void RasterizerSceneRD::_update_dirty_skys() { uint32_t w = sky->radiance_size, h = sky->radiance_size; int layers = roughness_layers; - if (sky->mode == VS::SKY_MODE_REALTIME) { + if (sky->mode == RS::SKY_MODE_REALTIME) { layers = 8; if (roughness_layers != 8) { WARN_PRINT("When using REALTIME skies, roughness_layers should be set to 8 in the project settings for best quality reflections"); @@ -287,7 +287,7 @@ void RasterizerSceneRD::_update_dirty_skys() { sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); - _update_reflection_data(sky->reflection, sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == VS::SKY_MODE_REALTIME); + _update_reflection_data(sky->reflection, sky->radiance_size, mipmaps, true, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME); } else { //regular cubemap, lower quality (aliasing, less memory) @@ -302,7 +302,7 @@ void RasterizerSceneRD::_update_dirty_skys() { sky->radiance = RD::get_singleton()->texture_create(tf, RD::TextureView()); - _update_reflection_data(sky->reflection, sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == VS::SKY_MODE_REALTIME); + _update_reflection_data(sky->reflection, sky->radiance_size, MIN(mipmaps, layers), false, sky->radiance, 0, sky->mode == RS::SKY_MODE_REALTIME); } texture_set_dirty = true; } @@ -456,7 +456,7 @@ RID RasterizerSceneRD::sky_get_material(RID p_sky) const { return sky->material; } -void RasterizerSceneRD::_draw_sky(bool p_can_continue, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform) { +void RasterizerSceneRD::_draw_sky(bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform) { ERR_FAIL_COND(!is_environment(p_environment)); @@ -465,12 +465,12 @@ void RasterizerSceneRD::_draw_sky(bool p_can_continue, RID p_fb, RID p_environme RID sky_material = sky_get_material(environment_get_sky(p_environment)); - SkyMaterialData *material = NULL; + SkyMaterialData *material = nullptr; if (sky_material.is_valid()) { material = (SkyMaterialData *)storage->material_get_data(sky_material, RasterizerStorageRD::SHADER_TYPE_SKY); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -537,7 +537,7 @@ void RasterizerSceneRD::_draw_sky(bool p_can_continue, RID p_fb, RID p_environme RID texture_uniform_set = _get_sky_textures(sky, SKY_TEXTURE_SET_BACKGROUND); - RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_fb, RD::INITIAL_ACTION_CONTINUE, p_can_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, p_can_continue ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); + RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_fb, RD::INITIAL_ACTION_CONTINUE, p_can_continue_color ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CONTINUE, p_can_continue_depth ? RD::FINAL_ACTION_CONTINUE : RD::FINAL_ACTION_READ); storage->get_effects()->render_sky(draw_list, time, p_fb, sky_scene_state.sampler_uniform_set, sky_scene_state.light_uniform_set, pipeline, material->uniform_set, texture_uniform_set, camera, sky_transform, multiplier, p_transform.origin); RD::get_singleton()->draw_list_end(); } @@ -551,12 +551,12 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position, RID sky_material = sky_get_material(environment_get_sky(p_environment)); - SkyMaterialData *material = NULL; + SkyMaterialData *material = nullptr; if (sky_material.is_valid()) { material = (SkyMaterialData *)storage->material_get_data(sky_material, RasterizerStorageRD::SHADER_TYPE_SKY); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -604,7 +604,7 @@ void RasterizerSceneRD::_setup_sky(RID p_environment, const Vector3 &p_position, sky->prev_time = time; sky->reflection.dirty = true; - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } if (material != sky->prev_material) { @@ -688,12 +688,12 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro RID sky_material = sky_get_material(environment_get_sky(p_environment)); - SkyMaterialData *material = NULL; + SkyMaterialData *material = nullptr; if (sky_material.is_valid()) { material = (SkyMaterialData *)storage->material_get_data(sky_material, RasterizerStorageRD::SHADER_TYPE_SKY); if (!material || !material->shader_data->valid) { - material = NULL; + material = nullptr; } } @@ -785,7 +785,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro RD::get_singleton()->draw_list_end(); } if (sky_use_cubemap_array) { - if (sky->mode == VS::SKY_MODE_QUALITY) { + if (sky->mode == RS::SKY_MODE_QUALITY) { for (int i = 1; i < sky->reflection.layers.size(); i++) { _create_reflection_importance_sample(sky->reflection, sky_use_cubemap_array, 10, i); } @@ -795,7 +795,7 @@ void RasterizerSceneRD::_update_sky(RID p_environment, const CameraMatrix &p_pro _update_reflection_mipmaps(sky->reflection); } else { - if (sky->mode == VS::SKY_MODE_QUALITY) { + if (sky->mode == RS::SKY_MODE_QUALITY) { for (int i = 1; i < sky->reflection.layers[0].mipmaps.size(); i++) { _create_reflection_importance_sample(sky->reflection, sky_use_cubemap_array, 10, i); } @@ -857,7 +857,7 @@ void RasterizerSceneRD::SkyShaderData::set_code(const String &p_code) { RasterizerSceneRD *scene_singleton = (RasterizerSceneRD *)RasterizerSceneRD::singleton; - Error err = scene_singleton->sky_shader.compiler.compile(VS::SHADER_SKY, code, &actions, path, gen_code); + Error err = scene_singleton->sky_shader.compiler.compile(RS::SHADER_SKY, code, &actions, path, gen_code); ERR_FAIL_COND(err != OK); @@ -1082,7 +1082,7 @@ RID RasterizerSceneRD::environment_create() { return environment_owner.make_rid(Environent()); } -void RasterizerSceneRD::environment_set_background(RID p_env, VS::EnvironmentBG p_bg) { +void RasterizerSceneRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { Environent *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->background = p_bg; @@ -1117,7 +1117,7 @@ void RasterizerSceneRD::environment_set_canvas_max_layer(RID p_env, int p_max_la ERR_FAIL_COND(!env); env->canvas_max_layer = p_max_layer; } -void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, VS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) { +void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) { Environent *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->ambient_light = p_color; @@ -1128,9 +1128,9 @@ void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_ env->ao_color = p_ao_color; } -VS::EnvironmentBG RasterizerSceneRD::environment_get_background(RID p_env) const { +RS::EnvironmentBG RasterizerSceneRD::environment_get_background(RID p_env) const { Environent *env = environment_owner.getornull(p_env); - ERR_FAIL_COND_V(!env, VS::ENV_BG_MAX); + ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX); return env->background; } RID RasterizerSceneRD::environment_get_sky(RID p_env) const { @@ -1168,9 +1168,9 @@ Color RasterizerSceneRD::environment_get_ambient_light_color(RID p_env) const { ERR_FAIL_COND_V(!env, Color()); return env->ambient_light; } -VS::EnvironmentAmbientSource RasterizerSceneRD::environment_get_ambient_light_ambient_source(RID p_env) const { +RS::EnvironmentAmbientSource RasterizerSceneRD::environment_get_ambient_light_ambient_source(RID p_env) const { Environent *env = environment_owner.getornull(p_env); - ERR_FAIL_COND_V(!env, VS::ENV_AMBIENT_SOURCE_BG); + ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG); return env->ambient_source; } float RasterizerSceneRD::environment_get_ambient_light_ambient_energy(RID p_env) const { @@ -1183,9 +1183,9 @@ float RasterizerSceneRD::environment_get_ambient_sky_contribution(RID p_env) con ERR_FAIL_COND_V(!env, 0); return env->ambient_sky_contribution; } -VS::EnvironmentReflectionSource RasterizerSceneRD::environment_get_reflection_source(RID p_env) const { +RS::EnvironmentReflectionSource RasterizerSceneRD::environment_get_reflection_source(RID p_env) const { Environent *env = environment_owner.getornull(p_env); - ERR_FAIL_COND_V(!env, VS::ENV_REFLECTION_SOURCE_DISABLED); + ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED); return env->reflection_source; } @@ -1195,7 +1195,7 @@ Color RasterizerSceneRD::environment_get_ao_color(RID p_env) const { return env->ao_color; } -void RasterizerSceneRD::environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { +void RasterizerSceneRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { Environent *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->exposure = p_exposure; @@ -1211,7 +1211,7 @@ void RasterizerSceneRD::environment_set_tonemap(RID p_env, VS::EnvironmentToneMa env->auto_exp_scale = p_auto_exp_scale; } -void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) { +void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) { Environent *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -1225,10 +1225,33 @@ void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_lev env->glow_hdr_bleed_threshold = p_hdr_bleed_threshold; env->glow_hdr_bleed_scale = p_hdr_bleed_scale; env->glow_hdr_luminance_cap = p_hdr_luminance_cap; - env->glow_bicubic_upscale = p_bicubic_upscale; } -void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) { +void RasterizerSceneRD::environment_glow_set_use_bicubic_upscale(bool p_enable) { + glow_bicubic_upscale = p_enable; +} + +void RasterizerSceneRD::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) { + + Environent *env = environment_owner.getornull(p_env); + ERR_FAIL_COND(!env); + + env->ssr_enabled = p_enable; + env->ssr_max_steps = p_max_steps; + env->ssr_fade_in = p_fade_int; + env->ssr_fade_out = p_fade_out; + env->ssr_depth_tolerance = p_depth_tolerance; +} + +void RasterizerSceneRD::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) { + ssr_roughness_quality = p_quality; +} + +RS::EnvironmentSSRRoughnessQuality RasterizerSceneRD::environment_get_ssr_roughness_quality() const { + return ssr_roughness_quality; +} + +void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) { Environent *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); @@ -1242,7 +1265,7 @@ void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_r env->ssao_blur = p_blur; } -void RasterizerSceneRD::environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size) { +void RasterizerSceneRD::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size) { ssao_quality = p_quality; ssao_half_size = p_half_size; } @@ -1269,7 +1292,7 @@ bool RasterizerSceneRD::environment_is_ssr_enabled(RID p_env) const { Environent *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); - return false; + return env->ssr_enabled; } bool RasterizerSceneRD::is_environment(RID p_env) const { @@ -1363,7 +1386,7 @@ bool RasterizerSceneRD::reflection_probe_instance_needs_redraw(RID p_instance) { return true; } - if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS) { + if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) { return true; } @@ -1387,12 +1410,12 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance); ERR_FAIL_COND_V(!rpi, false); - if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->size != 256) { + if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->size != 256) { WARN_PRINT("ReflectionProbes set to UPDATE_ALWAYS must have an atlas size of 256. Please update the atlas size in the ProjectSettings."); reflection_atlas_set_size(p_reflection_atlas, 256, atlas->count); } - if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->reflections[0].data.layers[0].mipmaps.size() != 8) { + if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS && atlas->reflection.is_valid() && atlas->reflections[0].data.layers[0].mipmaps.size() != 8) { // Invalidate reflection atlas, need to regenerate RD::get_singleton()->free(atlas->reflection); atlas->reflection = RID(); @@ -1409,7 +1432,7 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R if (atlas->reflection.is_null()) { int mipmaps = MIN(roughness_layers, Image::get_image_required_mipmaps(atlas->size, atlas->size, Image::FORMAT_RGBAH) + 1); - mipmaps = storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS ? 8 : mipmaps; // always use 8 mipmaps with real time filtering + mipmaps = storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS ? 8 : mipmaps; // always use 8 mipmaps with real time filtering { //reflection atlas was unused, create: RD::TextureFormat tf; @@ -1434,7 +1457,7 @@ bool RasterizerSceneRD::reflection_probe_instance_begin_render(RID p_instance, R } atlas->reflections.resize(atlas->count); for (int i = 0; i < atlas->count; i++) { - _update_reflection_data(atlas->reflections.write[i].data, atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS); + _update_reflection_data(atlas->reflections.write[i].data, atlas->size, mipmaps, false, atlas->reflection, i * 6, storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS); for (int j = 0; j < 6; j++) { Vector<RID> fb; fb.push_back(atlas->reflections.write[i].data.layers[0].mipmaps[0].views[j]); @@ -1493,7 +1516,7 @@ bool RasterizerSceneRD::reflection_probe_instance_postprocess_step(RID p_instanc return false; } - if (storage->reflection_probe_get_update_mode(rpi->probe) == VS::REFLECTION_PROBE_UPDATE_ALWAYS) { + if (storage->reflection_probe_get_update_mode(rpi->probe) == RS::REFLECTION_PROBE_UPDATE_ALWAYS) { // Using real time reflections, all roughness is done in one step _create_reflection_fast_filter(atlas->reflections.write[rpi->atlas_index].data, false); rpi->rendering = false; @@ -1937,10 +1960,10 @@ int RasterizerSceneRD::get_directional_light_shadow_size(RID p_light_intance) { ERR_FAIL_COND_V(!light_instance, 0); switch (storage->light_directional_get_shadow_mode(light_instance->light)) { - case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: + case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: break; //none - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: r.size.height /= 2; break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: r.size /= 2; break; + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: r.size.height /= 2; break; + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: r.size /= 2; break; } return MAX(r.size.width, r.size.height); @@ -1953,13 +1976,13 @@ RID RasterizerSceneRD::camera_effects_create() { return camera_effects_owner.make_rid(CameraEffects()); } -void RasterizerSceneRD::camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter) { +void RasterizerSceneRD::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) { dof_blur_quality = p_quality; dof_blur_use_jitter = p_use_jitter; } -void RasterizerSceneRD::camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape) { +void RasterizerSceneRD::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) { dof_blur_bokeh_shape = p_shape; } @@ -2014,7 +2037,7 @@ void RasterizerSceneRD::light_instance_set_shadow_transform(RID p_light_instance LightInstance *light_instance = light_instance_owner.getornull(p_light_instance); ERR_FAIL_COND(!light_instance); - if (storage->light_get_type(light_instance->light) != VS::LIGHT_DIRECTIONAL) { + if (storage->light_get_type(light_instance->light) != RS::LIGHT_DIRECTIONAL) { p_pass = 0; } @@ -2257,7 +2280,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc RD::Uniform u; u.type = RD::UNIFORM_TYPE_SAMPLER; u.binding = 10; - u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); uniforms.push_back(u); } @@ -2446,7 +2469,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc RD::Uniform u; u.type = RD::UNIFORM_TYPE_SAMPLER; u.binding = 10; - u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); uniforms.push_back(u); } { @@ -2516,7 +2539,7 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc RD::Uniform u; u.type = RD::UNIFORM_TYPE_SAMPLER; u.binding = 10; - u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); uniforms.push_back(u); } @@ -2589,16 +2612,16 @@ void RasterizerSceneRD::gi_probe_update(RID p_probe, bool p_update_light_instanc RID light = light_instance_get_base_light(light_instance); l.type = storage->light_get_type(light); - l.attenuation = storage->light_get_param(light, VS::LIGHT_PARAM_ATTENUATION); - l.energy = storage->light_get_param(light, VS::LIGHT_PARAM_ENERGY) * storage->light_get_param(light, VS::LIGHT_PARAM_INDIRECT_ENERGY); - l.radius = to_cell.basis.xform(Vector3(storage->light_get_param(light, VS::LIGHT_PARAM_RANGE), 0, 0)).length(); + l.attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_ATTENUATION); + l.energy = storage->light_get_param(light, RS::LIGHT_PARAM_ENERGY) * storage->light_get_param(light, RS::LIGHT_PARAM_INDIRECT_ENERGY); + l.radius = to_cell.basis.xform(Vector3(storage->light_get_param(light, RS::LIGHT_PARAM_RANGE), 0, 0)).length(); Color color = storage->light_get_color(light).to_linear(); l.color[0] = color.r; l.color[1] = color.g; l.color[2] = color.b; - l.spot_angle_radians = Math::deg2rad(storage->light_get_param(light, VS::LIGHT_PARAM_SPOT_ANGLE)); - l.spot_attenuation = storage->light_get_param(light, VS::LIGHT_PARAM_SPOT_ATTENUATION); + l.spot_angle_radians = Math::deg2rad(storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ANGLE)); + l.spot_attenuation = storage->light_get_param(light, RS::LIGHT_PARAM_SPOT_ATTENUATION); Transform xform = light_instance_get_base_transform(light_instance); @@ -2975,7 +2998,7 @@ void RasterizerSceneRD::_debug_giprobe(RID p_gi_probe, RD::DrawListID p_draw_lis RD::Uniform u; u.type = RD::UNIFORM_TYPE_SAMPLER; u.binding = 3; - u.ids.push_back(storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); + u.ids.push_back(storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED)); uniforms.push_back(u); } @@ -3164,6 +3187,74 @@ void RasterizerSceneRD::_free_render_buffer_data(RenderBuffers *rb) { rb->ssao.ao_full = RID(); rb->ssao.depth_slices.clear(); } + + if (rb->ssr.blur_radius[0].is_valid()) { + RD::get_singleton()->free(rb->ssr.blur_radius[0]); + RD::get_singleton()->free(rb->ssr.blur_radius[1]); + rb->ssr.blur_radius[0] = RID(); + rb->ssr.blur_radius[1] = RID(); + } + + if (rb->ssr.depth_scaled.is_valid()) { + RD::get_singleton()->free(rb->ssr.depth_scaled); + rb->ssr.depth_scaled = RID(); + RD::get_singleton()->free(rb->ssr.normal_scaled); + rb->ssr.normal_scaled = RID(); + } +} + +void RasterizerSceneRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_buffer, RID p_roughness_buffer, RID p_specular_buffer, RID p_metallic, const Color &p_metallic_mask, RID p_environment, const CameraMatrix &p_projection, bool p_use_additive) { + + RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); + ERR_FAIL_COND(!rb); + + bool can_use_effects = rb->width >= 8 && rb->height >= 8; + + if (!can_use_effects) { + //just copy + storage->get_effects()->merge_specular(p_dest_framebuffer, p_specular_buffer, p_use_additive ? RID() : rb->texture, RID()); + return; + } + + Environent *env = environment_owner.getornull(p_environment); + ERR_FAIL_COND(!env); + + ERR_FAIL_COND(!env->ssr_enabled); + + if (rb->ssr.depth_scaled.is_null()) { + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R32_SFLOAT; + tf.width = rb->width / 2; + tf.height = rb->height / 2; + tf.type = RD::TEXTURE_TYPE_2D; + tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT; + + rb->ssr.depth_scaled = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + tf.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; + + rb->ssr.normal_scaled = RD::get_singleton()->texture_create(tf, RD::TextureView()); + } + + if (ssr_roughness_quality != RS::ENV_SSR_ROUGNESS_QUALITY_DISABLED && !rb->ssr.blur_radius[0].is_valid()) { + RD::TextureFormat tf; + tf.format = RD::DATA_FORMAT_R8_UNORM; + tf.width = rb->width / 2; + tf.height = rb->height / 2; + tf.type = RD::TEXTURE_TYPE_2D; + tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; + + rb->ssr.blur_radius[0] = RD::get_singleton()->texture_create(tf, RD::TextureView()); + rb->ssr.blur_radius[1] = RD::get_singleton()->texture_create(tf, RD::TextureView()); + } + + if (rb->blur[0].texture.is_null()) { + _allocate_blur_textures(rb); + _render_buffers_uniform_set_changed(p_render_buffers); + } + + storage->get_effects()->screen_space_reflection(rb->texture, p_normal_buffer, ssr_roughness_quality, p_roughness_buffer, rb->ssr.blur_radius[0], rb->ssr.blur_radius[1], p_metallic, p_metallic_mask, rb->depth_texture, rb->ssr.depth_scaled, rb->ssr.normal_scaled, rb->blur[0].mipmaps[1].texture, rb->blur[1].mipmaps[0].texture, Size2i(rb->width / 2, rb->height / 2), env->ssr_max_steps, env->ssr_fade_in, env->ssr_fade_out, env->ssr_depth_tolerance, p_projection); + storage->get_effects()->merge_specular(p_dest_framebuffer, p_specular_buffer, p_use_additive ? RID() : rb->texture, rb->blur[0].mipmaps[1].texture); } void RasterizerSceneRD::_process_ssao(RID p_render_buffers, RID p_environment, RID p_normal_buffer, const CameraMatrix &p_projection) { @@ -3271,7 +3362,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu //swap final reduce with prev luminance SWAP(rb->luminance.current, rb->luminance.reduce.write[rb->luminance.reduce.size() - 1]); - VisualServerRaster::redraw_request(); //redraw all the time if auto exposure rendering is on + RenderingServerRaster::redraw_request(); //redraw all the time if auto exposure rendering is on } int max_glow_level = -1; @@ -3286,7 +3377,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu _render_buffers_uniform_set_changed(p_render_buffers); } - for (int i = 0; i < VS::MAX_GLOW_LEVELS; i++) { + for (int i = 0; i < RS::MAX_GLOW_LEVELS; i++) { if (env->glow_levels & (1 << i)) { if (i >= rb->blur[1].mipmaps.size()) { @@ -3335,11 +3426,11 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu if (can_use_effects && env && env->glow_enabled) { tonemap.use_glow = true; tonemap.glow_mode = RasterizerEffectsRD::TonemapSettings::GlowMode(env->glow_blend_mode); - tonemap.glow_intensity = env->glow_blend_mode == VS::ENV_GLOW_BLEND_MODE_MIX ? env->glow_mix : env->glow_intensity; + tonemap.glow_intensity = env->glow_blend_mode == RS::ENV_GLOW_BLEND_MODE_MIX ? env->glow_mix : env->glow_intensity; tonemap.glow_level_flags = glow_mask; tonemap.glow_texture_size.x = rb->blur[1].mipmaps[0].width; tonemap.glow_texture_size.y = rb->blur[1].mipmaps[0].height; - tonemap.glow_use_bicubic_upscale = env->glow_bicubic_upscale; + tonemap.glow_use_bicubic_upscale = glow_bicubic_upscale; tonemap.glow_texture = rb->blur[1].texture; } else { tonemap.glow_texture = storage->texture_rd_get_default(RasterizerStorageRD::DEFAULT_RD_TEXTURE_BLACK); @@ -3363,7 +3454,7 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(!rb); - if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS) { + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SHADOW_ATLAS) { if (p_shadow_atlas.is_valid()) { RID shadow_atlas_texture = shadow_atlas_get_texture(p_shadow_atlas); Size2 rtsize = storage->render_target_get_size(rb->render_target); @@ -3372,7 +3463,7 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s } } - if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS) { + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS) { if (directional_shadow_get_texture().is_valid()) { RID shadow_atlas_texture = directional_shadow_get_texture(); Size2 rtsize = storage->render_target_get_size(rb->render_target); @@ -3381,7 +3472,7 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s } } - if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE) { + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SCENE_LUMINANCE) { if (rb->luminance.current.is_valid()) { Size2 rtsize = storage->render_target_get_size(rb->render_target); @@ -3389,18 +3480,18 @@ void RasterizerSceneRD::_render_buffers_debug_draw(RID p_render_buffers, RID p_s } } - if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_SSAO && rb->ssao.ao[0].is_valid()) { + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_SSAO && rb->ssao.ao[0].is_valid()) { Size2 rtsize = storage->render_target_get_size(rb->render_target); RID ao_buf = rb->ssao.ao_full.is_valid() ? rb->ssao.ao_full : rb->ssao.ao[0]; effects->copy_to_rect(ao_buf, storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize), false, true); } - if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_ROUGHNESS_LIMITER && _render_buffers_get_roughness_texture(p_render_buffers).is_valid()) { + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_ROUGHNESS_LIMITER && _render_buffers_get_roughness_texture(p_render_buffers).is_valid()) { Size2 rtsize = storage->render_target_get_size(rb->render_target); effects->copy_to_rect(_render_buffers_get_roughness_texture(p_render_buffers), storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize), false, true); } - if (debug_draw == VS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER && _render_buffers_get_normal_texture(p_render_buffers).is_valid()) { + if (debug_draw == RS::VIEWPORT_DEBUG_DRAW_NORMAL_BUFFER && _render_buffers_get_normal_texture(p_render_buffers).is_valid()) { Size2 rtsize = storage->render_target_get_size(rb->render_target); effects->copy_to_rect(_render_buffers_get_normal_texture(p_render_buffers), storage->render_target_get_rd_framebuffer(rb->render_target), Rect2(Vector2(), rtsize)); } @@ -3423,7 +3514,7 @@ RID RasterizerSceneRD::render_buffers_get_ao_texture(RID p_render_buffers) { return rb->ssao.ao_full.is_valid() ? rb->ssao.ao_full : rb->ssao.ao[0]; } -void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa) { +void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); rb->width = p_width; @@ -3466,7 +3557,7 @@ bool RasterizerSceneRD::is_using_radiance_cubemap_array() const { RasterizerSceneRD::RenderBufferData *RasterizerSceneRD::render_buffers_get_data(RID p_render_buffers) { RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); - ERR_FAIL_COND_V(!rb, NULL); + ERR_FAIL_COND_V(!rb, nullptr); return rb->data; } @@ -3513,7 +3604,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas CameraMatrix light_projection; Transform light_transform; - if (storage->light_get_type(light_instance->light) == VS::LIGHT_DIRECTIONAL) { + if (storage->light_get_type(light_instance->light) == RS::LIGHT_DIRECTIONAL) { //set pssm stuff if (light_instance->last_scene_shadow_pass != scene_pass) { light_instance->directional_rect = _get_directional_shadow_rect(directional_shadow.size, directional_shadow.light_count, directional_shadow.current_light); @@ -3529,7 +3620,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas atlas_rect.size.width = light_instance->directional_rect.size.x; atlas_rect.size.height = light_instance->directional_rect.size.y; - if (storage->light_directional_get_shadow_mode(light_instance->light) == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { + if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { atlas_rect.size.width /= 2; atlas_rect.size.height /= 2; @@ -3543,7 +3634,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas atlas_rect.position.y += atlas_rect.size.height; } - } else if (storage->light_directional_get_shadow_mode(light_instance->light) == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { + } else if (storage->light_directional_get_shadow_mode(light_instance->light) == RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { atlas_rect.size.height /= 2; @@ -3559,10 +3650,10 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas light_instance->shadow_transform[p_pass].atlas_rect.position /= directional_shadow.size; light_instance->shadow_transform[p_pass].atlas_rect.size /= directional_shadow.size; - float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE)); - zfar = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_RANGE); - bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_BIAS) * bias_mult; - normal_bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * bias_mult; + float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE)); + zfar = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_RANGE); + bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_BIAS) * bias_mult; + normal_bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS) * bias_mult; ShadowMap *shadow_map = _get_shadow_map(atlas_rect.size); render_fb = shadow_map->fb; @@ -3596,13 +3687,13 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas atlas_rect.size.height = shadow_size; atlas_fb = shadow_atlas->fb; - zfar = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_RANGE); - bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_BIAS); - normal_bias = storage->light_get_param(light_instance->light, VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS); + zfar = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_RANGE); + bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_BIAS); + normal_bias = storage->light_get_param(light_instance->light, RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS); - if (storage->light_get_type(light_instance->light) == VS::LIGHT_OMNI) { + if (storage->light_get_type(light_instance->light) == RS::LIGHT_OMNI) { - if (storage->light_omni_get_shadow_mode(light_instance->light) == VS::LIGHT_OMNI_SHADOW_CUBE) { + if (storage->light_omni_get_shadow_mode(light_instance->light) == RS::LIGHT_OMNI_SHADOW_CUBE) { ShadowCubemap *cubemap = _get_shadow_cubemap(shadow_size / 2); @@ -3630,7 +3721,7 @@ void RasterizerSceneRD::render_shadow(RID p_light, RID p_shadow_atlas, int p_pas render_texture = shadow_map->depth; } - } else if (storage->light_get_type(light_instance->light) == VS::LIGHT_SPOT) { + } else if (storage->light_get_type(light_instance->light) == RS::LIGHT_SPOT) { light_projection = light_instance->shadow_transform[0].camera; light_transform = light_instance->shadow_transform[0].transform; @@ -3769,7 +3860,7 @@ bool RasterizerSceneRD::free(RID p_rid) { return true; } -void RasterizerSceneRD::set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw) { +void RasterizerSceneRD::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) { debug_draw = p_debug_draw; } @@ -3795,7 +3886,7 @@ float RasterizerSceneRD::screen_space_roughness_limiter_get_curve() const { return screen_space_roughness_limiter_curve; } -RasterizerSceneRD *RasterizerSceneRD::singleton = NULL; +RasterizerSceneRD *RasterizerSceneRD::singleton = nullptr; RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) { storage = p_storage; @@ -3985,29 +4076,31 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) { u.binding = 0; u.ids.resize(12); RID *ids_ptr = u.ids.ptrw(); - ids_ptr[0] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[1] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[2] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[3] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[4] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[5] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); - ids_ptr[6] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[7] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[8] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[9] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[10] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); - ids_ptr[11] = storage->sampler_rd_get_default(VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[0] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[1] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[2] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[3] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[4] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[5] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[6] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[7] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[8] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[9] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[10] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[11] = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); uniforms.push_back(u); } sky_scene_state.sampler_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_SAMPLERS); } - camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape")))); - camera_effects_set_dof_blur_quality(VS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))), GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter")); - environment_set_ssao_quality(VS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size")); + camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape")))); + camera_effects_set_dof_blur_quality(RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))), GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter")); + environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size")); screen_space_roughness_limiter = GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"); screen_space_roughness_limiter_curve = GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve"); + glow_bicubic_upscale = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0; + ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality"))); } RasterizerSceneRD::~RasterizerSceneRD() { diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h index 7332f93dc5..11a8555d22 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h @@ -32,12 +32,12 @@ #define RASTERIZER_SCENE_RD_H #include "core/rid_owner.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual/rasterizer_rd/rasterizer_storage_rd.h" -#include "servers/visual/rasterizer_rd/shaders/giprobe.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl.gen.h" -#include "servers/visual/rasterizer_rd/shaders/sky.glsl.gen.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering/rasterizer_rd/rasterizer_storage_rd.h" +#include "servers/rendering/rasterizer_rd/shaders/giprobe.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl.gen.h" +#include "servers/rendering/rasterizer_rd/shaders/sky.glsl.gen.h" +#include "servers/rendering/rendering_device.h" class RasterizerSceneRD : public RasterizerScene { public: @@ -73,7 +73,7 @@ protected: struct RenderBufferData { - virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, VS::ViewportMSAA p_msaa) = 0; + virtual void configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) = 0; virtual ~RenderBufferData() {} }; virtual RenderBufferData *_create_render_buffer_data() = 0; @@ -92,13 +92,14 @@ protected: virtual RID _render_buffers_get_normal_texture(RID p_render_buffers) = 0; void _process_ssao(RID p_render_buffers, RID p_environment, RID p_normal_buffer, const CameraMatrix &p_projection); + void _process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_buffer, RID p_roughness_buffer, RID p_specular_buffer, RID p_metallic, const Color &p_metallic_mask, RID p_environment, const CameraMatrix &p_projection, bool p_use_additive); void _setup_sky(RID p_environment, const Vector3 &p_position, const Size2i p_screen_size); void _update_sky(RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform); - void _draw_sky(bool p_can_continue, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform); + void _draw_sky(bool p_can_continue_color, bool p_can_continue_depth, RID p_fb, RID p_environment, const CameraMatrix &p_projection, const Transform &p_transform); private: - VS::ViewportDebugDraw debug_draw = VS::VIEWPORT_DEBUG_DRAW_DISABLED; + RS::ViewportDebugDraw debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; double time_step = 0; static RasterizerSceneRD *singleton; @@ -255,7 +256,7 @@ private: int radiance_size = 256; - VS::SkyMode mode = VS::SKY_MODE_QUALITY; + RS::SkyMode mode = RS::SKY_MODE_QUALITY; ReflectionData reflection; bool dirty = false; @@ -571,7 +572,7 @@ private: Rect2 atlas_rect; }; - VS::LightType light_type; + RS::LightType light_type = RS::LIGHT_DIRECTIONAL; ShadowTransform shadow_transform[4]; @@ -581,7 +582,7 @@ private: Vector3 light_vector; Vector3 spot_vector; - float linear_att; + float linear_att = 0.0; uint64_t shadow_pass = 0; uint64_t last_scene_pass = 0; @@ -590,7 +591,7 @@ private: uint32_t light_index = 0; uint32_t light_directional_index = 0; - uint32_t current_shadow_atlas_key; + uint32_t current_shadow_atlas_key = 0; Vector2 dp; @@ -608,23 +609,23 @@ private: struct Environent { // BG - VS::EnvironmentBG background = VS::ENV_BG_CLEAR_COLOR; + RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR; RID sky; float sky_custom_fov = 0.0; Basis sky_orientation; Color bg_color; float bg_energy = 1.0; int canvas_max_layer = 0; - VS::EnvironmentAmbientSource ambient_source = VS::ENV_AMBIENT_SOURCE_BG; + RS::EnvironmentAmbientSource ambient_source = RS::ENV_AMBIENT_SOURCE_BG; Color ambient_light; float ambient_light_energy = 1.0; float ambient_sky_contribution = 1.0; - VS::EnvironmentReflectionSource reflection_source = VS::ENV_REFLECTION_SOURCE_BG; + RS::EnvironmentReflectionSource reflection_source = RS::ENV_REFLECTION_SOURCE_BG; Color ao_color; /// Tonemap - VS::EnvironmentToneMapper tone_mapper; + RS::EnvironmentToneMapper tone_mapper; float exposure = 1.0; float white = 1.0; bool auto_exposure = false; @@ -642,11 +643,10 @@ private: float glow_strength = 1.0; float glow_bloom = 0.0; float glow_mix = 0.01; - VS::EnvironmentGlowBlendMode glow_blend_mode = VS::ENV_GLOW_BLEND_MODE_SOFTLIGHT; + RS::EnvironmentGlowBlendMode glow_blend_mode = RS::ENV_GLOW_BLEND_MODE_SOFTLIGHT; float glow_hdr_bleed_threshold = 1.0; float glow_hdr_luminance_cap = 12.0; float glow_hdr_bleed_scale = 2.0; - bool glow_bicubic_upscale = false; /// SSAO @@ -657,11 +657,21 @@ private: float ssao_direct_light_affect = 0.0; float ssao_ao_channel_affect = 0.0; float ssao_blur_edge_sharpness = 4.0; - VS::EnvironmentSSAOBlur ssao_blur = VS::ENV_SSAO_BLUR_3x3; + RS::EnvironmentSSAOBlur ssao_blur = RS::ENV_SSAO_BLUR_3x3; + + /// SSR + /// + bool ssr_enabled = false; + int ssr_max_steps = 64; + float ssr_fade_in = 0.15; + float ssr_fade_out = 2.0; + float ssr_depth_tolerance = 0.2; }; - VS::EnvironmentSSAOQuality ssao_quality = VS::ENV_SSAO_QUALITY_MEDIUM; + RS::EnvironmentSSAOQuality ssao_quality = RS::ENV_SSAO_QUALITY_MEDIUM; bool ssao_half_size = false; + bool glow_bicubic_upscale = false; + RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::ENV_SSR_ROUGNESS_QUALITY_LOW; static uint64_t auto_exposure_counter; @@ -685,8 +695,8 @@ private: float override_exposure = 1; }; - VS::DOFBlurQuality dof_blur_quality = VS::DOF_BLUR_QUALITY_MEDIUM; - VS::DOFBokehShape dof_blur_bokeh_shape = VS::DOF_BOKEH_HEXAGON; + RS::DOFBlurQuality dof_blur_quality = RS::DOF_BLUR_QUALITY_MEDIUM; + RS::DOFBokehShape dof_blur_bokeh_shape = RS::DOF_BOKEH_HEXAGON; bool dof_blur_use_jitter = false; mutable RID_Owner<CameraEffects> camera_effects_owner; @@ -697,7 +707,7 @@ private: RenderBufferData *data = nullptr; int width = 0, height = 0; - VS::ViewportMSAA msaa = VS::VIEWPORT_MSAA_DISABLED; + RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED; RID render_target; uint64_t auto_exposure_version = 1; @@ -733,6 +743,12 @@ private: RID ao[2]; RID ao_full; //when using half-size } ssao; + + struct SSR { + RID normal_scaled; + RID depth_scaled; + RID blur_radius[2]; + } ssr; }; bool screen_space_roughness_limiter = false; @@ -791,7 +807,7 @@ public: RID sky_create(); void sky_set_radiance_size(RID p_sky, int p_radiance_size); - void sky_set_mode(RID p_sky, VS::SkyMode p_mode); + void sky_set_mode(RID p_sky, RS::SkyMode p_mode); void sky_set_material(RID p_sky, RID p_material); RID sky_get_radiance_texture_rd(RID p_sky) const; @@ -802,16 +818,16 @@ public: RID environment_create(); - void environment_set_background(RID p_env, VS::EnvironmentBG p_bg); + void environment_set_background(RID p_env, RS::EnvironmentBG p_bg); void environment_set_sky(RID p_env, RID p_sky); void environment_set_sky_custom_fov(RID p_env, float p_scale); void environment_set_sky_orientation(RID p_env, const Basis &p_orientation); void environment_set_bg_color(RID p_env, const Color &p_color); void environment_set_bg_energy(RID p_env, float p_energy); void environment_set_canvas_max_layer(RID p_env, int p_max_layer); - void environment_set_ambient_light(RID p_env, const Color &p_color, VS::EnvironmentAmbientSource p_ambient = VS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, VS::EnvironmentReflectionSource p_reflection_source = VS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()); + void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG, const Color &p_ao_color = Color()); - VS::EnvironmentBG environment_get_background(RID p_env) const; + RS::EnvironmentBG environment_get_background(RID p_env) const; RID environment_get_sky(RID p_env) const; float environment_get_sky_custom_fov(RID p_env) const; Basis environment_get_sky_orientation(RID p_env) const; @@ -819,27 +835,31 @@ public: float environment_get_bg_energy(RID p_env) const; int environment_get_canvas_max_layer(RID p_env) const; Color environment_get_ambient_light_color(RID p_env) const; - VS::EnvironmentAmbientSource environment_get_ambient_light_ambient_source(RID p_env) const; + RS::EnvironmentAmbientSource environment_get_ambient_light_ambient_source(RID p_env) const; float environment_get_ambient_light_ambient_energy(RID p_env) const; float environment_get_ambient_sky_contribution(RID p_env) const; - VS::EnvironmentReflectionSource environment_get_reflection_source(RID p_env) const; + RS::EnvironmentReflectionSource environment_get_reflection_source(RID p_env) const; Color environment_get_ao_color(RID p_env) const; bool is_environment(RID p_env) const; - void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale); + void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap); + void environment_glow_set_use_bicubic_upscale(bool p_enable); void environment_set_fog(RID p_env, bool p_enable, float p_begin, float p_end, RID p_gradient_texture) {} - void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance, bool p_roughness) {} - void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness); - void environment_set_ssao_quality(VS::EnvironmentSSAOQuality p_quality, bool p_half_size); + void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance); + void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness); + void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size); bool environment_is_ssao_enabled(RID p_env) const; float environment_get_ssao_ao_affect(RID p_env) const; float environment_get_ssao_light_affect(RID p_env) const; bool environment_is_ssr_enabled(RID p_env) const; - void environment_set_tonemap(RID p_env, VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale); + void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality); + RS::EnvironmentSSRRoughnessQuality environment_get_ssr_roughness_quality() const; + + void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale); void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) {} void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount) {} @@ -848,8 +868,8 @@ public: virtual RID camera_effects_create(); - virtual void camera_effects_set_dof_blur_quality(VS::DOFBlurQuality p_quality, bool p_use_jitter); - virtual void camera_effects_set_dof_blur_bokeh_shape(VS::DOFBokehShape p_shape); + virtual void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter); + virtual void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape); virtual void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount); virtual void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure); @@ -940,7 +960,7 @@ public: return li->light_index; } - _FORCE_INLINE_ VS::LightType light_instance_get_type(RID p_light_instance) { + _FORCE_INLINE_ RS::LightType light_instance_get_type(RID p_light_instance) { LightInstance *li = light_instance_owner.getornull(p_light_instance); return li->light_type; } @@ -1072,7 +1092,7 @@ public: GIProbeQuality gi_probe_get_quality() const; RID render_buffers_create(); - void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, VS::ViewportMSAA p_msaa); + void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa); RID render_buffers_get_ao_texture(RID p_render_buffers); RID render_buffers_get_back_buffer_texture(RID p_render_buffers); @@ -1097,8 +1117,8 @@ public: virtual void update(); - virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw); - _FORCE_INLINE_ VS::ViewportDebugDraw get_debug_draw_mode() const { return debug_draw; } + virtual void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw); + _FORCE_INLINE_ RS::ViewportDebugDraw get_debug_draw_mode() const { return debug_draw; } virtual void set_time(double p_time, double p_step); diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp index 6e7f0aac07..322e89ef9a 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp @@ -29,9 +29,10 @@ /*************************************************************************/ #include "rasterizer_storage_rd.h" + #include "core/engine.h" #include "core/project_settings.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format) { @@ -608,7 +609,7 @@ RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) { return texture_owner.make_rid(texture); } -RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type) { +RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) { return RID(); } @@ -826,25 +827,25 @@ String RasterizerStorageRD::texture_get_path(RID p_texture) const { return String(); } -void RasterizerStorageRD::texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageRD::texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { Texture *tex = texture_owner.getornull(p_texture); ERR_FAIL_COND(!tex); tex->detect_3d_callback_ud = p_userdata; tex->detect_3d_callback = p_callback; } -void RasterizerStorageRD::texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata) { +void RasterizerStorageRD::texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata) { Texture *tex = texture_owner.getornull(p_texture); ERR_FAIL_COND(!tex); tex->detect_normal_callback_ud = p_userdata; tex->detect_normal_callback = p_callback; } -void RasterizerStorageRD::texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata) { +void RasterizerStorageRD::texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata) { Texture *tex = texture_owner.getornull(p_texture); ERR_FAIL_COND(!tex); tex->detect_roughness_callback_ud = p_userdata; tex->detect_roughness_callback = p_callback; } -void RasterizerStorageRD::texture_debug_usage(List<VS::TextureInfo> *r_info) { +void RasterizerStorageRD::texture_debug_usage(List<RS::TextureInfo> *r_info) { } void RasterizerStorageRD::texture_set_proxy(RID p_proxy, RID p_base) { @@ -861,7 +862,7 @@ Size2 RasterizerStorageRD::texture_size_with_proxy(RID p_proxy) { RID RasterizerStorageRD::shader_create() { Shader shader; - shader.data = NULL; + shader.data = nullptr; shader.type = SHADER_TYPE_MAX; return shader_owner.make_rid(shader); @@ -889,7 +890,7 @@ void RasterizerStorageRD::shader_set_code(RID p_shader, const String &p_code) { if (new_type != shader->type) { if (shader->data) { memdelete(shader->data); - shader->data = NULL; + shader->data = nullptr; } for (Set<Material *>::Element *E = shader->owners.front(); E; E = E->next()) { @@ -898,7 +899,7 @@ void RasterizerStorageRD::shader_set_code(RID p_shader, const String &p_code) { material->shader_type = new_type; if (material->data) { memdelete(material->data); - material->data = NULL; + material->data = nullptr; } } @@ -990,10 +991,10 @@ void RasterizerStorageRD::shader_set_data_request_function(ShaderType p_shader_t RID RasterizerStorageRD::material_create() { Material material; - material.data = NULL; - material.shader = NULL; + material.data = nullptr; + material.shader = nullptr; material.shader_type = SHADER_TYPE_MAX; - material.update_next = NULL; + material.update_next = nullptr; material.update_requested = false; material.uniform_dirty = false; material.texture_dirty = false; @@ -1025,12 +1026,12 @@ void RasterizerStorageRD::material_set_shader(RID p_material, RID p_shader) { if (material->data) { memdelete(material->data); - material->data = NULL; + material->data = nullptr; } if (material->shader) { material->shader->owners.erase(material); - material->shader = NULL; + material->shader = nullptr; material->shader_type = SHADER_TYPE_MAX; } @@ -1049,7 +1050,7 @@ void RasterizerStorageRD::material_set_shader(RID p_material, RID p_shader) { return; } - ERR_FAIL_COND(shader->data == NULL); + ERR_FAIL_COND(shader->data == nullptr); material->data = material_data_request_func[shader->type](shader->data); material->data->set_next_pass(material->next_pass); @@ -1664,7 +1665,7 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va RasterizerStorageRD *singleton = (RasterizerStorageRD *)RasterizerStorage::base_singleton; #ifdef TOOLS_ENABLED Texture *roughness_detect_texture = nullptr; - VS::TextureDetectRoughnessChannel roughness_channel; + RS::TextureDetectRoughnessChannel roughness_channel = RS::TEXTURE_DETECT_ROUGNHESS_R; Texture *normal_detect_texture = nullptr; #endif @@ -1727,7 +1728,7 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va if (tex->detect_roughness_callback && (p_texture_uniforms[i].hint >= ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R || p_texture_uniforms[i].hint <= ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_GRAY)) { //find the normal texture roughness_detect_texture = tex; - roughness_channel = VS::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R); + roughness_channel = RS::TextureDetectRoughnessChannel(p_texture_uniforms[i].hint - ShaderLanguage::ShaderNode::Uniform::HINT_ROUGHNESS_R); } #endif @@ -1769,10 +1770,10 @@ void RasterizerStorageRD::_update_queued_materials() { material->update_requested = false; material->texture_dirty = false; material->uniform_dirty = false; - material->update_next = NULL; + material->update_next = nullptr; material = next; } - material_update_list = NULL; + material_update_list = nullptr; } /* MESH API */ @@ -1782,7 +1783,7 @@ RID RasterizerStorageRD::mesh_create() { } /// Returns stride -void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface) { +void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -1797,67 +1798,67 @@ void RasterizerStorageRD::mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_ uint32_t stride = 0; - for (int i = 0; i < VS::ARRAY_WEIGHTS; i++) { + for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) { if ((p_surface.format & (1 << i))) { switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { - if (p_surface.format & VS::ARRAY_FLAG_USE_2D_VERTICES) { + if (p_surface.format & RS::ARRAY_FLAG_USE_2D_VERTICES) { stride += sizeof(float) * 2; } else { stride += sizeof(float) * 3; } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { - if (p_surface.format & VS::ARRAY_COMPRESS_NORMAL) { + if (p_surface.format & RS::ARRAY_COMPRESS_NORMAL) { stride += sizeof(int8_t) * 4; } else { stride += sizeof(float) * 4; } } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { - if (p_surface.format & VS::ARRAY_COMPRESS_TANGENT) { + if (p_surface.format & RS::ARRAY_COMPRESS_TANGENT) { stride += sizeof(int8_t) * 4; } else { stride += sizeof(float) * 4; } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { - if (p_surface.format & VS::ARRAY_COMPRESS_COLOR) { + if (p_surface.format & RS::ARRAY_COMPRESS_COLOR) { stride += sizeof(int8_t) * 4; } else { stride += sizeof(float) * 4; } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { - if (p_surface.format & VS::ARRAY_COMPRESS_TEX_UV) { + if (p_surface.format & RS::ARRAY_COMPRESS_TEX_UV) { stride += sizeof(int16_t) * 2; } else { stride += sizeof(float) * 2; } } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { - if (p_surface.format & VS::ARRAY_COMPRESS_TEX_UV2) { + if (p_surface.format & RS::ARRAY_COMPRESS_TEX_UV2) { stride += sizeof(int16_t) * 2; } else { stride += sizeof(float) * 2; } } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { //assumed weights too //unique format, internally 16 bits, exposed as single array for 32 @@ -1945,16 +1946,16 @@ int RasterizerStorageRD::mesh_get_blend_shape_count(RID p_mesh) const { return mesh->blend_shape_count; } -void RasterizerStorageRD::mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) { +void RasterizerStorageRD::mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); ERR_FAIL_INDEX((int)p_mode, 2); mesh->blend_shape_mode = p_mode; } -VS::BlendShapeMode RasterizerStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const { +RS::BlendShapeMode RasterizerStorageRD::mesh_get_blend_shape_mode(RID p_mesh) const { Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::BLEND_SHAPE_MODE_NORMALIZED); + ERR_FAIL_COND_V(!mesh, RS::BLEND_SHAPE_MODE_NORMALIZED); return mesh->blend_shape_mode; } @@ -1986,15 +1987,15 @@ RID RasterizerStorageRD::mesh_surface_get_material(RID p_mesh, int p_surface) co return mesh->surfaces[p_surface]->material; } -VS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const { +RS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface) const { Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::SurfaceData()); - ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, VS::SurfaceData()); + ERR_FAIL_COND_V(!mesh, RS::SurfaceData()); + ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_surface, mesh->surface_count, RS::SurfaceData()); Mesh::Surface &s = *mesh->surfaces[p_surface]; - VS::SurfaceData sd; + RS::SurfaceData sd; sd.format = s.format; sd.vertex_data = RD::get_singleton()->buffer_get_data(s.vertex_buffer); sd.vertex_count = s.vertex_count; @@ -2006,7 +2007,7 @@ VS::SurfaceData RasterizerStorageRD::mesh_get_surface(RID p_mesh, int p_surface) } sd.aabb = s.aabb; for (uint32_t i = 0; i < s.lod_count; i++) { - VS::SurfaceData::LOD lod; + RS::SurfaceData::LOD lod; lod.edge_length = s.lods[i].edge_length; lod.index_data = RD::get_singleton()->buffer_get_data(s.lods[i].index_buffer); sd.lods.push_back(lod); @@ -2058,7 +2059,7 @@ AABB RasterizerStorageRD::mesh_get_aabb(RID p_mesh, RID p_skeleton) { for (uint32_t i = 0; i < mesh->surface_count; i++) { AABB laabb; - if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->bone_aabbs.size()) { + if ((mesh->surfaces[i]->format & RS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->bone_aabbs.size()) { int bs = mesh->surfaces[i]->bone_aabbs.size(); const AABB *skbones = mesh->surfaces[i]->bone_aabbs.ptr(); @@ -2201,7 +2202,7 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su uint32_t stride = 0; - for (int i = 0; i < VS::ARRAY_WEIGHTS; i++) { + for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) { RD::VertexDescription vd; RID buffer; @@ -2212,33 +2213,33 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su buffer = mesh_default_rd_buffers[i]; switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT; } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT; } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { //assumed weights too vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT; @@ -2253,9 +2254,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { - if (s->format & VS::ARRAY_FLAG_USE_2D_VERTICES) { + if (s->format & RS::ARRAY_FLAG_USE_2D_VERTICES) { vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; stride += sizeof(float) * 2; } else { @@ -2264,9 +2265,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { - if (s->format & VS::ARRAY_COMPRESS_NORMAL) { + if (s->format & RS::ARRAY_COMPRESS_NORMAL) { vd.format = RD::DATA_FORMAT_R8G8B8A8_SNORM; stride += sizeof(int8_t) * 4; } else { @@ -2275,9 +2276,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su } } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { - if (s->format & VS::ARRAY_COMPRESS_TANGENT) { + if (s->format & RS::ARRAY_COMPRESS_TANGENT) { vd.format = RD::DATA_FORMAT_R8G8B8A8_SNORM; stride += sizeof(int8_t) * 4; } else { @@ -2286,9 +2287,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { - if (s->format & VS::ARRAY_COMPRESS_COLOR) { + if (s->format & RS::ARRAY_COMPRESS_COLOR) { vd.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; stride += sizeof(int8_t) * 4; } else { @@ -2297,9 +2298,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { - if (s->format & VS::ARRAY_COMPRESS_TEX_UV) { + if (s->format & RS::ARRAY_COMPRESS_TEX_UV) { vd.format = RD::DATA_FORMAT_R16G16_SFLOAT; stride += sizeof(int16_t) * 2; } else { @@ -2308,9 +2309,9 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su } } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { - if (s->format & VS::ARRAY_COMPRESS_TEX_UV2) { + if (s->format & RS::ARRAY_COMPRESS_TEX_UV2) { vd.format = RD::DATA_FORMAT_R16G16_SFLOAT; stride += sizeof(int16_t) * 2; } else { @@ -2319,7 +2320,7 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su } } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { //assumed weights too //unique format, internally 16 bits, exposed as single array for 32 @@ -2358,7 +2359,7 @@ RID RasterizerStorageRD::multimesh_create() { return multimesh_owner.make_rid(MultiMesh()); } -void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) { +void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors, bool p_use_custom_data) { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); @@ -2382,13 +2383,13 @@ void RasterizerStorageRD::multimesh_allocate(RID p_multimesh, int p_instances, V multimesh->instances = p_instances; multimesh->xform_format = p_transform_format; multimesh->uses_colors = p_use_colors; - multimesh->color_offset_cache = p_transform_format == VS::MULTIMESH_TRANSFORM_2D ? 8 : 12; + multimesh->color_offset_cache = p_transform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12; multimesh->uses_custom_data = p_use_custom_data; multimesh->custom_data_offset_cache = multimesh->color_offset_cache + (p_use_colors ? 4 : 0); multimesh->stride_cache = multimesh->custom_data_offset_cache + (p_use_custom_data ? 4 : 0); multimesh->buffer_set = false; - //print_line("allocate, elements: " + itos(p_instances) + " 2D: " + itos(p_transform_format == VS::MULTIMESH_TRANSFORM_2D) + " colors " + itos(multimesh->uses_colors) + " data " + itos(multimesh->uses_custom_data) + " stride " + itos(multimesh->stride_cache) + " total size " + itos(multimesh->stride_cache * multimesh->instances)); + //print_line("allocate, elements: " + itos(p_instances) + " 2D: " + itos(p_transform_format == RS::MULTIMESH_TRANSFORM_2D) + " colors " + itos(multimesh->uses_colors) + " data " + itos(multimesh->uses_custom_data) + " stride " + itos(multimesh->stride_cache) + " total size " + itos(multimesh->stride_cache * multimesh->instances)); multimesh->data_cache = Vector<float>(); multimesh->aabb = AABB(); multimesh->aabb_dirty = false; @@ -2521,7 +2522,7 @@ void RasterizerStorageRD::_multimesh_re_create_aabb(MultiMesh *multimesh, const const float *data = p_data + multimesh->stride_cache * i; Transform t; - if (multimesh->xform_format == VS::MULTIMESH_TRANSFORM_3D) { + if (multimesh->xform_format == RS::MULTIMESH_TRANSFORM_3D) { t.basis.elements[0][0] = data[0]; t.basis.elements[0][1] = data[1]; @@ -2562,7 +2563,7 @@ void RasterizerStorageRD::multimesh_instance_set_transform(RID p_multimesh, int MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->instances); - ERR_FAIL_COND(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_3D); + ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D); _multimesh_make_local(multimesh); @@ -2593,7 +2594,7 @@ void RasterizerStorageRD::multimesh_instance_set_transform_2d(RID p_multimesh, i MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->instances); - ERR_FAIL_COND(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_2D); + ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D); _multimesh_make_local(multimesh); @@ -2671,7 +2672,7 @@ Transform RasterizerStorageRD::multimesh_instance_get_transform(RID p_multimesh, MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND_V(!multimesh, Transform()); ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform()); - ERR_FAIL_COND_V(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_3D, Transform()); + ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D, Transform()); _multimesh_make_local(multimesh); @@ -2702,7 +2703,7 @@ Transform2D RasterizerStorageRD::multimesh_instance_get_transform_2d(RID p_multi MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); ERR_FAIL_COND_V(!multimesh, Transform2D()); ERR_FAIL_INDEX_V(p_index, multimesh->instances, Transform2D()); - ERR_FAIL_COND_V(multimesh->xform_format != VS::MULTIMESH_TRANSFORM_2D, Transform2D()); + ERR_FAIL_COND_V(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D, Transform2D()); _multimesh_make_local(multimesh); @@ -3094,24 +3095,24 @@ void RasterizerStorageRD::_update_dirty_skeletons() { /* LIGHT */ -RID RasterizerStorageRD::light_create(VS::LightType p_type) { +RID RasterizerStorageRD::light_create(RS::LightType p_type) { Light light; light.type = p_type; - light.param[VS::LIGHT_PARAM_ENERGY] = 1.0; - light.param[VS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0; - light.param[VS::LIGHT_PARAM_SPECULAR] = 0.5; - light.param[VS::LIGHT_PARAM_RANGE] = 1.0; - light.param[VS::LIGHT_PARAM_SPOT_ANGLE] = 45; - light.param[VS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45; - light.param[VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0; - light.param[VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1; - light.param[VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3; - light.param[VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6; - light.param[VS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8; - light.param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1; - light.param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1; + light.param[RS::LIGHT_PARAM_ENERGY] = 1.0; + light.param[RS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0; + light.param[RS::LIGHT_PARAM_SPECULAR] = 0.5; + light.param[RS::LIGHT_PARAM_RANGE] = 1.0; + light.param[RS::LIGHT_PARAM_SPOT_ANGLE] = 45; + light.param[RS::LIGHT_PARAM_CONTACT_SHADOW_SIZE] = 45; + light.param[RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE] = 0; + light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET] = 0.1; + light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3; + light.param[RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6; + light.param[RS::LIGHT_PARAM_SHADOW_FADE_START] = 0.8; + light.param[RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1; + light.param[RS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1; return light_owner.make_rid(light); } @@ -3123,21 +3124,21 @@ void RasterizerStorageRD::light_set_color(RID p_light, const Color &p_color) { light->color = p_color; } -void RasterizerStorageRD::light_set_param(RID p_light, VS::LightParam p_param, float p_value) { +void RasterizerStorageRD::light_set_param(RID p_light, RS::LightParam p_param, float p_value) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); - ERR_FAIL_INDEX(p_param, VS::LIGHT_PARAM_MAX); + ERR_FAIL_INDEX(p_param, RS::LIGHT_PARAM_MAX); switch (p_param) { - case VS::LIGHT_PARAM_RANGE: - case VS::LIGHT_PARAM_SPOT_ANGLE: - case VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE: - case VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET: - case VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET: - case VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET: - case VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS: - case VS::LIGHT_PARAM_SHADOW_BIAS: { + case RS::LIGHT_PARAM_RANGE: + case RS::LIGHT_PARAM_SPOT_ANGLE: + case RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE: + case RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET: + case RS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET: + case RS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET: + case RS::LIGHT_PARAM_SHADOW_NORMAL_BIAS: + case RS::LIGHT_PARAM_SHADOW_BIAS: { light->version++; light->instance_dependency.instance_notify_changed(true, false); @@ -3211,7 +3212,7 @@ void RasterizerStorageRD::light_set_use_gi(RID p_light, bool p_enabled) { light->version++; light->instance_dependency.instance_notify_changed(true, false); } -void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) { +void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); @@ -3222,15 +3223,15 @@ void RasterizerStorageRD::light_omni_set_shadow_mode(RID p_light, VS::LightOmniS light->instance_dependency.instance_notify_changed(true, false); } -VS::LightOmniShadowMode RasterizerStorageRD::light_omni_get_shadow_mode(RID p_light) { +RS::LightOmniShadowMode RasterizerStorageRD::light_omni_get_shadow_mode(RID p_light) { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI_SHADOW_CUBE); + ERR_FAIL_COND_V(!light, RS::LIGHT_OMNI_SHADOW_CUBE); return light->omni_shadow_mode; } -void RasterizerStorageRD::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) { +void RasterizerStorageRD::light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); @@ -3258,15 +3259,15 @@ bool RasterizerStorageRD::light_directional_get_blend_splits(RID p_light) const return light->directional_blend_splits; } -VS::LightDirectionalShadowMode RasterizerStorageRD::light_directional_get_shadow_mode(RID p_light) { +RS::LightDirectionalShadowMode RasterizerStorageRD::light_directional_get_shadow_mode(RID p_light) { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL); return light->directional_shadow_mode; } -void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode) { +void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode) { Light *light = light_owner.getornull(p_light); ERR_FAIL_COND(!light); @@ -3274,10 +3275,10 @@ void RasterizerStorageRD::light_directional_set_shadow_depth_range_mode(RID p_li light->directional_range_mode = p_range_mode; } -VS::LightDirectionalShadowDepthRangeMode RasterizerStorageRD::light_directional_get_shadow_depth_range_mode(RID p_light) const { +RS::LightDirectionalShadowDepthRangeMode RasterizerStorageRD::light_directional_get_shadow_depth_range_mode(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE); return light->directional_range_mode; } @@ -3304,18 +3305,18 @@ AABB RasterizerStorageRD::light_get_aabb(RID p_light) const { switch (light->type) { - case VS::LIGHT_SPOT: { + case RS::LIGHT_SPOT: { - float len = light->param[VS::LIGHT_PARAM_RANGE]; - float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; + float len = light->param[RS::LIGHT_PARAM_RANGE]; + float size = Math::tan(Math::deg2rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len; return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); }; - case VS::LIGHT_OMNI: { + case RS::LIGHT_OMNI: { - float r = light->param[VS::LIGHT_PARAM_RANGE]; + float r = light->param[RS::LIGHT_PARAM_RANGE]; return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); }; - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { return AABB(); }; @@ -3331,7 +3332,7 @@ RID RasterizerStorageRD::reflection_probe_create() { return reflection_probe_owner.make_rid(ReflectionProbe()); } -void RasterizerStorageRD::reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode) { +void RasterizerStorageRD::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); ERR_FAIL_COND(!reflection_probe); @@ -3450,10 +3451,10 @@ AABB RasterizerStorageRD::reflection_probe_get_aabb(RID p_probe) const { return aabb; } -VS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_mode(RID p_probe) const { +RS::ReflectionProbeUpdateMode RasterizerStorageRD::reflection_probe_get_update_mode(RID p_probe) const { const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!reflection_probe, VS::REFLECTION_PROBE_UPDATE_ALWAYS); + ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS); return reflection_probe->update_mode; } @@ -4266,25 +4267,25 @@ void RasterizerStorageRD::skeleton_update_dependency(RID p_skeleton, RasterizerS p_instance->update_dependency(&skeleton->instance_dependency); } -VS::InstanceType RasterizerStorageRD::get_base_type(RID p_rid) const { +RS::InstanceType RasterizerStorageRD::get_base_type(RID p_rid) const { if (mesh_owner.owns(p_rid)) { - return VS::INSTANCE_MESH; + return RS::INSTANCE_MESH; } if (multimesh_owner.owns(p_rid)) { - return VS::INSTANCE_MULTIMESH; + return RS::INSTANCE_MULTIMESH; } if (reflection_probe_owner.owns(p_rid)) { - return VS::INSTANCE_REFLECTION_PROBE; + return RS::INSTANCE_REFLECTION_PROBE; } if (gi_probe_owner.owns(p_rid)) { - return VS::INSTANCE_GI_PROBE; + return RS::INSTANCE_GI_PROBE; } if (light_owner.owns(p_rid)) { - return VS::INSTANCE_LIGHT; + return RS::INSTANCE_LIGHT; } - return VS::INSTANCE_NONE; + return RS::INSTANCE_NONE; } void RasterizerStorageRD::update_dirty_resources() { _update_queued_materials(); @@ -4374,7 +4375,7 @@ bool RasterizerStorageRD::free(RID p_rid) { mesh_owner.free(p_rid); } else if (multimesh_owner.owns(p_rid)) { _update_dirty_multimeshes(); - multimesh_allocate(p_rid, 0, VS::MULTIMESH_TRANSFORM_2D); + multimesh_allocate(p_rid, 0, RS::MULTIMESH_TRANSFORM_2D); MultiMesh *multimesh = multimesh_owner.getornull(p_rid); multimesh->instance_dependency.instance_notify_deleted(p_rid); multimesh_owner.free(p_rid); @@ -4452,10 +4453,10 @@ String RasterizerStorageRD::get_captured_timestamp_name(uint32_t p_index) const RasterizerStorageRD::RasterizerStorageRD() { for (int i = 0; i < SHADER_TYPE_MAX; i++) { - shader_data_request_func[i] = NULL; + shader_data_request_func[i] = nullptr; } - material_update_list = NULL; + material_update_list = nullptr; { //create default textures RD::TextureFormat tformat; @@ -4612,40 +4613,40 @@ RasterizerStorageRD::RasterizerStorageRD() { } //default samplers - for (int i = 1; i < VS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) { - for (int j = 1; j < VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) { + for (int i = 1; i < RS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) { + for (int j = 1; j < RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) { RD::SamplerState sampler_state; switch (i) { - case VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: { + case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: { sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST; sampler_state.min_filter = RD::SAMPLER_FILTER_NEAREST; sampler_state.max_lod = 0; } break; - case VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: { + case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR: { sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.max_lod = 0; } break; - case VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: { + case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: { sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST; sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; } break; - case VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: { + case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: { sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; } break; - case VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: { + case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC: { sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST; sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.use_anisotropy = true; sampler_state.anisotropy_max = GLOBAL_GET("rendering/quality/filters/max_anisotropy"); } break; - case VS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: { + case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: { sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR; sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; @@ -4657,17 +4658,17 @@ RasterizerStorageRD::RasterizerStorageRD() { } } switch (j) { - case VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: { + case RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: { sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE; sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE; } break; - case VS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: { + case RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: { sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_REPEAT; sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_REPEAT; } break; - case VS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: { + case RS::CANVAS_ITEM_TEXTURE_REPEAT_MIRROR: { sampler_state.repeat_u = RD::SAMPLER_REPEAT_MODE_MIRRORED_REPEAT; sampler_state.repeat_v = RD::SAMPLER_REPEAT_MODE_MIRRORED_REPEAT; } break; @@ -4808,8 +4809,8 @@ RasterizerStorageRD::~RasterizerStorageRD() { } //def samplers - for (int i = 1; i < VS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) { - for (int j = 1; j < VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) { + for (int i = 1; i < RS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) { + for (int j = 1; j < RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) { RD::get_singleton()->free(default_rd_samplers[i][j]); } } diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h index 410cd4adb4..49f77e49e1 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.h @@ -32,11 +32,11 @@ #define RASTERIZER_STORAGE_RD_H #include "core/rid_owner.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual/rasterizer_rd/rasterizer_effects_rd.h" -#include "servers/visual/rasterizer_rd/shader_compiler_rd.h" -#include "servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl.gen.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering/rasterizer_rd/rasterizer_effects_rd.h" +#include "servers/rendering/rasterizer_rd/shader_compiler_rd.h" +#include "servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl.gen.h" +#include "servers/rendering/rendering_device.h" class RasterizerStorageRD : public RasterizerStorage { public: @@ -138,13 +138,13 @@ private: RID proxy_to; Vector<RID> proxies; - VS::TextureDetectCallback detect_3d_callback = nullptr; + RS::TextureDetectCallback detect_3d_callback = nullptr; void *detect_3d_callback_ud = nullptr; - VS::TextureDetectCallback detect_normal_callback = nullptr; + RS::TextureDetectCallback detect_normal_callback = nullptr; void *detect_normal_callback_ud = nullptr; - VS::TextureDetectRoughnessCallback detect_roughness_callback = nullptr; + RS::TextureDetectRoughnessCallback detect_roughness_callback = nullptr; void *detect_roughness_callback_ud = nullptr; }; @@ -171,7 +171,7 @@ private: Ref<Image> _validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format); RID default_rd_textures[DEFAULT_RD_TEXTURE_MAX]; - RID default_rd_samplers[VS::CANVAS_ITEM_TEXTURE_FILTER_MAX][VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX]; + RID default_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX]; /* SHADER */ @@ -218,7 +218,7 @@ private: struct Mesh { struct Surface { - VS::PrimitiveType primitive; + RS::PrimitiveType primitive = RS::PRIMITIVE_POINTS; uint32_t format = 0; RID vertex_buffer; @@ -232,8 +232,8 @@ private: // cache-efficient structure. struct Version { - uint32_t input_mask; - RD::VertexFormatID vertex_format; + uint32_t input_mask = 0; + RD::VertexFormatID vertex_format = 0; RID vertex_array; }; @@ -246,7 +246,7 @@ private: uint32_t index_count = 0; struct LOD { - float edge_length; + float edge_length = 0.0; RID index_buffer; RID index_array; }; @@ -271,7 +271,7 @@ private: }; uint32_t blend_shape_count = 0; - VS::BlendShapeMode blend_shape_mode = VS::BLEND_SHAPE_MODE_NORMALIZED; + RS::BlendShapeMode blend_shape_mode = RS::BLEND_SHAPE_MODE_NORMALIZED; Surface **surfaces = nullptr; uint32_t surface_count = 0; @@ -296,7 +296,7 @@ private: struct MultiMesh { RID mesh; int instances = 0; - VS::MultimeshTransformFormat xform_format = VS::MULTIMESH_TRANSFORM_3D; + RS::MultimeshTransformFormat xform_format = RS::MULTIMESH_TRANSFORM_3D; bool uses_colors = false; bool uses_custom_data = false; int visible_instances = -1; @@ -359,8 +359,8 @@ private: struct Light { - VS::LightType type; - float param[VS::LIGHT_PARAM_MAX]; + RS::LightType type; + float param[RS::LIGHT_PARAM_MAX]; Color color = Color(1, 1, 1, 1); Color shadow_color; RID projector; @@ -369,9 +369,9 @@ private: bool reverse_cull = false; bool use_gi = true; uint32_t cull_mask = 0xFFFFFFFF; - VS::LightOmniShadowMode omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; - VS::LightDirectionalShadowMode directional_shadow_mode = VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; - VS::LightDirectionalShadowDepthRangeMode directional_range_mode = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; + RS::LightOmniShadowMode omni_shadow_mode = RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID; + RS::LightDirectionalShadowMode directional_shadow_mode = RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; + RS::LightDirectionalShadowDepthRangeMode directional_range_mode = RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE; bool directional_blend_splits = false; uint64_t version = 0; @@ -384,7 +384,7 @@ private: struct ReflectionProbe { - VS::ReflectionProbeUpdateMode update_mode = VS::REFLECTION_PROBE_UPDATE_ONCE; + RS::ReflectionProbeUpdateMode update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE; int resolution = 256; float intensity = 1.0; Color interior_ambient; @@ -456,9 +456,9 @@ private: RID color; //used for retrieving from CPU - RD::DataFormat color_format; - RD::DataFormat color_format_srgb; - Image::Format image_format; + RD::DataFormat color_format = RD::DATA_FORMAT_R4G4_UNORM_PACK8; + RD::DataFormat color_format_srgb = RD::DATA_FORMAT_R4G4_UNORM_PACK8; + Image::Format image_format = Image::FORMAT_L8; bool flags[RENDER_TARGET_FLAG_MAX]; @@ -498,7 +498,7 @@ public: /* TEXTURE API */ virtual RID texture_2d_create(const Ref<Image> &p_image); - virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, VS::TextureLayeredType p_layered_type); + virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type); virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices); //all slices, then all the mipmaps, must be coherent virtual RID texture_proxy_create(RID p_base); @@ -524,11 +524,11 @@ public: virtual void texture_set_path(RID p_texture, const String &p_path); virtual String texture_get_path(RID p_texture) const; - virtual void texture_set_detect_3d_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata); - virtual void texture_set_detect_normal_callback(RID p_texture, VS::TextureDetectCallback p_callback, void *p_userdata); - virtual void texture_set_detect_roughness_callback(RID p_texture, VS::TextureDetectRoughnessCallback p_callback, void *p_userdata); + virtual void texture_set_detect_3d_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_normal_callback(RID p_texture, RS::TextureDetectCallback p_callback, void *p_userdata); + virtual void texture_set_detect_roughness_callback(RID p_texture, RS::TextureDetectRoughnessCallback p_callback, void *p_userdata); - virtual void texture_debug_usage(List<VS::TextureInfo> *r_info); + virtual void texture_debug_usage(List<RS::TextureInfo> *r_info); virtual void texture_set_proxy(RID p_proxy, RID p_base); virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable); @@ -564,7 +564,7 @@ public: _FORCE_INLINE_ RID texture_rd_get_default(DefaultRDTexture p_texture) { return default_rd_textures[p_texture]; } - _FORCE_INLINE_ RID sampler_rd_get_default(VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat) { + _FORCE_INLINE_ RID sampler_rd_get_default(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) { return default_rd_samplers[p_filter][p_repeat]; } @@ -604,7 +604,7 @@ public: _FORCE_INLINE_ MaterialData *material_get_data(RID p_material, ShaderType p_shader_type) { Material *material = material_owner.getornull(p_material); if (!material || material->shader_type != p_shader_type) { - return NULL; + return nullptr; } else { return material->data; } @@ -615,19 +615,19 @@ public: virtual RID mesh_create(); /// Return stride - virtual void mesh_add_surface(RID p_mesh, const VS::SurfaceData &p_surface); + virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface); virtual int mesh_get_blend_shape_count(RID p_mesh) const; - virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode); - virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; + virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode); + virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data); virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material); virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const; - virtual VS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const; + virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const; virtual int mesh_get_surface_count(RID p_mesh) const; @@ -640,10 +640,10 @@ public: _FORCE_INLINE_ const RID *mesh_get_surface_count_and_materials(RID p_mesh, uint32_t &r_surface_count) { Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, NULL); + ERR_FAIL_COND_V(!mesh, nullptr); r_surface_count = mesh->surface_count; if (r_surface_count == 0) { - return NULL; + return nullptr; } if (mesh->material_cache.empty()) { mesh->material_cache.resize(mesh->surface_count); @@ -655,10 +655,10 @@ public: return mesh->material_cache.ptr(); } - _FORCE_INLINE_ VS::PrimitiveType mesh_surface_get_primitive(RID p_mesh, uint32_t p_surface_index) { + _FORCE_INLINE_ RS::PrimitiveType mesh_surface_get_primitive(RID p_mesh, uint32_t p_surface_index) { Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_MAX); - ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, VS::PRIMITIVE_MAX); + ERR_FAIL_COND_V(!mesh, RS::PRIMITIVE_MAX); + ERR_FAIL_UNSIGNED_INDEX_V(p_surface_index, mesh->surface_count, RS::PRIMITIVE_MAX); return mesh->surfaces[p_surface_index]->primitive; } @@ -732,7 +732,7 @@ public: RID multimesh_create(); - void multimesh_allocate(RID p_multimesh, int p_instances, VS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false); + void multimesh_allocate(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false); int multimesh_get_instance_count(RID p_multimesh) const; void multimesh_set_mesh(RID p_multimesh, RID p_mesh); @@ -756,7 +756,7 @@ public: AABB multimesh_get_aabb(RID p_multimesh) const; - _FORCE_INLINE_ VS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const { + _FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); return multimesh->xform_format; } @@ -797,7 +797,7 @@ public: /* IMMEDIATE API */ RID immediate_create() { return RID(); } - void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()) {} + void immediate_begin(RID p_immediate, RS::PrimitiveType p_rimitive, RID p_texture = RID()) {} void immediate_vertex(RID p_immediate, const Vector3 &p_vertex) {} void immediate_normal(RID p_immediate, const Vector3 &p_normal) {} void immediate_tangent(RID p_immediate, const Plane &p_tangent) {} @@ -843,14 +843,14 @@ public: } /* Light API */ - RID light_create(VS::LightType p_type); + RID light_create(RS::LightType p_type); - RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); } - RID omni_light_create() { return light_create(VS::LIGHT_OMNI); } - RID spot_light_create() { return light_create(VS::LIGHT_SPOT); } + RID directional_light_create() { return light_create(RS::LIGHT_DIRECTIONAL); } + RID omni_light_create() { return light_create(RS::LIGHT_OMNI); } + RID spot_light_create() { return light_create(RS::LIGHT_SPOT); } void light_set_color(RID p_light, const Color &p_color); - void light_set_param(RID p_light, VS::LightParam p_param, float p_value); + void light_set_param(RID p_light, RS::LightParam p_param, float p_value); void light_set_shadow(RID p_light, bool p_enabled); void light_set_shadow_color(RID p_light, const Color &p_color); void light_set_projector(RID p_light, RID p_texture); @@ -859,26 +859,26 @@ public: void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled); void light_set_use_gi(RID p_light, bool p_enabled); - void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode); + void light_omni_set_shadow_mode(RID p_light, RS::LightOmniShadowMode p_mode); - void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode); + void light_directional_set_shadow_mode(RID p_light, RS::LightDirectionalShadowMode p_mode); void light_directional_set_blend_splits(RID p_light, bool p_enable); bool light_directional_get_blend_splits(RID p_light) const; - void light_directional_set_shadow_depth_range_mode(RID p_light, VS::LightDirectionalShadowDepthRangeMode p_range_mode); - VS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const; + void light_directional_set_shadow_depth_range_mode(RID p_light, RS::LightDirectionalShadowDepthRangeMode p_range_mode); + RS::LightDirectionalShadowDepthRangeMode light_directional_get_shadow_depth_range_mode(RID p_light) const; - VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light); - VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light); + RS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light); + RS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light); - _FORCE_INLINE_ VS::LightType light_get_type(RID p_light) const { + _FORCE_INLINE_ RS::LightType light_get_type(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL); return light->type; } AABB light_get_aabb(RID p_light) const; - _FORCE_INLINE_ float light_get_param(RID p_light, VS::LightParam p_param) { + _FORCE_INLINE_ float light_get_param(RID p_light, RS::LightParam p_param) { const Light *light = light_owner.getornull(p_light); ERR_FAIL_COND_V(!light, 0); @@ -913,7 +913,7 @@ public: _FORCE_INLINE_ bool light_has_shadow(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL); return light->shadow; } @@ -921,7 +921,7 @@ public: _FORCE_INLINE_ bool light_is_negative(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL); + ERR_FAIL_COND_V(!light, RS::LIGHT_DIRECTIONAL); return light->negative; } @@ -933,7 +933,7 @@ public: RID reflection_probe_create(); - void reflection_probe_set_update_mode(RID p_probe, VS::ReflectionProbeUpdateMode p_mode); + void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode); void reflection_probe_set_intensity(RID p_probe, float p_intensity); void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient); void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy); @@ -948,7 +948,7 @@ public: void reflection_probe_set_resolution(RID p_probe, int p_resolution); AABB reflection_probe_get_aabb(RID p_probe) const; - VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; + RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; uint32_t reflection_probe_get_cull_mask(RID p_probe) const; Vector3 reflection_probe_get_extents(RID p_probe) const; Vector3 reflection_probe_get_origin_offset(RID p_probe) const; @@ -1037,7 +1037,7 @@ public: void lightmap_capture_set_energy(RID p_capture, float p_energy) {} float lightmap_capture_get_energy(RID p_capture) const { return 0.0; } const Vector<LightmapCaptureOctree> *lightmap_capture_get_octree_ptr(RID p_capture) const { - return NULL; + return nullptr; } /* PARTICLES */ @@ -1059,7 +1059,7 @@ public: void particles_set_fractional_delta(RID p_particles, bool p_enable) {} void particles_restart(RID p_particles) {} - void particles_set_draw_order(RID p_particles, VS::ParticlesDrawOrder p_order) {} + void particles_set_draw_order(RID p_particles, RS::ParticlesDrawOrder p_order) {} void particles_set_draw_passes(RID p_particles, int p_count) {} void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) {} @@ -1098,7 +1098,7 @@ public: Size2 render_target_get_size(RID p_render_target); RID render_target_get_rd_framebuffer(RID p_render_target); - VS::InstanceType get_base_type(RID p_rid) const; + RS::InstanceType get_base_type(RID p_rid) const; bool free(RID p_rid); @@ -1110,9 +1110,9 @@ public: void render_info_begin_capture() {} void render_info_end_capture() {} - int get_captured_render_info(VS::RenderInfo p_info) { return 0; } + int get_captured_render_info(RS::RenderInfo p_info) { return 0; } - int get_render_info(VS::RenderInfo p_info) { return 0; } + int get_render_info(RS::RenderInfo p_info) { return 0; } String get_video_adapter_name() const { return String(); } String get_video_adapter_vendor() const { return String(); } diff --git a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp index 4ee020aa69..2bfdb7fffe 100644 --- a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp +++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.cpp @@ -57,7 +57,7 @@ void RenderPipelineVertexFormatCacheRD::_clear() { } version_count = 0; memfree(versions); - versions = NULL; + versions = nullptr; } } @@ -88,7 +88,7 @@ void RenderPipelineVertexFormatCacheRD::clear() { RenderPipelineVertexFormatCacheRD::RenderPipelineVertexFormatCacheRD() { version_count = 0; - versions = NULL; + versions = nullptr; input_mask = 0; } diff --git a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h index 05c5968360..ecb1b42b06 100644 --- a/servers/visual/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h +++ b/servers/rendering/rasterizer_rd/render_pipeline_vertex_format_cache_rd.h @@ -32,7 +32,7 @@ #define RENDER_PIPELINE_CACHE_RD_H #include "core/spin_lock.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rendering_device.h" class RenderPipelineVertexFormatCacheRD { diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp index ecff8d81f6..4a0b4f02b1 100644 --- a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp @@ -303,7 +303,7 @@ void ShaderCompilerRD::_dump_function_deps(const SL::ShaderNode *p_node, const S _dump_function_deps(p_node, E->get(), p_func_code, r_to_add, added); - SL::FunctionNode *fnode = NULL; + SL::FunctionNode *fnode = nullptr; for (int i = 0; i < p_node->functions.size(); i++) { if (p_node->functions[i].name == E->get()) { @@ -572,7 +572,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge function = fnode; current_func_name = fnode->name; function_code[fnode->name] = _dump_node_code(fnode->body, p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning); - function = NULL; + function = nullptr; } //place functions in actual code @@ -605,7 +605,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge _dump_function_deps(pnode, fnode->name, function_code, r_gen_code.fragment_global, added_fragment); r_gen_code.light = function_code[light_name]; } - function = NULL; + function = nullptr; } //code+=dump_node_code(pnode->body,p_level); @@ -798,12 +798,12 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge else code = _mkid(anode->name); - if (anode->call_expression != NULL) { + if (anode->call_expression != nullptr) { code += "."; code += _dump_node_code(anode->call_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); } - if (anode->index_expression != NULL) { + if (anode->index_expression != nullptr) { code += "["; code += _dump_node_code(anode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "]"; @@ -1025,7 +1025,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge case SL::Node::TYPE_MEMBER: { SL::MemberNode *mnode = (SL::MemberNode *)p_node; code = _dump_node_code(mnode->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + "." + mnode->name; - if (mnode->index_expression != NULL) { + if (mnode->index_expression != nullptr) { code += "["; code += _dump_node_code(mnode->index_expression, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); code += "]"; @@ -1037,7 +1037,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge return code; } -Error ShaderCompilerRD::compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { +Error ShaderCompilerRD::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) { Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types()); @@ -1048,7 +1048,7 @@ Error ShaderCompilerRD::compile(VS::ShaderMode p_mode, const String &p_code, Ide print_line(itos(i + 1) + " " + shader[i]); } - _err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); + _err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); return err; } @@ -1066,7 +1066,7 @@ Error ShaderCompilerRD::compile(VS::ShaderMode p_mode, const String &p_code, Ide used_flag_pointers.clear(); shader = parser.get_shader(); - function = NULL; + function = nullptr; _dump_node_code(shader, 1, r_gen_code, *p_actions, actions, false); return OK; @@ -1099,145 +1099,145 @@ ShaderCompilerRD::ShaderCompilerRD() { /** SPATIAL SHADER **/ - actions[VS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform"; - actions[VS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix"; - actions[VS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix"; - actions[VS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix"; - actions[VS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "inv_projection_matrix"; - actions[VS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview"; - - actions[VS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz"; - actions[VS::SHADER_SPATIAL].renames["NORMAL"] = "normal"; - actions[VS::SHADER_SPATIAL].renames["TANGENT"] = "tangent"; - actions[VS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal"; - actions[VS::SHADER_SPATIAL].renames["POSITION"] = "position"; - actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp"; - actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp"; - actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp"; - actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize"; - actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "gl_InstanceID"; + actions[RS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform"; + actions[RS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix"; + actions[RS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix"; + actions[RS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix"; + actions[RS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "inv_projection_matrix"; + actions[RS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview"; + + actions[RS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz"; + actions[RS::SHADER_SPATIAL].renames["NORMAL"] = "normal"; + actions[RS::SHADER_SPATIAL].renames["TANGENT"] = "tangent"; + actions[RS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal"; + actions[RS::SHADER_SPATIAL].renames["POSITION"] = "position"; + actions[RS::SHADER_SPATIAL].renames["UV"] = "uv_interp"; + actions[RS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp"; + actions[RS::SHADER_SPATIAL].renames["COLOR"] = "color_interp"; + actions[RS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize"; + actions[RS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "gl_InstanceID"; //builtins - actions[VS::SHADER_SPATIAL].renames["TIME"] = "time"; - actions[VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size"; - - actions[VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord"; - actions[VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing"; - actions[VS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap"; - actions[VS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth"; - actions[VS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo"; - actions[VS::SHADER_SPATIAL].renames["ALPHA"] = "alpha"; - actions[VS::SHADER_SPATIAL].renames["METALLIC"] = "metallic"; - actions[VS::SHADER_SPATIAL].renames["SPECULAR"] = "specular"; - actions[VS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness"; - actions[VS::SHADER_SPATIAL].renames["RIM"] = "rim"; - actions[VS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint"; - actions[VS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat"; - actions[VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss"; - actions[VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy"; - actions[VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow"; - actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; - actions[VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission"; - actions[VS::SHADER_SPATIAL].renames["AO"] = "ao"; - actions[VS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect"; - actions[VS::SHADER_SPATIAL].renames["EMISSION"] = "emission"; - actions[VS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord"; - actions[VS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom"; - actions[VS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv"; - actions[VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture"; - actions[VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_buffer"; - actions[VS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth"; - actions[VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor"; - actions[VS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB"; + actions[RS::SHADER_SPATIAL].renames["TIME"] = "time"; + actions[RS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size"; + + actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord"; + actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing"; + actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap"; + actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth"; + actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo"; + actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha"; + actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic"; + actions[RS::SHADER_SPATIAL].renames["SPECULAR"] = "specular"; + actions[RS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness"; + actions[RS::SHADER_SPATIAL].renames["RIM"] = "rim"; + actions[RS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint"; + actions[RS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat"; + actions[RS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss"; + actions[RS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy"; + actions[RS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow"; + actions[RS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; + actions[RS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission"; + actions[RS::SHADER_SPATIAL].renames["AO"] = "ao"; + actions[RS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect"; + actions[RS::SHADER_SPATIAL].renames["EMISSION"] = "emission"; + actions[RS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord"; + actions[RS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom"; + actions[RS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv"; + actions[RS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture"; + actions[RS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_buffer"; + actions[RS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth"; + actions[RS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor"; + actions[RS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB"; //for light - actions[VS::SHADER_SPATIAL].renames["VIEW"] = "view"; - actions[VS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color"; - actions[VS::SHADER_SPATIAL].renames["LIGHT"] = "light"; - actions[VS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation"; - actions[VS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light"; - actions[VS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light"; - - actions[VS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT"; - actions[VS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n"; - actions[VS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM"; - actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n"; - actions[VS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT"; - actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n"; - actions[VS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY"; - actions[VS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n"; - actions[VS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n"; - actions[VS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP"; - actions[VS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n"; - actions[VS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n"; - actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n"; - - actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n"; - actions[VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; - actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; - - actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; - actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; - - actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; + actions[RS::SHADER_SPATIAL].renames["VIEW"] = "view"; + actions[RS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color"; + actions[RS::SHADER_SPATIAL].renames["LIGHT"] = "light"; + actions[RS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation"; + actions[RS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light"; + actions[RS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light"; + + actions[RS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT"; + actions[RS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n"; + actions[RS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM"; + actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n"; + actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT"; + actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n"; + actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY"; + actions[RS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n"; + actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n"; + actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP"; + actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n"; + actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n"; + actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n"; + + actions[RS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n"; + actions[RS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; + actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; + + actions[RS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[RS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + + actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley"); if (!force_lambert) { - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; } - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx"); if (!force_blinn) { - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n"; } else { - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n"; } - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; - actions[VS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; + actions[RS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; /* PARTICLES SHADER */ - actions[VS::SHADER_PARTICLES].renames["COLOR"] = "out_color"; - actions[VS::SHADER_PARTICLES].renames["VELOCITY"] = "out_velocity_active.xyz"; - actions[VS::SHADER_PARTICLES].renames["MASS"] = "mass"; - actions[VS::SHADER_PARTICLES].renames["ACTIVE"] = "shader_active"; - actions[VS::SHADER_PARTICLES].renames["RESTART"] = "restart"; - actions[VS::SHADER_PARTICLES].renames["CUSTOM"] = "out_custom"; - actions[VS::SHADER_PARTICLES].renames["TRANSFORM"] = "xform"; - actions[VS::SHADER_PARTICLES].renames["TIME"] = "time"; - actions[VS::SHADER_PARTICLES].renames["LIFETIME"] = "lifetime"; - actions[VS::SHADER_PARTICLES].renames["DELTA"] = "local_delta"; - actions[VS::SHADER_PARTICLES].renames["NUMBER"] = "particle_number"; - actions[VS::SHADER_PARTICLES].renames["INDEX"] = "index"; - actions[VS::SHADER_PARTICLES].renames["GRAVITY"] = "current_gravity"; - actions[VS::SHADER_PARTICLES].renames["EMISSION_TRANSFORM"] = "emission_transform"; - actions[VS::SHADER_PARTICLES].renames["RANDOM_SEED"] = "random_seed"; - - actions[VS::SHADER_PARTICLES].render_mode_defines["disable_force"] = "#define DISABLE_FORCE\n"; - actions[VS::SHADER_PARTICLES].render_mode_defines["disable_velocity"] = "#define DISABLE_VELOCITY\n"; - actions[VS::SHADER_PARTICLES].render_mode_defines["keep_data"] = "#define ENABLE_KEEP_DATA\n"; + actions[RS::SHADER_PARTICLES].renames["COLOR"] = "out_color"; + actions[RS::SHADER_PARTICLES].renames["VELOCITY"] = "out_velocity_active.xyz"; + actions[RS::SHADER_PARTICLES].renames["MASS"] = "mass"; + actions[RS::SHADER_PARTICLES].renames["ACTIVE"] = "shader_active"; + actions[RS::SHADER_PARTICLES].renames["RESTART"] = "restart"; + actions[RS::SHADER_PARTICLES].renames["CUSTOM"] = "out_custom"; + actions[RS::SHADER_PARTICLES].renames["TRANSFORM"] = "xform"; + actions[RS::SHADER_PARTICLES].renames["TIME"] = "time"; + actions[RS::SHADER_PARTICLES].renames["LIFETIME"] = "lifetime"; + actions[RS::SHADER_PARTICLES].renames["DELTA"] = "local_delta"; + actions[RS::SHADER_PARTICLES].renames["NUMBER"] = "particle_number"; + actions[RS::SHADER_PARTICLES].renames["INDEX"] = "index"; + actions[RS::SHADER_PARTICLES].renames["GRAVITY"] = "current_gravity"; + actions[RS::SHADER_PARTICLES].renames["EMISSION_TRANSFORM"] = "emission_transform"; + actions[RS::SHADER_PARTICLES].renames["RANDOM_SEED"] = "random_seed"; + + actions[RS::SHADER_PARTICLES].render_mode_defines["disable_force"] = "#define DISABLE_FORCE\n"; + actions[RS::SHADER_PARTICLES].render_mode_defines["disable_velocity"] = "#define DISABLE_VELOCITY\n"; + actions[RS::SHADER_PARTICLES].render_mode_defines["keep_data"] = "#define ENABLE_KEEP_DATA\n"; #endif } diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.h b/servers/rendering/rasterizer_rd/shader_compiler_rd.h index 95e1f0aa23..7d78469e9c 100644 --- a/servers/visual/rasterizer_rd/shader_compiler_rd.h +++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.h @@ -32,9 +32,9 @@ #define SHADER_COMPILER_RD_H #include "core/pair.h" -#include "servers/visual/shader_language.h" -#include "servers/visual/shader_types.h" -#include "servers/visual_server.h" +#include "servers/rendering/shader_language.h" +#include "servers/rendering/shader_types.h" +#include "servers/rendering_server.h" class ShaderCompilerRD { public: @@ -114,7 +114,7 @@ private: DefaultIdentifierActions actions; public: - Error compile(VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code); + Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code); void initialize(DefaultIdentifierActions p_actions); ShaderCompilerRD(); diff --git a/servers/visual/rasterizer_rd/shader_rd.cpp b/servers/rendering/rasterizer_rd/shader_rd.cpp index 74edaee983..d60a58813e 100644 --- a/servers/visual/rasterizer_rd/shader_rd.cpp +++ b/servers/rendering/rasterizer_rd/shader_rd.cpp @@ -32,7 +32,7 @@ #include "core/string_builder.h" #include "rasterizer_rd.h" -#include "servers/visual/rendering_device.h" +#include "servers/rendering/rendering_device.h" void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, const char *p_compute_code, const char *p_name) { @@ -191,7 +191,7 @@ RID ShaderRD::version_create() { version.dirty = true; version.valid = false; version.initialize_needed = true; - version.variants = NULL; + version.variants = nullptr; return version_owner.make_rid(version); } @@ -203,7 +203,7 @@ void ShaderRD::_clear_version(Version *p_version) { } memdelete_arr(p_version->variants); - p_version->variants = NULL; + p_version->variants = nullptr; } } @@ -394,7 +394,7 @@ void ShaderRD::_compile_version(Version *p_version) { } } memdelete_arr(p_version->variants); - p_version->variants = NULL; + p_version->variants = nullptr; return; } diff --git a/servers/visual/rasterizer_rd/shader_rd.h b/servers/rendering/rasterizer_rd/shader_rd.h index 6635b08cc8..6635b08cc8 100644 --- a/servers/visual/rasterizer_rd/shader_rd.h +++ b/servers/rendering/rasterizer_rd/shader_rd.h diff --git a/servers/rendering/rasterizer_rd/shaders/SCsub b/servers/rendering/rasterizer_rd/shaders/SCsub new file mode 100644 index 0000000000..ade0418bd2 --- /dev/null +++ b/servers/rendering/rasterizer_rd/shaders/SCsub @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +Import("env") + +if "RD_GLSL" in env["BUILDERS"]: + env.RD_GLSL("canvas.glsl") + env.RD_GLSL("canvas_occlusion.glsl") + env.RD_GLSL("blur.glsl") + env.RD_GLSL("cubemap_roughness.glsl") + env.RD_GLSL("cubemap_downsampler.glsl") + env.RD_GLSL("cubemap_filter.glsl") + env.RD_GLSL("scene_high_end.glsl") + env.RD_GLSL("sky.glsl") + env.RD_GLSL("tonemap.glsl") + env.RD_GLSL("copy.glsl") + env.RD_GLSL("giprobe.glsl") + env.RD_GLSL("giprobe_debug.glsl") + env.RD_GLSL("giprobe_sdf.glsl") + env.RD_GLSL("luminance_reduce.glsl") + env.RD_GLSL("bokeh_dof.glsl") + env.RD_GLSL("ssao.glsl") + env.RD_GLSL("ssao_minify.glsl") + env.RD_GLSL("ssao_blur.glsl") + env.RD_GLSL("roughness_limiter.glsl") + env.RD_GLSL("screen_space_reflection.glsl") + env.RD_GLSL("screen_space_reflection_filter.glsl") + env.RD_GLSL("screen_space_reflection_scale.glsl") + env.RD_GLSL("specular_merge.glsl") diff --git a/servers/visual/rasterizer_rd/shaders/blur.glsl b/servers/rendering/rasterizer_rd/shaders/blur.glsl index 87c20ebaef..87c20ebaef 100644 --- a/servers/visual/rasterizer_rd/shaders/blur.glsl +++ b/servers/rendering/rasterizer_rd/shaders/blur.glsl diff --git a/servers/visual/rasterizer_rd/shaders/blur_inc.glsl b/servers/rendering/rasterizer_rd/shaders/blur_inc.glsl index 33ba9de7bb..33ba9de7bb 100644 --- a/servers/visual/rasterizer_rd/shaders/blur_inc.glsl +++ b/servers/rendering/rasterizer_rd/shaders/blur_inc.glsl diff --git a/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl b/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl index 7153fe6b17..7153fe6b17 100644 --- a/servers/visual/rasterizer_rd/shaders/bokeh_dof.glsl +++ b/servers/rendering/rasterizer_rd/shaders/bokeh_dof.glsl diff --git a/servers/visual/rasterizer_rd/shaders/canvas.glsl b/servers/rendering/rasterizer_rd/shaders/canvas.glsl index 28135fce31..28135fce31 100644 --- a/servers/visual/rasterizer_rd/shaders/canvas.glsl +++ b/servers/rendering/rasterizer_rd/shaders/canvas.glsl diff --git a/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl b/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl index 7b30cc8fe9..7b30cc8fe9 100644 --- a/servers/visual/rasterizer_rd/shaders/canvas_occlusion.glsl +++ b/servers/rendering/rasterizer_rd/shaders/canvas_occlusion.glsl diff --git a/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl b/servers/rendering/rasterizer_rd/shaders/canvas_uniforms_inc.glsl index 1ac43480cd..1ac43480cd 100644 --- a/servers/visual/rasterizer_rd/shaders/canvas_uniforms_inc.glsl +++ b/servers/rendering/rasterizer_rd/shaders/canvas_uniforms_inc.glsl diff --git a/servers/visual/rasterizer_rd/shaders/copy.glsl b/servers/rendering/rasterizer_rd/shaders/copy.glsl index cbb9b546a3..cbb9b546a3 100644 --- a/servers/visual/rasterizer_rd/shaders/copy.glsl +++ b/servers/rendering/rasterizer_rd/shaders/copy.glsl diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl index 9f3ecf6053..9f3ecf6053 100644 --- a/servers/visual/rasterizer_rd/shaders/cubemap_downsampler.glsl +++ b/servers/rendering/rasterizer_rd/shaders/cubemap_downsampler.glsl diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl index 193d0a8a3c..193d0a8a3c 100644 --- a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl +++ b/servers/rendering/rasterizer_rd/shaders/cubemap_filter.glsl diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl b/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl index e85996fa1a..e85996fa1a 100644 --- a/servers/visual/rasterizer_rd/shaders/cubemap_roughness.glsl +++ b/servers/rendering/rasterizer_rd/shaders/cubemap_roughness.glsl diff --git a/servers/visual/rasterizer_rd/shaders/giprobe.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe.glsl index fd09f96a57..fd09f96a57 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe.glsl +++ b/servers/rendering/rasterizer_rd/shaders/giprobe.glsl diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl index b1784e7eee..b1784e7eee 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe_debug.glsl +++ b/servers/rendering/rasterizer_rd/shaders/giprobe_debug.glsl diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl index d089236723..d089236723 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe_sdf.glsl +++ b/servers/rendering/rasterizer_rd/shaders/giprobe_sdf.glsl diff --git a/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl b/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl index c832223b1e..c832223b1e 100644 --- a/servers/visual/rasterizer_rd/shaders/giprobe_write.glsl +++ b/servers/rendering/rasterizer_rd/shaders/giprobe_write.glsl diff --git a/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl b/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl index 4bf5b7e7f1..4bf5b7e7f1 100644 --- a/servers/visual/rasterizer_rd/shaders/luminance_reduce.glsl +++ b/servers/rendering/rasterizer_rd/shaders/luminance_reduce.glsl diff --git a/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl b/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl index 3637b1abb2..3637b1abb2 100644 --- a/servers/visual/rasterizer_rd/shaders/roughness_limiter.glsl +++ b/servers/rendering/rasterizer_rd/shaders/roughness_limiter.glsl diff --git a/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl index 07f4770b14..07f4770b14 100644 --- a/servers/visual/rasterizer_rd/shaders/scene_high_end.glsl +++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl diff --git a/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl index baef1e060f..baef1e060f 100644 --- a/servers/visual/rasterizer_rd/shaders/scene_high_end_inc.glsl +++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end_inc.glsl diff --git a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl new file mode 100644 index 0000000000..e3c26c9b72 --- /dev/null +++ b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection.glsl @@ -0,0 +1,262 @@ +/* clang-format off */ +[compute] + +#version 450 + +VERSION_DEFINES + + + +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +/* clang-format on */ + +layout(rgba16f, set = 0, binding = 0) uniform restrict readonly image2D source_diffuse; +layout(r32f, set = 0, binding = 1) uniform restrict readonly image2D source_depth; +layout(rgba16f, set = 1, binding = 0) uniform restrict writeonly image2D ssr_image; +#ifdef MODE_ROUGH +layout(r8, set = 1, binding = 1) uniform restrict writeonly image2D blur_radius_image; +#endif +layout(rgba8, set = 2, binding = 0) uniform restrict readonly image2D source_normal; +layout(set = 3, binding = 0) uniform sampler2D source_metallic; +#ifdef MODE_ROUGH +layout(set = 3, binding = 1) uniform sampler2D source_roughness; +#endif + +layout(push_constant, binding = 2, std430) uniform Params { + + vec4 proj_info; + + ivec2 screen_size; + float camera_z_near; + float camera_z_far; + + int num_steps; + float depth_tolerance; + float distance_fade; + float curve_fade_in; + + bool orthogonal; + float filter_mipmap_levels; + bool use_half_res; + uint metallic_mask; + + mat4 projection; +} +params; + +vec2 view_to_screen(vec3 view_pos, out float w) { + vec4 projected = params.projection * vec4(view_pos, 1.0); + projected.xyz /= projected.w; + projected.xy = projected.xy * 0.5 + 0.5; + w = projected.w; + return projected.xy; +} + +#define M_PI 3.14159265359 + +vec3 reconstructCSPosition(vec2 S, float z) { + if (params.orthogonal) { + return vec3((S.xy * params.proj_info.xy + params.proj_info.zw), z); + } else { + return vec3((S.xy * params.proj_info.xy + params.proj_info.zw) * z, z); + } +} + +void main() { + + // Pixel being shaded + ivec2 ssC = ivec2(gl_GlobalInvocationID.xy); + + if (any(greaterThan(ssC, params.screen_size))) { //too large, do nothing + return; + } + + vec2 pixel_size = 1.0 / vec2(params.screen_size); + vec2 uv = vec2(ssC) * pixel_size; + + uv += pixel_size * 0.5; + + float base_depth = imageLoad(source_depth, ssC).r; + + // World space point being shaded + vec3 vertex = reconstructCSPosition(uv * vec2(params.screen_size), base_depth); + + vec3 normal = imageLoad(source_normal, ssC).xyz * 2.0 - 1.0; + normal = normalize(normal); + normal.y = -normal.y; //because this code reads flipped + + vec3 view_dir = normalize(vertex); + vec3 ray_dir = normalize(reflect(view_dir, normal)); + + if (dot(ray_dir, normal) < 0.001) { + imageStore(ssr_image, ssC, vec4(0.0)); + return; + } + //ray_dir = normalize(view_dir - normal * dot(normal,view_dir) * 2.0); + //ray_dir = normalize(vec3(1.0, 1.0, -1.0)); + + //////////////// + + // make ray length and clip it against the near plane (don't want to trace beyond visible) + float ray_len = (vertex.z + ray_dir.z * params.camera_z_far) > -params.camera_z_near ? (-params.camera_z_near - vertex.z) / ray_dir.z : params.camera_z_far; + vec3 ray_end = vertex + ray_dir * ray_len; + + float w_begin; + vec2 vp_line_begin = view_to_screen(vertex, w_begin); + float w_end; + vec2 vp_line_end = view_to_screen(ray_end, w_end); + vec2 vp_line_dir = vp_line_end - vp_line_begin; + + // we need to interpolate w along the ray, to generate perspective correct reflections + w_begin = 1.0 / w_begin; + w_end = 1.0 / w_end; + + float z_begin = vertex.z * w_begin; + float z_end = ray_end.z * w_end; + + vec2 line_begin = vp_line_begin / pixel_size; + vec2 line_dir = vp_line_dir / pixel_size; + float z_dir = z_end - z_begin; + float w_dir = w_end - w_begin; + + // clip the line to the viewport edges + + float scale_max_x = min(1.0, 0.99 * (1.0 - vp_line_begin.x) / max(1e-5, vp_line_dir.x)); + float scale_max_y = min(1.0, 0.99 * (1.0 - vp_line_begin.y) / max(1e-5, vp_line_dir.y)); + float scale_min_x = min(1.0, 0.99 * vp_line_begin.x / max(1e-5, -vp_line_dir.x)); + float scale_min_y = min(1.0, 0.99 * vp_line_begin.y / max(1e-5, -vp_line_dir.y)); + float line_clip = min(scale_max_x, scale_max_y) * min(scale_min_x, scale_min_y); + line_dir *= line_clip; + z_dir *= line_clip; + w_dir *= line_clip; + + // clip z and w advance to line advance + vec2 line_advance = normalize(line_dir); // down to pixel + float step_size = length(line_advance) / length(line_dir); + float z_advance = z_dir * step_size; // adapt z advance to line advance + float w_advance = w_dir * step_size; // adapt w advance to line advance + + // make line advance faster if direction is closer to pixel edges (this avoids sampling the same pixel twice) + float advance_angle_adj = 1.0 / max(abs(line_advance.x), abs(line_advance.y)); + line_advance *= advance_angle_adj; // adapt z advance to line advance + z_advance *= advance_angle_adj; + w_advance *= advance_angle_adj; + + vec2 pos = line_begin; + float z = z_begin; + float w = w_begin; + float z_from = z / w; + float z_to = z_from; + float depth; + vec2 prev_pos = pos; + + bool found = false; + + float steps_taken = 0.0; + + for (int i = 0; i < params.num_steps; i++) { + + pos += line_advance; + z += z_advance; + w += w_advance; + + // convert to linear depth + + depth = imageLoad(source_depth, ivec2(pos - 0.5)).r; + + if (-depth >= params.camera_z_far) { //went beyond camera + break; + } + + z_from = z_to; + z_to = z / w; + + if (depth > z_to) { + // if depth was surpassed + if (depth <= max(z_to, z_from) + params.depth_tolerance) { + // check the depth tolerance + //check that normal is valid + found = true; + } + break; + } + + steps_taken += 1.0; + prev_pos = pos; + } + + if (found) { + + float margin_blend = 1.0; + + vec2 margin = vec2((params.screen_size.x + params.screen_size.y) * 0.5 * 0.05); // make a uniform margin + if (any(bvec4(lessThan(pos, -margin), greaterThan(pos, params.screen_size + margin)))) { + // clip outside screen + margin + imageStore(ssr_image, ssC, vec4(0.0)); + return; + } + + { + //blend fading out towards external margin + vec2 margin_grad = mix(pos - params.screen_size, -pos, lessThan(pos, vec2(0.0))); + margin_blend = 1.0 - smoothstep(0.0, margin.x, max(margin_grad.x, margin_grad.y)); + //margin_blend = 1.0; + } + + vec2 final_pos; + float grad; + grad = steps_taken / float(params.num_steps); + float initial_fade = params.curve_fade_in == 0.0 ? 1.0 : pow(clamp(grad, 0.0, 1.0), params.curve_fade_in); + float fade = pow(clamp(1.0 - grad, 0.0, 1.0), params.distance_fade) * initial_fade; + final_pos = pos; + + vec4 final_color; + +#ifdef MODE_ROUGH + + // if roughness is enabled, do screen space cone tracing + float blur_radius = 0.0; + float roughness = texelFetch(source_roughness, ssC << 1, 0).r; + + if (roughness > 0.001) { + + float cone_angle = min(roughness, 0.999) * M_PI * 0.5; + float cone_len = length(final_pos - line_begin); + float op_len = 2.0 * tan(cone_angle) * cone_len; // opposite side of iso triangle + { + // fit to sphere inside cone (sphere ends at end of cone), something like this: + // ___ + // \O/ + // V + // + // as it avoids bleeding from beyond the reflection as much as possible. As a plus + // it also makes the rough reflection more elongated. + float a = op_len; + float h = cone_len; + float a2 = a * a; + float fh2 = 4.0f * h * h; + blur_radius = (a * (sqrt(a2 + fh2) - a)) / (4.0f * h); + } + } + + final_color = imageLoad(source_diffuse, ivec2((final_pos - 0.5) * pixel_size)); + + imageStore(blur_radius_image, ssC, vec4(blur_radius / 255.0)); //stored in r8 + +#endif + + final_color = vec4(imageLoad(source_diffuse, ivec2(final_pos - 0.5)).rgb, fade * margin_blend); + //change blend by metallic + vec4 metallic_mask = unpackUnorm4x8(params.metallic_mask); + final_color.a *= dot(metallic_mask, texelFetch(source_metallic, ssC << 1, 0)); + + imageStore(ssr_image, ssC, final_color); + + } else { +#ifdef MODE_ROUGH + imageStore(blur_radius_image, ssC, vec4(0.0)); +#endif + imageStore(ssr_image, ssC, vec4(0.0)); + } +} diff --git a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl new file mode 100644 index 0000000000..671e289ed0 --- /dev/null +++ b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_filter.glsl @@ -0,0 +1,169 @@ +/* clang-format off */ +[compute] + +#version 450 + +VERSION_DEFINES + + + +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +/* clang-format on */ + +layout(rgba16f, set = 0, binding = 0) uniform restrict readonly image2D source_ssr; +layout(r8, set = 0, binding = 1) uniform restrict readonly image2D source_radius; +layout(rgba8, set = 1, binding = 0) uniform restrict readonly image2D source_normal; + +layout(rgba16f, set = 2, binding = 0) uniform restrict writeonly image2D dest_ssr; +#ifndef VERTICAL_PASS +layout(r8, set = 2, binding = 1) uniform restrict writeonly image2D dest_radius; +#endif +layout(r32f, set = 3, binding = 0) uniform restrict readonly image2D source_depth; + +layout(push_constant, binding = 2, std430) uniform Params { + + vec4 proj_info; + + bool orthogonal; + float edge_tolerance; + int increment; + uint pad; + + ivec2 screen_size; + bool vertical; + uint steps; +} +params; + +#define GAUSS_TABLE_SIZE 15 + +const float gauss_table[GAUSS_TABLE_SIZE + 1] = float[]( + 0.1847392078702266, + 0.16595854345772326, + 0.12031364177766891, + 0.07038755277896766, + 0.03322925565155569, + 0.012657819729901945, + 0.0038903040680094217, + 0.0009646503390864025, + 0.00019297087402915717, + 0.000031139936308099136, + 0.000004053309048174758, + 4.255228059965837e-7, + 3.602517634249573e-8, + 2.4592560765896795e-9, + 1.3534945386863618e-10, + 0.0 //one more for interpolation +); + +float gauss_weight(float p_val) { + + float idxf; + float c = modf(max(0.0, p_val * float(GAUSS_TABLE_SIZE)), idxf); + int idx = int(idxf); + if (idx >= GAUSS_TABLE_SIZE + 1) { + return 0.0; + } + + return mix(gauss_table[idx], gauss_table[idx + 1], c); +} + +#define GAUSS_WEIGHT(m_val) gauss_table[clamp(int(m_val * float(GAUSS_TABLE_SIZE - 1)), 0, GAUSS_TABLE_SIZE - 1)] + +#define M_PI 3.14159265359 + +vec3 reconstructCSPosition(vec2 S, float z) { + if (params.orthogonal) { + return vec3((S.xy * params.proj_info.xy + params.proj_info.zw), z); + } else { + return vec3((S.xy * params.proj_info.xy + params.proj_info.zw) * z, z); + } +} + +void do_filter(inout vec4 accum, inout float accum_radius, inout float divisor, ivec2 texcoord, ivec2 increment, vec3 p_pos, vec3 normal, float p_limit_radius) { + + for (int i = 1; i < params.steps; i++) { + float d = float(i * params.increment); + ivec2 tc = texcoord + increment * i; + float depth = imageLoad(source_depth, tc).r; + vec3 view_pos = reconstructCSPosition(vec2(tc) + 0.5, depth); + vec3 view_normal = normalize(imageLoad(source_normal, tc).rgb * 2.0 - 1.0); + view_normal.y = -view_normal.y; + + float r = imageLoad(source_radius, tc).r; + float radius = round(r * 255.0); + + float angle_n = 1.0 - abs(dot(normal, view_normal)); + if (angle_n > params.edge_tolerance) { + break; + } + + float angle = abs(dot(normal, normalize(view_pos - p_pos))); + + if (angle > params.edge_tolerance) { + break; + } + + float contrib = 0.0; + if (d < radius) { + contrib += gauss_weight(d / radius); + } + + if (contrib > 0.0) { + accum += imageLoad(source_ssr, tc) * contrib; +#ifndef VERTICAL_PASS + accum_radius += r * contrib; +#endif + divisor += contrib; + } + } +} + +void main() { + + // Pixel being shaded + ivec2 ssC = ivec2(gl_GlobalInvocationID.xy); + + if (any(greaterThan(ssC, params.screen_size))) { //too large, do nothing + return; + } + + float base_contrib = gauss_table[0]; + + vec4 accum = imageLoad(source_ssr, ssC); + + float accum_radius = imageLoad(source_radius, ssC).r; + float radius = accum_radius * 255.0; + + float divisor = gauss_table[0]; + accum *= divisor; + accum_radius *= divisor; +#ifdef VERTICAL_PASS + ivec2 direction = ivec2(0, params.increment); +#else + ivec2 direction = ivec2(params.increment, 0); +#endif + float depth = imageLoad(source_depth, ssC).r; + vec3 pos = reconstructCSPosition(vec2(ssC) + 0.5, depth); + vec3 normal = imageLoad(source_normal, ssC).xyz * 2.0 - 1.0; + normal = normalize(normal); + normal.y = -normal.y; + + do_filter(accum, accum_radius, divisor, ssC, direction, pos, normal, radius); + do_filter(accum, accum_radius, divisor, ssC, -direction, pos, normal, radius); + + if (divisor > 0.0) { + accum /= divisor; + accum_radius /= divisor; + } else { + accum = vec4(0.0); + accum_radius = 0.0; + } + + imageStore(dest_ssr, ssC, accum); + +#ifndef VERTICAL_PASS + imageStore(dest_radius, ssC, vec4(accum_radius)); +#endif +} diff --git a/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl new file mode 100644 index 0000000000..cec6c14c76 --- /dev/null +++ b/servers/rendering/rasterizer_rd/shaders/screen_space_reflection_scale.glsl @@ -0,0 +1,96 @@ +/* clang-format off */ +[compute] + +#version 450 + +VERSION_DEFINES + + +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +/* clang-format on */ + +layout(set = 0, binding = 0) uniform sampler2D source_ssr; +layout(set = 1, binding = 0) uniform sampler2D source_depth; +layout(set = 1, binding = 1) uniform sampler2D source_normal; +layout(rgba16f, set = 2, binding = 0) uniform restrict writeonly image2D dest_ssr; +layout(r32f, set = 3, binding = 0) uniform restrict writeonly image2D dest_depth; +layout(rgba8, set = 3, binding = 1) uniform restrict writeonly image2D dest_normal; + +layout(push_constant, binding = 1, std430) uniform Params { + + ivec2 screen_size; + float camera_z_near; + float camera_z_far; + + bool orthogonal; + bool filtered; + uint pad[2]; +} +params; + +void main() { + + // Pixel being shaded + ivec2 ssC = ivec2(gl_GlobalInvocationID.xy); + + if (any(greaterThan(ssC, params.screen_size))) { //too large, do nothing + return; + } + //do not filter, SSR will generate arctifacts if this is done + + float divisor = 0.0; + vec4 color; + float depth; + vec3 normal; + + if (params.filtered) { + + color = vec4(0.0); + depth = 0.0; + normal = vec3(0.0); + + for (int i = 0; i < 4; i++) { + + ivec2 ofs = ssC << 1; + if (bool(i & 1)) { + ofs.x += 1; + } + if (bool(i & 2)) { + ofs.y += 1; + } + color += texelFetch(source_ssr, ofs, 0); + float d = texelFetch(source_depth, ofs, 0).r; + normal += texelFetch(source_normal, ofs, 0).xyz * 2.0 - 1.0; + + d = d * 2.0 - 1.0; + if (params.orthogonal) { + d = ((d + (params.camera_z_far + params.camera_z_near) / (params.camera_z_far - params.camera_z_near)) * (params.camera_z_far - params.camera_z_near)) / 2.0; + } else { + d = 2.0 * params.camera_z_near * params.camera_z_far / (params.camera_z_far + params.camera_z_near - d * (params.camera_z_far - params.camera_z_near)); + } + depth += -d; + } + + color /= 4.0; + depth /= 4.0; + normal = normalize(normal / 4.0) * 0.5 + 0.5; + + } else { + color = texelFetch(source_ssr, ssC << 1, 0); + depth = texelFetch(source_depth, ssC << 1, 0).r; + normal = texelFetch(source_normal, ssC << 1, 0).xyz; + + depth = depth * 2.0 - 1.0; + if (params.orthogonal) { + depth = ((depth + (params.camera_z_far + params.camera_z_near) / (params.camera_z_far - params.camera_z_near)) * (params.camera_z_far - params.camera_z_near)) / 2.0; + } else { + depth = 2.0 * params.camera_z_near * params.camera_z_far / (params.camera_z_far + params.camera_z_near - depth * (params.camera_z_far - params.camera_z_near)); + } + depth = -depth; + } + + imageStore(dest_ssr, ssC, color); + imageStore(dest_depth, ssC, vec4(depth)); + imageStore(dest_normal, ssC, vec4(normal, 0.0)); +} diff --git a/servers/visual/rasterizer_rd/shaders/sky.glsl b/servers/rendering/rasterizer_rd/shaders/sky.glsl index 3f433eb2ee..469925839a 100644 --- a/servers/visual/rasterizer_rd/shaders/sky.glsl +++ b/servers/rendering/rasterizer_rd/shaders/sky.glsl @@ -141,15 +141,15 @@ void main() { vec4 quarter_res_color = vec4(1.0); #ifdef USE_CUBEMAP_PASS - float using_cubemap = 1.0; + vec3 inverted_cube_normal = cube_normal; + inverted_cube_normal.z *= -1.0; #ifdef USES_HALF_RES_COLOR - half_res_color = texture(samplerCube(half_res, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), cube_normal); + half_res_color = texture(samplerCube(half_res, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), inverted_cube_normal); #endif #ifdef USES_QUARTER_RES_COLOR - quarter_res_color = texture(samplerCube(quarter_res, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), cube_normal); + quarter_res_color = texture(samplerCube(quarter_res, material_samplers[SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP]), inverted_cube_normal); #endif #else - float using_cubemap = 0.0; #ifdef USES_HALF_RES_COLOR half_res_color = textureLod(sampler2D(half_res, material_samplers[SAMPLER_LINEAR_CLAMP]), uv, 0.0); #endif diff --git a/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl new file mode 100644 index 0000000000..b28250318e --- /dev/null +++ b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl @@ -0,0 +1,59 @@ +/* clang-format off */ +[vertex] + +#version 450 + +VERSION_DEFINES + +layout(location = 0) out vec2 uv_interp; +/* clang-format on */ + +void main() { + + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); + uv_interp = base_arr[gl_VertexIndex]; + + gl_Position = vec4(uv_interp * 2.0 - 1.0, 0.0, 1.0); +} + +/* clang-format off */ +[fragment] + +#version 450 + +VERSION_DEFINES + +layout(location = 0) in vec2 uv_interp; +/* clang-format on */ + +layout(set = 0, binding = 0) uniform sampler2D specular; + +#ifdef MODE_SSR + +layout(set = 1, binding = 0) uniform sampler2D ssr; + +#endif + +#ifdef MODE_MERGE + +layout(set = 2, binding = 0) uniform sampler2D diffuse; + +#endif + +layout(location = 0) out vec4 frag_color; + +void main() { + + frag_color.rgb = texture(specular, uv_interp).rgb; + frag_color.a = 0.0; +#ifdef MODE_SSR + + vec4 ssr = texture(ssr, uv_interp); + frag_color.rgb = mix(frag_color.rgb, ssr.rgb, ssr.a); +#endif + +#ifdef MODE_MERGE + frag_color += texture(diffuse, uv_interp); +#endif + //added using additive blend +} diff --git a/servers/visual/rasterizer_rd/shaders/ssao.glsl b/servers/rendering/rasterizer_rd/shaders/ssao.glsl index c9d7134610..c9d7134610 100644 --- a/servers/visual/rasterizer_rd/shaders/ssao.glsl +++ b/servers/rendering/rasterizer_rd/shaders/ssao.glsl diff --git a/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl b/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl index e90c788e08..e90c788e08 100644 --- a/servers/visual/rasterizer_rd/shaders/ssao_blur.glsl +++ b/servers/rendering/rasterizer_rd/shaders/ssao_blur.glsl diff --git a/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl b/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl index 8728154347..8728154347 100644 --- a/servers/visual/rasterizer_rd/shaders/ssao_minify.glsl +++ b/servers/rendering/rasterizer_rd/shaders/ssao_minify.glsl diff --git a/servers/visual/rasterizer_rd/shaders/tonemap.glsl b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl index 524ca5e2ea..524ca5e2ea 100644 --- a/servers/visual/rasterizer_rd/shaders/tonemap.glsl +++ b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl diff --git a/servers/visual/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 3c1795161d..a3799b0e4d 100644 --- a/servers/visual/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -30,14 +30,14 @@ #include "rendering_device.h" -RenderingDevice *RenderingDevice::singleton = NULL; +RenderingDevice *RenderingDevice::singleton = nullptr; RenderingDevice *RenderingDevice::get_singleton() { return singleton; } -RenderingDevice::ShaderCompileFunction RenderingDevice::compile_function = NULL; -RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = NULL; +RenderingDevice::ShaderCompileFunction RenderingDevice::compile_function = nullptr; +RenderingDevice::ShaderCacheFunction RenderingDevice::cache_function = nullptr; void RenderingDevice::shader_set_compile_function(ShaderCompileFunction p_function) { compile_function = p_function; diff --git a/servers/visual/rendering_device.h b/servers/rendering/rendering_device.h index 4705bcaa75..a639ff3641 100644 --- a/servers/visual/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -563,7 +563,7 @@ public: /**** SHADER ****/ /****************/ - virtual Vector<uint8_t> shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = NULL, bool p_allow_cache = true); + virtual Vector<uint8_t> shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = nullptr, bool p_allow_cache = true); static void shader_set_compile_function(ShaderCompileFunction p_function); static void shader_set_cache_function(ShaderCacheFunction p_function); diff --git a/servers/visual/visual_server_canvas.cpp b/servers/rendering/rendering_server_canvas.cpp index c192b77988..5d6dcfd2c1 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/rendering/rendering_server_canvas.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_canvas.cpp */ +/* rendering_server_canvas.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "visual_server_canvas.h" -#include "visual_server_globals.h" -#include "visual_server_raster.h" -#include "visual_server_viewport.h" +#include "rendering_server_canvas.h" +#include "rendering_server_globals.h" +#include "rendering_server_raster.h" +#include "rendering_server_viewport.h" -static const int z_range = VS::CANVAS_ITEM_Z_MAX - VS::CANVAS_ITEM_Z_MIN + 1; +static const int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1; -void VisualServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) { +void RenderingServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) { RENDER_TIMESTAMP("Cull CanvasItem Tree"); @@ -43,14 +43,14 @@ void VisualServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas memset(z_last_list, 0, z_range * sizeof(RasterizerCanvas::Item *)); for (int i = 0; i < p_child_item_count; i++) { - _cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL); + _cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, nullptr, nullptr); } if (p_canvas_item) { - _cull_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL); + _cull_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, nullptr, nullptr); } - RasterizerCanvas::Item *list = NULL; - RasterizerCanvas::Item *list_end = NULL; + RasterizerCanvas::Item *list = nullptr; + RasterizerCanvas::Item *list_end = nullptr; for (int i = 0; i < z_range; i++) { if (!z_list[i]) @@ -66,19 +66,19 @@ void VisualServerCanvas::_render_canvas_item_tree(RID p_to_render_target, Canvas RENDER_TIMESTAMP("Render Canvas Items"); - VSG::canvas_render->canvas_render_items(p_to_render_target, list, p_modulate, p_lights, p_transform); + RSG::canvas_render->canvas_render_items(p_to_render_target, list, p_modulate, p_lights, p_transform); } -void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2D p_transform, VisualServerCanvas::Item *p_material_owner, VisualServerCanvas::Item **r_items, int &r_index) { +void _collect_ysort_children(RenderingServerCanvas::Item *p_canvas_item, Transform2D p_transform, RenderingServerCanvas::Item *p_material_owner, RenderingServerCanvas::Item **r_items, int &r_index) { int child_item_count = p_canvas_item->child_items.size(); - VisualServerCanvas::Item **child_items = p_canvas_item->child_items.ptrw(); + RenderingServerCanvas::Item **child_items = p_canvas_item->child_items.ptrw(); for (int i = 0; i < child_item_count; i++) { if (child_items[i]->visible) { if (r_items) { r_items[r_index] = child_items[i]; child_items[i]->ysort_xform = p_transform; child_items[i]->ysort_pos = p_transform.xform(child_items[i]->xform.elements[2]); - child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : NULL; + child_items[i]->material_owner = child_items[i]->use_parent_material ? p_material_owner : nullptr; } r_index++; @@ -89,14 +89,14 @@ void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2 } } -void _mark_ysort_dirty(VisualServerCanvas::Item *ysort_owner, RID_PtrOwner<VisualServerCanvas::Item> &canvas_item_owner) { +void _mark_ysort_dirty(RenderingServerCanvas::Item *ysort_owner, RID_PtrOwner<RenderingServerCanvas::Item> &canvas_item_owner) { do { ysort_owner->ysort_children_count = -1; - ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : NULL; + ysort_owner = canvas_item_owner.owns(ysort_owner->parent) ? canvas_item_owner.getornull(ysort_owner->parent) : nullptr; } while (ysort_owner && ysort_owner->sort_y); } -void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) { +void RenderingServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) { Item *ci = p_canvas_item; @@ -118,7 +118,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 ci->material_owner = p_material_owner; else { p_material_owner = ci; - ci->material_owner = NULL; + ci->material_owner = nullptr; } Color modulate(ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g, ci->modulate.b * p_modulate.b, ci->modulate.a * p_modulate.a); @@ -130,7 +130,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 Item **child_items = ci->child_items.ptrw(); if (ci->clip) { - if (p_canvas_clip != NULL) { + if (p_canvas_clip != nullptr) { ci->final_clip_rect = p_canvas_clip->final_clip_rect.clip(global_rect); } else { ci->final_clip_rect = global_rect; @@ -145,7 +145,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 if (ci->ysort_children_count == -1) { ci->ysort_children_count = 0; - _collect_ysort_children(ci, Transform2D(), p_material_owner, NULL, ci->ysort_children_count); + _collect_ysort_children(ci, Transform2D(), p_material_owner, nullptr, ci->ysort_children_count); } child_item_count = ci->ysort_children_count; @@ -159,7 +159,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 } if (ci->z_relative) - p_z = CLAMP(p_z + ci->z_index, VS::CANVAS_ITEM_Z_MIN, VS::CANVAS_ITEM_Z_MAX); + p_z = CLAMP(p_z + ci->z_index, RS::CANVAS_ITEM_Z_MIN, RS::CANVAS_ITEM_Z_MAX); else p_z = ci->z_index; @@ -180,10 +180,10 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 } if (ci->update_when_visible) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } - if ((ci->commands != NULL && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) { + if ((ci->commands != nullptr && p_clip_rect.intersects(global_rect, true)) || ci->vp_render || ci->copy_back_buffer) { //something to draw? ci->final_transform = xform; ci->final_modulate = Color(modulate.r * ci->self_modulate.r, modulate.g * ci->self_modulate.g, modulate.b * ci->self_modulate.b, modulate.a * ci->self_modulate.a); @@ -191,7 +191,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 ci->global_rect_cache.position -= p_clip_rect.position; ci->light_masked = false; - int zidx = p_z - VS::CANVAS_ITEM_Z_MIN; + int zidx = p_z - RS::CANVAS_ITEM_Z_MIN; if (z_last_list[zidx]) { z_last_list[zidx]->next = ci; @@ -204,7 +204,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 ci->z_final = p_z; - ci->next = NULL; + ci->next = nullptr; } for (int i = 0; i < child_item_count; i++) { @@ -219,7 +219,7 @@ void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2 } } -void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) { +void RenderingServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights) { if (!p_masked_lights) return; @@ -242,7 +242,7 @@ void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Ite } } -void VisualServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) { +void RenderingServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) { RENDER_TIMESTAMP(">Render Canvas"); @@ -265,30 +265,30 @@ void VisualServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, co if (!has_mirror) { - _render_canvas_item_tree(p_render_target, ci, l, NULL, p_transform, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, ci, l, nullptr, p_transform, p_clip_rect, p_canvas->modulate, p_lights); } else { //used for parallaxlayer mirroring for (int i = 0; i < l; i++) { const Canvas::ChildItem &ci2 = p_canvas->child_items[i]; - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights); //mirroring (useful for scrolling backgrounds) if (ci2.mirror.x != 0) { Transform2D xform2 = p_transform * Transform2D(0, Vector2(ci2.mirror.x, 0)); - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); } if (ci2.mirror.y != 0) { Transform2D xform2 = p_transform * Transform2D(0, Vector2(0, ci2.mirror.y)); - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); } if (ci2.mirror.y != 0 && ci2.mirror.x != 0) { Transform2D xform2 = p_transform * Transform2D(0, ci2.mirror); - _render_canvas_item_tree(p_render_target, NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); + _render_canvas_item_tree(p_render_target, nullptr, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights); } } } @@ -296,7 +296,7 @@ void VisualServerCanvas::render_canvas(RID p_render_target, Canvas *p_canvas, co RENDER_TIMESTAMP("<End Render Canvas"); } -RID VisualServerCanvas::canvas_create() { +RID RenderingServerCanvas::canvas_create() { Canvas *canvas = memnew(Canvas); ERR_FAIL_COND_V(!canvas, RID()); @@ -305,7 +305,7 @@ RID VisualServerCanvas::canvas_create() { return rid; } -void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) { +void RenderingServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring) { Canvas *canvas = canvas_owner.getornull(p_canvas); ERR_FAIL_COND(!canvas); @@ -316,18 +316,18 @@ void VisualServerCanvas::canvas_set_item_mirroring(RID p_canvas, RID p_item, con ERR_FAIL_COND(idx == -1); canvas->child_items.write[idx].mirror = p_mirroring; } -void VisualServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) { +void RenderingServerCanvas::canvas_set_modulate(RID p_canvas, const Color &p_color) { Canvas *canvas = canvas_owner.getornull(p_canvas); ERR_FAIL_COND(!canvas); canvas->modulate = p_color; } -void VisualServerCanvas::canvas_set_disable_scale(bool p_disable) { +void RenderingServerCanvas::canvas_set_disable_scale(bool p_disable) { disable_scale = p_disable; } -void VisualServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) { +void RenderingServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_scale) { Canvas *canvas = canvas_owner.getornull(p_canvas); ERR_FAIL_COND(!canvas); @@ -336,7 +336,7 @@ void VisualServerCanvas::canvas_set_parent(RID p_canvas, RID p_parent, float p_s canvas->parent_scale = p_scale; } -RID VisualServerCanvas::canvas_item_create() { +RID RenderingServerCanvas::canvas_item_create() { Item *canvas_item = memnew(Item); ERR_FAIL_COND_V(!canvas_item, RID()); @@ -344,7 +344,7 @@ RID VisualServerCanvas::canvas_item_create() { return canvas_item_owner.make_rid(canvas_item); } -void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) { +void RenderingServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -394,7 +394,7 @@ void VisualServerCanvas::canvas_item_set_parent(RID p_item, RID p_parent) { canvas_item->parent = p_parent; } -void VisualServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) { +void RenderingServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -403,7 +403,7 @@ void VisualServerCanvas::canvas_item_set_visible(RID p_item, bool p_visible) { _mark_ysort_dirty(canvas_item, canvas_item_owner); } -void VisualServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) { +void RenderingServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -411,28 +411,28 @@ void VisualServerCanvas::canvas_item_set_light_mask(RID p_item, int p_mask) { canvas_item->light_mask = p_mask; } -void VisualServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) { +void RenderingServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D &p_transform) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->xform = p_transform; } -void VisualServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) { +void RenderingServerCanvas::canvas_item_set_clip(RID p_item, bool p_clip) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->clip = p_clip; } -void VisualServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) { +void RenderingServerCanvas::canvas_item_set_distance_field_mode(RID p_item, bool p_enable) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->distance_field = p_enable; } -void VisualServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) { +void RenderingServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect, const Rect2 &p_rect) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -440,14 +440,14 @@ void VisualServerCanvas::canvas_item_set_custom_rect(RID p_item, bool p_custom_r canvas_item->custom_rect = p_custom_rect; canvas_item->rect = p_rect; } -void VisualServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) { +void RenderingServerCanvas::canvas_item_set_modulate(RID p_item, const Color &p_color) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->modulate = p_color; } -void VisualServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) { +void RenderingServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color &p_color) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -455,7 +455,7 @@ void VisualServerCanvas::canvas_item_set_self_modulate(RID p_item, const Color & canvas_item->self_modulate = p_color; } -void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) { +void RenderingServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_enable) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -463,7 +463,7 @@ void VisualServerCanvas::canvas_item_set_draw_behind_parent(RID p_item, bool p_e canvas_item->behind = p_enable; } -void VisualServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_update) { +void RenderingServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_update) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -471,21 +471,21 @@ void VisualServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_ canvas_item->update_when_visible = p_update; } -void VisualServerCanvas::canvas_item_set_default_texture_filter(RID p_item, VS::CanvasItemTextureFilter p_filter) { +void RenderingServerCanvas::canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->texture_filter = p_filter; } -void VisualServerCanvas::canvas_item_set_default_texture_repeat(RID p_item, VS::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->texture_repeat = p_repeat; } -void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) { +void RenderingServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -511,7 +511,7 @@ void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, line->specular_shininess = Color(1, 1, 1, 1); } -void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) { +void RenderingServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) { ERR_FAIL_COND(p_points.size() < 2); Item *canvas_item = canvas_item_owner.getornull(p_item); @@ -520,7 +520,7 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>(); ERR_FAIL_COND(!pline); - pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID()); + pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID()); if (true || p_width <= 1) { #define TODO make thick lines possible @@ -535,7 +535,7 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point } } - pline->primitive = VS::PRIMITIVE_LINES; + pline->primitive = RS::PRIMITIVE_LINES; pline->specular_shininess = Color(1, 1, 1, 1); pline->polygon.create(indices, p_points, p_colors); } else { @@ -603,7 +603,7 @@ void VisualServerCanvas::canvas_item_add_polyline(RID p_item, const Vector<Point } } -void VisualServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) { +void RenderingServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width) { ERR_FAIL_COND(p_points.size() < 2); Item *canvas_item = canvas_item_owner.getornull(p_item); @@ -612,19 +612,19 @@ void VisualServerCanvas::canvas_item_add_multiline(RID p_item, const Vector<Poin Item::CommandPolygon *pline = canvas_item->alloc_command<Item::CommandPolygon>(); ERR_FAIL_COND(!pline); - pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID()); + pline->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID()); if (true || p_width <= 1) { #define TODO make thick lines possible - pline->primitive = VS::PRIMITIVE_LINES; + pline->primitive = RS::PRIMITIVE_LINES; pline->specular_shininess = Color(1, 1, 1, 1); pline->polygon.create(Vector<int>(), p_points, p_colors); } else { } } -void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) { +void RenderingServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -635,7 +635,7 @@ void VisualServerCanvas::canvas_item_add_rect(RID p_item, const Rect2 &p_rect, c rect->rect = p_rect; } -void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) { +void RenderingServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -643,9 +643,9 @@ void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, Item::CommandPolygon *circle = canvas_item->alloc_command<Item::CommandPolygon>(); ERR_FAIL_COND(!circle); - circle->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), VS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, VS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID()); + circle->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, RID(), RID(), RID(), RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, RID()); - circle->primitive = VS::PRIMITIVE_TRIANGLES; + circle->primitive = RS::PRIMITIVE_TRIANGLES; circle->specular_shininess = Color(1, 1, 1, 1); Vector<int> indices; @@ -673,7 +673,7 @@ void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos, circle->polygon.create(indices, points, color); } -void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -707,7 +707,7 @@ void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p rect->specular_shininess = p_specular_color_shininess; } -void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -752,7 +752,7 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R } } -void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode, VS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode, RS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -772,7 +772,7 @@ void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_r style->axis_x = p_x_axis_mode; style->axis_y = p_y_axis_mode; } -void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { uint32_t pc = p_points.size(); ERR_FAIL_COND(pc == 0 || pc > 4); @@ -803,7 +803,7 @@ void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Poin prim->specular_shininess = p_specular_color_shininess; } -void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -820,13 +820,13 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2 Item::CommandPolygon *polygon = canvas_item->alloc_command<Item::CommandPolygon>(); ERR_FAIL_COND(!polygon); - polygon->primitive = VS::PRIMITIVE_TRIANGLES; + polygon->primitive = RS::PRIMITIVE_TRIANGLES; polygon->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID()); polygon->specular_shininess = p_specular_color_shininess; polygon->polygon.create(indices, p_points, p_colors, p_uvs); } -void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -846,10 +846,10 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector polygon->specular_shininess = p_specular_color_shininess; polygon->polygon.create(indices, p_points, p_colors, p_uvs, p_bones, p_weights); - polygon->primitive = VS::PRIMITIVE_TRIANGLES; + polygon->primitive = RS::PRIMITIVE_TRIANGLES; } -void VisualServerCanvas::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) { +void RenderingServerCanvas::canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -859,7 +859,7 @@ void VisualServerCanvas::canvas_item_add_set_transform(RID p_item, const Transfo tr->xform = p_transform; } -void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -872,7 +872,7 @@ void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, con m->transform = p_transform; m->modulate = p_modulate; } -void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -884,10 +884,10 @@ void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, part->specular_shininess = p_specular_color_shininess; //take the chance and request processing for them, at least once until they become visible again - VSG::storage->particles_request_process(p_particles); + RSG::storage->particles_request_process(p_particles); } -void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) { +void RenderingServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, RenderingServer::CanvasItemTextureFilter p_filter, RenderingServer::CanvasItemTextureRepeat p_repeat) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -899,7 +899,7 @@ void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p mm->specular_shininess = p_specular_color_shininess; } -void VisualServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) { +void RenderingServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -908,7 +908,7 @@ void VisualServerCanvas::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) ERR_FAIL_COND(!ci); ci->ignore = p_ignore; } -void VisualServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) { +void RenderingServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -917,16 +917,16 @@ void VisualServerCanvas::canvas_item_set_sort_children_by_y(RID p_item, bool p_e _mark_ysort_dirty(canvas_item, canvas_item_owner); } -void VisualServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) { +void RenderingServerCanvas::canvas_item_set_z_index(RID p_item, int p_z) { - ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN || p_z > VS::CANVAS_ITEM_Z_MAX); + ERR_FAIL_COND(p_z < RS::CANVAS_ITEM_Z_MIN || p_z > RS::CANVAS_ITEM_Z_MAX); Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->z_index = p_z; } -void VisualServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) { +void RenderingServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -934,7 +934,7 @@ void VisualServerCanvas::canvas_item_set_z_as_relative_to_parent(RID p_item, boo canvas_item->z_relative = p_enable; } -void VisualServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) { +void RenderingServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -942,16 +942,16 @@ void VisualServerCanvas::canvas_item_attach_skeleton(RID p_item, RID p_skeleton) canvas_item->skeleton = p_skeleton; } -void VisualServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) { +void RenderingServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2 &p_rect) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); - if (bool(canvas_item->copy_back_buffer != NULL) != p_enable) { + if (bool(canvas_item->copy_back_buffer != nullptr) != p_enable) { if (p_enable) { canvas_item->copy_back_buffer = memnew(RasterizerCanvas::Item::CopyBackBuffer); } else { memdelete(canvas_item->copy_back_buffer); - canvas_item->copy_back_buffer = NULL; + canvas_item->copy_back_buffer = nullptr; } } @@ -961,14 +961,14 @@ void VisualServerCanvas::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_e } } -void VisualServerCanvas::canvas_item_clear(RID p_item) { +void RenderingServerCanvas::canvas_item_clear(RID p_item) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); canvas_item->clear(); } -void VisualServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) { +void RenderingServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -988,7 +988,7 @@ void VisualServerCanvas::canvas_item_set_draw_index(RID p_item, int p_index) { } } -void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) { +void RenderingServerCanvas::canvas_item_set_material(RID p_item, RID p_material) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -996,7 +996,7 @@ void VisualServerCanvas::canvas_item_set_material(RID p_item, RID p_material) { canvas_item->material = p_material; } -void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) { +void RenderingServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_enable) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -1004,13 +1004,13 @@ void VisualServerCanvas::canvas_item_set_use_parent_material(RID p_item, bool p_ canvas_item->use_parent_material = p_enable; } -RID VisualServerCanvas::canvas_light_create() { +RID RenderingServerCanvas::canvas_light_create() { RasterizerCanvas::Light *clight = memnew(RasterizerCanvas::Light); - clight->light_internal = VSG::canvas_render->light_create(); + clight->light_internal = RSG::canvas_render->light_create(); return canvas_light_owner.make_rid(clight); } -void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) { +void RenderingServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); @@ -1033,65 +1033,65 @@ void VisualServerCanvas::canvas_light_attach_to_canvas(RID p_light, RID p_canvas } } -void VisualServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) { +void RenderingServerCanvas::canvas_light_set_enabled(RID p_light, bool p_enabled) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->enabled = p_enabled; } -void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) { +void RenderingServerCanvas::canvas_light_set_scale(RID p_light, float p_scale) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->scale = p_scale; } -void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) { +void RenderingServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D &p_transform) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->xform = p_transform; } -void VisualServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) { +void RenderingServerCanvas::canvas_light_set_texture(RID p_light, RID p_texture) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->texture = p_texture; clight->version++; - VSG::canvas_render->light_set_texture(clight->light_internal, p_texture); + RSG::canvas_render->light_set_texture(clight->light_internal, p_texture); } -void VisualServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) { +void RenderingServerCanvas::canvas_light_set_texture_offset(RID p_light, const Vector2 &p_offset) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->texture_offset = p_offset; } -void VisualServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) { +void RenderingServerCanvas::canvas_light_set_color(RID p_light, const Color &p_color) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->color = p_color; } -void VisualServerCanvas::canvas_light_set_height(RID p_light, float p_height) { +void RenderingServerCanvas::canvas_light_set_height(RID p_light, float p_height) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->height = p_height; } -void VisualServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) { +void RenderingServerCanvas::canvas_light_set_energy(RID p_light, float p_energy) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->energy = p_energy; } -void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) { +void RenderingServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int p_max_z) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); @@ -1099,7 +1099,7 @@ void VisualServerCanvas::canvas_light_set_z_range(RID p_light, int p_min_z, int clight->z_min = p_min_z; clight->z_max = p_max_z; } -void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) { +void RenderingServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_layer, int p_max_layer) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); @@ -1107,21 +1107,21 @@ void VisualServerCanvas::canvas_light_set_layer_range(RID p_light, int p_min_lay clight->layer_max = p_max_layer; clight->layer_min = p_min_layer; } -void VisualServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) { +void RenderingServerCanvas::canvas_light_set_item_cull_mask(RID p_light, int p_mask) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->item_mask = p_mask; } -void VisualServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) { +void RenderingServerCanvas::canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->item_shadow_mask = p_mask; } -void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode) { +void RenderingServerCanvas::canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); @@ -1129,7 +1129,7 @@ void VisualServerCanvas::canvas_light_set_mode(RID p_light, VS::CanvasLightMode clight->mode = p_mode; } -void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) { +void RenderingServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); @@ -1139,10 +1139,10 @@ void VisualServerCanvas::canvas_light_set_shadow_enabled(RID p_light, bool p_ena } clight->use_shadow = p_enabled; clight->version++; - VSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size); + RSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size); } -void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size) { +void RenderingServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_size) { ERR_FAIL_COND(p_size < 32 || p_size > 16384); @@ -1156,17 +1156,17 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_ clight->shadow_buffer_size = next_power_of_2(p_size); clight->version++; - VSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size); + RSG::canvas_render->light_set_use_shadow(clight->light_internal, clight->use_shadow, clight->shadow_buffer_size); } -void VisualServerCanvas::canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter) { +void RenderingServerCanvas::canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->shadow_filter = p_filter; } -void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) { +void RenderingServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color &p_color) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); @@ -1174,20 +1174,20 @@ void VisualServerCanvas::canvas_light_set_shadow_color(RID p_light, const Color clight->shadow_color = p_color; } -void VisualServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) { +void RenderingServerCanvas::canvas_light_set_shadow_smooth(RID p_light, float p_smooth) { RasterizerCanvas::Light *clight = canvas_light_owner.getornull(p_light); ERR_FAIL_COND(!clight); clight->shadow_smooth = p_smooth; } -RID VisualServerCanvas::canvas_light_occluder_create() { +RID RenderingServerCanvas::canvas_light_occluder_create() { RasterizerCanvas::LightOccluderInstance *occluder = memnew(RasterizerCanvas::LightOccluderInstance); return canvas_light_occluder_owner.make_rid(occluder); } -void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) { +void RenderingServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, RID p_canvas) { RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!occluder); @@ -1209,14 +1209,14 @@ void VisualServerCanvas::canvas_light_occluder_attach_to_canvas(RID p_occluder, canvas->occluders.insert(occluder); } } -void VisualServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) { +void RenderingServerCanvas::canvas_light_occluder_set_enabled(RID p_occluder, bool p_enabled) { RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!occluder); occluder->enabled = p_enabled; } -void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) { +void RenderingServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p_polygon) { RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!occluder); @@ -1244,14 +1244,14 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p } } } -void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) { +void RenderingServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) { RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!occluder); occluder->xform = p_xform; } -void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) { +void RenderingServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, int p_mask) { RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.getornull(p_occluder); ERR_FAIL_COND(!occluder); @@ -1259,13 +1259,13 @@ void VisualServerCanvas::canvas_light_occluder_set_light_mask(RID p_occluder, in occluder->light_mask = p_mask; } -RID VisualServerCanvas::canvas_occluder_polygon_create() { +RID RenderingServerCanvas::canvas_occluder_polygon_create() { LightOccluderPolygon *occluder_poly = memnew(LightOccluderPolygon); - occluder_poly->occluder = VSG::canvas_render->occluder_polygon_create(); + occluder_poly->occluder = RSG::canvas_render->occluder_polygon_create(); return canvas_light_occluder_polygon_owner.make_rid(occluder_poly); } -void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) { +void RenderingServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed) { if (p_shape.size() < 3) { canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, p_shape); @@ -1295,7 +1295,7 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape(RID p_occluder_polygo canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon, lines); } -void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape) { +void RenderingServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape) { LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon); ERR_FAIL_COND(!occluder_poly); @@ -1313,24 +1313,24 @@ void VisualServerCanvas::canvas_occluder_polygon_set_shape_as_lines(RID p_occlud } } - VSG::canvas_render->occluder_polygon_set_shape_as_lines(occluder_poly->occluder, p_shape); + RSG::canvas_render->occluder_polygon_set_shape_as_lines(occluder_poly->occluder, p_shape); for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) { E->get()->aabb_cache = occluder_poly->aabb; } } -void VisualServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode) { +void RenderingServerCanvas::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode) { LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_occluder_polygon); ERR_FAIL_COND(!occluder_poly); occluder_poly->cull_mode = p_mode; - VSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode); + RSG::canvas_render->occluder_polygon_set_cull_mode(occluder_poly->occluder, p_mode); for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *E = occluder_poly->owners.front(); E; E = E->next()) { E->get()->cull_cache = p_mode; } } -bool VisualServerCanvas::free(RID p_rid) { +bool RenderingServerCanvas::free(RID p_rid) { if (canvas_owner.owns(p_rid)) { @@ -1339,10 +1339,10 @@ bool VisualServerCanvas::free(RID p_rid) { while (canvas->viewports.size()) { - VisualServerViewport::Viewport *vp = VSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get()); + RenderingServerViewport::Viewport *vp = RSG::viewport->viewport_owner.getornull(canvas->viewports.front()->get()); ERR_FAIL_COND_V(!vp, true); - Map<RID, VisualServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid); + Map<RID, RenderingServerViewport::Viewport::CanvasData>::Element *E = vp->canvas_map.find(p_rid); ERR_FAIL_COND_V(!E, true); vp->canvas_map.erase(p_rid); @@ -1416,7 +1416,7 @@ bool VisualServerCanvas::free(RID p_rid) { canvas->lights.erase(canvas_light); } - VSG::canvas_render->free(canvas_light->light_internal); + RSG::canvas_render->free(canvas_light->light_internal); canvas_light_owner.free(p_rid); memdelete(canvas_light); @@ -1447,7 +1447,7 @@ bool VisualServerCanvas::free(RID p_rid) { LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.getornull(p_rid); ERR_FAIL_COND_V(!occluder_poly, true); - VSG::canvas_render->free(occluder_poly->occluder); + RSG::canvas_render->free(occluder_poly->occluder); while (occluder_poly->owners.size()) { @@ -1464,7 +1464,7 @@ bool VisualServerCanvas::free(RID p_rid) { return true; } -VisualServerCanvas::VisualServerCanvas() { +RenderingServerCanvas::RenderingServerCanvas() { z_list = (RasterizerCanvas::Item **)memalloc(z_range * sizeof(RasterizerCanvas::Item *)); z_last_list = (RasterizerCanvas::Item **)memalloc(z_range * sizeof(RasterizerCanvas::Item *)); @@ -1472,7 +1472,7 @@ VisualServerCanvas::VisualServerCanvas() { disable_scale = false; } -VisualServerCanvas::~VisualServerCanvas() { +RenderingServerCanvas::~RenderingServerCanvas() { memfree(z_list); memfree(z_last_list); diff --git a/servers/visual/visual_server_canvas.h b/servers/rendering/rendering_server_canvas.h index dea4183752..9da11462db 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/rendering/rendering_server_canvas.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_canvas.h */ +/* rendering_server_canvas.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -32,9 +32,9 @@ #define VISUALSERVERCANVAS_H #include "rasterizer.h" -#include "visual_server_viewport.h" +#include "rendering_server_viewport.h" -class VisualServerCanvas { +class RenderingServerCanvas { public: struct Item : public RasterizerCanvas::Item { @@ -52,14 +52,14 @@ public: Color ysort_modulate; Transform2D ysort_xform; Vector2 ysort_pos; - VS::CanvasItemTextureFilter texture_filter; - VS::CanvasItemTextureRepeat texture_repeat; + RS::CanvasItemTextureFilter texture_filter; + RS::CanvasItemTextureRepeat texture_repeat; Vector<Item *> child_items; Item() { children_order_dirty = true; - E = NULL; + E = nullptr; z_index = 0; modulate = Color(1, 1, 1, 1); self_modulate = Color(1, 1, 1, 1); @@ -70,8 +70,8 @@ public: ysort_children_count = -1; ysort_xform = Transform2D(); ysort_pos = Vector2(); - texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT; - texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT; + texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT; + texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT; } }; @@ -98,13 +98,13 @@ public: bool active; Rect2 aabb; - VS::CanvasOccluderPolygonCullMode cull_mode; + RS::CanvasOccluderPolygonCullMode cull_mode; RID occluder; Set<RasterizerCanvas::LightOccluderInstance *> owners; LightOccluderPolygon() { active = false; - cull_mode = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; + cull_mode = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; } }; @@ -112,7 +112,7 @@ public: RID_PtrOwner<RasterizerCanvas::LightOccluderInstance> canvas_light_occluder_owner; - struct Canvas : public VisualServerViewport::CanvasBase { + struct Canvas : public RenderingServerViewport::CanvasBase { Set<RID> viewports; struct ChildItem { @@ -194,23 +194,23 @@ public: void canvas_item_set_update_when_visible(RID p_item, bool p_update); - void canvas_item_set_default_texture_filter(RID p_item, VS::CanvasItemTextureFilter p_filter); - void canvas_item_set_default_texture_repeat(RID p_item, VS::CanvasItemTextureRepeat p_repeat); + void canvas_item_set_default_texture_filter(RID p_item, RS::CanvasItemTextureFilter p_filter); + void canvas_item_set_default_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat); void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0); void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0); void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0); void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color); void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color); - void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_clip_uv = false, VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); - void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_clip_uv = false, RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, RS::NinePatchAxisMode p_x_axis_mode = RS::NINE_PATCH_STRETCH, RS::NinePatchAxisMode p_y_axis_mode = RS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); + void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), RS::CanvasItemTextureFilter p_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT); void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform); void canvas_item_add_clip_ignore(RID p_item, bool p_ignore); void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable); @@ -241,11 +241,11 @@ public: void canvas_light_set_item_cull_mask(RID p_light, int p_mask); void canvas_light_set_item_shadow_cull_mask(RID p_light, int p_mask); - void canvas_light_set_mode(RID p_light, VS::CanvasLightMode p_mode); + void canvas_light_set_mode(RID p_light, RS::CanvasLightMode p_mode); void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled); void canvas_light_set_shadow_buffer_size(RID p_light, int p_size); - void canvas_light_set_shadow_filter(RID p_light, VS::CanvasLightShadowFilter p_filter); + void canvas_light_set_shadow_filter(RID p_light, RS::CanvasLightShadowFilter p_filter); void canvas_light_set_shadow_color(RID p_light, const Color &p_color); void canvas_light_set_shadow_smooth(RID p_light, float p_smooth); @@ -260,11 +260,11 @@ public: void canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const Vector<Vector2> &p_shape, bool p_closed); void canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon, const Vector<Vector2> &p_shape); - void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, VS::CanvasOccluderPolygonCullMode p_mode); + void canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon, RS::CanvasOccluderPolygonCullMode p_mode); bool free(RID p_rid); - VisualServerCanvas(); - ~VisualServerCanvas(); + RenderingServerCanvas(); + ~RenderingServerCanvas(); }; #endif // VISUALSERVERCANVAS_H diff --git a/servers/rendering/rendering_server_globals.cpp b/servers/rendering/rendering_server_globals.cpp new file mode 100644 index 0000000000..5a270520a9 --- /dev/null +++ b/servers/rendering/rendering_server_globals.cpp @@ -0,0 +1,40 @@ +/*************************************************************************/ +/* rendering_server_globals.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "rendering_server_globals.h" + +RasterizerStorage *RenderingServerGlobals::storage = nullptr; +RasterizerCanvas *RenderingServerGlobals::canvas_render = nullptr; +RasterizerScene *RenderingServerGlobals::scene_render = nullptr; +Rasterizer *RenderingServerGlobals::rasterizer = nullptr; + +RenderingServerCanvas *RenderingServerGlobals::canvas = nullptr; +RenderingServerViewport *RenderingServerGlobals::viewport = nullptr; +RenderingServerScene *RenderingServerGlobals::scene = nullptr; diff --git a/servers/visual/visual_server_globals.h b/servers/rendering/rendering_server_globals.h index 5a9d365eca..b33f328b69 100644 --- a/servers/visual/visual_server_globals.h +++ b/servers/rendering/rendering_server_globals.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_globals.h */ +/* rendering_server_globals.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,27 +28,27 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VISUAL_SERVER_GLOBALS_H -#define VISUAL_SERVER_GLOBALS_H +#ifndef RENDERING_SERVER_GLOBALS_H +#define RENDERING_SERVER_GLOBALS_H #include "rasterizer.h" -class VisualServerCanvas; -class VisualServerViewport; -class VisualServerScene; +class RenderingServerCanvas; +class RenderingServerViewport; +class RenderingServerScene; -class VisualServerGlobals { +class RenderingServerGlobals { public: static RasterizerStorage *storage; static RasterizerCanvas *canvas_render; static RasterizerScene *scene_render; static Rasterizer *rasterizer; - static VisualServerCanvas *canvas; - static VisualServerViewport *viewport; - static VisualServerScene *scene; + static RenderingServerCanvas *canvas; + static RenderingServerViewport *viewport; + static RenderingServerScene *scene; }; -#define VSG VisualServerGlobals +#define RSG RenderingServerGlobals -#endif // VISUAL_SERVER_GLOBALS_H +#endif // RENDERING_SERVER_GLOBALS_H diff --git a/servers/visual/visual_server_raster.cpp b/servers/rendering/rendering_server_raster.cpp index 1026972a62..7cc06527e4 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/rendering/rendering_server_raster.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_raster.cpp */ +/* rendering_server_raster.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,23 +28,23 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "visual_server_raster.h" +#include "rendering_server_raster.h" #include "core/io/marshalls.h" #include "core/os/os.h" #include "core/project_settings.h" #include "core/sort_array.h" -#include "visual_server_canvas.h" -#include "visual_server_globals.h" -#include "visual_server_scene.h" +#include "rendering_server_canvas.h" +#include "rendering_server_globals.h" +#include "rendering_server_scene.h" // careful, these may run in different threads than the visual server -int VisualServerRaster::changes = 0; +int RenderingServerRaster::changes = 0; /* BLACK BARS */ -void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) { +void RenderingServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) { black_margin[MARGIN_LEFT] = p_left; black_margin[MARGIN_TOP] = p_top; @@ -52,7 +52,7 @@ void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_rig black_margin[MARGIN_BOTTOM] = p_bottom; } -void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) { +void RenderingServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) { black_image[MARGIN_LEFT] = p_left; black_image[MARGIN_TOP] = p_top; @@ -60,30 +60,30 @@ void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_righ black_image[MARGIN_BOTTOM] = p_bottom; } -void VisualServerRaster::_draw_margins() { +void RenderingServerRaster::_draw_margins() { - VSG::canvas_render->draw_window_margins(black_margin, black_image); + RSG::canvas_render->draw_window_margins(black_margin, black_image); }; /* FREE */ -void VisualServerRaster::free(RID p_rid) { +void RenderingServerRaster::free(RID p_rid) { - if (VSG::storage->free(p_rid)) + if (RSG::storage->free(p_rid)) return; - if (VSG::canvas->free(p_rid)) + if (RSG::canvas->free(p_rid)) return; - if (VSG::viewport->free(p_rid)) + if (RSG::viewport->free(p_rid)) return; - if (VSG::scene->free(p_rid)) + if (RSG::scene->free(p_rid)) return; - if (VSG::scene_render->free(p_rid)) + if (RSG::scene_render->free(p_rid)) return; } /* EVENT QUEUING */ -void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) { +void RenderingServerRaster::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) { ERR_FAIL_NULL(p_where); FrameDrawnCallbacks fdc; @@ -94,27 +94,27 @@ void VisualServerRaster::request_frame_drawn_callback(Object *p_where, const Str frame_drawn_callbacks.push_back(fdc); } -void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) { +void RenderingServerRaster::draw(bool p_swap_buffers, double frame_step) { //needs to be done before changes is reset to 0, to not force the editor to redraw - VS::get_singleton()->emit_signal("frame_pre_draw"); + RS::get_singleton()->emit_signal("frame_pre_draw"); changes = 0; - VSG::rasterizer->begin_frame(frame_step); + RSG::rasterizer->begin_frame(frame_step); TIMESTAMP_BEGIN() - VSG::scene_render->update(); //update scenes stuff before updating instances + RSG::scene_render->update(); //update scenes stuff before updating instances - VSG::scene->update_dirty_instances(); //update scene stuff + RSG::scene->update_dirty_instances(); //update scene stuff - VSG::scene->render_probes(); - VSG::viewport->draw_viewports(); - VSG::canvas_render->update(); + RSG::scene->render_probes(); + RSG::viewport->draw_viewports(); + RSG::canvas_render->update(); _draw_margins(); - VSG::rasterizer->end_frame(p_swap_buffers); + RSG::rasterizer->end_frame(p_swap_buffers); while (frame_drawn_callbacks.front()) { @@ -131,128 +131,128 @@ void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) { frame_drawn_callbacks.pop_front(); } - VS::get_singleton()->emit_signal("frame_post_draw"); + RS::get_singleton()->emit_signal("frame_post_draw"); - if (VSG::storage->get_captured_timestamps_count()) { + if (RSG::storage->get_captured_timestamps_count()) { Vector<FrameProfileArea> new_profile; - new_profile.resize(VSG::storage->get_captured_timestamps_count()); + new_profile.resize(RSG::storage->get_captured_timestamps_count()); - uint64_t base_cpu = VSG::storage->get_captured_timestamp_cpu_time(0); - uint64_t base_gpu = VSG::storage->get_captured_timestamp_gpu_time(0); - for (uint32_t i = 0; i < VSG::storage->get_captured_timestamps_count(); i++) { - uint64_t time_cpu = VSG::storage->get_captured_timestamp_cpu_time(i) - base_cpu; - uint64_t time_gpu = VSG::storage->get_captured_timestamp_gpu_time(i) - base_gpu; + uint64_t base_cpu = RSG::storage->get_captured_timestamp_cpu_time(0); + uint64_t base_gpu = RSG::storage->get_captured_timestamp_gpu_time(0); + for (uint32_t i = 0; i < RSG::storage->get_captured_timestamps_count(); i++) { + uint64_t time_cpu = RSG::storage->get_captured_timestamp_cpu_time(i) - base_cpu; + uint64_t time_gpu = RSG::storage->get_captured_timestamp_gpu_time(i) - base_gpu; new_profile.write[i].gpu_msec = float(time_gpu / 1000) / 1000.0; new_profile.write[i].cpu_msec = float(time_cpu) / 1000.0; - new_profile.write[i].name = VSG::storage->get_captured_timestamp_name(i); + new_profile.write[i].name = RSG::storage->get_captured_timestamp_name(i); } frame_profile = new_profile; } - frame_profile_frame = VSG::storage->get_captured_timestamps_frame(); + frame_profile_frame = RSG::storage->get_captured_timestamps_frame(); } -void VisualServerRaster::sync() { +void RenderingServerRaster::sync() { } -bool VisualServerRaster::has_changed() const { +bool RenderingServerRaster::has_changed() const { return changes > 0; } -void VisualServerRaster::init() { +void RenderingServerRaster::init() { - VSG::rasterizer->initialize(); + RSG::rasterizer->initialize(); } -void VisualServerRaster::finish() { +void RenderingServerRaster::finish() { if (test_cube.is_valid()) { free(test_cube); } - VSG::rasterizer->finalize(); + RSG::rasterizer->finalize(); } /* STATUS INFORMATION */ -int VisualServerRaster::get_render_info(RenderInfo p_info) { +int RenderingServerRaster::get_render_info(RenderInfo p_info) { - return VSG::storage->get_render_info(p_info); + return RSG::storage->get_render_info(p_info); } -String VisualServerRaster::get_video_adapter_name() const { +String RenderingServerRaster::get_video_adapter_name() const { - return VSG::storage->get_video_adapter_name(); + return RSG::storage->get_video_adapter_name(); } -String VisualServerRaster::get_video_adapter_vendor() const { +String RenderingServerRaster::get_video_adapter_vendor() const { - return VSG::storage->get_video_adapter_vendor(); + return RSG::storage->get_video_adapter_vendor(); } -void VisualServerRaster::set_frame_profiling_enabled(bool p_enable) { - VSG::storage->capturing_timestamps = p_enable; +void RenderingServerRaster::set_frame_profiling_enabled(bool p_enable) { + RSG::storage->capturing_timestamps = p_enable; } -uint64_t VisualServerRaster::get_frame_profile_frame() { +uint64_t RenderingServerRaster::get_frame_profile_frame() { return frame_profile_frame; } -Vector<VisualServer::FrameProfileArea> VisualServerRaster::get_frame_profile() { +Vector<RenderingServer::FrameProfileArea> RenderingServerRaster::get_frame_profile() { return frame_profile; } /* TESTING */ -void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { +void RenderingServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) { redraw_request(); - VSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter); + RSG::rasterizer->set_boot_image(p_image, p_color, p_scale, p_use_filter); } -void VisualServerRaster::set_default_clear_color(const Color &p_color) { - VSG::viewport->set_default_clear_color(p_color); +void RenderingServerRaster::set_default_clear_color(const Color &p_color) { + RSG::viewport->set_default_clear_color(p_color); } -bool VisualServerRaster::has_feature(Features p_feature) const { +bool RenderingServerRaster::has_feature(Features p_feature) const { return false; } -RID VisualServerRaster::get_test_cube() { +RID RenderingServerRaster::get_test_cube() { if (!test_cube.is_valid()) { test_cube = _make_test_cube(); } return test_cube; } -bool VisualServerRaster::has_os_feature(const String &p_feature) const { +bool RenderingServerRaster::has_os_feature(const String &p_feature) const { - return VSG::storage->has_os_feature(p_feature); + return RSG::storage->has_os_feature(p_feature); } -void VisualServerRaster::set_debug_generate_wireframes(bool p_generate) { +void RenderingServerRaster::set_debug_generate_wireframes(bool p_generate) { - VSG::storage->set_debug_generate_wireframes(p_generate); + RSG::storage->set_debug_generate_wireframes(p_generate); } -void VisualServerRaster::call_set_use_vsync(bool p_enable) { +void RenderingServerRaster::call_set_use_vsync(bool p_enable) { DisplayServer::get_singleton()->_set_use_vsync(p_enable); } -bool VisualServerRaster::is_low_end() const { +bool RenderingServerRaster::is_low_end() const { // FIXME: Commented out when rebasing vulkan branch on master, // causes a crash, it seems rasterizer is not initialized yet the // first time it's called. - //return VSG::rasterizer->is_low_end(); + //return RSG::rasterizer->is_low_end(); return false; } -VisualServerRaster::VisualServerRaster() { +RenderingServerRaster::RenderingServerRaster() { - VSG::canvas = memnew(VisualServerCanvas); - VSG::viewport = memnew(VisualServerViewport); - VSG::scene = memnew(VisualServerScene); - VSG::rasterizer = Rasterizer::create(); - VSG::storage = VSG::rasterizer->get_storage(); - VSG::canvas_render = VSG::rasterizer->get_canvas(); - VSG::scene_render = VSG::rasterizer->get_scene(); + RSG::canvas = memnew(RenderingServerCanvas); + RSG::viewport = memnew(RenderingServerViewport); + RSG::scene = memnew(RenderingServerScene); + RSG::rasterizer = Rasterizer::create(); + RSG::storage = RSG::rasterizer->get_storage(); + RSG::canvas_render = RSG::rasterizer->get_canvas(); + RSG::scene_render = RSG::rasterizer->get_scene(); frame_profile_frame = 0; @@ -262,10 +262,10 @@ VisualServerRaster::VisualServerRaster() { } } -VisualServerRaster::~VisualServerRaster() { +RenderingServerRaster::~RenderingServerRaster() { - memdelete(VSG::canvas); - memdelete(VSG::viewport); - memdelete(VSG::rasterizer); - memdelete(VSG::scene); + memdelete(RSG::canvas); + memdelete(RSG::viewport); + memdelete(RSG::rasterizer); + memdelete(RSG::scene); } diff --git a/servers/visual/visual_server_raster.h b/servers/rendering/rendering_server_raster.h index 1a40fc96a2..8480aa30fc 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/rendering/rendering_server_raster.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_raster.h */ +/* rendering_server_raster.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,18 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VISUAL_SERVER_RASTER_H -#define VISUAL_SERVER_RASTER_H +#ifndef RENDERING_SERVER_RASTER_H +#define RENDERING_SERVER_RASTER_H #include "core/math/octree.h" -#include "servers/visual/rasterizer.h" -#include "servers/visual_server.h" -#include "visual_server_canvas.h" -#include "visual_server_globals.h" -#include "visual_server_scene.h" -#include "visual_server_viewport.h" +#include "rendering_server_canvas.h" +#include "rendering_server_globals.h" +#include "rendering_server_scene.h" +#include "rendering_server_viewport.h" +#include "servers/rendering/rasterizer.h" +#include "servers/rendering_server.h" -class VisualServerRaster : public VisualServer { +class RenderingServerRaster : public RenderingServer { enum { @@ -145,7 +145,7 @@ public: void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); } //from now on, calls forwarded to this singleton -#define BINDBASE VSG::storage +#define BINDBASE RSG::storage /* TEXTURE API */ @@ -424,7 +424,7 @@ public: BIND1(particles_request_process, RID) BIND1(particles_restart, RID) - BIND2(particles_set_draw_order, RID, VS::ParticlesDrawOrder) + BIND2(particles_set_draw_order, RID, RS::ParticlesDrawOrder) BIND2(particles_set_draw_passes, RID, int) BIND3(particles_set_draw_pass_mesh, RID, int, RID) @@ -434,7 +434,7 @@ public: #undef BINDBASE //from now on, calls forwarded to this singleton -#define BINDBASE VSG::scene +#define BINDBASE RSG::scene /* CAMERA API */ @@ -450,7 +450,7 @@ public: #undef BINDBASE //from now on, calls forwarded to this singleton -#define BINDBASE VSG::viewport +#define BINDBASE RSG::viewport /* VIEWPORT TARGET API */ @@ -497,7 +497,7 @@ public: #undef BINDBASE //from now on, calls forwarded to this singleton -#define BINDBASE VSG::scene_render +#define BINDBASE RSG::scene_render BIND1(directional_shadow_atlas_set_size, int) @@ -523,11 +523,14 @@ public: #if 0 BIND2(environment_set_camera_feed_id, RID, int) #endif - BIND7(environment_set_ssr, RID, bool, int, float, float, float, bool) + BIND6(environment_set_ssr, RID, bool, int, float, float, float) + BIND1(environment_set_ssr_roughness_quality, EnvironmentSSRRoughnessQuality) + BIND9(environment_set_ssao, RID, bool, float, float, float, float, float, EnvironmentSSAOBlur, float) BIND2(environment_set_ssao_quality, EnvironmentSSAOQuality, bool) - BIND12(environment_set_glow, RID, bool, int, float, float, float, float, EnvironmentGlowBlendMode, float, float, float, bool) + BIND11(environment_set_glow, RID, bool, int, float, float, float, float, EnvironmentGlowBlendMode, float, float, float) + BIND1(environment_glow_set_use_bicubic_upscale, bool) BIND9(environment_set_tonemap, RID, EnvironmentToneMapper, float, float, bool, float, float, float, float) @@ -552,7 +555,7 @@ public: /* SCENARIO API */ #undef BINDBASE -#define BINDBASE VSG::scene +#define BINDBASE RSG::scene BIND0R(RID, scenario_create) @@ -595,7 +598,7 @@ public: #undef BINDBASE //from now on, calls forwarded to this singleton -#define BINDBASE VSG::canvas +#define BINDBASE RSG::canvas /* CANVAS (2D) */ @@ -735,8 +738,8 @@ public: virtual bool is_low_end() const; - VisualServerRaster(); - ~VisualServerRaster(); + RenderingServerRaster(); + ~RenderingServerRaster(); #undef DISPLAY_CHANGED diff --git a/servers/visual/visual_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp index 1a9ecae23a..65823e11aa 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/rendering/rendering_server_scene.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_scene.cpp */ +/* rendering_server_scene.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,23 +28,23 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "visual_server_scene.h" +#include "rendering_server_scene.h" #include "core/os/os.h" -#include "visual_server_globals.h" -#include "visual_server_raster.h" +#include "rendering_server_globals.h" +#include "rendering_server_raster.h" #include <new> /* CAMERA API */ -RID VisualServerScene::camera_create() { +RID RenderingServerScene::camera_create() { Camera *camera = memnew(Camera); return camera_owner.make_rid(camera); } -void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) { +void RenderingServerScene::camera_set_perspective(RID p_camera, float p_fovy_degrees, float p_z_near, float p_z_far) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); @@ -54,7 +54,7 @@ void VisualServerScene::camera_set_perspective(RID p_camera, float p_fovy_degree camera->zfar = p_z_far; } -void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) { +void RenderingServerScene::camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); @@ -64,7 +64,7 @@ void VisualServerScene::camera_set_orthogonal(RID p_camera, float p_size, float camera->zfar = p_z_far; } -void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) { +void RenderingServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p_offset, float p_z_near, float p_z_far) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); camera->type = Camera::FRUSTUM; @@ -74,14 +74,14 @@ void VisualServerScene::camera_set_frustum(RID p_camera, float p_size, Vector2 p camera->zfar = p_z_far; } -void VisualServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) { +void RenderingServerScene::camera_set_transform(RID p_camera, const Transform &p_transform) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); camera->transform = p_transform.orthonormalized(); } -void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) { +void RenderingServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); @@ -89,21 +89,21 @@ void VisualServerScene::camera_set_cull_mask(RID p_camera, uint32_t p_layers) { camera->visible_layers = p_layers; } -void VisualServerScene::camera_set_environment(RID p_camera, RID p_env) { +void RenderingServerScene::camera_set_environment(RID p_camera, RID p_env) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); camera->env = p_env; } -void VisualServerScene::camera_set_camera_effects(RID p_camera, RID p_fx) { +void RenderingServerScene::camera_set_camera_effects(RID p_camera, RID p_fx) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); camera->effects = p_fx; } -void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) { +void RenderingServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enable) { Camera *camera = camera_owner.getornull(p_camera); ERR_FAIL_COND(!camera); @@ -112,9 +112,9 @@ void VisualServerScene::camera_set_use_vertical_aspect(RID p_camera, bool p_enab /* SCENARIO API */ -void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) { +void *RenderingServerScene::_instance_pair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int) { - //VisualServerScene *self = (VisualServerScene*)p_self; + //RenderingServerScene *self = (RenderingServerScene*)p_self; Instance *A = p_A; Instance *B = p_B; @@ -123,7 +123,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance SWAP(A, B); //lesser always first } - if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -141,7 +141,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance geom->lighting_dirty = true; return E; //this element should make freeing faster - } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + } else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -155,7 +155,7 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance geom->reflection_dirty = true; return E; //this element should make freeing faster - } else if (B->base_type == VS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + } else if (B->base_type == RS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -165,10 +165,10 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance pinfo.L = geom->lightmap_captures.push_back(B); List<InstanceLightmapCaptureData::PairInfo>::Element *E = lightmap_capture->geometries.push_back(pinfo); - ((VisualServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture + ((RenderingServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture return E; //this element should make freeing faster - } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + } else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -188,17 +188,17 @@ void *VisualServerScene::_instance_pair(void *p_self, OctreeElementID, Instance return E; //this element should make freeing faster - } else if (B->base_type == VS::INSTANCE_GI_PROBE && A->base_type == VS::INSTANCE_LIGHT) { + } else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); return gi_probe->lights.insert(A); } - return NULL; + return nullptr; } -void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) { +void RenderingServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance *p_A, int, OctreeElementID, Instance *p_B, int, void *udata) { - //VisualServerScene *self = (VisualServerScene*)p_self; + //RenderingServerScene *self = (RenderingServerScene*)p_self; Instance *A = p_A; Instance *B = p_B; @@ -207,7 +207,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance SWAP(A, B); //lesser always first } - if (B->base_type == VS::INSTANCE_LIGHT && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + if (B->base_type == RS::INSTANCE_LIGHT && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceLightData *light = static_cast<InstanceLightData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -222,7 +222,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance } geom->lighting_dirty = true; - } else if (B->base_type == VS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + } else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -233,7 +233,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance reflection_probe->geometries.erase(E); geom->reflection_dirty = true; - } else if (B->base_type == VS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + } else if (B->base_type == RS::INSTANCE_LIGHTMAP_CAPTURE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -242,9 +242,9 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance geom->lightmap_captures.erase(E->get().L); lightmap_capture->geometries.erase(E); - ((VisualServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture + ((RenderingServerScene *)p_self)->_instance_queue_update(A, false, false); //need to update capture - } else if (B->base_type == VS::INSTANCE_GI_PROBE && ((1 << A->base_type) & VS::INSTANCE_GEOMETRY_MASK)) { + } else if (B->base_type == RS::INSTANCE_GI_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data); @@ -260,7 +260,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance geom->gi_probes_dirty = true; - } else if (B->base_type == VS::INSTANCE_GI_PROBE && A->base_type == VS::INSTANCE_LIGHT) { + } else if (B->base_type == RS::INSTANCE_GI_PROBE && A->base_type == RS::INSTANCE_LIGHT) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(B->base_data); Set<Instance *>::Element *E = reinterpret_cast<Set<Instance *>::Element *>(udata); @@ -269,7 +269,7 @@ void VisualServerScene::_instance_unpair(void *p_self, OctreeElementID, Instance } } -RID VisualServerScene::scenario_create() { +RID RenderingServerScene::scenario_create() { Scenario *scenario = memnew(Scenario); ERR_FAIL_COND_V(!scenario, RID()); @@ -278,54 +278,54 @@ RID VisualServerScene::scenario_create() { scenario->octree.set_pair_callback(_instance_pair, this); scenario->octree.set_unpair_callback(_instance_unpair, this); - scenario->reflection_probe_shadow_atlas = VSG::scene_render->shadow_atlas_create(); - VSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest - VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 0, 4); - VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 1, 4); - VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 2, 4); - VSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 3, 8); - scenario->reflection_atlas = VSG::scene_render->reflection_atlas_create(); + scenario->reflection_probe_shadow_atlas = RSG::scene_render->shadow_atlas_create(); + RSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest + RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 0, 4); + RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 1, 4); + RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 2, 4); + RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 3, 8); + scenario->reflection_atlas = RSG::scene_render->reflection_atlas_create(); return scenario_rid; } -void VisualServerScene::scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode) { +void RenderingServerScene::scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode) { Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND(!scenario); scenario->debug = p_debug_mode; } -void VisualServerScene::scenario_set_environment(RID p_scenario, RID p_environment) { +void RenderingServerScene::scenario_set_environment(RID p_scenario, RID p_environment) { Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND(!scenario); scenario->environment = p_environment; } -void VisualServerScene::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) { +void RenderingServerScene::scenario_set_camera_effects(RID p_scenario, RID p_camera_effects) { Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND(!scenario); scenario->camera_effects = p_camera_effects; } -void VisualServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) { +void RenderingServerScene::scenario_set_fallback_environment(RID p_scenario, RID p_environment) { Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND(!scenario); scenario->fallback_environment = p_environment; } -void VisualServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) { +void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_reflection_size, int p_reflection_count) { Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND(!scenario); - VSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count); + RSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_reflection_size, p_reflection_count); } /* INSTANCING API */ -void VisualServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies) { +void RenderingServerScene::_instance_queue_update(Instance *p_instance, bool p_update_aabb, bool p_update_dependencies) { if (p_update_aabb) p_instance->update_aabb = true; @@ -338,7 +338,7 @@ void VisualServerScene::_instance_queue_update(Instance *p_instance, bool p_upda _instance_update_list.add(&p_instance->update_item); } -RID VisualServerScene::instance_create() { +RID RenderingServerScene::instance_create() { Instance *instance = memnew(Instance); ERR_FAIL_COND_V(!instance, RID()); @@ -349,14 +349,14 @@ RID VisualServerScene::instance_create() { return instance_rid; } -void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { +void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); Scenario *scenario = instance->scenario; - if (instance->base_type != VS::INSTANCE_NONE) { + if (instance->base_type != RS::INSTANCE_NONE) { //free anything related to that base if (scenario && instance->octree_id) { @@ -365,7 +365,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { } switch (instance->base_type) { - case VS::INSTANCE_LIGHT: { + case RS::INSTANCE_LIGHT: { InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data); #ifdef DEBUG_ENABLED @@ -375,19 +375,19 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { #endif if (instance->scenario && light->D) { instance->scenario->directional_lights.erase(light->D); - light->D = NULL; + light->D = nullptr; } - VSG::scene_render->free(light->instance); + RSG::scene_render->free(light->instance); } break; - case VS::INSTANCE_REFLECTION_PROBE: { + case RS::INSTANCE_REFLECTION_PROBE: { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data); - VSG::scene_render->free(reflection_probe->instance); + RSG::scene_render->free(reflection_probe->instance); if (reflection_probe->update_list.in_list()) { reflection_probe_render_list.remove(&reflection_probe->update_list); } } break; - case VS::INSTANCE_LIGHTMAP_CAPTURE: { + case RS::INSTANCE_LIGHTMAP_CAPTURE: { InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(instance->base_data); //erase dependencies, since no longer a lightmap @@ -395,7 +395,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { instance_set_use_lightmap(lightmap_capture->users.front()->get()->self, RID(), RID()); } } break; - case VS::INSTANCE_GI_PROBE: { + case RS::INSTANCE_GI_PROBE: { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); #ifdef DEBUG_ENABLED @@ -416,11 +416,11 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { Instance *capture = (Instance *)instance->lightmap_capture; InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(capture->base_data); lightmap_capture->users.erase(instance); - instance->lightmap_capture = NULL; + instance->lightmap_capture = nullptr; instance->lightmap = RID(); } - VSG::scene_render->free(gi_probe->probe_instance); + RSG::scene_render->free(gi_probe->probe_instance); } break; default: { @@ -429,60 +429,60 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { if (instance->base_data) { memdelete(instance->base_data); - instance->base_data = NULL; + instance->base_data = nullptr; } instance->blend_values.clear(); instance->materials.clear(); } - instance->base_type = VS::INSTANCE_NONE; + instance->base_type = RS::INSTANCE_NONE; instance->base = RID(); if (p_base.is_valid()) { - instance->base_type = VSG::storage->get_base_type(p_base); - ERR_FAIL_COND(instance->base_type == VS::INSTANCE_NONE); + instance->base_type = RSG::storage->get_base_type(p_base); + ERR_FAIL_COND(instance->base_type == RS::INSTANCE_NONE); switch (instance->base_type) { - case VS::INSTANCE_LIGHT: { + case RS::INSTANCE_LIGHT: { InstanceLightData *light = memnew(InstanceLightData); - if (scenario && VSG::storage->light_get_type(p_base) == VS::LIGHT_DIRECTIONAL) { + if (scenario && RSG::storage->light_get_type(p_base) == RS::LIGHT_DIRECTIONAL) { light->D = scenario->directional_lights.push_back(instance); } - light->instance = VSG::scene_render->light_instance_create(p_base); + light->instance = RSG::scene_render->light_instance_create(p_base); instance->base_data = light; } break; - case VS::INSTANCE_MESH: - case VS::INSTANCE_MULTIMESH: - case VS::INSTANCE_IMMEDIATE: - case VS::INSTANCE_PARTICLES: { + case RS::INSTANCE_MESH: + case RS::INSTANCE_MULTIMESH: + case RS::INSTANCE_IMMEDIATE: + case RS::INSTANCE_PARTICLES: { InstanceGeometryData *geom = memnew(InstanceGeometryData); instance->base_data = geom; - if (instance->base_type == VS::INSTANCE_MESH) { - instance->blend_values.resize(VSG::storage->mesh_get_blend_shape_count(p_base)); + if (instance->base_type == RS::INSTANCE_MESH) { + instance->blend_values.resize(RSG::storage->mesh_get_blend_shape_count(p_base)); } } break; - case VS::INSTANCE_REFLECTION_PROBE: { + case RS::INSTANCE_REFLECTION_PROBE: { InstanceReflectionProbeData *reflection_probe = memnew(InstanceReflectionProbeData); reflection_probe->owner = instance; instance->base_data = reflection_probe; - reflection_probe->instance = VSG::scene_render->reflection_probe_instance_create(p_base); + reflection_probe->instance = RSG::scene_render->reflection_probe_instance_create(p_base); } break; - case VS::INSTANCE_LIGHTMAP_CAPTURE: { + case RS::INSTANCE_LIGHTMAP_CAPTURE: { InstanceLightmapCaptureData *lightmap_capture = memnew(InstanceLightmapCaptureData); instance->base_data = lightmap_capture; - //lightmap_capture->instance = VSG::scene_render->lightmap_capture_instance_create(p_base); + //lightmap_capture->instance = RSG::scene_render->lightmap_capture_instance_create(p_base); } break; - case VS::INSTANCE_GI_PROBE: { + case RS::INSTANCE_GI_PROBE: { InstanceGIProbeData *gi_probe = memnew(InstanceGIProbeData); instance->base_data = gi_probe; @@ -492,7 +492,7 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { gi_probe_update_list.add(&gi_probe->update_element); } - gi_probe->probe_instance = VSG::scene_render->gi_probe_instance_create(p_base); + gi_probe->probe_instance = RSG::scene_render->gi_probe_instance_create(p_base); } break; default: { @@ -502,12 +502,12 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { instance->base = p_base; //forcefully update the dependency now, so if for some reason it gets removed, we can immediately clear it - VSG::storage->base_update_dependency(p_base, instance); + RSG::storage->base_update_dependency(p_base, instance); } _instance_queue_update(instance, true, true); } -void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { +void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -523,7 +523,7 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { switch (instance->base_type) { - case VS::INSTANCE_LIGHT: { + case RS::INSTANCE_LIGHT: { InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data); #ifdef DEBUG_ENABLED @@ -533,15 +533,15 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { #endif if (light->D) { instance->scenario->directional_lights.erase(light->D); - light->D = NULL; + light->D = nullptr; } } break; - case VS::INSTANCE_REFLECTION_PROBE: { + case RS::INSTANCE_REFLECTION_PROBE: { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data); - VSG::scene_render->reflection_probe_release_atlas_index(reflection_probe->instance); + RSG::scene_render->reflection_probe_release_atlas_index(reflection_probe->instance); } break; - case VS::INSTANCE_GI_PROBE: { + case RS::INSTANCE_GI_PROBE: { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); @@ -564,7 +564,7 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { } } - instance->scenario = NULL; + instance->scenario = nullptr; } if (p_scenario.is_valid()) { @@ -578,15 +578,15 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { switch (instance->base_type) { - case VS::INSTANCE_LIGHT: { + case RS::INSTANCE_LIGHT: { InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data); - if (VSG::storage->light_get_type(instance->base) == VS::LIGHT_DIRECTIONAL) { + if (RSG::storage->light_get_type(instance->base) == RS::LIGHT_DIRECTIONAL) { light->D = scenario->directional_lights.push_back(instance); } } break; - case VS::INSTANCE_GI_PROBE: { + case RS::INSTANCE_GI_PROBE: { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); if (!gi_probe->update_element.in_list()) { @@ -600,14 +600,14 @@ void VisualServerScene::instance_set_scenario(RID p_instance, RID p_scenario) { _instance_queue_update(instance, true, true); } } -void VisualServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) { +void RenderingServerScene::instance_set_layer_mask(RID p_instance, uint32_t p_mask) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); instance->layer_mask = p_mask; } -void VisualServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) { +void RenderingServerScene::instance_set_transform(RID p_instance, const Transform &p_transform) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -631,14 +631,14 @@ void VisualServerScene::instance_set_transform(RID p_instance, const Transform & instance->transform = p_transform; _instance_queue_update(instance, true); } -void VisualServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) { +void RenderingServerScene::instance_attach_object_instance_id(RID p_instance, ObjectID p_id) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); instance->object_id = p_id; } -void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) { +void RenderingServerScene::instance_set_blend_shape_weight(RID p_instance, int p_shape, float p_weight) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -651,14 +651,14 @@ void VisualServerScene::instance_set_blend_shape_weight(RID p_instance, int p_sh instance->blend_values.write[p_shape] = p_weight; } -void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) { +void RenderingServerScene::instance_set_surface_material(RID p_instance, int p_surface, RID p_material) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); - if (instance->base_type == VS::INSTANCE_MESH) { + if (instance->base_type == RS::INSTANCE_MESH) { //may not have been updated yet, may also have not been set yet. When updated will be correcte, worst case - instance->materials.resize(MAX(p_surface + 1, VSG::storage->mesh_get_surface_count(instance->base))); + instance->materials.resize(MAX(p_surface + 1, RSG::storage->mesh_get_surface_count(instance->base))); } ERR_FAIL_INDEX(p_surface, instance->materials.size()); @@ -668,7 +668,7 @@ void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surf _instance_queue_update(instance, false, true); } -void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) { +void RenderingServerScene::instance_set_visible(RID p_instance, bool p_visible) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -679,27 +679,27 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) { instance->visible = p_visible; switch (instance->base_type) { - case VS::INSTANCE_LIGHT: { - if (VSG::storage->light_get_type(instance->base) != VS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) { - instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_LIGHT, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0); + case RS::INSTANCE_LIGHT: { + if (RSG::storage->light_get_type(instance->base) != RS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) { + instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_LIGHT, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0); } } break; - case VS::INSTANCE_REFLECTION_PROBE: { + case RS::INSTANCE_REFLECTION_PROBE: { if (instance->octree_id && instance->scenario) { - instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_REFLECTION_PROBE, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0); + instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_REFLECTION_PROBE, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0); } } break; - case VS::INSTANCE_LIGHTMAP_CAPTURE: { + case RS::INSTANCE_LIGHTMAP_CAPTURE: { if (instance->octree_id && instance->scenario) { - instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_LIGHTMAP_CAPTURE, p_visible ? VS::INSTANCE_GEOMETRY_MASK : 0); + instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_LIGHTMAP_CAPTURE, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0); } } break; - case VS::INSTANCE_GI_PROBE: { + case RS::INSTANCE_GI_PROBE: { if (instance->octree_id && instance->scenario) { - instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << VS::INSTANCE_GI_PROBE, p_visible ? (VS::INSTANCE_GEOMETRY_MASK | (1 << VS::INSTANCE_LIGHT)) : 0); + instance->scenario->octree.set_pairable(instance->octree_id, p_visible, 1 << RS::INSTANCE_GI_PROBE, p_visible ? (RS::INSTANCE_GEOMETRY_MASK | (1 << RS::INSTANCE_LIGHT)) : 0); } } break; @@ -707,11 +707,11 @@ void VisualServerScene::instance_set_visible(RID p_instance, bool p_visible) { } } } -inline bool is_geometry_instance(VisualServer::InstanceType p_type) { - return p_type == VS::INSTANCE_MESH || p_type == VS::INSTANCE_MULTIMESH || p_type == VS::INSTANCE_PARTICLES || p_type == VS::INSTANCE_IMMEDIATE; +inline bool is_geometry_instance(RenderingServer::InstanceType p_type) { + return p_type == RS::INSTANCE_MESH || p_type == RS::INSTANCE_MULTIMESH || p_type == RS::INSTANCE_PARTICLES || p_type == RS::INSTANCE_IMMEDIATE; } -void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap) { +void RenderingServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap_instance, RID p_lightmap) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -720,13 +720,13 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(((Instance *)instance->lightmap_capture)->base_data); lightmap_capture->users.erase(instance); instance->lightmap = RID(); - instance->lightmap_capture = NULL; + instance->lightmap_capture = nullptr; } if (p_lightmap_instance.is_valid()) { Instance *lightmap_instance = instance_owner.getornull(p_lightmap_instance); ERR_FAIL_COND(!lightmap_instance); - ERR_FAIL_COND(lightmap_instance->base_type != VS::INSTANCE_LIGHTMAP_CAPTURE); + ERR_FAIL_COND(lightmap_instance->base_type != RS::INSTANCE_LIGHTMAP_CAPTURE); instance->lightmap_capture = lightmap_instance; InstanceLightmapCaptureData *lightmap_capture = static_cast<InstanceLightmapCaptureData *>(((Instance *)instance->lightmap_capture)->base_data); @@ -735,7 +735,7 @@ void VisualServerScene::instance_set_use_lightmap(RID p_instance, RID p_lightmap } } -void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) { +void RenderingServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -744,16 +744,16 @@ void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) { if (p_aabb != AABB()) { // Set custom AABB - if (instance->custom_aabb == NULL) + if (instance->custom_aabb == nullptr) instance->custom_aabb = memnew(AABB); *instance->custom_aabb = p_aabb; } else { // Clear custom AABB - if (instance->custom_aabb != NULL) { + if (instance->custom_aabb != nullptr) { memdelete(instance->custom_aabb); - instance->custom_aabb = NULL; + instance->custom_aabb = nullptr; } } @@ -761,7 +761,7 @@ void VisualServerScene::instance_set_custom_aabb(RID p_instance, AABB p_aabb) { _instance_queue_update(instance, true, false); } -void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) { +void RenderingServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -773,15 +773,15 @@ void VisualServerScene::instance_attach_skeleton(RID p_instance, RID p_skeleton) if (p_skeleton.is_valid()) { //update the dependency now, so if cleared, we remove it - VSG::storage->skeleton_update_dependency(p_skeleton, instance); + RSG::storage->skeleton_update_dependency(p_skeleton, instance); } _instance_queue_update(instance, true, true); } -void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) { +void RenderingServerScene::instance_set_exterior(RID p_instance, bool p_enabled) { } -void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) { +void RenderingServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -789,13 +789,13 @@ void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, rea _instance_queue_update(instance, true, false); } -Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const { +Vector<ObjectID> RenderingServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const { Vector<ObjectID> instances; Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND_V(!scenario, instances); - const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling + const_cast<RenderingServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling int culled = 0; Instance *cull[1024]; @@ -813,12 +813,12 @@ Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID return instances; } -Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const { +Vector<ObjectID> RenderingServerScene::instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const { Vector<ObjectID> instances; Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND_V(!scenario, instances); - const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling + const_cast<RenderingServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling int culled = 0; Instance *cull[1024]; @@ -835,12 +835,12 @@ Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3 &p_from, co return instances; } -Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const { +Vector<ObjectID> RenderingServerScene::instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario) const { Vector<ObjectID> instances; Scenario *scenario = scenario_owner.getornull(p_scenario); ERR_FAIL_COND_V(!scenario, instances); - const_cast<VisualServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling + const_cast<RenderingServerScene *>(this)->update_dirty_instances(); // check dirty instances before culling int culled = 0; Instance *cull[1024]; @@ -860,21 +860,21 @@ Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane> &p return instances; } -void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled) { +void RenderingServerScene::instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); - //ERR_FAIL_COND(((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK)); + //ERR_FAIL_COND(((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK)); switch (p_flags) { - case VS::INSTANCE_FLAG_USE_BAKED_LIGHT: { + case RS::INSTANCE_FLAG_USE_BAKED_LIGHT: { instance->baked_light = p_enabled; } break; - case VS::INSTANCE_FLAG_USE_DYNAMIC_GI: { + case RS::INSTANCE_FLAG_USE_DYNAMIC_GI: { if (p_enabled == instance->dynamic_gi) { //bye, redundant @@ -892,7 +892,7 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF instance->dynamic_gi = p_enabled; } break; - case VS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: { + case RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE: { instance->redraw_if_visible = p_enabled; @@ -901,7 +901,7 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF } } } -void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) { +void RenderingServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -909,7 +909,7 @@ void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instanc instance->cast_shadows = p_shadow_casting_setting; _instance_queue_update(instance, false, true); } -void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) { +void RenderingServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) { Instance *instance = instance_owner.getornull(p_instance); ERR_FAIL_COND(!instance); @@ -918,48 +918,48 @@ void VisualServerScene::instance_geometry_set_material_override(RID p_instance, _instance_queue_update(instance, false, true); } -void VisualServerScene::instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) { +void RenderingServerScene::instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin) { } -void VisualServerScene::instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) { +void RenderingServerScene::instance_geometry_set_as_instance_lod(RID p_instance, RID p_as_lod_of_instance) { } -void VisualServerScene::_update_instance(Instance *p_instance) { +void RenderingServerScene::_update_instance(Instance *p_instance) { p_instance->version++; - if (p_instance->base_type == VS::INSTANCE_LIGHT) { + if (p_instance->base_type == RS::INSTANCE_LIGHT) { InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data); - VSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform); + RSG::scene_render->light_instance_set_transform(light->instance, p_instance->transform); light->shadow_dirty = true; } - if (p_instance->base_type == VS::INSTANCE_REFLECTION_PROBE) { + if (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data); - VSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform); + RSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, p_instance->transform); reflection_probe->reflection_dirty = true; } - if (p_instance->base_type == VS::INSTANCE_GI_PROBE) { + if (p_instance->base_type == RS::INSTANCE_GI_PROBE) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(p_instance->base_data); - VSG::scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform); + RSG::scene_render->gi_probe_instance_set_transform_to_data(gi_probe->probe_instance, p_instance->transform); } - if (p_instance->base_type == VS::INSTANCE_PARTICLES) { + if (p_instance->base_type == RS::INSTANCE_PARTICLES) { - VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform); + RSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform); } if (p_instance->aabb.has_no_surface()) { return; } - if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) { + if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) { InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data); //make sure lights are updated if it casts shadow @@ -1000,15 +1000,15 @@ void VisualServerScene::_update_instance(Instance *p_instance) { uint32_t pairable_mask = 0; bool pairable = false; - if (p_instance->base_type == VS::INSTANCE_LIGHT || p_instance->base_type == VS::INSTANCE_REFLECTION_PROBE || p_instance->base_type == VS::INSTANCE_LIGHTMAP_CAPTURE) { + if (p_instance->base_type == RS::INSTANCE_LIGHT || p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE || p_instance->base_type == RS::INSTANCE_LIGHTMAP_CAPTURE) { - pairable_mask = p_instance->visible ? VS::INSTANCE_GEOMETRY_MASK : 0; + pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK : 0; pairable = true; } - if (p_instance->base_type == VS::INSTANCE_GI_PROBE) { + if (p_instance->base_type == RS::INSTANCE_GI_PROBE) { //lights and geometries - pairable_mask = p_instance->visible ? VS::INSTANCE_GEOMETRY_MASK | (1 << VS::INSTANCE_LIGHT) : 0; + pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK | (1 << RS::INSTANCE_LIGHT) : 0; pairable = true; } @@ -1026,68 +1026,68 @@ void VisualServerScene::_update_instance(Instance *p_instance) { } } -void VisualServerScene::_update_instance_aabb(Instance *p_instance) { +void RenderingServerScene::_update_instance_aabb(Instance *p_instance) { AABB new_aabb; - ERR_FAIL_COND(p_instance->base_type != VS::INSTANCE_NONE && !p_instance->base.is_valid()); + ERR_FAIL_COND(p_instance->base_type != RS::INSTANCE_NONE && !p_instance->base.is_valid()); switch (p_instance->base_type) { - case VisualServer::INSTANCE_NONE: { + case RenderingServer::INSTANCE_NONE: { // do nothing } break; - case VisualServer::INSTANCE_MESH: { + case RenderingServer::INSTANCE_MESH: { if (p_instance->custom_aabb) new_aabb = *p_instance->custom_aabb; else - new_aabb = VSG::storage->mesh_get_aabb(p_instance->base, p_instance->skeleton); + new_aabb = RSG::storage->mesh_get_aabb(p_instance->base, p_instance->skeleton); } break; - case VisualServer::INSTANCE_MULTIMESH: { + case RenderingServer::INSTANCE_MULTIMESH: { if (p_instance->custom_aabb) new_aabb = *p_instance->custom_aabb; else - new_aabb = VSG::storage->multimesh_get_aabb(p_instance->base); + new_aabb = RSG::storage->multimesh_get_aabb(p_instance->base); } break; - case VisualServer::INSTANCE_IMMEDIATE: { + case RenderingServer::INSTANCE_IMMEDIATE: { if (p_instance->custom_aabb) new_aabb = *p_instance->custom_aabb; else - new_aabb = VSG::storage->immediate_get_aabb(p_instance->base); + new_aabb = RSG::storage->immediate_get_aabb(p_instance->base); } break; - case VisualServer::INSTANCE_PARTICLES: { + case RenderingServer::INSTANCE_PARTICLES: { if (p_instance->custom_aabb) new_aabb = *p_instance->custom_aabb; else - new_aabb = VSG::storage->particles_get_aabb(p_instance->base); + new_aabb = RSG::storage->particles_get_aabb(p_instance->base); } break; - case VisualServer::INSTANCE_LIGHT: { + case RenderingServer::INSTANCE_LIGHT: { - new_aabb = VSG::storage->light_get_aabb(p_instance->base); + new_aabb = RSG::storage->light_get_aabb(p_instance->base); } break; - case VisualServer::INSTANCE_REFLECTION_PROBE: { + case RenderingServer::INSTANCE_REFLECTION_PROBE: { - new_aabb = VSG::storage->reflection_probe_get_aabb(p_instance->base); + new_aabb = RSG::storage->reflection_probe_get_aabb(p_instance->base); } break; - case VisualServer::INSTANCE_GI_PROBE: { + case RenderingServer::INSTANCE_GI_PROBE: { - new_aabb = VSG::storage->gi_probe_get_bounds(p_instance->base); + new_aabb = RSG::storage->gi_probe_get_bounds(p_instance->base); } break; - case VisualServer::INSTANCE_LIGHTMAP_CAPTURE: { + case RenderingServer::INSTANCE_LIGHTMAP_CAPTURE: { - new_aabb = VSG::storage->lightmap_capture_get_bounds(p_instance->base); + new_aabb = RSG::storage->lightmap_capture_get_bounds(p_instance->base); } break; default: { @@ -1281,7 +1281,7 @@ _FORCE_INLINE_ static Color _light_capture_voxel_cone_trace(const RasterizerStor return Color(color.x, color.y, color.z, alpha); } -void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance) { +void RenderingServerScene::_update_instance_lightmap_captures(Instance *p_instance) { InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data); @@ -1313,12 +1313,12 @@ void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance) //this could use some sort of blending.. for (List<Instance *>::Element *E = geom->lightmap_captures.front(); E; E = E->next()) { - const Vector<RasterizerStorage::LightmapCaptureOctree> *octree = VSG::storage->lightmap_capture_get_octree_ptr(E->get()->base); + const Vector<RasterizerStorage::LightmapCaptureOctree> *octree = RSG::storage->lightmap_capture_get_octree_ptr(E->get()->base); //print_line("octree size: " + itos(octree->size())); if (octree->size() == 0) continue; - Transform to_cell_xform = VSG::storage->lightmap_capture_get_octree_cell_transform(E->get()->base); - int cell_subdiv = VSG::storage->lightmap_capture_get_octree_cell_subdiv(E->get()->base); + Transform to_cell_xform = RSG::storage->lightmap_capture_get_octree_cell_transform(E->get()->base); + int cell_subdiv = RSG::storage->lightmap_capture_get_octree_cell_subdiv(E->get()->base); to_cell_xform = to_cell_xform * E->get()->transform.affine_inverse(); const RasterizerStorage::LightmapCaptureOctree *octree_r = octree->ptr(); @@ -1334,7 +1334,7 @@ void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance) } } -bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) { +bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) { InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data); @@ -1343,24 +1343,24 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons bool animated_material_found = false; - switch (VSG::storage->light_get_type(p_instance->base)) { + switch (RSG::storage->light_get_type(p_instance->base)) { - case VS::LIGHT_DIRECTIONAL: { + case RS::LIGHT_DIRECTIONAL: { float max_distance = p_cam_projection.get_z_far(); - float shadow_max = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SHADOW_MAX_DISTANCE); + float shadow_max = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SHADOW_MAX_DISTANCE); if (shadow_max > 0 && !p_cam_orthogonal) { //its impractical (and leads to unwanted behaviors) to set max distance in orthogonal camera max_distance = MIN(shadow_max, max_distance); } max_distance = MAX(max_distance, p_cam_projection.get_z_near() + 0.001); float min_distance = MIN(p_cam_projection.get_z_near(), max_distance); - VS::LightDirectionalShadowDepthRangeMode depth_range_mode = VSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base); + RS::LightDirectionalShadowDepthRangeMode depth_range_mode = RSG::storage->light_directional_get_shadow_depth_range_mode(p_instance->base); - if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) { + if (depth_range_mode == RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED) { //optimize min/max Vector<Plane> planes = p_cam_projection.get_projection_planes(p_cam_transform); - int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK); + int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK); Plane base(p_cam_transform.origin, -p_cam_transform.basis.get_axis(2)); //check distance max and min @@ -1371,7 +1371,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons for (int i = 0; i < cull_count; i++) { Instance *instance = instance_shadow_cull_result[i]; - if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { + if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { continue; } @@ -1402,24 +1402,24 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons float range = max_distance - min_distance; int splits = 0; - switch (VSG::storage->light_directional_get_shadow_mode(p_instance->base)) { - case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: splits = 1; break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: splits = 2; break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: splits = 4; break; + switch (RSG::storage->light_directional_get_shadow_mode(p_instance->base)) { + case RS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: splits = 1; break; + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: splits = 2; break; + case RS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: splits = 4; break; } float distances[5]; distances[0] = min_distance; for (int i = 0; i < splits; i++) { - distances[i + 1] = min_distance + VSG::storage->light_get_param(p_instance->base, VS::LightParam(VS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range; + distances[i + 1] = min_distance + RSG::storage->light_get_param(p_instance->base, RS::LightParam(RS::LIGHT_PARAM_SHADOW_SPLIT_1_OFFSET + i)) * range; }; distances[splits] = max_distance; - float texture_size = VSG::scene_render->get_directional_light_shadow_size(light->instance); + float texture_size = RSG::scene_render->get_directional_light_shadow_size(light->instance); - bool overlap = VSG::storage->light_directional_get_blend_splits(p_instance->base); + bool overlap = RSG::storage->light_directional_get_blend_splits(p_instance->base); float first_radius = 0.0; @@ -1532,7 +1532,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons //z_max_cam = z_vec.dot(center) + radius; z_min_cam = z_vec.dot(center) - radius; - if (depth_range_mode == VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) { + if (depth_range_mode == RS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE) { //this trick here is what stabilizes the shadow (make potential jaggies to not move) //at the cost of some wasted resolution. Still the quality increase is very well worth it @@ -1560,7 +1560,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons light_frustum_planes.write[4] = Plane(z_vec, z_max + 1e6); light_frustum_planes.write[5] = Plane(-z_vec, -z_min); // z_min is ok, since casters further than far-light plane are not needed - int cull_count = p_scenario->octree.cull_convex(light_frustum_planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK); + int cull_count = p_scenario->octree.cull_convex(light_frustum_planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK); // a pre pass will need to be needed to determine the actual z-near to be used @@ -1570,7 +1570,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons float min, max; Instance *instance = instance_shadow_cull_result[j]; - if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { + if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { cull_count--; SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]); j--; @@ -1596,25 +1596,25 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons ortho_transform.basis = transform.basis; ortho_transform.origin = x_vec * (x_min_cam + half_x) + y_vec * (y_min_cam + half_y) + z_vec * z_max; - VSG::scene_render->light_instance_set_shadow_transform(light->instance, ortho_camera, ortho_transform, 0, distances[i + 1], i, bias_scale); + RSG::scene_render->light_instance_set_shadow_transform(light->instance, ortho_camera, ortho_transform, 0, distances[i + 1], i, bias_scale); } - VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); + RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); } } break; - case VS::LIGHT_OMNI: { + case RS::LIGHT_OMNI: { - VS::LightOmniShadowMode shadow_mode = VSG::storage->light_omni_get_shadow_mode(p_instance->base); + RS::LightOmniShadowMode shadow_mode = RSG::storage->light_omni_get_shadow_mode(p_instance->base); - if (shadow_mode == VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !VSG::scene_render->light_instances_can_render_shadow_cube()) { + if (shadow_mode == RS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID || !RSG::scene_render->light_instances_can_render_shadow_cube()) { for (int i = 0; i < 2; i++) { //using this one ensures that raster deferred will have it RENDER_TIMESTAMP("Culling Shadow Paraboloid" + itos(i)); - float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE); + float radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE); float z = i == 0 ? -1 : 1; Vector<Plane> planes; @@ -1625,13 +1625,13 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons planes.write[3] = light_transform.xform(Plane(Vector3(0, 1, z).normalized(), radius)); planes.write[4] = light_transform.xform(Plane(Vector3(0, -1, z).normalized(), radius)); - int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK); + int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK); Plane near_plane(light_transform.origin, light_transform.basis.get_axis(2) * z); for (int j = 0; j < cull_count; j++) { Instance *instance = instance_shadow_cull_result[j]; - if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { + if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { cull_count--; SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]); j--; @@ -1645,12 +1645,12 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons } } - VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, i); - VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); + RSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, i); + RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); } } else { //shadow cube - float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE); + float radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE); CameraMatrix cm; cm.set_perspective(90, 1, 0.01, radius); @@ -1680,13 +1680,13 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons Vector<Plane> planes = cm.get_projection_planes(xform); - int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK); + int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK); Plane near_plane(xform.origin, -xform.basis.get_axis(2)); for (int j = 0; j < cull_count; j++) { Instance *instance = instance_shadow_cull_result[j]; - if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { + if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { cull_count--; SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]); j--; @@ -1699,33 +1699,33 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons } } - VSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, xform, radius, 0, i); - VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); + RSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, xform, radius, 0, i); + RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, i, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); } //restore the regular DP matrix - VSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, 0); + RSG::scene_render->light_instance_set_shadow_transform(light->instance, CameraMatrix(), light_transform, radius, 0, 0); } } break; - case VS::LIGHT_SPOT: { + case RS::LIGHT_SPOT: { RENDER_TIMESTAMP("Culling Spot Light"); - float radius = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_RANGE); - float angle = VSG::storage->light_get_param(p_instance->base, VS::LIGHT_PARAM_SPOT_ANGLE); + float radius = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_RANGE); + float angle = RSG::storage->light_get_param(p_instance->base, RS::LIGHT_PARAM_SPOT_ANGLE); CameraMatrix cm; cm.set_perspective(angle * 2.0, 1.0, 0.01, radius); Vector<Plane> planes = cm.get_projection_planes(light_transform); - int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, VS::INSTANCE_GEOMETRY_MASK); + int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK); Plane near_plane(light_transform.origin, -light_transform.basis.get_axis(2)); for (int j = 0; j < cull_count; j++) { Instance *instance = instance_shadow_cull_result[j]; - if (!instance->visible || !((1 << instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { + if (!instance->visible || !((1 << instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows) { cull_count--; SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]); j--; @@ -1738,8 +1738,8 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons } } - VSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, light_transform, radius, 0, 0); - VSG::scene_render->render_shadow(light->instance, p_shadow_atlas, 0, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); + RSG::scene_render->light_instance_set_shadow_transform(light->instance, cm, light_transform, radius, 0, 0); + RSG::scene_render->render_shadow(light->instance, p_shadow_atlas, 0, (RasterizerScene::InstanceBase **)instance_shadow_cull_result, cull_count); } break; } @@ -1747,7 +1747,7 @@ bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons return animated_material_found; } -void VisualServerScene::render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) { +void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) { // render to mono camera #ifndef _3D_DISABLED @@ -1798,7 +1798,7 @@ void VisualServerScene::render_camera(RID p_render_buffers, RID p_camera, RID p_ #endif } -void VisualServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) { +void RenderingServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) { // render for AR/VR interface Camera *camera = camera_owner.getornull(p_camera); @@ -1882,7 +1882,7 @@ void VisualServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> & _render_scene(p_render_buffers, cam_transform, camera_matrix, false, camera->env, camera->effects, p_scenario, p_shadow_atlas, RID(), -1); }; -void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, bool p_using_shadows) { +void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, bool p_using_shadows) { // Note, in stereo rendering: // - p_cam_transform will be a transform in the middle of our two eyes // - p_cam_projection is a wider frustrum that encompasses both eyes @@ -1892,7 +1892,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca render_pass++; uint32_t camera_layer_mask = p_visible_layers; - VSG::scene_render->set_scene_pass(render_pass); + RSG::scene_render->set_scene_pass(render_pass); RENDER_TIMESTAMP("Frustum Culling"); @@ -1932,7 +1932,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca if ((camera_layer_mask & ins->layer_mask) == 0) { //failure - } else if (ins->base_type == VS::INSTANCE_LIGHT && ins->visible) { + } else if (ins->base_type == RS::INSTANCE_LIGHT && ins->visible) { if (light_cull_count < MAX_LIGHTS_CULLED) { @@ -1942,14 +1942,14 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca //do not add this light if no geometry is affected by it.. light_cull_result[light_cull_count] = ins; light_instance_cull_result[light_cull_count] = light->instance; - if (p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(ins->base)) { - VSG::scene_render->light_instance_mark_visible(light->instance); //mark it visible for shadow allocation later + if (p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(ins->base)) { + RSG::scene_render->light_instance_mark_visible(light->instance); //mark it visible for shadow allocation later } light_cull_count++; } } - } else if (ins->base_type == VS::INSTANCE_REFLECTION_PROBE && ins->visible) { + } else if (ins->base_type == RS::INSTANCE_REFLECTION_PROBE && ins->visible) { if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) { @@ -1961,7 +1961,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca if (!reflection_probe->geometries.empty()) { //do not add this light if no geometry is affected by it.. - if (reflection_probe->reflection_dirty || VSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) { + if (reflection_probe->reflection_dirty || RSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) { if (!reflection_probe->update_list.in_list()) { reflection_probe->render_step = 0; reflection_probe_render_list.add_last(&reflection_probe->update_list); @@ -1970,7 +1970,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca reflection_probe->reflection_dirty = false; } - if (VSG::scene_render->reflection_probe_instance_has_reflection(reflection_probe->instance)) { + if (RSG::scene_render->reflection_probe_instance_has_reflection(reflection_probe->instance)) { reflection_probe_instance_cull_result[reflection_probe_cull_count] = reflection_probe->instance; reflection_probe_cull_count++; } @@ -1978,7 +1978,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca } } - } else if (ins->base_type == VS::INSTANCE_GI_PROBE && ins->visible) { + } else if (ins->base_type == RS::INSTANCE_GI_PROBE && ins->visible) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(ins->base_data); if (!gi_probe->update_element.in_list()) { @@ -1990,25 +1990,25 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca gi_probe_cull_count++; } - } else if (((1 << ins->base_type) & VS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) { + } else if (((1 << ins->base_type) & RS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) { keep = true; InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(ins->base_data); if (ins->redraw_if_visible) { - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } - if (ins->base_type == VS::INSTANCE_PARTICLES) { + if (ins->base_type == RS::INSTANCE_PARTICLES) { //particles visible? process them - if (VSG::storage->particles_is_inactive(ins->base)) { + if (RSG::storage->particles_is_inactive(ins->base)) { //but if nothing is going on, don't do it. keep = false; } else { - VSG::storage->particles_request_process(ins->base); + RSG::storage->particles_request_process(ins->base); //particles visible? request redraw - VisualServerRaster::redraw_request(); + RenderingServerRaster::redraw_request(); } } @@ -2098,7 +2098,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca //check shadow.. if (light) { - if (p_using_shadows && p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(E->get()->base)) { + if (p_using_shadows && p_shadow_atlas.is_valid() && RSG::storage->light_has_shadow(E->get()->base)) { lights_with_shadow[directional_shadow_count++] = E->get(); } //add to list @@ -2106,7 +2106,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca } } - VSG::scene_render->set_directional_shadow_count(directional_shadow_count); + RSG::scene_render->set_directional_shadow_count(directional_shadow_count); for (int i = 0; i < directional_shadow_count; i++) { @@ -2126,7 +2126,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca Instance *ins = light_cull_result[i]; - if (!p_shadow_atlas.is_valid() || !VSG::storage->light_has_shadow(ins->base)) + if (!p_shadow_atlas.is_valid() || !RSG::storage->light_has_shadow(ins->base)) continue; InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data); @@ -2142,11 +2142,11 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca // near plane half width and height Vector2 vp_half_extents = p_cam_projection.get_viewport_half_extents(); - switch (VSG::storage->light_get_type(ins->base)) { + switch (RSG::storage->light_get_type(ins->base)) { - case VS::LIGHT_OMNI: { + case RS::LIGHT_OMNI: { - float radius = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_RANGE); + float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE); //get two points parallel to near plane Vector3 points[2] = { @@ -2168,10 +2168,10 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca float screen_diameter = points[0].distance_to(points[1]) * 2; coverage = screen_diameter / (vp_half_extents.x + vp_half_extents.y); } break; - case VS::LIGHT_SPOT: { + case RS::LIGHT_SPOT: { - float radius = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_RANGE); - float angle = VSG::storage->light_get_param(ins->base, VS::LIGHT_PARAM_SPOT_ANGLE); + float radius = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_RANGE); + float angle = RSG::storage->light_get_param(ins->base, RS::LIGHT_PARAM_SPOT_ANGLE); float w = radius * Math::sin(Math::deg2rad(angle)); float d = radius * Math::cos(Math::deg2rad(angle)); @@ -2209,7 +2209,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca light->shadow_dirty = false; } - bool redraw = VSG::scene_render->shadow_atlas_update_light(p_shadow_atlas, light->instance, coverage, light->last_version); + bool redraw = RSG::scene_render->shadow_atlas_update_light(p_shadow_atlas, light->instance, coverage, light->last_version); if (redraw) { //must redraw! @@ -2221,7 +2221,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca } } -void VisualServerScene::_render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) { +void RenderingServerScene::_render_scene(RID p_render_buffers, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_force_camera_effects, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) { Scenario *scenario = scenario_owner.getornull(p_scenario); @@ -2244,10 +2244,10 @@ void VisualServerScene::_render_scene(RID p_render_buffers, const Transform p_ca /* PROCESS GEOMETRY AND DRAW SCENE */ RENDER_TIMESTAMP("Render Scene "); - VSG::scene_render->render_scene(p_render_buffers, p_cam_transform, p_cam_projection, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, instance_cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, gi_probe_instance_cull_result, gi_probe_cull_count, environment, camera_effects, p_shadow_atlas, p_reflection_probe.is_valid() ? RID() : scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass); + RSG::scene_render->render_scene(p_render_buffers, p_cam_transform, p_cam_projection, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, instance_cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, gi_probe_instance_cull_result, gi_probe_cull_count, environment, camera_effects, p_shadow_atlas, p_reflection_probe.is_valid() ? RID() : scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass); } -void VisualServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) { +void RenderingServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas) { #ifndef _3D_DISABLED @@ -2259,21 +2259,21 @@ void VisualServerScene::render_empty_scene(RID p_render_buffers, RID p_scenario, else environment = scenario->fallback_environment; RENDER_TIMESTAMP("Render Empty Scene "); - VSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, NULL, 0, NULL, 0, NULL, 0, NULL, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0); + RSG::scene_render->render_scene(p_render_buffers, Transform(), CameraMatrix(), true, nullptr, 0, nullptr, 0, nullptr, 0, nullptr, 0, environment, RID(), p_shadow_atlas, scenario->reflection_atlas, RID(), 0); #endif } -bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) { +bool RenderingServerScene::_render_reflection_probe_step(Instance *p_instance, int p_step) { InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data); Scenario *scenario = p_instance->scenario; ERR_FAIL_COND_V(!scenario, true); - VisualServerRaster::redraw_request(); //update, so it updates in editor + RenderingServerRaster::redraw_request(); //update, so it updates in editor if (p_step == 0) { - if (!VSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) { + if (!RSG::scene_render->reflection_probe_instance_begin_render(reflection_probe->instance, scenario->reflection_atlas)) { return true; //all full } } @@ -2297,9 +2297,9 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int Vector3(0, -1, 0) }; - Vector3 extents = VSG::storage->reflection_probe_get_extents(p_instance->base); - Vector3 origin_offset = VSG::storage->reflection_probe_get_origin_offset(p_instance->base); - float max_distance = VSG::storage->reflection_probe_get_origin_max_distance(p_instance->base); + Vector3 extents = RSG::storage->reflection_probe_get_extents(p_instance->base); + Vector3 origin_offset = RSG::storage->reflection_probe_get_origin_offset(p_instance->base); + float max_distance = RSG::storage->reflection_probe_get_origin_max_distance(p_instance->base); Vector3 edge = view_normals[p_step] * extents; float distance = ABS(view_normals[p_step].dot(edge) - view_normals[p_step].dot(origin_offset)); //distance from origin offset to actual view distance limit @@ -2317,26 +2317,26 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int RID shadow_atlas; - bool use_shadows = VSG::storage->reflection_probe_renders_shadows(p_instance->base); + bool use_shadows = RSG::storage->reflection_probe_renders_shadows(p_instance->base); if (use_shadows) { shadow_atlas = scenario->reflection_probe_shadow_atlas; } RENDER_TIMESTAMP("Render Reflection Probe, Step " + itos(p_step)); - _prepare_scene(xform, cm, false, RID(), RID(), VSG::storage->reflection_probe_get_cull_mask(p_instance->base), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, use_shadows); + _prepare_scene(xform, cm, false, RID(), RID(), RSG::storage->reflection_probe_get_cull_mask(p_instance->base), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, use_shadows); _render_scene(RID(), xform, cm, false, RID(), RID(), p_instance->scenario->self, shadow_atlas, reflection_probe->instance, p_step); } else { //do roughness postprocess step until it believes it's done RENDER_TIMESTAMP("Post-Process Reflection Probe, Step " + itos(p_step)); - return VSG::scene_render->reflection_probe_instance_postprocess_step(reflection_probe->instance); + return RSG::scene_render->reflection_probe_instance_postprocess_step(reflection_probe->instance); } return false; } -void VisualServerScene::render_probes() { +void RenderingServerScene::render_probes() { /* REFLECTION PROBES */ @@ -2349,9 +2349,9 @@ void VisualServerScene::render_probes() { SelfList<InstanceReflectionProbeData> *next = ref_probe->next(); RID base = ref_probe->self()->owner->base; - switch (VSG::storage->reflection_probe_get_update_mode(base)) { + switch (RSG::storage->reflection_probe_get_update_mode(base)) { - case VS::REFLECTION_PROBE_UPDATE_ONCE: { + case RS::REFLECTION_PROBE_UPDATE_ONCE: { if (busy) //already rendering something break; @@ -2364,7 +2364,7 @@ void VisualServerScene::render_probes() { busy = true; //do not render another one of this kind } break; - case VS::REFLECTION_PROBE_UPDATE_ALWAYS: { + case RS::REFLECTION_PROBE_UPDATE_ALWAYS: { int step = 0; bool done = false; @@ -2422,16 +2422,16 @@ void VisualServerScene::render_probes() { if ( instance_caches[idx] != instance_light->instance || - cache->has_shadow != VSG::storage->light_has_shadow(instance->base) || - cache->type != VSG::storage->light_get_type(instance->base) || + cache->has_shadow != RSG::storage->light_has_shadow(instance->base) || + cache->type != RSG::storage->light_get_type(instance->base) || cache->transform != instance->transform || - cache->color != VSG::storage->light_get_color(instance->base) || - cache->energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY) || - cache->bake_energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY) || - cache->radius != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE) || - cache->attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION) || - cache->spot_angle != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE) || - cache->spot_attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION)) { + cache->color != RSG::storage->light_get_color(instance->base) || + cache->energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY) || + cache->bake_energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY) || + cache->radius != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE) || + cache->attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION) || + cache->spot_angle != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE) || + cache->spot_attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION)) { cache_dirty = true; } } @@ -2456,16 +2456,16 @@ void VisualServerScene::render_probes() { if ( instance_caches[idx] != instance_light->instance || - cache->has_shadow != VSG::storage->light_has_shadow(instance->base) || - cache->type != VSG::storage->light_get_type(instance->base) || + cache->has_shadow != RSG::storage->light_has_shadow(instance->base) || + cache->type != RSG::storage->light_get_type(instance->base) || cache->transform != instance->transform || - cache->color != VSG::storage->light_get_color(instance->base) || - cache->energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY) || - cache->bake_energy != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY) || - cache->radius != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE) || - cache->attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION) || - cache->spot_angle != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE) || - cache->spot_attenuation != VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION)) { + cache->color != RSG::storage->light_get_color(instance->base) || + cache->energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY) || + cache->bake_energy != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY) || + cache->radius != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE) || + cache->attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION) || + cache->spot_angle != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE) || + cache->spot_attenuation != RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION)) { cache_dirty = true; } } @@ -2480,7 +2480,7 @@ void VisualServerScene::render_probes() { cache_count = idx; } - bool update_lights = VSG::scene_render->gi_probe_needs_update(probe->probe_instance); + bool update_lights = RSG::scene_render->gi_probe_needs_update(probe->probe_instance); if (cache_dirty) { probe->light_cache.resize(cache_count); @@ -2501,16 +2501,16 @@ void VisualServerScene::render_probes() { InstanceGIProbeData::LightCache *cache = &caches[idx]; instance_caches[idx] = instance_light->instance; - cache->has_shadow = VSG::storage->light_has_shadow(instance->base); - cache->type = VSG::storage->light_get_type(instance->base); + cache->has_shadow = RSG::storage->light_has_shadow(instance->base); + cache->type = RSG::storage->light_get_type(instance->base); cache->transform = instance->transform; - cache->color = VSG::storage->light_get_color(instance->base); - cache->energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY); - cache->bake_energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY); - cache->radius = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE); - cache->attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION); - cache->spot_angle = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE); - cache->spot_attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION); + cache->color = RSG::storage->light_get_color(instance->base); + cache->energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY); + cache->bake_energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY); + cache->radius = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE); + cache->attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION); + cache->spot_angle = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE); + cache->spot_attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION); idx++; } @@ -2524,16 +2524,16 @@ void VisualServerScene::render_probes() { InstanceGIProbeData::LightCache *cache = &caches[idx]; instance_caches[idx] = instance_light->instance; - cache->has_shadow = VSG::storage->light_has_shadow(instance->base); - cache->type = VSG::storage->light_get_type(instance->base); + cache->has_shadow = RSG::storage->light_has_shadow(instance->base); + cache->type = RSG::storage->light_get_type(instance->base); cache->transform = instance->transform; - cache->color = VSG::storage->light_get_color(instance->base); - cache->energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ENERGY); - cache->bake_energy = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_INDIRECT_ENERGY); - cache->radius = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_RANGE); - cache->attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_ATTENUATION); - cache->spot_angle = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ANGLE); - cache->spot_attenuation = VSG::storage->light_get_param(instance->base, VS::LIGHT_PARAM_SPOT_ATTENUATION); + cache->color = RSG::storage->light_get_color(instance->base); + cache->energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ENERGY); + cache->bake_energy = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_INDIRECT_ENERGY); + cache->radius = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_RANGE); + cache->attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_ATTENUATION); + cache->spot_angle = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ANGLE); + cache->spot_attenuation = RSG::storage->light_get_param(instance->base, RS::LIGHT_PARAM_SPOT_ATTENUATION); idx++; } @@ -2571,7 +2571,7 @@ void VisualServerScene::render_probes() { } } - VSG::scene_render->gi_probe_update(probe->probe_instance, update_lights, probe->light_instances, instance_cull_count, (RasterizerScene::InstanceBase **)instance_cull_result); + RSG::scene_render->gi_probe_update(probe->probe_instance, update_lights, probe->light_instances, instance_cull_count, (RasterizerScene::InstanceBase **)instance_cull_result); gi_probe_update_list.remove(gi_probe); @@ -2579,7 +2579,7 @@ void VisualServerScene::render_probes() { } } -void VisualServerScene::_update_dirty_instance(Instance *p_instance) { +void RenderingServerScene::_update_dirty_instance(Instance *p_instance) { if (p_instance->update_aabb) { _update_instance_aabb(p_instance); @@ -2590,20 +2590,20 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { p_instance->instance_increase_version(); if (p_instance->base.is_valid()) { - VSG::storage->base_update_dependency(p_instance->base, p_instance); + RSG::storage->base_update_dependency(p_instance->base, p_instance); } if (p_instance->material_override.is_valid()) { - VSG::storage->material_update_dependency(p_instance->material_override, p_instance); + RSG::storage->material_update_dependency(p_instance->material_override, p_instance); } - if (p_instance->base_type == VS::INSTANCE_MESH) { + if (p_instance->base_type == RS::INSTANCE_MESH) { //remove materials no longer used and un-own them - int new_mat_count = VSG::storage->mesh_get_surface_count(p_instance->base); + int new_mat_count = RSG::storage->mesh_get_surface_count(p_instance->base); p_instance->materials.resize(new_mat_count); - int new_blend_shape_count = VSG::storage->mesh_get_blend_shape_count(p_instance->base); + int new_blend_shape_count = RSG::storage->mesh_get_blend_shape_count(p_instance->base); if (new_blend_shape_count != p_instance->blend_values.size()) { p_instance->blend_values.resize(new_blend_shape_count); for (int i = 0; i < new_blend_shape_count; i++) { @@ -2612,21 +2612,21 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { } } - if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) { + if ((1 << p_instance->base_type) & RS::INSTANCE_GEOMETRY_MASK) { InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data); bool can_cast_shadows = true; bool is_animated = false; - if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) { + if (p_instance->cast_shadows == RS::SHADOW_CASTING_SETTING_OFF) { can_cast_shadows = false; } else if (p_instance->material_override.is_valid()) { - can_cast_shadows = VSG::storage->material_casts_shadows(p_instance->material_override); - is_animated = VSG::storage->material_is_animated(p_instance->material_override); + can_cast_shadows = RSG::storage->material_casts_shadows(p_instance->material_override); + is_animated = RSG::storage->material_is_animated(p_instance->material_override); } else { - if (p_instance->base_type == VS::INSTANCE_MESH) { + if (p_instance->base_type == RS::INSTANCE_MESH) { RID mesh = p_instance->base; if (mesh.is_valid()) { @@ -2634,21 +2634,21 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { for (int i = 0; i < p_instance->materials.size(); i++) { - RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : VSG::storage->mesh_surface_get_material(mesh, i); + RID mat = p_instance->materials[i].is_valid() ? p_instance->materials[i] : RSG::storage->mesh_surface_get_material(mesh, i); if (!mat.is_valid()) { cast_shadows = true; } else { - if (VSG::storage->material_casts_shadows(mat)) { + if (RSG::storage->material_casts_shadows(mat)) { cast_shadows = true; } - if (VSG::storage->material_is_animated(mat)) { + if (RSG::storage->material_is_animated(mat)) { is_animated = true; } - VSG::storage->material_update_dependency(mat, p_instance); + RSG::storage->material_update_dependency(mat, p_instance); } } @@ -2657,30 +2657,30 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { } } - } else if (p_instance->base_type == VS::INSTANCE_MULTIMESH) { - RID mesh = VSG::storage->multimesh_get_mesh(p_instance->base); + } else if (p_instance->base_type == RS::INSTANCE_MULTIMESH) { + RID mesh = RSG::storage->multimesh_get_mesh(p_instance->base); if (mesh.is_valid()) { bool cast_shadows = false; - int sc = VSG::storage->mesh_get_surface_count(mesh); + int sc = RSG::storage->mesh_get_surface_count(mesh); for (int i = 0; i < sc; i++) { - RID mat = VSG::storage->mesh_surface_get_material(mesh, i); + RID mat = RSG::storage->mesh_surface_get_material(mesh, i); if (!mat.is_valid()) { cast_shadows = true; } else { - if (VSG::storage->material_casts_shadows(mat)) { + if (RSG::storage->material_casts_shadows(mat)) { cast_shadows = true; } - if (VSG::storage->material_is_animated(mat)) { + if (RSG::storage->material_is_animated(mat)) { is_animated = true; } - VSG::storage->material_update_dependency(mat, p_instance); + RSG::storage->material_update_dependency(mat, p_instance); } } @@ -2688,52 +2688,52 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { can_cast_shadows = false; } - VSG::storage->base_update_dependency(mesh, p_instance); + RSG::storage->base_update_dependency(mesh, p_instance); } - } else if (p_instance->base_type == VS::INSTANCE_IMMEDIATE) { + } else if (p_instance->base_type == RS::INSTANCE_IMMEDIATE) { - RID mat = VSG::storage->immediate_get_material(p_instance->base); + RID mat = RSG::storage->immediate_get_material(p_instance->base); - can_cast_shadows = !mat.is_valid() || VSG::storage->material_casts_shadows(mat); + can_cast_shadows = !mat.is_valid() || RSG::storage->material_casts_shadows(mat); - if (mat.is_valid() && VSG::storage->material_is_animated(mat)) { + if (mat.is_valid() && RSG::storage->material_is_animated(mat)) { is_animated = true; } if (mat.is_valid()) { - VSG::storage->material_update_dependency(mat, p_instance); + RSG::storage->material_update_dependency(mat, p_instance); } - } else if (p_instance->base_type == VS::INSTANCE_PARTICLES) { + } else if (p_instance->base_type == RS::INSTANCE_PARTICLES) { bool cast_shadows = false; - int dp = VSG::storage->particles_get_draw_passes(p_instance->base); + int dp = RSG::storage->particles_get_draw_passes(p_instance->base); for (int i = 0; i < dp; i++) { - RID mesh = VSG::storage->particles_get_draw_pass_mesh(p_instance->base, i); + RID mesh = RSG::storage->particles_get_draw_pass_mesh(p_instance->base, i); if (!mesh.is_valid()) continue; - int sc = VSG::storage->mesh_get_surface_count(mesh); + int sc = RSG::storage->mesh_get_surface_count(mesh); for (int j = 0; j < sc; j++) { - RID mat = VSG::storage->mesh_surface_get_material(mesh, j); + RID mat = RSG::storage->mesh_surface_get_material(mesh, j); if (!mat.is_valid()) { cast_shadows = true; } else { - if (VSG::storage->material_casts_shadows(mat)) { + if (RSG::storage->material_casts_shadows(mat)) { cast_shadows = true; } - if (VSG::storage->material_is_animated(mat)) { + if (RSG::storage->material_is_animated(mat)) { is_animated = true; } - VSG::storage->material_update_dependency(mat, p_instance); + RSG::storage->material_update_dependency(mat, p_instance); } } } @@ -2758,7 +2758,7 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { } if (p_instance->skeleton.is_valid()) { - VSG::storage->skeleton_update_dependency(p_instance->skeleton, p_instance); + RSG::storage->skeleton_update_dependency(p_instance->skeleton, p_instance); } p_instance->clean_up_dependencies(); @@ -2772,9 +2772,9 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { p_instance->update_dependencies = false; } -void VisualServerScene::update_dirty_instances() { +void RenderingServerScene::update_dirty_instances() { - VSG::storage->update_dirty_resources(); + RSG::storage->update_dirty_resources(); while (_instance_update_list.first()) { @@ -2782,7 +2782,7 @@ void VisualServerScene::update_dirty_instances() { } } -bool VisualServerScene::free(RID p_rid) { +bool RenderingServerScene::free(RID p_rid) { if (camera_owner.owns(p_rid)) { @@ -2798,8 +2798,8 @@ bool VisualServerScene::free(RID p_rid) { while (scenario->instances.first()) { instance_set_scenario(scenario->instances.first()->self()->self, RID()); } - VSG::scene_render->free(scenario->reflection_probe_shadow_atlas); - VSG::scene_render->free(scenario->reflection_atlas); + RSG::scene_render->free(scenario->reflection_probe_shadow_atlas); + RSG::scene_render->free(scenario->reflection_atlas); scenario_owner.free(p_rid); memdelete(scenario); @@ -2827,13 +2827,13 @@ bool VisualServerScene::free(RID p_rid) { return true; } -VisualServerScene *VisualServerScene::singleton = NULL; +RenderingServerScene *RenderingServerScene::singleton = nullptr; -VisualServerScene::VisualServerScene() { +RenderingServerScene::RenderingServerScene() { render_pass = 1; singleton = this; } -VisualServerScene::~VisualServerScene() { +RenderingServerScene::~RenderingServerScene() { } diff --git a/servers/visual/visual_server_scene.h b/servers/rendering/rendering_server_scene.h index 8dbd60d3ff..41641b7c75 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/rendering/rendering_server_scene.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_scene.h */ +/* rendering_server_scene.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,7 +31,7 @@ #ifndef VISUALSERVERSCENE_H #define VISUALSERVERSCENE_H -#include "servers/visual/rasterizer.h" +#include "servers/rendering/rasterizer.h" #include "core/math/geometry.h" #include "core/math/octree.h" @@ -41,7 +41,7 @@ #include "core/self_list.h" #include "servers/arvr/arvr_interface.h" -class VisualServerScene { +class RenderingServerScene { public: enum { @@ -55,7 +55,7 @@ public: uint64_t render_pass; - static VisualServerScene *singleton; + static RenderingServerScene *singleton; /* CAMERA API */ @@ -109,7 +109,7 @@ public: struct Scenario { - VS::ScenarioDebugMode debug; + RS::ScenarioDebugMode debug; RID self; Octree<Instance, true> octree; @@ -123,7 +123,7 @@ public: SelfList<Instance>::List instances; - Scenario() { debug = VS::SCENARIO_DEBUG_DISABLED; } + Scenario() { debug = RS::SCENARIO_DEBUG_DISABLED; } }; mutable RID_PtrOwner<Scenario> scenario_owner; @@ -133,7 +133,7 @@ public: virtual RID scenario_create(); - virtual void scenario_set_debug(RID p_scenario, VS::ScenarioDebugMode p_debug_mode); + virtual void scenario_set_debug(RID p_scenario, RS::ScenarioDebugMode p_debug_mode); virtual void scenario_set_environment(RID p_scenario, RID p_environment); virtual void scenario_set_camera_effects(RID p_scenario, RID p_fx); virtual void scenario_set_fallback_environment(RID p_scenario, RID p_environment); @@ -196,7 +196,7 @@ public: update_item(this) { octree_id = 0; - scenario = NULL; + scenario = nullptr; update_aabb = false; update_dependencies = false; @@ -213,9 +213,9 @@ public: last_render_pass = 0; last_frame_pass = 0; version = 1; - base_data = NULL; + base_data = nullptr; - custom_aabb = NULL; + custom_aabb = nullptr; } ~Instance() { @@ -301,9 +301,9 @@ public: InstanceLightData() { shadow_dirty = true; - D = NULL; + D = nullptr; last_version = 0; - baked_light = NULL; + baked_light = nullptr; } }; @@ -323,7 +323,7 @@ public: struct LightCache { - VS::LightType type; + RS::LightType type; Transform transform; Color color; float energy; @@ -406,8 +406,8 @@ public: virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const; - virtual void instance_geometry_set_flag(RID p_instance, VS::InstanceFlags p_flags, bool p_enabled); - virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting); + virtual void instance_geometry_set_flag(RID p_instance, RS::InstanceFlags p_flags, bool p_enabled); + virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, RS::ShadowCastingSetting p_shadow_casting_setting); virtual void instance_geometry_set_material_override(RID p_instance, RID p_material); virtual void instance_geometry_set_draw_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin); @@ -433,8 +433,8 @@ public: bool free(RID p_rid); - VisualServerScene(); - virtual ~VisualServerScene(); + RenderingServerScene(); + virtual ~RenderingServerScene(); }; #endif // VISUALSERVERSCENE_H diff --git a/servers/visual/visual_server_viewport.cpp b/servers/rendering/rendering_server_viewport.cpp index 555d5f99c7..aa65101ddf 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/rendering/rendering_server_viewport.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_viewport.cpp */ +/* rendering_server_viewport.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "visual_server_viewport.h" +#include "rendering_server_viewport.h" #include "core/project_settings.h" -#include "visual_server_canvas.h" -#include "visual_server_globals.h" -#include "visual_server_scene.h" +#include "rendering_server_canvas.h" +#include "rendering_server_globals.h" +#include "rendering_server_scene.h" -static Transform2D _canvas_get_transform(VisualServerViewport::Viewport *p_viewport, VisualServerCanvas::Canvas *p_canvas, VisualServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) { +static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_viewport, RenderingServerCanvas::Canvas *p_canvas, RenderingServerViewport::Viewport::CanvasData *p_canvas_data, const Vector2 &p_vp_size) { Transform2D xf = p_viewport->global_transform; @@ -47,7 +47,7 @@ static Transform2D _canvas_get_transform(VisualServerViewport::Viewport *p_viewp xf = xf * p_canvas_data->transform; - if (scale != 1.0 && !VSG::canvas->disable_scale) { + if (scale != 1.0 && !RSG::canvas->disable_scale) { Vector2 pivot = p_vp_size * 0.5; Transform2D xfpivot; xfpivot.set_origin(pivot); @@ -62,61 +62,61 @@ static Transform2D _canvas_get_transform(VisualServerViewport::Viewport *p_viewp return xf; } -void VisualServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_eye) { +void RenderingServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_eye) { RENDER_TIMESTAMP(">Begin Rendering 3D Scene"); Ref<ARVRInterface> arvr_interface; - if (ARVRServer::get_singleton() != NULL) { + if (ARVRServer::get_singleton() != nullptr) { arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); } if (p_viewport->use_arvr && arvr_interface.is_valid()) { - VSG::scene->render_camera(p_viewport->render_buffers, arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); + RSG::scene->render_camera(p_viewport->render_buffers, arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); } else { - VSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); + RSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas); } RENDER_TIMESTAMP("<End Rendering 3D Scene"); } -void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye) { +void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye) { /* Camera should always be BEFORE any other 3D */ bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front int scenario_canvas_max_layer = 0; - Color bgcolor = VSG::storage->get_default_clear_color(); + Color bgcolor = RSG::storage->get_default_clear_color(); - if (!p_viewport->hide_canvas && !p_viewport->disable_environment && VSG::scene->scenario_owner.owns(p_viewport->scenario)) { + if (!p_viewport->hide_canvas && !p_viewport->disable_environment && RSG::scene->scenario_owner.owns(p_viewport->scenario)) { - VisualServerScene::Scenario *scenario = VSG::scene->scenario_owner.getornull(p_viewport->scenario); + RenderingServerScene::Scenario *scenario = RSG::scene->scenario_owner.getornull(p_viewport->scenario); ERR_FAIL_COND(!scenario); - if (VSG::scene_render->is_environment(scenario->environment)) { - scenario_draw_canvas_bg = VSG::scene_render->environment_get_background(scenario->environment) == VS::ENV_BG_CANVAS; + if (RSG::scene_render->is_environment(scenario->environment)) { + scenario_draw_canvas_bg = RSG::scene_render->environment_get_background(scenario->environment) == RS::ENV_BG_CANVAS; - scenario_canvas_max_layer = VSG::scene_render->environment_get_canvas_max_layer(scenario->environment); + scenario_canvas_max_layer = RSG::scene_render->environment_get_canvas_max_layer(scenario->environment); } } - bool can_draw_3d = VSG::scene->camera_owner.owns(p_viewport->camera); + bool can_draw_3d = RSG::scene->camera_owner.owns(p_viewport->camera); - if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) { + if (p_viewport->clear_mode != RS::VIEWPORT_CLEAR_NEVER) { if (p_viewport->transparent_bg) { bgcolor = Color(0, 0, 0, 0); } - if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) { - p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER; + if (p_viewport->clear_mode == RS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) { + p_viewport->clear_mode = RS::VIEWPORT_CLEAR_NEVER; } } if ((scenario_draw_canvas_bg || can_draw_3d) && !p_viewport->render_buffers.is_valid()) { //wants to draw 3D but there is no render buffer, create - p_viewport->render_buffers = VSG::scene_render->render_buffers_create(); - VSG::scene_render->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, p_viewport->size.width, p_viewport->size.height, p_viewport->msaa); + p_viewport->render_buffers = RSG::scene_render->render_buffers_create(); + RSG::scene_render->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, p_viewport->size.width, p_viewport->size.height, p_viewport->msaa); } - VSG::storage->render_target_request_clear(p_viewport->render_target, bgcolor); + RSG::storage->render_target_request_clear(p_viewport->render_target, bgcolor); if (!scenario_draw_canvas_bg && can_draw_3d) { _draw_3d(p_viewport, p_eye); @@ -128,9 +128,9 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E Map<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map; Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y); - RasterizerCanvas::Light *lights = NULL; - RasterizerCanvas::Light *lights_with_shadow = NULL; - RasterizerCanvas::Light *lights_with_mask = NULL; + RasterizerCanvas::Light *lights = nullptr; + RasterizerCanvas::Light *lights_with_shadow = nullptr; + RasterizerCanvas::Light *lights_with_mask = nullptr; Rect2 shadow_rect; int light_count = 0; @@ -138,7 +138,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E RENDER_TIMESTAMP("Cull Canvas Lights"); for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas); + RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); @@ -149,7 +149,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E RasterizerCanvas::Light *cl = F->get(); if (cl->enabled && cl->texture.is_valid()) { //not super efficient.. - Size2 tsize = VSG::storage->texture_size_with_proxy(cl->texture); + Size2 tsize = RSG::storage->texture_size_with_proxy(cl->texture); tsize *= cl->scale; Vector2 offset = tsize / 2.0; @@ -160,7 +160,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E cl->filter_next_ptr = lights; lights = cl; - // cl->texture_cache = NULL; + // cl->texture_cache = nullptr; Transform2D scale; scale.scale(cl->rect_cache.size); scale.elements[2] = cl->rect_cache.position; @@ -169,7 +169,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E if (cl->use_shadow) { cl->shadows_next_ptr = lights_with_shadow; - if (lights_with_shadow == NULL) { + if (lights_with_shadow == nullptr) { shadow_rect = cl->xform_cache.xform(cl->rect_cache); } else { shadow_rect = shadow_rect.merge(cl->xform_cache.xform(cl->rect_cache)); @@ -177,7 +177,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E lights_with_shadow = cl; cl->radius_cache = cl->rect_cache.size.length(); } - if (cl->mode == VS::CANVAS_LIGHT_MODE_MASK) { + if (cl->mode == RS::CANVAS_LIGHT_MODE_MASK) { cl->mask_next_ptr = lights_with_mask; lights_with_mask = cl; } @@ -186,7 +186,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E } //guess this is not needed, but keeping because it may be - //VSG::canvas_render->light_internal_update(cl->light_internal, cl); + //RSG::canvas_render->light_internal_update(cl->light_internal, cl); } } @@ -196,7 +196,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E if (lights_with_shadow) { //update shadows if any - RasterizerCanvas::LightOccluderInstance *occluders = NULL; + RasterizerCanvas::LightOccluderInstance *occluders = nullptr; RENDER_TIMESTAMP(">Render 2D Shadows"); RENDER_TIMESTAMP("Cull Occluders"); @@ -204,7 +204,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E //make list of occluders for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) { - VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas); + RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get().canvas); Transform2D xf = _canvas_get_transform(p_viewport, canvas, &E->get(), clip_rect.size); for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) { @@ -226,17 +226,17 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E RENDER_TIMESTAMP("Render Shadow"); - VSG::canvas_render->light_update_shadow(light->light_internal, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders); + RSG::canvas_render->light_update_shadow(light->light_internal, light->xform_cache.affine_inverse(), light->item_shadow_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders); light = light->shadows_next_ptr; } - //VSG::canvas_render->reset_canvas(); + //RSG::canvas_render->reset_canvas(); RENDER_TIMESTAMP("<End rendering 2D Shadows"); } if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().get_layer() > scenario_canvas_max_layer) { if (!can_draw_3d) { - VSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); + RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { _draw_3d(p_viewport, p_eye); } @@ -245,11 +245,11 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) { - VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get()->canvas); + RenderingServerCanvas::Canvas *canvas = static_cast<RenderingServerCanvas::Canvas *>(E->get()->canvas); Transform2D xform = _canvas_get_transform(p_viewport, canvas, E->get(), clip_rect.size); - RasterizerCanvas::Light *canvas_lights = NULL; + RasterizerCanvas::Light *canvas_lights = nullptr; RasterizerCanvas::Light *ptr = lights; while (ptr) { @@ -260,12 +260,12 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E ptr = ptr->filter_next_ptr; } - VSG::canvas->render_canvas(p_viewport->render_target, canvas, xform, canvas_lights, lights_with_mask, clip_rect); + RSG::canvas->render_canvas(p_viewport->render_target, canvas, xform, canvas_lights, lights_with_mask, clip_rect); i++; if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) { if (!can_draw_3d) { - VSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); + RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { _draw_3d(p_viewport, p_eye); } @@ -276,28 +276,28 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E if (scenario_draw_canvas_bg) { if (!can_draw_3d) { - VSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); + RSG::scene->render_empty_scene(p_viewport->render_buffers, p_viewport->scenario, p_viewport->shadow_atlas); } else { _draw_3d(p_viewport, p_eye); } } - //VSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow); + //RSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow); } - if (VSG::storage->render_target_is_clear_requested(p_viewport->render_target)) { + if (RSG::storage->render_target_is_clear_requested(p_viewport->render_target)) { //was never cleared in the end, force clear it - VSG::storage->render_target_do_clear_request(p_viewport->render_target); + RSG::storage->render_target_do_clear_request(p_viewport->render_target); } } -void VisualServerViewport::draw_viewports() { +void RenderingServerViewport::draw_viewports() { #if 0 // get our arvr interface in case we need it Ref<ARVRInterface> arvr_interface; - if (ARVRServer::get_singleton() != NULL) { + if (ARVRServer::get_singleton() != nullptr) { arvr_interface = ARVRServer::get_singleton()->get_primary_interface(); // process all our active interfaces @@ -323,7 +323,7 @@ void VisualServerViewport::draw_viewports() { Viewport *vp = active_viewports[i]; - if (vp->update_mode == VS::VIEWPORT_UPDATE_DISABLED) + if (vp->update_mode == RS::VIEWPORT_UPDATE_DISABLED) continue; if (!vp->render_target.is_valid()) { @@ -333,15 +333,15 @@ void VisualServerViewport::draw_viewports() { bool visible = vp->viewport_to_screen_rect != Rect2(); - if (vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) { + if (vp->update_mode == RS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) { visible = true; } - if (vp->update_mode == VS::VIEWPORT_UPDATE_WHEN_VISIBLE && VSG::storage->render_target_was_used(vp->render_target)) { + if (vp->update_mode == RS::VIEWPORT_UPDATE_WHEN_VISIBLE && RSG::storage->render_target_was_used(vp->render_target)) { visible = true; } - if (vp->update_mode == VS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE) { + if (vp->update_mode == RS::VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE) { Viewport *parent = viewport_owner.getornull(vp->parent); if (parent && parent->last_pass == draw_viewports_pass) { visible = true; @@ -365,21 +365,21 @@ void VisualServerViewport::draw_viewports() { RENDER_TIMESTAMP(">Rendering Viewport " + itos(i)); - VSG::storage->render_target_set_as_unused(vp->render_target); + RSG::storage->render_target_set_as_unused(vp->render_target); #if 0 if (vp->use_arvr && arvr_interface.is_valid()) { // override our size, make sure it matches our required size vp->size = arvr_interface->get_render_targetsize(); - VSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y); + RSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y); // render mono or left eye first ARVRInterface::Eyes leftOrMono = arvr_interface->is_stereo() ? ARVRInterface::EYE_LEFT : ARVRInterface::EYE_MONO; // check for an external texture destination for our left eye/mono - VSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(leftOrMono)); + RSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(leftOrMono)); // set our render target as current - VSG::rasterizer->set_current_render_target(vp->render_target); + RSG::rasterizer->set_current_render_target(vp->render_target); // and draw left eye/mono _draw_viewport(vp, leftOrMono); @@ -388,10 +388,10 @@ void VisualServerViewport::draw_viewports() { // render right eye if (leftOrMono == ARVRInterface::EYE_LEFT) { // check for an external texture destination for our right eye - VSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(ARVRInterface::EYE_RIGHT)); + RSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(ARVRInterface::EYE_RIGHT)); // commit for eye may have changed the render target - VSG::rasterizer->set_current_render_target(vp->render_target); + RSG::rasterizer->set_current_render_target(vp->render_target); _draw_viewport(vp, ARVRInterface::EYE_RIGHT); arvr_interface->commit_for_eye(ARVRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect); @@ -402,23 +402,23 @@ void VisualServerViewport::draw_viewports() { } else { #endif { - VSG::storage->render_target_set_external_texture(vp->render_target, 0); + RSG::storage->render_target_set_external_texture(vp->render_target, 0); - VSG::scene_render->set_debug_draw_mode(vp->debug_draw); - VSG::storage->render_info_begin_capture(); + RSG::scene_render->set_debug_draw_mode(vp->debug_draw); + RSG::storage->render_info_begin_capture(); // render standard mono camera _draw_viewport(vp); - VSG::storage->render_info_end_capture(); - vp->render_info[VS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_OBJECTS_IN_FRAME); - vp->render_info[VS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_VERTICES_IN_FRAME); - vp->render_info[VS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME); - vp->render_info[VS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME); - vp->render_info[VS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME); - vp->render_info[VS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_DRAW_CALLS_IN_FRAME); + RSG::storage->render_info_end_capture(); + vp->render_info[RS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_OBJECTS_IN_FRAME); + vp->render_info[RS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_VERTICES_IN_FRAME); + vp->render_info[RS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_MATERIAL_CHANGES_IN_FRAME); + vp->render_info[RS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_SHADER_CHANGES_IN_FRAME); + vp->render_info[RS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_SURFACE_CHANGES_IN_FRAME); + vp->render_info[RS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = RSG::storage->get_captured_render_info(RS::INFO_DRAW_CALLS_IN_FRAME); - if (vp->viewport_to_screen != DisplayServer::INVALID_WINDOW_ID && (!vp->viewport_render_direct_to_screen || !VSG::rasterizer->is_low_end())) { + if (vp->viewport_to_screen != DisplayServer::INVALID_WINDOW_ID && (!vp->viewport_render_direct_to_screen || !RSG::rasterizer->is_low_end())) { //copy to screen if set as such Rasterizer::BlitToScreen blit; blit.render_target = vp->render_target; @@ -437,24 +437,24 @@ void VisualServerViewport::draw_viewports() { } } - if (vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) { - vp->update_mode = VS::VIEWPORT_UPDATE_DISABLED; + if (vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) { + vp->update_mode = RS::VIEWPORT_UPDATE_DISABLED; } RENDER_TIMESTAMP("<Rendering Viewport " + itos(i)); } - VSG::scene_render->set_debug_draw_mode(VS::VIEWPORT_DEBUG_DRAW_DISABLED); + RSG::scene_render->set_debug_draw_mode(RS::VIEWPORT_DEBUG_DRAW_DISABLED); RENDER_TIMESTAMP("<Render Viewports"); //this needs to be called to make screen swapping more efficient - VSG::rasterizer->prepare_for_blitting_render_targets(); + RSG::rasterizer->prepare_for_blitting_render_targets(); for (Map<int, Vector<Rasterizer::BlitToScreen>>::Element *E = blit_to_screen_list.front(); E; E = E->next()) { - VSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size()); + RSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size()); } } -RID VisualServerViewport::viewport_create() { +RID RenderingServerViewport::viewport_create() { Viewport *viewport = memnew(Viewport); @@ -463,21 +463,21 @@ RID VisualServerViewport::viewport_create() { viewport->self = rid; viewport->hide_scenario = false; viewport->hide_canvas = false; - viewport->render_target = VSG::storage->render_target_create(); - viewport->shadow_atlas = VSG::scene_render->shadow_atlas_create(); + viewport->render_target = RSG::storage->render_target_create(); + viewport->shadow_atlas = RSG::scene_render->shadow_atlas_create(); viewport->viewport_render_direct_to_screen = false; return rid; } -void VisualServerViewport::viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) { +void RenderingServerViewport::viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->use_arvr = p_use_arvr; } -void VisualServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) { +void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) { ERR_FAIL_COND(p_width < 0 && p_height < 0); @@ -485,18 +485,18 @@ void VisualServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_ ERR_FAIL_COND(!viewport); viewport->size = Size2(p_width, p_height); - VSG::storage->render_target_set_size(viewport->render_target, p_width, p_height); + RSG::storage->render_target_set_size(viewport->render_target, p_width, p_height); if (viewport->render_buffers.is_valid()) { if (p_width == 0 || p_height == 0) { - VSG::scene_render->free(viewport->render_buffers); + RSG::scene_render->free(viewport->render_buffers); viewport->render_buffers = RID(); } else { - VSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa); + RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, viewport->msaa); } } } -void VisualServerViewport::viewport_set_active(RID p_viewport, bool p_active) { +void RenderingServerViewport::viewport_set_active(RID p_viewport, bool p_active) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -509,7 +509,7 @@ void VisualServerViewport::viewport_set_active(RID p_viewport, bool p_active) { } } -void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) { +void RenderingServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -517,7 +517,7 @@ void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_pa viewport->parent = p_parent_viewport; } -void VisualServerViewport::viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode) { +void RenderingServerViewport::viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -525,7 +525,7 @@ void VisualServerViewport::viewport_set_clear_mode(RID p_viewport, VS::ViewportC viewport->clear_mode = p_clear_mode; } -void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) { +void RenderingServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, DisplayServer::WindowID p_screen) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -533,10 +533,10 @@ void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 if (p_screen != DisplayServer::INVALID_WINDOW_ID) { // If using GLES2 we can optimize this operation by rendering directly to system_fbo // instead of rendering to fbo and copying to system_fbo after - if (VSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { + if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { - VSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y); - VSG::storage->render_target_set_position(viewport->render_target, p_rect.position.x, p_rect.position.y); + RSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y); + RSG::storage->render_target_set_position(viewport->render_target, p_rect.position.x, p_rect.position.y); } viewport->viewport_to_screen_rect = p_rect; @@ -544,10 +544,10 @@ void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 } else { // if render_direct_to_screen was used, reset size and position - if (VSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { + if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { - VSG::storage->render_target_set_position(viewport->render_target, 0, 0); - VSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y); + RSG::storage->render_target_set_position(viewport->render_target, 0, 0); + RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y); } viewport->viewport_to_screen_rect = Rect2(); @@ -555,7 +555,7 @@ void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 } } -void VisualServerViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) { +void RenderingServerViewport::viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -565,22 +565,22 @@ void VisualServerViewport::viewport_set_render_direct_to_screen(RID p_viewport, // if disabled, reset render_target size and position if (!p_enable) { - VSG::storage->render_target_set_position(viewport->render_target, 0, 0); - VSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y); + RSG::storage->render_target_set_position(viewport->render_target, 0, 0); + RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y); } - VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN, p_enable); + RSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN, p_enable); viewport->viewport_render_direct_to_screen = p_enable; // if attached to screen already, setup screen size and position, this needs to happen after setting flag to avoid an unnecessary buffer allocation - if (VSG::rasterizer->is_low_end() && viewport->viewport_to_screen_rect != Rect2() && p_enable) { + if (RSG::rasterizer->is_low_end() && viewport->viewport_to_screen_rect != Rect2() && p_enable) { - VSG::storage->render_target_set_size(viewport->render_target, viewport->viewport_to_screen_rect.size.x, viewport->viewport_to_screen_rect.size.y); - VSG::storage->render_target_set_position(viewport->render_target, viewport->viewport_to_screen_rect.position.x, viewport->viewport_to_screen_rect.position.y); + RSG::storage->render_target_set_size(viewport->render_target, viewport->viewport_to_screen_rect.size.x, viewport->viewport_to_screen_rect.size.y); + RSG::storage->render_target_set_position(viewport->render_target, viewport->viewport_to_screen_rect.position.x, viewport->viewport_to_screen_rect.position.y); } } -void VisualServerViewport::viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode) { +void RenderingServerViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -588,29 +588,29 @@ void VisualServerViewport::viewport_set_update_mode(RID p_viewport, VS::Viewport viewport->update_mode = p_mode; } -RID VisualServerViewport::viewport_get_texture(RID p_viewport) const { +RID RenderingServerViewport::viewport_get_texture(RID p_viewport) const { const Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND_V(!viewport, RID()); - return VSG::storage->render_target_get_texture(viewport->render_target); + return RSG::storage->render_target_get_texture(viewport->render_target); } -void VisualServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) { +void RenderingServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->hide_scenario = p_hide; } -void VisualServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) { +void RenderingServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->hide_canvas = p_hide; } -void VisualServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) { +void RenderingServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -618,27 +618,27 @@ void VisualServerViewport::viewport_set_disable_environment(RID p_viewport, bool viewport->disable_environment = p_disable; } -void VisualServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) { +void RenderingServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->camera = p_camera; } -void VisualServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) { +void RenderingServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->scenario = p_scenario; } -void VisualServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) { +void RenderingServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); ERR_FAIL_COND(viewport->canvas_map.has(p_canvas)); - VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas); + RenderingServerCanvas::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas); ERR_FAIL_COND(!canvas); canvas->viewports.insert(p_viewport); @@ -648,18 +648,18 @@ void VisualServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) viewport->canvas_map[p_canvas].canvas = canvas; } -void VisualServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) { +void RenderingServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); - VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas); + RenderingServerCanvas::Canvas *canvas = RSG::canvas->canvas_owner.getornull(p_canvas); ERR_FAIL_COND(!canvas); viewport->canvas_map.erase(p_canvas); canvas->viewports.erase(p_viewport); } -void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) { +void RenderingServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -667,23 +667,23 @@ void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_c ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas)); viewport->canvas_map[p_canvas].transform = p_offset; } -void VisualServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) { +void RenderingServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); - VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled); + RSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled); viewport->transparent_bg = p_enabled; } -void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) { +void RenderingServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->global_transform = p_transform; } -void VisualServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) { +void RenderingServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_canvas, int p_layer, int p_sublayer) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -693,25 +693,25 @@ void VisualServerViewport::viewport_set_canvas_stacking(RID p_viewport, RID p_ca viewport->canvas_map[p_canvas].sublayer = p_sublayer; } -void VisualServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) { +void RenderingServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); viewport->shadow_atlas_size = p_size; - VSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size); + RSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size); } -void VisualServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) { +void RenderingServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); - VSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv); + RSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv); } -void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa) { +void RenderingServerViewport::viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -721,13 +721,13 @@ void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_ } viewport->msaa = p_msaa; if (viewport->render_buffers.is_valid()) { - VSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, p_msaa); + RSG::scene_render->render_buffers_configure(viewport->render_buffers, viewport->render_target, viewport->size.width, viewport->size.height, p_msaa); } } -int VisualServerViewport::viewport_get_render_info(RID p_viewport, VS::ViewportRenderInfo p_info) { +int RenderingServerViewport::viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfo p_info) { - ERR_FAIL_INDEX_V(p_info, VS::VIEWPORT_RENDER_INFO_MAX, -1); + ERR_FAIL_INDEX_V(p_info, RS::VIEWPORT_RENDER_INFO_MAX, -1); Viewport *viewport = viewport_owner.getornull(p_viewport); if (!viewport) @@ -736,7 +736,7 @@ int VisualServerViewport::viewport_get_render_info(RID p_viewport, VS::ViewportR return viewport->render_info[p_info]; } -void VisualServerViewport::viewport_set_debug_draw(RID p_viewport, VS::ViewportDebugDraw p_draw) { +void RenderingServerViewport::viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw) { Viewport *viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -744,16 +744,16 @@ void VisualServerViewport::viewport_set_debug_draw(RID p_viewport, VS::ViewportD viewport->debug_draw = p_draw; } -bool VisualServerViewport::free(RID p_rid) { +bool RenderingServerViewport::free(RID p_rid) { if (viewport_owner.owns(p_rid)) { Viewport *viewport = viewport_owner.getornull(p_rid); - VSG::storage->free(viewport->render_target); - VSG::scene_render->free(viewport->shadow_atlas); + RSG::storage->free(viewport->render_target); + RSG::scene_render->free(viewport->shadow_atlas); if (viewport->render_buffers.is_valid()) { - VSG::scene_render->free(viewport->render_buffers); + RSG::scene_render->free(viewport->render_buffers); } while (viewport->canvas_map.front()) { @@ -772,9 +772,9 @@ bool VisualServerViewport::free(RID p_rid) { return false; } -void VisualServerViewport::set_default_clear_color(const Color &p_color) { - VSG::storage->set_default_clear_color(p_color); +void RenderingServerViewport::set_default_clear_color(const Color &p_color) { + RSG::storage->set_default_clear_color(p_color); } -VisualServerViewport::VisualServerViewport() { +RenderingServerViewport::RenderingServerViewport() { } diff --git a/servers/visual/visual_server_viewport.h b/servers/rendering/rendering_server_viewport.h index 06372376f8..f574c58d96 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/rendering/rendering_server_viewport.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_viewport.h */ +/* rendering_server_viewport.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -35,9 +35,9 @@ #include "core/self_list.h" #include "rasterizer.h" #include "servers/arvr/arvr_interface.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" -class VisualServerViewport { +class RenderingServerViewport { public: struct CanvasBase { }; @@ -53,12 +53,12 @@ public: RID camera; RID scenario; - VS::ViewportUpdateMode update_mode; + RS::ViewportUpdateMode update_mode; RID render_target; RID render_target_texture; RID render_buffers; - VS::ViewportMSAA msaa; + RS::ViewportMSAA msaa; DisplayServer::WindowID viewport_to_screen; Rect2 viewport_to_screen_rect; @@ -75,10 +75,10 @@ public: uint64_t last_pass = 0; - int render_info[VS::VIEWPORT_RENDER_INFO_MAX]; - VS::ViewportDebugDraw debug_draw; + int render_info[RS::VIEWPORT_RENDER_INFO_MAX]; + RS::ViewportDebugDraw debug_draw; - VS::ViewportClearMode clear_mode; + RS::ViewportClearMode clear_mode; bool transparent_bg; @@ -115,16 +115,16 @@ public: Map<RID, CanvasData> canvas_map; Viewport() { - update_mode = VS::VIEWPORT_UPDATE_WHEN_VISIBLE; - clear_mode = VS::VIEWPORT_CLEAR_ALWAYS; + update_mode = RS::VIEWPORT_UPDATE_WHEN_VISIBLE; + clear_mode = RS::VIEWPORT_CLEAR_ALWAYS; transparent_bg = false; disable_environment = false; viewport_to_screen = DisplayServer::INVALID_WINDOW_ID; shadow_atlas_size = 0; keep_3d_linear = false; - debug_draw = VS::VIEWPORT_DEBUG_DRAW_DISABLED; - msaa = VS::VIEWPORT_MSAA_DISABLED; - for (int i = 0; i < VS::VIEWPORT_RENDER_INFO_MAX; i++) { + debug_draw = RS::VIEWPORT_DEBUG_DRAW_DISABLED; + msaa = RS::VIEWPORT_MSAA_DISABLED; + for (int i = 0; i < RS::VIEWPORT_RENDER_INFO_MAX; i++) { render_info[i] = 0; } use_arvr = false; @@ -167,10 +167,10 @@ public: void viewport_set_active(RID p_viewport, bool p_active); void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport); - void viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode); + void viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode); void viewport_set_vflip(RID p_viewport, bool p_enable); - void viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode); + void viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode); RID viewport_get_texture(RID p_viewport) const; @@ -191,18 +191,18 @@ public: void viewport_set_shadow_atlas_size(RID p_viewport, int p_size); void viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv); - void viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa); + void viewport_set_msaa(RID p_viewport, RS::ViewportMSAA p_msaa); - virtual int viewport_get_render_info(RID p_viewport, VS::ViewportRenderInfo p_info); - virtual void viewport_set_debug_draw(RID p_viewport, VS::ViewportDebugDraw p_draw); + virtual int viewport_get_render_info(RID p_viewport, RS::ViewportRenderInfo p_info); + virtual void viewport_set_debug_draw(RID p_viewport, RS::ViewportDebugDraw p_draw); void set_default_clear_color(const Color &p_color); void draw_viewports(); bool free(RID p_rid); - VisualServerViewport(); - virtual ~VisualServerViewport() {} + RenderingServerViewport(); + virtual ~RenderingServerViewport() {} }; #endif // VISUALSERVERVIEWPORT_H diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/rendering/rendering_server_wrap_mt.cpp index 4169144fc9..aa3bf583c7 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/rendering/rendering_server_wrap_mt.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_wrap_mt.cpp */ +/* rendering_server_wrap_mt.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,43 +28,43 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "visual_server_wrap_mt.h" +#include "rendering_server_wrap_mt.h" #include "core/os/os.h" #include "core/project_settings.h" #include "servers/display_server.h" -void VisualServerWrapMT::thread_exit() { +void RenderingServerWrapMT::thread_exit() { exit = true; } -void VisualServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) { +void RenderingServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) { if (!atomic_decrement(&draw_pending)) { - visual_server->draw(p_swap_buffers, frame_step); + rendering_server->draw(p_swap_buffers, frame_step); } } -void VisualServerWrapMT::thread_flush() { +void RenderingServerWrapMT::thread_flush() { atomic_decrement(&draw_pending); } -void VisualServerWrapMT::_thread_callback(void *_instance) { +void RenderingServerWrapMT::_thread_callback(void *_instance) { - VisualServerWrapMT *vsmt = reinterpret_cast<VisualServerWrapMT *>(_instance); + RenderingServerWrapMT *vsmt = reinterpret_cast<RenderingServerWrapMT *>(_instance); vsmt->thread_loop(); } -void VisualServerWrapMT::thread_loop() { +void RenderingServerWrapMT::thread_loop() { server_thread = Thread::get_caller_id(); DisplayServer::get_singleton()->make_rendering_thread(); - visual_server->init(); + rendering_server->init(); exit = false; draw_thread_up = true; @@ -75,66 +75,66 @@ void VisualServerWrapMT::thread_loop() { command_queue.flush_all(); // flush all - visual_server->finish(); + rendering_server->finish(); } /* EVENT QUEUING */ -void VisualServerWrapMT::sync() { +void RenderingServerWrapMT::sync() { if (create_thread) { atomic_increment(&draw_pending); - command_queue.push_and_sync(this, &VisualServerWrapMT::thread_flush); + command_queue.push_and_sync(this, &RenderingServerWrapMT::thread_flush); } else { command_queue.flush_all(); //flush all pending from other threads } } -void VisualServerWrapMT::draw(bool p_swap_buffers, double frame_step) { +void RenderingServerWrapMT::draw(bool p_swap_buffers, double frame_step) { if (create_thread) { atomic_increment(&draw_pending); - command_queue.push(this, &VisualServerWrapMT::thread_draw, p_swap_buffers, frame_step); + command_queue.push(this, &RenderingServerWrapMT::thread_draw, p_swap_buffers, frame_step); } else { - visual_server->draw(p_swap_buffers, frame_step); + rendering_server->draw(p_swap_buffers, frame_step); } } -void VisualServerWrapMT::init() { +void RenderingServerWrapMT::init() { if (create_thread) { - print_verbose("VisualServerWrapMT: Creating render thread"); + print_verbose("RenderingServerWrapMT: Creating render thread"); DisplayServer::get_singleton()->release_rendering_thread(); if (create_thread) { thread = Thread::create(_thread_callback, this); - print_verbose("VisualServerWrapMT: Starting render thread"); + print_verbose("RenderingServerWrapMT: Starting render thread"); } while (!draw_thread_up) { OS::get_singleton()->delay_usec(1000); } - print_verbose("VisualServerWrapMT: Finished render thread"); + print_verbose("RenderingServerWrapMT: Finished render thread"); } else { - visual_server->init(); + rendering_server->init(); } } -void VisualServerWrapMT::finish() { +void RenderingServerWrapMT::finish() { if (thread) { - command_queue.push(this, &VisualServerWrapMT::thread_exit); + command_queue.push(this, &RenderingServerWrapMT::thread_exit); Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } else { - visual_server->finish(); + rendering_server->finish(); } sky_free_cached_ids(); @@ -163,22 +163,22 @@ void VisualServerWrapMT::finish() { canvas_occluder_polygon_free_cached_ids(); } -void VisualServerWrapMT::set_use_vsync_callback(bool p_enable) { +void RenderingServerWrapMT::set_use_vsync_callback(bool p_enable) { singleton_mt->call_set_use_vsync(p_enable); } -VisualServerWrapMT *VisualServerWrapMT::singleton_mt = NULL; +RenderingServerWrapMT *RenderingServerWrapMT::singleton_mt = nullptr; -VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread) : +RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread) : command_queue(p_create_thread) { singleton_mt = this; DisplayServer::switch_vsync_function = set_use_vsync_callback; //as this goes to another thread, make sure it goes properly - visual_server = p_contained; + rendering_server = p_contained; create_thread = p_create_thread; - thread = NULL; + thread = nullptr; draw_pending = 0; draw_thread_up = false; pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); @@ -190,8 +190,8 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_ } } -VisualServerWrapMT::~VisualServerWrapMT() { +RenderingServerWrapMT::~RenderingServerWrapMT() { - memdelete(visual_server); + memdelete(rendering_server); //finish(); } diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/rendering/rendering_server_wrap_mt.h index e043ac5214..13dad3ec18 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/rendering/rendering_server_wrap_mt.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server_wrap_mt.h */ +/* rendering_server_wrap_mt.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,17 +28,17 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VISUAL_SERVER_WRAP_MT_H -#define VISUAL_SERVER_WRAP_MT_H +#ifndef RENDERING_SERVER_WRAP_MT_H +#define RENDERING_SERVER_WRAP_MT_H #include "core/command_queue_mt.h" #include "core/os/thread.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" -class VisualServerWrapMT : public VisualServer { +class RenderingServerWrapMT : public RenderingServer { // the real visual server - mutable VisualServer *visual_server; + mutable RenderingServer *rendering_server; mutable CommandQueueMT command_queue; @@ -63,7 +63,7 @@ class VisualServerWrapMT : public VisualServer { //#define DEBUG_SYNC - static VisualServerWrapMT *singleton_mt; + static RenderingServerWrapMT *singleton_mt; #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__)); @@ -72,28 +72,28 @@ class VisualServerWrapMT : public VisualServer { #endif public: -#define ServerName VisualServer -#define ServerNameWrapMT VisualServerWrapMT -#define server_name visual_server +#define ServerName RenderingServer +#define ServerNameWrapMT RenderingServerWrapMT +#define server_name rendering_server #include "servers/server_wrap_mt_common.h" //these go pass-through, as they can be called from any thread - virtual RID texture_2d_create(const Ref<Image> &p_image) { return visual_server->texture_2d_create(p_image); } - virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, TextureLayeredType p_layered_type) { return visual_server->texture_2d_layered_create(p_layers, p_layered_type); } - virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return visual_server->texture_3d_create(p_slices); } - virtual RID texture_proxy_create(RID p_base) { return visual_server->texture_proxy_create(p_base); } + virtual RID texture_2d_create(const Ref<Image> &p_image) { return rendering_server->texture_2d_create(p_image); } + virtual RID texture_2d_layered_create(const Vector<Ref<Image>> &p_layers, TextureLayeredType p_layered_type) { return rendering_server->texture_2d_layered_create(p_layers, p_layered_type); } + virtual RID texture_3d_create(const Vector<Ref<Image>> &p_slices) { return rendering_server->texture_3d_create(p_slices); } + virtual RID texture_proxy_create(RID p_base) { return rendering_server->texture_proxy_create(p_base); } //goes pass-through - virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) { visual_server->texture_2d_update_immediate(p_texture, p_image, p_layer); } + virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0) { rendering_server->texture_2d_update_immediate(p_texture, p_image, p_layer); } //these go through command queue if they are in another thread FUNC3(texture_2d_update, RID, const Ref<Image> &, int) FUNC4(texture_3d_update, RID, const Ref<Image> &, int, int) FUNC2(texture_proxy_update, RID, RID) //these also go pass-through - virtual RID texture_2d_placeholder_create() { return visual_server->texture_2d_placeholder_create(); } - virtual RID texture_2d_layered_placeholder_create() { return visual_server->texture_2d_layered_placeholder_create(); } - virtual RID texture_3d_placeholder_create() { return visual_server->texture_3d_placeholder_create(); } + virtual RID texture_2d_placeholder_create() { return rendering_server->texture_2d_placeholder_create(); } + virtual RID texture_2d_layered_placeholder_create() { return rendering_server->texture_2d_layered_placeholder_create(); } + virtual RID texture_3d_placeholder_create() { return rendering_server->texture_3d_placeholder_create(); } FUNC1RC(Ref<Image>, texture_2d_get, RID) FUNC2RC(Ref<Image>, texture_2d_layer_get, RID, int) @@ -145,7 +145,7 @@ public: /* MESH API */ virtual RID mesh_create_from_surfaces(const Vector<SurfaceData> &p_surfaces) { - return visual_server->mesh_create_from_surfaces(p_surfaces); + return rendering_server->mesh_create_from_surfaces(p_surfaces); } FUNCRID(mesh) @@ -346,7 +346,7 @@ public: FUNC1(particles_request_process, RID) FUNC1(particles_restart, RID) - FUNC2(particles_set_draw_order, RID, VS::ParticlesDrawOrder) + FUNC2(particles_set_draw_order, RID, RS::ParticlesDrawOrder) FUNC2(particles_set_draw_passes, RID, int) FUNC3(particles_set_draw_pass_mesh, RID, int, RID) @@ -406,7 +406,7 @@ public: //this passes directly to avoid stalling, but it's pretty dangerous, so don't call after freeing a viewport virtual int viewport_get_render_info(RID p_viewport, ViewportRenderInfo p_info) { - return visual_server->viewport_get_render_info(p_viewport, p_info); + return rendering_server->viewport_get_render_info(p_viewport, p_info); } FUNC2(viewport_set_debug_draw, RID, ViewportDebugDraw) @@ -437,12 +437,15 @@ public: #if 0 FUNC2(environment_set_camera_feed_id, RID, int) #endif - FUNC7(environment_set_ssr, RID, bool, int, float, float, float, bool) + FUNC6(environment_set_ssr, RID, bool, int, float, float, float) + FUNC1(environment_set_ssr_roughness_quality, EnvironmentSSRRoughnessQuality) + FUNC9(environment_set_ssao, RID, bool, float, float, float, float, float, EnvironmentSSAOBlur, float) FUNC2(environment_set_ssao_quality, EnvironmentSSAOQuality, bool) - FUNC12(environment_set_glow, RID, bool, int, float, float, float, float, EnvironmentGlowBlendMode, float, float, float, bool) + FUNC11(environment_set_glow, RID, bool, int, float, float, float, float, EnvironmentGlowBlendMode, float, float, float) + FUNC1(environment_glow_set_use_bicubic_upscale, bool) FUNC9(environment_set_tonemap, RID, EnvironmentToneMapper, float, float, bool, float, float, float, float) @@ -617,15 +620,15 @@ public: //this passes directly to avoid stalling virtual int get_render_info(RenderInfo p_info) { - return visual_server->get_render_info(p_info); + return rendering_server->get_render_info(p_info); } virtual String get_video_adapter_name() const { - return visual_server->get_video_adapter_name(); + return rendering_server->get_video_adapter_name(); } virtual String get_video_adapter_vendor() const { - return visual_server->get_video_adapter_vendor(); + return rendering_server->get_video_adapter_vendor(); } FUNC4(set_boot_image, const Ref<Image> &, const Color &, bool, bool) @@ -636,10 +639,10 @@ public: FUNC1(set_debug_generate_wireframes, bool) virtual bool has_feature(Features p_feature) const { - return visual_server->has_feature(p_feature); + return rendering_server->has_feature(p_feature); } virtual bool has_os_feature(const String &p_feature) const { - return visual_server->has_os_feature(p_feature); + return rendering_server->has_os_feature(p_feature); } FUNC1(call_set_use_vsync, bool) @@ -647,23 +650,23 @@ public: static void set_use_vsync_callback(bool p_enable); virtual bool is_low_end() const { - return visual_server->is_low_end(); + return rendering_server->is_low_end(); } virtual uint64_t get_frame_profile_frame() { - return visual_server->get_frame_profile_frame(); + return rendering_server->get_frame_profile_frame(); } virtual void set_frame_profiling_enabled(bool p_enabled) { - visual_server->set_frame_profiling_enabled(p_enabled); + rendering_server->set_frame_profiling_enabled(p_enabled); } virtual Vector<FrameProfileArea> get_frame_profile() { - return visual_server->get_frame_profile(); + return rendering_server->get_frame_profile(); } - VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread); - ~VisualServerWrapMT(); + RenderingServerWrapMT(RenderingServer *p_contained, bool p_create_thread); + ~RenderingServerWrapMT(); #undef ServerName #undef ServerNameWrapMT diff --git a/servers/visual/shader_language.cpp b/servers/rendering/shader_language.cpp index 98786fad3b..76a81a4a1c 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -31,7 +31,7 @@ #include "shader_language.h" #include "core/os/os.h" #include "core/print_string.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" static bool _is_text_char(CharType c) { @@ -328,7 +328,7 @@ const ShaderLanguage::KeyWord ShaderLanguage::keyword_list[] = { { TK_REPEAT_ENABLE, "repeat_enable" }, { TK_REPEAT_DISABLE, "repeat_disable" }, { TK_SHADER_TYPE, "shader_type" }, - { TK_ERROR, NULL } + { TK_ERROR, nullptr } }; ShaderLanguage::Token ShaderLanguage::_get_token() { @@ -879,7 +879,7 @@ void ShaderLanguage::clear() { current_function = StringName(); completion_type = COMPLETION_NONE; - completion_block = NULL; + completion_block = nullptr; completion_function = StringName(); completion_class = SubClassTag::TAG_GLOBAL; completion_struct = StringName(); @@ -913,7 +913,7 @@ bool ShaderLanguage::_find_identifier(const BlockNode *p_block, bool p_allow_rea return true; } - FunctionNode *function = NULL; + FunctionNode *function = nullptr; while (p_block) { @@ -2107,14 +2107,14 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { //array { "length", TYPE_INT, { TYPE_VOID }, TAG_ARRAY, true }, - { NULL, TYPE_VOID, { TYPE_VOID }, TAG_GLOBAL, false } + { nullptr, TYPE_VOID, { TYPE_VOID }, TAG_GLOBAL, false } }; const ShaderLanguage::BuiltinFuncOutArgs ShaderLanguage::builtin_func_out_args[] = { //constructors { "modf", 1 }, - { NULL, 0 } + { nullptr, 0 } }; bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str) { @@ -2165,7 +2165,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const Map<Strin } if (!fail) { - if (VisualServer::get_singleton()->is_low_end()) { + if (RenderingServer::get_singleton()->is_low_end()) { if (builtin_func_defs[idx].high_end) { fail = true; unsupported_builtin = true; @@ -3150,7 +3150,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons while (true) { - Node *expr = NULL; + Node *expr = nullptr; TkPos prepos = _get_tkpos(); Token tk = _get_token(); TkPos pos = _get_tkpos(); @@ -3162,14 +3162,14 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons expr = _parse_and_reduce_expression(p_block, p_builtin_types); if (!expr) - return NULL; + return nullptr; tk = _get_token(); if (tk.type != TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in expression"); - return NULL; + return nullptr; } } else if (tk.type == TK_REAL_CONSTANT) { @@ -3214,7 +3214,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons //make sure void is not used in expression _set_error("Void value not allowed in Expression"); - return NULL; + return nullptr; } else if (is_token_nonvoid_datatype(tk.type)) { //basic type constructor @@ -3234,7 +3234,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_PARENTHESIS_OPEN) { _set_error("Expected '(' after type name"); - return NULL; + return nullptr; } int carg = -1; @@ -3250,11 +3250,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (!ok) - return NULL; + return nullptr; if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) { _set_error("No matching constructor found for: '" + String(funcname->name) + "'"); - return NULL; + return nullptr; } expr = _reduce_expression(p_block, func); @@ -3265,7 +3265,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons StringName identifier; - StructNode *pstruct = NULL; + StructNode *pstruct = nullptr; bool struct_init = false; _get_completable_identifier(p_block, COMPLETION_IDENTIFIER, identifier); @@ -3317,7 +3317,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } else { if (!is_token_variable_datatype(tk.type)) { _set_error("Invalid data type for array"); - return NULL; + return nullptr; } type2 = get_token_datatype(tk.type); } @@ -3335,7 +3335,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); if (!n || n->type != Node::TYPE_CONSTANT || n->get_datatype() != TYPE_INT) { _set_error("Expected single integer constant > 0"); - return NULL; + return nullptr; } ConstantNode *cnode = (ConstantNode *)n; @@ -3343,24 +3343,24 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons array_size2 = cnode->values[0].sint; if (array_size2 <= 0) { _set_error("Expected single integer constant > 0"); - return NULL; + return nullptr; } } else { _set_error("Expected single integer constant > 0"); - return NULL; + return nullptr; } tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } else { tk = _get_token(); } } } else { _set_error("Expected '['"); - return NULL; + return nullptr; } if (type != type2 || struct_name != struct_name2 || array_size != array_size2) { @@ -3383,7 +3383,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons error_str += itos(array_size); error_str += "]'"; _set_error(error_str); - return NULL; + return nullptr; } } @@ -3396,12 +3396,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); if (!n) { - return NULL; + return nullptr; } if (type != n->get_datatype() || struct_name != n->get_datatype_name()) { _set_error("Invalid assignment of '" + (n->get_datatype() == TYPE_STRUCT ? n->get_datatype_name() : get_datatype_name(n->get_datatype())) + "' to '" + (type == TYPE_STRUCT ? struct_name : get_datatype_name(type)) + "'"); - return NULL; + return nullptr; } tk = _get_token(); @@ -3419,30 +3419,30 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons _set_error("Expected '}' or ','"); else _set_error("Expected ')' or ','"); - return NULL; + return nullptr; } } if (an->initializer.size() != array_size) { _set_error("Array size mismatch"); - return NULL; + return nullptr; } } else { _set_error("Expected array initialization!"); - return NULL; + return nullptr; } nexpr = an; } else { nexpr = _parse_and_reduce_expression(p_block, p_builtin_types); if (!nexpr) { - return NULL; + return nullptr; } Node *node = pstruct->members[i]; if (!_compare_datatypes_in_nodes(pstruct->members[i], nexpr)) { String type_name = nexpr->get_datatype() == TYPE_STRUCT ? nexpr->get_datatype_name() : get_datatype_name(nexpr->get_datatype()); String type_name2 = node->get_datatype() == TYPE_STRUCT ? node->get_datatype_name() : get_datatype_name(node->get_datatype()); _set_error("Invalid assignment of '" + type_name + "' to '" + type_name2 + "'"); - return NULL; + return nullptr; } } @@ -3450,7 +3450,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_COMMA) { _set_error("Expected ','"); - return NULL; + return nullptr; } } func->arguments.push_back(nexpr); @@ -3458,7 +3458,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_PARENTHESIS_CLOSE) { _set_error("Expected ')'"); - return NULL; + return nullptr; } expr = func; @@ -3482,7 +3482,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons while (bnode) { if (bnode->variables.has(name)) { _set_error("Expected function name"); - return NULL; + return nullptr; } bnode = bnode->parent_block; } @@ -3514,11 +3514,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (!ok) - return NULL; + return nullptr; if (!_validate_function_call(p_block, p_builtin_types, func, &func->return_cache, &func->struct_name)) { _set_error("No matching function found for: '" + String(funcname->name) + "'"); - return NULL; + return nullptr; } completion_class = TAG_GLOBAL; // reset sub-class if (function_index >= 0) { @@ -3529,7 +3529,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (call_function) { //get current base function - FunctionNode *base_function = NULL; + FunctionNode *base_function = nullptr; { BlockNode *b = p_block; @@ -3544,7 +3544,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } } - ERR_FAIL_COND_V(!base_function, NULL); //bug, wtf + ERR_FAIL_COND_V(!base_function, nullptr); //bug, wtf for (int i = 0; i < call_function->arguments.size(); i++) { int argidx = i + 1; @@ -3556,7 +3556,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons error = true; } else if (n->type == Node::TYPE_ARRAY) { ArrayNode *an = static_cast<ArrayNode *>(n); - if (an->call_expression != NULL) { + if (an->call_expression != nullptr) { error = true; } } else if (n->type == Node::TYPE_VARIABLE) { @@ -3584,7 +3584,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (error) { _set_error(vformat("Constant value cannot be passed for '%s' parameter!", _get_qualifier_str(call_function->arguments[i].qualifier))); - return NULL; + return nullptr; } } if (is_sampler_type(call_function->arguments[i].type)) { @@ -3599,12 +3599,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously //propagate if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat)) { - return NULL; + return nullptr; } } else if (p_builtin_types.has(varname)) { //a built-in if (!_propagate_function_call_sampler_builtin_reference(name, i, varname)) { - return NULL; + return nullptr; } } else { //or this comes from an argument, but nothing else can be a sampler @@ -3653,30 +3653,30 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (!found) { _set_error("Unknown identifier in expression: " + String(identifier)); - return NULL; + return nullptr; } } else { if (!_find_identifier(p_block, false, p_builtin_types, identifier, &data_type, &ident_type, &is_const, &array_size, &struct_name)) { _set_error("Unknown identifier in expression: " + String(identifier)); - return NULL; + return nullptr; } if (ident_type == IDENTIFIER_FUNCTION) { _set_error("Can't use function as identifier: " + String(identifier)); - return NULL; + return nullptr; } } - Node *index_expression = NULL; - Node *call_expression = NULL; + Node *index_expression = nullptr; + Node *call_expression = nullptr; if (array_size > 0) { tk = _get_token(); if (tk.type != TK_BRACKET_OPEN && tk.type != TK_PERIOD) { _set_error("Expected '[' or '.'"); - return NULL; + return nullptr; } if (tk.type == TK_PERIOD) { @@ -3685,17 +3685,17 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons call_expression = _parse_and_reduce_expression(p_block, p_builtin_types); p_block->block_tag = SubClassTag::TAG_GLOBAL; if (!call_expression) - return NULL; + return nullptr; data_type = call_expression->get_datatype(); } else { // indexing index_expression = _parse_and_reduce_expression(p_block, p_builtin_types); if (!index_expression) - return NULL; + return nullptr; if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) { _set_error("Only integer expressions are allowed for indexing"); - return NULL; + return nullptr; } if (index_expression->type == Node::TYPE_CONSTANT) { @@ -3705,7 +3705,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons int value = cnode->values[0].sint; if (value < 0 || value >= array_size) { _set_error(vformat("Index [%s] out of range [%s..%s]", value, 0, array_size - 1)); - return NULL; + return nullptr; } } } @@ -3714,7 +3714,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } } @@ -3750,18 +3750,18 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TK_OP_BIT_INVERT: e.op = OP_BIT_INVERT; break; case TK_OP_INCREMENT: e.op = OP_INCREMENT; break; case TK_OP_DECREMENT: e.op = OP_DECREMENT; break; - default: ERR_FAIL_V(NULL); + default: ERR_FAIL_V(nullptr); } expression.push_back(e); continue; } else { _set_error("Expected expression, found: " + get_token_text(tk)); - return NULL; + return nullptr; //nothing } - ERR_FAIL_COND_V(!expr, NULL); + ERR_FAIL_COND_V(!expr, nullptr); /* OK now see what's NEXT to the operator.. */ /* OK now see what's NEXT to the operator.. */ @@ -3791,7 +3791,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (identifier == StringName()) { _set_error("Expected identifier as member"); - return NULL; + return nullptr; } String ident = identifier; @@ -4042,12 +4042,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (mix_error) { _set_error("Cannot combine symbols from different sets in expression ." + ident); - return NULL; + return nullptr; } if (!ok) { _set_error("Invalid member for " + (dt == TYPE_STRUCT ? st : get_datatype_name(dt)) + " expression: ." + ident); - return NULL; + return nullptr; } MemberNode *mn = alloc_node<MemberNode>(); @@ -4066,16 +4066,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type == TK_PERIOD) { _set_error("Nested array length() is not yet implemented"); - return NULL; + return nullptr; } else if (tk.type == TK_BRACKET_OPEN) { Node *index_expression = _parse_and_reduce_expression(p_block, p_builtin_types); if (!index_expression) - return NULL; + return nullptr; if (index_expression->get_datatype() != TYPE_INT && index_expression->get_datatype() != TYPE_UINT) { _set_error("Only integer expressions are allowed for indexing"); - return NULL; + return nullptr; } if (index_expression->type == Node::TYPE_CONSTANT) { @@ -4085,7 +4085,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons int value = cnode->values[0].sint; if (value < 0 || value >= array_size) { _set_error(vformat("Index [%s] out of range [%s..%s]", value, 0, array_size - 1)); - return NULL; + return nullptr; } } } @@ -4094,13 +4094,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); - return NULL; + return nullptr; } mn->index_expression = index_expression; } else { _set_error("Expected '[' or '.'"); - return NULL; + return nullptr; } } @@ -4120,11 +4120,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons Node *index = _parse_and_reduce_expression(p_block, p_builtin_types); if (!index) - return NULL; + return nullptr; if (index->get_datatype() != TYPE_INT && index->get_datatype() != TYPE_UINT) { _set_error("Only integer datatypes are allowed for indexing"); - return NULL; + return nullptr; } DataType member_type = TYPE_VOID; @@ -4139,7 +4139,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; if (index_constant >= 2) { _set_error("Index out of range (0-1)"); - return NULL; + return nullptr; } } @@ -4162,7 +4162,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; if (index_constant >= 3) { _set_error("Index out of range (0-2)"); - return NULL; + return nullptr; } } @@ -4184,7 +4184,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint; if (index_constant >= 4) { _set_error("Index out of range (0-3)"); - return NULL; + return nullptr; } } @@ -4199,7 +4199,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons break; default: { _set_error("Object of type '" + (expr->get_datatype() == TYPE_STRUCT ? expr->get_datatype_name() : get_datatype_name(expr->get_datatype())) + "' can't be indexed"); - return NULL; + return nullptr; } } @@ -4213,7 +4213,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']' after indexing expression"); - return NULL; + return nullptr; } } else if (tk.type == TK_OP_INCREMENT || tk.type == TK_OP_DECREMENT) { @@ -4224,12 +4224,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (!_validate_operator(op, &op->return_cache)) { _set_error("Invalid base type for increment/decrement operator"); - return NULL; + return nullptr; } if (!_validate_assign(expr, p_builtin_types)) { _set_error("Invalid use of increment/decrement operator in constant expression."); - return NULL; + return nullptr; } expr = op; } else { @@ -4287,7 +4287,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TK_COLON: o.op = OP_SELECT_ELSE; break; default: { _set_error("Invalid token for operator: " + get_token_text(tk)); - return NULL; + return nullptr; } } @@ -4379,7 +4379,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons break; default: - ERR_FAIL_V(NULL); //unexpected operator + ERR_FAIL_V(nullptr); //unexpected operator } if (priority < min_priority) { @@ -4392,7 +4392,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } } - ERR_FAIL_COND_V(next_op == -1, NULL); + ERR_FAIL_COND_V(next_op == -1, nullptr); // OK! create operator.. // OK! create operator.. @@ -4405,7 +4405,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (expr_pos == expression.size()) { //can happen.. _set_error("Unexpected end of expression..."); - return NULL; + return nullptr; } } @@ -4417,7 +4417,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if ((op->op == OP_INCREMENT || op->op == OP_DECREMENT) && !_validate_assign(expression[i + 1].node, p_builtin_types)) { _set_error("Can't use increment/decrement operator in constant expression."); - return NULL; + return nullptr; } op->arguments.push_back(expression[i + 1].node); @@ -4433,7 +4433,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons at += get_datatype_name(op->arguments[j]->get_datatype()); } _set_error("Invalid arguments to unary operator '" + get_operator_text(op->op) + "' :" + at); - return NULL; + return nullptr; } expression.remove(i + 1); } @@ -4442,12 +4442,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (next_op + 2 >= expression.size() || !expression[next_op + 2].is_op || expression[next_op + 2].op != OP_SELECT_ELSE) { _set_error("Missing matching ':' for select operator"); - return NULL; + return nullptr; } OperatorNode *op = alloc_node<OperatorNode>(); @@ -4467,7 +4467,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons at += get_datatype_name(op->arguments[i]->get_datatype()); } _set_error("Invalid argument to ternary ?: operator: " + at); - return NULL; + return nullptr; } for (int i = 0; i < 4; i++) { @@ -4478,7 +4478,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (next_op < 1 || next_op >= (expression.size() - 1)) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } OperatorNode *op = alloc_node<OperatorNode>(); @@ -4487,7 +4487,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (expression[next_op - 1].is_op) { _set_error("Parser bug..."); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } if (_is_operator_assign(op->op)) { @@ -4496,7 +4496,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (!_validate_assign(expression[next_op - 1].node, p_builtin_types, &assign_message)) { _set_error(assign_message); - return NULL; + return nullptr; } } @@ -4528,7 +4528,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } } _set_error("Invalid arguments to operator '" + get_operator_text(op->op) + "' :" + at); - return NULL; + return nullptr; } expression.remove(next_op); @@ -4658,7 +4658,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_and_reduce_expression(BlockNode *p_ ShaderLanguage::Node *expr = _parse_expression(p_block, p_builtin_types); if (!expr) //errored - return NULL; + return nullptr; expr = _reduce_expression(p_block, expr); @@ -4741,7 +4741,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui tk = _get_token(); - Node *vardecl = NULL; + Node *vardecl = nullptr; while (true) { @@ -4752,7 +4752,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui StringName name = tk.text; ShaderLanguage::IdentifierType itype; - if (_find_identifier(p_block, true, p_builtin_types, name, (ShaderLanguage::DataType *)0, &itype)) { + if (_find_identifier(p_block, true, p_builtin_types, name, (ShaderLanguage::DataType *)nullptr, &itype)) { if (itype != IDENTIFIER_FUNCTION) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; @@ -4772,7 +4772,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui if (tk.type == TK_BRACKET_OPEN) { bool unknown_size = false; - if (VisualServer::get_singleton()->is_low_end() && is_const) { + if (RenderingServer::get_singleton()->is_low_end() && is_const) { _set_error("Local const arrays are supported only on high-end platform!"); return ERR_PARSE_ERROR; } @@ -4818,7 +4818,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui tk = _get_token(); if (tk.type == TK_OP_ASSIGN) { - if (VisualServer::get_singleton()->is_low_end()) { + if (RenderingServer::get_singleton()->is_low_end()) { _set_error("Array initialization is supported only on high-end platform!"); return ERR_PARSE_ERROR; } @@ -5025,7 +5025,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui VariableDeclarationNode::Declaration decl; decl.name = name; - decl.initializer = NULL; + decl.initializer = nullptr; //variable created with assignment! must parse an expression Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); @@ -5061,7 +5061,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui VariableDeclarationNode::Declaration decl; decl.name = name; - decl.initializer = NULL; + decl.initializer = nullptr; node->declarations.push_back(decl); } @@ -5070,6 +5070,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui p_block->variables[name] = var; if (tk.type == TK_COMMA) { + if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR) { + _set_error("Multiple declarations in 'for' loop are not implemented yet."); + return ERR_PARSE_ERROR; + } tk = _get_token(); //another variable } else if (tk.type == TK_SEMICOLON) { @@ -5136,7 +5140,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui } } else if (tk.type == TK_CF_SWITCH) { - if (VisualServer::get_singleton()->is_low_end()) { + if (RenderingServer::get_singleton()->is_low_end()) { _set_error("\"switch\" operator is supported only on high-end platform!"); return ERR_PARSE_ERROR; } @@ -5322,7 +5326,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui // while() {} bool is_do = tk.type == TK_CF_DO; - BlockNode *do_block = NULL; + BlockNode *do_block = nullptr; if (is_do) { do_block = alloc_node<BlockNode>(); @@ -5394,6 +5398,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui cf->flow_op = FLOW_OP_FOR; BlockNode *init_block = alloc_node<BlockNode>(); + init_block->block_type = BlockNode::BLOCK_TYPE_FOR; init_block->parent_block = p_block; init_block->single_statement = true; cf->blocks.push_back(init_block); @@ -5617,7 +5622,7 @@ String ShaderLanguage::_get_qualifier_str(ArgumentQualifier p_qualifier) const { } Error ShaderLanguage::_validate_datatype(DataType p_type) { - if (VisualServer::get_singleton()->is_low_end()) { + if (RenderingServer::get_singleton()->is_low_end()) { bool invalid_type = false; switch (p_type) { @@ -5689,7 +5694,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct while (true) { StringName mode; - _get_completable_identifier(NULL, COMPLETION_RENDER_MODE, mode); + _get_completable_identifier(nullptr, COMPLETION_RENDER_MODE, mode); if (mode == StringName()) { _set_error("Expected identifier for render mode"); @@ -5893,7 +5898,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct name = tk.text; - if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) { + if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -6069,7 +6074,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct if (tk.type == TK_OP_ASSIGN) { - Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>()); + Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>()); if (!expr) return ERR_PARSE_ERROR; if (expr->type != Node::TYPE_CONSTANT) { @@ -6186,14 +6191,14 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } _set_tkpos(prev_pos); - _get_completable_identifier(NULL, COMPLETION_MAIN_FUNCTION, name); + _get_completable_identifier(nullptr, COMPLETION_MAIN_FUNCTION, name); if (name == StringName()) { _set_error("Expected function name after datatype"); return ERR_PARSE_ERROR; } - if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) { + if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -6217,7 +6222,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct constant.type = is_struct ? TYPE_STRUCT : type; constant.type_str = struct_name; constant.precision = precision; - constant.initializer = NULL; + constant.initializer = nullptr; if (tk.type == TK_OP_ASSIGN) { @@ -6227,7 +6232,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } //variable created with assignment! must parse an expression - Node *expr = _parse_and_reduce_expression(NULL, Map<StringName, BuiltInInfo>()); + Node *expr = _parse_and_reduce_expression(nullptr, Map<StringName, BuiltInInfo>()); if (!expr) return ERR_PARSE_ERROR; if (expr->type == Node::TYPE_OPERATOR && ((OperatorNode *)expr)->op == OP_CALL) { @@ -6261,7 +6266,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } name = tk.text; - if (_find_identifier(NULL, false, Map<StringName, BuiltInInfo>(), name)) { + if (_find_identifier(nullptr, false, Map<StringName, BuiltInInfo>(), name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -6400,7 +6405,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct pname = tk.text; ShaderLanguage::IdentifierType itype; - if (_find_identifier(func_node->body, false, builtin_types, pname, (ShaderLanguage::DataType *)0, &itype)) { + if (_find_identifier(func_node->body, false, builtin_types, pname, (ShaderLanguage::DataType *)nullptr, &itype)) { if (itype != IDENTIFIER_FUNCTION) { _set_error("Redefinition of '" + String(pname) + "'"); return ERR_PARSE_ERROR; @@ -6640,7 +6645,7 @@ Error ShaderLanguage::compile(const String &p_code, const Map<StringName, Functi code = p_code; - nodes = NULL; + nodes = nullptr; shader = alloc_node<ShaderNode>(); Error err = _parse_shader(p_functions, p_render_modes, p_shader_types); @@ -6657,7 +6662,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct code = p_code; - nodes = NULL; + nodes = nullptr; shader = alloc_node<ShaderNode>(); _parse_shader(p_functions, p_render_modes, p_shader_types); @@ -6763,7 +6768,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct } int idx = 0; - bool low_end = VisualServer::get_singleton()->is_low_end(); + bool low_end = RenderingServer::get_singleton()->is_low_end(); while (builtin_func_defs[idx].name) { if (low_end && builtin_func_defs[idx].high_end) { @@ -6776,7 +6781,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct } else { // sub-class int idx = 0; - bool low_end = VisualServer::get_singleton()->is_low_end(); + bool low_end = RenderingServer::get_singleton()->is_low_end(); while (builtin_func_defs[idx].name) { if (low_end && builtin_func_defs[idx].high_end) { @@ -6854,7 +6859,7 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct int idx = 0; String calltip; - bool low_end = VisualServer::get_singleton()->is_low_end(); + bool low_end = RenderingServer::get_singleton()->is_low_end(); while (builtin_func_defs[idx].name) { @@ -6996,7 +7001,7 @@ ShaderLanguage::ShaderNode *ShaderLanguage::get_shader() { ShaderLanguage::ShaderLanguage() { - nodes = NULL; + nodes = nullptr; completion_class = TAG_GLOBAL; } diff --git a/servers/visual/shader_language.h b/servers/rendering/shader_language.h index bdc15cc4aa..beabae0dda 100644 --- a/servers/visual/shader_language.h +++ b/servers/rendering/shader_language.h @@ -342,7 +342,7 @@ public: virtual String get_datatype_name() const { return ""; } Node(Type t) : - next(NULL), + next(nullptr), type(t) {} virtual ~Node() {} }; @@ -423,8 +423,8 @@ public: ArrayNode() : Node(TYPE_ARRAY), datatype_cache(TYPE_VOID), - index_expression(NULL), - call_expression(NULL), + index_expression(nullptr), + call_expression(nullptr), is_const(false) {} }; @@ -487,6 +487,7 @@ public: enum BlockType { BLOCK_TYPE_STANDART, + BLOCK_TYPE_FOR, BLOCK_TYPE_SWITCH, BLOCK_TYPE_CASE, BLOCK_TYPE_DEFAULT, @@ -510,8 +511,8 @@ public: BlockNode() : Node(TYPE_BLOCK), - parent_function(NULL), - parent_block(NULL), + parent_function(nullptr), + parent_block(nullptr), block_type(BLOCK_TYPE_STANDART), block_tag(SubClassTag::TAG_GLOBAL), single_statement(false) {} @@ -549,8 +550,8 @@ public: basetype_const(false), datatype(TYPE_VOID), array_size(0), - owner(NULL), - index_expression(NULL), + owner(nullptr), + index_expression(nullptr), has_swizzling_duplicates(false) {} }; @@ -591,7 +592,7 @@ public: Node(TYPE_FUNCTION), return_type(TYPE_VOID), return_precision(PRECISION_DEFAULT), - body(NULL), + body(nullptr), can_discard(false) {} }; @@ -732,7 +733,7 @@ public: static bool is_token_nonvoid_datatype(TokenType p_type); static bool is_token_operator(TokenType p_type); - static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = NULL); + static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = nullptr); static DataType get_scalar_type(DataType p_type); static int get_cardinality(DataType p_type); static bool is_scalar_type(DataType p_type); @@ -824,10 +825,10 @@ private: IDENTIFIER_CONSTANT, }; - bool _find_identifier(const BlockNode *p_block, bool p_allow_reassign, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = NULL, IdentifierType *r_type = NULL, bool *r_is_const = NULL, int *r_array_size = NULL, StringName *r_struct_name = NULL); + bool _find_identifier(const BlockNode *p_block, bool p_allow_reassign, const Map<StringName, BuiltInInfo> &p_builtin_types, const StringName &p_identifier, DataType *r_data_type = nullptr, IdentifierType *r_type = nullptr, bool *r_is_const = nullptr, int *r_array_size = nullptr, StringName *r_struct_name = nullptr); bool _is_operator_assign(Operator p_op) const; - bool _validate_assign(Node *p_node, const Map<StringName, BuiltInInfo> &p_builtin_types, String *r_message = NULL); - bool _validate_operator(OperatorNode *p_op, DataType *r_ret_type = NULL); + bool _validate_assign(Node *p_node, const Map<StringName, BuiltInInfo> &p_builtin_types, String *r_message = nullptr); + bool _validate_operator(OperatorNode *p_op, DataType *r_ret_type = nullptr); struct BuiltinFuncDef { enum { MAX_ARGS = 5 }; @@ -860,7 +861,7 @@ private: bool _compare_datatypes_in_nodes(Node *a, Node *b) const; bool _validate_function_call(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str); - bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = NULL); + bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = nullptr); bool _propagate_function_call_sampler_uniform_settings(StringName p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat); bool _propagate_function_call_sampler_builtin_reference(StringName p_name, int p_argument, const StringName &p_builtin); diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp new file mode 100644 index 0000000000..ba7b992e51 --- /dev/null +++ b/servers/rendering/shader_types.cpp @@ -0,0 +1,328 @@ +/*************************************************************************/ +/* shader_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "shader_types.h" + +const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(RS::ShaderMode p_mode) { + + return shader_modes[p_mode].functions; +} + +const Vector<StringName> &ShaderTypes::get_modes(RS::ShaderMode p_mode) { + + return shader_modes[p_mode].modes; +} + +const Set<String> &ShaderTypes::get_types() { + return shader_types; +} + +ShaderTypes *ShaderTypes::singleton = nullptr; + +static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) { + + return ShaderLanguage::BuiltInInfo(p_type, true); +} + +ShaderTypes::ShaderTypes() { + singleton = this; + + /*************** SPATIAL ***********************/ + + shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["UV2"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_ID"] = constt(ShaderLanguage::TYPE_INT); + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].can_discard = false; + + //builtins + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_MATRIX"] = ShaderLanguage::TYPE_MAT4; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3; + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); + + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["FRONT_FACING"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SPECULAR"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM_TINT"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT_GLOSS"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["AO_LIGHT_AFFECT"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); + + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); + + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_NORMAL_MATRIX"] = constt(ShaderLanguage::TYPE_MAT3); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SPATIAL].functions["fragment"].can_discard = true; + + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ATTENUATION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ALBEDO"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["TRANSMISSION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ROUGHNESS"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["DIFFUSE_LIGHT"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_LIGHT"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SPATIAL].functions["light"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; + + shader_modes[RS::SHADER_SPATIAL].functions["light"].can_discard = true; + + //order used puts first enum mode (default) first + shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_mix"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_add"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_sub"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("blend_mul"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_opaque"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_always"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_draw_never"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_prepass_alpha"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("depth_test_disabled"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_back"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_front"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("cull_disabled"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("unshaded"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("wireframe"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_lambert"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_lambert_wrap"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_oren_nayar"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_burley"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("diffuse_toon"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_schlick_ggx"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_blinn"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_phong"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_toon"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("specular_disabled"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("skip_vertex_transform"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("world_vertex_coords"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("shadows_disabled"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("ambient_light_disabled"); + shader_modes[RS::SHADER_SPATIAL].modes.push_back("shadow_to_opacity"); + + shader_modes[RS::SHADER_SPATIAL].modes.push_back("vertex_lighting"); + + /************ CANVAS ITEM **************************/ + + shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT; + + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["CANVAS_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["SCREEN_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["vertex"].can_discard = false; + + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SHADOW_VERTEX"] = ShaderLanguage::TYPE_VEC2; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["LIGHT_VERTEX"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["fragment"].can_discard = true; + + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_VERTEX"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SHADOW_MODULATE"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["light"].can_discard = true; + + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("skip_vertex_transform"); + + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_mix"); + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_add"); + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_sub"); + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_mul"); + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_premul_alpha"); + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("blend_disabled"); + + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("unshaded"); + shader_modes[RS::SHADER_CANVAS_ITEM].modes.push_back("light_only"); + + /************ PARTICLES **************************/ + + shader_modes[RS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["MASS"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["ACTIVE"] = ShaderLanguage::TYPE_BOOL; + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["RESTART"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["CUSTOM"] = ShaderLanguage::TYPE_VEC4; + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["TRANSFORM"] = ShaderLanguage::TYPE_MAT4; + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["LIFETIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["DELTA"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["NUMBER"] = constt(ShaderLanguage::TYPE_UINT); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["INDEX"] = constt(ShaderLanguage::TYPE_INT); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["EMISSION_TRANSFORM"] = constt(ShaderLanguage::TYPE_MAT4); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].built_ins["RANDOM_SEED"] = constt(ShaderLanguage::TYPE_UINT); + shader_modes[RS::SHADER_PARTICLES].functions["vertex"].can_discard = false; + + shader_modes[RS::SHADER_PARTICLES].modes.push_back("disable_force"); + shader_modes[RS::SHADER_PARTICLES].modes.push_back("disable_velocity"); + shader_modes[RS::SHADER_PARTICLES].modes.push_back("keep_data"); + + /************ SKY **************************/ + + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["POSITION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["RADIANCE"] = constt(ShaderLanguage::TYPE_SAMPLERCUBE); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["AT_HALF_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["AT_QUARTER_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["AT_CUBEMAP_PASS"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT0_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT1_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT2_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["global"].built_ins["LIGHT3_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); + + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC3; + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["EYEDIR"] = constt(ShaderLanguage::TYPE_VEC3); + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["SKY_COORDS"] = constt(ShaderLanguage::TYPE_VEC2); + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["HALF_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4); + shader_modes[RS::SHADER_SKY].functions["fragment"].built_ins["QUARTER_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4); + + shader_modes[RS::SHADER_SKY].modes.push_back("use_half_res_pass"); + shader_modes[RS::SHADER_SKY].modes.push_back("use_quarter_res_pass"); + + shader_types.insert("spatial"); + shader_types.insert("canvas_item"); + shader_types.insert("particles"); + shader_types.insert("sky"); +} diff --git a/servers/visual/shader_types.h b/servers/rendering/shader_types.h index 7d674bfb5c..499a761265 100644 --- a/servers/visual/shader_types.h +++ b/servers/rendering/shader_types.h @@ -32,7 +32,7 @@ #define SHADERTYPES_H #include "core/ordered_hash_map.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" #include "shader_language.h" class ShaderTypes { @@ -43,7 +43,7 @@ class ShaderTypes { Vector<StringName> modes; }; - Map<VS::ShaderMode, Type> shader_modes; + Map<RS::ShaderMode, Type> shader_modes; static ShaderTypes *singleton; @@ -52,8 +52,8 @@ class ShaderTypes { public: static ShaderTypes *get_singleton() { return singleton; } - const Map<StringName, ShaderLanguage::FunctionInfo> &get_functions(VS::ShaderMode p_mode); - const Vector<StringName> &get_modes(VS::ShaderMode p_mode); + const Map<StringName, ShaderLanguage::FunctionInfo> &get_functions(RS::ShaderMode p_mode); + const Vector<StringName> &get_modes(RS::ShaderMode p_mode); const Set<String> &get_types(); ShaderTypes(); diff --git a/servers/visual_server.cpp b/servers/rendering_server.cpp index fecaf563db..55afd78fda 100644 --- a/servers/visual_server.cpp +++ b/servers/rendering_server.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server.cpp */ +/* rendering_server.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,30 +28,30 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "visual_server.h" +#include "rendering_server.h" #include "core/method_bind_ext.gen.inc" #include "core/project_settings.h" -VisualServer *VisualServer::singleton = NULL; -VisualServer *(*VisualServer::create_func)() = NULL; +RenderingServer *RenderingServer::singleton = nullptr; +RenderingServer *(*RenderingServer::create_func)() = nullptr; -VisualServer *VisualServer::get_singleton() { +RenderingServer *RenderingServer::get_singleton() { return singleton; } -VisualServer *VisualServer::create() { +RenderingServer *RenderingServer::create() { - ERR_FAIL_COND_V(singleton, NULL); + ERR_FAIL_COND_V(singleton, nullptr); if (create_func) return create_func(); - return NULL; + return nullptr; } -Array VisualServer::_texture_debug_usage_bind() { +Array RenderingServer::_texture_debug_usage_bind() { List<TextureInfo> list; texture_debug_usage(&list); @@ -71,7 +71,7 @@ Array VisualServer::_texture_debug_usage_bind() { return arr; } -Array VisualServer::_shader_get_param_list_bind(RID p_shader) const { +Array RenderingServer::_shader_get_param_list_bind(RID p_shader) const { List<PropertyInfo> l; shader_get_param_list(p_shader, &l); @@ -87,19 +87,19 @@ static Array to_array(const Vector<ObjectID> &ids) { return a; } -Array VisualServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const { +Array RenderingServer::_instances_cull_aabb_bind(const AABB &p_aabb, RID p_scenario) const { Vector<ObjectID> ids = instances_cull_aabb(p_aabb, p_scenario); return to_array(ids); } -Array VisualServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const { +Array RenderingServer::_instances_cull_ray_bind(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario) const { Vector<ObjectID> ids = instances_cull_ray(p_from, p_to, p_scenario); return to_array(ids); } -Array VisualServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const { +Array RenderingServer::_instances_cull_convex_bind(const Array &p_convex, RID p_scenario) const { Vector<Plane> planes; for (int i = 0; i < p_convex.size(); ++i) { @@ -112,7 +112,7 @@ Array VisualServer::_instances_cull_convex_bind(const Array &p_convex, RID p_sce return to_array(ids); } -RID VisualServer::get_test_texture() { +RID RenderingServer::get_test_texture() { if (test_texture.is_valid()) { return test_texture; @@ -160,7 +160,7 @@ RID VisualServer::get_test_texture() { return test_texture; } -void VisualServer::_free_internal_rids() { +void RenderingServer::_free_internal_rids() { if (test_texture.is_valid()) free(test_texture); @@ -170,7 +170,7 @@ void VisualServer::_free_internal_rids() { free(test_material); } -RID VisualServer::_make_test_cube() { +RID RenderingServer::_make_test_cube() { Vector<Vector3> vertices; Vector<Vector3> normals; @@ -223,17 +223,17 @@ RID VisualServer::_make_test_cube() { RID test_cube = mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_NORMAL] = normals; - d[VisualServer::ARRAY_TANGENT] = tangents; - d[VisualServer::ARRAY_TEX_UV] = uvs; - d[VisualServer::ARRAY_VERTEX] = vertices; + d.resize(RS::ARRAY_MAX); + d[RenderingServer::ARRAY_NORMAL] = normals; + d[RenderingServer::ARRAY_TANGENT] = tangents; + d[RenderingServer::ARRAY_TEX_UV] = uvs; + d[RenderingServer::ARRAY_VERTEX] = vertices; Vector<int> indices; indices.resize(vertices.size()); for (int i = 0; i < vertices.size(); i++) indices.set(i, i); - d[VisualServer::ARRAY_INDEX] = indices; + d[RenderingServer::ARRAY_INDEX] = indices; mesh_add_surface_from_arrays(test_cube, PRIMITIVE_TRIANGLES, d); @@ -252,7 +252,7 @@ RID VisualServer::_make_test_cube() { return test_cube; } -RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) { +RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) { Vector<Vector3> vertices; Vector<Vector3> normals; @@ -299,7 +299,7 @@ RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) { RID mesh = mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); d[ARRAY_VERTEX] = vertices; d[ARRAY_NORMAL] = normals; @@ -309,7 +309,7 @@ RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) { return mesh; } -RID VisualServer::get_white_texture() { +RID RenderingServer::get_white_texture() { if (white_texture.is_valid()) return white_texture; @@ -329,27 +329,27 @@ RID VisualServer::get_white_texture() { #define SMALL_VEC2 Vector2(0.00001, 0.00001) #define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001) -Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) { +Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb) { uint8_t *vw = r_vertex_array.ptrw(); - uint8_t *iw = NULL; + uint8_t *iw = nullptr; if (r_index_array.size()) { iw = r_index_array.ptrw(); } int max_bone = 0; - for (int ai = 0; ai < VS::ARRAY_MAX; ai++) { + for (int ai = 0; ai < RS::ARRAY_MAX; ai++) { if (!(p_format & (1 << ai))) // no array continue; switch (ai) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { - if (p_format & VS::ARRAY_FLAG_USE_2D_VERTICES) { + if (p_format & RS::ARRAY_FLAG_USE_2D_VERTICES) { Vector<Vector2> array = p_arrays[ai]; ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER); @@ -408,7 +408,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY, ERR_INVALID_PARAMETER); @@ -443,7 +443,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER); @@ -481,7 +481,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_COLOR_ARRAY, ERR_INVALID_PARAMETER); @@ -513,7 +513,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER); @@ -542,7 +542,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_VECTOR2_ARRAY, ERR_INVALID_PARAMETER); @@ -569,13 +569,13 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER); Vector<real_t> array = p_arrays[ai]; - ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(array.size() != p_vertex_array_len * RS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER); const real_t *src = array.ptr(); @@ -583,9 +583,9 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ for (int i = 0; i < p_vertex_array_len; i++) { - uint16_t data[VS::ARRAY_WEIGHTS_SIZE]; - for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) { - data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535); + uint16_t data[RS::ARRAY_WEIGHTS_SIZE]; + for (int j = 0; j < RS::ARRAY_WEIGHTS_SIZE; j++) { + data[j] = CLAMP(src[i * RS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535); } copymem(&vw[p_offsets[ai] + i * p_stride], data, 2 * 4); @@ -593,21 +593,21 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_INT32_ARRAY && p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER); Vector<int> array = p_arrays[ai]; - ERR_FAIL_COND_V(array.size() != p_vertex_array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(array.size() != p_vertex_array_len * RS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER); const int *src = array.ptr(); for (int i = 0; i < p_vertex_array_len; i++) { - uint16_t data[VS::ARRAY_WEIGHTS_SIZE]; - for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) { - data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j]; + uint16_t data[RS::ARRAY_WEIGHTS_SIZE]; + for (int j = 0; j < RS::ARRAY_WEIGHTS_SIZE; j++) { + data[j] = src[i * RS::ARRAY_WEIGHTS_SIZE + j]; max_bone = MAX(data[j], max_bone); } @@ -615,7 +615,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { ERR_FAIL_NULL_V(iw, ERR_INVALID_DATA); ERR_FAIL_COND_V(p_index_array_len <= 0, ERR_INVALID_DATA); @@ -648,7 +648,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } - if (p_format & VS::ARRAY_FORMAT_BONES) { + if (p_format & RS::ARRAY_FORMAT_BONES) { //create AABBs for each detected bone int total_bones = max_bone + 1; @@ -662,9 +662,9 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } - Vector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX]; - Vector<int> bones = p_arrays[VS::ARRAY_BONES]; - Vector<float> weights = p_arrays[VS::ARRAY_WEIGHTS]; + Vector<Vector3> vertices = p_arrays[RS::ARRAY_VERTEX]; + Vector<int> bones = p_arrays[RS::ARRAY_BONES]; + Vector<float> weights = p_arrays[RS::ARRAY_WEIGHTS]; bool any_valid = false; @@ -707,22 +707,22 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ return OK; } -uint32_t VisualServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const { +uint32_t RenderingServer::mesh_surface_get_format_offset(uint32_t p_format, int p_vertex_len, int p_index_len, int p_array_index) const { uint32_t offsets[ARRAY_MAX]; mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets); return offsets[p_array_index]; } -uint32_t VisualServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const { +uint32_t RenderingServer::mesh_surface_get_format_stride(uint32_t p_format, int p_vertex_len, int p_index_len) const { uint32_t offsets[ARRAY_MAX]; return mesh_surface_make_offsets_from_format(p_format, p_vertex_len, p_index_len, offsets); } -uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const { +uint32_t RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets) const { int total_elem_size = 0; - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { r_offsets[i] = 0; //reset @@ -733,7 +733,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { if (p_format & ARRAY_FLAG_USE_2D_VERTICES) { elem_size = 2; @@ -750,7 +750,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { if (p_format & ARRAY_COMPRESS_NORMAL) { elem_size = sizeof(uint32_t); @@ -760,7 +760,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { if (p_format & ARRAY_COMPRESS_TANGENT) { elem_size = sizeof(uint32_t); } else { @@ -768,7 +768,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { if (p_format & ARRAY_COMPRESS_COLOR) { elem_size = sizeof(uint32_t); @@ -776,7 +776,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, elem_size = sizeof(float) * 4; } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { if (p_format & ARRAY_COMPRESS_TEX_UV) { elem_size = sizeof(uint32_t); } else { @@ -785,7 +785,7 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { if (p_format & ARRAY_COMPRESS_TEX_UV2) { elem_size = sizeof(uint32_t); } else { @@ -793,17 +793,17 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, } } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { elem_size = sizeof(uint16_t) * 4; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { elem_size = sizeof(uint16_t) * 4; } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { if (p_index_len <= 0) { ERR_PRINT("index_array_len==NO_INDEX_ARRAY"); @@ -831,10 +831,10 @@ uint32_t VisualServer::mesh_surface_make_offsets_from_format(uint32_t p_format, return total_elem_size; } -Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) { +Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_data, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) { - ERR_FAIL_INDEX_V(p_primitive, VS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(p_arrays.size() != VS::ARRAY_MAX, ERR_INVALID_PARAMETER); + ERR_FAIL_INDEX_V(p_primitive, RS::PRIMITIVE_MAX, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(p_arrays.size() != RS::ARRAY_MAX, ERR_INVALID_PARAMETER); uint32_t format = 0; @@ -849,7 +849,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ format |= (1 << i); - if (i == VS::ARRAY_VERTEX) { + if (i == RS::ARRAY_VERTEX) { Variant var = p_arrays[i]; switch (var.get_type()) { @@ -866,13 +866,13 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ array_len = PackedVector3Array(p_arrays[i]).size(); ERR_FAIL_COND_V(array_len == 0, ERR_INVALID_DATA); - } else if (i == VS::ARRAY_INDEX) { + } else if (i == RS::ARRAY_INDEX) { index_array_len = PackedInt32Array(p_arrays[i]).size(); } } - ERR_FAIL_COND_V((format & VS::ARRAY_FORMAT_VERTEX) == 0, ERR_INVALID_PARAMETER); // mandatory + ERR_FAIL_COND_V((format & RS::ARRAY_FORMAT_VERTEX) == 0, ERR_INVALID_PARAMETER); // mandatory if (p_blend_shapes.size()) { //validate format for morphs @@ -886,15 +886,15 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ bsformat |= (1 << j); } - ERR_FAIL_COND_V((bsformat) != (format & (VS::ARRAY_FORMAT_INDEX - 1)), ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V((bsformat) != (format & (RS::ARRAY_FORMAT_INDEX - 1)), ERR_INVALID_PARAMETER); } } - uint32_t offsets[VS::ARRAY_MAX]; + uint32_t offsets[RS::ARRAY_MAX]; int total_elem_size = 0; - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { offsets[i] = 0; //reset @@ -905,7 +905,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { Variant arr = p_arrays[0]; if (arr.get_type() == Variant::PACKED_VECTOR2_ARRAY) { @@ -923,7 +923,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { if (p_compress_format & ARRAY_COMPRESS_NORMAL) { elem_size = sizeof(uint32_t); @@ -933,7 +933,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { if (p_compress_format & ARRAY_COMPRESS_TANGENT) { elem_size = sizeof(uint32_t); } else { @@ -941,7 +941,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { if (p_compress_format & ARRAY_COMPRESS_COLOR) { elem_size = sizeof(uint32_t); @@ -949,7 +949,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ elem_size = sizeof(float) * 4; } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { if (p_compress_format & ARRAY_COMPRESS_TEX_UV) { elem_size = sizeof(uint32_t); } else { @@ -958,7 +958,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { if (p_compress_format & ARRAY_COMPRESS_TEX_UV2) { elem_size = sizeof(uint32_t); } else { @@ -966,17 +966,17 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ } } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { elem_size = sizeof(uint16_t) * 4; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { elem_size = sizeof(uint16_t) * 4; } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { if (index_array_len <= 0) { ERR_PRINT("index_array_len==NO_INDEX_ARRAY"); @@ -1010,7 +1010,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ Vector<uint8_t> vertex_array; vertex_array.resize(array_size); - int index_array_size = offsets[VS::ARRAY_INDEX] * index_array_len; + int index_array_size = offsets[RS::ARRAY_INDEX] * index_array_len; Vector<uint8_t> index_array; index_array.resize(index_array_size); @@ -1092,7 +1092,7 @@ Error VisualServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surface_ return OK; } -void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) { +void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, uint32_t p_compress_format) { SurfaceData sd; Error err = mesh_create_surface_data_from_arrays(&sd, p_primitive, p_arrays, p_blend_shapes, p_lods, p_compress_format); @@ -1102,13 +1102,13 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim mesh_add_surface(p_mesh, sd); } -Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p_vertex_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len) const { +Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p_vertex_data, int p_vertex_len, Vector<uint8_t> p_index_data, int p_index_len) const { uint32_t offsets[ARRAY_MAX]; int total_elem_size = 0; - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { offsets[i] = 0; //reset @@ -1119,7 +1119,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { if (p_format & ARRAY_FLAG_USE_2D_VERTICES) { elem_size = 2; @@ -1132,7 +1132,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { if (p_format & ARRAY_COMPRESS_NORMAL) { elem_size = sizeof(uint32_t); @@ -1142,7 +1142,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { if (p_format & ARRAY_COMPRESS_TANGENT) { elem_size = sizeof(uint32_t); } else { @@ -1150,7 +1150,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { if (p_format & ARRAY_COMPRESS_COLOR) { elem_size = sizeof(uint32_t); @@ -1158,7 +1158,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p elem_size = sizeof(float) * 4; } } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { if (p_format & ARRAY_COMPRESS_TEX_UV) { elem_size = sizeof(uint32_t); } else { @@ -1167,7 +1167,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { if (p_format & ARRAY_COMPRESS_TEX_UV2) { elem_size = sizeof(uint32_t); } else { @@ -1175,17 +1175,17 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { elem_size = sizeof(uint16_t) * 4; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { elem_size = sizeof(uint16_t) * 4; } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { if (p_index_len <= 0) { ERR_PRINT("index_array_len==NO_INDEX_ARRAY"); @@ -1212,18 +1212,18 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } Array ret; - ret.resize(VS::ARRAY_MAX); + ret.resize(RS::ARRAY_MAX); const uint8_t *r = p_vertex_data.ptr(); - for (int i = 0; i < VS::ARRAY_MAX; i++) { + for (int i = 0; i < RS::ARRAY_MAX; i++) { if (!(p_format & (1 << i))) continue; switch (i) { - case VS::ARRAY_VERTEX: { + case RS::ARRAY_VERTEX: { if (p_format & ARRAY_FLAG_USE_2D_VERTICES) { @@ -1262,7 +1262,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } } break; - case VS::ARRAY_NORMAL: { + case RS::ARRAY_NORMAL: { Vector<Vector3> arr; arr.resize(p_vertex_len); @@ -1290,7 +1290,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p } break; - case VS::ARRAY_TANGENT: { + case RS::ARRAY_TANGENT: { Vector<float> arr; arr.resize(p_vertex_len * 4); if (p_format & ARRAY_COMPRESS_TANGENT) { @@ -1318,7 +1318,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p ret[i] = arr; } break; - case VS::ARRAY_COLOR: { + case RS::ARRAY_COLOR: { Vector<Color> arr; arr.resize(p_vertex_len); @@ -1344,7 +1344,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p ret[i] = arr; } break; - case VS::ARRAY_TEX_UV: { + case RS::ARRAY_TEX_UV: { Vector<Vector2> arr; arr.resize(p_vertex_len); @@ -1372,7 +1372,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p ret[i] = arr; } break; - case VS::ARRAY_TEX_UV2: { + case RS::ARRAY_TEX_UV2: { Vector<Vector2> arr; arr.resize(p_vertex_len); @@ -1399,7 +1399,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p ret[i] = arr; } break; - case VS::ARRAY_WEIGHTS: { + case RS::ARRAY_WEIGHTS: { Vector<float> arr; arr.resize(p_vertex_len * 4); @@ -1418,7 +1418,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p ret[i] = arr; } break; - case VS::ARRAY_BONES: { + case RS::ARRAY_BONES: { Vector<int> arr; arr.resize(p_vertex_len * 4); @@ -1436,7 +1436,7 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p ret[i] = arr; } break; - case VS::ARRAY_INDEX: { + case RS::ARRAY_INDEX: { /* determine whether using 16 or 32 bits indices */ const uint8_t *ir = p_index_data.ptr(); @@ -1472,13 +1472,13 @@ Array VisualServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t> p return ret; } -Array VisualServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const { +Array RenderingServer::mesh_surface_get_arrays(RID p_mesh, int p_surface) const { SurfaceData sd = mesh_get_surface(p_mesh, p_surface); return mesh_create_arrays_from_surface_data(sd); } -Dictionary VisualServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const { +Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const { SurfaceData sd = mesh_get_surface(p_mesh, p_surface); ERR_FAIL_COND_V(sd.vertex_count == 0, Dictionary()); @@ -1513,7 +1513,7 @@ Dictionary VisualServer::mesh_surface_get_lods(RID p_mesh, int p_surface) const return ret; } -Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const { +Array RenderingServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surface) const { SurfaceData sd = mesh_get_surface(p_mesh, p_surface); ERR_FAIL_COND_V(sd.vertex_count == 0, Array()); @@ -1540,7 +1540,7 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac } } -Array VisualServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const { +Array RenderingServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_data) const { Vector<uint8_t> vertex_data = p_data.vertex_data; @@ -1555,9 +1555,9 @@ Array VisualServer::mesh_create_arrays_from_surface_data(const SurfaceData &p_da return _get_array_from_surface(format, vertex_data, vertex_len, index_data, index_len); } #if 0 -Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const { +Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const { - Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); + Vector<AABB> vec = RS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); Array arr; for (int i = 0; i < vec.size(); i++) { arr[i] = vec[i]; @@ -1565,388 +1565,388 @@ Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surfa return arr; } #endif -void VisualServer::_bind_methods() { +void RenderingServer::_bind_methods() { - ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync); - ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &VisualServer::draw, DEFVAL(true), DEFVAL(0.0)); + ClassDB::bind_method(D_METHOD("force_sync"), &RenderingServer::sync); + ClassDB::bind_method(D_METHOD("force_draw", "swap_buffers", "frame_step"), &RenderingServer::draw, DEFVAL(true), DEFVAL(0.0)); #ifndef _MSC_VER #warning TODO all texture methods need re-binding #endif - ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &VisualServer::texture_2d_create); - ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &VisualServer::texture_2d_get); + ClassDB::bind_method(D_METHOD("texture_2d_create", "image"), &RenderingServer::texture_2d_create); + ClassDB::bind_method(D_METHOD("texture_2d_get", "texture"), &RenderingServer::texture_2d_get); #ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("sky_create"), &VisualServer::sky_create); - ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &VisualServer::sky_set_material); + ClassDB::bind_method(D_METHOD("sky_create"), &RenderingServer::sky_create); + ClassDB::bind_method(D_METHOD("sky_set_material", "sky", "material"), &RenderingServer::sky_set_material); #endif - ClassDB::bind_method(D_METHOD("shader_create"), &VisualServer::shader_create); - ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &VisualServer::shader_set_code); - ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &VisualServer::shader_get_code); - ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &VisualServer::_shader_get_param_list_bind); - ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &VisualServer::shader_set_default_texture_param); - ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &VisualServer::shader_get_default_texture_param); - ClassDB::bind_method(D_METHOD("shader_get_param_default", "material", "parameter"), &VisualServer::shader_get_param_default); - - ClassDB::bind_method(D_METHOD("material_create"), &VisualServer::material_create); - ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &VisualServer::material_set_shader); - ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param); - ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param); - ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority); - - ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass); - - ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create); - ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &VisualServer::mesh_surface_get_format_offset); - ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &VisualServer::mesh_surface_get_format_stride); - ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primitive", "arrays", "blend_shapes", "lods", "compress_format"), &VisualServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(Dictionary()), DEFVAL(ARRAY_COMPRESS_DEFAULT)); - ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &VisualServer::mesh_get_blend_shape_count); - ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &VisualServer::mesh_set_blend_shape_mode); - ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &VisualServer::mesh_get_blend_shape_mode); - ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &VisualServer::mesh_surface_update_region); - ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &VisualServer::mesh_surface_set_material); - ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &VisualServer::mesh_surface_get_material); - ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_arrays); - ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &VisualServer::mesh_surface_get_blend_shape_arrays); - ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &VisualServer::mesh_get_surface_count); - ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &VisualServer::mesh_set_custom_aabb); - ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &VisualServer::mesh_get_custom_aabb); - ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &VisualServer::mesh_clear); - - ClassDB::bind_method(D_METHOD("multimesh_create"), &VisualServer::multimesh_create); - ClassDB::bind_method(D_METHOD("multimesh_allocate", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &VisualServer::multimesh_allocate, DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &VisualServer::multimesh_get_instance_count); - ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &VisualServer::multimesh_set_mesh); - ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform); - ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &VisualServer::multimesh_instance_set_transform_2d); - ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &VisualServer::multimesh_instance_set_color); - ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &VisualServer::multimesh_instance_set_custom_data); - ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &VisualServer::multimesh_get_mesh); - ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &VisualServer::multimesh_get_aabb); - ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform); - ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &VisualServer::multimesh_instance_get_transform_2d); - ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &VisualServer::multimesh_instance_get_color); - ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &VisualServer::multimesh_instance_get_custom_data); - ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &VisualServer::multimesh_set_visible_instances); - ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &VisualServer::multimesh_get_visible_instances); - ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &VisualServer::multimesh_set_buffer); - ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &VisualServer::multimesh_get_buffer); + ClassDB::bind_method(D_METHOD("shader_create"), &RenderingServer::shader_create); + ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code); + ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code); + ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &RenderingServer::_shader_get_param_list_bind); + ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &RenderingServer::shader_set_default_texture_param); + ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &RenderingServer::shader_get_default_texture_param); + ClassDB::bind_method(D_METHOD("shader_get_param_default", "material", "parameter"), &RenderingServer::shader_get_param_default); + + ClassDB::bind_method(D_METHOD("material_create"), &RenderingServer::material_create); + ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &RenderingServer::material_set_shader); + ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &RenderingServer::material_set_param); + ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &RenderingServer::material_get_param); + ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &RenderingServer::material_set_render_priority); + + ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &RenderingServer::material_set_next_pass); + + ClassDB::bind_method(D_METHOD("mesh_create"), &RenderingServer::mesh_create); + ClassDB::bind_method(D_METHOD("mesh_surface_get_format_offset", "format", "vertex_len", "index_len", "array_index"), &RenderingServer::mesh_surface_get_format_offset); + ClassDB::bind_method(D_METHOD("mesh_surface_get_format_stride", "format", "vertex_len", "index_len"), &RenderingServer::mesh_surface_get_format_stride); + ClassDB::bind_method(D_METHOD("mesh_add_surface_from_arrays", "mesh", "primitive", "arrays", "blend_shapes", "lods", "compress_format"), &RenderingServer::mesh_add_surface_from_arrays, DEFVAL(Array()), DEFVAL(Dictionary()), DEFVAL(ARRAY_COMPRESS_DEFAULT)); + ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_count", "mesh"), &RenderingServer::mesh_get_blend_shape_count); + ClassDB::bind_method(D_METHOD("mesh_set_blend_shape_mode", "mesh", "mode"), &RenderingServer::mesh_set_blend_shape_mode); + ClassDB::bind_method(D_METHOD("mesh_get_blend_shape_mode", "mesh"), &RenderingServer::mesh_get_blend_shape_mode); + ClassDB::bind_method(D_METHOD("mesh_surface_update_region", "mesh", "surface", "offset", "data"), &RenderingServer::mesh_surface_update_region); + ClassDB::bind_method(D_METHOD("mesh_surface_set_material", "mesh", "surface", "material"), &RenderingServer::mesh_surface_set_material); + ClassDB::bind_method(D_METHOD("mesh_surface_get_material", "mesh", "surface"), &RenderingServer::mesh_surface_get_material); + ClassDB::bind_method(D_METHOD("mesh_surface_get_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_arrays); + ClassDB::bind_method(D_METHOD("mesh_surface_get_blend_shape_arrays", "mesh", "surface"), &RenderingServer::mesh_surface_get_blend_shape_arrays); + ClassDB::bind_method(D_METHOD("mesh_get_surface_count", "mesh"), &RenderingServer::mesh_get_surface_count); + ClassDB::bind_method(D_METHOD("mesh_set_custom_aabb", "mesh", "aabb"), &RenderingServer::mesh_set_custom_aabb); + ClassDB::bind_method(D_METHOD("mesh_get_custom_aabb", "mesh"), &RenderingServer::mesh_get_custom_aabb); + ClassDB::bind_method(D_METHOD("mesh_clear", "mesh"), &RenderingServer::mesh_clear); + + ClassDB::bind_method(D_METHOD("multimesh_create"), &RenderingServer::multimesh_create); + ClassDB::bind_method(D_METHOD("multimesh_allocate", "multimesh", "instances", "transform_format", "color_format", "custom_data_format"), &RenderingServer::multimesh_allocate, DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("multimesh_get_instance_count", "multimesh"), &RenderingServer::multimesh_get_instance_count); + ClassDB::bind_method(D_METHOD("multimesh_set_mesh", "multimesh", "mesh"), &RenderingServer::multimesh_set_mesh); + ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform); + ClassDB::bind_method(D_METHOD("multimesh_instance_set_transform_2d", "multimesh", "index", "transform"), &RenderingServer::multimesh_instance_set_transform_2d); + ClassDB::bind_method(D_METHOD("multimesh_instance_set_color", "multimesh", "index", "color"), &RenderingServer::multimesh_instance_set_color); + ClassDB::bind_method(D_METHOD("multimesh_instance_set_custom_data", "multimesh", "index", "custom_data"), &RenderingServer::multimesh_instance_set_custom_data); + ClassDB::bind_method(D_METHOD("multimesh_get_mesh", "multimesh"), &RenderingServer::multimesh_get_mesh); + ClassDB::bind_method(D_METHOD("multimesh_get_aabb", "multimesh"), &RenderingServer::multimesh_get_aabb); + ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform); + ClassDB::bind_method(D_METHOD("multimesh_instance_get_transform_2d", "multimesh", "index"), &RenderingServer::multimesh_instance_get_transform_2d); + ClassDB::bind_method(D_METHOD("multimesh_instance_get_color", "multimesh", "index"), &RenderingServer::multimesh_instance_get_color); + ClassDB::bind_method(D_METHOD("multimesh_instance_get_custom_data", "multimesh", "index"), &RenderingServer::multimesh_instance_get_custom_data); + ClassDB::bind_method(D_METHOD("multimesh_set_visible_instances", "multimesh", "visible"), &RenderingServer::multimesh_set_visible_instances); + ClassDB::bind_method(D_METHOD("multimesh_get_visible_instances", "multimesh"), &RenderingServer::multimesh_get_visible_instances); + ClassDB::bind_method(D_METHOD("multimesh_set_buffer", "multimesh", "buffer"), &RenderingServer::multimesh_set_buffer); + ClassDB::bind_method(D_METHOD("multimesh_get_buffer", "multimesh"), &RenderingServer::multimesh_get_buffer); #ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("immediate_create"), &VisualServer::immediate_create); - ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &VisualServer::immediate_begin, DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &VisualServer::immediate_vertex); - ClassDB::bind_method(D_METHOD("immediate_vertex_2d", "immediate", "vertex"), &VisualServer::immediate_vertex_2d); - ClassDB::bind_method(D_METHOD("immediate_normal", "immediate", "normal"), &VisualServer::immediate_normal); - ClassDB::bind_method(D_METHOD("immediate_tangent", "immediate", "tangent"), &VisualServer::immediate_tangent); - ClassDB::bind_method(D_METHOD("immediate_color", "immediate", "color"), &VisualServer::immediate_color); - ClassDB::bind_method(D_METHOD("immediate_uv", "immediate", "tex_uv"), &VisualServer::immediate_uv); - ClassDB::bind_method(D_METHOD("immediate_uv2", "immediate", "tex_uv"), &VisualServer::immediate_uv2); - ClassDB::bind_method(D_METHOD("immediate_end", "immediate"), &VisualServer::immediate_end); - ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &VisualServer::immediate_clear); - ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &VisualServer::immediate_set_material); - ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &VisualServer::immediate_get_material); + ClassDB::bind_method(D_METHOD("immediate_create"), &RenderingServer::immediate_create); + ClassDB::bind_method(D_METHOD("immediate_begin", "immediate", "primitive", "texture"), &RenderingServer::immediate_begin, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("immediate_vertex", "immediate", "vertex"), &RenderingServer::immediate_vertex); + ClassDB::bind_method(D_METHOD("immediate_vertex_2d", "immediate", "vertex"), &RenderingServer::immediate_vertex_2d); + ClassDB::bind_method(D_METHOD("immediate_normal", "immediate", "normal"), &RenderingServer::immediate_normal); + ClassDB::bind_method(D_METHOD("immediate_tangent", "immediate", "tangent"), &RenderingServer::immediate_tangent); + ClassDB::bind_method(D_METHOD("immediate_color", "immediate", "color"), &RenderingServer::immediate_color); + ClassDB::bind_method(D_METHOD("immediate_uv", "immediate", "tex_uv"), &RenderingServer::immediate_uv); + ClassDB::bind_method(D_METHOD("immediate_uv2", "immediate", "tex_uv"), &RenderingServer::immediate_uv2); + ClassDB::bind_method(D_METHOD("immediate_end", "immediate"), &RenderingServer::immediate_end); + ClassDB::bind_method(D_METHOD("immediate_clear", "immediate"), &RenderingServer::immediate_clear); + ClassDB::bind_method(D_METHOD("immediate_set_material", "immediate", "material"), &RenderingServer::immediate_set_material); + ClassDB::bind_method(D_METHOD("immediate_get_material", "immediate"), &RenderingServer::immediate_get_material); #endif - ClassDB::bind_method(D_METHOD("skeleton_create"), &VisualServer::skeleton_create); - ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &VisualServer::skeleton_allocate, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &VisualServer::skeleton_get_bone_count); - ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform); - ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform); - ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &VisualServer::skeleton_bone_set_transform_2d); - ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &VisualServer::skeleton_bone_get_transform_2d); + ClassDB::bind_method(D_METHOD("skeleton_create"), &RenderingServer::skeleton_create); + ClassDB::bind_method(D_METHOD("skeleton_allocate", "skeleton", "bones", "is_2d_skeleton"), &RenderingServer::skeleton_allocate, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("skeleton_get_bone_count", "skeleton"), &RenderingServer::skeleton_get_bone_count); + ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform); + ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform); + ClassDB::bind_method(D_METHOD("skeleton_bone_set_transform_2d", "skeleton", "bone", "transform"), &RenderingServer::skeleton_bone_set_transform_2d); + ClassDB::bind_method(D_METHOD("skeleton_bone_get_transform_2d", "skeleton", "bone"), &RenderingServer::skeleton_bone_get_transform_2d); #ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("directional_light_create"), &VisualServer::directional_light_create); - ClassDB::bind_method(D_METHOD("omni_light_create"), &VisualServer::omni_light_create); - ClassDB::bind_method(D_METHOD("spot_light_create"), &VisualServer::spot_light_create); - - ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &VisualServer::light_set_color); - ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &VisualServer::light_set_param); - ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &VisualServer::light_set_shadow); - ClassDB::bind_method(D_METHOD("light_set_shadow_color", "light", "color"), &VisualServer::light_set_shadow_color); - ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &VisualServer::light_set_projector); - ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &VisualServer::light_set_negative); - ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &VisualServer::light_set_cull_mask); - ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &VisualServer::light_set_reverse_cull_face_mode); - ClassDB::bind_method(D_METHOD("light_set_use_gi", "light", "enabled"), &VisualServer::light_set_use_gi); - - ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &VisualServer::light_omni_set_shadow_mode); - - ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &VisualServer::light_directional_set_shadow_mode); - ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &VisualServer::light_directional_set_blend_splits); - ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &VisualServer::light_directional_set_shadow_depth_range_mode); - - ClassDB::bind_method(D_METHOD("reflection_probe_create"), &VisualServer::reflection_probe_create); - ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &VisualServer::reflection_probe_set_update_mode); - ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &VisualServer::reflection_probe_set_intensity); - ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &VisualServer::reflection_probe_set_interior_ambient); - ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &VisualServer::reflection_probe_set_interior_ambient_energy); - ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &VisualServer::reflection_probe_set_interior_ambient_probe_contribution); - ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &VisualServer::reflection_probe_set_max_distance); - ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &VisualServer::reflection_probe_set_extents); - ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &VisualServer::reflection_probe_set_origin_offset); - ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &VisualServer::reflection_probe_set_as_interior); - ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &VisualServer::reflection_probe_set_enable_box_projection); - ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &VisualServer::reflection_probe_set_enable_shadows); - ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &VisualServer::reflection_probe_set_cull_mask); + ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create); + ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create); + ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create); + + ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color); + ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param); + ClassDB::bind_method(D_METHOD("light_set_shadow", "light", "enabled"), &RenderingServer::light_set_shadow); + ClassDB::bind_method(D_METHOD("light_set_shadow_color", "light", "color"), &RenderingServer::light_set_shadow_color); + ClassDB::bind_method(D_METHOD("light_set_projector", "light", "texture"), &RenderingServer::light_set_projector); + ClassDB::bind_method(D_METHOD("light_set_negative", "light", "enable"), &RenderingServer::light_set_negative); + ClassDB::bind_method(D_METHOD("light_set_cull_mask", "light", "mask"), &RenderingServer::light_set_cull_mask); + ClassDB::bind_method(D_METHOD("light_set_reverse_cull_face_mode", "light", "enabled"), &RenderingServer::light_set_reverse_cull_face_mode); + ClassDB::bind_method(D_METHOD("light_set_use_gi", "light", "enabled"), &RenderingServer::light_set_use_gi); + + ClassDB::bind_method(D_METHOD("light_omni_set_shadow_mode", "light", "mode"), &RenderingServer::light_omni_set_shadow_mode); + + ClassDB::bind_method(D_METHOD("light_directional_set_shadow_mode", "light", "mode"), &RenderingServer::light_directional_set_shadow_mode); + ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits); + ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &RenderingServer::light_directional_set_shadow_depth_range_mode); + + ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create); + ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode); + ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity); + ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &RenderingServer::reflection_probe_set_interior_ambient); + ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_interior_ambient_energy); + ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &RenderingServer::reflection_probe_set_interior_ambient_probe_contribution); + ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance); + ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &RenderingServer::reflection_probe_set_extents); + ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset); + ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior); + ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection); + ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows); + ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask); #ifndef _MSC_VER #warning TODO all giprobe methods need re-binding #endif #if 0 - ClassDB::bind_method(D_METHOD("gi_probe_create"), &VisualServer::gi_probe_create); - ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &VisualServer::gi_probe_set_bounds); - ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &VisualServer::gi_probe_get_bounds); - ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &VisualServer::gi_probe_set_cell_size); - ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &VisualServer::gi_probe_get_cell_size); - ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &VisualServer::gi_probe_set_to_cell_xform); - ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &VisualServer::gi_probe_get_to_cell_xform); - ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &VisualServer::gi_probe_set_dynamic_data); - ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &VisualServer::gi_probe_get_dynamic_data); - ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &VisualServer::gi_probe_set_dynamic_range); - ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &VisualServer::gi_probe_get_dynamic_range); - ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &VisualServer::gi_probe_set_energy); - ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &VisualServer::gi_probe_get_energy); - ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &VisualServer::gi_probe_set_bias); - ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &VisualServer::gi_probe_get_bias); - ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &VisualServer::gi_probe_set_normal_bias); - ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &VisualServer::gi_probe_get_normal_bias); - ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &VisualServer::gi_probe_set_propagation); - ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &VisualServer::gi_probe_get_propagation); - ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &VisualServer::gi_probe_set_interior); - ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &VisualServer::gi_probe_is_interior); - ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &VisualServer::gi_probe_set_compress); - ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &VisualServer::gi_probe_is_compressed); + ClassDB::bind_method(D_METHOD("gi_probe_create"), &RenderingServer::gi_probe_create); + ClassDB::bind_method(D_METHOD("gi_probe_set_bounds", "probe", "bounds"), &RenderingServer::gi_probe_set_bounds); + ClassDB::bind_method(D_METHOD("gi_probe_get_bounds", "probe"), &RenderingServer::gi_probe_get_bounds); + ClassDB::bind_method(D_METHOD("gi_probe_set_cell_size", "probe", "range"), &RenderingServer::gi_probe_set_cell_size); + ClassDB::bind_method(D_METHOD("gi_probe_get_cell_size", "probe"), &RenderingServer::gi_probe_get_cell_size); + ClassDB::bind_method(D_METHOD("gi_probe_set_to_cell_xform", "probe", "xform"), &RenderingServer::gi_probe_set_to_cell_xform); + ClassDB::bind_method(D_METHOD("gi_probe_get_to_cell_xform", "probe"), &RenderingServer::gi_probe_get_to_cell_xform); + ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_data", "probe", "data"), &RenderingServer::gi_probe_set_dynamic_data); + ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_data", "probe"), &RenderingServer::gi_probe_get_dynamic_data); + ClassDB::bind_method(D_METHOD("gi_probe_set_dynamic_range", "probe", "range"), &RenderingServer::gi_probe_set_dynamic_range); + ClassDB::bind_method(D_METHOD("gi_probe_get_dynamic_range", "probe"), &RenderingServer::gi_probe_get_dynamic_range); + ClassDB::bind_method(D_METHOD("gi_probe_set_energy", "probe", "energy"), &RenderingServer::gi_probe_set_energy); + ClassDB::bind_method(D_METHOD("gi_probe_get_energy", "probe"), &RenderingServer::gi_probe_get_energy); + ClassDB::bind_method(D_METHOD("gi_probe_set_bias", "probe", "bias"), &RenderingServer::gi_probe_set_bias); + ClassDB::bind_method(D_METHOD("gi_probe_get_bias", "probe"), &RenderingServer::gi_probe_get_bias); + ClassDB::bind_method(D_METHOD("gi_probe_set_normal_bias", "probe", "bias"), &RenderingServer::gi_probe_set_normal_bias); + ClassDB::bind_method(D_METHOD("gi_probe_get_normal_bias", "probe"), &RenderingServer::gi_probe_get_normal_bias); + ClassDB::bind_method(D_METHOD("gi_probe_set_propagation", "probe", "propagation"), &RenderingServer::gi_probe_set_propagation); + ClassDB::bind_method(D_METHOD("gi_probe_get_propagation", "probe"), &RenderingServer::gi_probe_get_propagation); + ClassDB::bind_method(D_METHOD("gi_probe_set_interior", "probe", "enable"), &RenderingServer::gi_probe_set_interior); + ClassDB::bind_method(D_METHOD("gi_probe_is_interior", "probe"), &RenderingServer::gi_probe_is_interior); + ClassDB::bind_method(D_METHOD("gi_probe_set_compress", "probe", "enable"), &RenderingServer::gi_probe_set_compress); + ClassDB::bind_method(D_METHOD("gi_probe_is_compressed", "probe"), &RenderingServer::gi_probe_is_compressed); #endif - ClassDB::bind_method(D_METHOD("lightmap_capture_create"), &VisualServer::lightmap_capture_create); - ClassDB::bind_method(D_METHOD("lightmap_capture_set_bounds", "capture", "bounds"), &VisualServer::lightmap_capture_set_bounds); - ClassDB::bind_method(D_METHOD("lightmap_capture_get_bounds", "capture"), &VisualServer::lightmap_capture_get_bounds); - ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree", "capture", "octree"), &VisualServer::lightmap_capture_set_octree); - ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_transform", "capture", "xform"), &VisualServer::lightmap_capture_set_octree_cell_transform); - ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_transform", "capture"), &VisualServer::lightmap_capture_get_octree_cell_transform); - ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_subdiv", "capture", "subdiv"), &VisualServer::lightmap_capture_set_octree_cell_subdiv); - ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_subdiv", "capture"), &VisualServer::lightmap_capture_get_octree_cell_subdiv); - ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &VisualServer::lightmap_capture_get_octree); - ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &VisualServer::lightmap_capture_set_energy); - ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &VisualServer::lightmap_capture_get_energy); + ClassDB::bind_method(D_METHOD("lightmap_capture_create"), &RenderingServer::lightmap_capture_create); + ClassDB::bind_method(D_METHOD("lightmap_capture_set_bounds", "capture", "bounds"), &RenderingServer::lightmap_capture_set_bounds); + ClassDB::bind_method(D_METHOD("lightmap_capture_get_bounds", "capture"), &RenderingServer::lightmap_capture_get_bounds); + ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree", "capture", "octree"), &RenderingServer::lightmap_capture_set_octree); + ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_transform", "capture", "xform"), &RenderingServer::lightmap_capture_set_octree_cell_transform); + ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_transform", "capture"), &RenderingServer::lightmap_capture_get_octree_cell_transform); + ClassDB::bind_method(D_METHOD("lightmap_capture_set_octree_cell_subdiv", "capture", "subdiv"), &RenderingServer::lightmap_capture_set_octree_cell_subdiv); + ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree_cell_subdiv", "capture"), &RenderingServer::lightmap_capture_get_octree_cell_subdiv); + ClassDB::bind_method(D_METHOD("lightmap_capture_get_octree", "capture"), &RenderingServer::lightmap_capture_get_octree); + ClassDB::bind_method(D_METHOD("lightmap_capture_set_energy", "capture", "energy"), &RenderingServer::lightmap_capture_set_energy); + ClassDB::bind_method(D_METHOD("lightmap_capture_get_energy", "capture"), &RenderingServer::lightmap_capture_get_energy); #endif - ClassDB::bind_method(D_METHOD("particles_create"), &VisualServer::particles_create); - ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &VisualServer::particles_set_emitting); - ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &VisualServer::particles_get_emitting); - ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &VisualServer::particles_set_amount); - ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &VisualServer::particles_set_lifetime); - ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &VisualServer::particles_set_one_shot); - ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &VisualServer::particles_set_pre_process_time); - ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &VisualServer::particles_set_explosiveness_ratio); - ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &VisualServer::particles_set_randomness_ratio); - ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &VisualServer::particles_set_custom_aabb); - ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &VisualServer::particles_set_speed_scale); - ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &VisualServer::particles_set_use_local_coordinates); - ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &VisualServer::particles_set_process_material); - ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &VisualServer::particles_set_fixed_fps); - ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &VisualServer::particles_set_fractional_delta); - ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &VisualServer::particles_is_inactive); - ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &VisualServer::particles_request_process); - ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &VisualServer::particles_restart); - ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &VisualServer::particles_set_draw_order); - ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &VisualServer::particles_set_draw_passes); - ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &VisualServer::particles_set_draw_pass_mesh); - ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &VisualServer::particles_get_current_aabb); - ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &VisualServer::particles_set_emission_transform); - - ClassDB::bind_method(D_METHOD("camera_create"), &VisualServer::camera_create); - ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &VisualServer::camera_set_perspective); - ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &VisualServer::camera_set_orthogonal); - ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &VisualServer::camera_set_frustum); - ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &VisualServer::camera_set_transform); - ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &VisualServer::camera_set_cull_mask); - ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &VisualServer::camera_set_environment); - ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &VisualServer::camera_set_use_vertical_aspect); - - ClassDB::bind_method(D_METHOD("viewport_create"), &VisualServer::viewport_create); - ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &VisualServer::viewport_set_use_arvr); - ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &VisualServer::viewport_set_size); - ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &VisualServer::viewport_set_active); - ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &VisualServer::viewport_set_parent_viewport); - ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &VisualServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID)); - ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &VisualServer::viewport_set_render_direct_to_screen); - - ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &VisualServer::viewport_set_update_mode); - ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &VisualServer::viewport_set_clear_mode); - ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &VisualServer::viewport_get_texture); - ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &VisualServer::viewport_set_hide_scenario); - ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &VisualServer::viewport_set_hide_canvas); - ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &VisualServer::viewport_set_disable_environment); - ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &VisualServer::viewport_attach_camera); - ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &VisualServer::viewport_set_scenario); - ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &VisualServer::viewport_attach_canvas); - ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &VisualServer::viewport_remove_canvas); - ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &VisualServer::viewport_set_canvas_transform); - ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &VisualServer::viewport_set_transparent_background); - ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &VisualServer::viewport_set_global_canvas_transform); - ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &VisualServer::viewport_set_canvas_stacking); - ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &VisualServer::viewport_set_shadow_atlas_size); - ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &VisualServer::viewport_set_shadow_atlas_quadrant_subdivision); - ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &VisualServer::viewport_set_msaa); - ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &VisualServer::viewport_get_render_info); - ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &VisualServer::viewport_set_debug_draw); - - ClassDB::bind_method(D_METHOD("environment_create"), &VisualServer::environment_create); - ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &VisualServer::environment_set_background); - ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &VisualServer::environment_set_sky); - ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &VisualServer::environment_set_sky_custom_fov); - ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &VisualServer::environment_set_sky_orientation); - ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &VisualServer::environment_set_bg_color); - ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &VisualServer::environment_set_bg_energy); - ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &VisualServer::environment_set_canvas_max_layer); - ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contibution", "reflection_source", "ao_color"), &VisualServer::environment_set_ambient_light, DEFVAL(VS::ENV_AMBIENT_SOURCE_BG), DEFVAL(1.0), DEFVAL(0.0), DEFVAL(VS::ENV_REFLECTION_SOURCE_BG), DEFVAL(Color())); - ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap", "bicubic_upscale"), &VisualServer::environment_set_glow); - ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &VisualServer::environment_set_tonemap); - ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &VisualServer::environment_set_adjustment); - ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance", "roughness"), &VisualServer::environment_set_ssr); - ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "bias", "light_affect", "ao_channel_affect", "blur", "bilateral_sharpness"), &VisualServer::environment_set_ssao); - ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "color", "sun_color", "sun_amount"), &VisualServer::environment_set_fog); - - ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "enable", "depth_begin", "depth_end", "depth_curve", "transmit", "transmit_curve"), &VisualServer::environment_set_fog_depth); - - ClassDB::bind_method(D_METHOD("environment_set_fog_height", "env", "enable", "min_height", "max_height", "height_curve"), &VisualServer::environment_set_fog_height); - - ClassDB::bind_method(D_METHOD("scenario_create"), &VisualServer::scenario_create); - ClassDB::bind_method(D_METHOD("scenario_set_debug", "scenario", "debug_mode"), &VisualServer::scenario_set_debug); - ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &VisualServer::scenario_set_environment); - ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &VisualServer::scenario_set_fallback_environment); + ClassDB::bind_method(D_METHOD("particles_create"), &RenderingServer::particles_create); + ClassDB::bind_method(D_METHOD("particles_set_emitting", "particles", "emitting"), &RenderingServer::particles_set_emitting); + ClassDB::bind_method(D_METHOD("particles_get_emitting", "particles"), &RenderingServer::particles_get_emitting); + ClassDB::bind_method(D_METHOD("particles_set_amount", "particles", "amount"), &RenderingServer::particles_set_amount); + ClassDB::bind_method(D_METHOD("particles_set_lifetime", "particles", "lifetime"), &RenderingServer::particles_set_lifetime); + ClassDB::bind_method(D_METHOD("particles_set_one_shot", "particles", "one_shot"), &RenderingServer::particles_set_one_shot); + ClassDB::bind_method(D_METHOD("particles_set_pre_process_time", "particles", "time"), &RenderingServer::particles_set_pre_process_time); + ClassDB::bind_method(D_METHOD("particles_set_explosiveness_ratio", "particles", "ratio"), &RenderingServer::particles_set_explosiveness_ratio); + ClassDB::bind_method(D_METHOD("particles_set_randomness_ratio", "particles", "ratio"), &RenderingServer::particles_set_randomness_ratio); + ClassDB::bind_method(D_METHOD("particles_set_custom_aabb", "particles", "aabb"), &RenderingServer::particles_set_custom_aabb); + ClassDB::bind_method(D_METHOD("particles_set_speed_scale", "particles", "scale"), &RenderingServer::particles_set_speed_scale); + ClassDB::bind_method(D_METHOD("particles_set_use_local_coordinates", "particles", "enable"), &RenderingServer::particles_set_use_local_coordinates); + ClassDB::bind_method(D_METHOD("particles_set_process_material", "particles", "material"), &RenderingServer::particles_set_process_material); + ClassDB::bind_method(D_METHOD("particles_set_fixed_fps", "particles", "fps"), &RenderingServer::particles_set_fixed_fps); + ClassDB::bind_method(D_METHOD("particles_set_fractional_delta", "particles", "enable"), &RenderingServer::particles_set_fractional_delta); + ClassDB::bind_method(D_METHOD("particles_is_inactive", "particles"), &RenderingServer::particles_is_inactive); + ClassDB::bind_method(D_METHOD("particles_request_process", "particles"), &RenderingServer::particles_request_process); + ClassDB::bind_method(D_METHOD("particles_restart", "particles"), &RenderingServer::particles_restart); + ClassDB::bind_method(D_METHOD("particles_set_draw_order", "particles", "order"), &RenderingServer::particles_set_draw_order); + ClassDB::bind_method(D_METHOD("particles_set_draw_passes", "particles", "count"), &RenderingServer::particles_set_draw_passes); + ClassDB::bind_method(D_METHOD("particles_set_draw_pass_mesh", "particles", "pass", "mesh"), &RenderingServer::particles_set_draw_pass_mesh); + ClassDB::bind_method(D_METHOD("particles_get_current_aabb", "particles"), &RenderingServer::particles_get_current_aabb); + ClassDB::bind_method(D_METHOD("particles_set_emission_transform", "particles", "transform"), &RenderingServer::particles_set_emission_transform); + + ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create); + ClassDB::bind_method(D_METHOD("camera_set_perspective", "camera", "fovy_degrees", "z_near", "z_far"), &RenderingServer::camera_set_perspective); + ClassDB::bind_method(D_METHOD("camera_set_orthogonal", "camera", "size", "z_near", "z_far"), &RenderingServer::camera_set_orthogonal); + ClassDB::bind_method(D_METHOD("camera_set_frustum", "camera", "size", "offset", "z_near", "z_far"), &RenderingServer::camera_set_frustum); + ClassDB::bind_method(D_METHOD("camera_set_transform", "camera", "transform"), &RenderingServer::camera_set_transform); + ClassDB::bind_method(D_METHOD("camera_set_cull_mask", "camera", "layers"), &RenderingServer::camera_set_cull_mask); + ClassDB::bind_method(D_METHOD("camera_set_environment", "camera", "env"), &RenderingServer::camera_set_environment); + ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect); + + ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create); + ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &RenderingServer::viewport_set_use_arvr); + ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size); + ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active); + ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport); + ClassDB::bind_method(D_METHOD("viewport_attach_to_screen", "viewport", "rect", "screen"), &RenderingServer::viewport_attach_to_screen, DEFVAL(Rect2()), DEFVAL(DisplayServer::MAIN_WINDOW_ID)); + ClassDB::bind_method(D_METHOD("viewport_set_render_direct_to_screen", "viewport", "enabled"), &RenderingServer::viewport_set_render_direct_to_screen); + + ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode); + ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode); + ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture); + ClassDB::bind_method(D_METHOD("viewport_set_hide_scenario", "viewport", "hidden"), &RenderingServer::viewport_set_hide_scenario); + ClassDB::bind_method(D_METHOD("viewport_set_hide_canvas", "viewport", "hidden"), &RenderingServer::viewport_set_hide_canvas); + ClassDB::bind_method(D_METHOD("viewport_set_disable_environment", "viewport", "disabled"), &RenderingServer::viewport_set_disable_environment); + ClassDB::bind_method(D_METHOD("viewport_attach_camera", "viewport", "camera"), &RenderingServer::viewport_attach_camera); + ClassDB::bind_method(D_METHOD("viewport_set_scenario", "viewport", "scenario"), &RenderingServer::viewport_set_scenario); + ClassDB::bind_method(D_METHOD("viewport_attach_canvas", "viewport", "canvas"), &RenderingServer::viewport_attach_canvas); + ClassDB::bind_method(D_METHOD("viewport_remove_canvas", "viewport", "canvas"), &RenderingServer::viewport_remove_canvas); + ClassDB::bind_method(D_METHOD("viewport_set_canvas_transform", "viewport", "canvas", "offset"), &RenderingServer::viewport_set_canvas_transform); + ClassDB::bind_method(D_METHOD("viewport_set_transparent_background", "viewport", "enabled"), &RenderingServer::viewport_set_transparent_background); + ClassDB::bind_method(D_METHOD("viewport_set_global_canvas_transform", "viewport", "transform"), &RenderingServer::viewport_set_global_canvas_transform); + ClassDB::bind_method(D_METHOD("viewport_set_canvas_stacking", "viewport", "canvas", "layer", "sublayer"), &RenderingServer::viewport_set_canvas_stacking); + ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_size", "viewport", "size"), &RenderingServer::viewport_set_shadow_atlas_size); + ClassDB::bind_method(D_METHOD("viewport_set_shadow_atlas_quadrant_subdivision", "viewport", "quadrant", "subdivision"), &RenderingServer::viewport_set_shadow_atlas_quadrant_subdivision); + ClassDB::bind_method(D_METHOD("viewport_set_msaa", "viewport", "msaa"), &RenderingServer::viewport_set_msaa); + ClassDB::bind_method(D_METHOD("viewport_get_render_info", "viewport", "info"), &RenderingServer::viewport_get_render_info); + ClassDB::bind_method(D_METHOD("viewport_set_debug_draw", "viewport", "draw"), &RenderingServer::viewport_set_debug_draw); + + ClassDB::bind_method(D_METHOD("environment_create"), &RenderingServer::environment_create); + ClassDB::bind_method(D_METHOD("environment_set_background", "env", "bg"), &RenderingServer::environment_set_background); + ClassDB::bind_method(D_METHOD("environment_set_sky", "env", "sky"), &RenderingServer::environment_set_sky); + ClassDB::bind_method(D_METHOD("environment_set_sky_custom_fov", "env", "scale"), &RenderingServer::environment_set_sky_custom_fov); + ClassDB::bind_method(D_METHOD("environment_set_sky_orientation", "env", "orientation"), &RenderingServer::environment_set_sky_orientation); + ClassDB::bind_method(D_METHOD("environment_set_bg_color", "env", "color"), &RenderingServer::environment_set_bg_color); + ClassDB::bind_method(D_METHOD("environment_set_bg_energy", "env", "energy"), &RenderingServer::environment_set_bg_energy); + ClassDB::bind_method(D_METHOD("environment_set_canvas_max_layer", "env", "max_layer"), &RenderingServer::environment_set_canvas_max_layer); + ClassDB::bind_method(D_METHOD("environment_set_ambient_light", "env", "color", "ambient", "energy", "sky_contibution", "reflection_source", "ao_color"), &RenderingServer::environment_set_ambient_light, DEFVAL(RS::ENV_AMBIENT_SOURCE_BG), DEFVAL(1.0), DEFVAL(0.0), DEFVAL(RS::ENV_REFLECTION_SOURCE_BG), DEFVAL(Color())); + ClassDB::bind_method(D_METHOD("environment_set_glow", "env", "enable", "level_flags", "intensity", "strength", "mix", "bloom_threshold", "blend_mode", "hdr_bleed_threshold", "hdr_bleed_scale", "hdr_luminance_cap"), &RenderingServer::environment_set_glow); + ClassDB::bind_method(D_METHOD("environment_set_tonemap", "env", "tone_mapper", "exposure", "white", "auto_exposure", "min_luminance", "max_luminance", "auto_exp_speed", "auto_exp_grey"), &RenderingServer::environment_set_tonemap); + ClassDB::bind_method(D_METHOD("environment_set_adjustment", "env", "enable", "brightness", "contrast", "saturation", "ramp"), &RenderingServer::environment_set_adjustment); + ClassDB::bind_method(D_METHOD("environment_set_ssr", "env", "enable", "max_steps", "fade_in", "fade_out", "depth_tolerance"), &RenderingServer::environment_set_ssr); + ClassDB::bind_method(D_METHOD("environment_set_ssao", "env", "enable", "radius", "intensity", "bias", "light_affect", "ao_channel_affect", "blur", "bilateral_sharpness"), &RenderingServer::environment_set_ssao); + ClassDB::bind_method(D_METHOD("environment_set_fog", "env", "enable", "color", "sun_color", "sun_amount"), &RenderingServer::environment_set_fog); + + ClassDB::bind_method(D_METHOD("environment_set_fog_depth", "env", "enable", "depth_begin", "depth_end", "depth_curve", "transmit", "transmit_curve"), &RenderingServer::environment_set_fog_depth); + + ClassDB::bind_method(D_METHOD("environment_set_fog_height", "env", "enable", "min_height", "max_height", "height_curve"), &RenderingServer::environment_set_fog_height); + + ClassDB::bind_method(D_METHOD("scenario_create"), &RenderingServer::scenario_create); + ClassDB::bind_method(D_METHOD("scenario_set_debug", "scenario", "debug_mode"), &RenderingServer::scenario_set_debug); + ClassDB::bind_method(D_METHOD("scenario_set_environment", "scenario", "environment"), &RenderingServer::scenario_set_environment); + ClassDB::bind_method(D_METHOD("scenario_set_fallback_environment", "scenario", "environment"), &RenderingServer::scenario_set_fallback_environment); #ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &VisualServer::instance_create2); - ClassDB::bind_method(D_METHOD("instance_create"), &VisualServer::instance_create); - ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &VisualServer::instance_set_base); - ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &VisualServer::instance_set_scenario); - ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &VisualServer::instance_set_layer_mask); - ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &VisualServer::instance_set_transform); - ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &VisualServer::instance_attach_object_instance_id); - ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &VisualServer::instance_set_blend_shape_weight); - ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &VisualServer::instance_set_surface_material); - ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &VisualServer::instance_set_visible); - ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &VisualServer::instance_set_use_lightmap); - ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &VisualServer::instance_set_custom_aabb); - ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &VisualServer::instance_attach_skeleton); - ClassDB::bind_method(D_METHOD("instance_set_exterior", "instance", "enabled"), &VisualServer::instance_set_exterior); - ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &VisualServer::instance_set_extra_visibility_margin); - ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &VisualServer::instance_geometry_set_flag); - ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &VisualServer::instance_geometry_set_cast_shadows_setting); - ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &VisualServer::instance_geometry_set_material_override); - ClassDB::bind_method(D_METHOD("instance_geometry_set_draw_range", "instance", "min", "max", "min_margin", "max_margin"), &VisualServer::instance_geometry_set_draw_range); - ClassDB::bind_method(D_METHOD("instance_geometry_set_as_instance_lod", "instance", "as_lod_of_instance"), &VisualServer::instance_geometry_set_as_instance_lod); - - ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &VisualServer::_instances_cull_aabb_bind, DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &VisualServer::_instances_cull_ray_bind, DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &VisualServer::_instances_cull_convex_bind, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("instance_create2", "base", "scenario"), &RenderingServer::instance_create2); + ClassDB::bind_method(D_METHOD("instance_create"), &RenderingServer::instance_create); + ClassDB::bind_method(D_METHOD("instance_set_base", "instance", "base"), &RenderingServer::instance_set_base); + ClassDB::bind_method(D_METHOD("instance_set_scenario", "instance", "scenario"), &RenderingServer::instance_set_scenario); + ClassDB::bind_method(D_METHOD("instance_set_layer_mask", "instance", "mask"), &RenderingServer::instance_set_layer_mask); + ClassDB::bind_method(D_METHOD("instance_set_transform", "instance", "transform"), &RenderingServer::instance_set_transform); + ClassDB::bind_method(D_METHOD("instance_attach_object_instance_id", "instance", "id"), &RenderingServer::instance_attach_object_instance_id); + ClassDB::bind_method(D_METHOD("instance_set_blend_shape_weight", "instance", "shape", "weight"), &RenderingServer::instance_set_blend_shape_weight); + ClassDB::bind_method(D_METHOD("instance_set_surface_material", "instance", "surface", "material"), &RenderingServer::instance_set_surface_material); + ClassDB::bind_method(D_METHOD("instance_set_visible", "instance", "visible"), &RenderingServer::instance_set_visible); + ClassDB::bind_method(D_METHOD("instance_set_use_lightmap", "instance", "lightmap_instance", "lightmap"), &RenderingServer::instance_set_use_lightmap); + ClassDB::bind_method(D_METHOD("instance_set_custom_aabb", "instance", "aabb"), &RenderingServer::instance_set_custom_aabb); + ClassDB::bind_method(D_METHOD("instance_attach_skeleton", "instance", "skeleton"), &RenderingServer::instance_attach_skeleton); + ClassDB::bind_method(D_METHOD("instance_set_exterior", "instance", "enabled"), &RenderingServer::instance_set_exterior); + ClassDB::bind_method(D_METHOD("instance_set_extra_visibility_margin", "instance", "margin"), &RenderingServer::instance_set_extra_visibility_margin); + ClassDB::bind_method(D_METHOD("instance_geometry_set_flag", "instance", "flag", "enabled"), &RenderingServer::instance_geometry_set_flag); + ClassDB::bind_method(D_METHOD("instance_geometry_set_cast_shadows_setting", "instance", "shadow_casting_setting"), &RenderingServer::instance_geometry_set_cast_shadows_setting); + ClassDB::bind_method(D_METHOD("instance_geometry_set_material_override", "instance", "material"), &RenderingServer::instance_geometry_set_material_override); + ClassDB::bind_method(D_METHOD("instance_geometry_set_draw_range", "instance", "min", "max", "min_margin", "max_margin"), &RenderingServer::instance_geometry_set_draw_range); + ClassDB::bind_method(D_METHOD("instance_geometry_set_as_instance_lod", "instance", "as_lod_of_instance"), &RenderingServer::instance_geometry_set_as_instance_lod); + + ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("instances_cull_convex", "convex", "scenario"), &RenderingServer::_instances_cull_convex_bind, DEFVAL(RID())); #endif - ClassDB::bind_method(D_METHOD("canvas_create"), &VisualServer::canvas_create); - ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &VisualServer::canvas_set_item_mirroring); - ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &VisualServer::canvas_set_modulate); + ClassDB::bind_method(D_METHOD("canvas_create"), &RenderingServer::canvas_create); + ClassDB::bind_method(D_METHOD("canvas_set_item_mirroring", "canvas", "item", "mirroring"), &RenderingServer::canvas_set_item_mirroring); + ClassDB::bind_method(D_METHOD("canvas_set_modulate", "canvas", "color"), &RenderingServer::canvas_set_modulate); #ifndef _MSC_VER #warning TODO method bindings need to be fixed #endif #if 0 - ClassDB::bind_method(D_METHOD("canvas_item_create"), &VisualServer::canvas_item_create); - ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &VisualServer::canvas_item_set_parent); - ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &VisualServer::canvas_item_set_visible); - ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &VisualServer::canvas_item_set_light_mask); - ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &VisualServer::canvas_item_set_transform); - ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &VisualServer::canvas_item_set_clip); - ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &VisualServer::canvas_item_set_distance_field_mode); - ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &VisualServer::canvas_item_set_custom_rect, DEFVAL(Rect2())); - ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &VisualServer::canvas_item_set_modulate); - ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &VisualServer::canvas_item_set_self_modulate); - ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &VisualServer::canvas_item_set_draw_behind_parent); - ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &VisualServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &VisualServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &VisualServer::canvas_item_add_rect); - ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &VisualServer::canvas_item_add_circle); - ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &VisualServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &VisualServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles); - ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &VisualServer::canvas_item_add_set_transform); - ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &VisualServer::canvas_item_add_clip_ignore); - ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &VisualServer::canvas_item_set_sort_children_by_y); + ClassDB::bind_method(D_METHOD("canvas_item_create"), &RenderingServer::canvas_item_create); + ClassDB::bind_method(D_METHOD("canvas_item_set_parent", "item", "parent"), &RenderingServer::canvas_item_set_parent); + ClassDB::bind_method(D_METHOD("canvas_item_set_visible", "item", "visible"), &RenderingServer::canvas_item_set_visible); + ClassDB::bind_method(D_METHOD("canvas_item_set_light_mask", "item", "mask"), &RenderingServer::canvas_item_set_light_mask); + ClassDB::bind_method(D_METHOD("canvas_item_set_transform", "item", "transform"), &RenderingServer::canvas_item_set_transform); + ClassDB::bind_method(D_METHOD("canvas_item_set_clip", "item", "clip"), &RenderingServer::canvas_item_set_clip); + ClassDB::bind_method(D_METHOD("canvas_item_set_distance_field_mode", "item", "enabled"), &RenderingServer::canvas_item_set_distance_field_mode); + ClassDB::bind_method(D_METHOD("canvas_item_set_custom_rect", "item", "use_custom_rect", "rect"), &RenderingServer::canvas_item_set_custom_rect, DEFVAL(Rect2())); + ClassDB::bind_method(D_METHOD("canvas_item_set_modulate", "item", "color"), &RenderingServer::canvas_item_set_modulate); + ClassDB::bind_method(D_METHOD("canvas_item_set_self_modulate", "item", "color"), &RenderingServer::canvas_item_set_self_modulate); + ClassDB::bind_method(D_METHOD("canvas_item_set_draw_behind_parent", "item", "enabled"), &RenderingServer::canvas_item_set_draw_behind_parent); + ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width", "antialiased"), &RenderingServer::canvas_item_add_line, DEFVAL(1.0), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_rect", "item", "rect", "color"), &RenderingServer::canvas_item_add_rect); + ClassDB::bind_method(D_METHOD("canvas_item_add_circle", "item", "pos", "radius", "color"), &RenderingServer::canvas_item_add_circle); + ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect", "item", "rect", "texture", "tile", "modulate", "transpose", "normal_map"), &RenderingServer::canvas_item_add_texture_rect, DEFVAL(false), DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_texture_rect_region", "item", "rect", "texture", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &RenderingServer::canvas_item_add_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(RID()), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &RenderingServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &RenderingServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &RenderingServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased"), &RenderingServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &RenderingServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &RenderingServer::canvas_item_add_multimesh, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &RenderingServer::canvas_item_add_particles); + ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &RenderingServer::canvas_item_add_set_transform); + ClassDB::bind_method(D_METHOD("canvas_item_add_clip_ignore", "item", "ignore"), &RenderingServer::canvas_item_add_clip_ignore); + ClassDB::bind_method(D_METHOD("canvas_item_set_sort_children_by_y", "item", "enabled"), &RenderingServer::canvas_item_set_sort_children_by_y); #endif - ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &VisualServer::canvas_item_set_z_index); - ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &VisualServer::canvas_item_set_z_as_relative_to_parent); - ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &VisualServer::canvas_item_set_copy_to_backbuffer); - ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &VisualServer::canvas_item_clear); - ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &VisualServer::canvas_item_set_draw_index); - ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &VisualServer::canvas_item_set_material); - ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &VisualServer::canvas_item_set_use_parent_material); - ClassDB::bind_method(D_METHOD("canvas_light_create"), &VisualServer::canvas_light_create); - ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &VisualServer::canvas_light_attach_to_canvas); - ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &VisualServer::canvas_light_set_enabled); - ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &VisualServer::canvas_light_set_scale); - ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &VisualServer::canvas_light_set_transform); - ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &VisualServer::canvas_light_set_texture); - ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &VisualServer::canvas_light_set_texture_offset); - ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &VisualServer::canvas_light_set_color); - ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &VisualServer::canvas_light_set_height); - ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &VisualServer::canvas_light_set_energy); - ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &VisualServer::canvas_light_set_z_range); - ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &VisualServer::canvas_light_set_layer_range); - ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_cull_mask); - ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &VisualServer::canvas_light_set_item_shadow_cull_mask); - ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &VisualServer::canvas_light_set_mode); - ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &VisualServer::canvas_light_set_shadow_enabled); - ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &VisualServer::canvas_light_set_shadow_buffer_size); - ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &VisualServer::canvas_light_set_shadow_filter); - ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &VisualServer::canvas_light_set_shadow_color); - ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &VisualServer::canvas_light_set_shadow_smooth); - - ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &VisualServer::canvas_light_occluder_create); - ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &VisualServer::canvas_light_occluder_attach_to_canvas); - ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &VisualServer::canvas_light_occluder_set_enabled); - ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &VisualServer::canvas_light_occluder_set_polygon); - ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &VisualServer::canvas_light_occluder_set_transform); - ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &VisualServer::canvas_light_occluder_set_light_mask); - - ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &VisualServer::canvas_occluder_polygon_create); - ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &VisualServer::canvas_occluder_polygon_set_shape); - ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &VisualServer::canvas_occluder_polygon_set_shape_as_lines); - ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &VisualServer::canvas_occluder_polygon_set_cull_mode); - - ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_margins); - ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &VisualServer::black_bars_set_images); - - ClassDB::bind_method(D_METHOD("free_rid", "rid"), &VisualServer::free); // shouldn't conflict with Object::free() - - ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &VisualServer::request_frame_drawn_callback); - ClassDB::bind_method(D_METHOD("has_changed"), &VisualServer::has_changed); - ClassDB::bind_method(D_METHOD("init"), &VisualServer::init); - ClassDB::bind_method(D_METHOD("finish"), &VisualServer::finish); - ClassDB::bind_method(D_METHOD("get_render_info", "info"), &VisualServer::get_render_info); - ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &VisualServer::get_video_adapter_name); - ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &VisualServer::get_video_adapter_vendor); + ClassDB::bind_method(D_METHOD("canvas_item_set_z_index", "item", "z_index"), &RenderingServer::canvas_item_set_z_index); + ClassDB::bind_method(D_METHOD("canvas_item_set_z_as_relative_to_parent", "item", "enabled"), &RenderingServer::canvas_item_set_z_as_relative_to_parent); + ClassDB::bind_method(D_METHOD("canvas_item_set_copy_to_backbuffer", "item", "enabled", "rect"), &RenderingServer::canvas_item_set_copy_to_backbuffer); + ClassDB::bind_method(D_METHOD("canvas_item_clear", "item"), &RenderingServer::canvas_item_clear); + ClassDB::bind_method(D_METHOD("canvas_item_set_draw_index", "item", "index"), &RenderingServer::canvas_item_set_draw_index); + ClassDB::bind_method(D_METHOD("canvas_item_set_material", "item", "material"), &RenderingServer::canvas_item_set_material); + ClassDB::bind_method(D_METHOD("canvas_item_set_use_parent_material", "item", "enabled"), &RenderingServer::canvas_item_set_use_parent_material); + ClassDB::bind_method(D_METHOD("canvas_light_create"), &RenderingServer::canvas_light_create); + ClassDB::bind_method(D_METHOD("canvas_light_attach_to_canvas", "light", "canvas"), &RenderingServer::canvas_light_attach_to_canvas); + ClassDB::bind_method(D_METHOD("canvas_light_set_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_enabled); + ClassDB::bind_method(D_METHOD("canvas_light_set_scale", "light", "scale"), &RenderingServer::canvas_light_set_scale); + ClassDB::bind_method(D_METHOD("canvas_light_set_transform", "light", "transform"), &RenderingServer::canvas_light_set_transform); + ClassDB::bind_method(D_METHOD("canvas_light_set_texture", "light", "texture"), &RenderingServer::canvas_light_set_texture); + ClassDB::bind_method(D_METHOD("canvas_light_set_texture_offset", "light", "offset"), &RenderingServer::canvas_light_set_texture_offset); + ClassDB::bind_method(D_METHOD("canvas_light_set_color", "light", "color"), &RenderingServer::canvas_light_set_color); + ClassDB::bind_method(D_METHOD("canvas_light_set_height", "light", "height"), &RenderingServer::canvas_light_set_height); + ClassDB::bind_method(D_METHOD("canvas_light_set_energy", "light", "energy"), &RenderingServer::canvas_light_set_energy); + ClassDB::bind_method(D_METHOD("canvas_light_set_z_range", "light", "min_z", "max_z"), &RenderingServer::canvas_light_set_z_range); + ClassDB::bind_method(D_METHOD("canvas_light_set_layer_range", "light", "min_layer", "max_layer"), &RenderingServer::canvas_light_set_layer_range); + ClassDB::bind_method(D_METHOD("canvas_light_set_item_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_cull_mask); + ClassDB::bind_method(D_METHOD("canvas_light_set_item_shadow_cull_mask", "light", "mask"), &RenderingServer::canvas_light_set_item_shadow_cull_mask); + ClassDB::bind_method(D_METHOD("canvas_light_set_mode", "light", "mode"), &RenderingServer::canvas_light_set_mode); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_enabled", "light", "enabled"), &RenderingServer::canvas_light_set_shadow_enabled); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_buffer_size", "light", "size"), &RenderingServer::canvas_light_set_shadow_buffer_size); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_filter", "light", "filter"), &RenderingServer::canvas_light_set_shadow_filter); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_color", "light", "color"), &RenderingServer::canvas_light_set_shadow_color); + ClassDB::bind_method(D_METHOD("canvas_light_set_shadow_smooth", "light", "smooth"), &RenderingServer::canvas_light_set_shadow_smooth); + + ClassDB::bind_method(D_METHOD("canvas_light_occluder_create"), &RenderingServer::canvas_light_occluder_create); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_attach_to_canvas", "occluder", "canvas"), &RenderingServer::canvas_light_occluder_attach_to_canvas); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_enabled", "occluder", "enabled"), &RenderingServer::canvas_light_occluder_set_enabled); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_polygon", "occluder", "polygon"), &RenderingServer::canvas_light_occluder_set_polygon); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_transform", "occluder", "transform"), &RenderingServer::canvas_light_occluder_set_transform); + ClassDB::bind_method(D_METHOD("canvas_light_occluder_set_light_mask", "occluder", "mask"), &RenderingServer::canvas_light_occluder_set_light_mask); + + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_create"), &RenderingServer::canvas_occluder_polygon_create); + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape", "occluder_polygon", "shape", "closed"), &RenderingServer::canvas_occluder_polygon_set_shape); + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_shape_as_lines", "occluder_polygon", "shape"), &RenderingServer::canvas_occluder_polygon_set_shape_as_lines); + ClassDB::bind_method(D_METHOD("canvas_occluder_polygon_set_cull_mode", "occluder_polygon", "mode"), &RenderingServer::canvas_occluder_polygon_set_cull_mode); + + ClassDB::bind_method(D_METHOD("black_bars_set_margins", "left", "top", "right", "bottom"), &RenderingServer::black_bars_set_margins); + ClassDB::bind_method(D_METHOD("black_bars_set_images", "left", "top", "right", "bottom"), &RenderingServer::black_bars_set_images); + + ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free); // shouldn't conflict with Object::free() + + ClassDB::bind_method(D_METHOD("request_frame_drawn_callback", "where", "method", "userdata"), &RenderingServer::request_frame_drawn_callback); + ClassDB::bind_method(D_METHOD("has_changed"), &RenderingServer::has_changed); + ClassDB::bind_method(D_METHOD("init"), &RenderingServer::init); + ClassDB::bind_method(D_METHOD("finish"), &RenderingServer::finish); + ClassDB::bind_method(D_METHOD("get_render_info", "info"), &RenderingServer::get_render_info); + ClassDB::bind_method(D_METHOD("get_video_adapter_name"), &RenderingServer::get_video_adapter_name); + ClassDB::bind_method(D_METHOD("get_video_adapter_vendor"), &RenderingServer::get_video_adapter_vendor); #ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &VisualServer::make_sphere_mesh); - ClassDB::bind_method(D_METHOD("get_test_cube"), &VisualServer::get_test_cube); + ClassDB::bind_method(D_METHOD("make_sphere_mesh", "latitudes", "longitudes", "radius"), &RenderingServer::make_sphere_mesh); + ClassDB::bind_method(D_METHOD("get_test_cube"), &RenderingServer::get_test_cube); #endif - ClassDB::bind_method(D_METHOD("get_test_texture"), &VisualServer::get_test_texture); - ClassDB::bind_method(D_METHOD("get_white_texture"), &VisualServer::get_white_texture); + ClassDB::bind_method(D_METHOD("get_test_texture"), &RenderingServer::get_test_texture); + ClassDB::bind_method(D_METHOD("get_white_texture"), &RenderingServer::get_white_texture); - ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &VisualServer::set_boot_image, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &VisualServer::set_default_clear_color); + ClassDB::bind_method(D_METHOD("set_boot_image", "image", "color", "scale", "use_filter"), &RenderingServer::set_boot_image, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("set_default_clear_color", "color"), &RenderingServer::set_default_clear_color); - ClassDB::bind_method(D_METHOD("has_feature", "feature"), &VisualServer::has_feature); - ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &VisualServer::has_os_feature); - ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &VisualServer::set_debug_generate_wireframes); + ClassDB::bind_method(D_METHOD("has_feature", "feature"), &RenderingServer::has_feature); + ClassDB::bind_method(D_METHOD("has_os_feature", "feature"), &RenderingServer::has_os_feature); + ClassDB::bind_method(D_METHOD("set_debug_generate_wireframes", "generate"), &RenderingServer::set_debug_generate_wireframes); BIND_CONSTANT(NO_INDEX_ARRAY); BIND_CONSTANT(ARRAY_WEIGHTS_SIZE); @@ -2227,18 +2227,18 @@ void VisualServer::_bind_methods() { ADD_SIGNAL(MethodInfo("frame_post_draw")); } -void VisualServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) { +void RenderingServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) { ERR_FAIL_COND(p_margins.size() != 4); //canvas_item_add_style_box(p_item,p_rect,p_source,p_texture,Vector2(p_margins[0],p_margins[1]),Vector2(p_margins[2],p_margins[3]),true,p_modulate); } -void VisualServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) { +void RenderingServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far) { camera_set_orthogonal(p_camera, p_size, p_z_near, p_z_far); } -void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) { +void RenderingServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) { Vector<Vector3> vertices; Vector<Vector3> normals; @@ -2260,23 +2260,23 @@ void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::M } Array d; - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); d[ARRAY_VERTEX] = vertices; d[ARRAY_NORMAL] = normals; mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d); } -void VisualServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) { +void RenderingServer::mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes) { Geometry::MeshData mdata = Geometry::build_convex_mesh(p_planes); mesh_add_surface_from_mesh_data(p_mesh, mdata); } -void VisualServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex) { +void RenderingServer::immediate_vertex_2d(RID p_immediate, const Vector2 &p_vertex) { immediate_vertex(p_immediate, Vector3(p_vertex.x, p_vertex.y, 0)); } -RID VisualServer::instance_create2(RID p_base, RID p_scenario) { +RID RenderingServer::instance_create2(RID p_base, RID p_scenario) { RID instance = instance_create(); instance_set_base(instance, p_base); @@ -2284,7 +2284,7 @@ RID VisualServer::instance_create2(RID p_base, RID p_scenario) { return instance; } -VisualServer::VisualServer() { +RenderingServer::RenderingServer() { //ERR_FAIL_COND(singleton); singleton = this; @@ -2355,9 +2355,16 @@ VisualServer::VisualServer() { ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/screen_space_roughness_limiter", PropertyInfo(Variant::INT, "rendering/quality/filters/screen_space_roughness_limiter", PROPERTY_HINT_ENUM, "Disabled,Enabled (Small Cost)")); GLOBAL_DEF("rendering/quality/filters/screen_space_roughness_limiter_curve", 1.0); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/screen_space_roughness_limiter_curve", PropertyInfo(Variant::FLOAT, "rendering/quality/filters/screen_space_roughness_limiter_curve", PROPERTY_HINT_EXP_EASING, "0.01,8,0.01")); + + GLOBAL_DEF("rendering/quality/glow/upscale_mode", 1); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/glow/upscale_mode", PropertyInfo(Variant::INT, "rendering/quality/glow/upscale_mode", PROPERTY_HINT_ENUM, "Linear (Fast),Bicubic (Slower)")); + GLOBAL_DEF("rendering/quality/glow/upscale_mode.mobile", 0); + + GLOBAL_DEF("rendering/quality/screen_space_reflection/roughness_quality", 1); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_space_reflection/roughness_quality", PropertyInfo(Variant::INT, "rendering/quality/screen_space_reflection/roughness_quality", PROPERTY_HINT_ENUM, "Disabled (Fastest),Low, Medium, High (Slowest)")); } -VisualServer::~VisualServer() { +RenderingServer::~RenderingServer() { - singleton = NULL; + singleton = nullptr; } diff --git a/servers/visual_server.h b/servers/rendering_server.h index 506800cc7d..9726a71f0c 100644 --- a/servers/visual_server.h +++ b/servers/rendering_server.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* visual_server.h */ +/* rendering_server.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VISUAL_SERVER_H -#define VISUAL_SERVER_H +#ifndef RENDERING_SERVER_H +#define RENDERING_SERVER_H #include "core/image.h" #include "core/math/geometry.h" @@ -39,11 +39,11 @@ #include "core/variant.h" #include "servers/display_server.h" -class VisualServer : public Object { +class RenderingServer : public Object { - GDCLASS(VisualServer, Object); + GDCLASS(RenderingServer, Object); - static VisualServer *singleton; + static RenderingServer *singleton; int mm_policy; @@ -60,12 +60,12 @@ protected: Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, Vector<uint8_t> &r_vertex_array, int p_vertex_array_len, Vector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> &r_bone_aabb); - static VisualServer *(*create_func)(); + static RenderingServer *(*create_func)(); static void _bind_methods(); public: - static VisualServer *get_singleton(); - static VisualServer *create(); + static RenderingServer *get_singleton(); + static RenderingServer *create(); enum { NO_INDEX_ARRAY = -1, @@ -733,7 +733,9 @@ public: ENV_GLOW_BLEND_MODE_REPLACE, ENV_GLOW_BLEND_MODE_MIX, }; - virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale) = 0; + virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) = 0; + + virtual void environment_glow_set_use_bicubic_upscale(bool p_enable) = 0; enum EnvironmentToneMapper { ENV_TONE_MAPPER_LINEAR, @@ -745,7 +747,16 @@ public: virtual void environment_set_tonemap(RID p_env, EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_grey) = 0; virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp) = 0; - virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness) = 0; + virtual void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance) = 0; + + enum EnvironmentSSRRoughnessQuality { + ENV_SSR_ROUGNESS_QUALITY_DISABLED, + ENV_SSR_ROUGNESS_QUALITY_LOW, + ENV_SSR_ROUGNESS_QUALITY_MEDIUM, + ENV_SSR_ROUGNESS_QUALITY_HIGH, + }; + + virtual void environment_set_ssr_roughness_quality(EnvironmentSSRRoughnessQuality p_quality) = 0; enum EnvironmentSSAOBlur { ENV_SSAO_BLUR_DISABLED, @@ -1103,55 +1114,55 @@ public: virtual bool is_low_end() const = 0; - VisualServer(); - virtual ~VisualServer(); + RenderingServer(); + virtual ~RenderingServer(); }; // make variant understand the enums -VARIANT_ENUM_CAST(VisualServer::TextureLayeredType); -VARIANT_ENUM_CAST(VisualServer::CubeMapLayer); -VARIANT_ENUM_CAST(VisualServer::ShaderMode); -VARIANT_ENUM_CAST(VisualServer::ArrayType); -VARIANT_ENUM_CAST(VisualServer::ArrayFormat); -VARIANT_ENUM_CAST(VisualServer::PrimitiveType); -VARIANT_ENUM_CAST(VisualServer::BlendShapeMode); -VARIANT_ENUM_CAST(VisualServer::MultimeshTransformFormat); -VARIANT_ENUM_CAST(VisualServer::LightType); -VARIANT_ENUM_CAST(VisualServer::LightParam); -VARIANT_ENUM_CAST(VisualServer::LightOmniShadowMode); -VARIANT_ENUM_CAST(VisualServer::LightDirectionalShadowMode); -VARIANT_ENUM_CAST(VisualServer::LightDirectionalShadowDepthRangeMode); -VARIANT_ENUM_CAST(VisualServer::ReflectionProbeUpdateMode); -VARIANT_ENUM_CAST(VisualServer::ParticlesDrawOrder); -VARIANT_ENUM_CAST(VisualServer::ViewportUpdateMode); -VARIANT_ENUM_CAST(VisualServer::ViewportClearMode); -VARIANT_ENUM_CAST(VisualServer::ViewportMSAA); -VARIANT_ENUM_CAST(VisualServer::ViewportRenderInfo); -VARIANT_ENUM_CAST(VisualServer::ViewportDebugDraw); -VARIANT_ENUM_CAST(VisualServer::SkyMode); -VARIANT_ENUM_CAST(VisualServer::EnvironmentBG); -VARIANT_ENUM_CAST(VisualServer::EnvironmentAmbientSource); -VARIANT_ENUM_CAST(VisualServer::EnvironmentReflectionSource); -VARIANT_ENUM_CAST(VisualServer::EnvironmentGlowBlendMode); -VARIANT_ENUM_CAST(VisualServer::EnvironmentToneMapper); -VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOQuality); -VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOBlur); -VARIANT_ENUM_CAST(VisualServer::DOFBlurQuality); -VARIANT_ENUM_CAST(VisualServer::DOFBokehShape); -VARIANT_ENUM_CAST(VisualServer::ScenarioDebugMode); -VARIANT_ENUM_CAST(VisualServer::InstanceType); -VARIANT_ENUM_CAST(VisualServer::InstanceFlags); -VARIANT_ENUM_CAST(VisualServer::ShadowCastingSetting); -VARIANT_ENUM_CAST(VisualServer::NinePatchAxisMode); -VARIANT_ENUM_CAST(VisualServer::CanvasItemTextureFilter); -VARIANT_ENUM_CAST(VisualServer::CanvasItemTextureRepeat); -VARIANT_ENUM_CAST(VisualServer::CanvasLightMode); -VARIANT_ENUM_CAST(VisualServer::CanvasLightShadowFilter); -VARIANT_ENUM_CAST(VisualServer::CanvasOccluderPolygonCullMode); -VARIANT_ENUM_CAST(VisualServer::RenderInfo); -VARIANT_ENUM_CAST(VisualServer::Features); - -//typedef VisualServer VS; // makes it easier to use -#define VS VisualServer +VARIANT_ENUM_CAST(RenderingServer::TextureLayeredType); +VARIANT_ENUM_CAST(RenderingServer::CubeMapLayer); +VARIANT_ENUM_CAST(RenderingServer::ShaderMode); +VARIANT_ENUM_CAST(RenderingServer::ArrayType); +VARIANT_ENUM_CAST(RenderingServer::ArrayFormat); +VARIANT_ENUM_CAST(RenderingServer::PrimitiveType); +VARIANT_ENUM_CAST(RenderingServer::BlendShapeMode); +VARIANT_ENUM_CAST(RenderingServer::MultimeshTransformFormat); +VARIANT_ENUM_CAST(RenderingServer::LightType); +VARIANT_ENUM_CAST(RenderingServer::LightParam); +VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowMode); +VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowMode); +VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowDepthRangeMode); +VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeUpdateMode); +VARIANT_ENUM_CAST(RenderingServer::ParticlesDrawOrder); +VARIANT_ENUM_CAST(RenderingServer::ViewportUpdateMode); +VARIANT_ENUM_CAST(RenderingServer::ViewportClearMode); +VARIANT_ENUM_CAST(RenderingServer::ViewportMSAA); +VARIANT_ENUM_CAST(RenderingServer::ViewportRenderInfo); +VARIANT_ENUM_CAST(RenderingServer::ViewportDebugDraw); +VARIANT_ENUM_CAST(RenderingServer::SkyMode); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentBG); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentAmbientSource); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentReflectionSource); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentGlowBlendMode); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentToneMapper); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSAOQuality); +VARIANT_ENUM_CAST(RenderingServer::EnvironmentSSAOBlur); +VARIANT_ENUM_CAST(RenderingServer::DOFBlurQuality); +VARIANT_ENUM_CAST(RenderingServer::DOFBokehShape); +VARIANT_ENUM_CAST(RenderingServer::ScenarioDebugMode); +VARIANT_ENUM_CAST(RenderingServer::InstanceType); +VARIANT_ENUM_CAST(RenderingServer::InstanceFlags); +VARIANT_ENUM_CAST(RenderingServer::ShadowCastingSetting); +VARIANT_ENUM_CAST(RenderingServer::NinePatchAxisMode); +VARIANT_ENUM_CAST(RenderingServer::CanvasItemTextureFilter); +VARIANT_ENUM_CAST(RenderingServer::CanvasItemTextureRepeat); +VARIANT_ENUM_CAST(RenderingServer::CanvasLightMode); +VARIANT_ENUM_CAST(RenderingServer::CanvasLightShadowFilter); +VARIANT_ENUM_CAST(RenderingServer::CanvasOccluderPolygonCullMode); +VARIANT_ENUM_CAST(RenderingServer::RenderInfo); +VARIANT_ENUM_CAST(RenderingServer::Features); + +//typedef RenderingServer VS; // makes it easier to use +#define RS RenderingServer #endif diff --git a/servers/visual/rasterizer_rd/shaders/SCsub b/servers/visual/rasterizer_rd/shaders/SCsub deleted file mode 100644 index 2dcb2a703f..0000000000 --- a/servers/visual/rasterizer_rd/shaders/SCsub +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -if 'RD_GLSL' in env['BUILDERS']: - env.RD_GLSL('canvas.glsl'); - env.RD_GLSL('canvas_occlusion.glsl'); - env.RD_GLSL('blur.glsl'); - env.RD_GLSL('cubemap_roughness.glsl'); - env.RD_GLSL('cubemap_downsampler.glsl'); - env.RD_GLSL('cubemap_filter.glsl'); - env.RD_GLSL('scene_high_end.glsl'); - env.RD_GLSL('sky.glsl'); - env.RD_GLSL('tonemap.glsl'); - env.RD_GLSL('copy.glsl'); - env.RD_GLSL('giprobe.glsl'); - env.RD_GLSL('giprobe_debug.glsl'); - env.RD_GLSL('giprobe_sdf.glsl'); - env.RD_GLSL('luminance_reduce.glsl'); - env.RD_GLSL('bokeh_dof.glsl'); - env.RD_GLSL('ssao.glsl'); - env.RD_GLSL('ssao_minify.glsl'); - env.RD_GLSL('ssao_blur.glsl'); - env.RD_GLSL('roughness_limiter.glsl'); diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp deleted file mode 100644 index 041ad799d0..0000000000 --- a/servers/visual/shader_types.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/*************************************************************************/ -/* shader_types.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "shader_types.h" - -const Map<StringName, ShaderLanguage::FunctionInfo> &ShaderTypes::get_functions(VS::ShaderMode p_mode) { - - return shader_modes[p_mode].functions; -} - -const Vector<StringName> &ShaderTypes::get_modes(VS::ShaderMode p_mode) { - - return shader_modes[p_mode].modes; -} - -const Set<String> &ShaderTypes::get_types() { - return shader_types; -} - -ShaderTypes *ShaderTypes::singleton = NULL; - -static ShaderLanguage::BuiltInInfo constt(ShaderLanguage::DataType p_type) { - - return ShaderLanguage::BuiltInInfo(p_type, true); -} - -ShaderTypes::ShaderTypes() { - singleton = this; - - /*************** SPATIAL ***********************/ - - shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["POSITION"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["UV2"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_ID"] = constt(ShaderLanguage::TYPE_INT); - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].can_discard = false; - - //builtins - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["WORLD_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_MATRIX"] = ShaderLanguage::TYPE_MAT4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_NORMAL_MATRIX"] = ShaderLanguage::TYPE_MAT3; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); - - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VERTEX"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["FRONT_FACING"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["BINORMAL"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALBEDO"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["METALLIC"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SPECULAR"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ROUGHNESS"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["RIM_TINT"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["CLEARCOAT_GLOSS"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["ANISOTROPY_FLOW"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SSS_STRENGTH"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["TRANSMISSION"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["AO"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["AO_LIGHT_AFFECT"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["EMISSION"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH_TEXTURE"] = ShaderLanguage::TYPE_SAMPLER2D; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["DEPTH"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); - - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); - - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["WORLD_NORMAL_MATRIX"] = constt(ShaderLanguage::TYPE_MAT3); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["fragment"].can_discard = true; - - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["INV_CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["UV2"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["VIEW"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ATTENUATION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ALBEDO"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["TRANSMISSION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ROUGHNESS"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["DIFFUSE_LIGHT"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["SPECULAR_LIGHT"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SPATIAL].functions["light"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; - - shader_modes[VS::SHADER_SPATIAL].functions["light"].can_discard = true; - - //order used puts first enum mode (default) first - shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_mix"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_add"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_sub"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("blend_mul"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_opaque"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_always"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_draw_never"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_prepass_alpha"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("depth_test_disabled"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_back"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_front"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("cull_disabled"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("unshaded"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("wireframe"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_lambert"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_lambert_wrap"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_oren_nayar"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_burley"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("diffuse_toon"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_schlick_ggx"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_blinn"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_phong"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_toon"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("specular_disabled"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("skip_vertex_transform"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("world_vertex_coords"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("shadows_disabled"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("ambient_light_disabled"); - shader_modes[VS::SHADER_SPATIAL].modes.push_back("shadow_to_opacity"); - - shader_modes[VS::SHADER_SPATIAL].modes.push_back("vertex_lighting"); - - /************ CANVAS ITEM **************************/ - - shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["POINT_SIZE"] = ShaderLanguage::TYPE_FLOAT; - - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["WORLD_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["CANVAS_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["SCREEN_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["INSTANCE_CUSTOM"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].can_discard = false; - - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SHADOW_VERTEX"] = ShaderLanguage::TYPE_VEC2; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["LIGHT_VERTEX"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMALMAP_DEPTH"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["NORMAL_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["AT_LIGHT_PASS"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].can_discard = true; - - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SPECULAR_SHININESS"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_COLOR"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT_VERTEX"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["LIGHT"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SHADOW_MODULATE"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["TEXTURE_PIXEL_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["POINT_COORD"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].can_discard = true; - - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("skip_vertex_transform"); - - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_mix"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_add"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_sub"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_mul"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_premul_alpha"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("blend_disabled"); - - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("unshaded"); - shader_modes[VS::SHADER_CANVAS_ITEM].modes.push_back("light_only"); - - /************ PARTICLES **************************/ - - shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["MASS"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["ACTIVE"] = ShaderLanguage::TYPE_BOOL; - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["RESTART"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["CUSTOM"] = ShaderLanguage::TYPE_VEC4; - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["TRANSFORM"] = ShaderLanguage::TYPE_MAT4; - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["LIFETIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["DELTA"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["NUMBER"] = constt(ShaderLanguage::TYPE_UINT); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["INDEX"] = constt(ShaderLanguage::TYPE_INT); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["EMISSION_TRANSFORM"] = constt(ShaderLanguage::TYPE_MAT4); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["RANDOM_SEED"] = constt(ShaderLanguage::TYPE_UINT); - shader_modes[VS::SHADER_PARTICLES].functions["vertex"].can_discard = false; - - shader_modes[VS::SHADER_PARTICLES].modes.push_back("disable_force"); - shader_modes[VS::SHADER_PARTICLES].modes.push_back("disable_velocity"); - shader_modes[VS::SHADER_PARTICLES].modes.push_back("keep_data"); - - /************ SKY **************************/ - - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["POSITION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["RADIANCE"] = constt(ShaderLanguage::TYPE_SAMPLERCUBE); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["AT_HALF_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["AT_QUARTER_RES_PASS"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["AT_CUBEMAP_PASS"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT0_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT0_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT0_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT0_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT1_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT1_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT1_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT1_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT2_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT2_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT2_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT2_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT3_ENABLED"] = constt(ShaderLanguage::TYPE_BOOL); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT3_DIRECTION"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT3_ENERGY"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[VS::SHADER_SKY].functions["global"].built_ins["LIGHT3_COLOR"] = constt(ShaderLanguage::TYPE_VEC3); - - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC3; - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["ALPHA"] = ShaderLanguage::TYPE_FLOAT; - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["EYEDIR"] = constt(ShaderLanguage::TYPE_VEC3); - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["SCREEN_UV"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["SKY_COORDS"] = constt(ShaderLanguage::TYPE_VEC2); - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["HALF_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4); - shader_modes[VS::SHADER_SKY].functions["fragment"].built_ins["QUARTER_RES_COLOR"] = constt(ShaderLanguage::TYPE_VEC4); - - shader_modes[VS::SHADER_SKY].modes.push_back("use_half_res_pass"); - shader_modes[VS::SHADER_SKY].modes.push_back("use_quarter_res_pass"); - - shader_types.insert("spatial"); - shader_types.insert("canvas_item"); - shader_types.insert("particles"); - shader_types.insert("sky"); -} diff --git a/servers/visual/visual_server_globals.cpp b/servers/visual/visual_server_globals.cpp deleted file mode 100644 index 248d27e08a..0000000000 --- a/servers/visual/visual_server_globals.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************/ -/* visual_server_globals.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "visual_server_globals.h" - -RasterizerStorage *VisualServerGlobals::storage = NULL; -RasterizerCanvas *VisualServerGlobals::canvas_render = NULL; -RasterizerScene *VisualServerGlobals::scene_render = NULL; -Rasterizer *VisualServerGlobals::rasterizer = NULL; - -VisualServerCanvas *VisualServerGlobals::canvas = NULL; -VisualServerViewport *VisualServerGlobals::viewport = NULL; -VisualServerScene *VisualServerGlobals::scene = NULL; diff --git a/thirdparty/README.md b/thirdparty/README.md index b52b68fe47..95a6902089 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -360,6 +360,10 @@ Collection of single-file libraries used in Godot components. * Upstream: https://sourceforge.net/projects/polyclipping * Version: 6.4.2 + Godot changes (added optional exceptions handling) * License: BSL-1.0 +- `cubemap_coeffs.h` + * Upstream: https://research.activision.com/publications/archives/fast-filtering-of-reflection-probes + File coeffs_const_8.txt + * License: MIT - `fastlz.{c,h}` * Upstream: https://github.com/ariya/FastLZ * Version: git (f121734, 2007) @@ -570,6 +574,8 @@ Files extracted from upstream source: `vk_enum_string_helper.h` is taken from the matching `Vulkan-ValidationLayers` SDK release: https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/layers/generated/vk_enum_string_helper.h +Includes custom change to disable MSVC pragma, might be upstreamed via: +https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/1666 `vk_mem_alloc.h` is taken from https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator Version: 2.3.0 diff --git a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp index 5656556db9..5c7ebed788 100644 --- a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp +++ b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp @@ -508,7 +508,7 @@ namespace Etc int iMaxRed1 = iColor1Red + (int)a_uiRadius; if (iMaxRed1 > 15) { - iMinRed1 = 15; + iMaxRed1 = 15; } int iMinGreen1 = iColor1Green - (int)a_uiRadius; @@ -519,7 +519,7 @@ namespace Etc int iMaxGreen1 = iColor1Green + (int)a_uiRadius; if (iMaxGreen1 > 15) { - iMinGreen1 = 15; + iMaxGreen1 = 15; } int iMinBlue1 = iColor1Blue - (int)a_uiRadius; @@ -530,7 +530,7 @@ namespace Etc int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; if (iMaxBlue1 > 15) { - iMinBlue1 = 15; + iMaxBlue1 = 15; } int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); @@ -545,7 +545,7 @@ namespace Etc int iMaxRed2 = iColor2Red + (int)a_uiRadius; if (iMaxRed2 > 15) { - iMinRed2 = 15; + iMaxRed2 = 15; } int iMinGreen2 = iColor2Green - (int)a_uiRadius; @@ -556,7 +556,7 @@ namespace Etc int iMaxGreen2 = iColor2Green + (int)a_uiRadius; if (iMaxGreen2 > 15) { - iMinGreen2 = 15; + iMaxGreen2 = 15; } int iMinBlue2 = iColor2Blue - (int)a_uiRadius; @@ -567,7 +567,7 @@ namespace Etc int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; if (iMaxBlue2 > 15) { - iMinBlue2 = 15; + iMaxBlue2 = 15; } for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) @@ -761,7 +761,7 @@ namespace Etc int iMaxRed1 = iColor1Red + (int)a_uiRadius; if (iMaxRed1 > 15) { - iMinRed1 = 15; + iMaxRed1 = 15; } int iMinGreen1 = iColor1Green - (int)a_uiRadius; @@ -772,7 +772,7 @@ namespace Etc int iMaxGreen1 = iColor1Green + (int)a_uiRadius; if (iMaxGreen1 > 15) { - iMinGreen1 = 15; + iMaxGreen1 = 15; } int iMinBlue1 = iColor1Blue - (int)a_uiRadius; @@ -783,7 +783,7 @@ namespace Etc int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; if (iMaxBlue1 > 15) { - iMinBlue1 = 15; + iMaxBlue1 = 15; } int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); @@ -798,7 +798,7 @@ namespace Etc int iMaxRed2 = iColor2Red + (int)a_uiRadius; if (iMaxRed2 > 15) { - iMinRed2 = 15; + iMaxRed2 = 15; } int iMinGreen2 = iColor2Green - (int)a_uiRadius; @@ -809,7 +809,7 @@ namespace Etc int iMaxGreen2 = iColor2Green + (int)a_uiRadius; if (iMaxGreen2 > 15) { - iMinGreen2 = 15; + iMaxGreen2 = 15; } int iMinBlue2 = iColor2Blue - (int)a_uiRadius; @@ -820,7 +820,7 @@ namespace Etc int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; if (iMaxBlue2 > 15) { - iMinBlue2 = 15; + iMaxBlue2 = 15; } for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) diff --git a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp index ba2b42fb05..b94b64e68c 100644 --- a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp +++ b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp @@ -847,7 +847,7 @@ namespace Etc int iMaxRed1 = iColor1Red + (int)a_uiRadius; if (iMaxRed1 > 15) { - iMinRed1 = 15; + iMaxRed1 = 15; } int iMinGreen1 = iColor1Green - (int)a_uiRadius; @@ -858,7 +858,7 @@ namespace Etc int iMaxGreen1 = iColor1Green + (int)a_uiRadius; if (iMaxGreen1 > 15) { - iMinGreen1 = 15; + iMaxGreen1 = 15; } int iMinBlue1 = iColor1Blue - (int)a_uiRadius; @@ -869,7 +869,7 @@ namespace Etc int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; if (iMaxBlue1 > 15) { - iMinBlue1 = 15; + iMaxBlue1 = 15; } int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); @@ -884,7 +884,7 @@ namespace Etc int iMaxRed2 = iColor2Red + (int)a_uiRadius; if (iMaxRed2 > 15) { - iMinRed2 = 15; + iMaxRed2 = 15; } int iMinGreen2 = iColor2Green - (int)a_uiRadius; @@ -895,7 +895,7 @@ namespace Etc int iMaxGreen2 = iColor2Green + (int)a_uiRadius; if (iMaxGreen2 > 15) { - iMinGreen2 = 15; + iMaxGreen2 = 15; } int iMinBlue2 = iColor2Blue - (int)a_uiRadius; @@ -906,7 +906,7 @@ namespace Etc int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; if (iMaxBlue2 > 15) { - iMinBlue2 = 15; + iMaxBlue2 = 15; } for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) @@ -1108,7 +1108,7 @@ namespace Etc int iMaxRed1 = iColor1Red + (int)a_uiRadius; if (iMaxRed1 > 15) { - iMinRed1 = 15; + iMaxRed1 = 15; } int iMinGreen1 = iColor1Green - (int)a_uiRadius; @@ -1119,7 +1119,7 @@ namespace Etc int iMaxGreen1 = iColor1Green + (int)a_uiRadius; if (iMaxGreen1 > 15) { - iMinGreen1 = 15; + iMaxGreen1 = 15; } int iMinBlue1 = iColor1Blue - (int)a_uiRadius; @@ -1130,7 +1130,7 @@ namespace Etc int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; if (iMaxBlue1 > 15) { - iMinBlue1 = 15; + iMaxBlue1 = 15; } int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); @@ -1145,7 +1145,7 @@ namespace Etc int iMaxRed2 = iColor2Red + (int)a_uiRadius; if (iMaxRed2 > 15) { - iMinRed2 = 15; + iMaxRed2 = 15; } int iMinGreen2 = iColor2Green - (int)a_uiRadius; @@ -1156,7 +1156,7 @@ namespace Etc int iMaxGreen2 = iColor2Green + (int)a_uiRadius; if (iMaxGreen2 > 15) { - iMinGreen2 = 15; + iMaxGreen2 = 15; } int iMinBlue2 = iColor2Blue - (int)a_uiRadius; @@ -1167,7 +1167,7 @@ namespace Etc int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; if (iMaxBlue2 > 15) { - iMinBlue2 = 15; + iMaxBlue2 = 15; } for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) diff --git a/thirdparty/etc2comp/patches/fix-rgba8-max-channels.patch b/thirdparty/etc2comp/patches/fix-rgba8-max-channels.patch new file mode 100644 index 0000000000..ea9b5640b6 --- /dev/null +++ b/thirdparty/etc2comp/patches/fix-rgba8-max-channels.patch @@ -0,0 +1,224 @@ +diff --git a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp +index 5656556db9..5c7ebed788 100644 +--- a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp ++++ b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8.cpp +@@ -508,7 +508,7 @@ namespace Etc + int iMaxRed1 = iColor1Red + (int)a_uiRadius; + if (iMaxRed1 > 15) + { +- iMinRed1 = 15; ++ iMaxRed1 = 15; + } + + int iMinGreen1 = iColor1Green - (int)a_uiRadius; +@@ -519,7 +519,7 @@ namespace Etc + int iMaxGreen1 = iColor1Green + (int)a_uiRadius; + if (iMaxGreen1 > 15) + { +- iMinGreen1 = 15; ++ iMaxGreen1 = 15; + } + + int iMinBlue1 = iColor1Blue - (int)a_uiRadius; +@@ -530,7 +530,7 @@ namespace Etc + int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; + if (iMaxBlue1 > 15) + { +- iMinBlue1 = 15; ++ iMaxBlue1 = 15; + } + + int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); +@@ -545,7 +545,7 @@ namespace Etc + int iMaxRed2 = iColor2Red + (int)a_uiRadius; + if (iMaxRed2 > 15) + { +- iMinRed2 = 15; ++ iMaxRed2 = 15; + } + + int iMinGreen2 = iColor2Green - (int)a_uiRadius; +@@ -556,7 +556,7 @@ namespace Etc + int iMaxGreen2 = iColor2Green + (int)a_uiRadius; + if (iMaxGreen2 > 15) + { +- iMinGreen2 = 15; ++ iMaxGreen2 = 15; + } + + int iMinBlue2 = iColor2Blue - (int)a_uiRadius; +@@ -567,7 +567,7 @@ namespace Etc + int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; + if (iMaxBlue2 > 15) + { +- iMinBlue2 = 15; ++ iMaxBlue2 = 15; + } + + for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) +@@ -761,7 +761,7 @@ namespace Etc + int iMaxRed1 = iColor1Red + (int)a_uiRadius; + if (iMaxRed1 > 15) + { +- iMinRed1 = 15; ++ iMaxRed1 = 15; + } + + int iMinGreen1 = iColor1Green - (int)a_uiRadius; +@@ -772,7 +772,7 @@ namespace Etc + int iMaxGreen1 = iColor1Green + (int)a_uiRadius; + if (iMaxGreen1 > 15) + { +- iMinGreen1 = 15; ++ iMaxGreen1 = 15; + } + + int iMinBlue1 = iColor1Blue - (int)a_uiRadius; +@@ -783,7 +783,7 @@ namespace Etc + int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; + if (iMaxBlue1 > 15) + { +- iMinBlue1 = 15; ++ iMaxBlue1 = 15; + } + + int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); +@@ -798,7 +798,7 @@ namespace Etc + int iMaxRed2 = iColor2Red + (int)a_uiRadius; + if (iMaxRed2 > 15) + { +- iMinRed2 = 15; ++ iMaxRed2 = 15; + } + + int iMinGreen2 = iColor2Green - (int)a_uiRadius; +@@ -809,7 +809,7 @@ namespace Etc + int iMaxGreen2 = iColor2Green + (int)a_uiRadius; + if (iMaxGreen2 > 15) + { +- iMinGreen2 = 15; ++ iMaxGreen2 = 15; + } + + int iMinBlue2 = iColor2Blue - (int)a_uiRadius; +@@ -820,7 +820,7 @@ namespace Etc + int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; + if (iMaxBlue2 > 15) + { +- iMinBlue2 = 15; ++ iMaxBlue2 = 15; + } + + for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) +diff --git a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp +index ba2b42fb05..b94b64e68c 100644 +--- a/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp ++++ b/thirdparty/etc2comp/EtcBlock4x4Encoding_RGB8A1.cpp +@@ -847,7 +847,7 @@ namespace Etc + int iMaxRed1 = iColor1Red + (int)a_uiRadius; + if (iMaxRed1 > 15) + { +- iMinRed1 = 15; ++ iMaxRed1 = 15; + } + + int iMinGreen1 = iColor1Green - (int)a_uiRadius; +@@ -858,7 +858,7 @@ namespace Etc + int iMaxGreen1 = iColor1Green + (int)a_uiRadius; + if (iMaxGreen1 > 15) + { +- iMinGreen1 = 15; ++ iMaxGreen1 = 15; + } + + int iMinBlue1 = iColor1Blue - (int)a_uiRadius; +@@ -869,7 +869,7 @@ namespace Etc + int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; + if (iMaxBlue1 > 15) + { +- iMinBlue1 = 15; ++ iMaxBlue1 = 15; + } + + int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); +@@ -884,7 +884,7 @@ namespace Etc + int iMaxRed2 = iColor2Red + (int)a_uiRadius; + if (iMaxRed2 > 15) + { +- iMinRed2 = 15; ++ iMaxRed2 = 15; + } + + int iMinGreen2 = iColor2Green - (int)a_uiRadius; +@@ -895,7 +895,7 @@ namespace Etc + int iMaxGreen2 = iColor2Green + (int)a_uiRadius; + if (iMaxGreen2 > 15) + { +- iMinGreen2 = 15; ++ iMaxGreen2 = 15; + } + + int iMinBlue2 = iColor2Blue - (int)a_uiRadius; +@@ -906,7 +906,7 @@ namespace Etc + int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; + if (iMaxBlue2 > 15) + { +- iMinBlue2 = 15; ++ iMaxBlue2 = 15; + } + + for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) +@@ -1108,7 +1108,7 @@ namespace Etc + int iMaxRed1 = iColor1Red + (int)a_uiRadius; + if (iMaxRed1 > 15) + { +- iMinRed1 = 15; ++ iMaxRed1 = 15; + } + + int iMinGreen1 = iColor1Green - (int)a_uiRadius; +@@ -1119,7 +1119,7 @@ namespace Etc + int iMaxGreen1 = iColor1Green + (int)a_uiRadius; + if (iMaxGreen1 > 15) + { +- iMinGreen1 = 15; ++ iMaxGreen1 = 15; + } + + int iMinBlue1 = iColor1Blue - (int)a_uiRadius; +@@ -1130,7 +1130,7 @@ namespace Etc + int iMaxBlue1 = iColor1Blue + (int)a_uiRadius; + if (iMaxBlue1 > 15) + { +- iMinBlue1 = 15; ++ iMaxBlue1 = 15; + } + + int iColor2Red = m_frgbaOriginalColor2_TAndH.IntRed(15.0f); +@@ -1145,7 +1145,7 @@ namespace Etc + int iMaxRed2 = iColor2Red + (int)a_uiRadius; + if (iMaxRed2 > 15) + { +- iMinRed2 = 15; ++ iMaxRed2 = 15; + } + + int iMinGreen2 = iColor2Green - (int)a_uiRadius; +@@ -1156,7 +1156,7 @@ namespace Etc + int iMaxGreen2 = iColor2Green + (int)a_uiRadius; + if (iMaxGreen2 > 15) + { +- iMinGreen2 = 15; ++ iMaxGreen2 = 15; + } + + int iMinBlue2 = iColor2Blue - (int)a_uiRadius; +@@ -1167,7 +1167,7 @@ namespace Etc + int iMaxBlue2 = iColor2Blue + (int)a_uiRadius; + if (iMaxBlue2 > 15) + { +- iMinBlue2 = 15; ++ iMaxBlue2 = 15; + } + + for (unsigned int uiDistance = 0; uiDistance < TH_DISTANCES; uiDistance++) diff --git a/servers/visual/rasterizer_rd/cubemap_coeffs.h b/thirdparty/misc/cubemap_coeffs.h index 1db03ce7c4..1db03ce7c4 100644 --- a/servers/visual/rasterizer_rd/cubemap_coeffs.h +++ b/thirdparty/misc/cubemap_coeffs.h diff --git a/thirdparty/vulkan/vk_enum_string_helper.h b/thirdparty/vulkan/vk_enum_string_helper.h index 00c2b9d1d5..1c99b31270 100644 --- a/thirdparty/vulkan/vk_enum_string_helper.h +++ b/thirdparty/vulkan/vk_enum_string_helper.h @@ -31,7 +31,7 @@ #pragma once -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning( disable : 4065 ) #endif |