diff options
446 files changed, 9186 insertions, 2769 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5631cefd..d1e622edb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,428 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [4.0] - TBD + +### Added + +#### Animation + +- [Revamped 3D animation storage.](https://godotengine.org/article/animation-data-redesign-40) + - [New blend shape track to adjust blend shapes in animations more efficiently.](https://github.com/godotengine/godot/pull/53865) + - [New expression-based transitions in AnimationTree state machines.](https://github.com/godotengine/godot/pull/54327) + - [Support for animation compression to improve performance with long animations such as cutscenes.](https://github.com/godotengine/godot/pull/54050) + - [Replaced transform tracks by position, rotation and scale tracks.](https://github.com/godotengine/godot/pull/53689) + - [Removed the animation dependency on bone rests.](https://github.com/godotengine/godot/pull/53765) + - Better compatibility with models that use non-uniform scaling in animations. + - Better compatibility with models exported from Maya and 3DS Max. + - Easier animation reuse across different models. + - Easier procedural generation of animations. + +#### Core + +- New TileMap and TileSet resources. +- New Vector2i, Vector3i and Rect2i types. + - These are integer variants of Vector2, Vector3 and Rect2. +- Callable type for first-class functions (can be created with lambdas in GDScript). +- The Euler rotation order can now be adjusted in Node3D. +- [New `Array.map()`, `Array.filter()` and `Array.reduce()` methods that can be used with Callables.](https://github.com/godotengine/godot/pull/38645) +- [Rewritten Tween with more functionality](https://github.com/godotengine/godot/pull/41794). + - Tween is no longer a node. + - Easier chaining of tweens. + - Low-level tweening option to get an interpolated value directly. + - *Existing projects will have to be modified to account for this, as automatic conversion isn't feasible.* +- [New and improved IK in Skeleton2D](https://github.com/godotengine/godot/pull/40347). + - New classes: SkeletonModifier2D, SkeletonModifierStack2D, SkeletonModification2DLookAt, SkeletonModification2DCCDIK, SkeletonModification2DFABRIK, SkeletonModification2DJiggle, SkeletonModification2DTwoBoneIK, PhysicalBone2D, SkeletonModification2DPhysicalBones, SkeletonModification2DStackHolder. + - New `Transform2D.looking_at()` function. +- [New and improved IK in Skeleton3D](https://github.com/godotengine/godot/pull/39353). + - New classes: SkeletonModifier3D, SkeletonModifierStack3D, SkeletonModifier3DLookAt, SkeletonModification3DCCDIK, SkeletonModification3DFABRIK, SkeletonModification3DJiggle, SkeletonModification3DTwoBoneIK, SkeletonModification3DStackHolder. + - The Bone struct now includes a local_pose_override. + - The Bone struct now keeps track of its children bones, if it has any. + - Added functions to Skeleton3D for getting the forward vector using the information stored in the rest pose for the bones. + - New `Basis.rotate_to_align()` function. + - Refactored the BoneAttachment3D node. + - Removed the `process_list` functions. +- [New GradientTexture2D resource (useful for 2D lights, particles, …)](https://github.com/godotengine/godot/pull/53234). +- [Support for gettext PO template generation from scene and script files.](https://github.com/godotengine/godot/pull/39415) + - Translation parser plugins can be written to allow extracting strings from custom file types. +- [New Time singleton to replace date/time handling methods in the OS singleton.](https://github.com/godotengine/godot/pull/49123) + - Includes new methods to handle ISO 8601 timestamp conversion. +- [Support for custom performance monitors](https://github.com/godotengine/godot/pull/39302). +- New `randi_range()` global scope function to return a random *integer* number within a range. +- New `randfn()` global scope function to return a floating-point number along a normal gaussian distribution. +- [New `pingpong()` global scope function to return a floating-point number that increments then decrements in a "sawtooth" fashion.](https://github.com/godotengine/godot/pull/46346) +- Vectors and Colors can now be clamped between two values their respective `clamp()` methods. +- New `Vector3.limit_length()` method as a Vector3 counterpart to `Vector2.limit_length()` (formerly `Vector2.clamped()`). +- New PackedArrays to replace PoolArrays. + - 64-bit integer and float arrays are now available in addition to the existing 32-bit ones. +- New `ConfigFile.parse(data: String)` method to load a string as if it was a ConfigFile on disk. +- New `Image.save_png_to_buffer()` method to save a PNG image to memory as a PackedByteArray (instead of saving to disk). +- [New File API to check, read and write symbolic links on macOS and Linux.](https://github.com/godotengine/godot/pull/46866) +- [Replaced GDNative with GDExtension](https://godotengine.org/article/introducing-gd-extensions). + - Easier setup and compilation for various platforms. + - Code structure is more similar to [statically compiled C++ modules](https://docs.godotengine.org/en/stable/development/cpp/custom_modules_in_cpp.html). + - Lower performance overhead compared to GDNative. + +#### Editor + +- New TileMap and TileSet editors with better usability. +- Support for multiple windows. + - Docks can be moved out of the main window into separate windows. + - Single-window mode can be enabled in the Editor Settings to revert to the old behavior. +- Movement and scaling handles in the 2D editor (similar to the 3D editor). +- New Replace in Files dialog in the script editor to complement Find in Files. +- **macOS:** More built-in mouse cursors are now exposed (such as diagonal resize cursors). +- **macOS:** Support for building Godot with Clang sanitizers. +- **HTML5:** [Support for profiling projects exported to HTML5.](https://godotengine.org/article/html5-export-profiling) + +#### Export + +- **macOS:** Projects can now optionally be exported to a application bundle contained within a ZIP archive. + - Previously, a DMG image was always used when exporting from macOS. +- **macOS:** DMG images can now be codesigned after exporting. + +#### GDScript + +- GDScript was rewritten from scratch with a cleaner approach. + - Annotations to replace keywords in certain cases (`@export`, `@onready`, `@rpc()`, `@tool`, `@warning_ignore()`, …). + - Typed arrays (`var array_of_nodes: Array[Node]`). Any type can be used, including custom classes. + - See individual progress reports for more information: + [#1](https://godotengine.org/article/gdscript-progress-report-writing-tokenizer), + [#2](https://godotengine.org/article/gdscript-progress-report-writing-new-parser), + [#3](https://godotengine.org/article/gdscript-progress-report-type-checking-back). +- [New documentation generation system](https://github.com/godotengine/godot/pull/41095). + - Comments starting with `##` are considered documentation comments. + - Documentation comments be placed before any member variable, constant, enum or function declaration, or at the top of a file. + - Documentation comments appear in the editor help and when hovering exported properties in the inspector. + +#### GUI + +- Support for multiple windows on desktop platforms. Projects can spawn additional windows, each with their own viewport. + - Added `NOTIFICATION_APPLICATION_FOCUS_IN` and `NOTIFICATION_APPLICATION_FOCUS_OUT` notifications for "global" project focus changes (separate from `NOTIFICATION_WM_FOCUS_IN` and `NOTIFICATION_WM_FOCUS_OUT`). +- RichTextLabel property `fit_content_height` to make the label's height fit its content automatically (not always reliable). +- RichTextLabel's `img` tag now supports an optional `color` attribute to modulate the image. +- `get_char_size()` is now exposed in Font, making it usable in DynamicFont rather than being limited to BitmapFont. +- [Tree can now highlight relationship lines for the currently selected item, its parents and direct children.](https://github.com/godotengine/godot/pull/48546) + - This is used in the scene tree dock in the editor. + +#### Import + +- Support for importing lights from glTF scenes. + +#### Input + +- Support for physical (keyboard layout-independent) key codes. + - This can be used to provide <kbd>W</kbd>/<kbd>A</kbd>/<kbd>S</kbd>/<kbd>D</kbd> controls that work on any keyboard layout. +- `DisplayServer.keyboard_get_current_layout()` and `DisplayServer.keyboard_get_layout_*()` methods to get information about keyboard layouts. +- New `Input.MOUSE_MODE_CONFINED_HIDDEN` mouse mode to combine the confined and hidden mouse modes. + +#### Mono/C# + +- Support for exporting C# projects to iOS and HTML5. +- [C# events can now be used to implement Godot signals](https://godotengine.org/article/csharp-ios-signals-events). +- [New Visual Studio and Visual Studio Code add-ons.](https://godotengine.org/article/csharp-vs-and-vscode) + +#### Navigation + +- [New NavigationServer.](https://godotengine.org/article/navigation-server-godot-4-0) + - Support for dynamic obstacle avoidance. + +#### Networking + +- [Support for DTLS encryption in UDP and ENet.](https://godotengine.org/article/enet-dtls-encryption) + +#### Porting + +- New DisplayServer abstraction, allowing for the creation of multiple windows. + - This is used in the editor for detachable docks, but can also be used in projects. +- **Android:** [Allow basic user data backup. This can be disabled in the export preset if needed.](https://github.com/godotengine/godot/pull/49069) +- **Android:** [Support for changing the mouse cursor shape (no custom images)](https://github.com/godotengine/godot/pull/44201). +- **iOS:** [The targeted device family (iPhone, iPad, iPhone and iPad) can now be specified in the export preset.](https://github.com/godotengine/godot/pull/49137) + +#### Physics + +- New CharacterBody node to supersede KinematicBody. + - Some KinematicBody features were moved to PhysicsBody. + +#### Porting + +- **Android:** Clients of the Godot library can now add their own command line arguments. + +#### Rendering + +- New Vulkan renderer. +- [New OpenGL renderer, using OpenGL 3.3/OpenGL ES 3.0/WebGL 2.0 as a baseline.](https://github.com/godotengine/godot/pull/53150) + - Designed to target mobile/web platforms first, but also usable on desktop platforms. + - Uses a low-end-friendly approach to maximize performance in simple scenes. + - Currently supports 2D rendering only. + - OpenGL 3D rendering is planned for a future 4.x release. +- Support for specular mapping when using 2D lighting. +- [New DirectionalLight2D node for 2D lighting.](https://github.com/godotengine/godot/pull/43297) +- CanvasGroup node to modulate several 2D nodes as a group (or apply shaders to them). +- Support for clipping in CanvasItem, replacing the use of Light2D as masks in a more convenient manner. +- [Support for light projectors/"cookies" in OmniLight3D and SpotLight3D.](https://github.com/godotengine/godot/pull/37887) + - Only supported for lights with shadows enabled. +- 3D lights now have a Size property which can be set to simulate area lights. + - This property also affects how fast shadow penumbras will grow over distance. + - A shadow blur property is also available to set a constant blurring factor on a per-light basis. +- Shadow mapping with improved filtering and PCSS-like penumbra simulation. + - Shadow normal offset bias is now implemented to avoid issues with shadow acne or peter-panning. +- [New Decal node to project textures onto 3D surfaces.](https://github.com/godotengine/godot/pull/37861) +- New fully real-time VoxelGI (formerly GIProbe). + - Dynamic lights and emissive can emit GI that's updated every frame (instead of only updating sporadically). + - Dynamic objects can receive GI and contribute to it. +- [New signed distance field-based global illumination](https://godotengine.org/article/godot-40-gets-sdf-based-real-time-global-illumination) (SDFGI) for open world lighting. + - Enabled in the WorldEnvironment. No node required, no baking. + - Semi-realtime: dynamic objects can receive GI, but not contribute to it. +- [Volumetric fog](https://github.com/godotengine/godot/pull/41213) with optional GI contribution. +- [Fog volumes to locally apply volumetric fog (or subtract to global fog using negative density).](https://github.com/godotengine/godot/pull/53353) +- More physically accurate exponential fog to replace the old distance-based fog. +- New Aerial Scattering property in distance-based fog to fade out to the background sky instead of a fixed color. + - Also available in volumetric fog with the Ambient Inject property. +- [New GPU-based lightmapper.](https://godotengine.org/article/godot-40-will-get-new-modernized-lightmapper) + - When using a dedicated GPU, this results in much faster bake speeds compared to the CPU lightmapper. + - Optional support for storing directional lighting information and rough reflections using spherical harmonics. + - Improved support for lighting dynamic objects with better performance and quality. + - In addition to automatic generation, LightmapProbe nodes can now be placed manually to provide better lighting information for dynamic objects where needed. +- [Physical sky material and custom sky shaders](https://godotengine.org/article/custom-sky-shaders-godot-4-0), both supporting real-time updates. +- [Global and per-instance shader uniforms.](https://godotengine.org/article/godot-40-gets-global-and-instance-shader-uniforms) + - This can be used to better reuse shaders, leading to improved performance. +- Support for automatically generating and using mesh LODs to improve performance. + - Several LOD levels are generated for imported 3D scenes by default. + - LODs are automatically used for mesh rendering using a pixel coverage-based selection algorithm. + - Uses the [meshoptimizer](https://github.com/zeux/meshoptimizer) library. +- Support for LOD visibility ranges in GeometryInstance3D. + - Manually authored LODs can be configured using distance and hysteresis cutoffs. + - Can be used for <abbr title="Hierarchical Level of Detail">HLOD</abbr> setups to reduce draw calls while preserving culling opportunities when up close. +- [Support for GeometryInstance3D distance fade to make distant meshes disappear smoothly without having to modify their material.](https://github.com/godotengine/godot/pull/54222) +- Support for automatically generating and using shadow meshes to improve performance. + - The generated shadow meshes are welded aggressively to improve performance with no difference in visual quality. + - To further improve performance, hand-made shadow meshes can be specified in the inspector in MeshInstance nodes. +- [Support for rendering a viewport's 3D contents at a lower resolution to improve performance](https://github.com/godotengine/godot/pull/51870). + - 2D elements remain at full resolution to improve perceived sharpness. + - A scaling factor above 1.0 can be used for supersampling, which is useful to maximize quality for offline rendering. +- See individual progress reports for more information: + [#1](https://godotengine.org/article/vulkan-progress-report-1), + [#2](https://godotengine.org/article/vulkan-progress-report-2), + [#3](https://godotengine.org/article/vulkan-progress-report-3), + [#4](https://godotengine.org/article/vulkan-progress-report-4), + [#5](https://godotengine.org/article/vulkan-progress-report-5), + [#6](https://godotengine.org/article/vulkan-progress-report-6), + [#7](https://godotengine.org/article/vulkan-progress-report-7). + +#### Shaders + +- New shader compiler rewritten from scratch. + - [Support for uniform arrays (including sampler arrays).](https://github.com/godotengine/godot/pull/49485) + - [Arrays can now be passed as function parameters (including arrays of structs).](https://github.com/godotengine/godot/pull/48933) + - [The return type of a function can now be an array (including arrays of structs).](https://github.com/godotengine/godot/pull/48933) + - [Array size can now be optionally written before the identifier (`int[2] array;` instead of `int array[2]`).](https://github.com/godotengine/godot/pull/53527) + - This eases porting shaders from GLSL. + - [Array constructors can now be called at any time after initialization.](https://github.com/godotengine/godot/pull/44705) + - For example, `int array[3]; array = {1, 2, 3}` is now valid. + - [New `fma()` (fused multiply-add) built-in function to optimize shaders in a low-level way.](https://github.com/godotengine/godot/pull/36225) + - [New built-in data (un)packing functions to optimize shaders in a low-level way.](https://github.com/godotengine/godot/pull/53066) + - Warning system for common issues such as floating-point comparison and unused variables. + - Argument names now appear in code completion tooltips. + - More information in the [progress report](https://godotengine.org/article/improvements-shaders-visual-shaders-godot-4). +- [Add Billboard mode to visual shaders.](https://github.com/godotengine/godot/pull/49157) +- [The constants `PI`, `TAU` and `E` are now available in the shader language.](https://github.com/godotengine/godot/pull/48837) + +#### Miscellaneous + +- The engine is now unit-tested using [doctest](https://github.com/onqtam/doctest). + - [GDScript also now has integration tests.](https://docs.godotengine.org/en/latest/development/cpp/unit_testing.html#integration-tests-for-gdscript) +- Switched from Travis CI and AppVeyor to GitHub Actions. +- A Fish shell completion file is now available for the Godot editor's command line interface. + +### Changed + +#### Audio + +- [Increased the default AudioStreamPlayer3D unit size to (1 → 10) to make sounds more audible while setting up the node.](https://github.com/godotengine/godot/pull/38224) +- Renamed the audio-related `FFT_Size` enum to `FFTSize` for consistency. + +#### Core + +- Tweaked the output strings to be more human-readable when printing various built-in Variant and Object types. +- Renamed File's `endian_swap` property to `big_endian` for consistency with ResourceSaver and StreamPeer. +- [Renamed File's `get_len()` method to `get_length()`.](https://github.com/godotengine/godot/pull/49061) +- [Renamed Object's `PROPERTY_USAGE_NOEDITOR` to `PROPERTY_USAGE_NO_EDITOR`.](https://github.com/godotengine/godot/pull/54571) +- Renamed `Vector2.clamped()` to `Vector2.limit_length()` to differentiate it from the new `Vector2.clamp()`. +- Renamed `rand_range()` to `randf_range()` to avoid ambiguity with the new `randi_range()` and make its return type more obvious. +- Replaced `Node.add_child_below_node()` with `Node.add_sibling()`. +- Replaced `Directory.list_dir_begin()`'s `skip_navigational` and `skip_hidden` arguments with `show_navigational` and `show_hidden`. + - Both arguments are `false` by default, which means the default behavior is now to exclude both navigational and hidden files from the returned list. +- Renamed the built-in Quat type to Quaternion. +- Renamed the built-in Transform type to Transform3D. +- Renamed Node3D's `translation` property to `position` for consistency with Node2D. +- Moved YSort functionality to a Node2D property. +- Viewports now use a size of 512×512 by default to make them visible out of the box. +- [Screen orientation is now represented as an enum in the Project Settings.](https://github.com/godotengine/godot/pull/48939) +- [Renamed 3D nodes to contain an explicit "3D" prefix for clarity and consistency](https://github.com/godotengine/godot/pull/37340). +- Renamed various nodes: + - Spatial → Node3D + - GIProbe → VoxelGI + - BakedLightmap → LightmapGI + - Light2D -> PointLight2D + - VisibilityNotifier2D -> VisibleOnScreenNotifier2D + - VisibilityNotifier3D -> VisibleOnScreenNotifier3D + - VisibilityEnabler2D -> VisibleOnScreenEnabler2D + - VisibilityEnabler3D -> VisibleOnScreenEnabler3D +- Renamed various resources: + - GradientTexture -> GradientTexture1D +- Old node and resource names are automatically converted when loading scenes from Godot 3.x. + +#### Editor + +- Renewed the editor theme for a more modern design. + - [Increased icon saturation by 30% when using a dark theme.](https://github.com/godotengine/godot/pull/48644) + - Icon saturation can now be adjusted in the Editor Settings. +- [Improved the audio bus editor appearance.](https://github.com/godotengine/godot/pull/49130) +- Improved layout and texts of the Manage Editor Features dialog. +- Improved the Video RAM debugger usability. + - The Video RAM tab is now refreshed automatically when switching to it. +- Hovering layer checkboxes in the inspector now results in visual feedback. + - Clicking between two checkboxes will now enable the checkbox that was last highlighted instead of doing nothing. +- CSV profiler measures can now be saved anywhere on the filesystem, not just in the project folder. +- Improved the 2D zooming algorithm to always visit powers of two (50%, 100%, 200%, …) and avoid floating-point precision issues. +- Times are now displayed as milliseconds in the profiler and performance monitors (instead of seconds). +- Improved the batch rename dialog usability and design consistency. + - Clarified error messages when there are regular expression errors. +- Optimized editor icon generation to speed up editor startup. +- Script editor autocompletion now displays previews next to color constant suggestions. +- The number of replaced results now appears in place of the matches counter when replacing text in the script editor. +- Pressing <kbd>Enter</kbd> (or <kbd>Shift + Enter</kbd>) in the script editor replacement dialog now performs a forwards (or backwards) replacement operation. +- Pressing <kbd>Ctrl + F</kbd> now focuses the search field in the AssetLib tab. +- Pressing <kbd>G</kbd> now switches to the Pan mode in the 2D editor. + - The TileMap editor's Bucket Fill shortcut was moved to <kbd>B</kbd> to cater for this change. +- Mouse wheel behavior for zooming in the animation behavior is now inverted. +- The Sync Scene Changes and Sync Script Changes settings' values now persist on a per-project basis instead of being always enabled by default. +- Various tooltips have been added or modified to clarify the editor operation. +- Various visual and formatting changes to the editor help to improve readability and be closer to the online class reference. +- Tweaked Camera2D editor line colors for better visibility. +- Light theme presets now use a negative contrast rate by default for a more logical preview of UI elevation. +- Increased the use of bold fonts throughout the editor. +- Revised icons for the Gradient and GradientTexture resources. +- Renamed "Identifier" to "Bundle Identifier" in the macOS and iOS export presets for clarity. +- Renamed the script editor's "Adaptive" syntax theme to "Default" and "Default" to "Godot 2", for consistency with the editor theme presets. +- Flipped the 2D editor icon to match Godot's coordinate handedness. + +#### GUI + +- Improved drive letter handling in EditorFileDialog and FileDialog. +- Container nodes (except PanelContainer) now use the Pass mouse mode by default. +- Pressing the left/right arrows while having selected text will now move the cursor to the beginning/end of the selection in LineEdit (while unselecting the text as usual). +- TextEdit's `search()` method now returns a Dictionary instead of a PackedIntArray. +- **macOS:** The <kbd>Ctrl + A</kbd> and <kbd>Ctrl + E</kbd> navigation shortcuts now work in LineEdit. + +#### Input + +- Renamed InputEventKey's `scancode` to `keycode`. +- Renamed InputMap's `get_action_list()` to `get_action_events()`. + +#### Networking + +- Optimized bandwidth usage in the high-level multiplayer API. + +#### Physics + +- Split KinematicBody into the new CharacterBody node and PhysicsBody. +- RayCast nodes are now enabled by default. + - The `disabled` property was renamed to `enabled` with its behavior inverted. +- Renamed PlaneShape to WorldBoundaryShape. + +#### Rendering + +- Some Environment settings such as depth of field have been moved to a CameraEffects resource which is assigned to individual Camera nodes. +- [The ACES Fitted tonemapping algoirthm is now used in place of the old ACES algorithm.](https://github.com/godotengine/godot/pull/52476) + - The old non-fitted ACES tonemapping algorithm was removed. +- Quality settings have been moved from individual nodes and resources to the Project Settings for better centralization. +- Quality settings now have performance hints in their values' names, such as "Fast" or "Slow". + +#### Shaders + +- Renamed the `.shader` file extension to `.gdshader`. + - Existing text-based shader files will have to be renamed before loading the project in a new engine version. + +#### Miscellaneous + +- Renamed the `x11` platform to `linuxbsd` to prepare for Wayland support. +- The engine is now written in C++17. +- Python 3.6 and SCons 3.1 are now required to build Godot from source. + +### Removed + +#### Buildsystem + +- Removed the `server` platform in favor of disabling specific DisplayServers at build-time (e.g. `vulkan=no`). + +#### Core + +- Removed the YSort node in favor of the Node2D YSort property. +- Removed the deprecated `Color.gray()` method. + - Use `Color.v()` for a better grayscale approximation instead. +- Removed built-in HQ2X implementation (used for crude hiDPI support in the default project theme). + - This helps with binary size as HQ2X is made of particularly large functions. + +#### Editor + +- Removed the **Dim Dialog on Editor Popup** editor setting since it was made obsolete by the multi-window paradigm. + +#### GUI + +- [Removed the ToolButton node in favor of Button.](https://github.com/godotengine/godot/pull/39690) + - Existing ToolButton nodes from Godot 3.x projects will be converted to Button nodes. + +#### Input + +- Removed the `DisplayServer.get_latin_keyboard_variant()` method (replaced by the more flexible `DisplayServer.keyboard_get_current_layout()`). + +#### Networking + +- Removed the deprecated `allow_object_decoding` property from PacketPeer. +- Removed the deprecated `sync` and `slave` high-level multiplayer keywords. + +#### Export + +- **iOS:** [Remove redundant orientation export setting in favor of the orientation project setting.](https://github.com/godotengine/godot/pull/48939) + +#### Physics + +- Removed the deprecated PhysicsBody `friction` and `bounce` properties (replaced by PhysicsMaterial). + +#### Rendering + +- Removed OpenGL ES 2.0 renderer (replaced by the new mobile-oriented OpenGL 3 renderer). + - Vulkan, OpenGL 3.3, OpenGL ES 3.0 or WebGL 2.0 support is now required to run Godot. +- [Removed support for 16× MSAA due to driver bugs and low performance.](https://github.com/godotengine/godot/pull/49063) + - For high-quality offline rendering, using supersampling together with 8× MSAA is a better option anyway. + +### Fixed + +#### Core + +- The positional command line argument now considers `.res` and `.tres` files as runnable scene formats. + - This fixes Godot not running the main scene or a custom scene if they were saved with a `.res` or `.tres` extension. +- **macOS/Linux:** Fix the result of `Directory.get_space_left()`. +- **Windows:** Godot can now kill its own PID using `OS.kill()`. + +#### Editor + +- The Android exporter no longer reports progress on each file, greatly speeding up the exporting process. +- Searching with the Whole Words option enabled in the script editor is no longer exceedingly slow. + +#### GUI + +- Fixed OptionButton minimum size. +- TabContainer is no longer too large when tabs are hidden. +- ScrollBar now allows using `scroll_to_line()` when Scroll Active is disabled. +- DynamicFont outlines now have antialiasing disabled if it was disabled on the font itself. + +#### Porting + +- **Windows:** `OS.execute()` now only quotes command line arguments if they contain special characters. + ## [3.2] - 2020-01-29 ### Added diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 7b212485ba..07b5d4042d 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -120,6 +120,11 @@ Copyright: 2007, Starbreeze Studios 2014-2021, Godot Engine contributors. License: Expat and Zlib +Files: ./thirdparty/amd-fsr/ +Comment: AMD FidelityFX Super Resolution +Copyright: 2021, Advanced Micro Devices, Inc. +License: Expat + Files: ./thirdparty/basis_universal/ Comment: Basis Universal Copyright: 2019, Binomial LLC. @@ -13,8 +13,6 @@ generous deed immortalized in the next stable release of Godot Engine. ## Platinum sponsors Gamblify <https://www.gamblify.com> - Heroic Labs <https://heroiclabs.com> - Spiffcode <http://www.spiffcode.com> ## Gold sponsors diff --git a/SConstruct b/SConstruct index 83bd1560ff..1922e904d0 100644 --- a/SConstruct +++ b/SConstruct @@ -149,7 +149,7 @@ opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False)) opts.Add("disable_classes", "Disable given classes (comma separated)", "") opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True)) -opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", False)) +opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True)) opts.Add("system_certs_path", "Use this path as SSL certificates default for editor (for package maintainers)", "") opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) @@ -329,6 +329,9 @@ if env_base["target"] == "debug": if env_base["use_precise_math_checks"]: env_base.Append(CPPDEFINES=["PRECISE_MATH_CHECKS"]) +if not env_base.File("#main/splash_editor.png").exists(): + # Force disabling editor splash if missing. + env_base["no_editor_splash"] = True if env_base["no_editor_splash"]: env_base.Append(CPPDEFINES=["NO_EDITOR_SPLASH"]) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 336f95c925..0e15edc29f 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -41,6 +41,9 @@ #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/variant/variant_parser.h" +#include "core/version.h" + +#include "modules/modules_enabled.gen.h" // For mono. const String ProjectSettings::PROJECT_DATA_DIR_NAME_SUFFIX = "godot"; @@ -62,10 +65,81 @@ String ProjectSettings::get_resource_path() const { return resource_path; } +String ProjectSettings::get_safe_project_name() const { + String safe_name = OS::get_singleton()->get_safe_dir_name(get("application/config/name")); + if (safe_name.is_empty()) { + safe_name = "UnnamedProject"; + } + return safe_name; +} + String ProjectSettings::get_imported_files_path() const { return get_project_data_path().plus_file("imported"); } +// Returns the features that a project must have when opened with this build of Godot. +// This is used by the project manager to provide the initial_settings for config/features. +const PackedStringArray ProjectSettings::get_required_features() { + PackedStringArray features = PackedStringArray(); + features.append(VERSION_BRANCH); +#ifdef REAL_T_IS_DOUBLE + features.append("Double Precision"); +#endif + return features; +} + +// Returns the features supported by this build of Godot. Includes all required features. +const PackedStringArray ProjectSettings::_get_supported_features() { + PackedStringArray features = get_required_features(); +#ifdef MODULE_MONO_ENABLED + features.append("C#"); +#endif + // Allow pinning to a specific patch number or build type by marking + // them as supported. They're only used if the user adds them manually. + features.append(VERSION_BRANCH "." _MKSTR(VERSION_PATCH)); + features.append(VERSION_FULL_CONFIG); + features.append(VERSION_FULL_BUILD); + // For now, assume Vulkan is always supported. + // This should be removed if it's possible to build the editor without Vulkan. + features.append("Vulkan Clustered"); + features.append("Vulkan Mobile"); + return features; +} + +// Returns the features that this project needs but this build of Godot lacks. +const PackedStringArray ProjectSettings::get_unsupported_features(const PackedStringArray &p_project_features) { + PackedStringArray unsupported_features = PackedStringArray(); + PackedStringArray supported_features = singleton->_get_supported_features(); + for (int i = 0; i < p_project_features.size(); i++) { + if (!supported_features.has(p_project_features[i])) { + unsupported_features.append(p_project_features[i]); + } + } + unsupported_features.sort(); + return unsupported_features; +} + +// Returns the features that both this project has and this build of Godot has, ensuring required features exist. +const PackedStringArray ProjectSettings::_trim_to_supported_features(const PackedStringArray &p_project_features) { + // Remove unsupported features if present. + PackedStringArray features = PackedStringArray(p_project_features); + PackedStringArray supported_features = _get_supported_features(); + for (int i = p_project_features.size() - 1; i > -1; i--) { + if (!supported_features.has(p_project_features[i])) { + features.remove_at(i); + } + } + // Add required features if not present. + PackedStringArray required_features = get_required_features(); + for (int i = 0; i < required_features.size(); i++) { + if (!features.has(required_features[i])) { + features.append(required_features[i]); + } + } + features.sort(); + return features; +} + String ProjectSettings::localize_path(const String &p_path) const { if (resource_path.is_empty() || p_path.begins_with("res://") || p_path.begins_with("user://") || (p_path.is_absolute_path() && !p_path.begins_with(resource_path))) { @@ -666,6 +740,13 @@ Error ProjectSettings::_load_settings_text_or_binary(const String &p_text_path, return err; } +Error ProjectSettings::load_custom(const String &p_path) { + if (p_path.ends_with(".binary")) { + return _load_settings_binary(p_path); + } + return _load_settings_text(p_path); +} + int ProjectSettings::get_order(const String &p_name) const { ERR_FAIL_COND_V_MSG(!props.has(p_name), -1, "Request for nonexistent project setting: " + p_name + "."); return props[p_name].order; @@ -845,6 +926,34 @@ Error ProjectSettings::_save_custom_bnd(const String &p_file) { // add other par Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_custom, const Vector<String> &p_custom_features, bool p_merge_with_current) { ERR_FAIL_COND_V_MSG(p_path == "", ERR_INVALID_PARAMETER, "Project settings save path cannot be empty."); + PackedStringArray project_features = has_setting("application/config/features") ? (PackedStringArray)get_setting("application/config/features") : PackedStringArray(); + // If there is no feature list currently present, force one to generate. + if (project_features.is_empty()) { + project_features = ProjectSettings::get_required_features(); + } + // Check the rendering API. + const String rendering_api = has_setting("rendering/quality/driver/driver_name") ? (String)get_setting("rendering/quality/driver/driver_name") : String(); + if (rendering_api != "") { + // Add the rendering API as a project feature if it doesn't already exist. + if (!project_features.has(rendering_api)) { + project_features.append(rendering_api); + } + } + // Check for the existence of a csproj file. + if (FileAccess::exists(get_resource_path().plus_file(get_safe_project_name() + ".csproj"))) { + // If there is a csproj file, add the C# feature if it doesn't already exist. + if (!project_features.has("C#")) { + project_features.append("C#"); + } + } else { + // If there isn't a csproj file, remove the C# feature if it exists. + if (project_features.has("C#")) { + project_features.remove_at(project_features.find("C#")); + } + } + project_features = _trim_to_supported_features(project_features); + set_setting("application/config/features", project_features); + Set<_VCSort> vclist; if (p_merge_with_current) { diff --git a/core/config/project_settings.h b/core/config/project_settings.h index aaa8e383f7..5b74356337 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -48,6 +48,8 @@ public: //properties that are not for built in values begin from this value, so builtin ones are displayed first NO_BUILTIN_ORDER_BASE = 1 << 16 }; + const static PackedStringArray get_required_features(); + const static PackedStringArray get_unsupported_features(const PackedStringArray &p_project_features); struct AutoloadInfo { StringName name; @@ -111,6 +113,9 @@ protected: Error _save_custom_bnd(const String &p_file); + const static PackedStringArray _get_supported_features(); + const static PackedStringArray _trim_to_supported_features(const PackedStringArray &p_project_features); + void _convert_to_last_version(int p_from_version); bool _load_resource_pack(const String &p_pack, bool p_replace_files = true, int p_offset = 0); @@ -125,7 +130,7 @@ protected: static void _bind_methods(); public: - static const int CONFIG_VERSION = 4; + static const int CONFIG_VERSION = 5; void set_setting(const String &p_setting, const Variant &p_value); Variant get_setting(const String &p_setting) const; @@ -146,6 +151,7 @@ public: String get_project_data_dir_name() const; String get_project_data_path() const; String get_resource_path() const; + String get_safe_project_name() const; String get_imported_files_path() const; static ProjectSettings *get_singleton(); @@ -158,6 +164,7 @@ public: Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false, bool p_ignore_override = false); + Error load_custom(const String &p_path); Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true); Error save(); void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); diff --git a/core/doc_data.h b/core/doc_data.h index c75cdfcde5..db83dda8aa 100644 --- a/core/doc_data.h +++ b/core/doc_data.h @@ -70,18 +70,29 @@ public: Vector<int> errors_returned; bool operator<(const MethodDoc &p_method) const { if (name == p_method.name) { - // Must be a constructor since there is no overloading. - // We want this arbitrary order for a class "Foo": - // - 1. Default constructor: Foo() - // - 2. Copy constructor: Foo(Foo) - // - 3+. Other constructors Foo(Bar, ...) based on first argument's name - if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1. + // Must be an operator or a constructor since there is no other overloading + if (name.left(8) == "operator") { + if (arguments.size() == p_method.arguments.size()) { + if (arguments.size() == 0) { + return false; + } + return arguments[0].type < p_method.arguments[0].type; + } return arguments.size() < p_method.arguments.size(); + } else { + // Must be a constructor + // We want this arbitrary order for a class "Foo": + // - 1. Default constructor: Foo() + // - 2. Copy constructor: Foo(Foo) + // - 3+. Other constructors Foo(Bar, ...) based on first argument's name + if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1. + return arguments.size() < p_method.arguments.size(); + } + if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2. + return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type); + } + return arguments[0] < p_method.arguments[0]; } - if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2. - return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type); - } - return arguments[0] < p_method.arguments[0]; } return name < p_method.name; } @@ -112,6 +123,7 @@ public: String setter, getter; String default_value; bool overridden = false; + String overrides; bool operator<(const PropertyDoc &p_prop) const { return name < p_prop.name; } @@ -124,7 +136,11 @@ public: String description; String default_value; bool operator<(const ThemeItemDoc &p_theme_item) const { - return name < p_theme_item.name; + // First sort by the data type, then by name. + if (data_type == p_theme_item.data_type) { + return name < p_theme_item.name; + } + return data_type < p_theme_item.data_type; } }; diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp index 719ea8afb5..61bb949ed4 100644 --- a/core/error/error_macros.cpp +++ b/core/error/error_macros.cpp @@ -76,7 +76,7 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co // Main error printing function. void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, const char *p_message, bool p_editor_notify, ErrorHandlerType p_type) { - OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, (Logger::ErrorType)p_type); + OS::get_singleton()->print_error(p_function, p_file, p_line, p_error, p_message, p_editor_notify, (Logger::ErrorType)p_type); _global_lock(); ErrorHandlerList *l = error_handler_list; diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp index 19988a26cb..0c9b344a37 100644 --- a/core/extension/gdnative_interface.cpp +++ b/core/extension/gdnative_interface.cpp @@ -827,16 +827,21 @@ static GDNativeObjectPtr gdnative_global_get_singleton(const char *p_name) { return (GDNativeObjectPtr)Engine::get_singleton()->get_singleton_object(String(p_name)); } -static void *gdnative_object_get_instance_binding(GDNativeObjectPtr p_instance, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks) { - Object *o = (Object *)p_instance; +static void *gdnative_object_get_instance_binding(GDNativeObjectPtr p_object, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks) { + Object *o = (Object *)p_object; return o->get_instance_binding(p_token, p_callbacks); } -static void gdnative_object_set_instance_binding(GDNativeObjectPtr p_instance, void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks) { - Object *o = (Object *)p_instance; +static void gdnative_object_set_instance_binding(GDNativeObjectPtr p_object, void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks) { + Object *o = (Object *)p_object; o->set_instance_binding(p_token, p_binding, p_callbacks); } +static void gdnative_object_set_instance(GDNativeObjectPtr p_object, const char *p_classname, GDExtensionClassInstancePtr p_instance) { + Object *o = (Object *)p_object; + ClassDB::set_object_extension_instance(o, p_classname, p_instance); +} + static GDNativeObjectPtr gdnative_object_get_instance_from_id(GDObjectInstanceID p_instance_id) { return (GDNativeObjectPtr)ObjectDB::get_instance(ObjectID(p_instance_id)); } @@ -866,19 +871,8 @@ static GDNativeMethodBindPtr gdnative_classdb_get_method_bind(const char *p_clas return (GDNativeMethodBindPtr)mb; } -static GDNativeClassConstructor gdnative_classdb_get_constructor(const char *p_classname, GDNativeExtensionPtr *r_extension) { - ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); - if (class_info) { - if (r_extension) { - *r_extension = class_info->native_extension; - } - return (GDNativeClassConstructor)class_info->creation_func; - } - return nullptr; -} - -static GDNativeObjectPtr gdnative_classdb_construct_object(GDNativeClassConstructor p_constructor, GDNativeExtensionPtr p_extension) { - return (GDNativeObjectPtr)ClassDB::construct_object((Object * (*)()) p_constructor, (ObjectNativeExtension *)p_extension); +static GDNativeObjectPtr gdnative_classdb_construct_object(const char *p_classname) { + return (GDNativeObjectPtr)ClassDB::instantiate(p_classname); } static void *gdnative_classdb_get_class_tag(const char *p_classname) { @@ -1026,6 +1020,7 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) { gdni.global_get_singleton = gdnative_global_get_singleton; gdni.object_get_instance_binding = gdnative_object_get_instance_binding; gdni.object_set_instance_binding = gdnative_object_set_instance_binding; + gdni.object_set_instance = gdnative_object_set_instance; gdni.object_cast_to = gdnative_object_cast_to; gdni.object_get_instance_from_id = gdnative_object_get_instance_from_id; @@ -1033,7 +1028,6 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) { /* CLASSDB */ - gdni.classdb_get_constructor = gdnative_classdb_get_constructor; gdni.classdb_construct_object = gdnative_classdb_construct_object; gdni.classdb_get_method_bind = gdnative_classdb_get_method_bind; gdni.classdb_get_class_tag = gdnative_classdb_get_class_tag; diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index e411a9d85b..2191d99dea 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -211,7 +211,7 @@ typedef const char *(*GDNativeExtensionClassToString)(GDExtensionClassInstancePt typedef void (*GDNativeExtensionClassReference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); -typedef GDExtensionClassInstancePtr (*GDNativeExtensionClassCreateInstance)(void *p_userdata); +typedef GDNativeObjectPtr (*GDNativeExtensionClassCreateInstance)(void *p_userdata); typedef void (*GDNativeExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance); typedef void (*GDNativeExtensionClassObjectInstance)(GDExtensionClassInstancePtr p_instance, GDNativeObjectPtr p_object_instance); typedef GDNativeExtensionClassCallVirtual (*GDNativeExtensionClassGetVirtual)(void *p_userdata, const char *p_name); @@ -227,7 +227,6 @@ typedef struct { GDNativeExtensionClassUnreference unreference_func; GDNativeExtensionClassCreateInstance create_instance_func; /* this one is mandatory */ GDNativeExtensionClassFreeInstance free_instance_func; /* this one is mandatory */ - GDNativeExtensionClassObjectInstance object_instance_func; /* this one is mandatory */ GDNativeExtensionClassGetVirtual get_virtual_func; void *class_userdata; } GDNativeExtensionClassCreationInfo; @@ -428,17 +427,18 @@ typedef struct { void (*object_method_bind_ptrcall)(const GDNativeMethodBindPtr p_method_bind, GDNativeObjectPtr p_instance, const GDNativeTypePtr *p_args, GDNativeTypePtr r_ret); void (*object_destroy)(GDNativeObjectPtr p_o); GDNativeObjectPtr (*global_get_singleton)(const char *p_name); + void *(*object_get_instance_binding)(GDNativeObjectPtr p_o, void *p_token, const GDNativeInstanceBindingCallbacks *p_callbacks); void (*object_set_instance_binding)(GDNativeObjectPtr p_o, void *p_token, void *p_binding, const GDNativeInstanceBindingCallbacks *p_callbacks); + void (*object_set_instance)(GDNativeObjectPtr p_o, const char *p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */ + GDNativeObjectPtr (*object_cast_to)(const GDNativeObjectPtr p_object, void *p_class_tag); GDNativeObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id); GDObjectInstanceID (*object_get_instance_id)(const GDNativeObjectPtr p_object); /* CLASSDB */ - - GDNativeClassConstructor (*classdb_get_constructor)(const char *p_classname, GDNativeExtensionPtr *r_extension); - GDNativeObjectPtr (*classdb_construct_object)(GDNativeClassConstructor p_constructor, GDNativeExtensionPtr p_extension); + GDNativeObjectPtr (*classdb_construct_object)(const char *p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */ GDNativeMethodBindPtr (*classdb_get_method_bind)(const char *p_classname, const char *p_methodname, GDNativeInt p_hash); void *(*classdb_get_class_tag)(const char *p_classname); diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index a6b0a708c3..ae7620fec4 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -156,7 +156,6 @@ void NativeExtension::_register_extension_class(const GDNativeExtensionClassLibr extension->native_extension.unreference = p_extension_funcs->unreference_func; extension->native_extension.class_userdata = p_extension_funcs->class_userdata; extension->native_extension.create_instance = p_extension_funcs->create_instance_func; - extension->native_extension.set_object_instance = p_extension_funcs->object_instance_func; extension->native_extension.free_instance = p_extension_funcs->free_instance_func; extension->native_extension.get_virtual = p_extension_funcs->get_virtual_func; diff --git a/core/input/input.cpp b/core/input/input.cpp index d0144ca47f..342ab3b704 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -1351,7 +1351,7 @@ void Input::add_joy_mapping(String p_mapping, bool p_update_existing) { void Input::remove_joy_mapping(String p_guid) { for (int i = map_db.size() - 1; i >= 0; i--) { if (p_guid == map_db[i].uid) { - map_db.remove(i); + map_db.remove_at(i); } } for (KeyValue<int, Joypad> &E : joy_names) { diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 49fa73dab2..33f992e153 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -183,7 +183,9 @@ Error ConfigFile::_internal_save(FileAccess *file) { if (E != values.front()) { file->store_string("\n"); } - file->store_string("[" + E.key() + "]\n\n"); + if (E.key() != "") { + file->store_string("[" + E.key() + "]\n\n"); + } for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) { String vstr; diff --git a/core/io/image.cpp b/core/io/image.cpp index b82e6637b4..3f34de132f 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -86,20 +86,14 @@ SaveEXRFunc Image::save_exr_func = nullptr; 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) { - uint32_t ofs = (p_y * width + p_x) * p_pixelsize; - - for (uint32_t i = 0; i < p_pixelsize; i++) { - p_data[ofs + i] = p_pixel[i]; - } +void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixel_size, uint8_t *p_data, const uint8_t *p_pixel) { + uint32_t ofs = (p_y * width + p_x) * p_pixel_size; + memcpy(p_data + ofs, p_pixel, p_pixel_size); } -void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_data, uint8_t *p_pixel) { - uint32_t ofs = (p_y * width + p_x) * p_pixelsize; - - for (uint32_t i = 0; i < p_pixelsize; i++) { - p_pixel[i] = p_data[ofs + i]; - } +void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixel_size, const uint8_t *p_data, uint8_t *p_pixel) { + uint32_t ofs = (p_y * width + p_x) * p_pixel_size; + memcpy(p_pixel, p_data + ofs, p_pixel_size); } int Image::get_format_pixel_size(Format p_format) { @@ -2697,24 +2691,55 @@ void Image::blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, c } } -void Image::fill(const Color &c) { +// Repeats `p_pixel` `p_count` times in consecutive memory. +// Results in the original pixel and `p_count - 1` subsequent copies of it. +void Image::_repeat_pixel_over_subsequent_memory(uint8_t *p_pixel, int p_pixel_size, int p_count) { + int offset = 1; + for (int stride = 1; offset + stride <= p_count; stride *= 2) { + memcpy(p_pixel + offset * p_pixel_size, p_pixel, stride * p_pixel_size); + offset += stride; + } + if (offset < p_count) { + memcpy(p_pixel + offset * p_pixel_size, p_pixel, (p_count - offset) * p_pixel_size); + } +} + +void Image::fill(const Color &p_color) { ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill in compressed or custom image formats."); - uint8_t *wp = data.ptrw(); - uint8_t *dst_data_ptr = wp; + uint8_t *dst_data_ptr = data.ptrw(); int pixel_size = get_format_pixel_size(format); - // put first pixel with the format-aware API - set_pixel(0, 0, c); + // Put first pixel with the format-aware API. + _set_color_at_ofs(dst_data_ptr, 0, p_color); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - uint8_t *dst = &dst_data_ptr[(y * width + x) * pixel_size]; + _repeat_pixel_over_subsequent_memory(dst_data_ptr, pixel_size, width * height); +} - for (int k = 0; k < pixel_size; k++) { - dst[k] = dst_data_ptr[k]; - } +void Image::fill_rect(const Rect2 &p_rect, const Color &p_color) { + ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot fill rect in compressed or custom image formats."); + + Rect2i r = Rect2i(0, 0, width, height).intersection(p_rect.abs()); + if (r.has_no_area()) { + return; + } + + uint8_t *dst_data_ptr = data.ptrw(); + + int pixel_size = get_format_pixel_size(format); + + // Put first pixel with the format-aware API. + uint8_t *rect_first_pixel_ptr = &dst_data_ptr[(r.position.y * width + r.position.x) * pixel_size]; + _set_color_at_ofs(rect_first_pixel_ptr, 0, p_color); + + if (r.size.x == width) { + // No need to fill rows separately. + _repeat_pixel_over_subsequent_memory(rect_first_pixel_ptr, pixel_size, width * r.size.y); + } else { + _repeat_pixel_over_subsequent_memory(rect_first_pixel_ptr, pixel_size, r.size.x); + for (int y = 1; y < r.size.y; y++) { + memcpy(rect_first_pixel_ptr + y * width * pixel_size, rect_first_pixel_ptr, r.size.x * pixel_size); } } } @@ -3160,6 +3185,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("blend_rect", "src", "src_rect", "dst"), &Image::blend_rect); ClassDB::bind_method(D_METHOD("blend_rect_mask", "src", "mask", "src_rect", "dst"), &Image::blend_rect_mask); ClassDB::bind_method(D_METHOD("fill", "color"), &Image::fill); + ClassDB::bind_method(D_METHOD("fill_rect", "rect", "color"), &Image::fill_rect); ClassDB::bind_method(D_METHOD("get_used_rect"), &Image::get_used_rect); ClassDB::bind_method(D_METHOD("get_rect", "rect"), &Image::get_rect); diff --git a/core/io/image.h b/core/io/image.h index d31a065aa7..9023463b08 100644 --- a/core/io/image.h +++ b/core/io/image.h @@ -190,8 +190,10 @@ private: 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); - _FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_data, uint8_t *p_pixel); + _FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixel_size, uint8_t *p_data, const uint8_t *p_pixel); + _FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixel_size, const uint8_t *p_data, uint8_t *p_pixel); + + _FORCE_INLINE_ void _repeat_pixel_over_subsequent_memory(uint8_t *p_pixel, int p_pixel_size, int p_count); void _set_data(const Dictionary &p_data); Dictionary _get_data() const; @@ -362,7 +364,8 @@ public: void blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest); void blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest); void blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest); - void fill(const Color &c); + void fill(const Color &p_color); + void fill_rect(const Rect2 &p_rect, const Color &p_color); Rect2 get_used_rect() const; Ref<Image> get_rect(const Rect2 &p_area) const; diff --git a/core/io/logger.cpp b/core/io/logger.cpp index b68a8b20a5..8a8bdf07d3 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -266,7 +266,7 @@ void CompositeLogger::log_error(const char *p_function, const char *p_file, int } for (int i = 0; i < loggers.size(); ++i) { - loggers[i]->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type); + loggers[i]->log_error(p_function, p_file, p_line, p_code, p_rationale, p_editor_notify, p_type); } } diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 1079da75ef..bdceae4374 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -210,7 +210,7 @@ bool AStar::has_point(int p_id) const { return points.has(p_id); } -Array AStar::get_points() { +Array AStar::get_point_ids() { Array point_list; for (OAHashMap<int, Point *>::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) { @@ -344,7 +344,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) { } sorter.pop_heap(0, open_list.size(), open_list.ptrw()); // Remove the current point from the open list - open_list.remove(open_list.size() - 1); + open_list.remove_at(open_list.size() - 1); p->closed_pass = pass; // Mark the point as closed for (OAHashMap<int, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { @@ -539,7 +539,7 @@ void AStar::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point); ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point); ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar::get_point_connections); - ClassDB::bind_method(D_METHOD("get_points"), &AStar::get_points); + ClassDB::bind_method(D_METHOD("get_point_ids"), &AStar::get_point_ids); ClassDB::bind_method(D_METHOD("set_point_disabled", "id", "disabled"), &AStar::set_point_disabled, DEFVAL(true)); ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar::is_point_disabled); @@ -606,8 +606,8 @@ Vector<int> AStar2D::get_point_connections(int p_id) { return astar.get_point_connections(p_id); } -Array AStar2D::get_points() { - return astar.get_points(); +Array AStar2D::get_point_ids() { + return astar.get_point_ids(); } void AStar2D::set_point_disabled(int p_id, bool p_disabled) { @@ -812,7 +812,7 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) { } sorter.pop_heap(0, open_list.size(), open_list.ptrw()); // Remove the current point from the open list - open_list.remove(open_list.size() - 1); + open_list.remove_at(open_list.size() - 1); p->closed_pass = astar.pass; // Mark the point as closed for (OAHashMap<int, AStar::Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { @@ -859,7 +859,7 @@ void AStar2D::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar2D::remove_point); ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar2D::has_point); ClassDB::bind_method(D_METHOD("get_point_connections", "id"), &AStar2D::get_point_connections); - ClassDB::bind_method(D_METHOD("get_points"), &AStar2D::get_points); + ClassDB::bind_method(D_METHOD("get_point_ids"), &AStar2D::get_point_ids); ClassDB::bind_method(D_METHOD("set_point_disabled", "id", "disabled"), &AStar2D::set_point_disabled, DEFVAL(true)); ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar2D::is_point_disabled); diff --git a/core/math/a_star.h b/core/math/a_star.h index 64fa32a325..ef6f22d228 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -138,7 +138,7 @@ public: void remove_point(int p_id); bool has_point(int p_id) const; Vector<int> get_point_connections(int p_id); - Array get_points(); + Array get_point_ids(); void set_point_disabled(int p_id, bool p_disabled = true); bool is_point_disabled(int p_id) const; @@ -188,7 +188,7 @@ public: void remove_point(int p_id); bool has_point(int p_id) const; Vector<int> get_point_connections(int p_id); - Array get_points(); + Array get_point_ids(); void set_point_disabled(int p_id, bool p_disabled = true); bool is_point_disabled(int p_id) const; diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp index f3e78c0080..83726f46b5 100644 --- a/core/math/aabb.cpp +++ b/core/math/aabb.cpp @@ -46,6 +46,11 @@ bool AABB::operator!=(const AABB &p_rval) const { } void AABB::merge_with(const AABB &p_aabb) { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0 || p_aabb.size.x < 0 || p_aabb.size.y < 0 || p_aabb.size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif Vector3 beg_1, beg_2; Vector3 end_1, end_2; Vector3 min, max; @@ -72,6 +77,11 @@ bool AABB::is_equal_approx(const AABB &p_aabb) const { } AABB AABB::intersection(const AABB &p_aabb) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0 || p_aabb.size.x < 0 || p_aabb.size.y < 0 || p_aabb.size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif Vector3 src_min = position; Vector3 src_max = position + size; Vector3 dst_min = p_aabb.position; @@ -104,6 +114,11 @@ AABB AABB::intersection(const AABB &p_aabb) const { } bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif Vector3 c1, c2; Vector3 end = position + size; real_t near = -1e20; @@ -147,6 +162,11 @@ bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 * } bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif real_t min = 0, max = 1; int axis = 0; real_t sign = 0; diff --git a/core/math/aabb.h b/core/math/aabb.h index 02ce2501a0..81124002e2 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -132,6 +132,11 @@ public: }; inline bool AABB::intersects(const AABB &p_aabb) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0 || p_aabb.size.x < 0 || p_aabb.size.y < 0 || p_aabb.size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif if (position.x >= (p_aabb.position.x + p_aabb.size.x)) { return false; } @@ -155,6 +160,11 @@ inline bool AABB::intersects(const AABB &p_aabb) const { } inline bool AABB::intersects_inclusive(const AABB &p_aabb) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0 || p_aabb.size.x < 0 || p_aabb.size.y < 0 || p_aabb.size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif if (position.x > (p_aabb.position.x + p_aabb.size.x)) { return false; } @@ -178,6 +188,11 @@ inline bool AABB::intersects_inclusive(const AABB &p_aabb) const { } inline bool AABB::encloses(const AABB &p_aabb) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0 || p_aabb.size.x < 0 || p_aabb.size.y < 0 || p_aabb.size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif Vector3 src_min = position; Vector3 src_max = position + size; Vector3 dst_min = p_aabb.position; @@ -288,6 +303,11 @@ bool AABB::inside_convex_shape(const Plane *p_planes, int p_plane_count) const { } bool AABB::has_point(const Vector3 &p_point) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif if (p_point.x < position.x) { return false; } @@ -311,6 +331,11 @@ bool AABB::has_point(const Vector3 &p_point) const { } inline void AABB::expand_to(const Vector3 &p_vector) { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif Vector3 begin = position; Vector3 end = position + size; @@ -377,6 +402,11 @@ inline real_t AABB::get_shortest_axis_size() const { } bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || size.z < 0)) { + ERR_PRINT("AABB size is negative, this is not supported. Use AABB.abs() to get an AABB with a positive size."); + } +#endif real_t divx = 1.0 / p_dir.x; real_t divy = 1.0 / p_dir.y; real_t divz = 1.0 / p_dir.z; diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index a5616b8d79..4a11b99fe8 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -124,10 +124,9 @@ struct AudioFrame { r = p_frame.r; } - _ALWAYS_INLINE_ AudioFrame &operator=(const AudioFrame &p_frame) { + _ALWAYS_INLINE_ void operator=(const AudioFrame &p_frame) { l = p_frame.l; r = p_frame.r; - return *this; } _ALWAYS_INLINE_ operator Vector2() const { diff --git a/core/math/bvh.h b/core/math/bvh.h index 65b8b102a3..c1eff02178 100644 --- a/core/math/bvh.h +++ b/core/math/bvh.h @@ -654,7 +654,7 @@ private: // remove from changed items (not very efficient yet) for (int n = 0; n < (int)changed_items.size(); n++) { if (changed_items[n] == p_handle) { - changed_items.remove_unordered(n); + changed_items.remove_at_unordered(n); // because we are using an unordered remove, // the last changed item will now be at spot 'n', diff --git a/core/math/bvh_pair.inc b/core/math/bvh_pair.inc index 839db59a3a..a12acec2b6 100644 --- a/core/math/bvh_pair.inc +++ b/core/math/bvh_pair.inc @@ -51,7 +51,7 @@ struct ItemPairs { for (int n = 0; n < num_pairs; n++) { if (extended_pairs[n].handle == h) { userdata = extended_pairs[n].userdata; - extended_pairs.remove_unordered(n); + extended_pairs.remove_at_unordered(n); num_pairs--; break; } diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp index f6560f1bea..2956e0cf09 100644 --- a/core/math/convex_hull.cpp +++ b/core/math/convex_hull.cpp @@ -1688,7 +1688,7 @@ real_t ConvexHullInternal::shrink(real_t p_amount, real_t p_clamp_amount) { while (stack.size() > 0) { Vertex *v = stack[stack.size() - 1]; - stack.remove(stack.size() - 1); + stack.remove_at(stack.size() - 1); Edge *e = v->edges; if (e) { do { diff --git a/core/math/delaunay_2d.h b/core/math/delaunay_2d.h index 2f80cb5634..779ac96b79 100644 --- a/core/math/delaunay_2d.h +++ b/core/math/delaunay_2d.h @@ -123,7 +123,7 @@ public: for (int j = 0; j < triangles.size(); j++) { if (triangles[j].bad) { - triangles.remove(j); + triangles.remove_at(j); j--; } } @@ -154,7 +154,7 @@ public: } } if (invalid) { - triangles.remove(i); + triangles.remove_at(i); i--; } } diff --git a/core/math/expression.cpp b/core/math/expression.cpp index 05f2c8dac9..fe277cff96 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -410,6 +410,14 @@ Error Expression::_get_token(Token &r_token) { } else if (id == "self") { r_token.type = TK_SELF; } else { + for (int i = 0; i < Variant::VARIANT_MAX; i++) { + if (id == Variant::get_type_name(Variant::Type(i))) { + r_token.type = TK_BASIC_TYPE; + r_token.value = i; + return OK; + } + } + if (Variant::has_utility_function(id)) { r_token.type = TK_BUILTIN_FUNC; r_token.value = id; @@ -1087,7 +1095,7 @@ Expression::ENode *Expression::_parse_expression() { op->nodes[1] = nullptr; expression.write[i].is_op = false; expression.write[i].node = op; - expression.remove(i + 1); + expression.remove_at(i + 1); } } else { @@ -1119,8 +1127,8 @@ Expression::ENode *Expression::_parse_expression() { //replace all 3 nodes by this operator and make it an expression expression.write[next_op - 1].node = op; - expression.remove(next_op); - expression.remove(next_op); + expression.remove_at(next_op); + expression.remove_at(next_op); } } diff --git a/core/math/quaternion.h b/core/math/quaternion.h index d8d0c06672..457d167516 100644 --- a/core/math/quaternion.h +++ b/core/math/quaternion.h @@ -134,12 +134,11 @@ public: w(p_q.w) { } - Quaternion &operator=(const Quaternion &p_q) { + void operator=(const Quaternion &p_q) { x = p_q.x; y = p_q.y; z = p_q.z; w = p_q.w; - return *this; } Quaternion(const Vector3 &v0, const Vector3 &v1) // shortest arc diff --git a/core/math/rect2.cpp b/core/math/rect2.cpp index f64bf560c8..0e6127b017 100644 --- a/core/math/rect2.cpp +++ b/core/math/rect2.cpp @@ -35,6 +35,11 @@ bool Rect2::is_equal_approx(const Rect2 &p_rect) const { } bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos, Point2 *r_normal) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif real_t min = 0, max = 1; int axis = 0; real_t sign = 0; @@ -95,6 +100,11 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 } bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif //SAT intersection between local and transformed rect2 Vector2 xf_points[4] = { diff --git a/core/math/rect2.h b/core/math/rect2.h index 26e202589d..7029204cf1 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -49,6 +49,11 @@ struct Rect2 { _FORCE_INLINE_ Vector2 get_center() const { return position + (size * 0.5); } inline bool intersects(const Rect2 &p_rect, const bool p_include_borders = false) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif if (p_include_borders) { if (position.x > (p_rect.position.x + p_rect.size.width)) { return false; @@ -81,6 +86,11 @@ struct Rect2 { } inline real_t distance_to(const Vector2 &p_point) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif real_t dist = 0.0; bool inside = true; @@ -117,6 +127,11 @@ struct Rect2 { 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 { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) && ((p_rect.position.x + p_rect.size.x) <= (position.x + size.x)) && ((p_rect.position.y + p_rect.size.y) <= (position.y + size.y)); @@ -147,7 +162,11 @@ struct Rect2 { } inline Rect2 merge(const Rect2 &p_rect) const { ///< return a merged rect - +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif Rect2 new_rect; new_rect.position.x = MIN(p_rect.position.x, position.x); @@ -161,6 +180,11 @@ struct Rect2 { return new_rect; } inline bool has_point(const Point2 &p_point) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif if (p_point.x < position.x) { return false; } @@ -183,6 +207,11 @@ struct Rect2 { bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; } inline Rect2 grow(real_t p_amount) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif Rect2 g = *this; g.grow_by(p_amount); return g; @@ -209,6 +238,11 @@ struct Rect2 { } inline Rect2 grow_individual(real_t p_left, real_t p_top, real_t p_right, real_t p_bottom) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif Rect2 g = *this; g.position.x -= p_left; g.position.y -= p_top; @@ -225,7 +259,11 @@ struct Rect2 { } inline void expand_to(const Vector2 &p_vector) { //in place function for speed - +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2 size is negative, this is not supported. Use Rect2.abs() to get a Rect2 with a positive size."); + } +#endif Vector2 begin = position; Vector2 end = position + size; @@ -349,6 +387,11 @@ struct Rect2i { _FORCE_INLINE_ Vector2i get_center() const { return position + (size / 2); } inline bool intersects(const Rect2i &p_rect) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif if (position.x > (p_rect.position.x + p_rect.size.width)) { return false; } @@ -366,6 +409,11 @@ struct Rect2i { } inline bool encloses(const Rect2i &p_rect) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) && ((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) && ((p_rect.position.y + p_rect.size.y) < (position.y + size.y)); @@ -389,14 +437,18 @@ struct Rect2i { Point2i p_rect_end = p_rect.position + p_rect.size; Point2i end = position + size; - new_rect.size.x = (int)(MIN(p_rect_end.x, end.x) - new_rect.position.x); - new_rect.size.y = (int)(MIN(p_rect_end.y, end.y) - new_rect.position.y); + new_rect.size.x = MIN(p_rect_end.x, end.x) - new_rect.position.x; + new_rect.size.y = MIN(p_rect_end.y, end.y) - new_rect.position.y; return new_rect; } inline Rect2i merge(const Rect2i &p_rect) const { ///< return a merged rect - +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0 || p_rect.size.x < 0 || p_rect.size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif Rect2i new_rect; new_rect.position.x = MIN(p_rect.position.x, position.x); @@ -410,6 +462,11 @@ struct Rect2i { return new_rect; } bool has_point(const Point2i &p_point) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif if (p_point.x < position.x) { return false; } @@ -431,6 +488,11 @@ struct Rect2i { bool operator!=(const Rect2i &p_rect) const { return position != p_rect.position || size != p_rect.size; } Rect2i grow(int p_amount) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif Rect2i g = *this; g.position.x -= p_amount; g.position.y -= p_amount; @@ -453,6 +515,11 @@ struct Rect2i { } inline Rect2i grow_individual(int p_left, int p_top, int p_right, int p_bottom) const { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif Rect2i g = *this; g.position.x -= p_left; g.position.y -= p_top; @@ -469,6 +536,11 @@ struct Rect2i { } inline void expand_to(const Point2i &p_vector) { +#ifdef MATH_CHECKS + if (unlikely(size.x < 0 || size.y < 0)) { + ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); + } +#endif Point2i begin = position; Point2i end = position + size; diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 42e3da0b27..b9bd04b8c1 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -108,10 +108,10 @@ Vector3 Vector3::move_toward(const Vector3 &p_to, const real_t p_delta) const { return len <= p_delta || len < CMP_EPSILON ? p_to : v + vd / len * p_delta; } -Basis Vector3::outer(const Vector3 &p_b) const { - Vector3 row0(x * p_b.x, x * p_b.y, x * p_b.z); - Vector3 row1(y * p_b.x, y * p_b.y, y * p_b.z); - Vector3 row2(z * p_b.x, z * p_b.y, z * p_b.z); +Basis Vector3::outer(const Vector3 &p_with) const { + Vector3 row0(x * p_with.x, x * p_with.y, x * p_with.z); + Vector3 row1(y * p_with.x, y * p_with.y, y * p_with.z); + Vector3 row2(z * p_with.x, z * p_with.y, z * p_with.z); return Basis(row0, row1, row2); } diff --git a/core/math/vector3.h b/core/math/vector3.h index 02a56f684e..6c21968aae 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -128,9 +128,9 @@ struct Vector3 { return n.normalized(); } - _FORCE_INLINE_ Vector3 cross(const Vector3 &p_b) const; - _FORCE_INLINE_ real_t dot(const Vector3 &p_b) const; - Basis outer(const Vector3 &p_b) const; + _FORCE_INLINE_ Vector3 cross(const Vector3 &p_with) const; + _FORCE_INLINE_ real_t dot(const Vector3 &p_with) const; + Basis outer(const Vector3 &p_with) const; _FORCE_INLINE_ Vector3 abs() const; _FORCE_INLINE_ Vector3 floor() const; @@ -199,17 +199,17 @@ struct Vector3 { } }; -Vector3 Vector3::cross(const Vector3 &p_b) const { +Vector3 Vector3::cross(const Vector3 &p_with) const { Vector3 ret( - (y * p_b.z) - (z * p_b.y), - (z * p_b.x) - (x * p_b.z), - (x * p_b.y) - (y * p_b.x)); + (y * p_with.z) - (z * p_with.y), + (z * p_with.x) - (x * p_with.z), + (x * p_with.y) - (y * p_with.x)); return ret; } -real_t Vector3::dot(const Vector3 &p_b) const { - return x * p_b.x + y * p_b.y + z * p_b.z; +real_t Vector3::dot(const Vector3 &p_with) const { + return x * p_with.x + y * p_with.y + z * p_with.z; } Vector3 Vector3::abs() const { diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 4b3c8b123f..ac628acf81 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -497,22 +497,6 @@ void ClassDB::add_compatibility_class(const StringName &p_class, const StringNam compat_classes[p_class] = p_fallback; } -thread_local bool initializing_with_extension = false; -thread_local ObjectNativeExtension *initializing_extension = nullptr; -thread_local GDExtensionClassInstancePtr initializing_extension_instance = nullptr; - -void ClassDB::instance_get_native_extension_data(ObjectNativeExtension **r_extension, GDExtensionClassInstancePtr *r_extension_instance, Object *p_base) { - if (initializing_with_extension) { - *r_extension = initializing_extension; - *r_extension_instance = initializing_extension_instance; - initializing_with_extension = false; - initializing_extension->set_object_instance(*r_extension_instance, p_base); - } else { - *r_extension = nullptr; - *r_extension_instance = nullptr; - } -} - Object *ClassDB::instantiate(const StringName &p_class) { ClassInfo *ti; { @@ -533,21 +517,31 @@ Object *ClassDB::instantiate(const StringName &p_class) { return nullptr; } #endif - if (ti->native_extension) { - initializing_with_extension = true; - initializing_extension = ti->native_extension; - initializing_extension_instance = ti->native_extension->create_instance(ti->native_extension->class_userdata); + if (ti->native_extension && ti->native_extension->create_instance) { + return (Object *)ti->native_extension->create_instance(ti->native_extension->class_userdata); + } else { + return ti->creation_func(); } - return ti->creation_func(); } -Object *ClassDB::construct_object(Object *(*p_create_func)(), ObjectNativeExtension *p_extension) { - if (p_extension) { - initializing_with_extension = true; - initializing_extension = p_extension; - initializing_extension_instance = p_extension->create_instance(p_extension->class_userdata); +void ClassDB::set_object_extension_instance(Object *p_object, const StringName &p_class, GDExtensionClassInstancePtr p_instance) { + ERR_FAIL_COND(!p_object); + ClassInfo *ti; + { + OBJTYPE_RLOCK; + ti = classes.getptr(p_class); + if (!ti || ti->disabled || !ti->creation_func || (ti->native_extension && !ti->native_extension->create_instance)) { + if (compat_classes.has(p_class)) { + ti = classes.getptr(compat_classes[p_class]); + } + } + ERR_FAIL_COND_MSG(!ti, "Cannot get class '" + String(p_class) + "'."); + ERR_FAIL_COND_MSG(ti->disabled, "Class '" + String(p_class) + "' is disabled."); + ERR_FAIL_COND_MSG(!ti->native_extension, "Class '" + String(p_class) + "' has no native extension."); } - return p_create_func(); + + p_object->_extension = ti->native_extension; + p_object->_extension_instance = p_instance; } bool ClassDB::can_instantiate(const StringName &p_class) { diff --git a/core/object/class_db.h b/core/object/class_db.h index dae75ba564..ca9c1def29 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -211,8 +211,7 @@ public: static bool is_parent_class(const StringName &p_class, const StringName &p_inherits); static bool can_instantiate(const StringName &p_class); static Object *instantiate(const StringName &p_class); - static Object *construct_object(Object *(*p_create_func)(), ObjectNativeExtension *p_extension); - static void instance_get_native_extension_data(ObjectNativeExtension **r_extension, GDExtensionClassInstancePtr *r_extension_instance, Object *p_base); + static void set_object_extension_instance(Object *p_object, const StringName &p_class, GDExtensionClassInstancePtr p_instance); static APIType get_api_type(const StringName &p_class); diff --git a/core/object/make_virtuals.py b/core/object/make_virtuals.py index 86c2891e5d..e961745d96 100644 --- a/core/object/make_virtuals.py +++ b/core/object/make_virtuals.py @@ -1,7 +1,8 @@ proto = """ #define GDVIRTUAL$VER($RET m_name $ARG) \\ StringName _gdvirtual_##m_name##_sn = #m_name;\\ -GDNativeExtensionClassCallVirtual _gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr;\\ +mutable bool _gdvirtual_##m_name##_initialized = false;\\ +mutable GDNativeExtensionClassCallVirtual _gdvirtual_##m_name = nullptr;\\ _FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST { \\ ScriptInstance *script_instance = ((Object*)(this))->get_script_instance();\\ if (script_instance) {\\ @@ -13,6 +14,10 @@ _FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST { \\ return true;\\ } \\ }\\ + if (unlikely(_get_extension() && !_gdvirtual_##m_name##_initialized)) {\\ + _gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr;\\ + _gdvirtual_##m_name##_initialized = true;\\ + }\\ if (_gdvirtual_##m_name) {\\ $CALLPTRARGS\\ $CALLPTRRETDEF\\ @@ -28,6 +33,10 @@ _FORCE_INLINE_ bool _gdvirtual_##m_name##_overridden() const { \\ if (script_instance) {\\ return script_instance->has_method(_gdvirtual_##m_name##_sn);\\ }\\ + if (unlikely(_get_extension() && !_gdvirtual_##m_name##_initialized)) {\\ + _gdvirtual_##m_name = (_get_extension() && _get_extension()->get_virtual) ? _get_extension()->get_virtual(_get_extension()->class_userdata, #m_name) : (GDNativeExtensionClassCallVirtual) nullptr;\\ + _gdvirtual_##m_name##_initialized = true;\\ + }\\ if (_gdvirtual_##m_name) {\\ return true;\\ }\\ diff --git a/core/object/object.cpp b/core/object/object.cpp index 90bd697d37..3942dddf52 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -1838,8 +1838,6 @@ void Object::_construct_object(bool p_reference) { type_is_reference = p_reference; _instance_id = ObjectDB::add_instance(this); - ClassDB::instance_get_native_extension_data(&_extension, &_extension_instance, this); - #ifdef DEBUG_ENABLED _lock_index.init(1); #endif diff --git a/core/object/object.h b/core/object/object.h index 218bc26dec..795bbf27e8 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -284,7 +284,6 @@ struct ObjectNativeExtension { GDNativeExtensionClassCreateInstance create_instance; GDNativeExtensionClassFreeInstance free_instance; - GDNativeExtensionClassObjectInstance set_object_instance; GDNativeExtensionClassGetVirtual get_virtual; }; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index c2449e3ddc..8ec1a973e7 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -511,7 +511,7 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c Variant defval; if (script->get_property_default_value(E->key(), defval)) { //remove because it's the same as the default value - if (defval == E) { + if (defval == E->get()) { to_remove.push_back(E->key()); } } diff --git a/core/object/undo_redo.cpp b/core/object/undo_redo.cpp index 07006e7968..3459506860 100644 --- a/core/object/undo_redo.cpp +++ b/core/object/undo_redo.cpp @@ -282,7 +282,7 @@ void UndoRedo::_pop_history_tail() { } } - actions.remove(0); + actions.remove_at(0); if (current_action >= 0) { current_action--; } diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp index 5fae13779e..7ab85ac9d0 100644 --- a/core/string/node_path.cpp +++ b/core/string/node_path.cpp @@ -293,12 +293,12 @@ void NodePath::simplify() { break; } if (data->path[i].operator String() == ".") { - data->path.remove(i); + data->path.remove_at(i); i--; } else if (i > 0 && data->path[i].operator String() == ".." && data->path[i - 1].operator String() != "." && data->path[i - 1].operator String() != "..") { //remove both - data->path.remove(i - 1); - data->path.remove(i - 1); + data->path.remove_at(i - 1); + data->path.remove_at(i - 1); i -= 2; if (data->path.size() == 0) { data->path.push_back("."); diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 70236231a2..8d1f610578 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -130,9 +130,8 @@ Char16String &Char16String::operator+=(char16_t p_char) { return *this; } -Char16String &Char16String::operator=(const char16_t *p_cstr) { +void Char16String::operator=(const char16_t *p_cstr) { copy_from(p_cstr); - return *this; } const char16_t *Char16String::get_data() const { @@ -186,9 +185,8 @@ CharString &CharString::operator+=(char p_char) { return *this; } -CharString &CharString::operator=(const char *p_cstr) { +void CharString::operator=(const char *p_cstr) { copy_from(p_cstr); - return *this; } const char *CharString::get_data() const { @@ -3670,15 +3668,15 @@ String String::simplify_path() const { for (int i = 0; i < dirs.size(); i++) { String d = dirs[i]; if (d == ".") { - dirs.remove(i); + dirs.remove_at(i); i--; } else if (d == "..") { if (i == 0) { - dirs.remove(i); + dirs.remove_at(i); i--; } else { - dirs.remove(i); - dirs.remove(i - 1); + dirs.remove_at(i); + dirs.remove_at(i - 1); i -= 2; } } diff --git a/core/string/ustring.h b/core/string/ustring.h index 1d80ccf58d..396c996050 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -108,13 +108,10 @@ public: _FORCE_INLINE_ Char16String() {} _FORCE_INLINE_ Char16String(const Char16String &p_str) { _cowdata._ref(p_str._cowdata); } - _FORCE_INLINE_ Char16String &operator=(const Char16String &p_str) { - _cowdata._ref(p_str._cowdata); - return *this; - } + _FORCE_INLINE_ void operator=(const Char16String &p_str) { _cowdata._ref(p_str._cowdata); } _FORCE_INLINE_ Char16String(const char16_t *p_cstr) { copy_from(p_cstr); } - Char16String &operator=(const char16_t *p_cstr); + void operator=(const char16_t *p_cstr); bool operator<(const Char16String &p_right) const; Char16String &operator+=(char16_t p_char); int length() const { return size() ? size() - 1 : 0; } @@ -152,13 +149,10 @@ public: _FORCE_INLINE_ CharString() {} _FORCE_INLINE_ CharString(const CharString &p_str) { _cowdata._ref(p_str._cowdata); } - _FORCE_INLINE_ CharString &operator=(const CharString &p_str) { - _cowdata._ref(p_str._cowdata); - return *this; - } + _FORCE_INLINE_ void operator=(const CharString &p_str) { _cowdata._ref(p_str._cowdata); } _FORCE_INLINE_ CharString(const char *p_cstr) { copy_from(p_cstr); } - CharString &operator=(const char *p_cstr); + void operator=(const char *p_cstr); bool operator<(const CharString &p_right) const; CharString &operator+=(char p_char); int length() const { return size() ? size() - 1 : 0; } @@ -209,7 +203,7 @@ public: _FORCE_INLINE_ char32_t *ptrw() { return _cowdata.ptrw(); } _FORCE_INLINE_ const char32_t *ptr() const { return _cowdata.ptr(); } - void remove(int p_index) { _cowdata.remove(p_index); } + void remove_at(int p_index) { _cowdata.remove_at(p_index); } _FORCE_INLINE_ void clear() { resize(0); } @@ -442,11 +436,7 @@ public: _FORCE_INLINE_ String() {} _FORCE_INLINE_ String(const String &p_str) { _cowdata._ref(p_str._cowdata); } - - String &operator=(const String &p_str) { - _cowdata._ref(p_str._cowdata); - return *this; - } + _FORCE_INLINE_ void operator=(const String &p_str) { _cowdata._ref(p_str._cowdata); } Vector<uint8_t> to_ascii_buffer() const; Vector<uint8_t> to_utf8_buffer() const; diff --git a/core/templates/bin_sorted_array.h b/core/templates/bin_sorted_array.h index be9d0b5475..8db3e7aeb8 100644 --- a/core/templates/bin_sorted_array.h +++ b/core/templates/bin_sorted_array.h @@ -112,7 +112,7 @@ public: return current_idx; } - void remove(uint64_t p_idx) { + void remove_at(uint64_t p_idx) { ERR_FAIL_COND(p_idx >= array.size()); uint64_t new_idx = move(p_idx, 0); uint64_t swap_idx = array.size() - 1; diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index 9b8c0eb528..e79ca037db 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -167,7 +167,7 @@ public: Error resize(int p_size); - _FORCE_INLINE_ void remove(int p_index) { + _FORCE_INLINE_ void remove_at(int p_index) { ERR_FAIL_INDEX(p_index, size()); T *p = ptrw(); int len = size(); diff --git a/core/templates/local_vector.h b/core/templates/local_vector.h index 5704b8f230..4ec08821f8 100644 --- a/core/templates/local_vector.h +++ b/core/templates/local_vector.h @@ -70,7 +70,7 @@ public: } } - void remove(U p_index) { + void remove_at(U p_index) { ERR_FAIL_UNSIGNED_INDEX(p_index, count); count--; for (U i = p_index; i < count; i++) { @@ -83,7 +83,7 @@ public: /// Removes the item copying the last value into the position of the one to /// remove. It's generally faster than `remove`. - void remove_unordered(U p_index) { + void remove_at_unordered(U p_index) { ERR_FAIL_INDEX(p_index, count); count--; if (count > p_index) { @@ -97,7 +97,7 @@ public: void erase(const T &p_val) { int64_t idx = find(p_val); if (idx >= 0) { - remove(idx); + remove_at(idx); } } @@ -234,19 +234,17 @@ public: data[i] = p_from.data[i]; } } - inline LocalVector &operator=(const LocalVector &p_from) { + inline void operator=(const LocalVector &p_from) { resize(p_from.size()); for (U i = 0; i < p_from.count; i++) { data[i] = p_from.data[i]; } - return *this; } - inline LocalVector &operator=(const Vector<T> &p_from) { + inline void operator=(const Vector<T> &p_from) { resize(p_from.size()); for (U i = 0; i < count; i++) { data[i] = p_from[i]; } - return *this; } _FORCE_INLINE_ ~LocalVector() { diff --git a/core/templates/oa_hash_map.h b/core/templates/oa_hash_map.h index 025cc30db4..9dab36e343 100644 --- a/core/templates/oa_hash_map.h +++ b/core/templates/oa_hash_map.h @@ -353,7 +353,7 @@ public: (*this) = p_other; } - OAHashMap &operator=(const OAHashMap &p_other) { + void operator=(const OAHashMap &p_other) { if (capacity != 0) { clear(); } @@ -363,7 +363,6 @@ public: for (Iterator it = p_other.iter(); it.valid; it = p_other.next_iter(it)) { set(*it.key, *it.value); } - return *this; } OAHashMap(uint32_t p_initial_capacity = 64) { diff --git a/core/templates/ordered_hash_map.h b/core/templates/ordered_hash_map.h index 4996b88190..928072bb18 100644 --- a/core/templates/ordered_hash_map.h +++ b/core/templates/ordered_hash_map.h @@ -85,11 +85,10 @@ public: next_element(other.next_element) { } - Element &operator=(const Element &other) { + void operator=(const Element &other) { list_element = other.list_element; next_element = other.next_element; prev_element = other.prev_element; - return *this; } _FORCE_INLINE_ bool operator==(const Element &p_other) const { @@ -145,9 +144,8 @@ public: list_element(other.list_element) { } - ConstElement &operator=(const ConstElement &other) { + void operator=(const ConstElement &other) { list_element = other.list_element; - return *this; } ConstElement next() const { diff --git a/core/templates/vector.h b/core/templates/vector.h index 98982c80d3..376d5cbeff 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -68,11 +68,11 @@ public: _FORCE_INLINE_ bool append(const T &p_elem) { return push_back(p_elem); } //alias void fill(T p_elem); - void remove(int p_index) { _cowdata.remove(p_index); } + void remove_at(int p_index) { _cowdata.remove_at(p_index); } void erase(const T &p_val) { int idx = find(p_val); if (idx >= 0) { - remove(idx); + remove_at(idx); } } void reverse(); @@ -132,9 +132,8 @@ public: insert(i, p_val); } - inline Vector &operator=(const Vector &p_from) { + inline void operator=(const Vector &p_from) { _cowdata._ref(p_from._cowdata); - return *this; } Vector<uint8_t> to_byte_array() const { diff --git a/core/templates/vmap.h b/core/templates/vmap.h index 520e0b3720..0ff105ccbf 100644 --- a/core/templates/vmap.h +++ b/core/templates/vmap.h @@ -134,7 +134,7 @@ public: if (pos < 0) { return; } - _cowdata.remove(pos); + _cowdata.remove_at(pos); } int find(const T &p_val) const { @@ -193,9 +193,8 @@ public: _FORCE_INLINE_ VMap() {} _FORCE_INLINE_ VMap(const VMap &p_from) { _cowdata._ref(p_from._cowdata); } - inline VMap &operator=(const VMap &p_from) { + inline void operator=(const VMap &p_from) { _cowdata._ref(p_from._cowdata); - return *this; } }; diff --git a/core/templates/vset.h b/core/templates/vset.h index 6665651d42..94e7a17061 100644 --- a/core/templates/vset.h +++ b/core/templates/vset.h @@ -119,7 +119,7 @@ public: if (pos < 0) { return; } - _data.remove(pos); + _data.remove_at(pos); } int find(const T &p_val) const { diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 69a0fff1a1..b049c29688 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -322,8 +322,8 @@ bool Array::has(const Variant &p_value) const { return _p->array.find(p_value, 0) != -1; } -void Array::remove(int p_pos) { - _p->array.remove(p_pos); +void Array::remove_at(int p_pos) { + _p->array.remove_at(p_pos); } void Array::set(int p_idx, const Variant &p_value) { @@ -576,7 +576,7 @@ Variant Array::pop_back() { Variant Array::pop_front() { if (!_p->array.is_empty()) { const Variant ret = _p->array.get(0); - _p->array.remove(0); + _p->array.remove_at(0); return ret; } return Variant(); @@ -603,7 +603,7 @@ Variant Array::pop_at(int p_pos) { _p->array.size())); const Variant ret = _p->array.get(p_pos); - _p->array.remove(p_pos); + _p->array.remove_at(p_pos); return ret; } diff --git a/core/variant/array.h b/core/variant/array.h index bd39b8e0b1..5d2839dda7 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -75,7 +75,7 @@ public: Error resize(int p_new_size); Error insert(int p_pos, const Variant &p_value); - void remove(int p_pos); + void remove_at(int p_pos); void fill(const Variant &p_value); Variant front() const; diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 65ea969146..b586757dcd 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1471,7 +1471,7 @@ static void _register_variant_builtin_methods() { bind_method(Vector2, angle, sarray(), varray()); bind_method(Vector2, angle_to, sarray("to"), varray()); bind_method(Vector2, angle_to_point, sarray("to"), varray()); - bind_method(Vector2, direction_to, sarray("b"), varray()); + bind_method(Vector2, direction_to, sarray("to"), varray()); bind_method(Vector2, distance_to, sarray("to"), varray()); bind_method(Vector2, distance_squared_to, sarray("to"), varray()); bind_method(Vector2, length, sarray(), varray()); @@ -1551,9 +1551,9 @@ static void _register_variant_builtin_methods() { bind_method(Vector3, max_axis, sarray(), varray()); bind_method(Vector3, angle_to, sarray("to"), varray()); bind_method(Vector3, signed_angle_to, sarray("to", "axis"), varray()); - bind_method(Vector3, direction_to, sarray("b"), varray()); - bind_method(Vector3, distance_to, sarray("b"), varray()); - bind_method(Vector3, distance_squared_to, sarray("b"), varray()); + bind_method(Vector3, direction_to, sarray("to"), varray()); + bind_method(Vector3, distance_to, sarray("to"), varray()); + bind_method(Vector3, distance_squared_to, sarray("to"), varray()); bind_method(Vector3, length, sarray(), varray()); bind_method(Vector3, length_squared, sarray(), varray()); bind_method(Vector3, limit_length, sarray("length"), varray(1.0)); @@ -1808,7 +1808,7 @@ static void _register_variant_builtin_methods() { bind_method(Array, append_array, sarray("array"), varray()); bind_method(Array, resize, sarray("size"), varray()); bind_method(Array, insert, sarray("position", "value"), varray()); - bind_method(Array, remove, sarray("position"), varray()); + bind_method(Array, remove_at, sarray("position"), varray()); bind_method(Array, fill, sarray("value"), varray()); bind_method(Array, erase, sarray("value"), varray()); bind_method(Array, front, sarray(), varray()); @@ -1842,7 +1842,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedByteArray, push_back, sarray("value"), varray()); bind_method(PackedByteArray, append, sarray("value"), varray()); bind_method(PackedByteArray, append_array, sarray("array"), varray()); - bind_method(PackedByteArray, remove, sarray("index"), varray()); + bind_method(PackedByteArray, remove_at, sarray("index"), varray()); bind_method(PackedByteArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedByteArray, fill, sarray("value"), varray()); bind_method(PackedByteArray, resize, sarray("new_size"), varray()); @@ -1903,7 +1903,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt32Array, push_back, sarray("value"), varray()); bind_method(PackedInt32Array, append, sarray("value"), varray()); bind_method(PackedInt32Array, append_array, sarray("array"), varray()); - bind_method(PackedInt32Array, remove, sarray("index"), varray()); + bind_method(PackedInt32Array, remove_at, sarray("index"), varray()); bind_method(PackedInt32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt32Array, fill, sarray("value"), varray()); bind_method(PackedInt32Array, resize, sarray("new_size"), varray()); @@ -1923,7 +1923,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedInt64Array, push_back, sarray("value"), varray()); bind_method(PackedInt64Array, append, sarray("value"), varray()); bind_method(PackedInt64Array, append_array, sarray("array"), varray()); - bind_method(PackedInt64Array, remove, sarray("index"), varray()); + bind_method(PackedInt64Array, remove_at, sarray("index"), varray()); bind_method(PackedInt64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedInt64Array, fill, sarray("value"), varray()); bind_method(PackedInt64Array, resize, sarray("new_size"), varray()); @@ -1943,7 +1943,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat32Array, push_back, sarray("value"), varray()); bind_method(PackedFloat32Array, append, sarray("value"), varray()); bind_method(PackedFloat32Array, append_array, sarray("array"), varray()); - bind_method(PackedFloat32Array, remove, sarray("index"), varray()); + bind_method(PackedFloat32Array, remove_at, sarray("index"), varray()); bind_method(PackedFloat32Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat32Array, fill, sarray("value"), varray()); bind_method(PackedFloat32Array, resize, sarray("new_size"), varray()); @@ -1963,7 +1963,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedFloat64Array, push_back, sarray("value"), varray()); bind_method(PackedFloat64Array, append, sarray("value"), varray()); bind_method(PackedFloat64Array, append_array, sarray("array"), varray()); - bind_method(PackedFloat64Array, remove, sarray("index"), varray()); + bind_method(PackedFloat64Array, remove_at, sarray("index"), varray()); bind_method(PackedFloat64Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedFloat64Array, fill, sarray("value"), varray()); bind_method(PackedFloat64Array, resize, sarray("new_size"), varray()); @@ -1983,7 +1983,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedStringArray, push_back, sarray("value"), varray()); bind_method(PackedStringArray, append, sarray("value"), varray()); bind_method(PackedStringArray, append_array, sarray("array"), varray()); - bind_method(PackedStringArray, remove, sarray("index"), varray()); + bind_method(PackedStringArray, remove_at, sarray("index"), varray()); bind_method(PackedStringArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedStringArray, fill, sarray("value"), varray()); bind_method(PackedStringArray, resize, sarray("new_size"), varray()); @@ -2003,7 +2003,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector2Array, push_back, sarray("value"), varray()); bind_method(PackedVector2Array, append, sarray("value"), varray()); bind_method(PackedVector2Array, append_array, sarray("array"), varray()); - bind_method(PackedVector2Array, remove, sarray("index"), varray()); + bind_method(PackedVector2Array, remove_at, sarray("index"), varray()); bind_method(PackedVector2Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector2Array, fill, sarray("value"), varray()); bind_method(PackedVector2Array, resize, sarray("new_size"), varray()); @@ -2023,7 +2023,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedVector3Array, push_back, sarray("value"), varray()); bind_method(PackedVector3Array, append, sarray("value"), varray()); bind_method(PackedVector3Array, append_array, sarray("array"), varray()); - bind_method(PackedVector3Array, remove, sarray("index"), varray()); + bind_method(PackedVector3Array, remove_at, sarray("index"), varray()); bind_method(PackedVector3Array, insert, sarray("at_index", "value"), varray()); bind_method(PackedVector3Array, fill, sarray("value"), varray()); bind_method(PackedVector3Array, resize, sarray("new_size"), varray()); @@ -2043,7 +2043,7 @@ static void _register_variant_builtin_methods() { bind_method(PackedColorArray, push_back, sarray("value"), varray()); bind_method(PackedColorArray, append, sarray("value"), varray()); bind_method(PackedColorArray, append_array, sarray("array"), varray()); - bind_method(PackedColorArray, remove, sarray("index"), varray()); + bind_method(PackedColorArray, remove_at, sarray("index"), varray()); bind_method(PackedColorArray, insert, sarray("at_index", "value"), varray()); bind_method(PackedColorArray, fill, sarray("value"), varray()); bind_method(PackedColorArray, resize, sarray("new_size"), varray()); diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index 2530d77c62..b6ad2d870e 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -704,7 +704,7 @@ struct VariantIndexedSetGet_String { String *b = VariantGetInternalPtr<String>::get_ptr(base); const String *v = VariantInternal::get_string(value); if (v->length() == 0) { - b->remove(index); + b->remove_at(index); } else { b->set(index, v->get(0)); } @@ -723,7 +723,7 @@ struct VariantIndexedSetGet_String { String *b = VariantGetInternalPtr<String>::get_ptr(base); const String *v = VariantInternal::get_string(value); if (v->length() == 0) { - b->remove(index); + b->remove_at(index); } else { b->set(index, v->get(0)); } @@ -738,7 +738,7 @@ struct VariantIndexedSetGet_String { OOB_TEST(index, v.length()); const String &m = *reinterpret_cast<const String *>(member); if (unlikely(m.length() == 0)) { - v.remove(index); + v.remove_at(index); } else { v.set(index, m.unicode_at(0)); } diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 9cfe494b7f..41cc043a74 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1,13 +1,15 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="@GlobalScope" version="4.0"> <brief_description> - Global scope constants and variables. + Global scope constants and functions. </brief_description> <description> - Global scope constants and variables. This is all that resides in the globals, constants regarding error codes, keycodes, property hints, etc. + A list of global scope enumerated constants and built-in functions. This is all that resides in the globals, constants regarding error codes, keycodes, property hints, etc. Singletons are also documented here, since they can be accessed from anywhere. + For the entries related to GDScript which can be accessed in any script see [@GDScript]. </description> <tutorials> + <link title="Random number generation">$DOCS_URL/tutorials/math/random_number_generation.html</link> </tutorials> <methods> <method name="abs"> @@ -248,9 +250,9 @@ - 1.0: Linear - Between -1.0 and 0.0 (exclusive): Ease out-in - 0.0: Constant - - Between 0.0 to 1.0 (exclusive): Ease in + - Between 0.0 to 1.0 (exclusive): Ease out - 1.0: Linear - - Greater than 1.0 (exclusive): Ease out + - Greater than 1.0 (exclusive): Ease in [/codeblock] [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/ease_cheatsheet.png]ease() curve values cheatsheet[/url] See also [method smoothstep]. If you need to perform more advanced transitions, use [Tween] or [AnimationPlayer]. diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index 170cfea6f9..bdf8a78dc3 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -6,6 +6,7 @@ <description> [AABB] consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. It uses floating-point coordinates. The 2D counterpart to [AABB] is [Rect2]. + Negative values for [member size] are not supported and will not work for most methods. Use [method abs] to get an AABB with a positive size. [b]Note:[/b] Unlike [Rect2], [AABB] does not have a variant that uses integer coordinates. </description> <tutorials> @@ -157,14 +158,15 @@ <return type="bool" /> <argument index="0" name="point" type="Vector3" /> <description> - Returns [code]true[/code] if the [AABB] contains a point. + Returns [code]true[/code] if the [AABB] contains a point. Points on the faces of the AABB are considered included, though float-point precision errors may impact the accuracy of such checks. + [b]Note:[/b] This method is not reliable for [AABB] with a [i]negative size[/i]. Use [method abs] to get a positive sized equivalent [AABB] to check for contained points. </description> </method> <method name="intersection" qualifiers="const"> <return type="AABB" /> <argument index="0" name="with" type="AABB" /> <description> - Returns the intersection between two [AABB]. An empty AABB (size 0,0,0) is returned on failure. + Returns the intersection between two [AABB]. An empty AABB (size [code](0, 0, 0)[/code]) is returned on failure. </description> </method> <method name="intersects" qualifiers="const"> diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index 11c0fc33b8..bbb5f6b8e3 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -244,6 +244,12 @@ Returns the number of points currently in the points pool. </description> </method> + <method name="get_point_ids"> + <return type="Array" /> + <description> + Returns an array of all point IDs. + </description> + </method> <method name="get_point_path"> <return type="PackedVector3Array" /> <argument index="0" name="from_id" type="int" /> @@ -267,12 +273,6 @@ Returns the weight scale of the point associated with the given [code]id[/code]. </description> </method> - <method name="get_points"> - <return type="Array" /> - <description> - Returns an array of all points. - </description> - </method> <method name="has_point" qualifiers="const"> <return type="bool" /> <argument index="0" name="id" type="int" /> diff --git a/doc/classes/AStar2D.xml b/doc/classes/AStar2D.xml index 43e7d59665..dc821ebb8b 100644 --- a/doc/classes/AStar2D.xml +++ b/doc/classes/AStar2D.xml @@ -215,6 +215,12 @@ Returns the number of points currently in the points pool. </description> </method> + <method name="get_point_ids"> + <return type="Array" /> + <description> + Returns an array of all point IDs. + </description> + </method> <method name="get_point_path"> <return type="PackedVector2Array" /> <argument index="0" name="from_id" type="int" /> @@ -238,12 +244,6 @@ Returns the weight scale of the point associated with the given [code]id[/code]. </description> </method> - <method name="get_points"> - <return type="Array" /> - <description> - Returns an array of all points. - </description> - </method> <method name="has_point" qualifiers="const"> <return type="bool" /> <argument index="0" name="id" type="int" /> diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index df0cc6f268..8fa4e9a309 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -68,11 +68,11 @@ <member name="dialog_text" type="String" setter="set_text" getter="get_text" default=""""> The text displayed by the dialog. </member> - <member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" override="true" default="true" /> - <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" /> + <member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" overrides="Window" default="true" /> + <member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default=""Alert!"" /> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" overrides="Window" default="true" /> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" overrides="Window" default="false" /> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" overrides="Window" default="true" /> </members> <signals> <signal name="cancelled"> diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml index b299f8654a..48507471e9 100644 --- a/doc/classes/AnimationNodeStateMachinePlayback.xml +++ b/doc/classes/AnimationNodeStateMachinePlayback.xml @@ -72,6 +72,6 @@ </method> </methods> <members> - <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> + <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="true" /> </members> </class> diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index b74d4c1d3d..d505ee98cc 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -194,7 +194,7 @@ <return type="void" /> <argument index="0" name="value" type="Variant" /> <description> - Removes the first occurrence of a value from the array. To remove an element by index, use [method remove] instead. + Removes the first occurrence of a value from the array. To remove an element by index, use [method remove_at] instead. [b]Note:[/b] This method acts in-place and doesn't return a value. [b]Note:[/b] On large arrays, this method will be slower if the removed element is close to the beginning of the array (index 0). This is because all elements placed after the removed element have to be reindexed. </description> @@ -400,7 +400,7 @@ [/codeblock] </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="position" type="int" /> <description> diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 981b3167d9..1b77a5b4d8 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -57,7 +57,7 @@ <member name="disabled" type="bool" setter="set_disabled" getter="is_disabled" default="false"> If [code]true[/code], the button is in disabled state and can't be clicked or toggled. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="keep_pressed_outside" type="bool" setter="set_keep_pressed_outside" getter="is_keep_pressed_outside" default="false"> If [code]true[/code], the button stays pressed when moving the cursor outside the button while pressing it. [b]Note:[/b] This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value. diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index f0f49f89d5..aa2ffae48c 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -53,6 +53,7 @@ <argument index="1" name="texture" type="Texture2D" /> <description> Sets the texture for the slot specified by [code]param[/code]. See [enum TextureParam] for available slots. + [b]Note:[/b] When setting a roughness or metallic texture on a material that has no texture assigned to those slots, [member roughness] or [member metallic] will automatically be set to [code]1.0[/code] to ensure correct appearance. </description> </method> </methods> @@ -229,6 +230,7 @@ </member> <member name="metallic" type="float" setter="set_metallic" getter="get_metallic" default="0.0"> A high value makes the material appear more like a metal. Non-metals use their albedo as the diffuse color and add diffuse to the specular reflection. With non-metals, the reflection appears on top of the albedo color. Metals use their albedo as a multiplier to the specular reflection and set the diffuse color to black resulting in a tinted reflection. Materials work better when fully metal or fully non-metal, values between [code]0[/code] and [code]1[/code] should only be used for blending between metal and non-metal sections. To alter the amount of reflection use [member roughness]. + [b]Note:[/b] [member metallic] is automatically set to [code]1.0[/code] when assigning a metallic texture using [method set_texture]. </member> <member name="metallic_specular" type="float" setter="set_specular" getter="get_specular" default="0.5"> Sets the size of the specular lobe. The specular lobe is the bright spot that is reflected from light sources. @@ -301,6 +303,7 @@ </member> <member name="roughness" type="float" setter="set_roughness" getter="get_roughness" default="1.0"> Surface reflection. A value of [code]0[/code] represents a perfect mirror while a value of [code]1[/code] completely blurs the reflection. See also [member metallic]. + [b]Note:[/b] [member roughness] is automatically set to [code]1.0[/code] when assigning a roughness texture using [method set_texture]. </member> <member name="roughness_texture" type="Texture2D" setter="set_texture" getter="get_texture"> Texture used to control the roughness per-pixel. Multiplied by [member roughness]. diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index 055d5091c7..3145756511 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -105,15 +105,6 @@ </constant> </constants> <theme_items> - <theme_item name="disabled" data_type="style" type="StyleBox"> - [StyleBox] used when the [Button] is disabled. - </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the [Button]'s text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [Button]. </theme_item> @@ -135,15 +126,6 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [Button] is being pressed. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the [Button]'s text. - </theme_item> - <theme_item name="hover" data_type="style" type="StyleBox"> - [StyleBox] used when the [Button] is being hovered. - </theme_item> - <theme_item name="hseparation" data_type="constant" type="int" default="2"> - The horizontal space between [Button]'s icon and text. - </theme_item> <theme_item name="icon_disabled_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Icon modulate [Color] used when the [Button] is disabled. </theme_item> @@ -162,12 +144,30 @@ <theme_item name="icon_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Icon modulate [Color] used when the [Button] is being pressed. </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - Default [StyleBox] for the [Button]. + <theme_item name="hseparation" data_type="constant" type="int" default="2"> + The horizontal space between [Button]'s icon and text. </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the [Button]'s text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the [Button]'s text. + </theme_item> + <theme_item name="disabled" data_type="style" type="StyleBox"> + [StyleBox] used when the [Button] is disabled. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [Button] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. + </theme_item> + <theme_item name="hover" data_type="style" type="StyleBox"> + [StyleBox] used when the [Button] is being hovered. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + Default [StyleBox] for the [Button]. + </theme_item> <theme_item name="pressed" data_type="style" type="StyleBox"> [StyleBox] used when the [Button] is being pressed. </theme_item> diff --git a/doc/classes/ButtonGroup.xml b/doc/classes/ButtonGroup.xml index 9229e69fa7..e3e781ac10 100644 --- a/doc/classes/ButtonGroup.xml +++ b/doc/classes/ButtonGroup.xml @@ -24,7 +24,7 @@ </method> </methods> <members> - <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> + <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="true" /> </members> <signals> <signal name="pressed"> diff --git a/doc/classes/Camera3D.xml b/doc/classes/Camera3D.xml index 06e2f83f05..772396befe 100644 --- a/doc/classes/Camera3D.xml +++ b/doc/classes/Camera3D.xml @@ -218,10 +218,10 @@ Disables [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] simulation (default). </constant> <constant name="DOPPLER_TRACKING_IDLE_STEP" value="1" enum="DopplerTracking"> - Simulate [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] by tracking positions of objects that are changed in [code]_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how Audio is perceived (changing the Audio's [code]pitch shift[/code]). + Simulate [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] by tracking positions of objects that are changed in [code]_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how audio is perceived (changing the audio's [member AudioStreamPlayer3D.pitch_scale]). </constant> <constant name="DOPPLER_TRACKING_PHYSICS_STEP" value="2" enum="DopplerTracking"> - Simulate [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] by tracking positions of objects that are changed in [code]_physics_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how Audio is perceived (changing the Audio's [code]pitch shift[/code]). + Simulate [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] by tracking positions of objects that are changed in [code]_physics_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how audio is perceived (changing the audio's [member AudioStreamPlayer3D.pitch_scale]). </constant> </constants> </class> diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml index 18f668a052..7dddacf3c9 100644 --- a/doc/classes/CheckBox.xml +++ b/doc/classes/CheckBox.xml @@ -10,28 +10,10 @@ <tutorials> </tutorials> <members> - <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" /> - <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + <member name="align" type="int" setter="set_text_align" getter="get_text_align" overrides="Button" enum="Button.TextAlign" default="0" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" /> </members> <theme_items> - <theme_item name="check_vadjust" data_type="constant" type="int" default="0"> - The vertical offset used when rendering the check icons (in pixels). - </theme_item> - <theme_item name="checked" data_type="icon" type="Texture2D"> - The check icon to display when the [CheckBox] is checked. - </theme_item> - <theme_item name="checked_disabled" data_type="icon" type="Texture2D"> - The check icon to display when the [CheckBox] is checked and disabled. - </theme_item> - <theme_item name="disabled" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckBox] is disabled. - </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckBox] is focused. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - The [Font] to use for the [CheckBox] text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> The [CheckBox] text's font color. </theme_item> @@ -53,26 +35,26 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> The [CheckBox] text's font color when it's pressed. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the [CheckBox]'s text. - </theme_item> - <theme_item name="hover" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckBox] is hovered. - </theme_item> - <theme_item name="hover_pressed" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckBox] is hovered and pressed. + <theme_item name="check_vadjust" data_type="constant" type="int" default="0"> + The vertical offset used when rendering the check icons (in pixels). </theme_item> <theme_item name="hseparation" data_type="constant" type="int" default="4"> The separation between the check icon and the text (in pixels). </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background. - </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> - <theme_item name="pressed" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckBox] is pressed. + <theme_item name="font" data_type="font" type="Font"> + The [Font] to use for the [CheckBox] text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the [CheckBox]'s text. + </theme_item> + <theme_item name="checked" data_type="icon" type="Texture2D"> + The check icon to display when the [CheckBox] is checked. + </theme_item> + <theme_item name="checked_disabled" data_type="icon" type="Texture2D"> + The check icon to display when the [CheckBox] is checked and disabled. </theme_item> <theme_item name="radio_checked" data_type="icon" type="Texture2D"> If the [CheckBox] is configured as a radio button, the icon to display when the [CheckBox] is checked. @@ -90,5 +72,23 @@ <theme_item name="unchecked_disabled" data_type="icon" type="Texture2D"> The check icon to display when the [CheckBox] is unchecked and disabled. </theme_item> + <theme_item name="disabled" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckBox] is disabled. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckBox] is focused. + </theme_item> + <theme_item name="hover" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckBox] is hovered. + </theme_item> + <theme_item name="hover_pressed" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckBox] is hovered and pressed. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background. + </theme_item> + <theme_item name="pressed" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckBox] is pressed. + </theme_item> </theme_items> </class> diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml index c86fadb6b0..c0315b93be 100644 --- a/doc/classes/CheckButton.xml +++ b/doc/classes/CheckButton.xml @@ -10,22 +10,10 @@ <tutorials> </tutorials> <members> - <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" /> - <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + <member name="align" type="int" setter="set_text_align" getter="get_text_align" overrides="Button" enum="Button.TextAlign" default="0" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" /> </members> <theme_items> - <theme_item name="check_vadjust" data_type="constant" type="int" default="0"> - The vertical offset used when rendering the toggle icons (in pixels). - </theme_item> - <theme_item name="disabled" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckButton] is disabled. - </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckButton] is focused. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - The [Font] to use for the [CheckButton] text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> The [CheckButton] text's font color. </theme_item> @@ -47,20 +35,20 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> The [CheckButton] text's font color when it's pressed. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the [CheckButton]'s text. - </theme_item> - <theme_item name="hover" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckButton] is hovered. - </theme_item> - <theme_item name="hover_pressed" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background when the [CheckButton] is hovered and pressed. + <theme_item name="check_vadjust" data_type="constant" type="int" default="0"> + The vertical offset used when rendering the toggle icons (in pixels). </theme_item> <theme_item name="hseparation" data_type="constant" type="int" default="4"> The separation between the toggle icon and the text (in pixels). </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - The [StyleBox] to display as a background. + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + The [Font] to use for the [CheckButton] text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the [CheckButton]'s text. </theme_item> <theme_item name="off" data_type="icon" type="Texture2D"> The icon to display when the [CheckButton] is unchecked (for left-to-right layouts). @@ -86,8 +74,20 @@ <theme_item name="on_mirrored" data_type="icon" type="Texture2D"> The icon to display when the [CheckButton] is checked (for right-to-left layouts). </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the text outline. + <theme_item name="disabled" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckButton] is disabled. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckButton] is focused. + </theme_item> + <theme_item name="hover" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckButton] is hovered. + </theme_item> + <theme_item name="hover_pressed" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background when the [CheckButton] is hovered and pressed. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + The [StyleBox] to display as a background. </theme_item> <theme_item name="pressed" data_type="style" type="StyleBox"> The [StyleBox] to display as a background when the [CheckButton] is pressed. diff --git a/doc/classes/CodeEdit.xml b/doc/classes/CodeEdit.xml index bb1a4a79f0..04c3d73357 100644 --- a/doc/classes/CodeEdit.xml +++ b/doc/classes/CodeEdit.xml @@ -487,7 +487,7 @@ <member name="indent_use_spaces" type="bool" setter="set_indent_using_spaces" getter="is_indent_using_spaces" default="false"> Use spaces instead of tabs for indentation. </member> - <member name="layout_direction" type="int" setter="set_layout_direction" getter="get_layout_direction" override="true" enum="Control.LayoutDirection" default="2" /> + <member name="layout_direction" type="int" setter="set_layout_direction" getter="get_layout_direction" overrides="Control" enum="Control.LayoutDirection" default="2" /> <member name="line_folding" type="bool" setter="set_line_folding_enabled" getter="is_line_folding_enabled" default="false"> Sets whether line folding is allowed. </member> @@ -497,7 +497,7 @@ <member name="symbol_lookup_on_click" type="bool" setter="set_symbol_lookup_on_click_enabled" getter="is_symbol_lookup_on_click_enabled" default="false"> Set when a validated word from [signal symbol_validate] is clicked, the [signal symbol_lookup] should be emitted. </member> - <member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" override="true" enum="Control.TextDirection" default="1" /> + <member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" overrides="TextEdit" enum="Control.TextDirection" default="1" /> </members> <signals> <signal name="breakpoint_toggled"> @@ -562,24 +562,15 @@ <theme_item name="background_color" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> Sets the background [Color]. </theme_item> - <theme_item name="bookmark" data_type="icon" type="Texture2D"> - Sets a custom [Texture2D] to draw in the bookmark gutter for bookmarked lines. - </theme_item> <theme_item name="bookmark_color" data_type="color" type="Color" default="Color(0.5, 0.64, 1, 0.8)"> [Color] of the bookmark icon for bookmarked lines. </theme_item> <theme_item name="brace_mismatch_color" data_type="color" type="Color" default="Color(1, 0.2, 0.2, 1)"> [Color] of the text to highlight mismatched braces. </theme_item> - <theme_item name="breakpoint" data_type="icon" type="Texture2D"> - Sets a custom [Texture2D] to draw in the breakpoint gutter for breakpointed lines. - </theme_item> <theme_item name="breakpoint_color" data_type="color" type="Color" default="Color(0.9, 0.29, 0.3, 1)"> [Color] of the breakpoint icon for bookmarked lines. </theme_item> - <theme_item name="can_fold" data_type="icon" type="Texture2D"> - Sets a custom [Texture2D] to draw in the line folding gutter when a line can be folded. - </theme_item> <theme_item name="caret_background_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> [Color] of the text behind the caret when block caret is enabled. </theme_item> @@ -589,9 +580,6 @@ <theme_item name="code_folding_color" data_type="color" type="Color" default="Color(0.8, 0.8, 0.8, 0.8)"> [Color] for all icons related to line folding. </theme_item> - <theme_item name="completion" data_type="style" type="StyleBox"> - [StyleBox] for the code completion popup. - </theme_item> <theme_item name="completion_background_color" data_type="color" type="Color" default="Color(0.17, 0.16, 0.2, 1)"> Sets the background [Color] for the code completion popup. </theme_item> @@ -601,42 +589,18 @@ <theme_item name="completion_font_color" data_type="color" type="Color" default="Color(0.67, 0.67, 0.67, 1)"> Font [Color] for the code completion popup. </theme_item> - <theme_item name="completion_lines" data_type="constant" type="int" default="7"> - Max number of options to display in the code completion popup at any one time. - </theme_item> - <theme_item name="completion_max_width" data_type="constant" type="int" default="50"> - Max width of options in the code completion popup. Options longer then this will be cut off. - </theme_item> <theme_item name="completion_scroll_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> [Color] of the scrollbar in the code completion popup. </theme_item> - <theme_item name="completion_scroll_width" data_type="constant" type="int" default="3"> - Width of the scrollbar in the code completion popup. - </theme_item> <theme_item name="completion_selected_color" data_type="color" type="Color" default="Color(0.26, 0.26, 0.27, 1)"> Background highlight [Color] for the current selected option item in the code completion popup. </theme_item> <theme_item name="current_line_color" data_type="color" type="Color" default="Color(0.25, 0.25, 0.26, 0.8)"> Background [Color] of the line containing the caret. </theme_item> - <theme_item name="executing_line" data_type="icon" type="Texture2D"> - Icon to draw in the executing gutter for executing lines. - </theme_item> <theme_item name="executing_line_color" data_type="color" type="Color" default="Color(0.98, 0.89, 0.27, 1)"> [Color] of the executing icon for executing lines. </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - Sets the [StyleBox] when in focus. - </theme_item> - <theme_item name="folded" data_type="icon" type="Texture2D"> - Sets a custom [Texture2D] to draw in the line folding gutter when a line is folded and can be unfolded. - </theme_item> - <theme_item name="folded_eol_icon" data_type="icon" type="Texture2D"> - Sets a custom [Texture2D] to draw at the end of a folded line. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - Sets the default [Font]. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Sets the font [Color]. </theme_item> @@ -649,35 +613,62 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> Sets the [Color] of the selected text. [member TextEdit.override_selected_font_color] has to be enabled. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Sets default font size. - </theme_item> <theme_item name="line_length_guideline_color" data_type="color" type="Color" default="Color(0.3, 0.5, 0.8, 0.1)"> [Color] of the main line length guideline, secondary guidelines will have 50% alpha applied. </theme_item> <theme_item name="line_number_color" data_type="color" type="Color" default="Color(0.67, 0.67, 0.67, 0.4)"> Sets the [Color] of line numbers. </theme_item> + <theme_item name="search_result_border_color" data_type="color" type="Color" default="Color(0.3, 0.3, 0.3, 0.4)"> + [Color] of the border around text that matches the search query. + </theme_item> + <theme_item name="search_result_color" data_type="color" type="Color" default="Color(0.3, 0.3, 0.3, 1)"> + [Color] behind the text that matches the search query. + </theme_item> + <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> + Sets the highlight [Color] of text selections. + </theme_item> + <theme_item name="word_highlighted_color" data_type="color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)"> + Sets the highlight [Color] of multiple occurrences. [member TextEdit.highlight_all_occurrences] has to be enabled. + </theme_item> + <theme_item name="completion_lines" data_type="constant" type="int" default="7"> + Max number of options to display in the code completion popup at any one time. + </theme_item> + <theme_item name="completion_max_width" data_type="constant" type="int" default="50"> + Max width of options in the code completion popup. Options longer then this will be cut off. + </theme_item> + <theme_item name="completion_scroll_width" data_type="constant" type="int" default="3"> + Width of the scrollbar in the code completion popup. + </theme_item> <theme_item name="line_spacing" data_type="constant" type="int" default="4"> Sets the spacing between the lines. </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - Sets the [StyleBox]. - </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> - <theme_item name="read_only" data_type="style" type="StyleBox"> - Sets the [StyleBox] when [member TextEdit.editable] is disabled. + <theme_item name="font" data_type="font" type="Font"> + Sets the default [Font]. </theme_item> - <theme_item name="search_result_border_color" data_type="color" type="Color" default="Color(0.3, 0.3, 0.3, 0.4)"> - [Color] of the border around text that matches the search query. + <theme_item name="font_size" data_type="font_size" type="int"> + Sets default font size. </theme_item> - <theme_item name="search_result_color" data_type="color" type="Color" default="Color(0.3, 0.3, 0.3, 1)"> - [Color] behind the text that matches the search query. + <theme_item name="bookmark" data_type="icon" type="Texture2D"> + Sets a custom [Texture2D] to draw in the bookmark gutter for bookmarked lines. </theme_item> - <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> - Sets the highlight [Color] of text selections. + <theme_item name="breakpoint" data_type="icon" type="Texture2D"> + Sets a custom [Texture2D] to draw in the breakpoint gutter for breakpointed lines. + </theme_item> + <theme_item name="can_fold" data_type="icon" type="Texture2D"> + Sets a custom [Texture2D] to draw in the line folding gutter when a line can be folded. + </theme_item> + <theme_item name="executing_line" data_type="icon" type="Texture2D"> + Icon to draw in the executing gutter for executing lines. + </theme_item> + <theme_item name="folded" data_type="icon" type="Texture2D"> + Sets a custom [Texture2D] to draw in the line folding gutter when a line is folded and can be unfolded. + </theme_item> + <theme_item name="folded_eol_icon" data_type="icon" type="Texture2D"> + Sets a custom [Texture2D] to draw at the end of a folded line. </theme_item> <theme_item name="space" data_type="icon" type="Texture2D"> Sets a custom [Texture2D] for space text characters. @@ -685,8 +676,17 @@ <theme_item name="tab" data_type="icon" type="Texture2D"> Sets a custom [Texture2D] for tab text characters. </theme_item> - <theme_item name="word_highlighted_color" data_type="color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)"> - Sets the highlight [Color] of multiple occurrences. [member TextEdit.highlight_all_occurrences] has to be enabled. + <theme_item name="completion" data_type="style" type="StyleBox"> + [StyleBox] for the code completion popup. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + Sets the [StyleBox] when in focus. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + Sets the [StyleBox]. + </theme_item> + <theme_item name="read_only" data_type="style" type="StyleBox"> + Sets the [StyleBox] when [member TextEdit.editable] is disabled. </theme_item> </theme_items> </class> diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index fca6a7631a..22439f6ca5 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -93,6 +93,20 @@ </constant> </constants> <theme_items> + <theme_item name="h_width" data_type="constant" type="int" default="30"> + The width of the hue selection slider. + </theme_item> + <theme_item name="label_width" data_type="constant" type="int" default="10"> + </theme_item> + <theme_item name="margin" data_type="constant" type="int" default="4"> + The margin around the [ColorPicker]. + </theme_item> + <theme_item name="sv_height" data_type="constant" type="int" default="256"> + The height of the saturation-value selection box. + </theme_item> + <theme_item name="sv_width" data_type="constant" type="int" default="256"> + The width of the saturation-value selection box. + </theme_item> <theme_item name="add_preset" data_type="icon" type="Texture2D"> The icon for the "Add Preset" button. </theme_item> @@ -104,14 +118,6 @@ </theme_item> <theme_item name="color_sample" data_type="icon" type="Texture2D"> </theme_item> - <theme_item name="h_width" data_type="constant" type="int" default="30"> - The width of the hue selection slider. - </theme_item> - <theme_item name="label_width" data_type="constant" type="int" default="10"> - </theme_item> - <theme_item name="margin" data_type="constant" type="int" default="4"> - The margin around the [ColorPicker]. - </theme_item> <theme_item name="overbright_indicator" data_type="icon" type="Texture2D"> The indicator used to signalize that the color value is outside the 0-1 range. </theme_item> @@ -122,11 +128,5 @@ <theme_item name="screen_picker" data_type="icon" type="Texture2D"> The icon for the screen color picker button. </theme_item> - <theme_item name="sv_height" data_type="constant" type="int" default="256"> - The height of the saturation-value selection box. - </theme_item> - <theme_item name="sv_width" data_type="constant" type="int" default="256"> - The width of the saturation-value selection box. - </theme_item> </theme_items> </class> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index fff27d2d56..2f78b10660 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -35,7 +35,7 @@ <member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha" default="true"> If [code]true[/code], the alpha channel in the displayed [ColorPicker] will be visible. </member> - <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" /> </members> <signals> <signal name="color_changed"> @@ -56,18 +56,6 @@ </signal> </signals> <theme_items> - <theme_item name="bg" data_type="icon" type="Texture2D"> - The background of the color preview rect on the button. - </theme_item> - <theme_item name="disabled" data_type="style" type="StyleBox"> - [StyleBox] used when the [ColorPickerButton] is disabled. - </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [ColorPickerButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the [ColorPickerButton]'s text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Default text [Color] of the [ColorPickerButton]. </theme_item> @@ -86,21 +74,33 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(0.8, 0.8, 0.8, 1)"> Text [Color] used when the [ColorPickerButton] is being pressed. </theme_item> + <theme_item name="hseparation" data_type="constant" type="int" default="2"> + The horizontal space between [ColorPickerButton]'s icon and text. + </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the [ColorPickerButton]'s text. + </theme_item> <theme_item name="font_size" data_type="font_size" type="int"> Font size of the [ColorPickerButton]'s text. </theme_item> + <theme_item name="bg" data_type="icon" type="Texture2D"> + The background of the color preview rect on the button. + </theme_item> + <theme_item name="disabled" data_type="style" type="StyleBox"> + [StyleBox] used when the [ColorPickerButton] is disabled. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [ColorPickerButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. + </theme_item> <theme_item name="hover" data_type="style" type="StyleBox"> [StyleBox] used when the [ColorPickerButton] is being hovered. </theme_item> - <theme_item name="hseparation" data_type="constant" type="int" default="2"> - The horizontal space between [ColorPickerButton]'s icon and text. - </theme_item> <theme_item name="normal" data_type="style" type="StyleBox"> Default [StyleBox] for the [ColorPickerButton]. </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the text outline. - </theme_item> <theme_item name="pressed" data_type="style" type="StyleBox"> [StyleBox] used when the [ColorPickerButton] is being pressed. </theme_item> diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index c4bdaf436d..bf4210ac98 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -27,8 +27,8 @@ </method> </methods> <members> - <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..."" /> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" overrides="Window" default="Vector2i(200, 70)" /> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" overrides="Window" default="Vector2i(200, 100)" /> + <member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default=""Please Confirm..."" /> </members> </class> diff --git a/doc/classes/Container.xml b/doc/classes/Container.xml index 24e73534d3..83655425fc 100644 --- a/doc/classes/Container.xml +++ b/doc/classes/Container.xml @@ -26,7 +26,7 @@ </method> </methods> <members> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="1" /> </members> <signals> <signal name="pre_sort_children"> diff --git a/doc/classes/DirectionalLight3D.xml b/doc/classes/DirectionalLight3D.xml index 661dbef07c..74450c311e 100644 --- a/doc/classes/DirectionalLight3D.xml +++ b/doc/classes/DirectionalLight3D.xml @@ -34,7 +34,7 @@ <member name="directional_shadow_split_3" type="float" setter="set_param" getter="get_param" default="0.5"> The distance from shadow split 2 to split 3. Relative to [member directional_shadow_max_distance]. Only used when [member directional_shadow_mode] is [constant SHADOW_PARALLEL_4_SPLITS]. </member> - <member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.1" /> + <member name="shadow_bias" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="0.1" /> <member name="use_in_sky_only" type="bool" setter="set_sky_only" getter="is_sky_only" default="false"> If [code]true[/code], this [DirectionalLight3D] will not be used for anything except sky shaders. Use this for lights that impact your sky shader that you may want to hide from affecting the rest of the scene. For example, you may want to enable this when the sun in your sky shader falls below the horizon. </member> diff --git a/doc/classes/EditorCommandPalette.xml b/doc/classes/EditorCommandPalette.xml index 01b8593f89..28f51228ca 100644 --- a/doc/classes/EditorCommandPalette.xml +++ b/doc/classes/EditorCommandPalette.xml @@ -49,6 +49,6 @@ </method> </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="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" /> </members> </class> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index 79758281ac..1d2146348a 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -49,7 +49,7 @@ <member name="current_path" type="String" setter="set_current_path" getter="get_current_path" default=""res://""> The file system path in the address bar. </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="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" /> <member name="disable_overwrite_warning" type="bool" setter="set_disable_overwrite_warning" getter="is_overwrite_warning_disabled" default="false"> If [code]true[/code], the [EditorFileDialog] will not warn the user before overwriting files. </member> @@ -62,7 +62,7 @@ <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="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" overrides="Window" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> diff --git a/doc/classes/EditorInspector.xml b/doc/classes/EditorInspector.xml index 0c47298180..46cebbd795 100644 --- a/doc/classes/EditorInspector.xml +++ b/doc/classes/EditorInspector.xml @@ -10,7 +10,7 @@ <tutorials> </tutorials> <members> - <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" override="true" default="false" /> + <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" overrides="ScrollContainer" default="false" /> </members> <signals> <signal name="object_id_selected"> diff --git a/doc/classes/EditorNode3DGizmo.xml b/doc/classes/EditorNode3DGizmo.xml index c804bb70e0..60c329935a 100644 --- a/doc/classes/EditorNode3DGizmo.xml +++ b/doc/classes/EditorNode3DGizmo.xml @@ -135,7 +135,7 @@ </method> <method name="add_mesh"> <return type="void" /> - <argument index="0" name="mesh" type="ArrayMesh" /> + <argument index="0" name="mesh" type="Mesh" /> <argument index="1" name="material" type="Material" default="null" /> <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)" /> <argument index="3" name="skeleton" type="SkinReference" default="null" /> diff --git a/doc/classes/EditorSpinSlider.xml b/doc/classes/EditorSpinSlider.xml index 9341b514c7..9636c33565 100644 --- a/doc/classes/EditorSpinSlider.xml +++ b/doc/classes/EditorSpinSlider.xml @@ -11,7 +11,7 @@ <members> <member name="flat" type="bool" setter="set_flat" getter="is_flat" default="false"> </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="label" type="String" setter="set_label" getter="get_label" default=""""> </member> <member name="read_only" type="bool" setter="set_read_only" getter="is_read_only" default="false"> diff --git a/doc/classes/File.xml b/doc/classes/File.xml index 276c1f0223..0dac9a379a 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -417,6 +417,7 @@ <argument index="0" name="string" type="String" /> <description> Appends [code]string[/code] to the file without a line return, encoding the text as UTF-8. + [b]Note:[/b] This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using [method store_pascal_string] instead. For retrieving strings from a text file, you can use [code]get_buffer(length).get_string_from_utf8()[/code] (if you know the length) or [method get_as_text]. </description> </method> <method name="store_var"> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index fa43f97104..1207288159 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -63,7 +63,7 @@ <member name="current_path" type="String" setter="set_current_path" getter="get_current_path" default=""res://""> 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="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" 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> @@ -76,7 +76,7 @@ <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="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" overrides="Window" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> @@ -125,24 +125,24 @@ </constant> </constants> <theme_items> - <theme_item name="back_folder" data_type="icon" type="Texture2D"> - Custom icon for the back arrow. - </theme_item> - <theme_item name="file" data_type="icon" type="Texture2D"> - Custom icon for files. - </theme_item> <theme_item name="file_icon_modulate" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> The color modulation applied to the file icon. </theme_item> <theme_item name="files_disabled" data_type="color" type="Color" default="Color(0, 0, 0, 0.7)"> The color tint for disabled files (when the [FileDialog] is used in open folder mode). </theme_item> - <theme_item name="folder" data_type="icon" type="Texture2D"> - Custom icon for folders. - </theme_item> <theme_item name="folder_icon_modulate" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> The color modulation applied to the folder icon. </theme_item> + <theme_item name="back_folder" data_type="icon" type="Texture2D"> + Custom icon for the back arrow. + </theme_item> + <theme_item name="file" data_type="icon" type="Texture2D"> + Custom icon for files. + </theme_item> + <theme_item name="folder" data_type="icon" type="Texture2D"> + Custom icon for folders. + </theme_item> <theme_item name="forward_folder" data_type="icon" type="Texture2D"> Custom icon for the forward arrow. </theme_item> diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index e962992491..76b255e273 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -159,7 +159,7 @@ <member name="connection_lines_thickness" type="float" setter="set_connection_lines_thickness" getter="get_connection_lines_thickness" default="2.0"> The thickness of the lines between the nodes. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="minimap_enabled" type="bool" setter="set_minimap_enabled" getter="is_minimap_enabled" default="true"> If [code]true[/code], the minimap is visible. </member> @@ -169,7 +169,7 @@ <member name="minimap_size" type="Vector2" setter="set_minimap_size" getter="get_minimap_size" default="Vector2(240, 160)"> The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle. </member> - <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" /> <member name="right_disconnects" type="bool" setter="set_right_disconnects" getter="is_right_disconnects_enabled" default="false"> If [code]true[/code], enables disconnection of existing connections in the GraphEdit by dragging the right end. </member> @@ -290,28 +290,21 @@ <theme_items> <theme_item name="activity" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> </theme_item> - <theme_item name="bezier_len_neg" data_type="constant" type="int" default="160"> - </theme_item> - <theme_item name="bezier_len_pos" data_type="constant" type="int" default="80"> - </theme_item> - <theme_item name="bg" data_type="style" type="StyleBox"> - The background drawn under the grid. - </theme_item> <theme_item name="grid_major" data_type="color" type="Color" default="Color(1, 1, 1, 0.2)"> Color of major grid lines. </theme_item> <theme_item name="grid_minor" data_type="color" type="Color" default="Color(1, 1, 1, 0.05)"> Color of minor grid lines. </theme_item> - <theme_item name="layout" data_type="icon" type="Texture2D"> + <theme_item name="selection_fill" data_type="color" type="Color" default="Color(1, 1, 1, 0.3)"> + The fill color of the selection rectangle. </theme_item> - <theme_item name="minimap" data_type="icon" type="Texture2D"> + <theme_item name="selection_stroke" data_type="color" type="Color" default="Color(1, 1, 1, 0.8)"> + The outline color of the selection rectangle. </theme_item> - <theme_item name="minus" data_type="icon" type="Texture2D"> - The icon for the zoom out button. + <theme_item name="bezier_len_neg" data_type="constant" type="int" default="160"> </theme_item> - <theme_item name="more" data_type="icon" type="Texture2D"> - The icon for the zoom in button. + <theme_item name="bezier_len_pos" data_type="constant" type="int" default="80"> </theme_item> <theme_item name="port_grab_distance_horizontal" data_type="constant" type="int" default="24"> The horizontal range within which a port can be grabbed (on both sides). @@ -319,17 +312,24 @@ <theme_item name="port_grab_distance_vertical" data_type="constant" type="int" default="6"> The vertical range within which a port can be grabbed (on both sides). </theme_item> - <theme_item name="reset" data_type="icon" type="Texture2D"> - The icon for the zoom reset button. + <theme_item name="layout" data_type="icon" type="Texture2D"> </theme_item> - <theme_item name="selection_fill" data_type="color" type="Color" default="Color(1, 1, 1, 0.3)"> - The fill color of the selection rectangle. + <theme_item name="minimap" data_type="icon" type="Texture2D"> </theme_item> - <theme_item name="selection_stroke" data_type="color" type="Color" default="Color(1, 1, 1, 0.8)"> - The outline color of the selection rectangle. + <theme_item name="minus" data_type="icon" type="Texture2D"> + The icon for the zoom out button. + </theme_item> + <theme_item name="more" data_type="icon" type="Texture2D"> + The icon for the zoom in button. + </theme_item> + <theme_item name="reset" data_type="icon" type="Texture2D"> + The icon for the zoom reset button. </theme_item> <theme_item name="snap" data_type="icon" type="Texture2D"> The icon for the snap toggle button. </theme_item> + <theme_item name="bg" data_type="style" type="StyleBox"> + The background drawn under the grid. + </theme_item> </theme_items> </class> diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index e9226f7c1d..d5780dce2d 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -218,7 +218,7 @@ <member name="language" type="String" setter="set_language" getter="get_language" default=""""> Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </member> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="0" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="0" /> <member name="overlay" type="int" setter="set_overlay" getter="get_overlay" enum="GraphNode.Overlay" default="0"> Sets the overlay shown above the GraphNode. See [enum Overlay]. </member> @@ -292,18 +292,42 @@ </constant> </constants> <theme_items> - <theme_item name="breakpoint" data_type="style" type="StyleBox"> - The background used when [member overlay] is set to [constant OVERLAY_BREAKPOINT]. - </theme_item> - <theme_item name="close" data_type="icon" type="Texture2D"> - The icon for the close button, visible when [member show_close] is enabled. - </theme_item> <theme_item name="close_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> The color modulation applied to the close button icon. </theme_item> + <theme_item name="resizer_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> + The color modulation applied to the resizer icon. + </theme_item> + <theme_item name="title_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> + Color of the title text. + </theme_item> <theme_item name="close_offset" data_type="constant" type="int" default="18"> The vertical offset of the close button. </theme_item> + <theme_item name="port_offset" data_type="constant" type="int" default="3"> + Horizontal offset for the ports. + </theme_item> + <theme_item name="separation" data_type="constant" type="int" default="1"> + The vertical distance between ports. + </theme_item> + <theme_item name="title_offset" data_type="constant" type="int" default="20"> + Vertical offset of the title text. + </theme_item> + <theme_item name="title_font" data_type="font" type="Font"> + Font used for the title text. + </theme_item> + <theme_item name="close" data_type="icon" type="Texture2D"> + The icon for the close button, visible when [member show_close] is enabled. + </theme_item> + <theme_item name="port" data_type="icon" type="Texture2D"> + The icon used for representing ports. + </theme_item> + <theme_item name="resizer" data_type="icon" type="Texture2D"> + The icon used for resizer, visible when [member resizable] is enabled. + </theme_item> + <theme_item name="breakpoint" data_type="style" type="StyleBox"> + The background used when [member overlay] is set to [constant OVERLAY_BREAKPOINT]. + </theme_item> <theme_item name="comment" data_type="style" type="StyleBox"> The [StyleBox] used when [member comment] is enabled. </theme_item> @@ -317,35 +341,11 @@ <theme_item name="frame" data_type="style" type="StyleBox"> The default background for [GraphNode]. </theme_item> - <theme_item name="port" data_type="icon" type="Texture2D"> - The icon used for representing ports. - </theme_item> - <theme_item name="port_offset" data_type="constant" type="int" default="3"> - Horizontal offset for the ports. - </theme_item> <theme_item name="position" data_type="style" type="StyleBox"> The background used when [member overlay] is set to [constant OVERLAY_POSITION]. </theme_item> - <theme_item name="resizer" data_type="icon" type="Texture2D"> - The icon used for resizer, visible when [member resizable] is enabled. - </theme_item> - <theme_item name="resizer_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> - The color modulation applied to the resizer icon. - </theme_item> <theme_item name="selectedframe" data_type="style" type="StyleBox"> The background used when the [GraphNode] is selected. </theme_item> - <theme_item name="separation" data_type="constant" type="int" default="1"> - The vertical distance between ports. - </theme_item> - <theme_item name="title_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> - Color of the title text. - </theme_item> - <theme_item name="title_font" data_type="font" type="Font"> - Font used for the title text. - </theme_item> - <theme_item name="title_offset" data_type="constant" type="int" default="20"> - Vertical offset of the title text. - </theme_item> </theme_items> </class> diff --git a/doc/classes/HScrollBar.xml b/doc/classes/HScrollBar.xml index fa9961710f..3197abcc3f 100644 --- a/doc/classes/HScrollBar.xml +++ b/doc/classes/HScrollBar.xml @@ -18,15 +18,6 @@ <theme_item name="decrement_pressed" data_type="icon" type="Texture2D"> Displayed when the decrement button is being pressed. </theme_item> - <theme_item name="grabber" data_type="style" type="StyleBox"> - Used as texture for the grabber, the draggable element representing current scroll. - </theme_item> - <theme_item name="grabber_highlight" data_type="style" type="StyleBox"> - Used when the mouse hovers over the grabber. - </theme_item> - <theme_item name="grabber_pressed" data_type="style" type="StyleBox"> - Used when the grabber is being dragged. - </theme_item> <theme_item name="increment" data_type="icon" type="Texture2D"> Icon used as a button to scroll the [ScrollBar] right. Supports custom step using the [member ScrollBar.custom_step] property. </theme_item> @@ -36,6 +27,15 @@ <theme_item name="increment_pressed" data_type="icon" type="Texture2D"> Displayed when the increment button is being pressed. </theme_item> + <theme_item name="grabber" data_type="style" type="StyleBox"> + Used as texture for the grabber, the draggable element representing current scroll. + </theme_item> + <theme_item name="grabber_highlight" data_type="style" type="StyleBox"> + Used when the mouse hovers over the grabber. + </theme_item> + <theme_item name="grabber_pressed" data_type="style" type="StyleBox"> + Used when the grabber is being dragged. + </theme_item> <theme_item name="scroll" data_type="style" type="StyleBox"> Used as background of this [ScrollBar]. </theme_item> diff --git a/doc/classes/HSlider.xml b/doc/classes/HSlider.xml index fa88085a70..1b83731a32 100644 --- a/doc/classes/HSlider.xml +++ b/doc/classes/HSlider.xml @@ -13,22 +13,22 @@ <theme_item name="grabber" data_type="icon" type="Texture2D"> The texture for the grabber (the draggable element). </theme_item> - <theme_item name="grabber_area" data_type="style" type="StyleBox"> - The background of the area to the left of the grabber. - </theme_item> - <theme_item name="grabber_area_highlight" data_type="style" type="StyleBox"> - </theme_item> <theme_item name="grabber_disabled" data_type="icon" type="Texture2D"> The texture for the grabber when it's disabled. </theme_item> <theme_item name="grabber_highlight" data_type="icon" type="Texture2D"> The texture for the grabber when it's focused. </theme_item> - <theme_item name="slider" data_type="style" type="StyleBox"> - The background for the whole slider. Determines the height of the [code]grabber_area[/code]. - </theme_item> <theme_item name="tick" data_type="icon" type="Texture2D"> The texture for the ticks, visible when [member Slider.tick_count] is greater than 0. </theme_item> + <theme_item name="grabber_area" data_type="style" type="StyleBox"> + The background of the area to the left of the grabber. + </theme_item> + <theme_item name="grabber_area_highlight" data_type="style" type="StyleBox"> + </theme_item> + <theme_item name="slider" data_type="style" type="StyleBox"> + The background for the whole slider. Determines the height of the [code]grabber_area[/code]. + </theme_item> </theme_items> </class> diff --git a/doc/classes/HSplitContainer.xml b/doc/classes/HSplitContainer.xml index 379d4cfbdb..f2c505b1bc 100644 --- a/doc/classes/HSplitContainer.xml +++ b/doc/classes/HSplitContainer.xml @@ -12,13 +12,13 @@ <theme_item name="autohide" data_type="constant" type="int" default="1"> Boolean value. If 1 ([code]true[/code]), the grabber will hide automatically when it isn't under the cursor. If 0 ([code]false[/code]), it's always visible. </theme_item> - <theme_item name="bg" data_type="style" type="StyleBox"> + <theme_item name="separation" data_type="constant" type="int" default="12"> + The space between sides of the container. </theme_item> <theme_item name="grabber" data_type="icon" type="Texture2D"> The icon used for the grabber drawn in the middle area. </theme_item> - <theme_item name="separation" data_type="constant" type="int" default="12"> - The space between sides of the container. + <theme_item name="bg" data_type="style" type="StyleBox"> </theme_item> </theme_items> </class> diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index d2b1b5c004..29feb107d4 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -154,7 +154,15 @@ <return type="void" /> <argument index="0" name="color" type="Color" /> <description> - Fills the image with a given [Color]. + Fills the image with [code]color[/code]. + </description> + </method> + <method name="fill_rect"> + <return type="void" /> + <argument index="0" name="rect" type="Rect2" /> + <argument index="1" name="color" type="Color" /> + <description> + Fills [code]rect[/code] with [code]color[/code]. </description> </method> <method name="fix_alpha_edges"> @@ -278,7 +286,7 @@ <return type="int" enum="Error" /> <argument index="0" name="path" type="String" /> <description> - Loads an image from file [code]path[/code]. See [url=$DOCS_URL/getting_started/workflow/assets/importing_images.html#supported-image-formats]Supported image formats[/url] for a list of supported image formats and limitations. + Loads an image from file [code]path[/code]. See [url=$DOCS_URL/tutorials/assets_pipeline/importing_images.html#supported-image-formats]Supported image formats[/url] for a list of supported image formats and limitations. [b]Warning:[/b] This method should only be used in the editor or in cases when you need to load external images at run-time, such as images located at the [code]user://[/code] directory, and may not work in exported projects. See also [ImageTexture] description for usage examples. </description> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index baa0faaae9..0626df0414 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -374,7 +374,7 @@ The size all icons will be adjusted to. If either X or Y component is not greater than zero, icon size won't be affected. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="icon_mode" type="int" setter="set_icon_mode" getter="get_icon_mode" enum="ItemList.IconMode" default="1"> The icon position, whether above or to the left of the text. See the [enum IconMode] constants. </member> @@ -393,7 +393,7 @@ Maximum lines of text allowed in each item. Space will be reserved even when there is not enough lines of text to display. [b]Note:[/b] This property takes effect only when [member icon_mode] is [constant ICON_MODE_TOP]. To make the text wrap, [member fixed_column_width] should be greater than zero. </member> - <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" /> <member name="same_column_width" type="bool" setter="set_same_column_width" getter="is_same_column_width" default="false"> Whether all columns will have the same width. If [code]true[/code], the width is equal to the largest column width of all columns. @@ -463,21 +463,6 @@ </constant> </constants> <theme_items> - <theme_item name="bg" data_type="style" type="StyleBox"> - Default [StyleBox] for the [ItemList], i.e. used when the control is not being focused. - </theme_item> - <theme_item name="bg_focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [ItemList] is being focused. - </theme_item> - <theme_item name="cursor" data_type="style" type="StyleBox"> - [StyleBox] used for the cursor, when the [ItemList] is being focused. - </theme_item> - <theme_item name="cursor_unfocused" data_type="style" type="StyleBox"> - [StyleBox] used for the cursor, when the [ItemList] is not being focused. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the item's text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.63, 0.63, 0.63, 1)"> Default text [Color] of the item. </theme_item> @@ -487,9 +472,6 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the item is selected. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the item's text. - </theme_item> <theme_item name="guide_color" data_type="color" type="Color" default="Color(0, 0, 0, 0.1)"> [Color] of the guideline. The guideline is a line drawn between each row of items. </theme_item> @@ -505,14 +487,32 @@ <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the item text outline. </theme_item> + <theme_item name="vseparation" data_type="constant" type="int" default="2"> + The vertical spacing between items. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the item's text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the item's text. + </theme_item> + <theme_item name="bg" data_type="style" type="StyleBox"> + Default [StyleBox] for the [ItemList], i.e. used when the control is not being focused. + </theme_item> + <theme_item name="bg_focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [ItemList] is being focused. + </theme_item> + <theme_item name="cursor" data_type="style" type="StyleBox"> + [StyleBox] used for the cursor, when the [ItemList] is being focused. + </theme_item> + <theme_item name="cursor_unfocused" data_type="style" type="StyleBox"> + [StyleBox] used for the cursor, when the [ItemList] is not being focused. + </theme_item> <theme_item name="selected" data_type="style" type="StyleBox"> [StyleBox] for the selected items, used when the [ItemList] is not being focused. </theme_item> <theme_item name="selected_focus" data_type="style" type="StyleBox"> [StyleBox] for the selected items, used when the [ItemList] is being focused. </theme_item> - <theme_item name="vseparation" data_type="constant" type="int" default="2"> - The vertical spacing between items. - </theme_item> </theme_items> </class> diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index 24ebf08c36..bb273bcf48 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -79,11 +79,11 @@ <member name="max_lines_visible" type="int" setter="set_max_lines_visible" getter="get_max_lines_visible" default="-1"> Limits the lines of text the node shows on screen. </member> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="2" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="2" /> <member name="percent_visible" type="float" setter="set_percent_visible" getter="get_percent_visible" default="1.0"> Limits the amount of visible characters. If you set [code]percent_visible[/code] to 0.5, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box. </member> - <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="4" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="4" /> <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> @@ -163,9 +163,6 @@ </constant> </constants> <theme_items> - <theme_item name="font" data_type="font" type="Font"> - [Font] used for the [Label]'s text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Default text [Color] of the [Label]. </theme_item> @@ -175,15 +172,9 @@ <theme_item name="font_shadow_color" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> [Color] of the text's shadow effect. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the [Label]'s text. - </theme_item> <theme_item name="line_spacing" data_type="constant" type="int" default="3"> Vertical space between lines in multiline [Label]. </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - Background [StyleBox] for the [Label]. - </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> Text outline size. </theme_item> @@ -196,5 +187,14 @@ <theme_item name="shadow_outline_size" data_type="constant" type="int" default="1"> The size of the shadow outline. </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] used for the [Label]'s text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the [Label]'s text. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + Background [StyleBox] for the [Label]. + </theme_item> </theme_items> </class> diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml index 4d9abbbb19..5e673cc19b 100644 --- a/doc/classes/Line2D.xml +++ b/doc/classes/Line2D.xml @@ -82,7 +82,7 @@ The smoothness of the rounded joints and caps. This is only used if a cap or joint is set as round. </member> <member name="sharp_limit" type="float" setter="set_sharp_limit" getter="get_sharp_limit" default="2.0"> - The direction difference in radians between vector points. This value is only used if [code]joint mode[/code] is set to [constant LINE_JOINT_SHARP]. + The direction difference in radians between vector points. This value is only used if [member joint_mode] is set to [constant LINE_JOINT_SHARP]. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> The texture used for the line's texture. Uses [code]texture_mode[/code] for drawing style. diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index a75bd2f704..40e1057ed0 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -199,7 +199,7 @@ <member name="flat" type="bool" setter="set_flat" getter="is_flat" default="false"> If [code]true[/code], the [LineEdit] don't display decoration. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="language" type="String" setter="set_language" getter="get_language" default=""""> Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </member> @@ -232,7 +232,7 @@ If [code]false[/code], using middle mouse button to paste clipboard will be disabled. [b]Note:[/b] This method is only implemented on Linux. </member> - <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" override="true" enum="Control.CursorShape" default="1" /> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" overrides="Control" enum="Control.CursorShape" default="1" /> <member name="placeholder_alpha" type="float" setter="set_placeholder_alpha" getter="get_placeholder_alpha" default="0.6"> Opacity of the [member placeholder_text]. From [code]0[/code] to [code]1[/code]. </member> @@ -397,21 +397,12 @@ <theme_item name="caret_color" data_type="color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Color of the [LineEdit]'s caret (text cursor). </theme_item> - <theme_item name="clear" data_type="icon" type="Texture2D"> - Texture for the clear button. See [member clear_button_enabled]. - </theme_item> <theme_item name="clear_button_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Color used as default tint for the clear button. </theme_item> <theme_item name="clear_button_color_pressed" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Color used for the clear button when it's pressed. </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - Background used when [LineEdit] has GUI focus. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - Font used for the text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default font color. </theme_item> @@ -421,26 +412,35 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> Font color for selected text (inside the selection rectangle). </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the [LineEdit]'s text. - </theme_item> <theme_item name="font_uneditable_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)"> Font color when editing is disabled. </theme_item> + <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> + Color of the selection rectangle. + </theme_item> <theme_item name="minimum_character_width" data_type="constant" type="int" default="4"> Minimum horizontal space for the text (not counting the clear button and content margins). This value is measured in count of 'M' characters (i.e. this amount of 'M' characters can be displayed without scrolling). </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - Default background for the [LineEdit]. - </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> + <theme_item name="font" data_type="font" type="Font"> + Font used for the text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the [LineEdit]'s text. + </theme_item> + <theme_item name="clear" data_type="icon" type="Texture2D"> + Texture for the clear button. See [member clear_button_enabled]. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + Background used when [LineEdit] has GUI focus. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + Default background for the [LineEdit]. + </theme_item> <theme_item name="read_only" data_type="style" type="StyleBox"> Background used when [LineEdit] is in read-only mode ([member editable] is set to [code]false[/code]). </theme_item> - <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> - Color of the selection rectangle. - </theme_item> </theme_items> </class> diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index 0329ed833f..17a9e13842 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -33,11 +33,11 @@ </method> </methods> <members> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="0" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="0" /> <member name="language" type="String" setter="set_language" getter="get_language" default=""""> Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead. </member> - <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" override="true" enum="Control.CursorShape" default="2" /> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" overrides="Control" enum="Control.CursorShape" default="2" /> <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> @@ -66,12 +66,6 @@ </constant> </constants> <theme_items> - <theme_item name="focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [LinkButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the [LinkButton]'s text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [LinkButton]. </theme_item> @@ -87,14 +81,20 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [LinkButton] is being pressed. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the [LinkButton]'s text. - </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> <theme_item name="underline_spacing" data_type="constant" type="int" default="2"> The vertical space between the baseline of text and the underline. </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the [LinkButton]'s text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the [LinkButton]'s text. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [LinkButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. + </theme_item> </theme_items> </class> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 7f9d3d96dc..93f514cc63 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -27,16 +27,16 @@ </method> </methods> <members> - <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" /> - <member name="flat" type="bool" setter="set_flat" getter="is_flat" override="true" default="true" /> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="0" /> + <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" overrides="BaseButton" enum="BaseButton.ActionMode" default="0" /> + <member name="flat" type="bool" setter="set_flat" getter="is_flat" overrides="Button" default="true" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="0" /> <member name="items_count" type="int" setter="set_item_count" getter="get_item_count" default="0"> The number of items currently in the list. </member> <member name="switch_on_hover" type="bool" setter="set_switch_on_hover" getter="is_switch_on_hover" default="false"> If [code]true[/code], when the cursor hovers above another [MenuButton] within the same parent which also has [code]switch_on_hover[/code] enabled, it will close the current [MenuButton] and open the other one. </member> - <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" /> </members> <signals> <signal name="about_to_popup"> @@ -46,15 +46,6 @@ </signal> </signals> <theme_items> - <theme_item name="disabled" data_type="style" type="StyleBox"> - [StyleBox] used when the [MenuButton] is disabled. - </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [MenuButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the [MenuButton]'s text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [MenuButton]. </theme_item> @@ -73,21 +64,30 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [MenuButton] is being pressed. </theme_item> + <theme_item name="hseparation" data_type="constant" type="int" default="3"> + The horizontal space between [MenuButton]'s icon and text. + </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the [MenuButton]'s text. + </theme_item> <theme_item name="font_size" data_type="font_size" type="int"> Font size of the [MenuButton]'s text. </theme_item> + <theme_item name="disabled" data_type="style" type="StyleBox"> + [StyleBox] used when the [MenuButton] is disabled. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [MenuButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. + </theme_item> <theme_item name="hover" data_type="style" type="StyleBox"> [StyleBox] used when the [MenuButton] is being hovered. </theme_item> - <theme_item name="hseparation" data_type="constant" type="int" default="3"> - The horizontal space between [MenuButton]'s icon and text. - </theme_item> <theme_item name="normal" data_type="style" type="StyleBox"> Default [StyleBox] for the [MenuButton]. </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the text outline. - </theme_item> <theme_item name="pressed" data_type="style" type="StyleBox"> [StyleBox] used when the [MenuButton] is being pressed. </theme_item> diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml index 636ed368d1..02144d641e 100644 --- a/doc/classes/NinePatchRect.xml +++ b/doc/classes/NinePatchRect.xml @@ -35,7 +35,7 @@ <member name="draw_center" type="bool" setter="set_draw_center" getter="is_draw_center_enabled" default="true"> If [code]true[/code], draw the panel's center. Else, only draw the 9-slice's borders. </member> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="2" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="2" /> <member name="patch_margin_bottom" type="int" setter="set_patch_margin" getter="get_patch_margin" default="0"> The height of the 9-slice's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders. </member> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 8a12314ba8..f1ab5e4843 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -261,7 +261,7 @@ <return type="Node" /> <argument index="0" name="path" type="NodePath" /> <description> - Fetches a node. The [NodePath] can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a [code]null instance[/code] is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error. + Fetches a node. The [NodePath] can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, [code]null[/code] is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error. [b]Note:[/b] Fetching absolute paths only works when the node is inside the scene tree (see [method is_inside_tree]). [b]Example:[/b] Assume your current node is Character and the following tree: [codeblock] @@ -322,7 +322,7 @@ <method name="get_parent" qualifiers="const"> <return type="Node" /> <description> - Returns the parent node of the current node, or a [code]null instance[/code] if the node lacks a parent. + Returns the parent node of the current node, or [code]null[/code] if the node lacks a parent. </description> </method> <method name="get_path" qualifiers="const"> @@ -791,8 +791,8 @@ <constant name="NOTIFICATION_DRAG_END" value="22"> Notification received when a drag ends. </constant> - <constant name="NOTIFICATION_PATH_CHANGED" value="23"> - Notification received when the node's [NodePath] changed. + <constant name="NOTIFICATION_PATH_RENAMED" value="23"> + Notification received when the node's name or one of its parents' name is changed. This notification is [i]not[/i] received when the node is removed from the scene tree to be added to another parent later on. </constant> <constant name="NOTIFICATION_INTERNAL_PROCESS" value="25"> Notification received every frame when the internal process flag is set (see [method set_process_internal]). diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index a3616af999..d914b86a33 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -163,12 +163,12 @@ </method> </methods> <members> - <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" /> - <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" /> + <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" overrides="BaseButton" enum="BaseButton.ActionMode" default="0" /> + <member name="align" type="int" setter="set_text_align" getter="get_text_align" overrides="Button" enum="Button.TextAlign" default="0" /> <member name="selected" type="int" setter="_select_int" getter="get_selected" default="-1"> The index of the currently selected item, or [code]-1[/code] if no item is selected. </member> - <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" overrides="BaseButton" default="true" /> </members> <signals> <signal name="item_focused"> @@ -185,24 +185,6 @@ </signal> </signals> <theme_items> - <theme_item name="arrow" data_type="icon" type="Texture2D"> - The arrow icon to be drawn on the right end of the button. - </theme_item> - <theme_item name="arrow_margin" data_type="constant" type="int" default="2"> - The horizontal space between the arrow icon and the right edge of the button. - </theme_item> - <theme_item name="disabled" data_type="style" type="StyleBox"> - [StyleBox] used when the [OptionButton] is disabled (for left-to-right layouts). - </theme_item> - <theme_item name="disabled_mirrored" data_type="style" type="StyleBox"> - [StyleBox] used when the [OptionButton] is disabled (for right-to-left layouts). - </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [OptionButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the [OptionButton]'s text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [OptionButton]. </theme_item> @@ -221,27 +203,45 @@ <theme_item name="font_pressed_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [OptionButton] is being pressed. </theme_item> + <theme_item name="arrow_margin" data_type="constant" type="int" default="2"> + The horizontal space between the arrow icon and the right edge of the button. + </theme_item> + <theme_item name="hseparation" data_type="constant" type="int" default="2"> + The horizontal space between [OptionButton]'s icon and text. + </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the [OptionButton]'s text. + </theme_item> <theme_item name="font_size" data_type="font_size" type="int"> Font size of the [OptionButton]'s text. </theme_item> + <theme_item name="arrow" data_type="icon" type="Texture2D"> + The arrow icon to be drawn on the right end of the button. + </theme_item> + <theme_item name="disabled" data_type="style" type="StyleBox"> + [StyleBox] used when the [OptionButton] is disabled (for left-to-right layouts). + </theme_item> + <theme_item name="disabled_mirrored" data_type="style" type="StyleBox"> + [StyleBox] used when the [OptionButton] is disabled (for right-to-left layouts). + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [OptionButton] is focused. It is displayed over the current [StyleBox], so using [StyleBoxEmpty] will just disable the focus visual effect. + </theme_item> <theme_item name="hover" data_type="style" type="StyleBox"> [StyleBox] used when the [OptionButton] is being hovered (for left-to-right layouts). </theme_item> <theme_item name="hover_mirrored" data_type="style" type="StyleBox"> [StyleBox] used when the [OptionButton] is being hovered (for right-to-left layouts). </theme_item> - <theme_item name="hseparation" data_type="constant" type="int" default="2"> - The horizontal space between [OptionButton]'s icon and text. - </theme_item> <theme_item name="normal" data_type="style" type="StyleBox"> Default [StyleBox] for the [OptionButton] (for left-to-right layouts). </theme_item> <theme_item name="normal_mirrored" data_type="style" type="StyleBox"> Default [StyleBox] for the [OptionButton] (for right-to-left layouts). </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the text outline. - </theme_item> <theme_item name="pressed" data_type="style" type="StyleBox"> [StyleBox] used when the [OptionButton] is being pressed (for left-to-right layouts). </theme_item> diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml index f951df1eb7..fd098481e4 100644 --- a/doc/classes/PackedByteArray.xml +++ b/doc/classes/PackedByteArray.xml @@ -332,7 +332,7 @@ Appends an element at the end of the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedColorArray.xml b/doc/classes/PackedColorArray.xml index 4aa8a19630..f69c5504da 100644 --- a/doc/classes/PackedColorArray.xml +++ b/doc/classes/PackedColorArray.xml @@ -95,7 +95,7 @@ Appends a value to the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedFloat32Array.xml b/doc/classes/PackedFloat32Array.xml index 68fb45a62a..ccac607386 100644 --- a/doc/classes/PackedFloat32Array.xml +++ b/doc/classes/PackedFloat32Array.xml @@ -96,7 +96,7 @@ Appends an element at the end of the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedFloat64Array.xml b/doc/classes/PackedFloat64Array.xml index 740591a0c0..b164283b3e 100644 --- a/doc/classes/PackedFloat64Array.xml +++ b/doc/classes/PackedFloat64Array.xml @@ -96,7 +96,7 @@ Appends an element at the end of the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedInt32Array.xml b/doc/classes/PackedInt32Array.xml index 7a01bb6c7c..c6ff31ebdd 100644 --- a/doc/classes/PackedInt32Array.xml +++ b/doc/classes/PackedInt32Array.xml @@ -96,7 +96,7 @@ Appends a value to the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedInt64Array.xml b/doc/classes/PackedInt64Array.xml index c7b69d4ad5..ff48eb1aad 100644 --- a/doc/classes/PackedInt64Array.xml +++ b/doc/classes/PackedInt64Array.xml @@ -96,7 +96,7 @@ Appends a value to the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedStringArray.xml b/doc/classes/PackedStringArray.xml index dfebfb718b..4204277ea2 100644 --- a/doc/classes/PackedStringArray.xml +++ b/doc/classes/PackedStringArray.xml @@ -96,7 +96,7 @@ Appends a string element at end of the array. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedVector2Array.xml b/doc/classes/PackedVector2Array.xml index bf9b7e97d4..e6a7b2fa41 100644 --- a/doc/classes/PackedVector2Array.xml +++ b/doc/classes/PackedVector2Array.xml @@ -96,7 +96,7 @@ Inserts a [Vector2] at the end. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PackedVector3Array.xml b/doc/classes/PackedVector3Array.xml index b439f8f217..6992bbca01 100644 --- a/doc/classes/PackedVector3Array.xml +++ b/doc/classes/PackedVector3Array.xml @@ -95,7 +95,7 @@ Inserts a [Vector3] at the end. </description> </method> - <method name="remove"> + <method name="remove_at"> <return type="void" /> <argument index="0" name="index" type="int" /> <description> diff --git a/doc/classes/PanelContainer.xml b/doc/classes/PanelContainer.xml index 95d038e2af..80005cce15 100644 --- a/doc/classes/PanelContainer.xml +++ b/doc/classes/PanelContainer.xml @@ -10,7 +10,7 @@ <link title="2D Role Playing Game Demo">https://godotengine.org/asset-library/asset/520</link> </tutorials> <members> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="0" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="0" /> </members> <theme_items> <theme_item name="panel" data_type="style" type="StyleBox"> diff --git a/doc/classes/ParallaxBackground.xml b/doc/classes/ParallaxBackground.xml index 5670660d01..592f12d9d7 100644 --- a/doc/classes/ParallaxBackground.xml +++ b/doc/classes/ParallaxBackground.xml @@ -9,7 +9,7 @@ <tutorials> </tutorials> <members> - <member name="layer" type="int" setter="set_layer" getter="get_layer" override="true" default="-100" /> + <member name="layer" type="int" setter="set_layer" getter="get_layer" overrides="CanvasLayer" default="-100" /> <member name="scroll_base_offset" type="Vector2" setter="set_scroll_base_offset" getter="get_scroll_base_offset" default="Vector2(0, 0)"> The base position offset for all [ParallaxLayer] children. </member> diff --git a/doc/classes/PhysicsBody2D.xml b/doc/classes/PhysicsBody2D.xml index 08f9de53ca..43e27ea437 100644 --- a/doc/classes/PhysicsBody2D.xml +++ b/doc/classes/PhysicsBody2D.xml @@ -57,6 +57,6 @@ </method> </methods> <members> - <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" override="true" default="false" /> + <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" overrides="CollisionObject2D" default="false" /> </members> </class> diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml index dd8003be1d..ceb3e788d2 100644 --- a/doc/classes/PhysicsServer3D.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -1152,16 +1152,16 @@ Maximum acceleration for the motor at the axes. </constant> <constant name="G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT" value="0" enum="G6DOFJointAxisFlag"> - If [code]set[/code] there is linear motion possible within the given limits. + If set, linear motion is possible within the given limits. </constant> <constant name="G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT" value="1" enum="G6DOFJointAxisFlag"> - If [code]set[/code] there is rotational motion possible. + If set, rotational motion is possible. </constant> <constant name="G6DOF_JOINT_FLAG_ENABLE_MOTOR" value="4" enum="G6DOFJointAxisFlag"> - If [code]set[/code] there is a rotational motor across these axes. + If set, there is a rotational motor across these axes. </constant> <constant name="G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR" value="5" enum="G6DOFJointAxisFlag"> - If [code]set[/code] there is a linear motor on this axis that targets a specific velocity. + If set, there is a linear motor on this axis that targets a specific velocity. </constant> <constant name="SHAPE_WORLD_BOUNDARY" value="0" enum="ShapeType"> The [Shape3D] is a [WorldBoundaryShape3D]. diff --git a/doc/classes/Popup.xml b/doc/classes/Popup.xml index a47f72b2b6..dc5dd47287 100644 --- a/doc/classes/Popup.xml +++ b/doc/classes/Popup.xml @@ -9,14 +9,14 @@ <tutorials> </tutorials> <members> - <member name="borderless" type="bool" setter="set_flag" getter="get_flag" override="true" default="true" /> + <member name="borderless" type="bool" setter="set_flag" getter="get_flag" overrides="Window" default="true" /> <member name="close_on_parent_focus" type="bool" setter="set_close_on_parent_focus" getter="get_close_on_parent_focus" default="true"> If [code]true[/code], the [Popup] will close when its parent is focused. </member> - <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" /> + <member name="transient" type="bool" setter="set_transient" getter="is_transient" overrides="Window" default="true" /> + <member name="unresizable" type="bool" setter="set_flag" getter="get_flag" overrides="Window" default="true" /> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" overrides="Window" default="false" /> + <member name="wrap_controls" type="bool" setter="set_wrap_controls" getter="is_wrapping_controls" overrides="Window" default="true" /> </members> <signals> <signal name="popup_hide"> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 4eb3ef34b4..b377b186f6 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -533,12 +533,6 @@ </signal> </signals> <theme_items> - <theme_item name="checked" data_type="icon" type="Texture2D"> - [Texture2D] icon for the checked checkbox items. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] used for the menu items. - </theme_item> <theme_item name="font_accelerator_color" data_type="color" type="Color" default="Color(0.7, 0.7, 0.7, 0.8)"> The text [Color] used for shortcuts and accelerators that show next to the menu item name when defined. See [method get_item_accelerator] for more info on accelerators. </theme_item> @@ -557,12 +551,6 @@ <theme_item name="font_separator_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> [Color] used for labeled separators' text. See [method add_separator]. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the menu items. - </theme_item> - <theme_item name="hover" data_type="style" type="StyleBox"> - [StyleBox] displayed when the [PopupMenu] item is hovered. - </theme_item> <theme_item name="hseparation" data_type="constant" type="int" default="4"> The horizontal space between the item's name and the shortcut text/submenu arrow. </theme_item> @@ -570,20 +558,20 @@ </theme_item> <theme_item name="item_start_padding" data_type="constant" type="int" default="2"> </theme_item> - <theme_item name="labeled_separator_left" data_type="style" type="StyleBox"> - [StyleBox] for the left side of labeled separator. See [method add_separator]. - </theme_item> - <theme_item name="labeled_separator_right" data_type="style" type="StyleBox"> - [StyleBox] for the right side of labeled separator. See [method add_separator]. - </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the item text outline. </theme_item> - <theme_item name="panel" data_type="style" type="StyleBox"> - Default [StyleBox] of the [PopupMenu] items. + <theme_item name="vseparation" data_type="constant" type="int" default="4"> + The vertical space between each menu item. </theme_item> - <theme_item name="panel_disabled" data_type="style" type="StyleBox"> - [StyleBox] used when the [PopupMenu] item is disabled. + <theme_item name="font" data_type="font" type="Font"> + [Font] used for the menu items. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the menu items. + </theme_item> + <theme_item name="checked" data_type="icon" type="Texture2D"> + [Texture2D] icon for the checked checkbox items. </theme_item> <theme_item name="radio_checked" data_type="icon" type="Texture2D"> [Texture2D] icon for the checked radio button items. @@ -591,9 +579,6 @@ <theme_item name="radio_unchecked" data_type="icon" type="Texture2D"> [Texture2D] icon for the unchecked radio button items. </theme_item> - <theme_item name="separator" data_type="style" type="StyleBox"> - [StyleBox] used for the separators. See [method add_separator]. - </theme_item> <theme_item name="submenu" data_type="icon" type="Texture2D"> [Texture2D] icon for the submenu arrow (for left-to-right layouts). </theme_item> @@ -603,8 +588,23 @@ <theme_item name="unchecked" data_type="icon" type="Texture2D"> [Texture2D] icon for the unchecked checkbox items. </theme_item> - <theme_item name="vseparation" data_type="constant" type="int" default="4"> - The vertical space between each menu item. + <theme_item name="hover" data_type="style" type="StyleBox"> + [StyleBox] displayed when the [PopupMenu] item is hovered. + </theme_item> + <theme_item name="labeled_separator_left" data_type="style" type="StyleBox"> + [StyleBox] for the left side of labeled separator. See [method add_separator]. + </theme_item> + <theme_item name="labeled_separator_right" data_type="style" type="StyleBox"> + [StyleBox] for the right side of labeled separator. See [method add_separator]. + </theme_item> + <theme_item name="panel" data_type="style" type="StyleBox"> + Default [StyleBox] of the [PopupMenu] items. + </theme_item> + <theme_item name="panel_disabled" data_type="style" type="StyleBox"> + [StyleBox] used when the [PopupMenu] item is disabled. + </theme_item> + <theme_item name="separator" data_type="style" type="StyleBox"> + [StyleBox] used for the separators. See [method add_separator]. </theme_item> </theme_items> </class> diff --git a/doc/classes/ProgressBar.xml b/doc/classes/ProgressBar.xml index 88132967a0..24cc490ce7 100644 --- a/doc/classes/ProgressBar.xml +++ b/doc/classes/ProgressBar.xml @@ -12,19 +12,10 @@ <member name="percent_visible" type="bool" setter="set_percent_visible" getter="is_percent_visible" default="true"> If [code]true[/code], the fill percentage is displayed on the bar. </member> - <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" /> - <member name="step" type="float" setter="set_step" getter="get_step" override="true" default="0.01" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="0" /> + <member name="step" type="float" setter="set_step" getter="get_step" overrides="Range" default="0.01" /> </members> <theme_items> - <theme_item name="bg" data_type="style" type="StyleBox"> - The style of the background. - </theme_item> - <theme_item name="fg" data_type="style" type="StyleBox"> - The style of the progress (i.e. the part that fills the bar). - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - Font used to draw the fill percentage if [member percent_visible] is [code]true[/code]. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> The color of the text. </theme_item> @@ -34,11 +25,20 @@ <theme_item name="font_shadow_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> The color of the text's shadow. </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + Font used to draw the fill percentage if [member percent_visible] is [code]true[/code]. + </theme_item> <theme_item name="font_size" data_type="font_size" type="int"> Font size used to draw the fill percentage if [member percent_visible] is [code]true[/code]. </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the text outline. + <theme_item name="bg" data_type="style" type="StyleBox"> + The style of the background. + </theme_item> + <theme_item name="fg" data_type="style" type="StyleBox"> + The style of the progress (i.e. the part that fills the bar). </theme_item> </theme_items> </class> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 69ee51ca99..e0371a6a4a 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1506,12 +1506,8 @@ </member> <member name="rendering/2d/snap/snap_2d_vertices_to_pixel" type="bool" setter="" getter="" default="false"> </member> - <member name="rendering/3d/viewport/scale" type="float" setter="" getter="" default="1.0"> - Scales the 3D render buffer based on the viewport size and displays the result with linear filtering. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member rendering/anti_aliasing/quality/msaa] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. - [b]Note:[/b] This property is only read when the project starts. To change the 3D rendering resolution scale at runtime, set [member Viewport.scale_3d] instead. - </member> <member name="rendering/anti_aliasing/quality/msaa" type="int" setter="" getter="" default="0"> - Sets the number of MSAA samples to use (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. See also [member rendering/3d/viewport/scale] for supersampling, which provides higher quality but is much more expensive. + Sets the number of MSAA samples to use (as a power of two). MSAA is used to reduce aliasing around the edges of polygons. A higher MSAA value results in smoother edges but can be significantly slower on some hardware. See also bilinear scaling 3d [member rendering/scaling_3d/mode] for supersampling, which provides higher quality but is much more expensive. </member> <member name="rendering/anti_aliasing/quality/screen_space_aa" type="int" setter="" getter="" default="0"> Sets the screen-space antialiasing mode for the default screen [Viewport]. Screen-space antialiasing works by selectively blurring edges in a post-process shader. It differs from MSAA which takes multiple coverage samples while rendering objects. Screen-space AA methods are typically faster than MSAA and will smooth out specular aliasing, but tend to make scenes appear blurry. @@ -1580,7 +1576,7 @@ 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/defaults/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. + [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, you do not need to set this property. </member> <member name="rendering/environment/glow/upscale_mode" type="int" setter="" getter="" default="1"> Sets how the glow effect is upscaled before being copied onto the screen. Linear is faster, but looks blocky. Bicubic is slower but looks smooth. @@ -1718,6 +1714,18 @@ <member name="rendering/reflections/sky_reflections/texture_array_reflections.mobile" type="bool" setter="" getter="" default="false"> Lower-end override for [member rendering/reflections/sky_reflections/texture_array_reflections] on mobile devices, due to performance concerns or driver support. </member> + <member name="rendering/scaling_3d/fsr_mipmap_bias" type="float" setter="" getter="" default="0.0"> + Affects the final texture sharpness by reading from a lower or higher mipmap. Negative values make textures sharper, while positive values make textures blurrier. When using FSR, this value is used to adjust the mipmap bias calculated internally which is based on the selected quality. The formula for this is [code]-log2(1.0 / scale) + mipmap_bias[/code] + </member> + <member name="rendering/scaling_3d/fsr_sharpness" type="float" setter="" getter="" default="0.2"> + Determines how sharp the upscaled image will be when using the FSR upscaling mode. Sharpness halves with every whole number. Values go from 0.0 (sharpest) to 2.0. Values above 2.0 won't make a visible difference. + </member> + <member name="rendering/scaling_3d/mode" type="int" setter="" getter="" default="0"> + Sets the scaling 3D mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible. + </member> + <member name="rendering/scaling_3d/scale" type="float" setter="" getter="" default="1.0"> + Scales the 3D render buffer based on the viewport size uses an image filter specified in [member rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member rendering/anti_aliasing/quality/msaa] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. + </member> <member name="rendering/shader_compiler/shader_cache/compress" type="bool" setter="" getter="" default="true"> </member> <member name="rendering/shader_compiler/shader_cache/enabled" type="bool" setter="" getter="" default="true"> diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 4dc3859ca5..65d1654c21 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -7,6 +7,7 @@ [Rect2] consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. It uses floating-point coordinates. If you need integer coordinates, use [Rect2i] instead. The 3D counterpart to [Rect2] is [AABB]. + Negative values for [member size] are not supported and will not work for most methods. Use [method abs] to get a Rect2 with a positive size. </description> <tutorials> <link title="Math documentation index">$DOCS_URL/tutorials/math/index.html</link> diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml index d66b589ec1..5909784135 100644 --- a/doc/classes/Rect2i.xml +++ b/doc/classes/Rect2i.xml @@ -6,6 +6,7 @@ <description> [Rect2i] consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. It uses integer coordinates. If you need floating-point coordinates, use [Rect2] instead. + Negative values for [member size] are not supported and will not work for most methods. Use [method abs] to get a Rect2i with a positive size. </description> <tutorials> <link title="Math documentation index">$DOCS_URL/tutorials/math/index.html</link> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 7f4d5cf1cd..0700650a91 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -3100,6 +3100,22 @@ If [code]true[/code], rendering of a viewport's environment is disabled. </description> </method> + <method name="viewport_set_fsr_mipmap_bias"> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="mipmap_bias" type="float" /> + <description> + Affects the final texture sharpness by reading from a lower or higher mipmap. Negative values make textures sharper, while positive values make textures blurrier. When using FSR, this value is used to adjust the mipmap bias calculated internally which is based on the selected quality. The formula for this is [code]-log2(1.0 / scale) + mipmap_bias[/code] + </description> + </method> + <method name="viewport_set_fsr_sharpness"> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="sharpness" type="float" /> + <description> + Determines how sharp the upscaled image will be when using the FSR upscaling mode. Sharpness halves with every whole number. Values go from 0.0 (sharpest) to 2.0. Values above 2.0 won't make a visible difference. + </description> + </method> <method name="viewport_set_global_canvas_transform"> <return type="void" /> <argument index="0" name="viewport" type="RID" /> @@ -3151,12 +3167,21 @@ If [code]true[/code], render the contents of the viewport directly to screen. This allows a low-level optimization where you can skip drawing a viewport to the root viewport. While this optimization can result in a significant increase in speed (especially on older devices), it comes at a cost of usability. When this is enabled, you cannot read from the viewport or from the [code]SCREEN_TEXTURE[/code]. You also lose the benefit of certain window settings, such as the various stretch modes. Another consequence to be aware of is that in 2D the rendering happens in window coordinates, so if you have a viewport that is double the size of the window, and you set this, then only the portion that fits within the window will be drawn, no automatic scaling is possible, even if your game scene is significantly larger than the window size. </description> </method> - <method name="viewport_set_scale_3d"> + <method name="viewport_set_scaling_3d_mode"> + <return type="void" /> + <argument index="0" name="viewport" type="RID" /> + <argument index="1" name="scaling_3d_mode" type="int" enum="RenderingServer.ViewportScaling3DMode" /> + <description> + Sets scaling 3d mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible. + </description> + </method> + <method name="viewport_set_scaling_3d_scale"> <return type="void" /> <argument index="0" name="viewport" type="RID" /> <argument index="1" name="scale" type="float" /> <description> - Sets the scale at which we render 3D contents. + Scales the 3D render buffer based on the viewport size uses an image filter specified in [enum ViewportScaling3DMode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [enum ViewportMSAA] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. + When using FSR upscaling, AMD recommends exposing the following values as preset options to users "Ultra Quality: 0.77", "Quality: 0.67", "Balanced: 0.59", "Performance: 0.5" instead of exposing the entire scale. </description> </method> <method name="viewport_set_scenario"> @@ -3844,6 +3869,14 @@ <constant name="FOG_VOLUME_SHAPE_WORLD" value="2" enum="FogVolumeShape"> [FogVolume] will have no shape, will cover the whole world and will not be culled. </constant> + <constant name="VIEWPORT_SCALING_3D_MODE_BILINEAR" value="0" enum="ViewportScaling3DMode"> + Enables bilinear scaling on 3D viewports. The amount of scaling can be set using [member Viewport.scaling_3d_scale]. Values less then [code]1.0[/code] will result in undersampling while values greater than [code]1.0[/code] will result in supersampling. A value of [code]1.0[/code] disables scaling. + </constant> + <constant name="VIEWPORT_SCALING_3D_MODE_FSR" value="1" enum="ViewportScaling3DMode"> + Enables FSR upscaling on 3D viewports. The amount of scaling can be set using [member Viewport.scaling_3d_scale]. Values less then [code]1.0[/code] will be result in the viewport being upscaled using FSR. Values greater than [code]1.0[/code] are not supported and bilinear supersampling will be used instead. A value of [code]1.0[/code] disables scaling. + </constant> + <constant name="VIEWPORT_SCALING_3D_MODE_MAX" value="2" enum="ViewportScaling3DMode"> + </constant> <constant name="VIEWPORT_UPDATE_DISABLED" value="0" enum="ViewportUpdateMode"> Do not update the viewport. </constant> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 6bfaca8928..a74b0ed812 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -399,7 +399,7 @@ The range of characters to display, as a [float] between 0.0 and 1.0. When assigned an out of range value, it's the same as assigning 1.0. [b]Note:[/b] Setting this property updates [member visible_characters] based on current [method get_total_character_count]. </member> - <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" /> <member name="scroll_active" type="bool" setter="set_scroll_active" getter="is_scroll_active" default="true"> If [code]true[/code], the scrollbar is visible. Setting this to [code]false[/code] does not block scrolling completely. See [method scroll_to_line]. </member> @@ -529,24 +529,9 @@ </constant> </constants> <theme_items> - <theme_item name="bold_font" data_type="font" type="Font"> - The font used for bold text. - </theme_item> - <theme_item name="bold_font_size" data_type="font_size" type="int"> - The font size used for bold text. - </theme_item> - <theme_item name="bold_italics_font" data_type="font" type="Font"> - The font used for bold italics text. - </theme_item> - <theme_item name="bold_italics_font_size" data_type="font_size" type="int"> - The font size used for bold italics text. - </theme_item> <theme_item name="default_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> The default text color. </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - The background The background used when the [RichTextLabel] is focused. - </theme_item> <theme_item name="font_outline_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> The default tint of text outline. </theme_item> @@ -556,36 +541,24 @@ <theme_item name="font_shadow_color" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> The color of the font's shadow. </theme_item> - <theme_item name="italics_font" data_type="font" type="Font"> - The font used for italics text. - </theme_item> - <theme_item name="italics_font_size" data_type="font_size" type="int"> - The font size used for italics text. - </theme_item> - <theme_item name="line_separation" data_type="constant" type="int" default="0"> - The vertical space between lines. - </theme_item> - <theme_item name="mono_font" data_type="font" type="Font"> - The font used for monospace text. + <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.1, 0.1, 1, 0.8)"> + The color of the selection box. </theme_item> - <theme_item name="mono_font_size" data_type="font_size" type="int"> - The font size used for monospace text. + <theme_item name="table_border" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> + The default cell border color. </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - The normal background for the [RichTextLabel]. + <theme_item name="table_even_row_bg" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> + The default background color for even rows. </theme_item> - <theme_item name="normal_font" data_type="font" type="Font"> - The default text font. + <theme_item name="table_odd_row_bg" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> + The default background color for odd rows. </theme_item> - <theme_item name="normal_font_size" data_type="font_size" type="int"> - The default text font size. + <theme_item name="line_separation" data_type="constant" type="int" default="0"> + The vertical space between lines. </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> - <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.1, 0.1, 1, 0.8)"> - The color of the selection box. - </theme_item> <theme_item name="shadow_offset_x" data_type="constant" type="int" default="1"> The horizontal offset of the font's shadow. </theme_item> @@ -595,20 +568,47 @@ <theme_item name="shadow_outline_size" data_type="constant" type="int" default="1"> The size of the shadow outline. </theme_item> - <theme_item name="table_border" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> - The default cell border color. - </theme_item> - <theme_item name="table_even_row_bg" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> - The default background color for even rows. - </theme_item> <theme_item name="table_hseparation" data_type="constant" type="int" default="3"> The horizontal separation of elements in a table. </theme_item> - <theme_item name="table_odd_row_bg" data_type="color" type="Color" default="Color(0, 0, 0, 0)"> - The default background color for odd rows. - </theme_item> <theme_item name="table_vseparation" data_type="constant" type="int" default="3"> The vertical separation of elements in a table. </theme_item> + <theme_item name="bold_font" data_type="font" type="Font"> + The font used for bold text. + </theme_item> + <theme_item name="bold_italics_font" data_type="font" type="Font"> + The font used for bold italics text. + </theme_item> + <theme_item name="italics_font" data_type="font" type="Font"> + The font used for italics text. + </theme_item> + <theme_item name="mono_font" data_type="font" type="Font"> + The font used for monospace text. + </theme_item> + <theme_item name="normal_font" data_type="font" type="Font"> + The default text font. + </theme_item> + <theme_item name="bold_font_size" data_type="font_size" type="int"> + The font size used for bold text. + </theme_item> + <theme_item name="bold_italics_font_size" data_type="font_size" type="int"> + The font size used for bold italics text. + </theme_item> + <theme_item name="italics_font_size" data_type="font_size" type="int"> + The font size used for italics text. + </theme_item> + <theme_item name="mono_font_size" data_type="font_size" type="int"> + The font size used for monospace text. + </theme_item> + <theme_item name="normal_font_size" data_type="font_size" type="int"> + The default text font size. + </theme_item> + <theme_item name="focus" data_type="style" type="StyleBox"> + The background The background used when the [RichTextLabel] is focused. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + The normal background for the [RichTextLabel]. + </theme_item> </theme_items> </class> diff --git a/doc/classes/SceneTreeTimer.xml b/doc/classes/SceneTreeTimer.xml index b0509a322e..80f0a54e70 100644 --- a/doc/classes/SceneTreeTimer.xml +++ b/doc/classes/SceneTreeTimer.xml @@ -22,12 +22,13 @@ } [/csharp] [/codeblocks] + The timer will be automatically freed after its time elapses. </description> <tutorials> </tutorials> <members> <member name="time_left" type="float" setter="set_time_left" getter="get_time_left"> - The time remaining. + The time remaining (in seconds). </member> </members> <signals> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml index 349adb9111..33ca5b4dc9 100644 --- a/doc/classes/ScriptCreateDialog.xml +++ b/doc/classes/ScriptCreateDialog.xml @@ -39,8 +39,8 @@ </method> </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="title" type="String" setter="set_title" getter="get_title" override="true" default=""Attach Node Script"" /> + <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" /> + <member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default=""Attach Node Script"" /> </members> <signals> <signal name="script_created"> diff --git a/doc/classes/ScrollBar.xml b/doc/classes/ScrollBar.xml index 1f1415bebe..2dcde10616 100644 --- a/doc/classes/ScrollBar.xml +++ b/doc/classes/ScrollBar.xml @@ -12,8 +12,8 @@ <member name="custom_step" type="float" setter="set_custom_step" getter="get_custom_step" default="-1.0"> Overrides the step used when clicking increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused. </member> - <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" /> - <member name="step" type="float" setter="set_step" getter="get_step" override="true" default="0.0" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="0" /> + <member name="step" type="float" setter="set_step" getter="get_step" overrides="Range" default="0.0" /> </members> <signals> <signal name="scrolling"> diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 976c32c243..f0c739bfa3 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -37,7 +37,7 @@ <member name="follow_focus" type="bool" setter="set_follow_focus" getter="is_following_focus" default="false"> If [code]true[/code], the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible. </member> - <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" /> <member name="scroll_deadzone" type="int" setter="set_deadzone" getter="get_deadzone" default="0"> </member> <member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0"> diff --git a/doc/classes/SkeletonModification3DTwoBoneIK.xml b/doc/classes/SkeletonModification3DTwoBoneIK.xml index 80f8ba4e5b..0e83cd0b28 100644 --- a/doc/classes/SkeletonModification3DTwoBoneIK.xml +++ b/doc/classes/SkeletonModification3DTwoBoneIK.xml @@ -4,7 +4,7 @@ A modification that moves two bones to reach the target. </brief_description> <description> - This [SkeletonModification3D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three verticies of the triangle. Because the algorithm works by making a triangle, it can only opperate on two bones. + This [SkeletonModification3D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three vertices of the triangle. Because the algorithm works by making a triangle, it can only opperate on two bones. TwoBoneIK is great for arms, legs, and really any joints that can be represented by just two bones that bend to reach a target. This solver is more lightweight than [SkeletonModification3DFABRIK], but gives similar, natural looking results. A [Node3D]-based node can be used to define the pole, or bend direction, allowing control over which direction the joint takes when bending to reach the target when the target is within reach. </description> diff --git a/doc/classes/Slider.xml b/doc/classes/Slider.xml index 21a45645b8..41ceb7b8b3 100644 --- a/doc/classes/Slider.xml +++ b/doc/classes/Slider.xml @@ -13,11 +13,11 @@ <member name="editable" type="bool" setter="set_editable" getter="is_editable" default="true"> If [code]true[/code], the slider can be interacted with. If [code]false[/code], the value can be changed only by code. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="scrollable" type="bool" setter="set_scrollable" getter="is_scrollable" default="true"> If [code]true[/code], the value can be changed using the mouse wheel. </member> - <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="0" /> <member name="tick_count" type="int" setter="set_ticks" getter="get_ticks" default="0"> Number of ticks displayed on the slider, including border ticks. Ticks are uniformly-distributed value markers. </member> diff --git a/doc/classes/SpotLight3D.xml b/doc/classes/SpotLight3D.xml index f9f9a62baa..b5276d25ea 100644 --- a/doc/classes/SpotLight3D.xml +++ b/doc/classes/SpotLight3D.xml @@ -11,7 +11,7 @@ <link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link> </tutorials> <members> - <member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.03" /> + <member name="shadow_bias" type="float" setter="set_param" getter="get_param" overrides="Light3D" default="0.03" /> <member name="spot_angle" type="float" setter="set_param" getter="get_param" default="45.0"> The spotlight's angle in degrees. </member> diff --git a/doc/classes/Sprite3D.xml b/doc/classes/Sprite3D.xml index 5a7fd537e0..4ad78429e9 100644 --- a/doc/classes/Sprite3D.xml +++ b/doc/classes/Sprite3D.xml @@ -36,5 +36,10 @@ Emitted when the [member frame] changes. </description> </signal> + <signal name="texture_changed"> + <description> + Emitted when the [member texture] changes. + </description> + </signal> </signals> </class> diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index b723c9f4d4..32abd1caea 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -60,7 +60,8 @@ If [code]true[/code], texture is flipped vertically. </member> <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> - A color value that gets multiplied on, could be used for mood-coloring or to simulate the color of light. + A color value used to [i]multiply[/i] the texture's colors. Can be used for mood-coloring or to simulate the color of light. + [b]Note:[/b] If a [member GeometryInstance3D.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in [member modulate] will be ignored. For a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/color] must be inserted in the shader's [code]fragment()[/code] function. </member> <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The texture's drawing offset. diff --git a/doc/classes/TabBar.xml b/doc/classes/TabBar.xml index 612f8fb740..a9b09fb026 100644 --- a/doc/classes/TabBar.xml +++ b/doc/classes/TabBar.xml @@ -290,24 +290,6 @@ </constant> </constants> <theme_items> - <theme_item name="close" data_type="icon" type="Texture2D"> - The icon for the close button (see [member tab_close_display_policy]). - </theme_item> - <theme_item name="close_bg_highlight" data_type="style" type="StyleBox"> - Background of the close button when it's being hovered with the cursor. - </theme_item> - <theme_item name="close_bg_pressed" data_type="style" type="StyleBox"> - Background of the close button when it's being pressed. - </theme_item> - <theme_item name="decrement" data_type="icon" type="Texture2D"> - Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent. - </theme_item> - <theme_item name="decrement_highlight" data_type="icon" type="Texture2D"> - Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - The font used to draw tab names. - </theme_item> <theme_item name="font_disabled_color" data_type="color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> Font color of disabled tabs. </theme_item> @@ -317,23 +299,41 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Font color of the currently selected tab. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the tab names. - </theme_item> <theme_item name="font_unselected_color" data_type="color" type="Color" default="Color(0.69, 0.69, 0.69, 1)"> Font color of the other, unselected tabs. </theme_item> <theme_item name="hseparation" data_type="constant" type="int" default="4"> The horizontal separation between the elements inside tabs. </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the tab text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + The font used to draw tab names. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the tab names. + </theme_item> + <theme_item name="close" data_type="icon" type="Texture2D"> + The icon for the close button (see [member tab_close_display_policy]). + </theme_item> + <theme_item name="decrement" data_type="icon" type="Texture2D"> + Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent. + </theme_item> + <theme_item name="decrement_highlight" data_type="icon" type="Texture2D"> + Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor. + </theme_item> <theme_item name="increment" data_type="icon" type="Texture2D"> Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent. </theme_item> <theme_item name="increment_highlight" data_type="icon" type="Texture2D"> Icon for the right arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor. </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the tab text outline. + <theme_item name="close_bg_highlight" data_type="style" type="StyleBox"> + Background of the close button when it's being hovered with the cursor. + </theme_item> + <theme_item name="close_bg_pressed" data_type="style" type="StyleBox"> + Background of the close button when it's being pressed. </theme_item> <theme_item name="tab_disabled" data_type="style" type="StyleBox"> The style of disabled tabs. diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 1f32bba5a1..2ac6549250 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -4,8 +4,9 @@ Tabbed container. </brief_description> <description> - Sets the active tab's [code]visible[/code] property to the value [code]true[/code]. Sets all other children's to [code]false[/code]. + Arranges [Control] children into a tabbed view, creating a tab for each one. The active tab's corresponding [Control] has its [code]visible[/code] property set to [code]true[/code], and all other children's to [code]false[/code]. Ignores non-[Control] children. + [b]Note:[/b] The drawing of the clickable tabs themselves is handled by this node. Adding [TabBar]s as children is not needed. </description> <tutorials> </tutorials> @@ -181,15 +182,6 @@ </constant> </constants> <theme_items> - <theme_item name="decrement" data_type="icon" type="Texture2D"> - Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent. - </theme_item> - <theme_item name="decrement_highlight" data_type="icon" type="Texture2D"> - Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - The font used to draw tab names. - </theme_item> <theme_item name="font_disabled_color" data_type="color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> Font color of disabled tabs. </theme_item> @@ -199,15 +191,30 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Font color of the currently selected tab. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the tab names. - </theme_item> <theme_item name="font_unselected_color" data_type="color" type="Color" default="Color(0.69, 0.69, 0.69, 1)"> Font color of the other, unselected tabs. </theme_item> <theme_item name="icon_separation" data_type="constant" type="int" default="4"> Space between tab's name and its icon. </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the tab text outline. + </theme_item> + <theme_item name="side_margin" data_type="constant" type="int" default="8"> + The space at the left and right edges of the tab bar. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + The font used to draw tab names. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the tab names. + </theme_item> + <theme_item name="decrement" data_type="icon" type="Texture2D"> + Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent. + </theme_item> + <theme_item name="decrement_highlight" data_type="icon" type="Texture2D"> + Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor. + </theme_item> <theme_item name="increment" data_type="icon" type="Texture2D"> Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent. </theme_item> @@ -220,15 +227,9 @@ <theme_item name="menu_highlight" data_type="icon" type="Texture2D"> The icon for the menu button (see [method set_popup]) when it's being hovered with the cursor. </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the tab text outline. - </theme_item> <theme_item name="panel" data_type="style" type="StyleBox"> The style for the background fill. </theme_item> - <theme_item name="side_margin" data_type="constant" type="int" default="8"> - The space at the left and right edges of the tab bar. - </theme_item> <theme_item name="tab_disabled" data_type="style" type="StyleBox"> The style of disabled tabs. </theme_item> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 16d8595b4e..ffc91decca 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -586,6 +586,13 @@ Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided). </description> </method> + <method name="is_mouse_over_selection" qualifiers="const"> + <return type="bool" /> + <argument index="0" name="edges" type="bool" /> + <description> + Returns whether the mouse is over selection. If [code]edges[/code] is [code]true[/code], the edges are considered part of the selection. + </description> + </method> <method name="is_overtype_mode_enabled" qualifiers="const"> <return type="bool" /> <description> @@ -964,7 +971,7 @@ <member name="editable" type="bool" setter="set_editable" getter="is_editable" default="true"> If [code]false[/code], existing text cannot be modified and new text cannot be added. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="highlight_all_occurrences" type="bool" setter="set_highlight_all_occurrences" getter="is_highlight_all_occurrences_enabled" default="false"> If [code]true[/code], all occurrences of the selected text will be highlighted. </member> @@ -984,7 +991,7 @@ <member name="minimap_width" type="int" setter="set_minimap_width" getter="get_minimap_width" default="80"> The width, in pixels, of the minimap. </member> - <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" override="true" enum="Control.CursorShape" default="1" /> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" overrides="Control" enum="Control.CursorShape" default="1" /> <member name="override_selected_font_color" type="bool" setter="set_override_selected_font_color" getter="is_overriding_selected_font_color" default="false"> If [code]true[/code], custom [code]font_selected_color[/code] will be used for selected text. </member> @@ -1221,12 +1228,6 @@ <theme_item name="current_line_color" data_type="color" type="Color" default="Color(0.25, 0.25, 0.26, 0.8)"> Background [Color] of the line containing the caret. </theme_item> - <theme_item name="focus" data_type="style" type="StyleBox"> - Sets the [StyleBox] when in focus. - </theme_item> - <theme_item name="font" data_type="font" type="Font"> - Sets the default [Font]. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Sets the font [Color]. </theme_item> @@ -1239,21 +1240,6 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> Sets the [Color] of the selected text. [member override_selected_font_color] has to be enabled. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Sets default font size. - </theme_item> - <theme_item name="line_spacing" data_type="constant" type="int" default="4"> - Sets the spacing between the lines. - </theme_item> - <theme_item name="normal" data_type="style" type="StyleBox"> - Sets the [StyleBox] of this [TextEdit]. - </theme_item> - <theme_item name="outline_size" data_type="constant" type="int" default="0"> - The size of the text outline. - </theme_item> - <theme_item name="read_only" data_type="style" type="StyleBox"> - Sets the [StyleBox] of this [TextEdit] when [member editable] is disabled. - </theme_item> <theme_item name="search_result_border_color" data_type="color" type="Color" default="Color(0.3, 0.3, 0.3, 0.4)"> [Color] of the border around text that matches the search query. </theme_item> @@ -1263,14 +1249,35 @@ <theme_item name="selection_color" data_type="color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> Sets the highlight [Color] of text selections. </theme_item> + <theme_item name="word_highlighted_color" data_type="color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)"> + Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled. + </theme_item> + <theme_item name="line_spacing" data_type="constant" type="int" default="4"> + Sets the spacing between the lines. + </theme_item> + <theme_item name="outline_size" data_type="constant" type="int" default="0"> + The size of the text outline. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + Sets the default [Font]. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Sets default font size. + </theme_item> <theme_item name="space" data_type="icon" type="Texture2D"> Sets a custom [Texture2D] for space text characters. </theme_item> <theme_item name="tab" data_type="icon" type="Texture2D"> Sets a custom [Texture2D] for tab text characters. </theme_item> - <theme_item name="word_highlighted_color" data_type="color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)"> - Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled. + <theme_item name="focus" data_type="style" type="StyleBox"> + Sets the [StyleBox] when in focus. + </theme_item> + <theme_item name="normal" data_type="style" type="StyleBox"> + Sets the [StyleBox] of this [TextEdit]. + </theme_item> + <theme_item name="read_only" data_type="style" type="StyleBox"> + Sets the [StyleBox] of this [TextEdit] when [member editable] is disabled. </theme_item> </theme_items> </class> diff --git a/doc/classes/TextureProgressBar.xml b/doc/classes/TextureProgressBar.xml index ee47557b39..25725d2f67 100644 --- a/doc/classes/TextureProgressBar.xml +++ b/doc/classes/TextureProgressBar.xml @@ -27,7 +27,7 @@ <member name="fill_mode" type="int" setter="set_fill_mode" getter="get_fill_mode" default="0"> The fill direction. See [enum FillMode] for possible values. </member> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="1" /> <member name="nine_patch_stretch" type="bool" setter="set_nine_patch_stretch" getter="get_nine_patch_stretch" default="false"> If [code]true[/code], Godot treats the bar's textures like in [NinePatchRect]. Use the [code]stretch_margin_*[/code] properties like [member stretch_margin_bottom] to set up the nine patch's 3×3 grid. When using a radial [member fill_mode], this setting will enable stretching. </member> diff --git a/doc/classes/TextureRect.xml b/doc/classes/TextureRect.xml index 4f18f43ddf..a160eceb35 100644 --- a/doc/classes/TextureRect.xml +++ b/doc/classes/TextureRect.xml @@ -19,7 +19,7 @@ <member name="flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" default="false"> If [code]true[/code], texture is flipped vertically. </member> - <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" overrides="Control" enum="Control.MouseFilter" default="1" /> <member name="stretch_mode" type="int" setter="set_stretch_mode" getter="get_stretch_mode" enum="TextureRect.StretchMode" default="0"> Controls the texture's behavior when resizing the node's bounding rectangle. See [enum StretchMode]. </member> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index be41cdde99..97cbf6918d 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -225,17 +225,17 @@ </description> </operator> <operator name="operator *"> - <return type="Transform2D" /> - <argument index="0" name="right" type="Transform2D" /> + <return type="Rect2" /> + <argument index="0" name="right" type="Rect2" /> <description> - Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent). + Transforms (multiplies) the [Rect2] by the given [Transform2D] matrix. </description> </operator> <operator name="operator *"> - <return type="Rect2" /> - <argument index="0" name="right" type="Rect2" /> + <return type="Transform2D" /> + <argument index="0" name="right" type="Transform2D" /> <description> - Transforms (multiplies) the [Rect2] by the given [Transform2D] matrix. + Composes these two transformation matrices by multiplying them together. This has the effect of transforming the second transform (the child) by the first transform (the parent). </description> </operator> <operator name="operator *"> diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml index 511574f6aa..e62cb9216e 100644 --- a/doc/classes/Transform3D.xml +++ b/doc/classes/Transform3D.xml @@ -152,6 +152,13 @@ </description> </operator> <operator name="operator *"> + <return type="AABB" /> + <argument index="0" name="right" type="AABB" /> + <description> + Transforms (multiplies) the [AABB] by the given [Transform3D] matrix. + </description> + </operator> + <operator name="operator *"> <return type="PackedVector3Array" /> <argument index="0" name="right" type="PackedVector3Array" /> <description> @@ -166,13 +173,6 @@ </description> </operator> <operator name="operator *"> - <return type="AABB" /> - <argument index="0" name="right" type="AABB" /> - <description> - Transforms (multiplies) the [AABB] by the given [Transform3D] matrix. - </description> - </operator> - <operator name="operator *"> <return type="Vector3" /> <argument index="0" name="right" type="Vector3" /> <description> diff --git a/doc/classes/TranslationServer.xml b/doc/classes/TranslationServer.xml index 519e1cb041..a1b4404079 100644 --- a/doc/classes/TranslationServer.xml +++ b/doc/classes/TranslationServer.xml @@ -49,7 +49,7 @@ <argument index="0" name="locale" type="String" /> <description> Returns the [Translation] instance based on the [code]locale[/code] passed in. - It will return a [code]nullptr[/code] if there is no [Translation] instance that matches the [code]locale[/code]. + It will return [code]null[/code] if there is no [Translation] instance that matches the [code]locale[/code]. </description> </method> <method name="pseudolocalize" qualifiers="const"> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index ed24905254..10bbdc0301 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -35,12 +35,6 @@ <tutorials> </tutorials> <methods> - <method name="are_column_titles_visible" qualifiers="const"> - <return type="bool" /> - <description> - Returns [code]true[/code] if the column titles are being shown. - </description> - </method> <method name="clear"> <return type="void" /> <description> @@ -313,13 +307,6 @@ Sets OpenType feature [code]tag[/code] for the column title. </description> </method> - <method name="set_column_titles_visible"> - <return type="void" /> - <argument index="0" name="visible" type="bool" /> - <description> - If [code]true[/code], column titles are visible. - </description> - </method> </methods> <members> <member name="allow_reselect" type="bool" setter="set_allow_reselect" getter="get_allow_reselect" default="false"> @@ -328,6 +315,9 @@ <member name="allow_rmb_select" type="bool" setter="set_allow_rmb_select" getter="get_allow_rmb_select" default="false"> If [code]true[/code], a right mouse button click can select items. </member> + <member name="column_titles_visible" type="bool" setter="set_column_titles_visible" getter="are_column_titles_visible" default="false"> + If [code]true[/code], column titles are visible. + </member> <member name="columns" type="int" setter="set_columns" getter="get_columns" default="1"> The number of columns. </member> @@ -335,14 +325,14 @@ The drop mode as an OR combination of flags. See [enum DropModeFlags] constants. Once dropping is done, reverts to [constant DROP_MODE_DISABLED]. Setting this during [method Control._can_drop_data] is recommended. This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" /> <member name="hide_folding" type="bool" setter="set_hide_folding" getter="is_folding_hidden" default="false"> If [code]true[/code], the folding arrow is hidden. </member> <member name="hide_root" type="bool" setter="set_hide_root" getter="is_root_hidden" default="false"> If [code]true[/code], the tree's root is hidden. </member> - <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" /> <member name="scroll_horizontal_enabled" type="bool" setter="set_h_scroll_enabled" getter="is_h_scroll_enabled" default="true"> If [code]true[/code], enables horizontal scrolling. </member> @@ -474,66 +464,15 @@ </constant> </constants> <theme_items> - <theme_item name="arrow" data_type="icon" type="Texture2D"> - The arrow icon used when a foldable item is not collapsed. - </theme_item> - <theme_item name="arrow_collapsed" data_type="icon" type="Texture2D"> - The arrow icon used when a foldable item is collapsed (for left-to-right layouts). - </theme_item> - <theme_item name="arrow_collapsed_mirrored" data_type="icon" type="Texture2D"> - The arrow icon used when a foldable item is collapsed (for right-to-left layouts). - </theme_item> - <theme_item name="bg" data_type="style" type="StyleBox"> - Default [StyleBox] for the [Tree], i.e. used when the control is not being focused. - </theme_item> - <theme_item name="bg_focus" data_type="style" type="StyleBox"> - [StyleBox] used when the [Tree] is being focused. - </theme_item> - <theme_item name="button_margin" data_type="constant" type="int" default="4"> - The horizontal space between each button in a cell. - </theme_item> - <theme_item name="button_pressed" data_type="style" type="StyleBox"> - [StyleBox] used when a button in the tree is pressed. - </theme_item> - <theme_item name="checked" data_type="icon" type="Texture2D"> - The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked. - </theme_item> <theme_item name="children_hl_line_color" data_type="color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> The [Color] of the relationship lines between the selected [TreeItem] and its children. </theme_item> - <theme_item name="children_hl_line_width" data_type="constant" type="int" default="1"> - The width of the relationship lines between the selected [TreeItem] and its children. - </theme_item> - <theme_item name="cursor" data_type="style" type="StyleBox"> - [StyleBox] used for the cursor, when the [Tree] is being focused. - </theme_item> - <theme_item name="cursor_unfocused" data_type="style" type="StyleBox"> - [StyleBox] used for the cursor, when the [Tree] is not being focused. - </theme_item> - <theme_item name="custom_button" data_type="style" type="StyleBox"> - Default [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell. - </theme_item> <theme_item name="custom_button_font_highlight" data_type="color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Text [Color] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. </theme_item> - <theme_item name="custom_button_hover" data_type="style" type="StyleBox"> - [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. - </theme_item> - <theme_item name="custom_button_pressed" data_type="style" type="StyleBox"> - [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's pressed. - </theme_item> - <theme_item name="draw_guides" data_type="constant" type="int" default="1"> - Draws the guidelines if not zero, this acts as a boolean. The guideline is a horizontal line drawn at the bottom of each item. - </theme_item> - <theme_item name="draw_relationship_lines" data_type="constant" type="int" default="0"> - Draws the relationship lines if not zero, this acts as a boolean. Relationship lines are drawn at the start of child items to show hierarchy. - </theme_item> <theme_item name="drop_position_color" data_type="color" type="Color" default="Color(1, 0.3, 0.2, 1)"> [Color] used to draw possible drop locations. See [enum DropModeFlags] constants for further description of drop locations. </theme_item> - <theme_item name="font" data_type="font" type="Font"> - [Font] of the item's text. - </theme_item> <theme_item name="font_color" data_type="color" type="Color" default="Color(0.69, 0.69, 0.69, 1)"> Default text [Color] of the item. </theme_item> @@ -543,36 +482,45 @@ <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the item is selected. </theme_item> - <theme_item name="font_size" data_type="font_size" type="int"> - Font size of the item's text. - </theme_item> <theme_item name="guide_color" data_type="color" type="Color" default="Color(0, 0, 0, 0.1)"> [Color] of the guideline. </theme_item> + <theme_item name="parent_hl_line_color" data_type="color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> + The [Color] of the relationship lines between the selected [TreeItem] and its parents. + </theme_item> + <theme_item name="relationship_line_color" data_type="color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> + The default [Color] of the relationship lines. + </theme_item> + <theme_item name="title_button_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> + Default text [Color] of the title button. + </theme_item> + <theme_item name="button_margin" data_type="constant" type="int" default="4"> + The horizontal space between each button in a cell. + </theme_item> + <theme_item name="children_hl_line_width" data_type="constant" type="int" default="1"> + The width of the relationship lines between the selected [TreeItem] and its children. + </theme_item> + <theme_item name="draw_guides" data_type="constant" type="int" default="1"> + Draws the guidelines if not zero, this acts as a boolean. The guideline is a horizontal line drawn at the bottom of each item. + </theme_item> + <theme_item name="draw_relationship_lines" data_type="constant" type="int" default="0"> + Draws the relationship lines if not zero, this acts as a boolean. Relationship lines are drawn at the start of child items to show hierarchy. + </theme_item> <theme_item name="hseparation" data_type="constant" type="int" default="4"> The horizontal space between item cells. This is also used as the margin at the start of an item when folding is disabled. </theme_item> - <theme_item name="indeterminate" data_type="icon" type="Texture2D"> - The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is indeterminate. - </theme_item> <theme_item name="item_margin" data_type="constant" type="int" default="12"> The horizontal margin at the start of an item. This is used when folding is enabled for the item. </theme_item> <theme_item name="outline_size" data_type="constant" type="int" default="0"> The size of the text outline. </theme_item> - <theme_item name="parent_hl_line_color" data_type="color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> - The [Color] of the relationship lines between the selected [TreeItem] and its parents. - </theme_item> <theme_item name="parent_hl_line_margin" data_type="constant" type="int" default="0"> The space between the parent relationship lines for the selected [TreeItem] and the relationship lines to its siblings that are not selected. </theme_item> <theme_item name="parent_hl_line_width" data_type="constant" type="int" default="1"> The width of the relationship lines between the selected [TreeItem] and its parents. </theme_item> - <theme_item name="relationship_line_color" data_type="color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> - The default [Color] of the relationship lines. - </theme_item> <theme_item name="relationship_line_width" data_type="constant" type="int" default="1"> The default width of the relationship lines. </theme_item> @@ -582,21 +530,72 @@ <theme_item name="scroll_speed" data_type="constant" type="int" default="12"> The speed of border scrolling. </theme_item> + <theme_item name="vseparation" data_type="constant" type="int" default="4"> + The vertical padding inside each item, i.e. the distance between the item's content and top/bottom border. + </theme_item> + <theme_item name="font" data_type="font" type="Font"> + [Font] of the item's text. + </theme_item> + <theme_item name="title_button_font" data_type="font" type="Font"> + [Font] of the title button's text. + </theme_item> + <theme_item name="font_size" data_type="font_size" type="int"> + Font size of the item's text. + </theme_item> + <theme_item name="arrow" data_type="icon" type="Texture2D"> + The arrow icon used when a foldable item is not collapsed. + </theme_item> + <theme_item name="arrow_collapsed" data_type="icon" type="Texture2D"> + The arrow icon used when a foldable item is collapsed (for left-to-right layouts). + </theme_item> + <theme_item name="arrow_collapsed_mirrored" data_type="icon" type="Texture2D"> + The arrow icon used when a foldable item is collapsed (for right-to-left layouts). + </theme_item> + <theme_item name="checked" data_type="icon" type="Texture2D"> + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked. + </theme_item> + <theme_item name="indeterminate" data_type="icon" type="Texture2D"> + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is indeterminate. + </theme_item> <theme_item name="select_arrow" data_type="icon" type="Texture2D"> The arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. </theme_item> + <theme_item name="unchecked" data_type="icon" type="Texture2D"> + The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is unchecked. + </theme_item> + <theme_item name="updown" data_type="icon" type="Texture2D"> + The updown arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. + </theme_item> + <theme_item name="bg" data_type="style" type="StyleBox"> + Default [StyleBox] for the [Tree], i.e. used when the control is not being focused. + </theme_item> + <theme_item name="bg_focus" data_type="style" type="StyleBox"> + [StyleBox] used when the [Tree] is being focused. + </theme_item> + <theme_item name="button_pressed" data_type="style" type="StyleBox"> + [StyleBox] used when a button in the tree is pressed. + </theme_item> + <theme_item name="cursor" data_type="style" type="StyleBox"> + [StyleBox] used for the cursor, when the [Tree] is being focused. + </theme_item> + <theme_item name="cursor_unfocused" data_type="style" type="StyleBox"> + [StyleBox] used for the cursor, when the [Tree] is not being focused. + </theme_item> + <theme_item name="custom_button" data_type="style" type="StyleBox"> + Default [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell. + </theme_item> + <theme_item name="custom_button_hover" data_type="style" type="StyleBox"> + [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. + </theme_item> + <theme_item name="custom_button_pressed" data_type="style" type="StyleBox"> + [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's pressed. + </theme_item> <theme_item name="selected" data_type="style" type="StyleBox"> [StyleBox] for the selected items, used when the [Tree] is not being focused. </theme_item> <theme_item name="selected_focus" data_type="style" type="StyleBox"> [StyleBox] for the selected items, used when the [Tree] is being focused. </theme_item> - <theme_item name="title_button_color" data_type="color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> - Default text [Color] of the title button. - </theme_item> - <theme_item name="title_button_font" data_type="font" type="Font"> - [Font] of the title button's text. - </theme_item> <theme_item name="title_button_hover" data_type="style" type="StyleBox"> [StyleBox] used when the title button is being hovered. </theme_item> @@ -606,14 +605,5 @@ <theme_item name="title_button_pressed" data_type="style" type="StyleBox"> [StyleBox] used when the title button is being pressed. </theme_item> - <theme_item name="unchecked" data_type="icon" type="Texture2D"> - The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is unchecked. - </theme_item> - <theme_item name="updown" data_type="icon" type="Texture2D"> - The updown arrow icon to display for the [constant TreeItem.CELL_MODE_RANGE] mode cell. - </theme_item> - <theme_item name="vseparation" data_type="constant" type="int" default="4"> - The vertical padding inside each item, i.e. the distance between the item's content and top/bottom border. - </theme_item> </theme_items> </class> diff --git a/doc/classes/VScrollBar.xml b/doc/classes/VScrollBar.xml index 0cf06576f6..09df3411d8 100644 --- a/doc/classes/VScrollBar.xml +++ b/doc/classes/VScrollBar.xml @@ -9,8 +9,8 @@ <tutorials> </tutorials> <members> - <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" override="true" default="0" /> - <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="1" /> + <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" overrides="Control" default="0" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="1" /> </members> <theme_items> <theme_item name="decrement" data_type="icon" type="Texture2D"> @@ -22,15 +22,6 @@ <theme_item name="decrement_pressed" data_type="icon" type="Texture2D"> Displayed when the decrement button is being pressed. </theme_item> - <theme_item name="grabber" data_type="style" type="StyleBox"> - Used as texture for the grabber, the draggable element representing current scroll. - </theme_item> - <theme_item name="grabber_highlight" data_type="style" type="StyleBox"> - Used when the mouse hovers over the grabber. - </theme_item> - <theme_item name="grabber_pressed" data_type="style" type="StyleBox"> - Used when the grabber is being dragged. - </theme_item> <theme_item name="increment" data_type="icon" type="Texture2D"> Icon used as a button to scroll the [ScrollBar] down. Supports custom step using the [member ScrollBar.custom_step] property. </theme_item> @@ -40,6 +31,15 @@ <theme_item name="increment_pressed" data_type="icon" type="Texture2D"> Displayed when the increment button is being pressed. </theme_item> + <theme_item name="grabber" data_type="style" type="StyleBox"> + Used as texture for the grabber, the draggable element representing current scroll. + </theme_item> + <theme_item name="grabber_highlight" data_type="style" type="StyleBox"> + Used when the mouse hovers over the grabber. + </theme_item> + <theme_item name="grabber_pressed" data_type="style" type="StyleBox"> + Used when the grabber is being dragged. + </theme_item> <theme_item name="scroll" data_type="style" type="StyleBox"> Used as background of this [ScrollBar]. </theme_item> diff --git a/doc/classes/VSlider.xml b/doc/classes/VSlider.xml index 286674a9b4..c1fea97ddc 100644 --- a/doc/classes/VSlider.xml +++ b/doc/classes/VSlider.xml @@ -10,29 +10,29 @@ <tutorials> </tutorials> <members> - <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" override="true" default="0" /> - <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="1" /> + <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" overrides="Control" default="0" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="1" /> </members> <theme_items> <theme_item name="grabber" data_type="icon" type="Texture2D"> The texture for the grabber (the draggable element). </theme_item> - <theme_item name="grabber_area" data_type="style" type="StyleBox"> - The background of the area below the grabber. - </theme_item> - <theme_item name="grabber_area_highlight" data_type="style" type="StyleBox"> - </theme_item> <theme_item name="grabber_disabled" data_type="icon" type="Texture2D"> The texture for the grabber when it's disabled. </theme_item> <theme_item name="grabber_highlight" data_type="icon" type="Texture2D"> The texture for the grabber when it's focused. </theme_item> - <theme_item name="slider" data_type="style" type="StyleBox"> - The background for the whole slider. Determines the width of the [code]grabber_area[/code]. - </theme_item> <theme_item name="tick" data_type="icon" type="Texture2D"> The texture for the ticks, visible when [member Slider.tick_count] is greater than 0. </theme_item> + <theme_item name="grabber_area" data_type="style" type="StyleBox"> + The background of the area below the grabber. + </theme_item> + <theme_item name="grabber_area_highlight" data_type="style" type="StyleBox"> + </theme_item> + <theme_item name="slider" data_type="style" type="StyleBox"> + The background for the whole slider. Determines the width of the [code]grabber_area[/code]. + </theme_item> </theme_items> </class> diff --git a/doc/classes/VSplitContainer.xml b/doc/classes/VSplitContainer.xml index 323ce1fe80..6316068e9d 100644 --- a/doc/classes/VSplitContainer.xml +++ b/doc/classes/VSplitContainer.xml @@ -12,13 +12,13 @@ <theme_item name="autohide" data_type="constant" type="int" default="1"> Boolean value. If 1 ([code]true[/code]), the grabber will hide automatically when it isn't under the cursor. If 0 ([code]false[/code]), it's always visible. </theme_item> - <theme_item name="bg" data_type="style" type="StyleBox"> + <theme_item name="separation" data_type="constant" type="int" default="12"> + The space between sides of the container. </theme_item> <theme_item name="grabber" data_type="icon" type="Texture2D"> The icon used for the grabber drawn in the middle area. </theme_item> - <theme_item name="separation" data_type="constant" type="int" default="12"> - The space between sides of the container. + <theme_item name="bg" data_type="style" type="StyleBox"> </theme_item> </theme_items> </class> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 595af6222c..15f7d2f9e3 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -125,16 +125,16 @@ </method> <method name="direction_to" qualifiers="const"> <return type="Vector2" /> - <argument index="0" name="b" type="Vector2" /> + <argument index="0" name="to" type="Vector2" /> <description> - Returns the normalized vector pointing from this vector to [code]b[/code]. This is equivalent to using [code](b - a).normalized()[/code]. + Returns the normalized vector pointing from this vector to [code]to[/code]. This is equivalent to using [code](b - a).normalized()[/code]. </description> </method> <method name="distance_squared_to" qualifiers="const"> <return type="float" /> <argument index="0" name="to" type="Vector2" /> <description> - Returns the squared distance between this vector and [code]b[/code]. + Returns the squared distance between this vector and [code]to[/code]. This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> @@ -358,19 +358,19 @@ </operator> <operator name="operator *"> <return type="Vector2" /> - <argument index="0" name="right" type="Vector2" /> + <argument index="0" name="right" type="Transform2D" /> <description> - Multiplies each component of the [Vector2] by the components of the given [Vector2]. - [codeblock] - print(Vector2(10, 20) * Vector2(3, 4)) # Prints "(30, 80)" - [/codeblock] + Inversely transforms (multiplies) the [Vector2] by the given [Transform2D] transformation matrix. </description> </operator> <operator name="operator *"> <return type="Vector2" /> - <argument index="0" name="right" type="Transform2D" /> + <argument index="0" name="right" type="Vector2" /> <description> - Inversely transforms (multiplies) the [Vector2] by the given [Transform2D] transformation matrix. + Multiplies each component of the [Vector2] by the components of the given [Vector2]. + [codeblock] + print(Vector2(10, 20) * Vector2(3, 4)) # Prints "(30, 80)" + [/codeblock] </description> </operator> <operator name="operator *"> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 62d467c505..6d87ce9ea8 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -86,7 +86,7 @@ <return type="Vector3" /> <argument index="0" name="with" type="Vector3" /> <description> - Returns the cross product of this vector and [code]b[/code]. + Returns the cross product of this vector and [code]with[/code]. </description> </method> <method name="cubic_interpolate" qualifiers="const"> @@ -101,31 +101,31 @@ </method> <method name="direction_to" qualifiers="const"> <return type="Vector3" /> - <argument index="0" name="b" type="Vector3" /> + <argument index="0" name="to" type="Vector3" /> <description> - Returns the normalized vector pointing from this vector to [code]b[/code]. This is equivalent to using [code](b - a).normalized()[/code]. + Returns the normalized vector pointing from this vector to [code]to[/code]. This is equivalent to using [code](b - a).normalized()[/code]. </description> </method> <method name="distance_squared_to" qualifiers="const"> <return type="float" /> - <argument index="0" name="b" type="Vector3" /> + <argument index="0" name="to" type="Vector3" /> <description> - Returns the squared distance between this vector and [code]b[/code]. + Returns the squared distance between this vector and [code]to[/code]. This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="distance_to" qualifiers="const"> <return type="float" /> - <argument index="0" name="b" type="Vector3" /> + <argument index="0" name="to" type="Vector3" /> <description> - Returns the distance between this vector and [code]b[/code]. + Returns the distance between this vector and [code]to[/code]. </description> </method> <method name="dot" qualifiers="const"> <return type="float" /> <argument index="0" name="with" type="Vector3" /> <description> - Returns the dot product of this vector and [code]b[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. + Returns the dot product of this vector and [code]with[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned. [b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code]. @@ -225,7 +225,7 @@ <return type="Basis" /> <argument index="0" name="with" type="Vector3" /> <description> - Returns the outer product with [code]b[/code]. + Returns the outer product with [code]with[/code]. </description> </method> <method name="posmod" qualifiers="const"> @@ -373,16 +373,6 @@ </operator> <operator name="operator *"> <return type="Vector3" /> - <argument index="0" name="right" type="Vector3" /> - <description> - Multiplies each component of the [Vector3] by the components of the given [Vector3]. - [codeblock] - print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)" - [/codeblock] - </description> - </operator> - <operator name="operator *"> - <return type="Vector3" /> <argument index="0" name="right" type="Basis" /> <description> Inversely transforms (multiplies) the [Vector3] by the given [Basis] matrix. @@ -404,6 +394,16 @@ </operator> <operator name="operator *"> <return type="Vector3" /> + <argument index="0" name="right" type="Vector3" /> + <description> + Multiplies each component of the [Vector3] by the components of the given [Vector3]. + [codeblock] + print(Vector3(10, 20, 30) * Vector3(3, 4, 5)) # Prints "(30, 80, 150)" + [/codeblock] + </description> + </operator> + <operator name="operator *"> + <return type="Vector3" /> <argument index="0" name="right" type="float" /> <description> Multiplies each component of the [Vector3] by the given [float]. diff --git a/doc/classes/VehicleBody3D.xml b/doc/classes/VehicleBody3D.xml index 9315f6e6ad..9960eeedc2 100644 --- a/doc/classes/VehicleBody3D.xml +++ b/doc/classes/VehicleBody3D.xml @@ -20,7 +20,7 @@ [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="mass" type="float" setter="set_mass" getter="get_mass" overrides="RigidDynamicBody3D" 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 VehicleWheel3D.use_as_steering] set to [code]true[/code] will automatically be rotated. </member> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index d83645a8af..4a3f99696d 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -25,13 +25,13 @@ <method name="find_world_2d" qualifiers="const"> <return type="World2D" /> <description> - Returns the 2D world of the viewport. + Returns the first valid [World2D] for this viewport, searching the [member world_2d] property of itself and any Viewport ancestor. </description> </method> <method name="find_world_3d" qualifiers="const"> <return type="World3D" /> <description> - Returns the 3D world of the viewport, or if none the world of the parent viewport. + Returns the first valid [World3D] for this viewport, searching the [member world_3d] property of itself and any Viewport ancestor. </description> </method> <method name="get_camera_2d" qualifiers="const"> @@ -194,6 +194,14 @@ <member name="disable_3d" type="bool" setter="set_disable_3d" getter="is_3d_disabled" default="false"> Disable 3D rendering (but keep 2D rendering). </member> + <member name="fsr_mipmap_bias" type="float" setter="set_fsr_mipmap_bias" getter="get_fsr_mipmap_bias" default="0.0"> + Affects the final texture sharpness by reading from a lower or higher mipmap when using FSR. Mipmap bias does nothing when FSR is not being used. Negative values make textures sharper, while positive values make textures blurrier. This value is used to adjust the mipmap bias calculated internally which is based on the selected quality. The formula for this is [code]-log2(1.0 / scale) + mipmap_bias[/code]. This updates the rendering server's mipmap bias when called + To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/fsr_mipmap_bias] project setting. + </member> + <member name="fsr_sharpness" type="float" setter="set_fsr_sharpness" getter="get_fsr_sharpness" default="0.2"> + Determines how sharp the upscaled image will be when using the FSR upscaling mode. Sharpness halves with every whole number. Values go from 0.0 (sharpest) to 2.0. Values above 2.0 won't make a visible difference. + To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/fsr_sharpness] project setting. + </member> <member name="global_canvas_transform" type="Transform2D" setter="set_global_canvas_transform" getter="get_global_canvas_transform"> The global canvas transform of the viewport. The canvas transform is relative to this. </member> @@ -210,7 +218,7 @@ <member name="lod_threshold" type="float" setter="set_lod_threshold" getter="get_lod_threshold" default="1.0"> </member> <member name="msaa" type="int" setter="set_msaa" getter="get_msaa" enum="Viewport.MSAA" default="0"> - The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. See also [member scale_3d] for supersampling, which provides higher quality but is much more expensive. + The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. See also bilinear scaling 3d [member scaling_3d_mode] for supersampling, which provides higher quality but is much more expensive. </member> <member name="own_world_3d" type="bool" setter="set_use_own_world_3d" getter="is_using_own_world_3d" default="false"> If [code]true[/code], the viewport will use the [World3D] defined in [member world_3d]. @@ -218,9 +226,14 @@ <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="scale_3d" type="float" setter="set_scale_3d" getter="get_scale_3d" default="1.0"> - Scales the 3D render buffer based on the viewport size and displays the result with linear filtering. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member msaa] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. - To control this property on the root viewport, set the [member ProjectSettings.rendering/3d/viewport/scale] project setting. + <member name="scaling_3d_mode" type="int" setter="set_scaling_3d_mode" getter="get_scaling_3d_mode" enum="Viewport.Scaling3DMode" default="0"> + Sets scaling 3d mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible. + To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/mode] project setting. + </member> + <member name="scaling_3d_scale" type="float" setter="set_scaling_3d_scale" getter="get_scaling_3d_scale" default="1.0"> + Scales the 3D render buffer based on the viewport size uses an image filter specified in [member ProjectSettings.rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa] for multi-sample antialiasing, which is significantly cheaper but only smoothens the edges of polygons. + When using FSR upscaling, AMD recommends exposing the following values as preset options to users "Ultra Quality: 0.77", "Quality: 0.67", "Balanced: 0.59", "Performance: 0.5" instead of exposing the entire scale. + To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/scale] project setting. </member> <member name="screen_space_aa" type="int" setter="set_screen_space_aa" getter="get_screen_space_aa" enum="Viewport.ScreenSpaceAA" default="0"> Sets the screen-space antialiasing method used. Screen-space antialiasing works by selectively blurring edges in a post-process shader. It differs from MSAA which takes multiple coverage samples while rendering objects. Screen-space AA methods are typically faster than MSAA and will smooth out specular aliasing, but tend to make scenes appear blurry. @@ -306,6 +319,15 @@ <constant name="SHADOW_ATLAS_QUADRANT_SUBDIV_MAX" value="7" enum="ShadowAtlasQuadrantSubdiv"> Represents the size of the [enum ShadowAtlasQuadrantSubdiv] enum. </constant> + <constant name="SCALING_3D_MODE_BILINEAR" value="0" enum="Scaling3DMode"> + Enables bilinear scaling on 3D viewports. The amount of scaling can be set using [member scaling_3d_scale]. Values less then [code]1.0[/code] will result in undersampling while values greater than [code]1.0[/code] will result in supersampling. A value of [code]1.0[/code] disables scaling. + </constant> + <constant name="SCALING_3D_MODE_FSR" value="1" enum="Scaling3DMode"> + Enables FSR upscaling on 3D viewports. The amount of scaling can be set using [member scaling_3d_scale]. Values less then [code]1.0[/code] will be result in the viewport being upscaled using FSR. Values greater than [code]1.0[/code] are not supported and bilinear supersampling will be used instead. A value of [code]1.0[/code] disables scaling. + </constant> + <constant name="SCALING_3D_MODE_MAX" value="2" enum="Scaling3DMode"> + Represents the size of the [enum Scaling3DMode] enum. + </constant> <constant name="MSAA_DISABLED" value="0" enum="MSAA"> Multisample antialiasing mode disabled. This is the default value, and is also the fastest setting. </constant> diff --git a/doc/classes/ViewportTexture.xml b/doc/classes/ViewportTexture.xml index c0cf3b3c7b..de32413fdd 100644 --- a/doc/classes/ViewportTexture.xml +++ b/doc/classes/ViewportTexture.xml @@ -14,7 +14,7 @@ <link title="3D Viewport Scaling Demo">https://godotengine.org/asset-library/asset/586</link> </tutorials> <members> - <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> + <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="true" /> <member name="viewport_path" type="NodePath" setter="set_viewport_path_in_scene" getter="get_viewport_path_in_scene" default="NodePath("")"> The path to the [Viewport] node to display. This is relative to the scene root, not to the node which uses the texture. </member> diff --git a/doc/classes/VisualShaderNodeIntFunc.xml b/doc/classes/VisualShaderNodeIntFunc.xml index d2782efa96..316529a347 100644 --- a/doc/classes/VisualShaderNodeIntFunc.xml +++ b/doc/classes/VisualShaderNodeIntFunc.xml @@ -23,7 +23,10 @@ <constant name="FUNC_SIGN" value="2" enum="Function"> Extracts the sign of the parameter. Translates to [code]sign(x)[/code] in the Godot Shader Language. </constant> - <constant name="FUNC_MAX" value="3" enum="Function"> + <constant name="FUNC_BITWISE_NOT" value="3" enum="Function"> + Returns the result of bitwise [code]NOT[/code] operation on the integer. Translates to [code]~a[/code] in the Godot Shader Language. + </constant> + <constant name="FUNC_MAX" value="4" enum="Function"> Represents the size of the [enum Function] enum. </constant> </constants> diff --git a/doc/classes/VisualShaderNodeIntOp.xml b/doc/classes/VisualShaderNodeIntOp.xml index e5fcafca81..c685592fd0 100644 --- a/doc/classes/VisualShaderNodeIntOp.xml +++ b/doc/classes/VisualShaderNodeIntOp.xml @@ -35,7 +35,22 @@ <constant name="OP_MIN" value="6" enum="Operator"> Returns the lesser of two numbers. Translates to [code]max(a, b)[/code] in the Godot Shader Language. </constant> - <constant name="OP_ENUM_SIZE" value="7" enum="Operator"> + <constant name="OP_BITWISE_AND" value="7" enum="Operator"> + Returns the result of bitwise [code]AND[/code] operation on the integer. Translates to [code]a & b[/code] in the Godot Shader Language. + </constant> + <constant name="OP_BITWISE_OR" value="8" enum="Operator"> + Returns the result of bitwise [code]OR[/code] operation for two integers. Translates to [code]a | b[/code] in the Godot Shader Language. + </constant> + <constant name="OP_BITWISE_XOR" value="9" enum="Operator"> + Returns the result of bitwise [code]XOR[/code] operation for two integers. Translates to [code]a ^ b[/code] in the Godot Shader Language. + </constant> + <constant name="OP_BITWISE_LEFT_SHIFT" value="10" enum="Operator"> + Returns the result of bitwise left shift operation on the integer. Translates to [code]a << b[/code] in the Godot Shader Language. + </constant> + <constant name="OP_BITWISE_RIGHT_SHIFT" value="11" enum="Operator"> + Returns the result of bitwise right shift operation on the integer. Translates to [code]a >> b[/code] in the Godot Shader Language. + </constant> + <constant name="OP_ENUM_SIZE" value="12" enum="Operator"> Represents the size of the [enum Operator] enum. </constant> </constants> diff --git a/doc/classes/VoxelGIData.xml b/doc/classes/VoxelGIData.xml index f0bd2a0601..36907c88ba 100644 --- a/doc/classes/VoxelGIData.xml +++ b/doc/classes/VoxelGIData.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="VoxelGIData" inherits="Resource" version="4.0"> <brief_description> + Contains baked voxel global illumination data for use in a [VoxelGI] node. </brief_description> <description> + [VoxelGIData] contains baked voxel global illumination for use in a [VoxelGI] node. [VoxelGIData] also offers several properties to adjust the final appearance of the global illumination. These properties can be adjusted at run-time without having to bake the [VoxelGI] node again. + [b]Note:[/b] To prevent text-based scene files ([code].tscn[/code]) from growing too much and becoming slow to load and save, always save [VoxelGIData] to an external binary resource file ([code].res[/code]) instead of embedding it within the scene. This can be done by clicking the dropdown arrow next to the [VoxelGIData] resource, choosing [b]Edit[/b], clicking the floppy disk icon at the top of the inspector then choosing [b]Save As...[/b]. </description> <tutorials> <link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link> @@ -23,6 +26,8 @@ <method name="get_bounds" qualifiers="const"> <return type="AABB" /> <description> + Returns the bounds of the baked voxel data as an [AABB], which should match [member VoxelGI.extents] after being baked (which only contains the size as a [Vector3]). + [b]Note:[/b] If the extents were modified without baking the VoxelGI data, then the value of [method get_bounds] and [member VoxelGI.extents] will not match. </description> </method> <method name="get_data_cells" qualifiers="const"> @@ -53,18 +58,25 @@ </methods> <members> <member name="bias" type="float" setter="set_bias" getter="get_bias" default="1.5"> + The normal bias to use for indirect lighting and reflections. Higher values reduce self-reflections visible in non-rough materials, at the cost of more visible light leaking and flatter-looking indirect lighting. To prioritize hiding self-reflections over lighting quality, set [member bias] to [code]0.0[/code] and [member normal_bias] to a value between [code]1.0[/code] and [code]2.0[/code]. </member> <member name="dynamic_range" type="float" setter="set_dynamic_range" getter="get_dynamic_range" default="4.0"> + The dynamic range to use ([code]1.0[/code] represents a low dynamic range scene brightness). Higher values can be used to provide brighter indirect lighting, at the cost of more visible color banding in dark areas (both in indirect lighting and reflections). To avoid color banding, it's recommended to use the lowest value that does not result in visible light clipping. </member> <member name="energy" type="float" setter="set_energy" getter="get_energy" default="1.0"> + The energy of the indirect lighting and reflections produced by the [VoxelGI] node. Higher values result in brighter indirect lighting. If indirect lighting looks too flat, try decreasing [member propagation] while increasing [member energy] at the same time. See also [member use_two_bounces] which influences the indirect lighting's effective brightness. </member> <member name="interior" type="bool" setter="set_interior" getter="is_interior" default="false"> + If [code]true[/code], [Environment] lighting is ignored by the [VoxelGI] node. If [code]false[/code], [Environment] lighting is taken into account by the [VoxelGI] node. [Environment] lighting updates in real-time, which means it can be changed without having to bake the [VoxelGI] node again. </member> <member name="normal_bias" type="float" setter="set_normal_bias" getter="get_normal_bias" default="0.0"> + The normal bias to use for indirect lighting and reflections. Higher values reduce self-reflections visible in non-rough materials, at the cost of more visible light leaking and flatter-looking indirect lighting. See also [member bias]. To prioritize hiding self-reflections over lighting quality, set [member bias] to [code]0.0[/code] and [member normal_bias] to a value between [code]1.0[/code] and [code]2.0[/code]. </member> <member name="propagation" type="float" setter="set_propagation" getter="get_propagation" default="0.7"> + If indirect lighting looks too flat, try decreasing [member propagation] while increasing [member energy] at the same time. See also [member use_two_bounces] which influences the indirect lighting's effective brightness. </member> <member name="use_two_bounces" type="bool" setter="set_use_two_bounces" getter="is_using_two_bounces" default="false"> + If [code]true[/code], performs two bounces of indirect lighting instead of one. This makes indirect lighting look more natural and brighter at a small performance cost. The second bounce is also visible in reflections. If the scene appears too bright after enabling [member use_two_bounces], adjust [member propagation] and [member energy]. </member> </members> </class> diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 3fee1feae8..c7ca6a20be 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -437,34 +437,34 @@ </constant> </constants> <theme_items> - <theme_item name="close" data_type="icon" type="Texture2D"> + <theme_item name="title_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> </theme_item> - <theme_item name="close_h_ofs" data_type="constant" type="int" default="18"> + <theme_item name="title_outline_modulate" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> + The color of the title outline. </theme_item> - <theme_item name="close_pressed" data_type="icon" type="Texture2D"> + <theme_item name="close_h_ofs" data_type="constant" type="int" default="18"> </theme_item> <theme_item name="close_v_ofs" data_type="constant" type="int" default="18"> </theme_item> - <theme_item name="embedded_border" data_type="style" type="StyleBox"> - </theme_item> <theme_item name="resize_margin" data_type="constant" type="int" default="4"> </theme_item> <theme_item name="scaleborder_size" data_type="constant" type="int" default="4"> </theme_item> - <theme_item name="title_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)"> + <theme_item name="title_height" data_type="constant" type="int" default="20"> + </theme_item> + <theme_item name="title_outline_size" data_type="constant" type="int" default="0"> + The size of the title outline. </theme_item> <theme_item name="title_font" data_type="font" type="Font"> </theme_item> <theme_item name="title_font_size" data_type="font_size" type="int"> The size of the title font. </theme_item> - <theme_item name="title_height" data_type="constant" type="int" default="20"> + <theme_item name="close" data_type="icon" type="Texture2D"> </theme_item> - <theme_item name="title_outline_modulate" data_type="color" type="Color" default="Color(1, 1, 1, 1)"> - The color of the title outline. + <theme_item name="close_pressed" data_type="icon" type="Texture2D"> </theme_item> - <theme_item name="title_outline_size" data_type="constant" type="int" default="0"> - The size of the title outline. + <theme_item name="embedded_border" data_type="style" type="StyleBox"> </theme_item> </theme_items> </class> diff --git a/doc/classes/float.xml b/doc/classes/float.xml index c96360e6ba..9effe9d5bf 100644 --- a/doc/classes/float.xml +++ b/doc/classes/float.xml @@ -62,10 +62,13 @@ </description> </operator> <operator name="operator *"> - <return type="float" /> - <argument index="0" name="right" type="float" /> + <return type="Color" /> + <argument index="0" name="right" type="Color" /> <description> - Multiplies two [float]s. + Multiplies each component of the [Color] by the given [float]. + [codeblock] + print(1.5 * Color(0.5, 0.5, 0.5)) # Color(0.75, 0.75, 0.75) + [/codeblock] </description> </operator> <operator name="operator *"> @@ -113,13 +116,10 @@ </description> </operator> <operator name="operator *"> - <return type="Color" /> - <argument index="0" name="right" type="Color" /> + <return type="float" /> + <argument index="0" name="right" type="float" /> <description> - Multiplies each component of the [Color] by the given [float]. - [codeblock] - print(1.5 * Color(0.5, 0.5, 0.5)) # Color(0.75, 0.75, 0.75) - [/codeblock] + Multiplies two [float]s. </description> </operator> <operator name="operator *"> diff --git a/doc/classes/int.xml b/doc/classes/int.xml index bb36d83741..d212fe42bf 100644 --- a/doc/classes/int.xml +++ b/doc/classes/int.xml @@ -132,20 +132,6 @@ </description> </operator> <operator name="operator *"> - <return type="int" /> - <argument index="0" name="right" type="int" /> - <description> - Multiplies two [int]s. - </description> - </operator> - <operator name="operator *"> - <return type="float" /> - <argument index="0" name="right" type="float" /> - <description> - Multiplies an [int] and a [float]. The result is a [float]. - </description> - </operator> - <operator name="operator *"> <return type="Vector2" /> <argument index="0" name="right" type="Vector2" /> <description> @@ -176,6 +162,20 @@ Multiplies each component of the [Vector3i] by the given [int]. </description> </operator> + <operator name="operator *"> + <return type="float" /> + <argument index="0" name="right" type="float" /> + <description> + Multiplies an [int] and a [float]. The result is a [float]. + </description> + </operator> + <operator name="operator *"> + <return type="int" /> + <argument index="0" name="right" type="int" /> + <description> + Multiplies two [int]s. + </description> + </operator> <operator name="operator +"> <return type="float" /> <argument index="0" name="right" type="float" /> diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py index b5e5cf8fa7..1523194a85 100755 --- a/doc/tools/make_rst.py +++ b/doc/tools/make_rst.py @@ -40,15 +40,15 @@ 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 + self, name, type_name, setter, getter, text, default_value, overrides + ): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]) -> None self.name = name self.type_name = type_name self.setter = setter self.getter = getter self.text = text self.default_value = default_value - self.overridden = overridden + self.overrides = overrides class ParameterDef: @@ -162,10 +162,10 @@ class State: default_value = property.get("default") or None if default_value is not None: default_value = "``{}``".format(default_value) - overridden = property.get("override") or False + overrides = property.get("overrides") or None property_def = PropertyDef( - property_name, type_name, setter, getter, property.text, default_value, overridden + property_name, type_name, setter, getter, property.text, default_value, overrides ) class_def.properties[property_name] = property_def @@ -520,8 +520,9 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S for property_def in class_def.properties.values(): type_rst = property_def.type_name.to_rst(state) default = property_def.default_value - if default is not None and property_def.overridden: - ml.append((type_rst, property_def.name, default + " *(parent override)*")) + if default is not None and property_def.overrides: + ref = ":ref:`{1}<class_{1}_property_{0}>`".format(property_def.name, property_def.overrides) + ml.append((type_rst, property_def.name, default + " (overrides " + ref + ")")) else: ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name) ml.append((type_rst, ref, default)) @@ -624,12 +625,12 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write("\n\n") # Property descriptions - if any(not p.overridden for p in class_def.properties.values()) > 0: + if any(not p.overrides for p in class_def.properties.values()) > 0: f.write(make_heading("Property Descriptions", "-")) index = 0 for property_def in class_def.properties.values(): - if property_def.overridden: + if property_def.overrides: continue if index != 0: diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index e66bde90fe..c7753e2c5c 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -421,7 +421,7 @@ RID RasterizerSceneGLES3::render_buffers_create() { return RID(); } -void RasterizerSceneGLES3::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { +void RasterizerSceneGLES3::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { } void RasterizerSceneGLES3::gi_set_use_half_resolution(bool p_enable) { diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index e8d257087f..14ab0eaa4a 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -203,7 +203,7 @@ public: void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) override; RID render_buffers_create() override; - void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override; + void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override; void gi_set_use_half_resolution(bool p_enable) override; void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) override; diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index f9443e11db..168080f2f1 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -758,6 +758,10 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener code += a + " - " + n + " * (" + a + " / " + n + "))"; } break; + case SL::OP_EMPTY: { + // Semicolon (or empty statement) - ignored. + } break; + default: { if (p_use_scope) { code += "("; diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index f07c654bd6..dc21d1d8e5 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -307,7 +307,8 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { if (!err) { return flags.st_mtime; } else { - ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + p_file + "."); + print_verbose("Failed to get modified time for: " + p_file + ""); + return 0; }; } diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index cbc870d385..67ee6ac856 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -102,7 +102,7 @@ public: class UnixTerminalLogger : public StdLogger { public: - virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR); + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR) override; virtual ~UnixTerminalLogger(); }; diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 4cae051302..952ee50074 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -8822,6 +8822,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context, bool p_local_de // get info about further features VulkanContext::MultiviewCapabilities multiview_capabilies = p_context->get_multiview_capabilities(); device_capabilities.supports_multiview = multiview_capabilies.is_supported && multiview_capabilies.max_view_count > 1; + device_capabilities.supports_fsr_half_float = p_context->get_shader_capabilities().shader_float16_is_supported && p_context->get_storage_buffer_capabilities().storage_buffer_16_bit_access_is_supported; } context = p_context; diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index c178a68236..5912f481ec 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -535,6 +535,24 @@ Error VulkanContext::_check_capabilities() { multiview_capabilities.is_supported = multiview_features.multiview; multiview_capabilities.geometry_shader_is_supported = multiview_features.multiviewGeometryShader; multiview_capabilities.tessellation_shader_is_supported = multiview_features.multiviewTessellationShader; + + VkPhysicalDeviceShaderFloat16Int8FeaturesKHR shader_features; + shader_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR; + shader_features.pNext = NULL; + + device_features.pNext = &shader_features; + + device_features_func(gpu, &device_features); + shader_capabilities.shader_float16_is_supported = shader_features.shaderFloat16; + + VkPhysicalDevice16BitStorageFeaturesKHR storage_feature; + storage_feature.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR; + storage_feature.pNext = NULL; + + device_features.pNext = &storage_feature; + + device_features_func(gpu, &device_features); + storage_buffer_capabilities.storage_buffer_16_bit_access_is_supported = storage_feature.storageBuffer16BitAccess; } // check extended properties diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index ae7c697be8..ab2f6a3eb5 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -66,6 +66,14 @@ public: uint32_t max_instance_count; }; + struct ShaderCapabilities { + bool shader_float16_is_supported; + }; + + struct StorageBufferCapabilities { + bool storage_buffer_16_bit_access_is_supported; + }; + private: enum { MAX_EXTENSIONS = 128, @@ -88,6 +96,8 @@ private: uint32_t vulkan_patch = 0; SubgroupCapabilities subgroup_capabilities; MultiviewCapabilities multiview_capabilities; + ShaderCapabilities shader_capabilities; + StorageBufferCapabilities storage_buffer_capabilities; String device_vendor; String device_name; @@ -239,6 +249,8 @@ public: uint32_t get_vulkan_minor() const { return vulkan_minor; }; SubgroupCapabilities get_subgroup_capabilities() const { return subgroup_capabilities; }; MultiviewCapabilities get_multiview_capabilities() const { return multiview_capabilities; }; + ShaderCapabilities get_shader_capabilities() const { return shader_capabilities; }; + StorageBufferCapabilities get_storage_buffer_capabilities() const { return storage_buffer_capabilities; }; VkDevice get_device(); VkPhysicalDevice get_physical_device(); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 035c44a28c..ff81622408 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -335,7 +335,8 @@ uint64_t FileAccessWindows::_get_modified_time(const String &p_file) { if (rv == 0) { return st.st_mtime; } else { - ERR_FAIL_V_MSG(0, "Failed to get modified time for: " + file + "."); + print_verbose("Failed to get modified time for: " + p_file + ""); + return 0; } } diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 3ca3576de6..dc0c62fbc9 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -847,7 +847,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i int event_index = item->get_meta("__index"); Array events = action["events"]; - events.remove(event_index); + events.remove_at(event_index); action["events"] = events; emit_signal(SNAME("action_edited"), action_name, action); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 6fce55f8e3..f36a2099d5 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -39,6 +39,7 @@ #include "editor_scale.h" #include "scene/animation/animation_player.h" #include "scene/main/window.h" +#include "scene/scene_string_names.h" #include "servers/audio/audio_stream.h" class AnimationTrackKeyEdit : public Object { @@ -3505,7 +3506,7 @@ void AnimationTrackEditor::make_insert_queue() { void AnimationTrackEditor::commit_insert_queue() { bool reset_allowed = true; AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player(); - if (player->has_animation("RESET") && player->get_animation("RESET") == animation) { + if (player->has_animation(SceneStringNames::get_singleton()->RESET) && player->get_animation(SceneStringNames::get_singleton()->RESET) == animation) { // Avoid messing with the reset animation itself. reset_allowed = false; } else { @@ -3925,15 +3926,15 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() { AnimationPlayer *player = AnimationPlayerEditor::get_singleton()->get_player(); - if (player->has_animation("RESET")) { - return player->get_animation("RESET"); + if (player->has_animation(SceneStringNames::get_singleton()->RESET)) { + return player->get_animation(SceneStringNames::get_singleton()->RESET); } else { Ref<Animation> reset_anim; reset_anim.instantiate(); reset_anim->set_length(ANIM_MIN_LENGTH); - undo_redo->add_do_method(player, "add_animation", "RESET", reset_anim); + undo_redo->add_do_method(player, "add_animation", SceneStringNames::get_singleton()->RESET, reset_anim); undo_redo->add_do_method(AnimationPlayerEditor::get_singleton(), "_animation_player_changed", player); - undo_redo->add_undo_method(player, "remove_animation", "RESET"); + undo_redo->add_undo_method(player, "remove_animation", SceneStringNames::get_singleton()->RESET); undo_redo->add_undo_method(AnimationPlayerEditor::get_singleton(), "_animation_player_changed", player); return reset_anim; } diff --git a/editor/audio_stream_preview.h b/editor/audio_stream_preview.h index 9cf47fd51a..8b83235b35 100644 --- a/editor/audio_stream_preview.h +++ b/editor/audio_stream_preview.h @@ -66,14 +66,13 @@ class AudioStreamPreviewGenerator : public Node { Thread *thread = nullptr; // Needed for the bookkeeping of the Map - Preview &operator=(const Preview &p_rhs) { + void operator=(const Preview &p_rhs) { preview = p_rhs.preview; base_stream = p_rhs.base_stream; playback = p_rhs.playback; generating.set_to(generating.is_set()); id = p_rhs.id; thread = p_rhs.thread; - return *this; } Preview(const Preview &p_rhs) { preview = p_rhs.preview; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index bfcd2dd4ca..1f01e9d4cf 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1314,10 +1314,10 @@ void CodeTextEditor::delete_lines() { int count = Math::abs(to_line - from_line) + 1; text_editor->set_caret_line(from_line, false); + text_editor->deselect(); for (int i = 0; i < count; i++) { _delete_line(from_line); } - text_editor->deselect(); } else { _delete_line(text_editor->get_caret_line()); } diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index b954c87476..d00fdd0ce7 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -240,7 +240,7 @@ void ConnectDialog::_remove_bind() { int idx = st.get_slice("/", 1).to_int() - 1; ERR_FAIL_INDEX(idx, cdbinds->params.size()); - cdbinds->params.remove(idx); + cdbinds->params.remove_at(idx); cdbinds->notify_changed(); } @@ -723,7 +723,7 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &item) { c = '_'; } else { // Remove any other characters. - midname.remove(i); + midname.remove_at(i); i--; continue; } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 72aea9b630..dec4f50f03 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -576,7 +576,7 @@ void CreateDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co drop_idx--; } - favorite_list.remove(from_idx); + favorite_list.remove_at(from_idx); if (ds < 0) { favorite_list.insert(drop_idx, type); diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index 2e0e6cb7c8..36fbf8adf1 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -192,10 +192,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::VECTOR2I: { int id = variable_id++; Vector2 vec = p_var; + const String type_scalar = Variant::get_type_name(p_var.get_type() == Variant::VECTOR2 ? Variant::FLOAT : Variant::INT); DAP::Variable x, y; x.name = "x"; y.name = "y"; - x.type = y.type = Variant::get_type_name(p_var.get_type() == Variant::VECTOR2 ? Variant::FLOAT : Variant::INT); + x.type = type_scalar; + y.type = type_scalar; x.value = rtos(vec.x); y.value = rtos(vec.y); @@ -209,12 +211,16 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::RECT2I: { int id = variable_id++; Rect2 rect = p_var; + const String type_scalar = Variant::get_type_name(p_var.get_type() == Variant::RECT2 ? Variant::FLOAT : Variant::INT); DAP::Variable x, y, w, h; x.name = "x"; y.name = "y"; w.name = "w"; h.name = "h"; - x.type = y.type = w.type = h.type = Variant::get_type_name(p_var.get_type() == Variant::RECT2 ? Variant::FLOAT : Variant::INT); + x.type = type_scalar; + y.type = type_scalar; + w.type = type_scalar; + h.type = type_scalar; x.value = rtos(rect.position.x); y.value = rtos(rect.position.y); w.value = rtos(rect.size.x); @@ -232,11 +238,14 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::VECTOR3I: { int id = variable_id++; Vector3 vec = p_var; + const String type_scalar = Variant::get_type_name(p_var.get_type() == Variant::VECTOR3 ? Variant::FLOAT : Variant::INT); DAP::Variable x, y, z; x.name = "x"; y.name = "y"; z.name = "z"; - x.type = y.type = z.type = Variant::get_type_name(p_var.get_type() == Variant::VECTOR3 ? Variant::FLOAT : Variant::INT); + x.type = type_scalar; + y.type = type_scalar; + z.type = type_scalar; x.value = rtos(vec.x); y.value = rtos(vec.y); z.value = rtos(vec.z); @@ -251,11 +260,14 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::TRANSFORM2D: { int id = variable_id++; Transform2D transform = p_var; + const String type_vec2 = Variant::get_type_name(Variant::VECTOR2); DAP::Variable x, y, origin; x.name = "x"; y.name = "y"; origin.name = "origin"; - x.type = y.type = origin.type = Variant::get_type_name(Variant::VECTOR2); + x.type = type_vec2; + y.type = type_vec2; + origin.type = type_vec2; x.value = transform.elements[0]; y.value = transform.elements[1]; origin.value = transform.elements[2]; @@ -291,12 +303,16 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::QUATERNION: { int id = variable_id++; Quaternion quat = p_var; + const String type_float = Variant::get_type_name(Variant::FLOAT); DAP::Variable x, y, z, w; x.name = "x"; y.name = "y"; z.name = "z"; w.name = "w"; - x.type = y.type = z.type = w.type = Variant::get_type_name(Variant::FLOAT); + x.type = type_float; + y.type = type_float; + z.type = type_float; + w.type = type_float; x.value = rtos(quat.x); y.value = rtos(quat.y); z.value = rtos(quat.z); @@ -313,10 +329,12 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::AABB: { int id = variable_id++; AABB aabb = p_var; + const String type_vec3 = Variant::get_type_name(Variant::VECTOR3); DAP::Variable position, size; position.name = "position"; size.name = "size"; - position.type = size.type = Variant::get_type_name(Variant::VECTOR3); + position.type = type_vec3; + size.type = type_vec3; position.value = aabb.position; size.value = aabb.size; position.variablesReference = parse_variant(aabb.position); @@ -331,11 +349,14 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::BASIS: { int id = variable_id++; Basis basis = p_var; + const String type_vec2 = Variant::get_type_name(Variant::VECTOR2); DAP::Variable x, y, z; x.name = "x"; y.name = "y"; z.name = "z"; - x.type = y.type = z.type = Variant::get_type_name(Variant::VECTOR2); + x.type = type_vec2; + y.type = type_vec2; + z.type = type_vec2; x.value = basis.elements[0]; y.value = basis.elements[1]; z.value = basis.elements[2]; @@ -372,12 +393,16 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) { case Variant::COLOR: { int id = variable_id++; Color color = p_var; + const String type_float = Variant::get_type_name(Variant::FLOAT); DAP::Variable r, g, b, a; r.name = "r"; g.name = "g"; b.name = "b"; a.name = "a"; - r.type = g.type = b.type = a.type = Variant::get_type_name(Variant::FLOAT); + r.type = type_float; + g.type = type_float; + b.type = type_float; + a.type = type_float; r.value = rtos(color.r); g.value = rtos(color.g); b.value = rtos(color.b); diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index e53f66e72e..9346b8f1af 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -55,9 +55,14 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) } void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->clear(); //sorry, no want category - for (const PropertyInfo &E : prop_list) { - p_list->push_back(E); + p_list->clear(); // Sorry, no want category. + for (const PropertyInfo &prop : prop_list) { + if (prop.name == "script") { + // Skip the script property, it's always added by the non-virtual method. + continue; + } + + p_list->push_back(prop); } } diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 391839d639..85cf1558fe 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -183,6 +183,11 @@ ScriptEditorDebugger *EditorDebuggerNode::get_default_debugger() const { return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0)); } +String EditorDebuggerNode::get_server_uri() const { + ERR_FAIL_COND_V(server.is_null(), ""); + return server->get_uri(); +} + Error EditorDebuggerNode::start(const String &p_uri) { stop(); ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 4d9e846834..135122db68 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -188,8 +188,9 @@ public: void set_camera_override(CameraOverride p_override); CameraOverride get_camera_override(); - Error start(const String &p_uri = "tcp://"); + String get_server_uri() const; + Error start(const String &p_uri = "tcp://"); void stop(); void add_debugger_plugin(const Ref<Script> &p_script); diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp index 8c3833af50..34904d55aa 100644 --- a/editor/debugger/editor_debugger_server.cpp +++ b/editor/debugger/editor_debugger_server.cpp @@ -41,15 +41,18 @@ class EditorDebuggerServerTCP : public EditorDebuggerServer { private: Ref<TCPServer> server; + String endpoint; public: static EditorDebuggerServer *create(const String &p_protocol); - virtual void poll() {} - virtual Error start(const String &p_uri); - virtual void stop(); - virtual bool is_active() const; - virtual bool is_connection_available() const; - virtual Ref<RemoteDebuggerPeer> take_connection(); + + virtual void poll() override {} + virtual String get_uri() const override; + virtual Error start(const String &p_uri) override; + virtual void stop() override; + virtual bool is_active() const override; + virtual bool is_connection_available() const override; + virtual Ref<RemoteDebuggerPeer> take_connection() override; EditorDebuggerServerTCP(); }; @@ -63,21 +66,42 @@ EditorDebuggerServerTCP::EditorDebuggerServerTCP() { server.instantiate(); } +String EditorDebuggerServerTCP::get_uri() const { + return endpoint; +} + Error EditorDebuggerServerTCP::start(const String &p_uri) { - int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + // Default host and port String bind_host = (String)EditorSettings::get_singleton()->get("network/debug/remote_host"); + int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + + // Optionally override if (!p_uri.is_empty() && p_uri != "tcp://") { String scheme, path; Error err = p_uri.parse_url(scheme, bind_host, bind_port, path); ERR_FAIL_COND_V(err != OK, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(!bind_host.is_valid_ip_address() && bind_host != "*", ERR_INVALID_PARAMETER); } - const Error err = server->listen(bind_port, bind_host); - if (err != OK) { - EditorNode::get_log()->add_message(String("Error listening on port ") + itos(bind_port), EditorLog::MSG_TYPE_ERROR); - return err; + + // Try listening on ports + const int max_attempts = 5; + for (int attempt = 1;; ++attempt) { + const Error err = server->listen(bind_port, bind_host); + if (err == OK) { + break; + } + if (attempt >= max_attempts) { + EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, remote debugging unavailable.", bind_port), EditorLog::MSG_TYPE_ERROR); + return err; + } + int last_port = bind_port++; + EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, trying %d instead.", last_port, bind_port), EditorLog::MSG_TYPE_WARNING); } - return err; + + // Endpoint that the client should connect to + endpoint = vformat("tcp://%s:%d", bind_host, bind_port); + + return OK; } void EditorDebuggerServerTCP::stop() { diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h index 844d1a9e5a..6a4ca895d1 100644 --- a/editor/debugger/editor_debugger_server.h +++ b/editor/debugger/editor_debugger_server.h @@ -47,8 +47,10 @@ public: static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func); static EditorDebuggerServer *create(const String &p_protocol); + + virtual String get_uri() const = 0; virtual void poll() = 0; - virtual Error start(const String &p_uri = "") = 0; + virtual Error start(const String &p_uri) = 0; virtual void stop() = 0; virtual bool is_active() const = 0; virtual bool is_connection_available() const = 0; diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 5ce57e936a..f1d427648a 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -341,11 +341,17 @@ void DocTools::generate(bool p_basic_types) { } DocData::PropertyDoc prop; - prop.name = E.name; - prop.overridden = inherited; + if (inherited) { + String parent = ClassDB::get_parent_class(c.name); + while (!ClassDB::has_property(parent, prop.name, true)) { + parent = ClassDB::get_parent_class(parent); + } + prop.overrides = parent; + } + bool default_value_valid = false; Variant default_value; @@ -603,6 +609,8 @@ void DocTools::generate(bool p_basic_types) { tid.data_type = "style"; c.theme_properties.push_back(tid); } + + c.theme_properties.sort(); } classes.pop_front(); @@ -1355,7 +1363,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str const DocData::PropertyDoc &p = c.properties[i]; if (c.properties[i].overridden) { - _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" override=\"true\"" + additional_attributes + " />"); + _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" overrides=\"" + p.overrides + "\"" + additional_attributes + " />"); } else { _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">"); _write_string(f, 3, p.description.strip_edges().xml_escape()); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index e1aaa060c6..eb54bb3efb 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -230,11 +230,10 @@ private: render_db_value = n.render_db_value; } - _FORCE_INLINE_ AudioNotch &operator=(const EditorAudioMeterNotches::AudioNotch &n) { + _FORCE_INLINE_ void operator=(const EditorAudioMeterNotches::AudioNotch &n) { relative_position = n.relative_position; db_value = n.db_value; render_db_value = n.render_db_value; - return *this; } _FORCE_INLINE_ AudioNotch() {} diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index aee9c21007..6fd8cb47ea 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -70,7 +70,7 @@ void EditorHistory::cleanup_history() { } if (fail) { - history.remove(i); + history.remove_at(i); i--; } } @@ -510,7 +510,7 @@ void EditorData::remove_custom_type(const String &p_type) { for (Map<String, Vector<CustomType>>::Element *E = custom_types.front(); E; E = E->next()) { for (int i = 0; i < E->get().size(); i++) { if (E->get()[i].name == p_type) { - E->get().remove(i); + E->get().remove_at(i); if (E->get().is_empty()) { custom_types.erase(E->key()); } @@ -570,7 +570,7 @@ void EditorData::remove_scene(int p_idx) { ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path); } - edited_scene.remove(p_idx); + edited_scene.remove_at(p_idx); } bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) { @@ -751,7 +751,7 @@ void EditorData::move_edited_scene_to_index(int p_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); EditedScene es = edited_scene[current_edited_scene]; - edited_scene.remove(current_edited_scene); + edited_scene.remove_at(current_edited_scene); edited_scene.insert(p_idx, es); current_edited_scene = p_idx; } @@ -893,8 +893,13 @@ bool EditorData::script_class_is_parent(const String &p_class, const String &p_i if (!ScriptServer::is_global_class(p_class)) { return false; } - String base = script_class_get_base(p_class); + Ref<Script> script = script_class_load_script(p_class); + if (script.is_null()) { + return false; + } + + String base = script_class_get_base(p_class); Ref<Script> base_script = script->get_base_script(); while (p_inherits != base) { diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index e78ca7cd64..55a2c319fe 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -488,8 +488,8 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S String cur_dir_no_prefix = cur_dir.replace("res://", ""); Vector<String> dirs; - String f; - while ((f = da->get_next()) != "") { + String f = da->get_next(); + while (!f.is_empty()) { if (da->current_is_dir()) { dirs.push_back(f); } else { @@ -506,6 +506,7 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S } } } + f = da->get_next(); } da->list_dir_end(); @@ -1534,7 +1535,7 @@ Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) { } void EditorExport::remove_export_preset(int p_idx) { - export_presets.remove(p_idx); + export_presets.remove_at(p_idx); save_presets(); } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 2d7c31b64c..ec8651ac7c 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -302,7 +302,7 @@ void EditorFileDialog::_post_popup() { bool exists = dir_access->dir_exists(recentd[i]); if (!exists) { // Remove invalid directory from the list of Recent directories. - recentd.remove(i--); + recentd.remove_at(i--); } else { recent->add_item(name, folder); recent->set_item_metadata(recent->get_item_count() - 1, recentd[i]); @@ -761,10 +761,11 @@ void EditorFileDialog::update_file_list() { List<String> files; List<String> dirs; - String item; + String item = dir_access->get_next(); - while ((item = dir_access->get_next()) != "") { + while (!item.is_empty()) { if (item == "." || item == "..") { + item = dir_access->get_next(); continue; } @@ -775,6 +776,7 @@ void EditorFileDialog::update_file_list() { dirs.push_back(item); } } + item = dir_access->get_next(); } dirs.sort_custom<NaturalNoCaseComparator>(); @@ -1445,7 +1447,7 @@ void EditorFileDialog::_save_to_recent() { for (int i = 0; i < recent.size(); i++) { bool cres = recent[i].begins_with("res://"); if (recent[i] == dir || (res == cres && count > max)) { - recent.remove(i); + recent.remove_at(i); i--; } else { count++; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index d141447044..4f02a82fb5 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -577,7 +577,7 @@ bool EditorFileSystem::_update_scan_actions() { ERR_CONTINUE(idx == -1); _delete_internal_files(ia.dir->files[idx]->file); memdelete(ia.dir->files[idx]); - ia.dir->files.remove(idx); + ia.dir->files.remove_at(idx); fs_changed = true; @@ -1536,7 +1536,7 @@ void EditorFileSystem::update_file(const String &p_file) { } } memdelete(fs->files[cpos]); - fs->files.remove(cpos); + fs->files.remove_at(cpos); } call_deferred(SNAME("emit_signal"), "filesystem_changed"); //update later diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 29e3236ac2..c98606730c 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -262,10 +262,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { if (E.type == Variant::OBJECT) { RES res = p_object->get(E.name); - print_line("res: " + String(E.name) + " valid " + itos(res.is_valid())); - if (res.is_valid()) { - print_line("path " + res->get_path()); - } if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { resources.insert(res); _do_object_unfolds(res.ptr(), resources); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index f520877256..c95b1c753e 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -237,8 +237,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->push_cell(); class_desc->push_paragraph(RichTextLabel::ALIGN_RIGHT, Control::TEXT_DIRECTION_AUTO, ""); } else { - static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; - class_desc->add_text(String(prefix)); + _add_bulletpoint(); } _add_type(p_method.return_type, p_method.return_enum); @@ -314,6 +313,11 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview } } +void EditorHelp::_add_bulletpoint() { + static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; + class_desc->add_text(String(prefix)); +} + Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (!doc->class_list.has(p_class)) { return ERR_DOES_NOT_EXIST; @@ -669,7 +673,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); class_desc->push_font(doc_code_font); class_desc->push_indent(1); - class_desc->push_table(2); + class_desc->push_table(4); class_desc->set_table_column_expand(1, true); for (int i = 0; i < cd.properties.size(); i++) { @@ -679,13 +683,14 @@ void EditorHelp::_update_doc() { } property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + // Property type. class_desc->push_cell(); class_desc->push_paragraph(RichTextLabel::ALIGN_RIGHT, Control::TEXT_DIRECTION_AUTO, ""); class_desc->push_font(doc_code_font); _add_type(cd.properties[i].type, cd.properties[i].enumeration); class_desc->pop(); class_desc->pop(); - class_desc->pop(); + class_desc->pop(); // cell bool describe = false; @@ -706,6 +711,7 @@ void EditorHelp::_update_doc() { describe = false; } + // Property name. class_desc->push_cell(); class_desc->push_font(doc_code_font); class_desc->push_color(headline_color); @@ -721,18 +727,43 @@ void EditorHelp::_update_doc() { property_descr = true; } + class_desc->pop(); + class_desc->pop(); + class_desc->pop(); // cell + + // Property value. + class_desc->push_cell(); + class_desc->push_font(doc_code_font); + if (cd.properties[i].default_value != "") { class_desc->push_color(symbol_color); - class_desc->add_text(cd.properties[i].overridden ? " [" + TTR("override:") + " " : " [" + TTR("default:") + " "); + if (cd.properties[i].overridden) { + class_desc->add_text(" ["); + class_desc->push_meta("@member " + cd.properties[i].overrides + "." + cd.properties[i].name); + _add_text(vformat(TTR("overrides %s:"), cd.properties[i].overrides)); + class_desc->pop(); + class_desc->add_text(" "); + } else { + class_desc->add_text(" [" + TTR("default:") + " "); + } class_desc->pop(); + class_desc->push_color(value_color); _add_text(_fix_constant(cd.properties[i].default_value)); class_desc->pop(); + class_desc->push_color(symbol_color); class_desc->add_text("]"); class_desc->pop(); } + class_desc->pop(); + class_desc->pop(); // cell + + // Property setters and getters. + class_desc->push_cell(); + class_desc->push_font(doc_code_font); + if (cd.is_script_doc && (cd.properties[i].setter != "" || cd.properties[i].getter != "")) { class_desc->push_color(symbol_color); class_desc->add_text(" [" + TTR("property:") + " "); @@ -760,12 +791,10 @@ void EditorHelp::_update_doc() { } class_desc->pop(); - class_desc->pop(); - - class_desc->pop(); + class_desc->pop(); // cell } - class_desc->pop(); //table + class_desc->pop(); // table class_desc->pop(); class_desc->pop(); // font class_desc->add_newline(); @@ -837,27 +866,54 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->pop(); + class_desc->add_newline(); + class_desc->add_newline(); + class_desc->push_indent(1); - class_desc->push_table(2); - class_desc->set_table_column_expand(1, true); + + String theme_data_type; + Map<String, String> data_type_names; + data_type_names["color"] = TTR("Colors"); + data_type_names["constant"] = TTR("Constants"); + data_type_names["font"] = TTR("Fonts"); + data_type_names["font_size"] = TTR("Font Sizes"); + data_type_names["icon"] = TTR("Icons"); + data_type_names["style"] = TTR("Styles"); for (int i = 0; i < cd.theme_properties.size(); i++) { theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description - class_desc->push_cell(); - class_desc->push_paragraph(RichTextLabel::ALIGN_RIGHT, Control::TEXT_DIRECTION_AUTO, ""); + if (theme_data_type != cd.theme_properties[i].data_type) { + theme_data_type = cd.theme_properties[i].data_type; + + class_desc->push_color(title_color); + class_desc->push_font(doc_title_font); + if (data_type_names.has(theme_data_type)) { + class_desc->add_text(data_type_names[theme_data_type]); + } else { + class_desc->add_text(""); + } + class_desc->pop(); + class_desc->pop(); + + class_desc->add_newline(); + class_desc->add_newline(); + } + + // Theme item header. class_desc->push_font(doc_code_font); + _add_bulletpoint(); + + // Theme item object type. _add_type(cd.theme_properties[i].type); - class_desc->pop(); - class_desc->pop(); - class_desc->pop(); - class_desc->push_cell(); - class_desc->push_font(doc_code_font); + // Theme item name. class_desc->push_color(headline_color); + class_desc->add_text(" "); _add_text(cd.theme_properties[i].name); class_desc->pop(); + // Theme item default value. if (cd.theme_properties[i].default_value != "") { class_desc->push_color(symbol_color); class_desc->add_text(" [" + TTR("default:") + " "); @@ -870,23 +926,25 @@ void EditorHelp::_update_doc() { class_desc->pop(); } - class_desc->pop(); + class_desc->pop(); // monofont + // Theme item description. if (cd.theme_properties[i].description != "") { class_desc->push_font(doc_font); class_desc->push_color(comment_color); - class_desc->add_text(U" – "); + class_desc->push_indent(1); _add_text(DTR(cd.theme_properties[i].description)); - class_desc->pop(); - class_desc->pop(); + class_desc->pop(); // indent + class_desc->pop(); // color + class_desc->pop(); // font } - class_desc->pop(); // cell + + class_desc->add_newline(); + class_desc->add_newline(); } - class_desc->pop(); // table class_desc->pop(); class_desc->add_newline(); - class_desc->add_newline(); } // Signals @@ -909,10 +967,10 @@ void EditorHelp::_update_doc() { for (int i = 0; i < cd.signals.size(); i++) { signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + class_desc->push_font(doc_code_font); // monofont class_desc->push_color(headline_color); - static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; - class_desc->add_text(String(prefix)); + _add_bulletpoint(); _add_text(cd.signals[i].name); class_desc->pop(); class_desc->push_color(symbol_color); @@ -1043,8 +1101,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_code_font); class_desc->push_color(headline_color); - static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; - class_desc->add_text(String(prefix)); + _add_bulletpoint(); _add_text(enum_list[i].name); class_desc->pop(); class_desc->push_color(symbol_color); @@ -1054,10 +1111,12 @@ void EditorHelp::_update_doc() { _add_text(_fix_constant(enum_list[i].value)); class_desc->pop(); class_desc->pop(); - if (enum_list[i].description != "") { + + class_desc->add_newline(); + + if (enum_list[i].description.strip_edges() != "") { class_desc->push_font(doc_font); class_desc->push_color(comment_color); - class_desc->add_text(U" – "); _add_text(DTR(enum_list[i].description)); class_desc->pop(); class_desc->pop(); @@ -1103,13 +1162,11 @@ void EditorHelp::_update_doc() { Vector<float> color = stripped.split_floats(","); if (color.size() >= 3) { class_desc->push_color(Color(color[0], color[1], color[2])); - static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; - class_desc->add_text(String(prefix)); + _add_bulletpoint(); class_desc->pop(); } } else { - static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; - class_desc->add_text(String(prefix)); + _add_bulletpoint(); } class_desc->push_color(headline_color); @@ -1123,10 +1180,12 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->pop(); + + class_desc->add_newline(); + if (constants[i].description != "") { class_desc->push_font(doc_font); class_desc->push_color(comment_color); - class_desc->add_text(U" – "); _add_text(DTR(constants[i].description)); class_desc->pop(); class_desc->pop(); @@ -1167,8 +1226,7 @@ void EditorHelp::_update_doc() { class_desc->push_cell(); class_desc->push_font(doc_code_font); - static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; - class_desc->add_text(String(prefix)); + _add_bulletpoint(); _add_type(cd.properties[i].type, cd.properties[i].enumeration); class_desc->add_text(" "); diff --git a/editor/editor_help.h b/editor/editor_help.h index c0f3f66505..393e4a940a 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -145,6 +145,8 @@ class EditorHelp : public VBoxContainer { void _add_type(const String &p_type, const String &p_enum = String()); void _add_method(const DocData::MethodDoc &p_method, bool p_overview = true); + void _add_bulletpoint(); + void _class_list_select(const String &p_select); void _class_desc_select(const String &p_select); void _class_desc_input(const Ref<InputEvent> &p_input); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 2729b1eb3b..a6cd07dab3 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1608,11 +1608,11 @@ void EditorInspectorArray::_move_element(int p_element_index, int p_to_pos) { properties_as_array.insert(p_to_pos < 0 ? properties_as_array.size() : p_to_pos, Dictionary()); } else if (p_to_pos < 0) { // Delete the element. - properties_as_array.remove(p_element_index); + properties_as_array.remove_at(p_element_index); } else { // Move the element. properties_as_array.insert(p_to_pos, properties_as_array[p_element_index].duplicate()); - properties_as_array.remove(p_to_pos < p_element_index ? p_element_index + 1 : p_element_index); + properties_as_array.remove_at(p_to_pos < p_element_index ? p_element_index + 1 : p_element_index); } // Change the array size then set the properties. @@ -2194,10 +2194,7 @@ void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> & for (int i = idx; i < inspector_plugin_count - 1; i++) { inspector_plugins[i] = inspector_plugins[i + 1]; } - - if (idx == inspector_plugin_count - 1) { - inspector_plugins[idx] = Ref<EditorInspectorPlugin>(); - } + inspector_plugins[inspector_plugin_count - 1] = Ref<EditorInspectorPlugin>(); inspector_plugin_count--; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 69a59b7ddb..2cf4a3395f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -831,7 +831,7 @@ void EditorNode::_remove_plugin_from_enabled(const String &p_name) { PackedStringArray enabled_plugins = ps->get("editor_plugins/enabled"); for (int i = 0; i < enabled_plugins.size(); ++i) { if (enabled_plugins.get(i) == p_name) { - enabled_plugins.remove(i); + enabled_plugins.remove_at(i); break; } } @@ -2315,8 +2315,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); String run_filename; - String args; - bool skip_breakpoints; if (p_current || (editor_data.get_edited_scene_root() && p_custom != String() && p_custom == editor_data.get_edited_scene_root()->get_scene_file_path())) { Node *scene = editor_data.get_edited_scene_root(); @@ -2371,17 +2369,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) { make_bottom_panel_item_visible(log); } - List<String> breakpoints; - editor_data.get_editor_breakpoints(&breakpoints); - - args = ProjectSettings::get_singleton()->get("editor/run/main_run_args"); - skip_breakpoints = EditorDebuggerNode::get_singleton()->is_skip_breakpoints(); - EditorDebuggerNode::get_singleton()->start(); - Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints); + Error error = editor_run.run(run_filename); if (error != OK) { EditorDebuggerNode::get_singleton()->stop(); - show_accept(TTR("Could not start subprocess!"), TTR("OK")); + show_accept(TTR("Could not start subprocess(es)!"), TTR("OK")); return; } @@ -3199,7 +3191,7 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan } memdelete(singleton->main_editor_buttons[i]); - singleton->main_editor_buttons.remove(i); + singleton->main_editor_buttons.remove_at(i); break; } @@ -3758,7 +3750,7 @@ void EditorNode::_open_recent_scene(int p_idx) { ERR_FAIL_INDEX(p_idx, rc.size()); if (load_scene(rc[p_idx]) != OK) { - rc.remove(p_idx); + rc.remove_at(p_idx); EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc); _update_recent_scenes(); } @@ -4244,7 +4236,6 @@ void EditorNode::_dock_make_float() { Size2 dock_size = dock->get_size() + borders * 2; // remember size Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders; - print_line("dock pos: " + dock->get_global_position() + " window pos: " + get_tree()->get_root()->get_position()); int dock_index = dock->get_index(); dock_slot[dock_popup_selected]->remove_child(dock); @@ -5177,7 +5168,7 @@ void EditorNode::remove_bottom_panel_item(Control *p_item) { bottom_panel_vb->remove_child(bottom_panel_items[i].control); bottom_panel_hb_editors->remove_child(bottom_panel_items[i].button); memdelete(bottom_panel_items[i].button); - bottom_panel_items.remove(i); + bottom_panel_items.remove_at(i); break; } } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index a3b6f6e59b..0f59c8281f 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -413,7 +413,7 @@ void EditorPropertyArray::update_property() { void EditorPropertyArray::_remove_pressed(int p_index) { Variant array = object->get_array(); - array.call("remove", p_index); + array.call("remove_at", p_index); emit_changed(get_edited_property(), array, "", false); update_property(); diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index d7daa0c750..3f4418d5f2 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -31,6 +31,7 @@ #include "editor_run.h" #include "core/config/project_settings.h" +#include "editor/editor_node.h" #include "editor_settings.h" #include "servers/display_server.h" @@ -42,20 +43,17 @@ String EditorRun::get_running_scene() const { return running_scene; } -Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints) { +Error EditorRun::run(const String &p_scene) { List<String> args; String resource_path = ProjectSettings::get_singleton()->get_resource_path(); - String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host"); - int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); - - if (resource_path != "") { + if (!resource_path.is_empty()) { args.push_back("--path"); args.push_back(resource_path.replace(" ", "%20")); } args.push_back("--remote-debug"); - args.push_back("tcp://" + remote_host + ":" + String::num(remote_port)); + args.push_back(EditorDebuggerNode::get_singleton()->get_server_uri()); args.push_back("--allow_focus_steal_pid"); args.push_back(itos(OS::get_singleton()->get_process_id())); @@ -162,10 +160,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } break; } - if (p_breakpoints.size()) { + List<String> breakpoints; + EditorNode::get_editor_data().get_editor_breakpoints(&breakpoints); + + if (!breakpoints.is_empty()) { args.push_back("--breakpoints"); String bpoints; - for (const List<String>::Element *E = p_breakpoints.front(); E; E = E->next()) { + for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) { bpoints += E->get().replace(" ", "%20"); if (E->next()) { bpoints += ","; @@ -175,7 +176,7 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L args.push_back(bpoints); } - if (p_skip_breakpoints) { + if (EditorDebuggerNode::get_singleton()->is_skip_breakpoints()) { args.push_back("--skip-breakpoints"); } @@ -185,23 +186,24 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L String exec = OS::get_singleton()->get_executable_path(); - if (p_custom_args != "") { + const String raw_custom_args = ProjectSettings::get_singleton()->get("editor/run/main_run_args"); + if (!raw_custom_args.is_empty()) { // Allow the user to specify a command to run, similar to Steam's launch options. // In this case, Godot will no longer be run directly; it's up to the underlying command // to run it. For instance, this can be used on Linux to force a running project // to use Optimus using `prime-run` or similar. // Example: `prime-run %command% --time-scale 0.5` - const int placeholder_pos = p_custom_args.find("%command%"); + const int placeholder_pos = raw_custom_args.find("%command%"); Vector<String> custom_args; if (placeholder_pos != -1) { // Prepend executable-specific custom arguments. // If nothing is placed before `%command%`, behave as if no placeholder was specified. - Vector<String> exec_args = p_custom_args.substr(0, placeholder_pos).split(" ", false); + Vector<String> exec_args = raw_custom_args.substr(0, placeholder_pos).split(" ", false); if (exec_args.size() >= 1) { exec = exec_args[0]; - exec_args.remove(0); + exec_args.remove_at(0); // Append the Godot executable name before we append executable arguments // (since the order is reversed when using `push_front()`). @@ -214,13 +216,13 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } // Append Godot-specific custom arguments. - custom_args = p_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false); + custom_args = raw_custom_args.substr(placeholder_pos + String("%command%").size()).split(" ", false); for (int i = 0; i < custom_args.size(); i++) { args.push_back(custom_args[i].replace(" ", "%20")); } } else { // Append Godot-specific custom arguments. - custom_args = p_custom_args.split(" ", false); + custom_args = raw_custom_args.split(" ", false); for (int i = 0; i < custom_args.size(); i++) { args.push_back(custom_args[i].replace(" ", "%20")); } diff --git a/editor/editor_run.h b/editor/editor_run.h index d6cf3fed71..3bfe28e1ad 100644 --- a/editor/editor_run.h +++ b/editor/editor_run.h @@ -50,7 +50,7 @@ private: public: Status get_status() const; String get_running_scene() const; - Error run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints = false); + Error run(const String &p_scene); void run_native_notify() { status = STATUS_PLAY; } void stop(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 7ae3dcd44f..abe20c693b 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -46,6 +46,7 @@ #include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" +#include "shader_create_dialog.h" Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, String p_file_type) { Ref<Texture2D> file_icon; @@ -197,7 +198,7 @@ Vector<String> FileSystemDock::_compute_uncollapsed_paths() { child = child->get_next(); } } - needs_check.remove(0); + needs_check.remove_at(0); } } } @@ -1093,7 +1094,7 @@ void FileSystemDock::_push_to_history() { history_pos++; if (history.size() > history_max_size) { - history.remove(0); + history.remove_at(0); history_pos = history_max_size - 1; } } @@ -1670,7 +1671,7 @@ Vector<String> FileSystemDock::_remove_self_included_paths(Vector<String> select String last_path = ""; for (int i = 0; i < selected_strings.size(); i++) { if (last_path != "" && selected_strings[i].begins_with(last_path)) { - selected_strings.remove(i); + selected_strings.remove_at(i); i--; } if (selected_strings[i].ends_with("/")) { @@ -1704,7 +1705,7 @@ void FileSystemDock::_tree_rmb_option(int p_option) { child = child->get_next(); } - needs_check.remove(0); + needs_check.remove_at(0); } } } break; @@ -1967,6 +1968,22 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected } void FileSystemDock::_resource_created() { + String fpath = path; + if (!fpath.ends_with("/")) { + fpath = fpath.get_base_dir(); + } + + String type_name = new_resource_dialog->get_selected_type(); + if (type_name == "Shader") { + make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 0); + make_shader_dialog->popup_centered(); + return; + } else if (type_name == "VisualShader") { + make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 1); + make_shader_dialog->popup_centered(); + return; + } + Variant c = new_resource_dialog->instance_selected(); ERR_FAIL_COND(!c); @@ -1982,12 +1999,6 @@ void FileSystemDock::_resource_created() { } editor->push_item(r); - - String fpath = path; - if (!fpath.ends_with("/")) { - fpath = fpath.get_base_dir(); - } - editor->save_resource_as(RES(r), fpath); } @@ -2229,7 +2240,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, drop_position -= offset; to_remove.sort(); for (int i = 0; i < to_remove.size(); i++) { - dirs.remove(to_remove[i] - i); + dirs.remove_at(to_remove[i] - i); } // Re-add them at the right position. @@ -2997,6 +3008,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { make_script_dialog->set_title(TTR("Create Script")); add_child(make_script_dialog); + make_shader_dialog = memnew(ShaderCreateDialog); + add_child(make_shader_dialog); + new_resource_dialog = memnew(CreateDialog); add_child(new_resource_dialog); new_resource_dialog->set_base_type("Resource"); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 7c3851b94f..34b445f1b3 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -54,6 +54,7 @@ #include "script_create_dialog.h" class EditorNode; +class ShaderCreateDialog; class FileSystemDock : public VBoxContainer { GDCLASS(FileSystemDock, VBoxContainer); @@ -158,6 +159,7 @@ private: LineEdit *make_scene_dialog_text; ConfirmationDialog *overwrite_dialog; ScriptCreateDialog *make_script_dialog; + ShaderCreateDialog *make_shader_dialog; CreateDialog *new_resource_dialog; bool always_show_folders; diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 19b4943e6d..c34379f1ec 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -2024,7 +2024,7 @@ void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton bool Collada::_remove_node(Node *p_parent, Node *p_node) { for (int i = 0; i < p_parent->children.size(); i++) { if (p_parent->children[i] == p_node) { - p_parent->children.remove(i); + p_parent->children.remove_at(i); return true; } if (_remove_node(p_parent->children[i], p_node)) { @@ -2038,7 +2038,7 @@ bool Collada::_remove_node(Node *p_parent, Node *p_node) { void Collada::_remove_node(VisualScene *p_vscene, Node *p_node) { for (int i = 0; i < p_vscene->root_nodes.size(); i++) { if (p_vscene->root_nodes[i] == p_node) { - p_vscene->root_nodes.remove(i); + p_vscene->root_nodes.remove_at(i); return; } if (_remove_node(p_vscene->root_nodes[i], p_node)) { @@ -2271,7 +2271,7 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L for (int i = 0; i < p_node->children.size(); i++) { if (_move_geometry_to_skeletons(p_vscene, p_node->children[i], p_mgeom)) { - p_node->children.remove(i); + p_node->children.remove_at(i); i--; } } @@ -2325,7 +2325,7 @@ void Collada::_optimize() { for (int i = 0; i < vs.root_nodes.size(); i++) { List<Node *> mgeom; if (_move_geometry_to_skeletons(&vs, vs.root_nodes[i], &mgeom)) { - vs.root_nodes.remove(i); + vs.root_nodes.remove_at(i); i--; } diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 3fdf5dd9db..048d84d1f9 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -134,7 +134,7 @@ static void _plot_triangle(Vector2i *vertices, const Vector2i &p_offset, bool p_ int max_y = MIN(y[2], height - p_offset.y - 1); for (int yi = y[0]; yi < max_y; yi++) { if (yi >= 0) { - for (int xi = (xf > 0 ? int(xf) : 0); xi < (xt < src_width ? xt : src_width - 1); xi++) { + for (int xi = (xf > 0 ? int(xf) : 0); xi < (xt <= src_width ? xt : src_width); xi++) { int px = xi, py = yi; int sx = px, sy = py; sx = CLAMP(sx, 0, src_width - 1); diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 3fe1aa557d..7458f617c3 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -98,7 +98,7 @@ void LocalizationEditor::_translation_delete(Object *p_item, int p_column, int p ERR_FAIL_INDEX(idx, translations.size()); - translations.remove(idx); + translations.remove_at(idx); undo_redo->create_action(TTR("Remove Translation")); undo_redo->add_do_property(ProjectSettings::get_singleton(), "internationalization/locale/translations", translations); @@ -276,7 +276,7 @@ void LocalizationEditor::_translation_res_option_delete(Object *p_item, int p_co ERR_FAIL_COND(!remaps.has(key)); PackedStringArray r = remaps[key]; ERR_FAIL_INDEX(idx, r.size()); - r.remove(idx); + r.remove_at(idx); remaps[key] = r; undo_redo->create_action(TTR("Remove Resource Remap Option")); @@ -321,7 +321,7 @@ void LocalizationEditor::_translation_filter_option_changed() { } } else { if (l_idx != -1) { - f_locales.remove(l_idx); + f_locales.remove_at(l_idx); } } @@ -397,7 +397,7 @@ void LocalizationEditor::_pot_delete(Object *p_item, int p_column, int p_button) ERR_FAIL_INDEX(idx, pot_translations.size()); - pot_translations.remove(idx); + pot_translations.remove_at(idx); undo_redo->create_action(TTR("Remove file from POT generation")); undo_redo->add_do_property(ProjectSettings::get_singleton(), "internationalization/locale/translations_pot_files", pot_translations); @@ -497,7 +497,7 @@ void LocalizationEditor::update_translations() { TreeItem *t = translation_filter->create_item(root); t->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - t->set_text(0, n); + t->set_text(0, vformat("[%s] %s", l, n)); t->set_editable(0, true); t->set_tooltip(0, l); t->set_checked(0, is_checked); @@ -537,7 +537,7 @@ void LocalizationEditor::update_translations() { if (langnames.length() > 0) { langnames += ","; } - langnames += names[i]; + langnames += vformat("[%s] %s", langs[i], names[i]); translation_locales_idxs_remap.write[l_idx] = i; l_idx++; } @@ -546,7 +546,7 @@ void LocalizationEditor::update_translations() { if (i > 0) { langnames += ","; } - langnames += names[i]; + langnames += vformat("[%s] %s", langs[i], names[i]); } } diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 7cafbbc1c4..58f92a98a6 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -446,7 +446,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) if (k->get_keycode() == Key::KEY_DELETE || k->get_keycode() == Key::BACKSPACE) { if (wip_active && selected_point.polygon == -1) { if (wip.size() > selected_point.vertex) { - wip.remove(selected_point.vertex); + wip.remove_at(selected_point.vertex); _wip_changed(); selected_point = wip.size() - 1; canvas_item_editor->update_viewport(); @@ -599,7 +599,7 @@ void AbstractPolygon2DEditor::remove_point(const Vertex &p_vertex) { Vector<Vector2> vertices = _get_polygon(p_vertex.polygon); if (vertices.size() > (_is_line() ? 2 : 3)) { - vertices.remove(p_vertex.vertex); + vertices.remove_at(p_vertex.vertex); undo_redo->create_action(TTR("Edit Polygon (Remove Point)")); _action_set_polygon(p_vertex.polygon, vertices); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 2aded41810..c4a938f91d 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -58,7 +58,7 @@ void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const R void AnimationNodeBlendTreeEditor::remove_custom_type(const Ref<Script> &p_script) { for (int i = 0; i < add_options.size(); i++) { if (add_options[i].script == p_script) { - add_options.remove(i); + add_options.remove_at(i); return; } } @@ -945,7 +945,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { add_node->set_text(TTR("Add Node...")); graph->get_zoom_hbox()->move_child(add_node, 0); add_node->get_popup()->connect("id_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_add_node)); - add_node->connect("about_to_popup", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu)); + add_node->connect("about_to_popup", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu), varray(false)); add_options.push_back(AddOption("Animation", "AnimationNodeAnimation")); add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot", 2)); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 226046f250..f936871bce 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -42,6 +42,7 @@ #include "editor/plugins/node_3d_editor_plugin.h" // For onion skinning. #include "scene/main/window.h" #include "scene/resources/animation.h" +#include "scene/scene_string_names.h" #include "servers/rendering_server.h" void AnimationPlayerEditor::_node_removed(Node *p_node) { @@ -836,12 +837,12 @@ void AnimationPlayerEditor::_update_player() { for (const StringName &E : animlist) { Ref<Texture2D> icon; if (E == player->get_autoplay()) { - if (E == "RESET") { + if (E == SceneStringNames::get_singleton()->RESET) { icon = autoplay_reset_icon; } else { icon = autoplay_icon; } - } else if (E == "RESET") { + } else if (E == SceneStringNames::get_singleton()->RESET) { icon = reset_icon; } animation->add_icon_item(icon, E); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ecc404f903..aa46eef21f 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -242,7 +242,7 @@ bool CanvasItemEditor::_is_node_movable(const Node *p_node, bool p_popup_warning } if (Object::cast_to<Control>(p_node) && Object::cast_to<Container>(p_node->get_parent())) { if (p_popup_warning) { - _popup_warning_temporarily(warning_child_of_container, 3.0); + EditorToaster::get_singleton()->popup_str("Children of a container get their position and size determined only by their parent.", EditorToaster::SEVERITY_WARNING); } return false; } @@ -658,7 +658,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel //Remove the item if invalid if (!canvas_item || duplicate || (canvas_item != scene && canvas_item->get_owner() != scene && !scene->is_editable_instance(canvas_item->get_owner())) || (!p_allow_locked && _is_node_locked(canvas_item))) { - r_items.remove(i); + r_items.remove_at(i); i--; } else { r_items.write[i].item = canvas_item; @@ -1045,7 +1045,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve } } else { if (dragged_guide_index >= 0) { - vguides.remove(dragged_guide_index); + vguides.remove_at(dragged_guide_index); undo_redo->create_action(TTR("Remove Vertical Guide")); if (vguides.is_empty()) { undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "remove_meta", "_edit_vertical_guides_"); @@ -1078,7 +1078,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve } } else { if (dragged_guide_index >= 0) { - hguides.remove(dragged_guide_index); + hguides.remove_at(dragged_guide_index); undo_redo->create_action(TTR("Remove Horizontal Guide")); if (hguides.is_empty()) { undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "remove_meta", "_edit_horizontal_guides_"); @@ -2339,7 +2339,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (selection2.size() > 0) { drag_type = DRAG_MOVE; - drag_from = click; + drag_from = drag_start_origin; _save_canvas_item_state(drag_selection); } return true; @@ -2913,14 +2913,6 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 corner = Point2(begin.x, end.y); Vector2 length_vector = (begin - end).abs() / zoom; - bool draw_secondary_lines = !(Math::is_equal_approx(begin.y, corner.y) || Math::is_equal_approx(end.x, corner.x)); - - viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3)); - if (draw_secondary_lines) { - viewport->draw_line(begin, corner, ruler_secondary_color, Math::round(EDSCALE)); - viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE)); - } - Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); @@ -2936,8 +2928,24 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 text_pos = (begin + end) / 2 - Vector2(text_width / 2, text_height / 2); text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5); text_pos.y = CLAMP(text_pos.y, text_height * 1.5, viewport->get_rect().size.y - text_height * 1.5); + + if (begin.is_equal_approx(end)) { + viewport->draw_string(font, text_pos, (String)ruler_tool_origin, HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + return; + } + viewport->draw_string(font, text_pos, TS->format_number(vformat("%.1f px", length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); + bool draw_secondary_lines = !(Math::is_equal_approx(begin.y, corner.y) || Math::is_equal_approx(end.x, corner.x)); + + viewport->draw_line(begin, end, ruler_primary_color, Math::round(EDSCALE * 3)); + if (draw_secondary_lines) { + viewport->draw_line(begin, corner, ruler_secondary_color, Math::round(EDSCALE)); + viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE)); + } + if (draw_secondary_lines) { const real_t horizontal_angle_rad = length_vector.angle(); const real_t vertical_angle_rad = Math_PI / 2.0 - horizontal_angle_rad; @@ -3665,8 +3673,6 @@ void CanvasItemEditor::_draw_viewport() { group_button->set_disabled(selection.is_empty()); ungroup_button->set_visible(all_group); - info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); - _draw_grid(); _draw_ruler_tool(); _draw_axis(); @@ -3919,11 +3925,6 @@ void CanvasItemEditor::_notification(int p_what) { anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignWide"), SNAME("EditorIcons")), TTR("Full Rect"), ANCHORS_PRESET_WIDE); anchor_mode_button->set_icon(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); - - info_overlay->get_theme()->set_stylebox("normal", "Label", get_theme_stylebox(SNAME("CanvasItemInfoOverlay"), SNAME("EditorStyles"))); - warning_child_of_container->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - warning_child_of_container->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); - warning_child_of_container->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -4079,34 +4080,6 @@ void CanvasItemEditor::_update_scrollbars() { updating_scroll = false; } -void CanvasItemEditor::_popup_warning_depop(Control *p_control) { - ERR_FAIL_COND(!popup_temporarily_timers.has(p_control)); - - Timer *timer = popup_temporarily_timers[p_control]; - timer->queue_delete(); - p_control->hide(); - popup_temporarily_timers.erase(p_control); - info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); -} - -void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const double p_duration) { - Timer *timer; - if (!popup_temporarily_timers.has(p_control)) { - timer = memnew(Timer); - timer->connect("timeout", callable_mp(this, &CanvasItemEditor::_popup_warning_depop), varray(p_control)); - timer->set_one_shot(true); - add_child(timer); - - popup_temporarily_timers[p_control] = timer; - } else { - timer = popup_temporarily_timers[p_control]; - } - - timer->start(p_duration); - p_control->show(); - info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); -} - void CanvasItemEditor::_update_scroll(real_t) { if (updating_scroll) { return; @@ -5136,19 +5109,6 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { viewport->update(); } -void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) { - ERR_FAIL_COND(!p_control); - - p_control->set_h_size_flags(p_control->get_h_size_flags() & ~Control::SIZE_EXPAND_FILL); - info_overlay->add_child(p_control); - info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); -} - -void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) { - info_overlay->remove_child(p_control); - info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); -} - void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { ERR_FAIL_COND(!p_control); @@ -5281,23 +5241,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { viewport->connect("draw", callable_mp(this, &CanvasItemEditor::_draw_viewport)); viewport->connect("gui_input", callable_mp(this, &CanvasItemEditor::_gui_input_viewport)); - info_overlay = memnew(VBoxContainer); - info_overlay->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT); - info_overlay->set_offset(SIDE_LEFT, 10); - info_overlay->set_offset(SIDE_BOTTOM, -15); - info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN); - info_overlay->add_theme_constant_override("separation", 10); - viewport_scrollable->add_child(info_overlay); - - // Make sure all labels inside of the container are styled the same. - Theme *info_overlay_theme = memnew(Theme); - info_overlay->set_theme(info_overlay_theme); - - warning_child_of_container = memnew(Label); - warning_child_of_container->hide(); - warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent.")); - add_control_to_info_overlay(warning_child_of_container); - h_scroll = memnew(HScrollBar); viewport->add_child(h_scroll); h_scroll->connect("value_changed", callable_mp(this, &CanvasItemEditor::_update_scroll)); @@ -5332,7 +5275,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { select_button->set_pressed(true); select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), Key::Q)); select_button->set_shortcut_context(this); - select_button->set_tooltip(keycode_get_string((Key)KeyModifierMask::CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD) + TTR("RMB: Add node at position clicked.")); + select_button->set_tooltip(keycode_get_string((Key)KeyModifierMask::CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD) + TTR("Alt+Drag: Scale selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + keycode_get_string((Key)KeyModifierMask::CMD) + TTR("RMB: Add node at position clicked.")); hb->add_child(memnew(VSeparator)); @@ -5361,7 +5304,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_SCALE)); scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTR("Scale Mode"), Key::S)); scale_button->set_shortcut_context(this); - scale_button->set_tooltip(TTR("Scale Mode")); + scale_button->set_tooltip(TTR("Shift: Scale proportionally.")); hb->add_child(memnew(VSeparator)); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 286771ee08..b6576b7144 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -235,11 +235,6 @@ private: PanelContainer *context_menu_container; HBoxContainer *hbc_context_menu; - Map<Control *, Timer *> popup_temporarily_timers; - - Label *warning_child_of_container; - VBoxContainer *info_overlay; - Transform2D transform; bool show_grid; bool show_rulers; @@ -536,8 +531,6 @@ private: VSplitContainer *bottom_split; void _update_context_menu_stylebox(); - void _popup_warning_temporarily(Control *p_control, const double p_duration); - void _popup_warning_depop(Control *p_control); void _set_owner_for_node_and_children(Node *p_node, Node *p_owner); @@ -578,9 +571,6 @@ public: void add_control_to_menu_panel(Control *p_control); void remove_control_from_menu_panel(Control *p_control); - void add_control_to_info_overlay(Control *p_control); - void remove_control_from_info_overlay(Control *p_control); - HSplitContainer *get_palette_split(); VSplitContainer *get_bottom_split(); diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 7a8680c4dd..4c728ff757 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -285,7 +285,7 @@ EditorPlugin::AfterGUIInput CollisionPolygon3DEditor::forward_spatial_gui_input( if (closest_idx >= 0) { undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node, "set_polygon", poly); - poly.remove(closest_idx); + poly.remove_at(closest_idx); undo_redo->add_do_method(node, "set_polygon", poly); undo_redo->add_do_method(this, "_polygon_draw"); undo_redo->add_undo_method(this, "_polygon_draw"); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index daf34903e6..d99d6709ad 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -460,7 +460,7 @@ void CurveEditor::remove_point(int index) { Curve::Point p = _curve_ref->get_point(index); ur.add_do_method(*_curve_ref, "remove_point", index); - ur.add_undo_method(*_curve_ref, "add_point", p.pos, p.left_tangent, p.right_tangent, p.left_mode, p.right_mode); + ur.add_undo_method(*_curve_ref, "add_point", p.position, p.left_tangent, p.right_tangent, p.left_mode, p.right_mode); if (index == _selected_point) { set_selected_point(-1); diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 44c789b145..4b50f484a4 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -57,6 +57,27 @@ void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) { emission_mask->popup_centered(); } +void GPUParticles2DEditorPlugin::_selection_changed() { + List<Node *> selected_nodes = editor->get_editor_selection()->get_selected_node_list(); + + if (selected_particles.is_empty() && selected_nodes.is_empty()) { + return; + } + + for (GPUParticles2D *SP : selected_particles) { + SP->set_show_visibility_rect(false); + } + selected_particles.clear(); + + for (Node *P : selected_nodes) { + GPUParticles2D *selected_particle = Object::cast_to<GPUParticles2D>(P); + if (selected_particle != nullptr) { + selected_particle->set_show_visibility_rect(true); + selected_particles.push_back(selected_particle); + } + } +} + void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { switch (p_idx) { case MENU_GENERATE_VISIBILITY_RECT: { @@ -334,6 +355,7 @@ void GPUParticles2DEditorPlugin::_notification(int p_what) { menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons"))); file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); + EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &GPUParticles2DEditorPlugin::_selection_changed)); } } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index 0b2028b745..bdfc021aa7 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -56,6 +56,7 @@ class GPUParticles2DEditorPlugin : public EditorPlugin { }; GPUParticles2D *particles; + List<GPUParticles2D *> selected_particles; EditorFileDialog *file; EditorNode *editor; @@ -79,6 +80,7 @@ class GPUParticles2DEditorPlugin : public EditorPlugin { void _menu_callback(int p_idx); void _generate_visibility_rect(); void _generate_emission_mask(); + void _selection_changed(); protected: void _notification(int p_what); diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index 6df2e34ceb..57279c57e7 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -68,32 +68,36 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { return; } + // Set information tooltip on the Bake button. This information is useful + // to optimize performance (video RAM size) and reduce collision tunneling (individual cell size). + const Vector3i size = col_sdf->get_estimated_cell_size(); - String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z); - int data_size = 2; - const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2)); + const Vector3 extents = col_sdf->get_extents(); - if (bake_info->get_text() == text) { - return; + int data_size = 2; + const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); + // Add a qualitative measurement to help the user assess whether a GPUParticlesCollisionSDF node is using a lot of VRAM. + String size_quality; + if (size_mb < 8.0) { + size_quality = TTR("Low"); + } else if (size_mb < 32.0) { + size_quality = TTR("Moderate"); + } else { + size_quality = TTR("High"); } - // Color the label depending on the estimated performance level. - Color color; - if (size_mb <= 16.0 + CMP_EPSILON) { - // Fast. - color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); - } else if (size_mb <= 64.0 + CMP_EPSILON) { - // Medium. - color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - } else { - // Slow. - color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); + String text; + text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; + text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; + text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); + + // Only update the tooltip when needed to avoid constant redrawing. + if (bake->get_tooltip(Point2()) == text) { + return; } - bake_info->add_theme_color_override("font_color", color); - bake_info->set_text(text); + bake->set_tooltip(text); } } @@ -178,10 +182,6 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito bake->set_text(TTR("Bake SDF")); bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake)); bake_hb->add_child(bake); - bake_info = memnew(Label); - bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL); - bake_info->set_clip_text(true); - bake_hb->add_child(bake_info); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); col_sdf = nullptr; diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h index 5a71fc44ef..26b8b352d6 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h @@ -42,7 +42,6 @@ class GPUParticlesCollisionSDFEditorPlugin : public EditorPlugin { GPUParticlesCollisionSDF *col_sdf; HBoxContainer *bake_hb; - Label *bake_info; Button *bake; EditorNode *editor; diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 74fbef3caf..1f5d68929a 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -244,8 +244,10 @@ void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) RS::get_singleton()->instance_geometry_set_flag(instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); } -void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material, const Transform3D &p_xform, const Ref<SkinReference> &p_skin_reference) { +void EditorNode3DGizmo::add_mesh(const Ref<Mesh> &p_mesh, const Ref<Material> &p_material, const Transform3D &p_xform, const Ref<SkinReference> &p_skin_reference) { ERR_FAIL_COND(!spatial_node); + ERR_FAIL_COND_MSG(!p_mesh.is_valid(), "EditorNode3DGizmo.add_mesh() requires a valid Mesh resource."); + Instance ins; ins.mesh = p_mesh; @@ -2579,7 +2581,7 @@ void CPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { 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; + gizmo_color.a = MAX((gizmo_color.a - 0.2) * 0.02, 0.0); create_material("particles_solid_material", gizmo_color); create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoGPUParticles3D"), SNAME("EditorIcons"))); create_handle_material("handles"); @@ -2869,7 +2871,6 @@ void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo * void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Node3D *cs = p_gizmo->get_spatial_node(); - print_line("redraw request " + itos(cs != nullptr)); p_gizmo->clear(); const Ref<Material> material = diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 56e4ad5518..cf9a464b69 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -45,7 +45,7 @@ class EditorNode3DGizmo : public Node3DGizmo { struct Instance { RID instance; - Ref<ArrayMesh> mesh; + Ref<Mesh> mesh; Ref<Material> material; Ref<SkinReference> skin_reference; bool extra_margin = false; @@ -95,7 +95,7 @@ protected: public: void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); - void add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material = Ref<Material>(), const Transform3D &p_xform = Transform3D(), const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>()); + void add_mesh(const Ref<Mesh> &p_mesh, const Ref<Material> &p_material = Ref<Material>(), const Transform3D &p_xform = Transform3D(), const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>()); void add_collision_segments(const Vector<Vector3> &p_lines); void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); void add_unscaled_billboard(const Ref<Material> &p_material, real_t p_scale = 1, const Color &p_modulate = Color(1, 1, 1)); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index d6e6f0597a..51086d47b7 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1238,7 +1238,7 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { Node3D *item = selection_results[i].item; if (item != scene && item->get_owner() != scene && item != scene->get_deepest_editable_node(item)) { //invalid result - selection_results.remove(i); + selection_results.remove_at(i); i--; } } @@ -1749,7 +1749,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } else { const bool movement_threshold_passed = _edit.original_mouse_pos.distance_to(_edit.mouse_pos) > 8 * EDSCALE; if (clicked.is_valid() && movement_threshold_passed) { - _compute_edit(_edit.mouse_pos); + _compute_edit(_edit.original_mouse_pos); clicked = ObjectID(); _edit.mode = TRANSFORM_TRANSLATE; @@ -4048,7 +4048,23 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po if (mesh != nullptr) { MeshInstance3D *mesh_instance = memnew(MeshInstance3D); mesh_instance->set_mesh(mesh); - mesh_instance->set_name(path.get_file().get_basename()); + + // Adjust casing according to project setting. The file name is expected to be in snake_case, but will work for others. + String name = path.get_file().get_basename(); + switch (ProjectSettings::get_singleton()->get("editor/node_naming/name_casing").operator int()) { + case NAME_CASING_PASCAL_CASE: + name = name.capitalize().replace(" ", ""); + break; + case NAME_CASING_CAMEL_CASE: + name = name.capitalize().replace(" ", ""); + name[0] = name.to_lower()[0]; + break; + case NAME_CASING_SNAKE_CASE: + name = name.capitalize().replace(" ", "_").to_lower(); + break; + } + mesh_instance->set_name(name); + instantiated_scene = mesh_instance; } else { if (!scene.is_valid()) { // invalid scene @@ -4221,10 +4237,9 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_ if (root_node) { target_node = root_node; } else { - accept->set_text(TTR("Cannot drag and drop into scene with no root node.")); - accept->popup_centered(); - _remove_preview(); - return; + // Create a root node so we can add child nodes to it. + EditorNode::get_singleton()->get_scene_tree_dock()->add_root_node(memnew(Node3D)); + target_node = get_tree()->get_edited_scene_root(); } } else { accept->set_text(TTR("Cannot drag and drop into multiple selected nodes.")); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 6ffe99d4d0..79cfcbec64 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -584,10 +584,10 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { return; } - uv_create_poly_prev.remove(closest); - uv_create_uv_prev.remove(closest); + uv_create_poly_prev.remove_at(closest); + uv_create_uv_prev.remove_at(closest); if (uv_create_colors_prev.size()) { - uv_create_colors_prev.remove(closest); + uv_create_colors_prev.remove_at(closest); } undo_redo->create_action(TTR("Remove Internal Vertex")); @@ -599,7 +599,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { undo_redo->add_undo_method(node, "set_vertex_colors", node->get_vertex_colors()); for (int i = 0; i < node->get_bone_count(); i++) { Vector<float> bonew = node->get_bone_weights(i); - bonew.remove(closest); + bonew.remove_at(closest); undo_redo->add_do_method(node, "set_bone_weights", i, bonew); undo_redo->add_undo_method(node, "set_bone_weights", i, node->get_bone_weights(i)); } @@ -702,7 +702,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (erase_index != -1) { - polygons.remove(erase_index); + polygons.remove_at(erase_index); undo_redo->create_action(TTR("Remove Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 583862893c..aeb6ba13d5 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -733,7 +733,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { return; } - rc.remove(p_idx); + rc.remove_at(p_idx); EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", rc); _update_recent_scripts(); _show_error_dialog(path); @@ -785,7 +785,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { for (int i = 0; i < history.size(); i++) { if (history[i].control == tselected) { - history.remove(i); + history.remove_at(i); i--; history_pos--; } @@ -1415,8 +1415,12 @@ void ScriptEditor::_menu_option(int p_option) { } break; case SHOW_IN_FILE_SYSTEM: { const RES script = current->get_edited_resource(); - const String path = script->get_path(); + String path = script->get_path(); if (!path.is_empty()) { + if (script->is_built_in()) { + path = path.get_slice("::", 0); // Show the scene instead. + } + FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock(); file_system_dock->navigate_to_path(path); // Ensure that the FileSystem dock is visible. diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 5f21c8c881..bb5ef0f6eb 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -964,6 +964,7 @@ void Skeleton3DEditor::select_bone(int p_idx) { Skeleton3DEditor::~Skeleton3DEditor() { if (skeleton) { + select_bone(-1); #ifdef TOOLS_ENABLED skeleton->disconnect("show_rest_only_changed", callable_mp(this, &Skeleton3DEditor::_update_gizmo_visible)); skeleton->disconnect("bone_enabled_changed", callable_mp(this, &Skeleton3DEditor::_bone_enabled_changed)); @@ -973,6 +974,7 @@ Skeleton3DEditor::~Skeleton3DEditor() { #endif handles_mesh_instance->get_parent()->remove_child(handles_mesh_instance); } + edit_mode_toggled(false); handles_mesh_instance->queue_delete(); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index f94439f344..f62dbfc2cc 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -2581,11 +2581,11 @@ void ThemeTypeEditor::_update_type_items() { } // Various type settings. - if (ClassDB::class_exists(edited_type)) { + if (edited_type.is_empty() || ClassDB::class_exists(edited_type)) { type_variation_edit->set_editable(false); type_variation_edit->set_text(""); type_variation_button->hide(); - type_variation_locked->show(); + type_variation_locked->set_visible(!edited_type.is_empty()); } else { type_variation_edit->set_editable(true); type_variation_edit->set_text(edited_theme->get_type_variation_base(edited_type)); diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index f13fcb005f..86b0fc0eaf 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -157,6 +157,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even emit_signal(SNAME("control_picked"), theme_type); picker_button->set_pressed(false); picker_overlay->set_visible(false); + return; } } @@ -167,6 +168,9 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even hovered_control = _find_hovered_control(preview_content, mp); picker_overlay->update(); } + + // Forward input to the scroll container underneath to allow scrolling. + preview_container->gui_input(p_event); } void ThemeEditorPreview::_reset_picker_overlay() { @@ -223,7 +227,7 @@ ThemeEditorPreview::ThemeEditorPreview() { preview_body->set_v_size_flags(SIZE_EXPAND_FILL); add_child(preview_body); - ScrollContainer *preview_container = memnew(ScrollContainer); + preview_container = memnew(ScrollContainer); preview_container->set_enable_v_scroll(true); preview_container->set_enable_h_scroll(true); preview_body->add_child(preview_container); diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h index f973119257..73422b4fba 100644 --- a/editor/plugins/theme_editor_preview.h +++ b/editor/plugins/theme_editor_preview.h @@ -55,6 +55,7 @@ class ThemeEditorPreview : public VBoxContainer { GDCLASS(ThemeEditorPreview, VBoxContainer); + ScrollContainer *preview_container; ColorRect *preview_bg; MarginContainer *preview_overlay; Control *picker_overlay; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d165f44334..44cf6b42bc 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -516,7 +516,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) _grab_polygon_point(mb->get_position(), xform, closest_polygon, closest_point); if (closest_polygon >= 0) { PackedVector2Array old_polygon = polygons[closest_polygon]; - polygons[closest_polygon].remove(closest_point); + polygons[closest_polygon].remove_at(closest_point); undo_redo->create_action(TTR("Edit Polygons")); if (polygons[closest_polygon].size() < 3) { remove_polygon(closest_polygon); @@ -563,7 +563,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) _grab_polygon_point(mb->get_position(), xform, closest_polygon, closest_point); if (closest_polygon >= 0) { PackedVector2Array old_polygon = polygons[closest_polygon]; - polygons[closest_polygon].remove(closest_point); + polygons[closest_polygon].remove_at(closest_point); undo_redo->create_action(TTR("Edit Polygons")); if (polygons[closest_polygon].size() < 3) { remove_polygon(closest_polygon); @@ -676,7 +676,7 @@ int GenericTilePolygonEditor::add_polygon(Vector<Point2> p_polygon, int p_index) void GenericTilePolygonEditor::remove_polygon(int p_index) { ERR_FAIL_INDEX(p_index, (int)polygons.size()); - polygons.remove(p_index); + polygons.remove_at(p_index); if (polygons.size() == 0) { button_create->set_pressed(true); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 73b1fc7c67..37d52174f9 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -598,7 +598,10 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p } if (drag_type == DRAG_TYPE_CLIPBOARD_PASTE) { - // Do nothing. + // Cancel tile pasting on right-click + if (mb->get_button_index() == MouseButton::RIGHT) { + drag_type = DRAG_TYPE_NONE; + } } else if (tool_buttons_group->get_pressed_button() == select_tool_button) { drag_start_mouse_pos = mpos; if (tile_map_selection.has(tile_map->world_to_map(drag_start_mouse_pos)) && !mb->is_shift_pressed()) { diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index b1a9da9e26..44f2eaa2a1 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1061,7 +1061,7 @@ void VisualShaderEditor::remove_plugin(const Ref<VisualShaderNodePlugin> &p_plug void VisualShaderEditor::clear_custom_types() { for (int i = 0; i < add_options.size(); i++) { if (add_options[i].is_custom) { - add_options.remove(i); + add_options.remove_at(i); i--; } } @@ -4556,6 +4556,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("ATan", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the arc-tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_ATAN, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("ATan2", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the arc-tangent of the parameters."), VisualShaderNodeFloatOp::OP_ATAN2, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("ATanH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the inverse hyperbolic tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_ATANH, VisualShaderNode::PORT_TYPE_SCALAR)); + add_options.push_back(AddOption("BitwiseNOT", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Returns the result of bitwise NOT (~a) operation on the integer."), VisualShaderNodeIntFunc::FUNC_BITWISE_NOT, VisualShaderNode::PORT_TYPE_SCALAR_INT)); add_options.push_back(AddOption("Ceil", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the nearest integer that is greater than or equal to the parameter."), VisualShaderNodeFloatFunc::FUNC_CEIL, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeClamp", TTR("Constrains a value to lie between two further values."), VisualShaderNodeClamp::OP_TYPE_FLOAT, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeClamp", TTR("Constrains a value to lie between two further values."), VisualShaderNodeClamp::OP_TYPE_INT, VisualShaderNode::PORT_TYPE_SCALAR_INT)); @@ -4595,6 +4596,11 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Add", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Sums two floating-point scalars."), VisualShaderNodeFloatOp::OP_ADD, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Add", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Sums two integer scalars."), VisualShaderNodeIntOp::OP_ADD, VisualShaderNode::PORT_TYPE_SCALAR_INT)); + add_options.push_back(AddOption("BitwiseAND", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Returns the result of bitwise AND (a & b) operation for two integers."), VisualShaderNodeIntOp::OP_BITWISE_AND, VisualShaderNode::PORT_TYPE_SCALAR_INT)); + add_options.push_back(AddOption("BitwiseLeftShift", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Returns the result of bitwise left shift (a << b) operation on the integer."), VisualShaderNodeIntOp::OP_BITWISE_LEFT_SHIFT, VisualShaderNode::PORT_TYPE_SCALAR_INT)); + add_options.push_back(AddOption("BitwiseOR", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Returns the result of bitwise OR (a | b) operation for two integers."), VisualShaderNodeIntOp::OP_BITWISE_OR, VisualShaderNode::PORT_TYPE_SCALAR_INT)); + add_options.push_back(AddOption("BitwiseRightShift", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Returns the result of bitwise right shift (a >> b) operation on the integer."), VisualShaderNodeIntOp::OP_BITWISE_RIGHT_SHIFT, VisualShaderNode::PORT_TYPE_SCALAR_INT)); + add_options.push_back(AddOption("BitwiseXOR", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Returns the result of bitwise XOR (a ^ b) operation on the integer."), VisualShaderNodeIntOp::OP_BITWISE_XOR, VisualShaderNode::PORT_TYPE_SCALAR_INT)); add_options.push_back(AddOption("Divide", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Divides two floating-point scalars."), VisualShaderNodeFloatOp::OP_DIV, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Divide", "Scalar", "Operators", "VisualShaderNodeIntOp", TTR("Divides two integer scalars."), VisualShaderNodeIntOp::OP_DIV, VisualShaderNode::PORT_TYPE_SCALAR_INT)); add_options.push_back(AddOption("Multiply", "Scalar", "Operators", "VisualShaderNodeFloatOp", TTR("Multiplies two floating-point scalars."), VisualShaderNodeFloatOp::OP_MUL, VisualShaderNode::PORT_TYPE_SCALAR)); diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index 9a44d40dcb..4f3cb9e189 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -67,31 +67,36 @@ void VoxelGIEditorPlugin::_notification(int p_what) { return; } + // Set information tooltip on the Bake button. This information is useful + // to optimize performance (video RAM size) and reduce light leaking (individual cell size). + const Vector3i size = voxel_gi->get_estimated_cell_size(); - String text = vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z); + + const Vector3 extents = voxel_gi->get_extents(); + const int data_size = 4; const double size_mb = size.x * size.y * size.z * data_size / (1024.0 * 1024.0); - text += " - " + vformat(TTR("VRAM Size: %s MB"), String::num(size_mb, 2)); - - if (bake_info->get_text() == text) { - return; + // Add a qualitative measurement to help the user assess whether a VoxelGI node is using a lot of VRAM. + String size_quality; + if (size_mb < 16.0) { + size_quality = TTR("Low"); + } else if (size_mb < 64.0) { + size_quality = TTR("Moderate"); + } else { + size_quality = TTR("High"); } - // Color the label depending on the estimated performance level. - Color color; - if (size_mb <= 16.0 + CMP_EPSILON) { - // Fast. - color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); - } else if (size_mb <= 64.0 + CMP_EPSILON) { - // Medium. - color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); - } else { - // Slow. - color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); + String text; + text += vformat(TTR("Subdivisions: %s"), vformat(String::utf8("%d × %d × %d"), size.x, size.y, size.z)) + "\n"; + text += vformat(TTR("Cell size: %s"), vformat(String::utf8("%.3f × %.3f × %.3f"), extents.x / size.x, extents.y / size.y, extents.z / size.z)) + "\n"; + text += vformat(TTR("Video RAM size: %s MB (%s)"), String::num(size_mb, 2), size_quality); + + // Only update the tooltip when needed to avoid constant redrawing. + if (bake->get_tooltip(Point2()) == text) { + return; } - bake_info->add_theme_color_override("font_color", color); - bake_info->set_text(text); + bake->set_tooltip(text); } } @@ -147,10 +152,6 @@ VoxelGIEditorPlugin::VoxelGIEditorPlugin(EditorNode *p_node) { bake->set_text(TTR("Bake GI Probe")); bake->connect("pressed", callable_mp(this, &VoxelGIEditorPlugin::_bake)); bake_hb->add_child(bake); - bake_info = memnew(Label); - bake_info->set_h_size_flags(Control::SIZE_EXPAND_FILL); - bake_info->set_clip_text(true); - bake_hb->add_child(bake_info); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); voxel_gi = nullptr; diff --git a/editor/plugins/voxel_gi_editor_plugin.h b/editor/plugins/voxel_gi_editor_plugin.h index 4d3cfe90f6..ed66728557 100644 --- a/editor/plugins/voxel_gi_editor_plugin.h +++ b/editor/plugins/voxel_gi_editor_plugin.h @@ -42,7 +42,6 @@ class VoxelGIEditorPlugin : public EditorPlugin { VoxelGI *voxel_gi; HBoxContainer *bake_hb; - Label *bake_info; Button *bake; EditorNode *editor; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 8ee90a1184..7ae03b3072 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -102,7 +102,6 @@ private: FileDialog *fdialog; FileDialog *fdialog_install; OptionButton *vcs_metadata_selection; - CheckBox *create_default_environment; String zip_path; String zip_title; AcceptDialog *dialog_error; @@ -478,36 +477,27 @@ private: cd->grab_focus(); return; } + PackedStringArray project_features = ProjectSettings::get_required_features(); ProjectSettings::CustomMap initial_settings; - initial_settings["rendering/vulkan/rendering/back_end"] = rasterizer_button_group->get_pressed_button()->get_meta(SNAME("driver_name")); + // Be sure to change this code if/when renderers are changed. + int renderer_type = rasterizer_button_group->get_pressed_button()->get_meta(SNAME("driver_name")); + initial_settings["rendering/vulkan/rendering/back_end"] = renderer_type; + if (renderer_type == 0) { + project_features.push_back("Vulkan Clustered"); + } else if (renderer_type == 1) { + project_features.push_back("Vulkan Mobile"); + } else { + WARN_PRINT("Unknown renderer type. Please report this as a bug on GitHub."); + } + project_features.sort(); + initial_settings["application/config/features"] = project_features; initial_settings["application/config/name"] = project_name->get_text().strip_edges(); initial_settings["application/config/icon"] = "res://icon.png"; - if (create_default_environment->is_pressed()) { - initial_settings["rendering/environment/defaults/default_environment"] = "res://default_env.tres"; - } - if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector<String>(), false) != OK) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { ResourceSaver::save(dir.plus_file("icon.png"), create_unscaled_default_project_icon()); - FileAccess *f; - if (create_default_environment->is_pressed()) { - f = FileAccess::open(dir.plus_file("default_env.tres"), FileAccess::WRITE); - if (!f) { - set_message(TTR("Couldn't create default_env.tres in project path."), MESSAGE_ERROR); - } else { - f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]"); - f->store_line(""); - f->store_line("[sub_resource type=\"Sky\" id=\"1\"]"); - f->store_line(""); - f->store_line("[resource]"); - f->store_line("background_mode = 2"); - f->store_line("sky = SubResource( \"1\" )"); - memdelete(f); - } - } - EditorVCSInterface::create_vcs_metadata_files(EditorVCSInterface::VCSMetadata(vcs_metadata_selection->get_selected()), dir); } } else if (mode == MODE_INSTALL) { @@ -933,10 +923,6 @@ public: Control *spacer = memnew(Control); spacer->set_h_size_flags(Control::SIZE_EXPAND_FILL); default_files_container->add_child(spacer); - create_default_environment = memnew(CheckBox); - create_default_environment->set_text("Create Default Environment"); - create_default_environment->set_pressed(true); - default_files_container->add_child(create_default_environment); fdialog = memnew(FileDialog); fdialog->set_access(FileDialog::ACCESS_FILESYSTEM); @@ -1019,6 +1005,7 @@ public: String path; String icon; String main_scene; + PackedStringArray unsupported_features; uint64_t last_edited = 0; bool favorite = false; bool grayed = false; @@ -1035,6 +1022,7 @@ public: const String &p_path, const String &p_icon, const String &p_main_scene, + const PackedStringArray &p_unsupported_features, uint64_t p_last_edited, bool p_favorite, bool p_grayed, @@ -1046,6 +1034,7 @@ public: path = p_path; icon = p_icon; main_scene = p_main_scene; + unsupported_features = p_unsupported_features; last_edited = p_last_edited; favorite = p_favorite; grayed = p_grayed; @@ -1097,8 +1086,7 @@ private: void remove_project(int p_index, bool p_update_settings); void update_icons_async(); void load_project_icon(int p_index); - - static void load_project_data(const String &p_property_key, Item &p_item, bool p_favorite); + static Item load_project_data(const String &p_property_key, bool p_favorite); String _search_term; FilterOption _order_option; @@ -1189,7 +1177,8 @@ void ProjectList::load_project_icon(int p_index) { item.control->icon_needs_reload = false; } -void ProjectList::load_project_data(const String &p_property_key, Item &p_item, bool p_favorite) { +// Load project data from p_property_key and return it in a ProjectList::Item. p_favorite is passed directly into the Item. +ProjectList::Item ProjectList::load_project_data(const String &p_property_key, bool p_favorite) { String path = EditorSettings::get_singleton()->get(p_property_key); String conf = path.plus_file("project.godot"); bool grayed = false; @@ -1209,13 +1198,16 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item, } if (config_version > ProjectSettings::CONFIG_VERSION) { - // Comes from an incompatible (more recent) Godot version, grey it out + // Comes from an incompatible (more recent) Godot version, gray it out. grayed = true; } - String description = cf->get_value("application", "config/description", ""); - String icon = cf->get_value("application", "config/icon", ""); - String main_scene = cf->get_value("application", "run/main_scene", ""); + const String description = cf->get_value("application", "config/description", ""); + const String icon = cf->get_value("application", "config/icon", ""); + const String main_scene = cf->get_value("application", "run/main_scene", ""); + + PackedStringArray project_features = cf->get_value("application", "config/features", PackedStringArray()); + PackedStringArray unsupported_features = ProjectSettings::get_unsupported_features(project_features); uint64_t last_edited = 0; if (FileAccess::exists(conf)) { @@ -1237,9 +1229,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item, print_line("Project is missing: " + conf); } - String project_key = p_property_key.get_slice("/", 1); + const String project_key = p_property_key.get_slice("/", 1); - p_item = Item(project_key, project_name, description, path, icon, main_scene, last_edited, p_favorite, grayed, missing, config_version); + return Item(project_key, project_name, description, path, icon, main_scene, unsupported_features, last_edited, p_favorite, grayed, missing, config_version); } void ProjectList::load_projects() { @@ -1282,8 +1274,7 @@ void ProjectList::load_projects() { String project_key = property_key.get_slice("/", 1); bool favorite = favorites.has("favorite_projects/" + project_key); - Item item; - load_project_data(property_key, item, favorite); + Item item = load_project_data(property_key, favorite); _projects.push_back(item); } @@ -1366,7 +1357,7 @@ void ProjectList::create_project_item_control(int p_index) { TextureButton *favorite = memnew(TextureButton); favorite->set_name("FavoriteButton"); favorite->set_normal_texture(favorite_icon); - // This makes the project's "hover" style display correctly when hovering the favorite icon + // This makes the project's "hover" style display correctly when hovering the favorite icon. favorite->set_mouse_filter(MOUSE_FILTER_PASS); favorite->connect("pressed", callable_mp(this, &ProjectList::_favorite_pressed), varray(hb)); favorite_box->add_child(favorite); @@ -1396,40 +1387,65 @@ void ProjectList::create_project_item_control(int p_index) { ec->set_custom_minimum_size(Size2(0, 1)); ec->set_mouse_filter(MOUSE_FILTER_PASS); vb->add_child(ec); - Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project"))); - title->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts"))); - title->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("title_size"), SNAME("EditorFonts"))); - title->add_theme_color_override("font_color", font_color); - title->set_clip_text(true); - vb->add_child(title); - - HBoxContainer *path_hb = memnew(HBoxContainer); - path_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - vb->add_child(path_hb); - - Button *show = memnew(Button); - // Display a folder icon if the project directory can be opened, or a "broken file" icon if it can't. - show->set_icon(get_theme_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons")); - if (!item.grayed) { - // Don't make the icon less prominent if the parent is already grayed out. - show->set_modulate(Color(1, 1, 1, 0.5)); - } - path_hb->add_child(show); - - if (!item.missing) { - show->connect("pressed", callable_mp(this, &ProjectList::_show_project), varray(item.path)); - show->set_tooltip(TTR("Show in File Manager")); - } else { - show->set_tooltip(TTR("Error: Project is missing on the filesystem.")); - } - Label *fpath = memnew(Label(item.path)); - fpath->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE); - path_hb->add_child(fpath); - fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL); - fpath->set_modulate(Color(1, 1, 1, 0.5)); - fpath->add_theme_color_override("font_color", font_color); - fpath->set_clip_text(true); + { // Top half, title and unsupported features labels. + HBoxContainer *title_hb = memnew(HBoxContainer); + vb->add_child(title_hb); + + Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project"))); + title->set_h_size_flags(Control::SIZE_EXPAND_FILL); + title->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts"))); + title->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("title_size"), SNAME("EditorFonts"))); + title->add_theme_color_override("font_color", font_color); + title->set_clip_text(true); + title_hb->add_child(title); + + String unsupported_features_str = Variant(item.unsupported_features).operator String().trim_prefix("[").trim_suffix("]"); + int length = unsupported_features_str.length(); + if (length > 0) { + Label *unsupported_label = memnew(Label(unsupported_features_str)); + unsupported_label->set_custom_minimum_size(Size2(length * 15, 10) * EDSCALE); + unsupported_label->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts"))); + unsupported_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + unsupported_label->set_clip_text(true); + unsupported_label->set_align(Label::ALIGN_RIGHT); + title_hb->add_child(unsupported_label); + Control *spacer = memnew(Control()); + spacer->set_custom_minimum_size(Size2(10, 10)); + title_hb->add_child(spacer); + } + } + + { // Bottom half, containing the path and view folder button. + HBoxContainer *path_hb = memnew(HBoxContainer); + path_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); + vb->add_child(path_hb); + + Button *show = memnew(Button); + // Display a folder icon if the project directory can be opened, or a "broken file" icon if it can't. + show->set_icon(get_theme_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons")); + show->set_flat(true); + if (!item.grayed) { + // Don't make the icon less prominent if the parent is already grayed out. + show->set_modulate(Color(1, 1, 1, 0.5)); + } + path_hb->add_child(show); + + if (!item.missing) { + show->connect("pressed", callable_mp(this, &ProjectList::_show_project), varray(item.path)); + show->set_tooltip(TTR("Show in File Manager")); + } else { + show->set_tooltip(TTR("Error: Project is missing on the filesystem.")); + } + + Label *fpath = memnew(Label(item.path)); + fpath->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE); + path_hb->add_child(fpath); + fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL); + fpath->set_modulate(Color(1, 1, 1, 0.5)); + fpath->add_theme_color_override("font_color", font_color); + fpath->set_clip_text(true); + } _scroll_children->add_child(hb); item.control = hb; @@ -1543,7 +1559,7 @@ void ProjectList::remove_project(int p_index, bool p_update_settings) { } memdelete(item.control); - _projects.remove(p_index); + _projects.remove_at(p_index); if (p_update_settings) { EditorSettings::get_singleton()->erase("projects/" + item.project_key); @@ -1634,8 +1650,7 @@ int ProjectList::refresh_project(const String &dir_path) { if (should_be_in_list) { // Recreate it with updated info - Item item; - load_project_data(property_key, item, is_favourite); + Item item = load_project_data(property_key, is_favourite); _projects.push_back(item); create_project_item_control(_projects.size() - 1); @@ -1733,7 +1748,7 @@ void ProjectList::erase_selected_projects(bool p_delete_project_contents) { } memdelete(item.control); - _projects.remove(i); + _projects.remove_at(i); --i; } } @@ -2114,8 +2129,12 @@ void ProjectManager::_open_selected_projects_ask() { } // Update the project settings or don't open - String conf = project.path.plus_file("project.godot"); - int config_version = project.version; + const String conf = project.path.plus_file("project.godot"); + const int config_version = project.version; + PackedStringArray unsupported_features = project.unsupported_features; + + Label *ask_update_label = ask_update_settings->get_label(); + ask_update_label->set_align(Label::ALIGN_LEFT); // Reset in case of previous center align. // Check if the config_version property was empty or 0 if (config_version == 0) { @@ -2135,6 +2154,35 @@ void ProjectManager::_open_selected_projects_ask() { dialog_error->popup_centered(); return; } + // Check if the project is using features not supported by this build of Godot. + if (!unsupported_features.is_empty()) { + String warning_message = ""; + for (int i = 0; i < unsupported_features.size(); i++) { + String feature = unsupported_features[i]; + if (feature == "Double Precision") { + warning_message += TTR("Warning: This project uses double precision floats, but this version of\nGodot uses single precision floats. Opening this project may cause data loss.\n\n"); + unsupported_features.remove_at(i); + i--; + } else if (feature == "C#") { + warning_message += TTR("Warning: This project uses C#, but this build of Godot does not have\nthe Mono module. If you proceed you will not be able to use any C# scripts.\n\n"); + unsupported_features.remove_at(i); + i--; + } else if (feature.substr(0, 3).is_numeric()) { + warning_message += vformat(TTR("Warning: This project was built in Godot %s.\nOpening will upgrade or downgrade the project to Godot %s.\n\n"), Variant(feature), Variant(VERSION_BRANCH)); + unsupported_features.remove_at(i); + i--; + } + } + if (!unsupported_features.is_empty()) { + String unsupported_features_str = Variant(unsupported_features).operator String().trim_prefix("[").trim_suffix("]"); + warning_message += vformat(TTR("Warning: This project uses the following features not supported by this build of Godot:\n\n%s\n\n"), unsupported_features_str); + } + warning_message += TTR("Open anyway? Project will be modified."); + ask_update_label->set_align(Label::ALIGN_CENTER); + ask_update_settings->set_text(warning_message); + ask_update_settings->popup_centered(); + return; + } // Open if the project is up-to-date _open_selected_projects(); @@ -2669,7 +2717,7 @@ ProjectManager::ProjectManager() { for (int i = 0; i < editor_languages.size(); i++) { String lang = editor_languages[i]; String lang_name = TranslationServer::get_singleton()->get_locale_name(lang); - language_btn->add_item(lang_name + " [" + lang + "]", i); + language_btn->add_item(vformat("[%s] %s", lang, lang_name), i); language_btn->set_item_metadata(i, lang); if (current_lang == lang) { language_btn->select(i); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 611038a947..b36275322a 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -419,6 +419,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!selected_item) { selected_item = tree->get_root(); + if (!selected_item) { + break; + } } bool collapsed = _is_collapsed_recursive(selected_item); @@ -1306,6 +1309,7 @@ void SceneTreeDock::_notification(int p_what) { button_instance->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); button_create_script->set_icon(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons"))); button_detach_script->set_icon(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons"))); + button_tree_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); @@ -2973,7 +2977,7 @@ void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) { shader_create_dialog->connect("shader_created", callable_mp(this, &SceneTreeDock::_shader_created)); shader_create_dialog->connect("confirmed", callable_mp(this, &SceneTreeDock::_shader_creation_closed)); shader_create_dialog->connect("cancelled", callable_mp(this, &SceneTreeDock::_shader_creation_closed)); - shader_create_dialog->config(path, true, true, p_preferred_mode); + shader_create_dialog->config(path, true, true, -1, p_preferred_mode); shader_create_dialog->popup_centered(); } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 684f8aa37e..e1229729ac 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -486,7 +486,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column _update_shortcut_events(current_edited_identifier, Array()); } } else if (type == "event") { - current_events.remove(current_event_index); + current_events.remove_at(current_event_index); if (is_editing_action) { _update_builtin_action(current_edited_identifier, current_events); @@ -564,7 +564,7 @@ void EditorSettingsDialog::drop_data_fw(const Point2 &p_point, const Variant &p_ Array events = selected->get_parent()->get_meta("events"); Variant event_moved = events[index_moving_from]; - events.remove(index_moving_from); + events.remove_at(index_moving_from); events.insert(target_event_index, event_moved); String ident = selected->get_parent()->get_meta("shortcut_identifier"); diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index 23bdc06f95..1ddd79eea8 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -324,7 +324,7 @@ void ShaderCreateDialog::_path_submitted(const String &p_path) { ok_pressed(); } -void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled, int p_preferred_mode) { +void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled, int p_preferred_type, int p_preferred_mode) { if (p_base_path != "") { initial_base_path = p_base_path.get_basename(); file_path->set_text(initial_base_path + "." + language_data[language_menu->get_selected()].default_extension); @@ -338,6 +338,11 @@ void ShaderCreateDialog::config(const String &p_base_path, bool p_built_in_enabl built_in_enabled = p_built_in_enabled; load_enabled = p_load_enabled; + if (p_preferred_type > -1) { + language_menu->select(p_preferred_type); + _language_changed(p_preferred_type); + } + if (p_preferred_mode > -1) { mode_menu->select(p_preferred_mode); _mode_changed(p_preferred_mode); diff --git a/editor/shader_create_dialog.h b/editor/shader_create_dialog.h index be0a0cad06..cd20897ddb 100644 --- a/editor/shader_create_dialog.h +++ b/editor/shader_create_dialog.h @@ -108,7 +108,7 @@ protected: static void _bind_methods(); public: - void config(const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true, int p_preferred_mode = -1); + void config(const String &p_base_path, bool p_built_in_enabled = true, bool p_load_enabled = true, int p_preferred_type = -1, int p_preferred_mode = -1); ShaderCreateDialog(); }; diff --git a/glsl_builders.py b/glsl_builders.py index 57aaed5f9f..0926212e50 100644 --- a/glsl_builders.py +++ b/glsl_builders.py @@ -29,6 +29,10 @@ def include_file_in_rd_header(filename, header_data, depth): while line: + index = line.find("//") + if index != -1: + line = line[:index] + if line.find("#[vertex]") != -1: header_data.reading = "vertex" line = fs.readline() @@ -55,7 +59,14 @@ def include_file_in_rd_header(filename, header_data, depth): import os.path - included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline) + included_file = "" + + if includeline.startswith("thirdparty/"): + included_file = os.path.relpath(includeline) + + else: + included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline) + if not included_file in header_data.vertex_included_files and header_data.reading == "vertex": header_data.vertex_included_files += [included_file] if include_file_in_rd_header(included_file, header_data, depth + 1) is None: diff --git a/main/SCsub b/main/SCsub index 87d64e48f9..79dc4bff15 100644 --- a/main/SCsub +++ b/main/SCsub @@ -20,12 +20,13 @@ env_main.CommandNoCache( env.Run(main_builders.make_splash, "Building splash screen header."), ) -env_main.Depends("#main/splash_editor.gen.h", "#main/splash_editor.png") -env_main.CommandNoCache( - "#main/splash_editor.gen.h", - "#main/splash_editor.png", - env.Run(main_builders.make_splash_editor, "Building editor splash screen header."), -) +if not env_main["no_editor_splash"]: + env_main.Depends("#main/splash_editor.gen.h", "#main/splash_editor.png") + env_main.CommandNoCache( + "#main/splash_editor.gen.h", + "#main/splash_editor.png", + env.Run(main_builders.make_splash_editor, "Building editor splash screen header."), + ) env_main.Depends("#main/app_icon.gen.h", "#main/app_icon.png") env_main.CommandNoCache( diff --git a/main/main.cpp b/main/main.cpp index ab44149988..c7b33f3f1b 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -56,7 +56,6 @@ #include "main/main_timer_sync.h" #include "main/performance.h" #include "main/splash.gen.h" -#include "main/splash_editor.gen.h" #include "modules/register_module_types.h" #include "platform/register_platform_apis.h" #include "scene/main/scene_tree.h" @@ -86,6 +85,9 @@ #include "editor/editor_settings.h" #include "editor/progress_dialog.h" #include "editor/project_manager.h" +#ifndef NO_EDITOR_SPLASH +#include "main/splash_editor.gen.h" +#endif #endif #include "modules/modules_enabled.gen.h" // For mono. @@ -442,6 +444,9 @@ Error Main::test_setup() { register_module_types(); register_driver_types(); + // Theme needs modules to be initialized so that sub-resources can be loaded. + initialize_theme(); + ERR_FAIL_COND_V(TextServerManager::get_singleton()->get_interface_count() == 0, ERR_CANT_CREATE); TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(0)); @@ -1701,7 +1706,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (show_logo) { //boot logo! const bool boot_logo_image = GLOBAL_DEF("application/boot_splash/show_image", true); - const String boot_logo_path = GLOBAL_DEF("application/boot_splash/image", String()); + const String boot_logo_path = String(GLOBAL_DEF("application/boot_splash/image", String())).strip_edges(); const bool boot_logo_scale = GLOBAL_DEF("application/boot_splash/fullsize", true); const bool boot_logo_filter = GLOBAL_DEF("application/boot_splash/use_filter", true); ProjectSettings::get_singleton()->set_custom_property_info("application/boot_splash/image", @@ -1882,6 +1887,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) { register_platform_apis(); register_module_types(); + // Theme needs modules to be initialized so that sub-resources can be loaded. + initialize_theme(); + GLOBAL_DEF("display/mouse_cursor/custom_image", String()); GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2()); GLOBAL_DEF("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); diff --git a/main/splash_editor.png b/main/splash_editor.png Binary files differdeleted file mode 100644 index 49af9fde22..0000000000 --- a/main/splash_editor.png +++ /dev/null diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp index 435069e25c..10a71d65df 100644 --- a/modules/bullet/area_bullet.cpp +++ b/modules/bullet/area_bullet.cpp @@ -89,7 +89,7 @@ void AreaBullet::dispatch_callbacks() { // This object's last shape being removed. overlapping_shape.other_object->on_exit_area(this); } - overlapping_shapes.remove(i); // Remove after callback + overlapping_shapes.remove_at(i); // Remove after callback break; case OVERLAP_STATE_INSIDE: { if (overlapping_shape.other_object->getType() == TYPE_RIGID_BODY) { @@ -188,7 +188,7 @@ void AreaBullet::remove_object_overlaps(CollisionObjectBullet *p_object) { // Reverse order so items can be removed. for (int i = overlapping_shapes.size() - 1; i >= 0; i--) { if (overlapping_shapes[i].other_object == p_object) { - overlapping_shapes.remove(i); + overlapping_shapes.remove_at(i); } } } diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 987a45ad5f..cbb746800d 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -273,7 +273,7 @@ void RigidCollisionObjectBullet::remove_shape_full(ShapeBullet *p_shape) { for (int i = shapes.size() - 1; 0 <= i; --i) { if (p_shape == shapes[i].shape) { internal_shape_destroy(i); - shapes.remove(i); + shapes.remove_at(i); } } reload_shapes(); @@ -282,7 +282,7 @@ void RigidCollisionObjectBullet::remove_shape_full(ShapeBullet *p_shape) { void RigidCollisionObjectBullet::remove_shape_full(int p_index) { ERR_FAIL_INDEX(p_index, get_shape_count()); internal_shape_destroy(p_index); - shapes.remove(p_index); + shapes.remove_at(p_index); reload_shapes(); } diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index 1f962772e7..edb2bcb4c7 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -107,7 +107,14 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo PhysicsDirectSpaceState3D::ShapeResult &result = m_results[count]; - result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is an odd name but contains the compound shape ID + // Triangle index is an odd name but contains the compound shape ID. + // A shape part of -1 indicates the index is a shape index and not a triangle index. + if (convexResult.m_localShapeInfo && convexResult.m_localShapeInfo->m_shapePart == -1) { + result.shape = convexResult.m_localShapeInfo->m_triangleIndex; + } else { + result.shape = 0; + } + result.rid = gObj->get_self(); result.collider_id = gObj->get_instance_id(); result.collider = result.collider_id.is_null() ? nullptr : ObjectDB::get_instance(result.collider_id); @@ -171,11 +178,14 @@ bool GodotClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) } btScalar GodotClosestConvexResultCallback::addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace) { - if (convexResult.m_localShapeInfo) { - m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is an odd name but contains the compound shape ID + // Triangle index is an odd name but contains the compound shape ID. + // A shape part of -1 indicates the index is a shape index and not a triangle index. + if (convexResult.m_localShapeInfo && convexResult.m_localShapeInfo->m_shapePart == -1) { + m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex; } else { m_shapeId = 0; } + return btCollisionWorld::ClosestConvexResultCallback::addSingleResult(convexResult, normalInWorldSpace); } @@ -219,10 +229,22 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con CollisionObjectBullet *colObj; if (m_self_object == colObj0Wrap->getCollisionObject()) { colObj = static_cast<CollisionObjectBullet *>(colObj1Wrap->getCollisionObject()->getUserPointer()); - result.shape = cp.m_index1; + // Checking for compound shape because the index might be uninitialized otherwise. + // A partId of -1 indicates the index is a shape index and not a triangle index. + if (colObj1Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId1 == -1) { + result.shape = cp.m_index1; + } else { + result.shape = 0; + } } else { colObj = static_cast<CollisionObjectBullet *>(colObj0Wrap->getCollisionObject()->getUserPointer()); - result.shape = cp.m_index0; + // Checking for compound shape because the index might be uninitialized otherwise. + // A partId of -1 indicates the index is a shape index and not a triangle index. + if (colObj0Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId0 == -1) { + result.shape = cp.m_index0; + } else { + result.shape = 0; + } } result.collider_id = colObj->get_instance_id(); @@ -311,14 +333,26 @@ btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp CollisionObjectBullet *colObj; if (m_self_object == colObj0Wrap->getCollisionObject()) { colObj = static_cast<CollisionObjectBullet *>(colObj1Wrap->getCollisionObject()->getUserPointer()); - m_result->shape = cp.m_index1; + // Checking for compound shape because the index might be uninitialized otherwise. + // A partId of -1 indicates the index is a shape index and not a triangle index. + if (colObj1Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId1 == -1) { + m_result->shape = cp.m_index1; + } else { + m_result->shape = 0; + } B_TO_G(cp.getPositionWorldOnB(), m_result->point); B_TO_G(cp.m_normalWorldOnB, m_result->normal); m_rest_info_bt_point = cp.getPositionWorldOnB(); m_rest_info_collision_object = colObj1Wrap->getCollisionObject(); } else { colObj = static_cast<CollisionObjectBullet *>(colObj0Wrap->getCollisionObject()->getUserPointer()); - m_result->shape = cp.m_index0; + // Checking for compound shape because the index might be uninitialized otherwise. + // A partId of -1 indicates the index is a shape index and not a triangle index. + if (colObj0Wrap->getCollisionObject()->getCollisionShape()->isCompound() && cp.m_partId0 == -1) { + m_result->shape = cp.m_index0; + } else { + m_result->shape = 0; + } B_TO_G(cp.m_normalWorldOnB * -1, m_result->normal); m_rest_info_bt_point = cp.getPositionWorldOnA(); m_rest_info_collision_object = colObj0Wrap->getCollisionObject(); diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index 96a649d77a..3dfa21aec8 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -70,8 +70,10 @@ public: virtual bool needsCollision(btBroadphaseProxy *proxy0) const; virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace) { - if (rayResult.m_localShapeInfo) { - m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID + // Triangle index is an odd name but contains the compound shape ID. + // A shape part of -1 indicates the index is a shape index and not a triangle index. + if (rayResult.m_localShapeInfo && rayResult.m_localShapeInfo->m_shapePart == -1) { + m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex; } else { m_shapeId = 0; } diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp index 3a2370ff31..c0ffffa364 100644 --- a/modules/bullet/soft_body_bullet.cpp +++ b/modules/bullet/soft_body_bullet.cpp @@ -442,7 +442,7 @@ void SoftBodyBullet::unpin_node(int p_node_index) { } const int id = search_node_pinned(p_node_index); if (-1 != id) { - pinned_nodes.remove(id); + pinned_nodes.remove_at(id); } } diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index a7742ef415..a70e153abd 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -933,7 +933,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_ merge_faces_idx.sort(); merge_faces_idx.reverse(); for (int i = 0; i < merge_faces_idx.size(); ++i) { - faces.remove(merge_faces_idx[i]); + faces.remove_at(merge_faces_idx[i]); } if (degenerate_points.size() == 0) { @@ -983,7 +983,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_ // If new vertex snaps to degenerate vertex, just delete this face. if (degenerate_idx == opposite_vertex_idx) { - faces.remove(face_idx); + faces.remove_at(face_idx); // Update index. --face_idx; break; @@ -999,7 +999,7 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector<int> &p_segment_ right_face.vertex_idx[0] = opposite_vertex_idx; right_face.vertex_idx[1] = face.vertex_idx[face_edge_idx]; right_face.vertex_idx[2] = degenerate_idx; - faces.remove(face_idx); + faces.remove_at(face_idx); faces.insert(face_idx, right_face); faces.insert(face_idx, left_face); @@ -1070,7 +1070,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s // If new vertex snaps to opposite vertex, just delete this face. if (new_vertex_idx == opposite_vertex_idx) { - faces.remove(face_idx); + faces.remove_at(face_idx); // Update index. --face_idx; break; @@ -1092,7 +1092,7 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s right_face.vertex_idx[0] = opposite_vertex_idx; right_face.vertex_idx[1] = face.vertex_idx[face_edge_idx]; right_face.vertex_idx[2] = new_vertex_idx; - faces.remove(face_idx); + faces.remove_at(face_idx); faces.insert(face_idx, right_face); faces.insert(face_idx, left_face); @@ -1162,7 +1162,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { // If new vertex snaps to opposite vertex, just delete this face. if (new_vertex_idx == opposite_vertex_idx) { - faces.remove(face_idx); + faces.remove_at(face_idx); // Update index. --face_idx; break; @@ -1187,7 +1187,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { right_face.vertex_idx[0] = opposite_vertex_idx; right_face.vertex_idx[1] = face.vertex_idx[face_edge_idx]; right_face.vertex_idx[2] = new_vertex_idx; - faces.remove(face_idx); + faces.remove_at(face_idx); faces.insert(face_idx, right_face); faces.insert(face_idx, left_face); @@ -1222,7 +1222,7 @@ int CSGBrushOperation::Build2DFaces::_insert_point(const Vector2 &p_point) { new_face.vertex_idx[2] = new_vertex_idx; faces.push_back(new_face); } - faces.remove(face_idx); + faces.remove_at(face_idx); // No need to check other faces. break; diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 9c8adb4cf1..33f4198ac1 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -4,10 +4,10 @@ Built-in GDScript functions. </brief_description> <description> - List of core built-in GDScript functions. Math functions and other utilities. Everything else is provided by objects. (Keywords: builtin, built in, global functions.) + A list of GDScript-specific utility functions accessed in any script. + For the list of the global functions and constants see [@GlobalScope]. </description> <tutorials> - <link title="Random number generation">$DOCS_URL/tutorials/math/random_number_generation.html</link> </tutorials> <methods> <method name="Color8"> diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 68da588c3d..b76c2c0437 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -427,7 +427,7 @@ void GDScript::_add_doc(const DocData::ClassDoc &p_inner_class) { } else { for (int i = 0; i < docs.size(); i++) { if (docs[i].name == p_inner_class.name) { - docs.remove(i); + docs.remove_at(i); break; } } @@ -2131,7 +2131,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b const GDScriptParser::ClassNode *inner_class = subclass->members[i].m_class; if (inner_class->identifier->name == extend_classes[0]) { - extend_classes.remove(0); + extend_classes.remove_at(0); found = true; subclass = inner_class; break; diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 9d076a8e4c..e1ed71a268 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -192,7 +192,7 @@ public: GDScriptDataType() = default; - GDScriptDataType &operator=(const GDScriptDataType &p_other) { + void operator=(const GDScriptDataType &p_other) { kind = p_other.kind; has_type = p_other.has_type; builtin_type = p_other.builtin_type; @@ -203,7 +203,6 @@ public: if (p_other.has_container_element_type()) { set_container_element_type(p_other.get_container_element_type()); } - return *this; } GDScriptDataType(const GDScriptDataType &p_other) { diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index d9cf9f4f10..fd6bd545c9 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3413,8 +3413,8 @@ bool GDScriptParser::validate_annotation_arguments(AnnotationNode *p_annotation) Variant::construct(parameter.type, r, &(name), 1, error); p_annotation->resolved_arguments.push_back(r); if (error.error != Callable::CallError::CALL_OK) { - push_error(vformat(R"(Expected %s as argument %d of annotation "%s").)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); - p_annotation->resolved_arguments.remove(p_annotation->resolved_arguments.size() - 1); + push_error(vformat(R"(Expected %s as argument %d of annotation "%s".)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); + p_annotation->resolved_arguments.remove_at(p_annotation->resolved_arguments.size() - 1); return false; } break; @@ -3422,13 +3422,13 @@ bool GDScriptParser::validate_annotation_arguments(AnnotationNode *p_annotation) [[fallthrough]]; default: { if (argument->type != Node::LITERAL) { - push_error(vformat(R"(Expected %s as argument %d of annotation "%s").)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); + push_error(vformat(R"(Expected %s as argument %d of annotation "%s".)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); return false; } Variant value = static_cast<LiteralNode *>(argument)->value; if (!Variant::can_convert_strict(value.get_type(), parameter.type)) { - push_error(vformat(R"(Expected %s as argument %d of annotation "%s").)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); + push_error(vformat(R"(Expected %s as argument %d of annotation "%s".)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); return false; } Callable::CallError error; @@ -3437,8 +3437,8 @@ bool GDScriptParser::validate_annotation_arguments(AnnotationNode *p_annotation) Variant::construct(parameter.type, r, &(args), 1, error); p_annotation->resolved_arguments.push_back(r); if (error.error != Callable::CallError::CALL_OK) { - push_error(vformat(R"(Expected %s as argument %d of annotation "%s").)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); - p_annotation->resolved_arguments.remove(p_annotation->resolved_arguments.size() - 1); + push_error(vformat(R"(Expected %s as argument %d of annotation "%s".)", Variant::get_type_name(parameter.type), i + 1, p_annotation->name)); + p_annotation->resolved_arguments.remove_at(p_annotation->resolved_arguments.size() - 1); return false; } break; diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index af9b973ada..2f05b4b948 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -203,7 +203,7 @@ public: return !(this->operator==(p_other)); } - DataType &operator=(const DataType &p_other) { + void operator=(const DataType &p_other) { kind = p_other.kind; type_source = p_other.type_source; is_constant = p_other.is_constant; @@ -221,7 +221,6 @@ public: if (p_other.has_container_element_type()) { set_container_element_type(p_other.get_container_element_type()); } - return *this; } DataType() = default; diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 5cf1e0fc5f..578943696e 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -115,7 +115,7 @@ Error GDScriptLanguageProtocol::LSPeer::send_data() { // Response sent if (res_sent >= c_res.size() - 1) { res_sent = 0; - res_queue.remove(0); + res_queue.remove_at(0); } } return OK; diff --git a/modules/gdscript/language_server/gdscript_language_server.h b/modules/gdscript/language_server/gdscript_language_server.h index f1413f0133..feee23dd13 100644 --- a/modules/gdscript/language_server/gdscript_language_server.h +++ b/modules/gdscript/language_server/gdscript_language_server.h @@ -45,7 +45,7 @@ class GDScriptLanguageServer : public EditorPlugin { bool started = false; bool use_thread = false; String host = "127.0.0.1"; - int port = 6008; + int port = 6005; static void thread_main(void *p_userdata); private: diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index f3317aeada..dbf6b6e1af 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -192,7 +192,7 @@ Error GLTFDocument::serialize(Ref<GLTFState> state, Node *p_root, const String & uint64_t elapsed = OS::get_singleton()->get_ticks_usec() - begin_time; float elapsed_sec = double(elapsed) / 1000000.0; elapsed_sec = Math::snapped(elapsed_sec, 0.01f); - print_line("glTF: Export time elapsed seconds " + rtos(elapsed_sec).pad_decimals(2)); + print_verbose("glTF: Export time elapsed seconds " + rtos(elapsed_sec).pad_decimals(2)); return OK; } diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index 49e9f5f97e..17406b7263 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -125,7 +125,7 @@ AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() { Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() { Ref<AudioStreamPlaybackMP3> mp3s; - ERR_FAIL_COND_V_MSG(data == nullptr, mp3s, + ERR_FAIL_COND_V_MSG(data.is_empty(), mp3s, "This AudioStreamMP3 does not have an audio file assigned " "to it. AudioStreamMP3 should not be created from the " "inspector or with `.new()`. Instead, load an audio file."); @@ -134,7 +134,7 @@ Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() { mp3s->mp3_stream = Ref<AudioStreamMP3>(this); mp3s->mp3d = (mp3dec_ex_t *)memalloc(sizeof(mp3dec_ex_t)); - int errorcode = mp3dec_ex_open_buf(mp3s->mp3d, (const uint8_t *)data, data_len, MP3D_SEEK_TO_SAMPLE); + int errorcode = mp3dec_ex_open_buf(mp3s->mp3d, data.ptr(), data_len, MP3D_SEEK_TO_SAMPLE); mp3s->frames_mixed = 0; mp3s->active = false; @@ -152,11 +152,7 @@ String AudioStreamMP3::get_stream_name() const { } void AudioStreamMP3::clear_data() { - if (data) { - memfree(data); - data = nullptr; - data_len = 0; - } + data.clear(); } void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) { @@ -165,7 +161,7 @@ void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) { mp3dec_ex_t mp3d; int err = mp3dec_ex_open_buf(&mp3d, src_datar, src_data_len, MP3D_SEEK_TO_SAMPLE); - ERR_FAIL_COND(err != 0); + ERR_FAIL_COND_MSG(err || mp3d.info.hz == 0, "Failed to decode mp3 file. Make sure it is a valid mp3 audio file."); channels = mp3d.info.channels; sample_rate = mp3d.info.hz; @@ -175,23 +171,13 @@ void AudioStreamMP3::set_data(const Vector<uint8_t> &p_data) { clear_data(); - data = memalloc(src_data_len); - memcpy(data, src_datar, src_data_len); + data.resize(src_data_len); + memcpy(data.ptrw(), src_datar, src_data_len); data_len = src_data_len; } Vector<uint8_t> AudioStreamMP3::get_data() const { - Vector<uint8_t> vdata; - - if (data_len && data) { - vdata.resize(data_len); - { - uint8_t *w = vdata.ptrw(); - memcpy(w, data, data_len); - } - } - - return vdata; + return data; } void AudioStreamMP3::set_loop(bool p_enable) { @@ -229,8 +215,8 @@ void AudioStreamMP3::_bind_methods() { ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamMP3::get_loop_offset); ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_data", "get_data"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_loop", "has_loop"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_loop_offset", "get_loop_offset"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset"), "set_loop_offset", "get_loop_offset"); } AudioStreamMP3::AudioStreamMP3() { diff --git a/modules/minimp3/audio_stream_mp3.h b/modules/minimp3/audio_stream_mp3.h index 3c8bdd8c53..e3adfe683b 100644 --- a/modules/minimp3/audio_stream_mp3.h +++ b/modules/minimp3/audio_stream_mp3.h @@ -75,7 +75,7 @@ class AudioStreamMP3 : public AudioStream { friend class AudioStreamPlaybackMP3; - void *data = nullptr; + PackedByteArray data; uint32_t data_len = 0; float sample_rate = 1.0; diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml index 18a77c8b8d..df099f2c98 100644 --- a/modules/mobile_vr/doc_classes/MobileVRInterface.xml +++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml @@ -37,6 +37,6 @@ <member name="oversample" type="float" setter="set_oversample" getter="get_oversample" default="1.5"> The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance. </member> - <member name="xr_play_area_mode" type="int" setter="set_play_area_mode" getter="get_play_area_mode" override="true" enum="XRInterface.PlayAreaMode" default="1" /> + <member name="xr_play_area_mode" type="int" setter="set_play_area_mode" getter="get_play_area_mode" overrides="XRInterface" enum="XRInterface.PlayAreaMode" default="1" /> </members> </class> diff --git a/modules/mono/SdkPackageVersions.props b/modules/mono/SdkPackageVersions.props index df3ebe581c..bdec051625 100644 --- a/modules/mono/SdkPackageVersions.props +++ b/modules/mono/SdkPackageVersions.props @@ -1,6 +1,7 @@ <Project> <PropertyGroup> - <PackageVersion_Godot_NET_Sdk>4.0.0-dev5</PackageVersion_Godot_NET_Sdk> - <PackageVersion_Godot_SourceGenerators>4.0.0-dev2</PackageVersion_Godot_SourceGenerators> + <PackageFloatingVersion_Godot>4.0.*-*</PackageFloatingVersion_Godot> + <PackageVersion_Godot_NET_Sdk>4.0.0-dev6</PackageVersion_Godot_NET_Sdk> + <PackageVersion_Godot_SourceGenerators>4.0.0-dev3</PackageVersion_Godot_SourceGenerators> </PropertyGroup> </Project> diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 544f2a7584..0ceb45d425 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -788,11 +788,7 @@ bool CSharpLanguage::is_assembly_reloading_needed() { GDMonoAssembly *proj_assembly = gdmono->get_project_assembly(); - String appname = ProjectSettings::get_singleton()->get("application/config/name"); - String appname_safe = OS::get_singleton()->get_safe_dir_name(appname); - if (appname_safe.is_empty()) { - appname_safe = "UnnamedProject"; - } + String appname_safe = ProjectSettings::get_singleton()->get_safe_project_name(); appname_safe += ".dll"; diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets index 92e299d2f3..397ede9644 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets @@ -17,6 +17,6 @@ <!-- C# source generators --> <ItemGroup Condition=" '$(DisableImplicitGodotGeneratorReferences)' != 'true' "> - <PackageReference Include="Godot.SourceGenerators" Version="$(PackageVersion_Godot_SourceGenerators)" /> + <PackageReference Include="Godot.SourceGenerators" Version="$(PackageFloatingVersion_Godot)" /> </ItemGroup> </Project> diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs new file mode 100644 index 0000000000..2ddb8880c2 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Generic.cs @@ -0,0 +1,16 @@ +namespace Godot.SourceGenerators.Sample +{ + partial class Generic<T> : Godot.Object + { + } + + // Generic again but different generic parameters + partial class Generic<T, R> : Godot.Object + { + } + + // Generic again but without generic parameters + partial class Generic : Godot.Object + { + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs index a51728e221..fa65595290 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPathAttributeGenerator.cs @@ -97,9 +97,13 @@ namespace Godot.SourceGenerators string.Empty; bool hasNamespace = classNs.Length != 0; - string uniqueName = hasNamespace ? - classNs + "." + className + "_ScriptPath_Generated" : - className + "_ScriptPath_Generated"; + var uniqueName = new StringBuilder(); + if (hasNamespace) + uniqueName.Append($"{classNs}."); + uniqueName.Append(className); + if (symbol.IsGenericType) + uniqueName.Append($"Of{string.Join(string.Empty, symbol.TypeParameters)}"); + uniqueName.Append("_ScriptPath_Generated"); var source = new StringBuilder(); @@ -121,6 +125,8 @@ namespace Godot.SourceGenerators source.Append(attributes); source.Append("\n partial class "); source.Append(className); + if (symbol.IsGenericType) + source.Append($"<{string.Join(", ", symbol.TypeParameters)}>"); source.Append("\n{\n}\n"); if (hasNamespace) @@ -128,7 +134,7 @@ namespace Godot.SourceGenerators source.Append("\n}\n"); } - context.AddSource(uniqueName, SourceText.From(source.ToString(), Encoding.UTF8)); + context.AddSource(uniqueName.ToString(), SourceText.From(source.ToString(), Encoding.UTF8)); } private static void AddScriptTypesAssemblyAttr(GeneratorExecutionContext context, @@ -145,12 +151,15 @@ namespace Godot.SourceGenerators foreach (var godotClass in godotClasses) { var qualifiedName = godotClass.Key.ToDisplayString( - NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat); + NullableFlowState.NotNull, SymbolDisplayFormat.FullyQualifiedFormat + .WithGenericsOptions(SymbolDisplayGenericsOptions.None)); if (!first) sourceBuilder.Append(", "); first = false; sourceBuilder.Append("typeof("); sourceBuilder.Append(qualifiedName); + if (godotClass.Key.IsGenericType) + sourceBuilder.Append($"<{new string(',', godotClass.Key.TypeParameters.Count() - 1)}>"); sourceBuilder.Append(")"); } diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 51a27ee934..a7879e96c8 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -598,7 +598,7 @@ class BindingsGenerator { private: NameCache(const NameCache &); - NameCache &operator=(const NameCache &); + void operator=(const NameCache &); }; NameCache name_cache; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs index 3051bcedc7..ee4d0eed08 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/MarshalUtils.cs @@ -80,6 +80,18 @@ namespace Godot private static bool TypeIsGenericIDictionary(Type type) => type.GetGenericTypeDefinition() == typeof(IDictionary<,>); /// <summary> + /// Returns the generic type definition of <paramref name="type"/>. + /// </summary> + /// <exception cref="InvalidOperationException"> + /// Thrown when the given <paramref name="type"/> is not a generic type. + /// That is, <see cref="Type.IsGenericType"/> returns <see langword="false"/>. + /// </exception> + private static void GetGenericTypeDefinition(Type type, out Type genericTypeDefinition) + { + genericTypeDefinition = type.GetGenericTypeDefinition(); + } + + /// <summary> /// Gets the element type for the given <paramref name="arrayType"/>. /// </summary> /// <param name="arrayType">Type for the generic array.</param> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index 0c3331900a..30ecd22db7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -184,13 +184,13 @@ namespace Godot } /// <summary> - /// Returns the cross product of this vector and <paramref name="b"/>. + /// Returns the cross product of this vector and <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector.</param> + /// <param name="with">The other vector.</param> /// <returns>The cross product value.</returns> - public real_t Cross(Vector2 b) + public real_t Cross(Vector2 with) { - return (x * b.y) - (y * b.x); + return (x * with.y) - (y * with.x); } /// <summary> @@ -222,13 +222,13 @@ namespace Godot } /// <summary> - /// Returns the normalized vector pointing from this vector to <paramref name="b"/>. + /// Returns the normalized vector pointing from this vector to <paramref name="to"/>. /// </summary> - /// <param name="b">The other vector to point towards.</param> - /// <returns>The direction from this vector to <paramref name="b"/>.</returns> - public Vector2 DirectionTo(Vector2 b) + /// <param name="to">The other vector to point towards.</param> + /// <returns>The direction from this vector to <paramref name="to"/>.</returns> + public Vector2 DirectionTo(Vector2 to) { - return new Vector2(b.x - x, b.y - y).Normalized(); + return new Vector2(to.x - x, to.y - y).Normalized(); } /// <summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs index 6cac16d53b..3bbc2ae2ba 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -149,45 +149,45 @@ namespace Godot } /// <summary> - /// Returns the cross product of this vector and <paramref name="b"/>. + /// Returns the cross product of this vector and <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector.</param> + /// <param name="with">The other vector.</param> /// <returns>The cross product vector.</returns> - public int Cross(Vector2i b) + public int Cross(Vector2i with) { - return x * b.y - y * b.x; + return x * with.y - y * with.x; } /// <summary> - /// Returns the squared distance between this vector and <paramref name="b"/>. + /// Returns the squared distance between this vector and <paramref name="to"/>. /// This method runs faster than <see cref="DistanceTo"/>, so prefer it if /// you need to compare vectors or need the squared distance for some formula. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="to">The other vector to use.</param> /// <returns>The squared distance between the two vectors.</returns> - public int DistanceSquaredTo(Vector2i b) + public int DistanceSquaredTo(Vector2i to) { - return (b - this).LengthSquared(); + return (to - this).LengthSquared(); } /// <summary> - /// Returns the distance between this vector and <paramref name="b"/>. + /// Returns the distance between this vector and <paramref name="to"/>. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="to">The other vector to use.</param> /// <returns>The distance between the two vectors.</returns> - public real_t DistanceTo(Vector2i b) + public real_t DistanceTo(Vector2i to) { - return (b - this).Length(); + return (to - this).Length(); } /// <summary> - /// Returns the dot product of this vector and <paramref name="b"/>. + /// Returns the dot product of this vector and <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="with">The other vector to use.</param> /// <returns>The dot product of the two vectors.</returns> - public int Dot(Vector2i b) + public int Dot(Vector2i with) { - return x * b.x + y * b.y; + return x * with.x + y * with.y; } /// <summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 63d9be0a6d..15acf88f62 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -170,17 +170,17 @@ namespace Godot } /// <summary> - /// Returns the cross product of this vector and <paramref name="b"/>. + /// Returns the cross product of this vector and <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector.</param> + /// <param name="with">The other vector.</param> /// <returns>The cross product vector.</returns> - public Vector3 Cross(Vector3 b) + public Vector3 Cross(Vector3 with) { return new Vector3 ( - (y * b.z) - (z * b.y), - (z * b.x) - (x * b.z), - (x * b.y) - (y * b.x) + (y * with.z) - (z * with.y), + (z * with.x) - (x * with.z), + (x * with.y) - (y * with.x) ); } @@ -212,46 +212,46 @@ namespace Godot } /// <summary> - /// Returns the normalized vector pointing from this vector to <paramref name="b"/>. + /// Returns the normalized vector pointing from this vector to <paramref name="to"/>. /// </summary> - /// <param name="b">The other vector to point towards.</param> - /// <returns>The direction from this vector to <paramref name="b"/>.</returns> - public Vector3 DirectionTo(Vector3 b) + /// <param name="to">The other vector to point towards.</param> + /// <returns>The direction from this vector to <paramref name="to"/>.</returns> + public Vector3 DirectionTo(Vector3 to) { - return new Vector3(b.x - x, b.y - y, b.z - z).Normalized(); + return new Vector3(to.x - x, to.y - y, to.z - z).Normalized(); } /// <summary> - /// Returns the squared distance between this vector and <paramref name="b"/>. + /// Returns the squared distance between this vector and <paramref name="to"/>. /// This method runs faster than <see cref="DistanceTo"/>, so prefer it if /// you need to compare vectors or need the squared distance for some formula. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="to">The other vector to use.</param> /// <returns>The squared distance between the two vectors.</returns> - public real_t DistanceSquaredTo(Vector3 b) + public real_t DistanceSquaredTo(Vector3 to) { - return (b - this).LengthSquared(); + return (to - this).LengthSquared(); } /// <summary> - /// Returns the distance between this vector and <paramref name="b"/>. + /// Returns the distance between this vector and <paramref name="to"/>. /// </summary> /// <seealso cref="DistanceSquaredTo(Vector3)"/> - /// <param name="b">The other vector to use.</param> + /// <param name="to">The other vector to use.</param> /// <returns>The distance between the two vectors.</returns> - public real_t DistanceTo(Vector3 b) + public real_t DistanceTo(Vector3 to) { - return (b - this).Length(); + return (to - this).Length(); } /// <summary> - /// Returns the dot product of this vector and <paramref name="b"/>. + /// Returns the dot product of this vector and <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="with">The other vector to use.</param> /// <returns>The dot product of the two vectors.</returns> - public real_t Dot(Vector3 b) + public real_t Dot(Vector3 with) { - return (x * b.x) + (y * b.y) + (z * b.z); + return (x * with.x) + (y * with.y) + (z * with.z); } /// <summary> @@ -412,16 +412,16 @@ namespace Godot } /// <summary> - /// Returns the outer product with <paramref name="b"/>. + /// Returns the outer product with <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector.</param> + /// <param name="with">The other vector.</param> /// <returns>A <see cref="Basis"/> representing the outer product matrix.</returns> - public Basis Outer(Vector3 b) + public Basis Outer(Vector3 with) { return new Basis( - x * b.x, x * b.y, x * b.z, - y * b.x, y * b.y, y * b.z, - z * b.x, z * b.y, z * b.z + x * with.x, x * with.y, x * with.z, + y * with.x, y * with.y, y * with.z, + z * with.x, z * with.y, z * with.z ); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs index 474876fc91..562f653fa8 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -124,36 +124,36 @@ namespace Godot } /// <summary> - /// Returns the squared distance between this vector and <paramref name="b"/>. + /// Returns the squared distance between this vector and <paramref name="to"/>. /// This method runs faster than <see cref="DistanceTo"/>, so prefer it if /// you need to compare vectors or need the squared distance for some formula. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="to">The other vector to use.</param> /// <returns>The squared distance between the two vectors.</returns> - public int DistanceSquaredTo(Vector3i b) + public int DistanceSquaredTo(Vector3i to) { - return (b - this).LengthSquared(); + return (to - this).LengthSquared(); } /// <summary> - /// Returns the distance between this vector and <paramref name="b"/>. + /// Returns the distance between this vector and <paramref name="to"/>. /// </summary> /// <seealso cref="DistanceSquaredTo(Vector3i)"/> - /// <param name="b">The other vector to use.</param> + /// <param name="to">The other vector to use.</param> /// <returns>The distance between the two vectors.</returns> - public real_t DistanceTo(Vector3i b) + public real_t DistanceTo(Vector3i to) { - return (b - this).Length(); + return (to - this).Length(); } /// <summary> - /// Returns the dot product of this vector and <paramref name="b"/>. + /// Returns the dot product of this vector and <paramref name="with"/>. /// </summary> - /// <param name="b">The other vector to use.</param> + /// <param name="with">The other vector to use.</param> /// <returns>The dot product of the two vectors.</returns> - public int Dot(Vector3i b) + public int Dot(Vector3i with) { - return x * b.x + y * b.y + z * b.z; + return x * with.x + y * with.y + z * with.z; } /// <summary> diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index 86976de244..e367ecb7d6 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -144,7 +144,7 @@ void godot_icall_Array_Insert(Array *ptr, int32_t index, MonoObject *item) { MonoBoolean godot_icall_Array_Remove(Array *ptr, MonoObject *item) { int idx = ptr->find(GDMonoMarshal::mono_object_to_variant(item)); if (idx >= 0) { - ptr->remove(idx); + ptr->remove_at(idx); return true; } return false; @@ -155,7 +155,7 @@ void godot_icall_Array_RemoveAt(Array *ptr, int32_t index) { GDMonoUtils::set_pending_exception(mono_get_exception_index_out_of_range()); return; } - ptr->remove(index); + ptr->remove_at(index); } int32_t godot_icall_Array_Resize(Array *ptr, int32_t new_size) { diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 24bd1ed492..2b4cc7fcc3 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -229,9 +229,6 @@ private: #endif } - _GodotSharpDirs(const _GodotSharpDirs &); - _GodotSharpDirs &operator=(const _GodotSharpDirs &); - public: static _GodotSharpDirs &get_singleton() { static _GodotSharpDirs singleton; diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h index d0e51d159f..a18a4ce646 100644 --- a/modules/mono/mono_gc_handle.h +++ b/modules/mono/mono_gc_handle.h @@ -56,13 +56,12 @@ struct MonoGCHandleData { void release(); - MonoGCHandleData &operator=(const MonoGCHandleData &p_other) { + void operator=(const MonoGCHandleData &p_other) { #ifdef DEBUG_ENABLED CRASH_COND(!is_released()); #endif handle = p_other.handle; type = p_other.type; - return *this; } MonoGCHandleData(const MonoGCHandleData &) = default; diff --git a/modules/mono/mono_gd/gd_mono_cache.cpp b/modules/mono/mono_gd/gd_mono_cache.cpp index 2bf55493e0..60277e0652 100644 --- a/modules/mono/mono_gd/gd_mono_cache.cpp +++ b/modules/mono/mono_gd/gd_mono_cache.cpp @@ -177,6 +177,8 @@ void CachedData::clear_godot_api_cache() { methodthunk_MarshalUtils_TypeIsGenericICollection.nullify(); methodthunk_MarshalUtils_TypeIsGenericIDictionary.nullify(); + methodthunk_MarshalUtils_GetGenericTypeDefinition.nullify(); + methodthunk_MarshalUtils_ArrayGetElementType.nullify(); methodthunk_MarshalUtils_DictionaryGetKeyValueTypes.nullify(); @@ -299,6 +301,8 @@ void update_godot_api_cache() { CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericICollection, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericICollection", 1)); CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, TypeIsGenericIDictionary, GODOT_API_CLASS(MarshalUtils)->get_method("TypeIsGenericIDictionary", 1)); + CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, GetGenericTypeDefinition, GODOT_API_CLASS(MarshalUtils)->get_method("GetGenericTypeDefinition", 2)); + CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, ArrayGetElementType, GODOT_API_CLASS(MarshalUtils)->get_method("ArrayGetElementType", 2)); CACHE_METHOD_THUNK_AND_CHECK(MarshalUtils, DictionaryGetKeyValueTypes, GODOT_API_CLASS(MarshalUtils)->get_method("DictionaryGetKeyValueTypes", 3)); diff --git a/modules/mono/mono_gd/gd_mono_cache.h b/modules/mono/mono_gd/gd_mono_cache.h index 4b4688b4d9..5101907bd6 100644 --- a/modules/mono/mono_gd/gd_mono_cache.h +++ b/modules/mono/mono_gd/gd_mono_cache.h @@ -148,6 +148,8 @@ struct CachedData { GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericICollection; GDMonoMethodThunkR<MonoBoolean, MonoReflectionType *> methodthunk_MarshalUtils_TypeIsGenericIDictionary; + GDMonoMethodThunk<MonoReflectionType *, MonoReflectionType **> methodthunk_MarshalUtils_GetGenericTypeDefinition; + GDMonoMethodThunk<MonoReflectionType *, MonoReflectionType **> methodthunk_MarshalUtils_ArrayGetElementType; GDMonoMethodThunk<MonoReflectionType *, MonoReflectionType **, MonoReflectionType **> methodthunk_MarshalUtils_DictionaryGetKeyValueTypes; diff --git a/modules/mono/mono_gd/gd_mono_class.cpp b/modules/mono/mono_gd/gd_mono_class.cpp index 4f4480fa49..520568071e 100644 --- a/modules/mono/mono_gd/gd_mono_class.cpp +++ b/modules/mono/mono_gd/gd_mono_class.cpp @@ -464,9 +464,18 @@ const Vector<GDMonoClass *> &GDMonoClass::get_all_delegates() { return delegates_list; } + // If the class is generic we must use the generic type definition. + MonoClass *klass = mono_class; + if (mono_type_get_type(get_mono_type()) == MONO_TYPE_GENERICINST) { + MonoReflectionType *reftype = mono_type_get_object(mono_domain_get(), get_mono_type()); + GDMonoUtils::Marshal::get_generic_type_definition(reftype, &reftype); + MonoType *type = mono_reflection_type_get_type(reftype); + klass = mono_class_from_mono_type(type); + } + void *iter = nullptr; MonoClass *raw_class = nullptr; - while ((raw_class = mono_class_get_nested_types(mono_class, &iter)) != nullptr) { + while ((raw_class = mono_class_get_nested_types(klass, &iter)) != nullptr) { if (mono_class_is_delegate(raw_class)) { StringName name = String::utf8(mono_class_get_name(raw_class)); diff --git a/modules/mono/mono_gd/gd_mono_log.cpp b/modules/mono/mono_gd/gd_mono_log.cpp index 179bbfb40c..bcdcd6623b 100644 --- a/modules/mono/mono_gd/gd_mono_log.cpp +++ b/modules/mono/mono_gd/gd_mono_log.cpp @@ -121,12 +121,10 @@ void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) { ERR_FAIL_COND(da->list_dir_begin() != OK); - String current; - while ((current = da->get_next()).length()) { - if (da->current_is_dir()) { - continue; - } - if (!current.ends_with(".txt")) { + String current = da->get_next(); + while (!current.is_empty()) { + if (da->current_is_dir() || !current.ends_with(".txt")) { + current = da->get_next(); continue; } @@ -135,6 +133,7 @@ void GDMonoLog::_delete_old_log_files(const String &p_logs_dir) { if (OS::get_singleton()->get_unix_time() - modified_time > MAX_SECS) { da->remove(current); } + current = da->get_next(); } da->list_dir_end(); diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 09aa9ad948..505c637af9 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -614,6 +614,12 @@ bool type_is_generic_idictionary(MonoReflectionType *p_reftype) { return (bool)res; } +void get_generic_type_definition(MonoReflectionType *p_reftype, MonoReflectionType **r_generic_reftype) { + MonoException *exc = nullptr; + CACHED_METHOD_THUNK(MarshalUtils, GetGenericTypeDefinition).invoke(p_reftype, r_generic_reftype, &exc); + UNHANDLED_EXCEPTION(exc); +} + void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype) { MonoException *exc = nullptr; CACHED_METHOD_THUNK(MarshalUtils, ArrayGetElementType).invoke(p_array_reftype, r_elem_reftype, &exc); diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index 773501e93d..3162ef198d 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -62,6 +62,8 @@ bool type_is_generic_ienumerable(MonoReflectionType *p_reftype); bool type_is_generic_icollection(MonoReflectionType *p_reftype); bool type_is_generic_idictionary(MonoReflectionType *p_reftype); +void get_generic_type_definition(MonoReflectionType *p_reftype, MonoReflectionType **r_generic_reftype); + void array_get_element_type(MonoReflectionType *p_array_reftype, MonoReflectionType **r_elem_reftype); void dictionary_get_key_value_types(MonoReflectionType *p_dict_reftype, MonoReflectionType **r_key_reftype, MonoReflectionType **r_value_reftype); diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp index f600f07c87..ac3422187f 100644 --- a/modules/navigation/godot_navigation_server.cpp +++ b/modules/navigation/godot_navigation_server.cpp @@ -150,8 +150,8 @@ COMMAND_2(map_set_active, RID, p_map, bool, p_active) { } else { int map_index = active_maps.find(map); ERR_FAIL_COND(map_index < 0); - active_maps.remove(map_index); - active_maps_update_id.remove(map_index); + active_maps.remove_at(map_index); + active_maps_update_id.remove_at(map_index); } } @@ -469,8 +469,8 @@ COMMAND_1(free, RID, p_object) { } int map_index = active_maps.find(map); - active_maps.remove(map_index); - active_maps_update_id.remove(map_index); + active_maps.remove_at(map_index); + active_maps_update_id.remove_at(map_index); map_owner.free(p_object); } else if (region_owner.owns(p_object)) { diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp index 05e040b518..0bce0fc9f0 100644 --- a/modules/navigation/navigation_mesh_generator.cpp +++ b/modules/navigation/navigation_mesh_generator.cpp @@ -36,6 +36,7 @@ #include "core/os/thread.h" #include "scene/3d/collision_shape_3d.h" #include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/multimesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/resources/box_shape_3d.h" #include "scene/resources/capsule_shape_3d.h" @@ -63,17 +64,17 @@ NavigationMeshGenerator *NavigationMeshGenerator::singleton = nullptr; -void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies) { - p_verticies.push_back(p_vec3.x); - p_verticies.push_back(p_vec3.y); - p_verticies.push_back(p_vec3.z); +void NavigationMeshGenerator::_add_vertex(const Vector3 &p_vec3, Vector<float> &p_vertices) { + p_vertices.push_back(p_vec3.x); + p_vertices.push_back(p_vec3.y); + p_vertices.push_back(p_vec3.z); } -void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) { +void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices) { int current_vertex_count; for (int i = 0; i < p_mesh->get_surface_count(); i++) { - current_vertex_count = p_verticies.size() / 3; + current_vertex_count = p_vertices.size() / 3; if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) { continue; @@ -100,7 +101,7 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform const int *ir = mesh_indices.ptr(); for (int j = 0; j < mesh_vertices.size(); j++) { - _add_vertex(p_xform.xform(vr[j]), p_verticies); + _add_vertex(p_xform.xform(vr[j]), p_vertices); } for (int j = 0; j < face_count; j++) { @@ -112,9 +113,9 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform } else { face_count = mesh_vertices.size() / 3; for (int j = 0; j < face_count; j++) { - _add_vertex(p_xform.xform(vr[j * 3 + 0]), p_verticies); - _add_vertex(p_xform.xform(vr[j * 3 + 2]), p_verticies); - _add_vertex(p_xform.xform(vr[j * 3 + 1]), p_verticies); + _add_vertex(p_xform.xform(vr[j * 3 + 0]), p_vertices); + _add_vertex(p_xform.xform(vr[j * 3 + 2]), p_vertices); + _add_vertex(p_xform.xform(vr[j * 3 + 1]), p_vertices); p_indices.push_back(current_vertex_count + (j * 3 + 0)); p_indices.push_back(current_vertex_count + (j * 3 + 1)); @@ -124,14 +125,14 @@ void NavigationMeshGenerator::_add_mesh(const Ref<Mesh> &p_mesh, const Transform } } -void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices) { +void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices) { int face_count = p_faces.size() / 3; - int current_vertex_count = p_verticies.size() / 3; + int current_vertex_count = p_vertices.size() / 3; for (int j = 0; j < face_count; j++) { - _add_vertex(p_xform.xform(p_faces[j * 3 + 0]), p_verticies); - _add_vertex(p_xform.xform(p_faces[j * 3 + 1]), p_verticies); - _add_vertex(p_xform.xform(p_faces[j * 3 + 2]), p_verticies); + _add_vertex(p_xform.xform(p_faces[j * 3 + 0]), p_vertices); + _add_vertex(p_xform.xform(p_faces[j * 3 + 1]), p_vertices); + _add_vertex(p_xform.xform(p_faces[j * 3 + 2]), p_vertices); p_indices.push_back(current_vertex_count + (j * 3 + 0)); p_indices.push_back(current_vertex_count + (j * 3 + 2)); @@ -139,12 +140,27 @@ void NavigationMeshGenerator::_add_faces(const PackedVector3Array &p_faces, cons } } -void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) { +void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_vertices, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children) { if (Object::cast_to<MeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_node); Ref<Mesh> mesh = mesh_instance->get_mesh(); if (mesh.is_valid()) { - _add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_verticies, p_indices); + _add_mesh(mesh, p_accumulated_transform * mesh_instance->get_transform(), p_vertices, p_indices); + } + } + + if (Object::cast_to<MultiMeshInstance3D>(p_node) && p_generate_from != NavigationMesh::PARSED_GEOMETRY_STATIC_COLLIDERS) { + MultiMeshInstance3D *multimesh_instance = Object::cast_to<MultiMeshInstance3D>(p_node); + Ref<MultiMesh> multimesh = multimesh_instance->get_multimesh(); + Ref<Mesh> mesh = multimesh->get_mesh(); + if (mesh.is_valid()) { + int n = multimesh->get_visible_instance_count(); + if (n == -1) { + n = multimesh->get_instance_count(); + } + for (int i = 0; i < n; i++) { + _add_mesh(mesh, p_accumulated_transform * multimesh->get_instance_transform(i), p_vertices, p_indices); + } } } @@ -155,7 +171,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor if (!meshes.is_empty()) { Ref<Mesh> mesh = meshes[1]; if (mesh.is_valid()) { - _add_mesh(mesh, p_accumulated_transform * csg_shape->get_transform(), p_verticies, p_indices); + _add_mesh(mesh, p_accumulated_transform * csg_shape->get_transform(), p_vertices, p_indices); } } } @@ -213,7 +229,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor ConcavePolygonShape3D *concave_polygon = Object::cast_to<ConcavePolygonShape3D>(*s); if (concave_polygon) { - _add_faces(concave_polygon->get_faces(), transform, p_verticies, p_indices); + _add_faces(concave_polygon->get_faces(), transform, p_vertices, p_indices); } ConvexPolygonShape3D *convex_polygon = Object::cast_to<ConvexPolygonShape3D>(*s); @@ -236,12 +252,12 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor } } - _add_faces(faces, transform, p_verticies, p_indices); + _add_faces(faces, transform, p_vertices, p_indices); } } if (mesh.is_valid()) { - _add_mesh(mesh, transform, p_verticies, p_indices); + _add_mesh(mesh, transform, p_vertices, p_indices); } } } @@ -256,7 +272,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor for (int i = 0; i < meshes.size(); i += 2) { Ref<Mesh> mesh = meshes[i + 1]; if (mesh.is_valid()) { - _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_verticies, p_indices); + _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_vertices, p_indices); } } } @@ -269,7 +285,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor if (p_recurse_children) { for (int i = 0; i < p_node->get_child_count(); i++) { - _parse_geometry(p_accumulated_transform, p_node->get_child(i), p_verticies, p_indices, p_generate_from, p_collision_mask, p_recurse_children); + _parse_geometry(p_accumulated_transform, p_node->get_child(i), p_vertices, p_indices, p_generate_from, p_collision_mask, p_recurse_children); } } } diff --git a/modules/navigation/navigation_mesh_generator.h b/modules/navigation/navigation_mesh_generator.h index 78f1329e3f..dac844c68e 100644 --- a/modules/navigation/navigation_mesh_generator.h +++ b/modules/navigation/navigation_mesh_generator.h @@ -49,10 +49,10 @@ class NavigationMeshGenerator : public Object { protected: static void _bind_methods(); - static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_verticies); - static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices); - static void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_verticies, Vector<int> &p_indices); - static void _parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_verticies, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children); + static void _add_vertex(const Vector3 &p_vec3, Vector<float> &p_vertices); + static void _add_mesh(const Ref<Mesh> &p_mesh, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices); + static void _add_faces(const PackedVector3Array &p_faces, const Transform3D &p_xform, Vector<float> &p_vertices, Vector<int> &p_indices); + static void _parse_geometry(Transform3D p_accumulated_transform, Node *p_node, Vector<float> &p_vertices, Vector<int> &p_indices, NavigationMesh::ParsedGeometryType p_generate_from, uint32_t p_collision_mask, bool p_recurse_children); static void _convert_detail_mesh_to_native_navigation_mesh(const rcPolyMeshDetail *p_detail_mesh, Ref<NavigationMesh> p_nav_mesh); static void _build_recast_navigation_mesh( diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 1adaef4d84..f480c86088 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -2148,7 +2148,7 @@ void TextServerAdvanced::font_remove_texture(RID p_font_rid, const Vector2i &p_s ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); ERR_FAIL_INDEX(p_texture_index, fd->cache[size]->textures.size()); - fd->cache[size]->textures.remove(p_texture_index); + fd->cache[size]->textures.remove_at(p_texture_index); } void TextServerAdvanced::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) { diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 80ae10c005..5c06051211 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -1326,7 +1326,7 @@ void TextServerFallback::font_remove_texture(RID p_font_rid, const Vector2i &p_s ERR_FAIL_COND(!_ensure_cache_for_size(fd, size)); ERR_FAIL_INDEX(p_texture_index, fd->cache[size]->textures.size()); - fd->cache[size]->textures.remove(p_texture_index); + fd->cache[size]->textures.remove_at(p_texture_index); } void TextServerFallback::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) { diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 88d92b0083..64823deaba 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -257,7 +257,7 @@ void UPNP::set_device(int index, Ref<UPNPDevice> device) { void UPNP::remove_device(int index) { ERR_FAIL_INDEX(index, devices.size()); - devices.remove(index); + devices.remove_at(index); } void UPNP::clear_devices() { diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp index e8b25b58b6..13dd1f7bc7 100644 --- a/modules/visual_script/editor/visual_script_editor.cpp +++ b/modules/visual_script/editor/visual_script_editor.cpp @@ -1262,6 +1262,23 @@ void VisualScriptEditor::_member_edited() { undo_redo->create_action(TTR("Rename Variable")); undo_redo->add_do_method(script.ptr(), "rename_variable", name, new_name); undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name); + + // Also fix all variable setter & getter calls + List<int> lst; + script->get_node_list(&lst); + for (int &P : lst) { + Ref<VisualScriptPropertySet> pset = script->get_node(P); + if (pset.is_valid() && pset->get_property() == name) { + undo_redo->add_do_method(pset.ptr(), "set_property", new_name); + undo_redo->add_undo_method(pset.ptr(), "set_property", name); + } + Ref<VisualScriptPropertyGet> pget = script->get_node(P); + if (pget.is_valid() && pget->get_property() == name) { + undo_redo->add_do_method(pget.ptr(), "set_property", new_name); + undo_redo->add_undo_method(pget.ptr(), "set_property", name); + } + } + undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); @@ -1278,6 +1295,18 @@ void VisualScriptEditor::_member_edited() { undo_redo->create_action(TTR("Rename Signal")); undo_redo->add_do_method(script.ptr(), "rename_custom_signal", name, new_name); undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, name); + + // Also fix all signal emitting nodes + List<int> lst; + script->get_node_list(&lst); + for (int &P : lst) { + Ref<VisualScriptEmitSignal> psig = script->get_node(P); + if (psig.is_valid() && psig->get_signal() == name) { + undo_redo->add_do_method(psig.ptr(), "set_signal", new_name); + undo_redo->add_undo_method(psig.ptr(), "set_signal", name); + } + } + undo_redo->add_do_method(this, "_update_members"); undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 700cc85672..34d8c0b1e6 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -661,7 +661,7 @@ void VisualScript::custom_signal_remove_argument(const StringName &p_func, int p ERR_FAIL_COND(instances.size()); ERR_FAIL_COND(!custom_signals.has(p_func)); ERR_FAIL_INDEX(p_argidx, custom_signals[p_func].size()); - custom_signals[p_func].remove(p_argidx); + custom_signals[p_func].remove_at(p_argidx); } int VisualScript::custom_signal_get_argument_count(const StringName &p_func) const { diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 55c707890f..699042ffa6 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -1190,7 +1190,7 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { op->nodes[1] = nullptr; expression.write[i].is_op = false; expression.write[i].node = op; - expression.remove(i + 1); + expression.remove_at(i + 1); } } else { @@ -1222,8 +1222,8 @@ VisualScriptExpression::ENode *VisualScriptExpression::_parse_expression() { //replace all 3 nodes by this operator and make it an expression expression.write[next_op - 1].node = op; - expression.remove(next_op); - expression.remove(next_op); + expression.remove_at(next_op); + expression.remove_at(next_op); } } diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 471d8ef0ae..b0af030981 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -253,7 +253,7 @@ String VisualScriptFunction::get_argument_name(int p_argidx) const { void VisualScriptFunction::remove_argument(int p_argidx) { ERR_FAIL_INDEX(p_argidx, arguments.size()); - arguments.remove(p_argidx); + arguments.remove_at(p_argidx); ports_changed_notify(); } @@ -623,7 +623,7 @@ void VisualScriptLists::remove_input_data_port(int p_argidx) { ERR_FAIL_INDEX(p_argidx, inputports.size()); - inputports.remove(p_argidx); + inputports.remove_at(p_argidx); ports_changed_notify(); notify_property_list_changed(); @@ -679,7 +679,7 @@ void VisualScriptLists::remove_output_data_port(int p_argidx) { ERR_FAIL_INDEX(p_argidx, outputports.size()); - outputports.remove(p_argidx); + outputports.remove_at(p_argidx); ports_changed_notify(); notify_property_list_changed(); diff --git a/modules/websocket/editor_debugger_server_websocket.cpp b/modules/websocket/editor_debugger_server_websocket.cpp index d248433d82..78a5fa50d8 100644 --- a/modules/websocket/editor_debugger_server_websocket.cpp +++ b/modules/websocket/editor_debugger_server_websocket.cpp @@ -31,6 +31,8 @@ #include "editor_debugger_server_websocket.h" #include "core/config/project_settings.h" +#include "editor/editor_log.h" +#include "editor/editor_node.h" #include "editor/editor_settings.h" #include "modules/websocket/remote_debugger_peer_websocket.h" @@ -48,19 +50,47 @@ void EditorDebuggerServerWebSocket::poll() { server->poll(); } +String EditorDebuggerServerWebSocket::get_uri() const { + return endpoint; +} + Error EditorDebuggerServerWebSocket::start(const String &p_uri) { + // Default host and port + String bind_host = (String)EditorSettings::get_singleton()->get("network/debug/remote_host"); int bind_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); - String bind_host = EditorSettings::get_singleton()->get("network/debug/remote_host"); + + // Optionally override if (!p_uri.is_empty() && p_uri != "ws://") { String scheme, path; Error err = p_uri.parse_url(scheme, bind_host, bind_port, path); ERR_FAIL_COND_V(err != OK, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(!bind_host.is_valid_ip_address() && bind_host != "*", ERR_INVALID_PARAMETER); } + + // Set up the server server->set_bind_ip(bind_host); Vector<String> compatible_protocols; compatible_protocols.push_back("binary"); // compatibility with EMSCRIPTEN TCP-to-WebSocket layer. - return server->listen(bind_port, compatible_protocols); + + // Try listening on ports + const int max_attempts = 5; + for (int attempt = 1;; ++attempt) { + const Error err = server->listen(bind_port, compatible_protocols); + if (err == OK) { + break; + } + if (attempt >= max_attempts) { + EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, remote debugging unavailable.", bind_port), EditorLog::MSG_TYPE_ERROR); + return err; + } + int last_port = bind_port++; + EditorNode::get_log()->add_message(vformat("Cannot listen on port %d, trying %d instead.", last_port, bind_port), EditorLog::MSG_TYPE_WARNING); + } + + // Endpoint that the client should connect to + endpoint = vformat("ws://%s:%d", bind_host, bind_port); + + return OK; } void EditorDebuggerServerWebSocket::stop() { diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor_debugger_server_websocket.h index 14ab0109b2..1e5ea66146 100644 --- a/modules/websocket/editor_debugger_server_websocket.h +++ b/modules/websocket/editor_debugger_server_websocket.h @@ -40,6 +40,7 @@ class EditorDebuggerServerWebSocket : public EditorDebuggerServer { private: Ref<WebSocketServer> server; List<int> pending_peers; + String endpoint; public: static EditorDebuggerServer *create(const String &p_protocol); @@ -47,12 +48,13 @@ public: void _peer_connected(int p_peer, String p_protocol); void _peer_disconnected(int p_peer, bool p_was_clean); - void poll() override; - Error start(const String &p_uri) override; - void stop() override; - bool is_active() const override; - bool is_connection_available() const override; - Ref<RemoteDebuggerPeer> take_connection() override; + virtual void poll() override; + virtual String get_uri() const override; + virtual Error start(const String &p_uri = "") override; + virtual void stop() override; + virtual bool is_active() const override; + virtual bool is_connection_available() const override; + virtual Ref<RemoteDebuggerPeer> take_connection() override; EditorDebuggerServerWebSocket(); ~EditorDebuggerServerWebSocket(); diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index dc259da886..52f80b3080 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -223,7 +223,7 @@ void AndroidInputHandler::process_touch(int p_event, int p_pointer, const Vector ev->set_pressed(false); ev->set_position(touch[i].pos); Input::get_singleton()->parse_input_event(ev); - touch.remove(i); + touch.remove_at(i); break; } diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 05cd63d935..c5d3cbd966 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -2212,7 +2212,7 @@ void EditorExportPlatformAndroid::get_command_line_flags(const Ref<EditorExportP Vector<String> command_line_strings = cmdline.strip_edges().split(" "); for (int i = 0; i < command_line_strings.size(); i++) { if (command_line_strings[i].strip_edges().length() == 0) { - command_line_strings.remove(i); + command_line_strings.remove_at(i); i--; } } diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp index 7450215cfb..0abd255c7c 100644 --- a/platform/iphone/export/export_plugin.cpp +++ b/platform/iphone/export/export_plugin.cpp @@ -728,10 +728,10 @@ Error EditorExportPlatformIOS::_export_loading_screen_images(const Ref<EditorExp Error EditorExportPlatformIOS::_walk_dir_recursive(DirAccess *p_da, FileHandler p_handler, void *p_userdata) { Vector<String> dirs; - String path; String current_dir = p_da->get_current_dir(); p_da->list_dir_begin(); - while ((path = p_da->get_next()).length() != 0) { + String path = p_da->get_next(); + while (!path.is_empty()) { if (p_da->current_is_dir()) { if (path != "." && path != "..") { dirs.push_back(path); @@ -743,6 +743,7 @@ Error EditorExportPlatformIOS::_walk_dir_recursive(DirAccess *p_da, FileHandler return err; } } + path = p_da->get_next(); } p_da->list_dir_end(); diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index fa9e6eed15..8d9ba82fd4 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -28,11 +28,11 @@ if env["javascript_eval"]: sys_env.AddJSLibraries(["js/libs/library_godot_javascript_singleton.js"]) for lib in sys_env["JS_LIBS"]: - sys_env.Append(LINKFLAGS=["--js-library", lib]) + sys_env.Append(LINKFLAGS=["--js-library", lib.abspath]) for js in env["JS_PRE"]: - sys_env.Append(LINKFLAGS=["--pre-js", env.File(js).path]) + sys_env.Append(LINKFLAGS=["--pre-js", js.abspath]) for ext in env["JS_EXTERNS"]: - sys_env["ENV"]["EMCC_CLOSURE_ARGS"] += " --externs " + ext.path + sys_env["ENV"]["EMCC_CLOSURE_ARGS"] += " --externs " + ext.abspath build = [] if env["gdnative_enabled"]: diff --git a/platform/javascript/js/libs/library_godot_input.js b/platform/javascript/js/libs/library_godot_input.js index d85d0d5335..945dbba902 100644 --- a/platform/javascript/js/libs/library_godot_input.js +++ b/platform/javascript/js/libs/library_godot_input.js @@ -393,7 +393,9 @@ const GodotInput = { const rect = canvas.getBoundingClientRect(); const pos = GodotInput.computePosition(evt, rect); const modifiers = GodotInput.getModifiers(evt); - if (p_pressed && document.activeElement !== GodotConfig.canvas) { + // Since the event is consumed, focus manually. + // NOTE: The iframe container may not have focus yet, so focus even when already active. + if (p_pressed) { GodotConfig.canvas.focus(); } if (func(p_pressed, evt.button, pos[0], pos[1], modifiers)) { @@ -412,7 +414,9 @@ const GodotInput = { const func = GodotRuntime.get_func(callback); const canvas = GodotConfig.canvas; function touch_cb(type, evt) { - if (type === 0 && document.activeElement !== GodotConfig.canvas) { + // Since the event is consumed, focus manually. + // NOTE: The iframe container may not have focus yet, so focus even when already active. + if (type === 0) { GodotConfig.canvas.focus(); } const rect = canvas.getBoundingClientRect(); @@ -420,9 +424,9 @@ const GodotInput = { for (let i = 0; i < touches.length; i++) { const touch = touches[i]; const pos = GodotInput.computePosition(touch, rect); - GodotRuntime.setHeapValue(coords + (i * 2), pos[0], 'double'); - GodotRuntime.setHeapValue(coords + (i * 2 + 8), pos[1], 'double'); - GodotRuntime.setHeapValue(ids + i, touch.identifier, 'i32'); + GodotRuntime.setHeapValue(coords + (i * 2) * 8, pos[0], 'double'); + GodotRuntime.setHeapValue(coords + (i * 2 + 1) * 8, pos[1], 'double'); + GodotRuntime.setHeapValue(ids + i * 4, touch.identifier, 'i32'); } func(type, touches.length); if (evt.cancelable) { diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 2a62780410..74ec8b652f 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -286,7 +286,7 @@ void DisplayServerX11::_flush_mouse_motion() { XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data; if (event_data->evtype == XI_RawMotion) { XFreeEventData(x11_display, &event.xcookie); - polled_events.remove(event_index--); + polled_events.remove_at(event_index--); continue; } XFreeEventData(x11_display, &event.xcookie); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 1c6afabfab..55cc21cc6c 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -253,7 +253,7 @@ void JoypadLinux::close_joypad(int p_id) { if (joy.fd != -1) { close(joy.fd); joy.fd = -1; - attached_devices.remove(attached_devices.find(joy.devpath)); + attached_devices.remove_at(attached_devices.find(joy.devpath)); input->joy_connection_changed(p_id, false, ""); }; } diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp index a88f7bb332..36a2e5e205 100644 --- a/platform/osx/export/export_plugin.cpp +++ b/platform/osx/export/export_plugin.cpp @@ -960,9 +960,10 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String DirAccessRef da = DirAccess::open(dir); da->list_dir_begin(); - String f; - while ((f = da->get_next()) != "") { + String f = da->get_next(); + while (!f.is_empty()) { if (f == "." || f == "..") { + f = da->get_next(); continue; } if (da->is_link(f)) { @@ -1065,6 +1066,7 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String zipCloseFileInZip(p_zip); } + f = da->get_next(); } da->list_dir_end(); } diff --git a/platform/osx/gl_manager_osx.mm b/platform/osx/gl_manager_osx.mm index cce58530ee..60e0706fc0 100644 --- a/platform/osx/gl_manager_osx.mm +++ b/platform/osx/gl_manager_osx.mm @@ -75,7 +75,7 @@ Error GLManager_OSX::window_create(DisplayServer::WindowID p_window_id, id p_vie win.window_view = p_view; if (_create_context(win) != OK) { - _windows.remove(_windows.size() - 1); + _windows.remove_at(_windows.size() - 1); return FAILED; } diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index 8405ed1da1..48d165d30b 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -264,7 +264,7 @@ void JoypadOSX::_device_removed(IOReturn p_res, IOHIDDeviceRef p_device) { input->joy_connection_changed(device_list[device].id, false, ""); device_list.write[device].free(); - device_list.remove(device); + device_list.remove_at(device); } static String _hex_str(uint8_t p_byte) { diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 45a81be80a..39608bdea8 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -178,7 +178,7 @@ class OSXTerminalLogger : public StdLogger { public: - virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type = ERR_ERROR) { + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR) { if (!should_log(true)) { return; } diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp index a54b85a803..192814efe4 100644 --- a/platform/uwp/export/export_plugin.cpp +++ b/platform/uwp/export/export_plugin.cpp @@ -376,7 +376,7 @@ Error EditorExportPlatformUWP::export_project(const Ref<EditorExportPreset> &p_p Vector<String> cl = ((String)p_preset->get("command_line/extra_args")).strip_edges().split(" "); for (int i = 0; i < cl.size(); i++) { if (cl[i].strip_edges().length() == 0) { - cl.remove(i); + cl.remove_at(i); i--; } } diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp index 1ce8b0b040..fe98f8b0ba 100644 --- a/platform/windows/gl_manager_windows.cpp +++ b/platform/windows/gl_manager_windows.cpp @@ -77,7 +77,7 @@ int GLManager_Windows::_find_or_create_display(GLWindow &win) { if (err != OK) { // not good // delete the _display? - _displays.remove(new_display_id); + _displays.remove_at(new_display_id); return -1; } @@ -193,7 +193,7 @@ Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND if (win.gldisplay_id == -1) { // release DC? - _windows.remove(_windows.size() - 1); + _windows.remove_at(_windows.size() - 1); return FAILED; } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d8d4e92d9d..6a0a4790fc 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -447,7 +447,12 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, ZeroMemory(&pi.pi, sizeof(pi.pi)); LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si; - int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi); + DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS; +#ifndef DEBUG_ENABLED + dwCreationFlags |= CREATE_NO_WINDOW; +#endif + + int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, dwCreationFlags, nullptr, nullptr, si_w, &pi.pi); ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command); WaitForSingleObject(pi.pi.hProcess, INFINITE); @@ -475,7 +480,12 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg ZeroMemory(&pi.pi, sizeof(pi.pi)); LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si; - int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi); + DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS; +#ifndef DEBUG_ENABLED + dwCreationFlags |= CREATE_NO_WINDOW; +#endif + + int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, dwCreationFlags, nullptr, nullptr, si_w, &pi.pi); ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command); ProcessID pid = pi.pi.dwProcessId; diff --git a/platform/windows/windows_terminal_logger.cpp b/platform/windows/windows_terminal_logger.cpp index e54a61fdfd..d4148630f0 100644 --- a/platform/windows/windows_terminal_logger.cpp +++ b/platform/windows/windows_terminal_logger.cpp @@ -71,7 +71,7 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er #endif } -void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) { +void WindowsTerminalLogger::log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify, ErrorType p_type) { if (!should_log(true)) { return; } diff --git a/platform/windows/windows_terminal_logger.h b/platform/windows/windows_terminal_logger.h index aacfe5869e..86b65ae30a 100644 --- a/platform/windows/windows_terminal_logger.h +++ b/platform/windows/windows_terminal_logger.h @@ -37,8 +37,8 @@ class WindowsTerminalLogger : public StdLogger { public: - virtual void logv(const char *p_format, va_list p_list, bool p_err); - virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR); + virtual void logv(const char *p_format, va_list p_list, bool p_err) override; + virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR) override; virtual ~WindowsTerminalLogger(); }; diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp index 24da2ce9ce..8bf95e6965 100644 --- a/scene/2d/audio_stream_player_2d.cpp +++ b/scene/2d/audio_stream_player_2d.cpp @@ -97,7 +97,7 @@ void AudioStreamPlayer2D::_notification(int p_what) { while (stream_playbacks.size() > max_polyphony) { AudioServer::get_singleton()->stop_playback_stream(stream_playbacks[0]); - stream_playbacks.remove(0); + stream_playbacks.remove_at(0); } } } diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index bf5671be19..b6902686fe 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -176,7 +176,7 @@ Transform2D Camera2D::get_camera_transform() { Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom); - if (!limit_smoothing_enabled) { + if (!smoothing_enabled || !limit_smoothing_enabled) { if (screen_rect.position.x < limit[SIDE_LEFT]) { screen_rect.position.x = limit[SIDE_LEFT]; } diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 4b348f12e6..bd13d96b01 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -434,7 +434,7 @@ void CollisionObject2D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) PhysicsServer2D::get_singleton()->body_remove_shape(rid, index_to_remove); } - shapes[p_owner].shapes.remove(p_shape); + shapes[p_owner].shapes.remove_at(p_shape); for (KeyValue<uint32_t, ShapeData> &E : shapes) { for (int i = 0; i < E.value.shapes.size(); i++) { diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 80c17b6e88..8d997bb1f5 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -890,7 +890,7 @@ void CPUParticles2D::_particles_process(double p_delta) { real_t base_angle = (tex_angle)*Math::lerp(parameters_min[PARAM_ANGLE], parameters_max[PARAM_ANGLE], p.angle_rand); base_angle += p.custom[1] * lifetime * tex_angular_velocity * Math::lerp(parameters_min[PARAM_ANGULAR_VELOCITY], parameters_max[PARAM_ANGULAR_VELOCITY], rand_from_seed(alt_seed)); p.rotation = Math::deg2rad(base_angle); //angle - p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand) + p.custom[1] * tex_anim_speed * Math::lerp(parameters_min[PARAM_ANIM_SPEED], parameters_max[PARAM_ANIM_SPEED], rand_from_seed(alt_seed)); + p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand) + tv * tex_anim_speed * Math::lerp(parameters_min[PARAM_ANIM_SPEED], parameters_max[PARAM_ANIM_SPEED], rand_from_seed(alt_seed)); } //apply color //apply hue rotation diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index f1f4d1b769..4384ec8141 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -170,6 +170,13 @@ void GPUParticles2D::set_trail_section_subdivisions(int p_subdivisions) { update(); } +#ifdef TOOLS_ENABLED +void GPUParticles2D::set_show_visibility_rect(bool p_show_visibility_rect) { + show_visibility_rect = p_show_visibility_rect; + update(); +} +#endif + bool GPUParticles2D::is_trail_enabled() const { return trail_enabled; } @@ -452,7 +459,7 @@ void GPUParticles2D::_notification(int p_what) { RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_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_ancestor_of(this))) { + if (show_visibility_rect) { draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false); } #endif @@ -588,6 +595,9 @@ GPUParticles2D::GPUParticles2D() { set_speed_scale(1); set_fixed_fps(30); set_collision_base_size(collision_base_size); +#ifdef TOOLS_ENABLED + show_visibility_rect = false; +#endif } GPUParticles2D::~GPUParticles2D() { diff --git a/scene/2d/gpu_particles_2d.h b/scene/2d/gpu_particles_2d.h index d7eee461b4..a9e66b3051 100644 --- a/scene/2d/gpu_particles_2d.h +++ b/scene/2d/gpu_particles_2d.h @@ -58,7 +58,9 @@ private: bool local_coords; int fixed_fps; bool fractional_delta; - +#ifdef TOOLS_ENABLED + bool show_visibility_rect; +#endif Ref<Material> process_material; DrawOrder draw_order; @@ -81,7 +83,6 @@ protected: static void _bind_methods(); virtual void _validate_property(PropertyInfo &property) const override; void _notification(int p_what); - void _update_collision_size(); public: @@ -102,6 +103,10 @@ public: void set_trail_sections(int p_sections); void set_trail_section_subdivisions(int p_subdivisions); +#ifdef TOOLS_ENABLED + void set_show_visibility_rect(bool p_show_visibility_rect); +#endif + bool is_emitting() const; int get_amount() const; double get_lifetime() const; diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 37eb45c21d..00767ec22c 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -148,7 +148,7 @@ void Line2D::add_point(Vector2 p_pos, int p_atpos) { } void Line2D::remove_point(int i) { - _points.remove(i); + _points.remove_at(i); update(); } diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp index 204ed72878..ecd79c23a7 100644 --- a/scene/2d/navigation_region_2d.cpp +++ b/scene/2d/navigation_region_2d.cpp @@ -207,7 +207,7 @@ void NavigationPolygon::set_outline(int p_idx, const Vector<Vector2> &p_outline) void NavigationPolygon::remove_outline(int p_idx) { ERR_FAIL_INDEX(p_idx, outlines.size()); - outlines.remove(p_idx); + outlines.remove_at(p_idx); rect_cache_dirty = true; } diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index ed30e871d7..40211f2a9b 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -100,16 +100,18 @@ void Path2D::_notification(int p_what) { #endif const Color color = Color(0.5, 0.6, 1.0, 0.7); - for (int i = 0; i < curve->get_point_count(); i++) { - Vector2 prev_p = curve->get_point_position(i); + _cached_draw_pts.resize(curve->get_point_count() * 8); + int count = 0; - for (int j = 1; j <= 8; j++) { - real_t frac = j / 8.0; + for (int i = 0; i < curve->get_point_count(); i++) { + for (int j = 0; j < 8; j++) { + real_t frac = j * (1.0 / 8.0); Vector2 p = curve->interpolate(i, frac); - draw_line(prev_p, p, color, line_width); - prev_p = p; + _cached_draw_pts.set(count++, p); } } + + draw_polyline(_cached_draw_pts, color, line_width, true); } } diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index 3b12f025fc..7e8478283f 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -38,6 +38,7 @@ class Path2D : public Node2D { GDCLASS(Path2D, Node2D); Ref<Curve2D> curve; + Vector<Vector2> _cached_draw_pts; void _curve_changed(); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index f00959bbb6..7a237bf557 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -532,7 +532,7 @@ Vector<float> Polygon2D::get_bone_weights(int p_index) const { void Polygon2D::erase_bone(int p_idx) { ERR_FAIL_INDEX(p_idx, bone_weights.size()); - bone_weights.remove(p_idx); + bone_weights.remove_at(p_idx); } void Polygon2D::clear_bones() { diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 63a0fb9b89..b558f0aa21 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -165,7 +165,7 @@ void Bone2D::_notification(int p_what) { if (skeleton) { for (int i = 0; i < skeleton->bones.size(); i++) { if (skeleton->bones[i].bone == this) { - skeleton->bones.remove(i); + skeleton->bones.remove_at(i); break; } } diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index a8caebf088..084a5a520d 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -576,7 +576,7 @@ void TileMap::move_layer(int p_layer, int p_to_pos) { TileMapLayer tl = layers[p_layer]; layers.insert(p_to_pos, tl); - layers.remove(p_to_pos < p_layer ? p_layer + 1 : p_layer); + layers.remove_at(p_to_pos < p_layer ? p_layer + 1 : p_layer); _recreate_internals(); notify_property_list_changed(); @@ -595,7 +595,7 @@ void TileMap::remove_layer(int p_layer) { // Clear before removing the layer. _clear_internals(); - layers.remove(p_layer); + layers.remove_at(p_layer); _recreate_internals(); notify_property_list_changed(); diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 34f748b197..efe23c6102 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -311,7 +311,7 @@ void AudioStreamPlayer3D::_notification(int p_what) { while (stream_playbacks.size() > max_polyphony) { AudioServer::get_singleton()->stop_playback_stream(stream_playbacks[0]); - stream_playbacks.remove(0); + stream_playbacks.remove_at(0); } } } diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index a166a05c71..085f1ade66 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -628,7 +628,7 @@ void CollisionObject3D::shape_owner_remove_shape(uint32_t p_owner, int p_shape) --debug_shapes_count; } - shapes[p_owner].shapes.remove(p_shape); + shapes[p_owner].shapes.remove_at(p_shape); for (KeyValue<uint32_t, ShapeData> &E : shapes) { for (int i = 0; i < E.value.shapes.size(); i++) { diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index d347d24c2c..b081142fbf 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -881,53 +881,53 @@ void CPUParticles3D::_particles_process(double p_delta) { p.custom[1] = p.time / lifetime; tv = p.time / p.lifetime; - real_t tex_linear_velocity = 0.0; + real_t tex_linear_velocity = 1.0; if (curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) { tex_linear_velocity = curve_parameters[PARAM_INITIAL_LINEAR_VELOCITY]->interpolate(tv); } - real_t tex_orbit_velocity = 0.0; + real_t tex_orbit_velocity = 1.0; if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) { if (curve_parameters[PARAM_ORBIT_VELOCITY].is_valid()) { tex_orbit_velocity = curve_parameters[PARAM_ORBIT_VELOCITY]->interpolate(tv); } } - real_t tex_angular_velocity = 0.0; + real_t tex_angular_velocity = 1.0; if (curve_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) { tex_angular_velocity = curve_parameters[PARAM_ANGULAR_VELOCITY]->interpolate(tv); } - real_t tex_linear_accel = 0.0; + real_t tex_linear_accel = 1.0; if (curve_parameters[PARAM_LINEAR_ACCEL].is_valid()) { tex_linear_accel = curve_parameters[PARAM_LINEAR_ACCEL]->interpolate(tv); } - real_t tex_tangential_accel = 0.0; + real_t tex_tangential_accel = 1.0; if (curve_parameters[PARAM_TANGENTIAL_ACCEL].is_valid()) { tex_tangential_accel = curve_parameters[PARAM_TANGENTIAL_ACCEL]->interpolate(tv); } - real_t tex_radial_accel = 0.0; + real_t tex_radial_accel = 1.0; if (curve_parameters[PARAM_RADIAL_ACCEL].is_valid()) { tex_radial_accel = curve_parameters[PARAM_RADIAL_ACCEL]->interpolate(tv); } - real_t tex_damping = 0.0; + real_t tex_damping = 1.0; if (curve_parameters[PARAM_DAMPING].is_valid()) { tex_damping = curve_parameters[PARAM_DAMPING]->interpolate(tv); } - real_t tex_angle = 0.0; + real_t tex_angle = 1.0; if (curve_parameters[PARAM_ANGLE].is_valid()) { tex_angle = curve_parameters[PARAM_ANGLE]->interpolate(tv); } - real_t tex_anim_speed = 0.0; + real_t tex_anim_speed = 1.0; if (curve_parameters[PARAM_ANIM_SPEED].is_valid()) { tex_anim_speed = curve_parameters[PARAM_ANIM_SPEED]->interpolate(tv); } - real_t tex_anim_offset = 0.0; + real_t tex_anim_offset = 1.0; if (curve_parameters[PARAM_ANIM_OFFSET].is_valid()) { tex_anim_offset = curve_parameters[PARAM_ANIM_OFFSET]->interpolate(tv); } @@ -984,7 +984,7 @@ void CPUParticles3D::_particles_process(double p_delta) { real_t base_angle = (tex_angle)*Math::lerp(parameters_min[PARAM_ANGLE], parameters_max[PARAM_ANGLE], p.angle_rand); base_angle += p.custom[1] * lifetime * tex_angular_velocity * Math::lerp(parameters_min[PARAM_ANGULAR_VELOCITY], parameters_max[PARAM_ANGULAR_VELOCITY], rand_from_seed(alt_seed)); p.custom[0] = Math::deg2rad(base_angle); //angle - p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand) + p.custom[1] * tex_anim_speed * Math::lerp(parameters_min[PARAM_ANIM_SPEED], parameters_max[PARAM_ANIM_SPEED], rand_from_seed(alt_seed)); //angle + p.custom[2] = tex_anim_offset * Math::lerp(parameters_min[PARAM_ANIM_OFFSET], parameters_max[PARAM_ANIM_OFFSET], p.anim_offset_rand) + tv * tex_anim_speed * Math::lerp(parameters_min[PARAM_ANIM_SPEED], parameters_max[PARAM_ANIM_SPEED], rand_from_seed(alt_seed)); //angle } //apply color //apply hue rotation diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index b7b88c7135..ddd9d2da8a 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -478,7 +478,7 @@ void Node3D::remove_gizmo(Ref<Node3DGizmo> p_gizmo) { int idx = data.gizmos.find(p_gizmo); if (idx != -1) { p_gizmo->free(); - data.gizmos.remove(idx); + data.gizmos.remove_at(idx); } #endif } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index edaf76bc3e..393e29e398 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -1328,8 +1328,15 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo // Apply slide on forward in order to allow only lateral motion on next step. Vector3 forward = wall_normal.slide(up_direction).normalized(); motion = motion.slide(forward); - // Avoid accelerating when you jump on the wall and smooth falling. - motion_velocity = motion_velocity.slide(forward); + + // Scales the horizontal velocity according to the wall slope. + if (vel_dir_facing_up) { + Vector3 slide_motion = motion_velocity.slide(result.collisions[0].normal); + // Keeps the vertical motion from motion_velocity and add the horizontal motion of the projection. + motion_velocity = up_direction * up_direction.dot(motion_velocity) + slide_motion.slide(up_direction); + } else { + motion_velocity = motion_velocity.slide(forward); + } // Allow only lateral motion along previous floor when already on floor. // Fixes slowing down when moving in diagonal against an inclined wall. diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index d4d3c0ebe1..04b5b88ef8 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -633,7 +633,7 @@ void Skeleton3D::remove_bone_child(int p_bone, int p_child) { int child_idx = bones[p_bone].child_bones.find(p_child); if (child_idx >= 0) { - bones.write[p_bone].child_bones.remove(child_idx); + bones.write[p_bone].child_bones.remove_at(child_idx); } else { WARN_PRINT("Cannot remove child bone: Child bone not found."); } diff --git a/scene/3d/soft_dynamic_body_3d.cpp b/scene/3d/soft_dynamic_body_3d.cpp index 903eedb58b..d9907430fc 100644 --- a/scene/3d/soft_dynamic_body_3d.cpp +++ b/scene/3d/soft_dynamic_body_3d.cpp @@ -100,12 +100,11 @@ SoftDynamicBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) { offset = obj_tocopy.offset; } -SoftDynamicBody3D::PinnedPoint &SoftDynamicBody3D::PinnedPoint::operator=(const PinnedPoint &obj) { +void SoftDynamicBody3D::PinnedPoint::operator=(const PinnedPoint &obj) { point_index = obj.point_index; spatial_attachment_path = obj.spatial_attachment_path; spatial_attachment = obj.spatial_attachment; offset = obj.offset; - return *this; } void SoftDynamicBody3D::_update_pickable() { @@ -773,7 +772,7 @@ void SoftDynamicBody3D::_reset_points_offsets() { void SoftDynamicBody3D::_remove_pinned_point(int p_point_index) { const int id(_has_pinned_point(p_point_index)); if (-1 != id) { - pinned_points.remove(id); + pinned_points.remove_at(id); } } diff --git a/scene/3d/soft_dynamic_body_3d.h b/scene/3d/soft_dynamic_body_3d.h index 57e116aa05..daef9acac0 100644 --- a/scene/3d/soft_dynamic_body_3d.h +++ b/scene/3d/soft_dynamic_body_3d.h @@ -80,7 +80,7 @@ public: PinnedPoint(); PinnedPoint(const PinnedPoint &obj_tocopy); - PinnedPoint &operator=(const PinnedPoint &obj); + void operator=(const PinnedPoint &obj); }; private: diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 90af70e7c2..197a5c0f27 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -625,6 +625,7 @@ void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) { texture->connect(CoreStringNames::get_singleton()->changed, Callable(this, "_queue_update")); } _queue_update(); + emit_signal(SceneStringNames::get_singleton()->texture_changed); } Ref<Texture2D> Sprite3D::get_texture() const { @@ -780,6 +781,7 @@ void Sprite3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); ADD_SIGNAL(MethodInfo("frame_changed")); + ADD_SIGNAL(MethodInfo("texture_changed")); } Sprite3D::Sprite3D() { diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp index 26fa43b969..4eeb987dde 100644 --- a/scene/3d/world_environment.cpp +++ b/scene/3d/world_environment.cpp @@ -133,8 +133,8 @@ Ref<CameraEffects> WorldEnvironment::get_camera_effects() const { TypedArray<String> WorldEnvironment::get_configuration_warnings() const { TypedArray<String> warnings = Node::get_configuration_warnings(); - if (!environment.is_valid()) { - warnings.push_back(TTR("WorldEnvironment requires its \"Environment\" property to contain an Environment to have a visible effect.")); + if (!environment.is_valid() && !camera_effects.is_valid()) { + warnings.push_back(TTR("To have any visible effect, WorldEnvironment requires its \"Environment\" property to contain an Environment, its \"Camera Effects\" property to contain a CameraEffects resource, or both.")); } if (!is_inside_tree()) { diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index e621f06ce9..8b5203961f 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -134,7 +134,7 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) { } } if (erase) { - triangles.remove(i); + triangles.remove_at(i); i--; } @@ -224,7 +224,7 @@ int AnimationNodeBlendSpace2D::get_triangle_point(int p_triangle, int p_point) { void AnimationNodeBlendSpace2D::remove_triangle(int p_triangle) { ERR_FAIL_INDEX(p_triangle, triangles.size()); - triangles.remove(p_triangle); + triangles.remove_at(p_triangle); } int AnimationNodeBlendSpace2D::get_triangle_count() const { diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index b5d7a0555e..c8fa8bf395 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -464,7 +464,7 @@ double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_s } if (path.size()) { //if it came from path, remove path - path.remove(0); + path.remove_at(0); } current = next; if (switch_mode == AnimationNodeStateMachineTransition::SWITCH_MODE_SYNC) { @@ -624,7 +624,7 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) { for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_name || transitions[i].to == p_name) { transitions.write[i].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); - transitions.remove(i); + transitions.remove_at(i); i--; } } @@ -751,7 +751,7 @@ void AnimationNodeStateMachine::remove_transition(const StringName &p_from, cons for (int i = 0; i < transitions.size(); i++) { if (transitions[i].from == p_from && transitions[i].to == p_to) { transitions.write[i].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); - transitions.remove(i); + transitions.remove_at(i); return; } } @@ -764,7 +764,7 @@ void AnimationNodeStateMachine::remove_transition(const StringName &p_from, cons void AnimationNodeStateMachine::remove_transition_by_index(int p_transition) { ERR_FAIL_INDEX(p_transition, transitions.size()); transitions.write[p_transition].transition->disconnect("advance_condition_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed)); - transitions.remove(p_transition); + transitions.remove_at(p_transition); /*if (playing) { path.clear(); }*/ diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 93339711bd..b9435b6692 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1754,7 +1754,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::backup_animated_values(Node *p_root_o Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) { ERR_FAIL_COND_V(!can_apply_reset(), Ref<AnimatedValuesBackup>()); - Ref<Animation> reset_anim = animation_set["RESET"].animation; + Ref<Animation> reset_anim = animation_set[SceneStringNames::get_singleton()->RESET].animation; ERR_FAIL_COND_V(reset_anim.is_null(), Ref<AnimatedValuesBackup>()); Node *root_node = get_node_or_null(root); @@ -1762,8 +1762,8 @@ Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) { AnimationPlayer *aux_player = memnew(AnimationPlayer); EditorNode::get_singleton()->add_child(aux_player); - aux_player->add_animation("RESET", reset_anim); - aux_player->set_assigned_animation("RESET"); + aux_player->add_animation(SceneStringNames::get_singleton()->RESET, reset_anim); + aux_player->set_assigned_animation(SceneStringNames::get_singleton()->RESET); // Forcing the use of the original root because the scene where original player belongs may be not the active one Node *root = get_node(get_root()); Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values(root); @@ -1785,7 +1785,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) { } bool AnimationPlayer::can_apply_reset() const { - return has_animation("RESET") && playback.assigned != StringName("RESET"); + return has_animation(SceneStringNames::get_singleton()->RESET) && playback.assigned != SceneStringNames::get_singleton()->RESET; } #endif diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index ea04918988..1b07c086c0 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -198,7 +198,7 @@ private: struct PlaybackData { AnimationData *from = nullptr; - float pos = 0.0; + double pos = 0.0; float speed_scale = 1.0; }; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 37e754148c..57c615a6ab 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -329,7 +329,7 @@ void AnimationNode::set_input_name(int p_input, const String &p_name) { void AnimationNode::remove_input(int p_index) { ERR_FAIL_INDEX(p_index, inputs.size()); - inputs.remove(p_index); + inputs.remove_at(p_index); emit_changed(); } diff --git a/scene/audio/audio_stream_player.cpp b/scene/audio/audio_stream_player.cpp index 43c4ce4c82..3da4f23a08 100644 --- a/scene/audio/audio_stream_player.cpp +++ b/scene/audio/audio_stream_player.cpp @@ -143,7 +143,7 @@ void AudioStreamPlayer::play(float p_from_pos) { set_process_internal(true); while (stream_playbacks.size() > max_polyphony) { AudioServer::get_singleton()->stop_playback_stream(stream_playbacks[0]); - stream_playbacks.remove(0); + stream_playbacks.remove_at(0); } } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 3c8949ddfb..56c04b32e3 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -367,7 +367,7 @@ void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) { PropertyHint hint = pi.hint; String hint_string = pi.hint_string; - if (!res.is_null()) { + if (!res.is_null() && !res->get_path().is_empty()) { var = res->get_path(); } else { //only send information that can be sent.. int len = 0; //test how big is this to encode diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 7fba94da4c..a8c5966569 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -1419,40 +1419,23 @@ void CodeEdit::fold_line(int p_line) { /* End line is the same therefore we have a block of single line delimiters. */ if (end_line == p_line) { for (int i = p_line + 1; i <= line_count; i++) { - if (i == line_count) { - end_line = line_count; - break; - } - if ((in_string != -1 && is_in_string(i) == -1) || (in_comment != -1 && is_in_comment(i) == -1)) { - end_line = i - 1; break; } + end_line = i; } } } else { int start_indent = get_indent_level(p_line); for (int i = p_line + 1; i <= line_count; i++) { - if (get_line(p_line).strip_edges().size() == 0 || is_in_string(i) != -1 || is_in_comment(i) != -1) { - end_line = i; + if (get_line(i).strip_edges().size() == 0) { continue; } - - if (i == line_count) { - /* Do not fold empty last line of script if any */ + if (get_indent_level(i) > start_indent) { end_line = i; - if (get_line(i).strip_edges().size() == 0) { - end_line--; - } - break; + continue; } - - if ((get_indent_level(i) <= start_indent && get_line(i).strip_edges().size() != 0)) { - /* Keep an empty line unfolded if any */ - end_line = i - 1; - if (get_line(i - 1).strip_edges().size() == 0 && i - 2 > p_line) { - end_line = i - 2; - } + if (is_in_string(i) == -1 && is_in_comment(i) == -1) { break; } } @@ -2395,7 +2378,7 @@ void CodeEdit::_update_delimiter_cache(int p_from_line, int p_to_line) { if (start_line != end_line) { if (p_to_line < p_from_line) { for (int i = end_line; i > start_line; i--) { - delimiter_cache.remove(i); + delimiter_cache.remove_at(i); } } else { for (int i = start_line; i < end_line; i++) { @@ -2632,7 +2615,7 @@ void CodeEdit::_remove_delimiter(const String &p_start_key, DelimiterType p_type break; } - delimiters.remove(i); + delimiters.remove_at(i); if (!setting_delimiters) { delimiter_cache.clear(); _update_delimiter_cache(); @@ -2673,7 +2656,7 @@ void CodeEdit::_set_delimiters(const TypedArray<String> &p_delimiters, Delimiter void CodeEdit::_clear_delimiters(DelimiterType p_type) { for (int i = delimiters.size() - 1; i >= 0; i--) { if (delimiters[i].type == p_type) { - delimiters.remove(i); + delimiters.remove_at(i); } } delimiter_cache.clear(); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 44853fc006..e3754c4d38 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -473,6 +473,13 @@ void FileDialog::update_file_list() { dir_access->list_dir_begin(); + if (dir_access->is_readable(dir_access->get_current_dir().utf8().get_data())) { + message->hide(); + } else { + message->set_text(TTRC("You don't have permission to access contents of this folder.")); + message->show(); + } + TreeItem *root = tree->create_item(); Ref<Texture2D> folder = vbox->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); Ref<Texture2D> file_icon = vbox->get_theme_icon(SNAME("file"), SNAME("FileDialog")); @@ -482,17 +489,11 @@ void FileDialog::update_file_list() { List<String> dirs; bool is_hidden; - String item; - - if (dir_access->is_readable(dir_access->get_current_dir().utf8().get_data())) { - message->hide(); - } else { - message->set_text(TTRC("You don't have permission to access contents of this folder.")); - message->show(); - } + String item = dir_access->get_next(); - while ((item = dir_access->get_next()) != "") { + while (!item.is_empty()) { if (item == "." || item == "..") { + item = dir_access->get_next(); continue; } @@ -505,6 +506,7 @@ void FileDialog::update_file_list() { dirs.push_back(item); } } + item = dir_access->get_next(); } dirs.sort_custom<NaturalNoCaseComparator>(); diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index ae15b021a5..1210be15ce 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -89,7 +89,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->get_keycode() == Key::KEY_DELETE && grabbed != -1) { - points.remove(grabbed); + points.remove_at(grabbed); grabbed = -1; grabbing = false; update(); @@ -109,7 +109,7 @@ void GradientEdit::gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->get_button_index() == MouseButton::RIGHT && mb->is_pressed()) { grabbed = _get_point_from_pos(mb->get_position().x); if (grabbed != -1) { - points.remove(grabbed); + points.remove_at(grabbed); grabbed = -1; grabbing = false; update(); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index c0f2cdbef1..408ef53e89 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -381,7 +381,7 @@ void ItemList::move_item(int p_from_idx, int p_to_idx) { } Item item = items[p_from_idx]; - items.remove(p_from_idx); + items.remove_at(p_from_idx); items.insert(p_to_idx, item); update(); @@ -404,7 +404,7 @@ int ItemList::get_item_count() const { void ItemList::remove_item(int p_idx) { ERR_FAIL_INDEX(p_idx, items.size()); - items.remove(p_idx); + items.remove_at(p_idx); if (current == p_idx) { current = -1; } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 69b08fda3c..30a6f0fc9a 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -322,7 +322,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { deselect(); selection.start_column = caret_column; selection.creating = true; - } else if (selection.enabled) { + } else if (selection.enabled && !selection.double_click) { selection.drag_attempt = true; } } @@ -588,13 +588,19 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { if (p_data.get_type() == Variant::STRING && is_editable()) { set_caret_at_pixel_pos(p_point.x); int caret_column_tmp = caret_column; + bool is_inside_sel = selection.enabled && caret_column >= selection.begin && caret_column <= selection.end; + if (Input::get_singleton()->is_key_pressed(Key::CTRL)) { + is_inside_sel = selection.enabled && caret_column > selection.begin && caret_column < selection.end; + } if (selection.drag_attempt) { selection.drag_attempt = false; - if (caret_column < selection.begin || caret_column > selection.end) { - if (caret_column_tmp > selection.end) { - caret_column_tmp = caret_column_tmp - (selection.end - selection.begin); + if (!is_inside_sel) { + if (!Input::get_singleton()->is_key_pressed(Key::CTRL)) { + if (caret_column_tmp > selection.end) { + caret_column_tmp = caret_column_tmp - (selection.end - selection.begin); + } + selection_delete(); } - selection_delete(); set_caret_column(caret_column_tmp); insert_text_at_caret(p_data); @@ -975,7 +981,7 @@ void LineEdit::_notification(int p_what) { if (is_drag_successful()) { if (selection.drag_attempt) { selection.drag_attempt = false; - if (is_editable()) { + if (is_editable() && !Input::get_singleton()->is_key_pressed(Key::CTRL)) { selection_delete(); } else if (deselect_on_focus_loss_enabled) { deselect(); diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 7e9b545776..2e854abb76 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -1403,7 +1403,7 @@ void PopupMenu::remove_item(int p_idx) { _unref_shortcut(items[p_idx].shortcut); } - items.remove(p_idx); + items.remove_at(p_idx); control->update(); child_controls_changed(); } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index f191dfecb4..fd19fad667 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2334,7 +2334,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub p_item->parent->subitems.erase(p_item); // If a newline was erased, all lines AFTER the newline need to be decremented. if (p_item->type == ITEM_NEWLINE) { - current_frame->lines.remove(p_line); + current_frame->lines.remove_at(p_line); for (int i = 0; i < current->subitems.size(); i++) { if (current->subitems[i]->line > p_subitem_line) { current->subitems[i]->line--; @@ -2423,7 +2423,7 @@ bool RichTextLabel::remove_line(const int p_line) { } if (!had_newline) { - current_frame->lines.remove(p_line); + current_frame->lines.remove_at(p_line); if (current_frame->lines.size() == 0) { current_frame->lines.resize(1); } @@ -3527,7 +3527,7 @@ void RichTextLabel::append_text(const String &p_bbcode) { pos = brk_pos + 1; } else { String identifier = expr[0]; - expr.remove(0); + expr.remove_at(0); Dictionary properties = parse_expressions_for_values(expr); Ref<RichTextEffect> effect = _get_custom_effect_by_code(identifier); diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index 9f4ec558dc..9c87d07f66 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -68,7 +68,6 @@ class ScrollContainer : public Container { protected: Size2 get_minimum_size() const override; - virtual void gui_input(const Ref<InputEvent> &p_gui_input) override; void _gui_focus_changed(Control *p_control); void _update_dimensions(); void _notification(int p_what); @@ -80,6 +79,8 @@ protected: void _update_scrollbar_position(); public: + virtual void gui_input(const Ref<InputEvent> &p_gui_input) override; + void set_h_scroll(int p_pos); int get_h_scroll() const; diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 1dda29f668..c7d5a600a1 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -164,7 +164,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (rb_pressing && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { if (rb_hover != -1) { - // pressed + // Right mouse button clicked. emit_signal(SNAME("tab_rmb_clicked"), rb_hover); } @@ -174,7 +174,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { if (cb_pressing && !mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) { if (cb_hover != -1) { - // pressed + // Close button pressed. emit_signal(SNAME("tab_close_pressed"), cb_hover); } @@ -183,7 +183,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { } if (mb->is_pressed() && (mb->get_button_index() == MouseButton::LEFT || (select_with_rmb && mb->get_button_index() == MouseButton::RIGHT))) { - // clicks + // Clicks. Point2 pos = mb->get_position(); if (buttons_visible) { @@ -235,7 +235,7 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) { return; } - if (tabs[i].cb_rect.has_point(pos)) { + if (tabs[i].cb_rect.has_point(pos) && (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current))) { cb_pressing = true; update(); return; @@ -659,7 +659,7 @@ void TabBar::_update_hover() { } const Point2 &pos = get_local_mouse_position(); - // test hovering to display right or close button + // test hovering to display right or close button. int hover_now = -1; int hover_buttons = -1; for (int i = offset; i < tabs.size(); i++) { @@ -684,7 +684,7 @@ void TabBar::_update_hover() { emit_signal(SNAME("tab_hovered"), hover); } - if (hover_buttons == -1) { // no hover + if (hover_buttons == -1) { // No hover. rb_hover = hover_buttons; cb_hover = hover_buttons; } @@ -790,7 +790,7 @@ void TabBar::clear_tabs() { void TabBar::remove_tab(int p_idx) { ERR_FAIL_INDEX(p_idx, tabs.size()); - tabs.remove(p_idx); + tabs.remove_at(p_idx); if (current >= p_idx) { current--; } @@ -860,7 +860,7 @@ bool TabBar::can_drop_data(const Point2 &p_point, const Variant &p_data) const { if (from_path == to_path) { return true; } else if (get_tabs_rearrange_group() != -1) { - // drag and drop between other TabBars + // Drag and drop between other TabBars. Node *from_node = get_node(from_path); TabBar *from_tabs = Object::cast_to<TabBar>(from_node); if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) { @@ -895,7 +895,7 @@ void TabBar::drop_data(const Point2 &p_point, const Variant &p_data) { emit_signal(SNAME("active_tab_rearranged"), hover_now); set_current_tab(hover_now); } else if (get_tabs_rearrange_group() != -1) { - // drag and drop between Tabs + // Drag and drop between Tabs. Node *from_node = get_node(from_path); TabBar *from_tabs = Object::cast_to<TabBar>(from_node); if (from_tabs && from_tabs->get_tabs_rearrange_group() == get_tabs_rearrange_group()) { @@ -961,7 +961,7 @@ void TabBar::move_tab(int from, int to) { ERR_FAIL_INDEX(to, tabs.size()); Tab tab_from = tabs[from]; - tabs.remove(from); + tabs.remove_at(from); tabs.insert(to, tab_from); _update_cache(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index c8f6ecdafd..bc30bf4447 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -39,6 +39,7 @@ #include "core/os/os.h" #include "core/string/string_builder.h" #include "core/string/translation.h" +#include "label.h" #include "scene/main/window.h" @@ -300,11 +301,11 @@ void TextEdit::Text::insert(int p_at, const String &p_text, const Array &p_bidi_ invalidate_cache(p_at); } -void TextEdit::Text::remove(int p_at) { - int height = text[p_at].height; - int width = text[p_at].width; +void TextEdit::Text::remove_at(int p_index) { + int height = text[p_index].height; + int width = text[p_index].width; - text.remove(p_at); + text.remove_at(p_index); // If this is the tallest line, we need to get the next tallest. if (height == line_height) { @@ -330,7 +331,7 @@ void TextEdit::Text::add_gutter(int p_at) { void TextEdit::Text::remove_gutter(int p_gutter) { for (int i = 0; i < text.size(); i++) { - text.write[i].gutters.remove(p_gutter); + text.write[i].gutters.remove_at(p_gutter); } gutter_count--; } @@ -1055,7 +1056,7 @@ void TextEdit::_notification(int p_what) { while (highlighted_word_col != -1) { Vector<Vector2> sel = TS->shaped_text_get_selection(rid, highlighted_word_col + start, highlighted_word_col + lookup_symbol_word.length() + start); for (int j = 0; j < sel.size(); j++) { - Rect2 rect = Rect2(sel[j].x + char_margin + ofs_x, ofs_y, sel[j].y - sel[j].x, row_height); + Rect2 rect = Rect2(sel[j].x + char_margin + ofs_x, ofs_y + (line_spacing / 2), sel[j].y - sel[j].x, row_height); if (rect.position.x + rect.size.x <= xmargin_beg || rect.position.x > xmargin_end) { continue; } @@ -1065,9 +1066,9 @@ void TextEdit::_notification(int p_what) { } else if (rect.position.x + rect.size.x > xmargin_end) { rect.size.x = xmargin_end - rect.position.x; } - rect.position.y = TS->shaped_text_get_ascent(rid) + font->get_underline_position(font_size); - rect.size.y = font->get_underline_thickness(font_size); - draw_rect(rect, font_selected_color); + rect.position.y += ceil(TS->shaped_text_get_ascent(rid)) + ceil(font->get_underline_position(font_size)); + rect.size.y = MAX(1, font->get_underline_thickness(font_size)); + draw_rect(rect, color); } highlighted_word_col = _get_column_pos_of_word(lookup_symbol_word, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, highlighted_word_col + 1); @@ -1224,7 +1225,7 @@ void TextEdit::_notification(int p_what) { if (caret.draw_pos.x >= xmargin_beg && caret.draw_pos.x < xmargin_end) { caret.visible = true; - if (draw_caret) { + if (draw_caret || drag_caret_force_displayed) { if (caret_type == CaretType::CARET_TYPE_BLOCK || overtype_mode) { //Block or underline caret, draw trailing carets at full height. int h = font->get_height(font_size); @@ -1391,7 +1392,7 @@ void TextEdit::_notification(int p_what) { DisplayServer::get_singleton()->virtual_keyboard_hide(); } - if (deselect_on_focus_loss_enabled) { + if (deselect_on_focus_loss_enabled && !selection.drag_attempt) { deselect(); } } break; @@ -1411,6 +1412,30 @@ void TextEdit::_notification(int p_what) { update(); } } break; + case Control::NOTIFICATION_DRAG_BEGIN: { + selection.selecting_mode = SelectionMode::SELECTION_MODE_NONE; + drag_action = true; + dragging_minimap = false; + dragging_selection = false; + can_drag_minimap = false; + click_select_held->stop(); + } break; + case Control::NOTIFICATION_DRAG_END: { + if (is_drag_successful()) { + if (selection.drag_attempt) { + selection.drag_attempt = false; + if (is_editable() && !Input::get_singleton()->is_key_pressed(Key::CTRL)) { + delete_selection(); + } else if (deselect_on_focus_loss_enabled) { + deselect(); + } + } + } else { + selection.drag_attempt = false; + } + drag_action = false; + drag_caret_force_displayed = false; + } break; } } @@ -1495,6 +1520,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { set_caret_line(row, false, false); set_caret_column(col); + selection.drag_attempt = false; if (mb->is_shift_pressed() && (caret.column != prev_col || caret.line != prev_line)) { if (!selection.active) { @@ -1538,6 +1564,9 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { update(); } + } else if (is_mouse_over_selection()) { + selection.selecting_mode = SelectionMode::SELECTION_MODE_NONE; + selection.drag_attempt = true; } else { selection.active = false; selection.selecting_mode = SelectionMode::SELECTION_MODE_POINTER; @@ -1551,6 +1580,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { if (!mb->is_double_click() && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < triple_click_timeout && mb->get_position().distance_to(last_dblclk_pos) < triple_click_tolerance) { // Triple-click select line. selection.selecting_mode = SelectionMode::SELECTION_MODE_LINE; + selection.drag_attempt = false; _update_selection_mode_line(); last_dblclk = 0; } else if (mb->is_double_click() && text[caret.line].length()) { @@ -1601,10 +1631,16 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { } } else { if (mb->get_button_index() == MouseButton::LEFT) { + if (selection.drag_attempt && is_mouse_over_selection()) { + selection.active = false; + } dragging_minimap = false; dragging_selection = false; can_drag_minimap = false; click_select_held->stop(); + if (!drag_action) { + selection.drag_attempt = false; + } if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CLIPBOARD_PRIMARY)) { DisplayServer::get_singleton()->clipboard_set_primary(get_selected_text()); } @@ -1689,6 +1725,14 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) { hovered_gutter = current_hovered_gutter; update(); } + + if (drag_action && can_drop_data(mpos, get_viewport()->gui_get_drag_data())) { + drag_caret_force_displayed = true; + Point2i pos = get_line_column_at_pos(get_local_mouse_pos()); + set_caret_line(pos.y, false); + set_caret_column(pos.x); + dragging_selection = true; + } } if (draw_minimap && !dragging_selection) { @@ -2406,6 +2450,75 @@ bool TextEdit::is_text_field() const { return true; } +Variant TextEdit::get_drag_data(const Point2 &p_point) { + if (selection.active && selection.drag_attempt) { + String t = get_selected_text(); + Label *l = memnew(Label); + l->set_text(t); + set_drag_preview(l); + return t; + } + + return Variant(); +} + +bool TextEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const { + bool drop_override = Control::can_drop_data(p_point, p_data); // In case user wants to drop custom data. + if (drop_override) { + return drop_override; + } + + return is_editable() && p_data.get_type() == Variant::STRING; +} + +void TextEdit::drop_data(const Point2 &p_point, const Variant &p_data) { + Control::drop_data(p_point, p_data); + + if (p_data.get_type() == Variant::STRING && is_editable()) { + Point2i pos = get_line_column_at_pos(get_local_mouse_pos()); + int caret_row_tmp = pos.y; + int caret_column_tmp = pos.x; + if (selection.drag_attempt) { + selection.drag_attempt = false; + if (!is_mouse_over_selection(!Input::get_singleton()->is_key_pressed(Key::CTRL))) { + begin_complex_operation(); + if (!Input::get_singleton()->is_key_pressed(Key::CTRL)) { + if (caret_row_tmp > selection.to_line) { + caret_row_tmp = caret_row_tmp - (selection.to_line - selection.from_line); + } else if (caret_row_tmp == selection.to_line && caret_column_tmp >= selection.to_column) { + caret_column_tmp = caret_column_tmp - (selection.to_column - selection.from_column); + } + delete_selection(); + } else { + deselect(); + } + + set_caret_line(caret_row_tmp, true, false); + set_caret_column(caret_column_tmp); + insert_text_at_caret(p_data); + end_complex_operation(); + } + } else if (is_mouse_over_selection()) { + caret_row_tmp = selection.from_line; + caret_column_tmp = selection.from_column; + set_caret_line(caret_row_tmp, true, false); + set_caret_column(caret_column_tmp); + insert_text_at_caret(p_data); + grab_focus(); + } else { + deselect(); + set_caret_line(caret_row_tmp, true, false); + set_caret_column(caret_column_tmp); + insert_text_at_caret(p_data); + grab_focus(); + } + + if (caret_row_tmp != caret.line || caret_column_tmp != caret.column) { + select(caret_row_tmp, caret_column_tmp, caret.line, caret.column); + } + } +} + Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { Point2i pos = get_line_column_at_pos(p_pos); int row = pos.y; @@ -3580,6 +3693,21 @@ bool TextEdit::is_dragging_cursor() const { return dragging_selection || dragging_minimap; } +bool TextEdit::is_mouse_over_selection(bool p_edges) const { + if (!has_selection()) { + return false; + } + Point2i pos = get_line_column_at_pos(get_local_mouse_pos()); + int row = pos.y; + int col = pos.x; + if (p_edges) { + if ((row == selection.from_line && col == selection.from_column) || (row == selection.to_line && col == selection.to_column)) { + return true; + } + } + return (row >= selection.from_line && row <= selection.to_line && (row > selection.from_line || col > selection.from_column) && (row < selection.to_line || col < selection.to_column)); +} + /* Caret */ void TextEdit::set_caret_type(CaretType p_type) { caret_type = p_type; @@ -4347,7 +4475,7 @@ void TextEdit::add_gutter(int p_at) { void TextEdit::remove_gutter(int p_gutter) { ERR_FAIL_INDEX(p_gutter, gutters.size()); - gutters.remove(p_gutter); + gutters.remove_at(p_gutter); for (int i = 0; i < text.size() + 1; i++) { text.remove_gutter(p_gutter); @@ -4776,6 +4904,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_minimap_line_at_pos", "position"), &TextEdit::get_minimap_line_at_pos); ClassDB::bind_method(D_METHOD("is_dragging_cursor"), &TextEdit::is_dragging_cursor); + ClassDB::bind_method(D_METHOD("is_mouse_over_selection", "edges"), &TextEdit::is_mouse_over_selection); /* Caret. */ BIND_ENUM_CONSTANT(CARET_TYPE_LINE); @@ -6249,7 +6378,7 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li String post_text = text[p_to_line].substr(p_to_column, text[p_to_line].length()); for (int i = p_from_line; i < p_to_line; i++) { - text.remove(p_from_line + 1); + text.remove_at(p_from_line + 1); } text.set(p_from_line, pre_text + post_text, structured_text_parser(st_parser, st_args, pre_text + post_text)); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index b13adb8519..a1b2ed59f5 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -205,7 +205,7 @@ private: } bool is_hidden(int p_line) const { return text[p_line].hidden; } void insert(int p_at, const String &p_text, const Array &p_bidi_override); - void remove(int p_at); + void remove_at(int p_index); int size() const { return text.size(); } void clear(); @@ -375,6 +375,9 @@ private: bool caret_mid_grapheme_enabled = false; + bool drag_action = false; + bool drag_caret_force_displayed = false; + void _emit_caret_changed(); void _reset_caret_blink_timer(); @@ -400,6 +403,7 @@ private: int to_column = 0; bool shiftclick_left = false; + bool drag_attempt = false; } selection; bool selecting_enabled = true; @@ -611,6 +615,9 @@ public: virtual Size2 get_minimum_size() const override; virtual bool is_text_field() const override; virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override; + virtual Variant get_drag_data(const Point2 &p_point) override; + virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override; + virtual void drop_data(const Point2 &p_point, const Variant &p_data) override; virtual String get_tooltip(const Point2 &p_pos) const override; void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata); @@ -731,6 +738,7 @@ public: int get_minimap_line_at_pos(const Point2i &p_pos) const; bool is_dragging_cursor() const; + bool is_mouse_over_selection(bool p_edges = true) const; /* Caret */ void set_caret_type(CaretType p_type); diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp index fe11de128a..3c10c6bd66 100644 --- a/scene/gui/texture_progress_bar.cpp +++ b/scene/gui/texture_progress_bar.cpp @@ -387,7 +387,6 @@ void TextureProgressBar::draw_nine_patch_stretched(const Ref<Texture2D> &p_textu } void TextureProgressBar::_notification(int p_what) { - const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 }; switch (p_what) { case NOTIFICATION_DRAW: { if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP || mode == FILL_BILINEAR_LEFT_AND_RIGHT || mode == FILL_BILINEAR_TOP_AND_BOTTOM)) { @@ -452,7 +451,7 @@ void TextureProgressBar::_notification(int p_what) { float val = get_as_ratio() * rad_max_degrees / 360; if (val == 1) { Rect2 region = Rect2(progress_offset, s); - Rect2 source = Rect2(Point2(), s); + Rect2 source = Rect2(Point2(), progress->get_size()); draw_texture_rect_region(progress, region, source, tint_progress); } else if (val != 0) { Array pts; @@ -466,16 +465,14 @@ void TextureProgressBar::_notification(int p_what) { } float end = start + direction * val; - pts.append(start); - pts.append(end); float from = MIN(start, end); float to = MAX(start, end); - for (int i = 0; i < 12; i++) { - if (corners[i] > from && corners[i] < to) { - pts.append(corners[i]); - } + pts.append(from); + for (float corner = Math::floor(from * 4 + 0.5) * 0.25 + 0.125; corner < to; corner += 0.25) { + pts.append(corner); } - pts.sort(); + pts.append(to); + Vector<Point2> uvs; Vector<Point2> points; uvs.push_back(get_relative_center()); @@ -492,6 +489,8 @@ void TextureProgressBar::_notification(int p_what) { colors.push_back(tint_progress); draw_polygon(points, colors, uvs, progress); } + + // Draw a reference cross. if (Engine::get_singleton()->is_editor_hint()) { Point2 p; @@ -502,6 +501,7 @@ void TextureProgressBar::_notification(int p_what) { } p *= get_relative_center(); + p += progress_offset; p = p.floor(); draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2); draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 27e617bdd0..7c0612036d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -848,7 +848,7 @@ String TreeItem::get_button_tooltip(int p_column, int p_idx) const { void TreeItem::erase_button(int p_column, int p_idx) { ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); - cells.write[p_column].buttons.remove(p_idx); + cells.write[p_column].buttons.remove_at(p_idx); _changed_notify(p_column); } @@ -4830,6 +4830,7 @@ void Tree::_bind_methods() { ClassDB::bind_method(D_METHOD("get_allow_reselect"), &Tree::get_allow_reselect); ADD_PROPERTY(PropertyInfo(Variant::INT, "columns"), "set_columns", "get_columns"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "column_titles_visible"), "set_column_titles_visible", "are_column_titles_visible"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_reselect"), "set_allow_reselect", "get_allow_reselect"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_rmb_select"), "set_allow_rmb_select", "get_allow_rmb_select"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_folding"), "set_hide_folding", "is_folding_hidden"); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 2e4e1bd364..d4caec614a 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -171,7 +171,7 @@ private: } if (parent) { if (!parent->children_cache.is_empty()) { - parent->children_cache.remove(get_index()); + parent->children_cache.remove_at(get_index()); } if (parent->first_child == this) { parent->first_child = next; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 44420fcc31..0d646ff2a9 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -114,7 +114,7 @@ void Node::_notification(int p_notification) { get_multiplayer()->scene_enter_exit_notify(data.scene_file_path, this, false); } } break; - case NOTIFICATION_PATH_CHANGED: { + case NOTIFICATION_PATH_RENAMED: { if (data.path_cache) { memdelete(data.path_cache); data.path_cache = nullptr; @@ -332,7 +332,7 @@ void Node::_move_child(Node *p_child, int p_pos, bool p_ignore_end) { int motion_from = MIN(p_pos, p_child->data.pos); int motion_to = MAX(p_pos, p_child->data.pos); - data.children.remove(p_child->data.pos); + data.children.remove_at(p_child->data.pos); data.children.insert(p_pos, p_child); if (data.tree) { @@ -899,7 +899,7 @@ void Node::set_name(const String &p_name) { data.parent->_validate_child_name(this); } - propagate_notification(NOTIFICATION_PATH_CHANGED); + propagate_notification(NOTIFICATION_PATH_RENAMED); if (is_inside_tree()) { emit_signal(SNAME("renamed")); @@ -1208,7 +1208,7 @@ void Node::remove_child(Node *p_child) { remove_child_notify(p_child); p_child->notification(NOTIFICATION_UNPARENTED); - data.children.remove(idx); + data.children.remove_at(idx); //update pointer and size child_count = data.children.size(); @@ -2829,7 +2829,7 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_INSTANCED); BIND_CONSTANT(NOTIFICATION_DRAG_BEGIN); BIND_CONSTANT(NOTIFICATION_DRAG_END); - BIND_CONSTANT(NOTIFICATION_PATH_CHANGED); + BIND_CONSTANT(NOTIFICATION_PATH_RENAMED); BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS); BIND_CONSTANT(NOTIFICATION_INTERNAL_PHYSICS_PROCESS); BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE); diff --git a/scene/main/node.h b/scene/main/node.h index 2dd32a2e1d..dc74a33580 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -256,7 +256,7 @@ public: NOTIFICATION_INSTANCED = 20, NOTIFICATION_DRAG_BEGIN = 21, NOTIFICATION_DRAG_END = 22, - NOTIFICATION_PATH_CHANGED = 23, + NOTIFICATION_PATH_RENAMED = 23, //NOTIFICATION_TRANSLATION_CHANGED = 24, moved below NOTIFICATION_INTERNAL_PROCESS = 25, NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26, diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 48a672b310..007e5d1173 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -55,6 +55,7 @@ #include "scene/resources/world_2d.h" #include "scene/scene_string_names.h" #include "servers/audio_server.h" +#include "servers/rendering/rendering_server_globals.h" void ViewportTexture::setup_local_to_scene() { Node *local_scene = get_local_scene(); @@ -290,7 +291,7 @@ void Viewport::_sub_window_grab_focus(Window *p_window) { if (p_window->get_flag(Window::FLAG_NO_FOCUS)) { // Can only move to foreground, but no focus granted. SubWindow sw = gui.sub_windows[index]; - gui.sub_windows.remove(index); + gui.sub_windows.remove_at(index); gui.sub_windows.push_back(sw); index = gui.sub_windows.size() - 1; _sub_window_update_order(); @@ -318,7 +319,7 @@ void Viewport::_sub_window_grab_focus(Window *p_window) { { // Move to foreground. SubWindow sw = gui.sub_windows[index]; - gui.sub_windows.remove(index); + gui.sub_windows.remove_at(index); gui.sub_windows.push_back(sw); index = gui.sub_windows.size() - 1; _sub_window_update_order(); @@ -335,7 +336,7 @@ 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) { RS::get_singleton()->free(gui.sub_windows[i].canvas_item); - gui.sub_windows.remove(i); + gui.sub_windows.remove_at(i); break; } } @@ -395,14 +396,15 @@ void Viewport::_notification(int p_what) { #ifndef _3D_DISABLED PhysicsServer3D::get_singleton()->space_set_debug_contacts(find_world_3d()->get_space(), get_tree()->get_collision_debug_contact_count()); contact_3d_debug_multimesh = RenderingServer::get_singleton()->multimesh_create(); - RenderingServer::get_singleton()->multimesh_allocate_data(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, true); + RenderingServer::get_singleton()->multimesh_allocate_data(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), RS::MULTIMESH_TRANSFORM_3D, false); 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_3d()->get_scenario()); - //RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true); + RenderingServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, RS::INSTANCE_FLAG_DRAW_NEXT_FRAME_IF_VISIBLE, true); #endif // _3D_DISABLED + set_physics_process_internal(true); } } break; @@ -1706,12 +1708,10 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (mm->get_button_mask() == MouseButton::NONE) { // Nothing pressed. - bool can_tooltip = true; - bool is_tooltip_shown = false; if (gui.tooltip_popup) { - if (can_tooltip && gui.tooltip_control) { + if (gui.tooltip_control) { String tooltip = _gui_get_tooltip(over, gui.tooltip_control->get_global_transform().xform_inv(mpos)); if (tooltip.length() == 0) { @@ -1736,7 +1736,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } - if (can_tooltip && !is_tooltip_shown) { + if (!is_tooltip_shown && over->can_process()) { if (gui.tooltip_timer.is_valid()) { gui.tooltip_timer->release_connections(); gui.tooltip_timer = Ref<SceneTreeTimer>(); @@ -1869,14 +1869,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { Transform2D localizer = gui.drag_mouse_over->get_global_transform_with_canvas().affine_inverse(); gui.drag_mouse_over_pos = localizer.xform(viewport_pos); - if ((mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { - bool can_drop = _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, true); + bool can_drop = _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, true); - if (!can_drop) { - ds_cursor_shape = DisplayServer::CURSOR_FORBIDDEN; - } else { - ds_cursor_shape = DisplayServer::CURSOR_CAN_DROP; - } + if (!can_drop) { + ds_cursor_shape = DisplayServer::CURSOR_FORBIDDEN; + } else { + ds_cursor_shape = DisplayServer::CURSOR_CAN_DROP; } } @@ -2044,6 +2042,7 @@ void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control * if (p_control) { _gui_set_drag_preview(p_base, p_control); } + _propagate_viewport_notification(this, NOTIFICATION_DRAG_BEGIN); } void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) { @@ -3473,17 +3472,60 @@ bool Viewport::is_using_xr() { return use_xr; } -void Viewport::set_scale_3d(float p_scale_3d) { +void Viewport::set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode) { + if (scaling_3d_mode == p_scaling_3d_mode) { + return; + } + + scaling_3d_mode = p_scaling_3d_mode; + RS::get_singleton()->viewport_set_scaling_3d_mode(viewport, (RS::ViewportScaling3DMode)(int)p_scaling_3d_mode); +} + +Viewport::Scaling3DMode Viewport::get_scaling_3d_mode() const { + return scaling_3d_mode; +} + +void Viewport::set_scaling_3d_scale(float p_scaling_3d_scale) { // Clamp to reasonable values that are actually useful. // Values above 2.0 don't serve a practical purpose since the viewport // isn't displayed with mipmaps. - scale_3d = CLAMP(p_scale_3d, 0.1, 2.0); + scaling_3d_scale = CLAMP(p_scaling_3d_scale, 0.1, 2.0); + + RS::get_singleton()->viewport_set_scaling_3d_scale(viewport, scaling_3d_scale); +} + +float Viewport::get_scaling_3d_scale() const { + return scaling_3d_scale; +} + +void Viewport::set_fsr_sharpness(float p_fsr_sharpness) { + if (fsr_sharpness == p_fsr_sharpness) { + return; + } - RS::get_singleton()->viewport_set_scale_3d(viewport, scale_3d); + if (p_fsr_sharpness < 0.0f) { + p_fsr_sharpness = 0.0f; + } + + fsr_sharpness = p_fsr_sharpness; + RS::get_singleton()->viewport_set_fsr_sharpness(viewport, p_fsr_sharpness); +} + +float Viewport::get_fsr_sharpness() const { + return fsr_sharpness; +} + +void Viewport::set_fsr_mipmap_bias(float p_fsr_mipmap_bias) { + if (fsr_mipmap_bias == p_fsr_mipmap_bias) { + return; + } + + fsr_mipmap_bias = p_fsr_mipmap_bias; + RS::get_singleton()->viewport_set_fsr_mipmap_bias(viewport, p_fsr_mipmap_bias); } -float Viewport::get_scale_3d() const { - return scale_3d; +float Viewport::get_fsr_mipmap_bias() const { + return fsr_mipmap_bias; } #endif // _3D_DISABLED @@ -3611,12 +3653,20 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_xr", "use"), &Viewport::set_use_xr); ClassDB::bind_method(D_METHOD("is_using_xr"), &Viewport::is_using_xr); - ClassDB::bind_method(D_METHOD("set_scale_3d", "scale"), &Viewport::set_scale_3d); - ClassDB::bind_method(D_METHOD("get_scale_3d"), &Viewport::get_scale_3d); + ClassDB::bind_method(D_METHOD("set_scaling_3d_mode", "scaling_3d_mode"), &Viewport::set_scaling_3d_mode); + ClassDB::bind_method(D_METHOD("get_scaling_3d_mode"), &Viewport::get_scaling_3d_mode); + + ClassDB::bind_method(D_METHOD("set_scaling_3d_scale", "scale"), &Viewport::set_scaling_3d_scale); + ClassDB::bind_method(D_METHOD("get_scaling_3d_scale"), &Viewport::get_scaling_3d_scale); + + ClassDB::bind_method(D_METHOD("set_fsr_sharpness", "fsr_sharpness"), &Viewport::set_fsr_sharpness); + ClassDB::bind_method(D_METHOD("get_fsr_sharpness"), &Viewport::get_fsr_sharpness); + + ClassDB::bind_method(D_METHOD("set_fsr_mipmap_bias", "fsr_mipmap_bias"), &Viewport::set_fsr_mipmap_bias); + ClassDB::bind_method(D_METHOD("get_fsr_mipmap_bias"), &Viewport::get_fsr_mipmap_bias); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_xr"), "set_use_xr", "is_using_xr"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scale_3d", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), "set_scale_3d", "get_scale_3d"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_3d"), "set_as_audio_listener_3d", "is_audio_listener_3d"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); @@ -3633,6 +3683,13 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_occlusion_culling"), "set_use_occlusion_culling", "is_using_occlusion_culling"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lod_threshold", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_lod_threshold", "get_lod_threshold"); ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw"); +#ifndef _3D_DISABLED + ADD_GROUP("Scaling 3D", ""); + ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Disabled (Slowest),Bilinear (Fastest),FSR (Fast)"), "set_scaling_3d_mode", "get_scaling_3d_mode"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scaling_3d_scale", PROPERTY_HINT_RANGE, "0.25,2.0,0.01"), "set_scaling_3d_scale", "get_scaling_3d_scale"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fsr_mipmap_bias", PROPERTY_HINT_RANGE, "-2,2,0.1"), "set_fsr_mipmap_bias", "get_fsr_mipmap_bias"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fsr_sharpness", PROPERTY_HINT_RANGE, "0,2,0.1"), "set_fsr_sharpness", "get_fsr_sharpness"); +#endif ADD_GROUP("Canvas Items", "canvas_item_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,Linear Mipmap,Nearest Mipmap"), "set_default_canvas_item_texture_filter", "get_default_canvas_item_texture_filter"); ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirror"), "set_default_canvas_item_texture_repeat", "get_default_canvas_item_texture_repeat"); @@ -3669,6 +3726,10 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_1024); BIND_ENUM_CONSTANT(SHADOW_ATLAS_QUADRANT_SUBDIV_MAX); + BIND_ENUM_CONSTANT(SCALING_3D_MODE_BILINEAR); + BIND_ENUM_CONSTANT(SCALING_3D_MODE_FSR); + BIND_ENUM_CONSTANT(SCALING_3D_MODE_MAX); + BIND_ENUM_CONSTANT(MSAA_DISABLED); BIND_ENUM_CONSTANT(MSAA_2X); BIND_ENUM_CONSTANT(MSAA_4X); @@ -3772,7 +3833,16 @@ Viewport::Viewport() { 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 #ifndef _3D_DISABLED - set_scale_3d(GLOBAL_GET("rendering/3d/viewport/scale")); + Viewport::Scaling3DMode scaling_3d_mode = (Viewport::Scaling3DMode)(int)GLOBAL_GET("rendering/scaling_3d/mode"); + set_scaling_3d_mode(scaling_3d_mode); + + set_scaling_3d_scale(GLOBAL_GET("rendering/scaling_3d/scale")); + + float fsr_sharpness = GLOBAL_GET("rendering/scaling_3d/fsr_sharpness"); + set_fsr_sharpness(fsr_sharpness); + + float fsr_mipmap_bias = GLOBAL_GET("rendering/scaling_3d/fsr_mipmap_bias"); + set_fsr_mipmap_bias(fsr_mipmap_bias); #endif // _3D_DISABLED set_sdf_oversize(sdf_oversize); // Set to server. diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 11b76b32eb..38d43e1e59 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -89,6 +89,12 @@ class Viewport : public Node { GDCLASS(Viewport, Node); public: + enum Scaling3DMode { + SCALING_3D_MODE_BILINEAR, + SCALING_3D_MODE_FSR, + SCALING_3D_MODE_MAX + }; + enum ShadowAtlasQuadrantSubdiv { SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED, SHADOW_ATLAS_QUADRANT_SUBDIV_1, @@ -284,6 +290,11 @@ private: MSAA msaa = MSAA_DISABLED; ScreenSpaceAA screen_space_aa = SCREEN_SPACE_AA_DISABLED; + + Scaling3DMode scaling_3d_mode = SCALING_3D_MODE_BILINEAR; + float scaling_3d_scale = 1.0; + float fsr_sharpness = 0.2f; + float fsr_mipmap_bias = 0.0f; bool use_debanding = false; float lod_threshold = 1.0; bool use_occlusion_culling = false; @@ -504,6 +515,18 @@ public: void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa); ScreenSpaceAA get_screen_space_aa() const; + void set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode); + Scaling3DMode get_scaling_3d_mode() const; + + void set_scaling_3d_scale(float p_scaling_3d_scale); + float get_scaling_3d_scale() const; + + void set_fsr_sharpness(float p_fsr_sharpness); + float get_fsr_sharpness() const; + + void set_fsr_mipmap_bias(float p_fsr_mipmap_bias); + float get_fsr_mipmap_bias() const; + void set_use_debanding(bool p_use_debanding); bool is_using_debanding() const; @@ -586,7 +609,6 @@ public: #ifndef _3D_DISABLED bool use_xr = false; - float scale_3d = 1.0; friend class AudioListener3D; AudioListener3D *audio_listener_3d = nullptr; Set<AudioListener3D *> audio_listener_3d_set; @@ -657,9 +679,6 @@ public: void set_use_xr(bool p_use_xr); bool is_using_xr(); - - void set_scale_3d(float p_scale_3d); - float get_scale_3d() const; #endif // _3D_DISABLED Viewport(); @@ -714,6 +733,7 @@ public: SubViewport(); ~SubViewport(); }; +VARIANT_ENUM_CAST(Viewport::Scaling3DMode); VARIANT_ENUM_CAST(SubViewport::UpdateMode); VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv); VARIANT_ENUM_CAST(Viewport::MSAA); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 056ace5e4e..b1178b9263 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -1031,6 +1031,16 @@ void register_scene_types() { GLOBAL_DEF_BASIC(vformat("layer_names/3d_navigation/layer_%d", i + 1), ""); } + if (RenderingServer::get_singleton()) { + ColorPicker::init_shaders(); // RenderingServer needs to exist for this to succeed. + } + + SceneDebugger::initialize(); + + NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE); +} + +void initialize_theme() { bool default_theme_hidpi = GLOBAL_DEF("gui/theme/use_hidpi", false); ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/use_hidpi", PropertyInfo(Variant::BOOL, "gui/theme/use_hidpi", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)); String theme_path = GLOBAL_DEF_RST("gui/theme/custom", ""); @@ -1049,7 +1059,6 @@ void register_scene_types() { // Always make the default theme to avoid invalid default font/icon/style in the given theme. if (RenderingServer::get_singleton()) { make_default_theme(default_theme_hidpi, font); - ColorPicker::init_shaders(); // RenderingServer needs to exist for this to succeed. } if (theme_path != String()) { @@ -1063,9 +1072,6 @@ void register_scene_types() { ERR_PRINT("Error loading custom theme '" + theme_path + "'"); } } - SceneDebugger::initialize(); - - NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE); } void unregister_scene_types() { diff --git a/scene/register_scene_types.h b/scene/register_scene_types.h index 1ff542eef8..32ab165fb3 100644 --- a/scene/register_scene_types.h +++ b/scene/register_scene_types.h @@ -34,4 +34,6 @@ void register_scene_types(); void unregister_scene_types(); +void initialize_theme(); + #endif diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index d31771e71a..e3cf9183a0 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -930,7 +930,7 @@ void Animation::remove_track(int p_track) { } memdelete(t); - tracks.remove(p_track); + tracks.remove_at(p_track); emit_changed(); emit_signal(SceneStringNames::get_singleton()->tracks_changed); } @@ -1320,7 +1320,7 @@ void Animation::track_remove_key(int p_track, int p_idx) { ERR_FAIL_COND(tt->compressed_track >= 0); ERR_FAIL_INDEX(p_idx, tt->positions.size()); - tt->positions.remove(p_idx); + tt->positions.remove_at(p_idx); } break; case TYPE_ROTATION_3D: { @@ -1329,7 +1329,7 @@ void Animation::track_remove_key(int p_track, int p_idx) { ERR_FAIL_COND(rt->compressed_track >= 0); ERR_FAIL_INDEX(p_idx, rt->rotations.size()); - rt->rotations.remove(p_idx); + rt->rotations.remove_at(p_idx); } break; case TYPE_SCALE_3D: { @@ -1338,7 +1338,7 @@ void Animation::track_remove_key(int p_track, int p_idx) { ERR_FAIL_COND(st->compressed_track >= 0); ERR_FAIL_INDEX(p_idx, st->scales.size()); - st->scales.remove(p_idx); + st->scales.remove_at(p_idx); } break; case TYPE_BLEND_SHAPE: { @@ -1347,37 +1347,37 @@ void Animation::track_remove_key(int p_track, int p_idx) { ERR_FAIL_COND(bst->compressed_track >= 0); ERR_FAIL_INDEX(p_idx, bst->blend_shapes.size()); - bst->blend_shapes.remove(p_idx); + bst->blend_shapes.remove_at(p_idx); } break; case TYPE_VALUE: { ValueTrack *vt = static_cast<ValueTrack *>(t); ERR_FAIL_INDEX(p_idx, vt->values.size()); - vt->values.remove(p_idx); + vt->values.remove_at(p_idx); } break; case TYPE_METHOD: { MethodTrack *mt = static_cast<MethodTrack *>(t); ERR_FAIL_INDEX(p_idx, mt->methods.size()); - mt->methods.remove(p_idx); + mt->methods.remove_at(p_idx); } break; case TYPE_BEZIER: { BezierTrack *bz = static_cast<BezierTrack *>(t); ERR_FAIL_INDEX(p_idx, bz->values.size()); - bz->values.remove(p_idx); + bz->values.remove_at(p_idx); } break; case TYPE_AUDIO: { AudioTrack *ad = static_cast<AudioTrack *>(t); ERR_FAIL_INDEX(p_idx, ad->values.size()); - ad->values.remove(p_idx); + ad->values.remove_at(p_idx); } break; case TYPE_ANIMATION: { AnimationTrack *an = static_cast<AnimationTrack *>(t); ERR_FAIL_INDEX(p_idx, an->values.size()); - an->values.remove(p_idx); + an->values.remove_at(p_idx); } break; } @@ -1905,7 +1905,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, tt->positions.size()); TKey<Vector3> key = tt->positions[p_key_idx]; key.time = p_time; - tt->positions.remove(p_key_idx); + tt->positions.remove_at(p_key_idx); _insert(p_time, tt->positions, key); return; } @@ -1915,7 +1915,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, tt->rotations.size()); TKey<Quaternion> key = tt->rotations[p_key_idx]; key.time = p_time; - tt->rotations.remove(p_key_idx); + tt->rotations.remove_at(p_key_idx); _insert(p_time, tt->rotations, key); return; } @@ -1925,7 +1925,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, tt->scales.size()); TKey<Vector3> key = tt->scales[p_key_idx]; key.time = p_time; - tt->scales.remove(p_key_idx); + tt->scales.remove_at(p_key_idx); _insert(p_time, tt->scales, key); return; } @@ -1935,7 +1935,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, tt->blend_shapes.size()); TKey<float> key = tt->blend_shapes[p_key_idx]; key.time = p_time; - tt->blend_shapes.remove(p_key_idx); + tt->blend_shapes.remove_at(p_key_idx); _insert(p_time, tt->blend_shapes, key); return; } @@ -1944,7 +1944,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, vt->values.size()); TKey<Variant> key = vt->values[p_key_idx]; key.time = p_time; - vt->values.remove(p_key_idx); + vt->values.remove_at(p_key_idx); _insert(p_time, vt->values, key); return; } @@ -1953,7 +1953,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, mt->methods.size()); MethodKey key = mt->methods[p_key_idx]; key.time = p_time; - mt->methods.remove(p_key_idx); + mt->methods.remove_at(p_key_idx); _insert(p_time, mt->methods, key); return; } @@ -1962,7 +1962,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, bt->values.size()); TKey<BezierKey> key = bt->values[p_key_idx]; key.time = p_time; - bt->values.remove(p_key_idx); + bt->values.remove_at(p_key_idx); _insert(p_time, bt->values, key); return; } @@ -1971,7 +1971,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, at->values.size()); TKey<AudioKey> key = at->values[p_key_idx]; key.time = p_time; - at->values.remove(p_key_idx); + at->values.remove_at(p_key_idx); _insert(p_time, at->values, key); return; } @@ -1980,7 +1980,7 @@ void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) { ERR_FAIL_INDEX(p_key_idx, at->values.size()); TKey<StringName> key = at->values[p_key_idx]; key.time = p_time; - at->values.remove(p_key_idx); + at->values.remove_at(p_key_idx); _insert(p_time, at->values, key); return; } @@ -3679,7 +3679,7 @@ void Animation::track_move_to(int p_track, int p_to_index) { } Track *track = tracks.get(p_track); - tracks.remove(p_track); + tracks.remove_at(p_track); // Take into account that the position of the tracks that come after the one removed will change. tracks.insert(p_to_index > p_track ? p_to_index - 1 : p_to_index, track); @@ -4058,7 +4058,7 @@ void Animation::_position_track_optimize(int p_idx, real_t p_allowed_linear_err, prev_erased = true; } - tt->positions.remove(i); + tt->positions.remove_at(i); i--; } else { @@ -4093,7 +4093,7 @@ void Animation::_rotation_track_optimize(int p_idx, real_t p_allowed_angular_err prev_erased = true; } - tt->rotations.remove(i); + tt->rotations.remove_at(i); i--; } else { @@ -4127,7 +4127,7 @@ void Animation::_scale_track_optimize(int p_idx, real_t p_allowed_linear_err) { prev_erased = true; } - tt->scales.remove(i); + tt->scales.remove_at(i); i--; } else { @@ -4162,7 +4162,7 @@ void Animation::_blend_shape_track_optimize(int p_idx, real_t p_allowed_linear_e prev_erased = true; } - tt->blend_shapes.remove(i); + tt->blend_shapes.remove_at(i); i--; } else { diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index b530a72033..bf3efd7599 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -33,15 +33,15 @@ #include "core/core_string_names.h" template <class T> -static _FORCE_INLINE_ T _bezier_interp(real_t t, T start, T control_1, T control_2, T end) { +static _FORCE_INLINE_ T _bezier_interp(real_t p_t, T p_start, T p_control_1, T p_control_2, T p_end) { /* Formula from Wikipedia article on Bezier curves. */ - real_t omt = (1.0 - t); + real_t omt = (1.0 - p_t); real_t omt2 = omt * omt; real_t omt3 = omt2 * omt; - real_t t2 = t * t; - real_t t3 = t2 * t; + real_t t2 = p_t * p_t; + real_t t3 = t2 * p_t; - return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3; + return p_start * omt3 + p_control_1 * omt2 * p_t * 3.0 + p_control_2 * omt * t2 * 3.0 + p_end * t3; } const char *Curve::SIGNAL_RANGE_CHANGED = "range_changed"; @@ -49,46 +49,46 @@ const char *Curve::SIGNAL_RANGE_CHANGED = "range_changed"; Curve::Curve() { } -int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, TangentMode left_mode, TangentMode right_mode) { +int Curve::add_point(Vector2 p_position, real_t p_left_tangent, real_t p_right_tangent, TangentMode p_left_mode, TangentMode p_right_mode) { // Add a point and preserve order // Curve bounds is in 0..1 - if (p_pos.x > MAX_X) { - p_pos.x = MAX_X; - } else if (p_pos.x < MIN_X) { - p_pos.x = MIN_X; + if (p_position.x > MAX_X) { + p_position.x = MAX_X; + } else if (p_position.x < MIN_X) { + p_position.x = MIN_X; } int ret = -1; if (_points.size() == 0) { - _points.push_back(Point(p_pos, left_tangent, right_tangent, left_mode, right_mode)); + _points.push_back(Point(p_position, p_left_tangent, p_right_tangent, p_left_mode, p_right_mode)); ret = 0; } else if (_points.size() == 1) { // TODO Is the `else` able to handle this block already? - real_t diff = p_pos.x - _points[0].pos.x; + real_t diff = p_position.x - _points[0].position.x; if (diff > 0) { - _points.push_back(Point(p_pos, left_tangent, right_tangent, left_mode, right_mode)); + _points.push_back(Point(p_position, p_left_tangent, p_right_tangent, p_left_mode, p_right_mode)); ret = 1; } else { - _points.insert(0, Point(p_pos, left_tangent, right_tangent, left_mode, right_mode)); + _points.insert(0, Point(p_position, p_left_tangent, p_right_tangent, p_left_mode, p_right_mode)); ret = 0; } } else { - int i = get_index(p_pos.x); + int i = get_index(p_position.x); - if (i == 0 && p_pos.x < _points[0].pos.x) { + if (i == 0 && p_position.x < _points[0].position.x) { // Insert before anything else - _points.insert(0, Point(p_pos, left_tangent, right_tangent, left_mode, right_mode)); + _points.insert(0, Point(p_position, p_left_tangent, p_right_tangent, p_left_mode, p_right_mode)); ret = 0; } else { // Insert between i and i+1 ++i; - _points.insert(i, Point(p_pos, left_tangent, right_tangent, left_mode, right_mode)); + _points.insert(i, Point(p_position, p_left_tangent, p_right_tangent, p_left_mode, p_right_mode)); ret = i; } } @@ -100,7 +100,7 @@ int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, T return ret; } -int Curve::get_index(real_t offset) const { +int Curve::get_index(real_t p_offset) const { // Lower-bound float binary search int imin = 0; @@ -109,13 +109,13 @@ int Curve::get_index(real_t offset) const { while (imax - imin > 1) { int m = (imin + imax) / 2; - real_t a = _points[m].pos.x; - real_t b = _points[m + 1].pos.x; + real_t a = _points[m].position.x; + real_t b = _points[m + 1].position.x; - if (a < offset && b < offset) { + if (a < p_offset && b < p_offset) { imin = m; - } else if (a > offset) { + } else if (a > p_offset) { imax = m; } else { @@ -124,7 +124,7 @@ int Curve::get_index(real_t offset) const { } // Will happen if the offset is out of bounds - if (offset > _points[imax].pos.x) { + if (p_offset > _points[imax].position.x) { return imax; } return imin; @@ -134,9 +134,9 @@ void Curve::clean_dupes() { bool dirty = false; for (int i = 1; i < _points.size(); ++i) { - real_t diff = _points[i - 1].pos.x - _points[i].pos.x; + real_t diff = _points[i - 1].position.x - _points[i].position.x; if (diff <= CMP_EPSILON) { - _points.remove(i); + _points.remove_at(i); --i; dirty = true; } @@ -147,67 +147,67 @@ void Curve::clean_dupes() { } } -void Curve::set_point_left_tangent(int i, real_t tangent) { - ERR_FAIL_INDEX(i, _points.size()); - _points.write[i].left_tangent = tangent; - _points.write[i].left_mode = TANGENT_FREE; +void Curve::set_point_left_tangent(int p_index, real_t p_tangent) { + ERR_FAIL_INDEX(p_index, _points.size()); + _points.write[p_index].left_tangent = p_tangent; + _points.write[p_index].left_mode = TANGENT_FREE; mark_dirty(); } -void Curve::set_point_right_tangent(int i, real_t tangent) { - ERR_FAIL_INDEX(i, _points.size()); - _points.write[i].right_tangent = tangent; - _points.write[i].right_mode = TANGENT_FREE; +void Curve::set_point_right_tangent(int p_index, real_t p_tangent) { + ERR_FAIL_INDEX(p_index, _points.size()); + _points.write[p_index].right_tangent = p_tangent; + _points.write[p_index].right_mode = TANGENT_FREE; mark_dirty(); } -void Curve::set_point_left_mode(int i, TangentMode p_mode) { - ERR_FAIL_INDEX(i, _points.size()); - _points.write[i].left_mode = p_mode; - if (i > 0) { +void Curve::set_point_left_mode(int p_index, TangentMode p_mode) { + ERR_FAIL_INDEX(p_index, _points.size()); + _points.write[p_index].left_mode = p_mode; + if (p_index > 0) { if (p_mode == TANGENT_LINEAR) { - Vector2 v = (_points[i - 1].pos - _points[i].pos).normalized(); - _points.write[i].left_tangent = v.y / v.x; + Vector2 v = (_points[p_index - 1].position - _points[p_index].position).normalized(); + _points.write[p_index].left_tangent = v.y / v.x; } } mark_dirty(); } -void Curve::set_point_right_mode(int i, TangentMode p_mode) { - ERR_FAIL_INDEX(i, _points.size()); - _points.write[i].right_mode = p_mode; - if (i + 1 < _points.size()) { +void Curve::set_point_right_mode(int p_index, TangentMode p_mode) { + ERR_FAIL_INDEX(p_index, _points.size()); + _points.write[p_index].right_mode = p_mode; + if (p_index + 1 < _points.size()) { if (p_mode == TANGENT_LINEAR) { - Vector2 v = (_points[i + 1].pos - _points[i].pos).normalized(); - _points.write[i].right_tangent = v.y / v.x; + Vector2 v = (_points[p_index + 1].position - _points[p_index].position).normalized(); + _points.write[p_index].right_tangent = v.y / v.x; } } mark_dirty(); } -real_t Curve::get_point_left_tangent(int i) const { - ERR_FAIL_INDEX_V(i, _points.size(), 0); - return _points[i].left_tangent; +real_t Curve::get_point_left_tangent(int p_index) const { + ERR_FAIL_INDEX_V(p_index, _points.size(), 0); + return _points[p_index].left_tangent; } -real_t Curve::get_point_right_tangent(int i) const { - ERR_FAIL_INDEX_V(i, _points.size(), 0); - return _points[i].right_tangent; +real_t Curve::get_point_right_tangent(int p_index) const { + ERR_FAIL_INDEX_V(p_index, _points.size(), 0); + return _points[p_index].right_tangent; } -Curve::TangentMode Curve::get_point_left_mode(int i) const { - ERR_FAIL_INDEX_V(i, _points.size(), TANGENT_FREE); - return _points[i].left_mode; +Curve::TangentMode Curve::get_point_left_mode(int p_index) const { + ERR_FAIL_INDEX_V(p_index, _points.size(), TANGENT_FREE); + return _points[p_index].left_mode; } -Curve::TangentMode Curve::get_point_right_mode(int i) const { - ERR_FAIL_INDEX_V(i, _points.size(), TANGENT_FREE); - return _points[i].right_mode; +Curve::TangentMode Curve::get_point_right_mode(int p_index) const { + ERR_FAIL_INDEX_V(p_index, _points.size(), TANGENT_FREE); + return _points[p_index].right_mode; } void Curve::remove_point(int p_index) { ERR_FAIL_INDEX(p_index, _points.size()); - _points.remove(p_index); + _points.remove_at(p_index); mark_dirty(); } @@ -216,18 +216,18 @@ void Curve::clear_points() { mark_dirty(); } -void Curve::set_point_value(int p_index, real_t pos) { +void Curve::set_point_value(int p_index, real_t p_position) { ERR_FAIL_INDEX(p_index, _points.size()); - _points.write[p_index].pos.y = pos; + _points.write[p_index].position.y = p_position; update_auto_tangents(p_index); mark_dirty(); } -int Curve::set_point_offset(int p_index, float offset) { +int Curve::set_point_offset(int p_index, real_t p_offset) { ERR_FAIL_INDEX_V(p_index, _points.size(), -1); Point p = _points[p_index]; remove_point(p_index); - int i = add_point(Vector2(offset, p.pos.y)); + int i = add_point(Vector2(p_offset, p.position.y)); _points.write[i].left_tangent = p.left_tangent; _points.write[i].right_tangent = p.right_tangent; _points.write[i].left_mode = p.left_mode; @@ -241,7 +241,7 @@ int Curve::set_point_offset(int p_index, float offset) { Vector2 Curve::get_point_position(int p_index) const { ERR_FAIL_INDEX_V(p_index, _points.size(), Vector2(0, 0)); - return _points[p_index].pos; + return _points[p_index].position; } Curve::Point Curve::get_point(int p_index) const { @@ -249,35 +249,35 @@ Curve::Point Curve::get_point(int p_index) const { return _points[p_index]; } -void Curve::update_auto_tangents(int i) { - Point &p = _points.write[i]; +void Curve::update_auto_tangents(int p_index) { + Point &p = _points.write[p_index]; - if (i > 0) { + if (p_index > 0) { if (p.left_mode == TANGENT_LINEAR) { - Vector2 v = (_points[i - 1].pos - p.pos).normalized(); + Vector2 v = (_points[p_index - 1].position - p.position).normalized(); p.left_tangent = v.y / v.x; } - if (_points[i - 1].right_mode == TANGENT_LINEAR) { - Vector2 v = (_points[i - 1].pos - p.pos).normalized(); - _points.write[i - 1].right_tangent = v.y / v.x; + if (_points[p_index - 1].right_mode == TANGENT_LINEAR) { + Vector2 v = (_points[p_index - 1].position - p.position).normalized(); + _points.write[p_index - 1].right_tangent = v.y / v.x; } } - if (i + 1 < _points.size()) { + if (p_index + 1 < _points.size()) { if (p.right_mode == TANGENT_LINEAR) { - Vector2 v = (_points[i + 1].pos - p.pos).normalized(); + Vector2 v = (_points[p_index + 1].position - p.position).normalized(); p.right_tangent = v.y / v.x; } - if (_points[i + 1].left_mode == TANGENT_LINEAR) { - Vector2 v = (_points[i + 1].pos - p.pos).normalized(); - _points.write[i + 1].left_tangent = v.y / v.x; + if (_points[p_index + 1].left_mode == TANGENT_LINEAR) { + Vector2 v = (_points[p_index + 1].position - p.position).normalized(); + _points.write[p_index + 1].left_tangent = v.y / v.x; } } } #define MIN_Y_RANGE 0.01 -void Curve::set_min_value(float p_min) { +void Curve::set_min_value(real_t p_min) { if (_minmax_set_once & 0b11 && p_min > _max_value - MIN_Y_RANGE) { _min_value = _max_value - MIN_Y_RANGE; } else { @@ -289,7 +289,7 @@ void Curve::set_min_value(float p_min) { emit_signal(SNAME(SIGNAL_RANGE_CHANGED)); } -void Curve::set_max_value(float p_max) { +void Curve::set_max_value(real_t p_max) { if (_minmax_set_once & 0b11 && p_max < _min_value + MIN_Y_RANGE) { _max_value = _min_value + MIN_Y_RANGE; } else { @@ -299,32 +299,32 @@ void Curve::set_max_value(float p_max) { emit_signal(SNAME(SIGNAL_RANGE_CHANGED)); } -real_t Curve::interpolate(real_t offset) const { +real_t Curve::interpolate(real_t p_offset) const { if (_points.size() == 0) { return 0; } if (_points.size() == 1) { - return _points[0].pos.y; + return _points[0].position.y; } - int i = get_index(offset); + int i = get_index(p_offset); if (i == _points.size() - 1) { - return _points[i].pos.y; + return _points[i].position.y; } - real_t local = offset - _points[i].pos.x; + real_t local = p_offset - _points[i].position.x; if (i == 0 && local <= 0) { - return _points[0].pos.y; + return _points[0].position.y; } return interpolate_local_nocheck(i, local); } -real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const { - const Point a = _points[index]; - const Point b = _points[index + 1]; +real_t Curve::interpolate_local_nocheck(int p_index, real_t p_local_offset) const { + const Point a = _points[p_index]; + const Point b = _points[p_index + 1]; /* Cubic bezier * @@ -341,16 +341,16 @@ real_t Curve::interpolate_local_nocheck(int index, real_t local_offset) const { */ // Control points are chosen at equal distances - real_t d = b.pos.x - a.pos.x; - if (Math::abs(d) <= CMP_EPSILON) { - return b.pos.y; + real_t d = b.position.x - a.position.x; + if (Math::is_zero_approx(d)) { + return b.position.y; } - local_offset /= d; + p_local_offset /= d; d /= 3.0; - real_t yac = a.pos.y + d * a.right_tangent; - real_t ybc = b.pos.y - d * b.left_tangent; + real_t yac = a.position.y + d * a.right_tangent; + real_t ybc = b.position.y - d * b.left_tangent; - real_t y = _bezier_interp(local_offset, a.pos.y, yac, ybc, b.pos.y); + real_t y = _bezier_interp(p_local_offset, a.position.y, yac, ybc, b.position.y); return y; } @@ -369,7 +369,7 @@ Array Curve::get_data() const { const Point p = _points[j]; int i = j * ELEMS; - output[i] = p.pos; + output[i] = p.position; output[i + 1] = p.left_tangent; output[i + 2] = p.right_tangent; output[i + 3] = p.left_mode; @@ -379,39 +379,39 @@ Array Curve::get_data() const { return output; } -void Curve::set_data(Array input) { +void Curve::set_data(const Array p_input) { const unsigned int ELEMS = 5; - ERR_FAIL_COND(input.size() % ELEMS != 0); + ERR_FAIL_COND(p_input.size() % ELEMS != 0); _points.clear(); // Validate input - for (int i = 0; i < input.size(); i += ELEMS) { - ERR_FAIL_COND(input[i].get_type() != Variant::VECTOR2); - ERR_FAIL_COND(!input[i + 1].is_num()); - ERR_FAIL_COND(input[i + 2].get_type() != Variant::FLOAT); + for (int i = 0; i < p_input.size(); i += ELEMS) { + ERR_FAIL_COND(p_input[i].get_type() != Variant::VECTOR2); + ERR_FAIL_COND(!p_input[i + 1].is_num()); + ERR_FAIL_COND(p_input[i + 2].get_type() != Variant::FLOAT); - ERR_FAIL_COND(input[i + 3].get_type() != Variant::INT); - int left_mode = input[i + 3]; + ERR_FAIL_COND(p_input[i + 3].get_type() != Variant::INT); + int left_mode = p_input[i + 3]; ERR_FAIL_COND(left_mode < 0 || left_mode >= TANGENT_MODE_COUNT); - ERR_FAIL_COND(input[i + 4].get_type() != Variant::INT); - int right_mode = input[i + 4]; + ERR_FAIL_COND(p_input[i + 4].get_type() != Variant::INT); + int right_mode = p_input[i + 4]; ERR_FAIL_COND(right_mode < 0 || right_mode >= TANGENT_MODE_COUNT); } - _points.resize(input.size() / ELEMS); + _points.resize(p_input.size() / ELEMS); for (int j = 0; j < _points.size(); ++j) { Point &p = _points.write[j]; int i = j * ELEMS; - p.pos = input[i]; - p.left_tangent = input[i + 1]; - p.right_tangent = input[i + 2]; + p.position = p_input[i]; + p.left_tangent = p_input[i + 1]; + p.right_tangent = p_input[i + 2]; // TODO For some reason the compiler won't convert from Variant to enum - int left_mode = input[i + 3]; - int right_mode = input[i + 4]; + int left_mode = p_input[i + 3]; + int right_mode = p_input[i + 4]; p.left_mode = (TangentMode)left_mode; p.right_mode = (TangentMode)right_mode; } @@ -431,8 +431,8 @@ void Curve::bake() { } if (_points.size() != 0) { - _baked_cache.write[0] = _points[0].pos.y; - _baked_cache.write[_baked_cache.size() - 1] = _points[_points.size() - 1].pos.y; + _baked_cache.write[0] = _points[0].position.y; + _baked_cache.write[_baked_cache.size() - 1] = _points[_points.size() - 1].position.y; } _baked_cache_dirty = false; @@ -445,7 +445,7 @@ void Curve::set_bake_resolution(int p_resolution) { _baked_cache_dirty = true; } -real_t Curve::interpolate_baked(real_t offset) const { +real_t Curve::interpolate_baked(real_t p_offset) const { if (_baked_cache_dirty) { // Last-second bake if not done already const_cast<Curve *>(this)->bake(); @@ -456,13 +456,13 @@ real_t Curve::interpolate_baked(real_t offset) const { if (_points.size() == 0) { return 0; } - return _points[0].pos.y; + return _points[0].position.y; } else if (_baked_cache.size() == 1) { return _baked_cache[0]; } // Get interpolation index - real_t fi = offset * _baked_cache.size(); + real_t fi = p_offset * _baked_cache.size(); int i = Math::floor(fi); if (i < 0) { i = 0; @@ -481,7 +481,7 @@ real_t Curve::interpolate_baked(real_t offset) const { } } -void Curve::ensure_default_setup(float p_min, float p_max) { +void Curve::ensure_default_setup(real_t p_min, real_t p_max) { if (_points.size() == 0 && _min_value == 0 && _max_value == 1) { add_point(Vector2(0, 1)); add_point(Vector2(1, 1)); @@ -535,9 +535,9 @@ int Curve2D::get_point_count() const { return points.size(); } -void Curve2D::add_point(const Vector2 &p_pos, const Vector2 &p_in, const Vector2 &p_out, int p_atpos) { +void Curve2D::add_point(const Vector2 &p_position, const Vector2 &p_in, const Vector2 &p_out, int p_atpos) { Point n; - n.pos = p_pos; + n.position = p_position; n.in = p_in; n.out = p_out; if (p_atpos >= 0 && p_atpos < points.size()) { @@ -550,17 +550,17 @@ void Curve2D::add_point(const Vector2 &p_pos, const Vector2 &p_in, const Vector2 emit_signal(CoreStringNames::get_singleton()->changed); } -void Curve2D::set_point_position(int p_index, const Vector2 &p_pos) { +void Curve2D::set_point_position(int p_index, const Vector2 &p_position) { ERR_FAIL_INDEX(p_index, points.size()); - points.write[p_index].pos = p_pos; + points.write[p_index].position = p_position; baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } Vector2 Curve2D::get_point_position(int p_index) const { ERR_FAIL_INDEX_V(p_index, points.size(), Vector2()); - return points[p_index].pos; + return points[p_index].position; } void Curve2D::set_point_in(int p_index, const Vector2 &p_in) { @@ -591,7 +591,7 @@ Vector2 Curve2D::get_point_out(int p_index) const { void Curve2D::remove_point(int p_index) { ERR_FAIL_INDEX(p_index, points.size()); - points.remove(p_index); + points.remove_at(p_index); baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } @@ -604,19 +604,19 @@ void Curve2D::clear_points() { } } -Vector2 Curve2D::interpolate(int p_index, float p_offset) const { +Vector2 Curve2D::interpolate(int p_index, const real_t p_offset) const { int pc = points.size(); ERR_FAIL_COND_V(pc == 0, Vector2()); if (p_index >= pc - 1) { - return points[pc - 1].pos; + return points[pc - 1].position; } else if (p_index < 0) { - return points[0].pos; + return points[0].position; } - Vector2 p0 = points[p_index].pos; + Vector2 p0 = points[p_index].position; Vector2 p1 = p0 + points[p_index].out; - Vector2 p3 = points[p_index + 1].pos; + Vector2 p3 = points[p_index + 1].position; Vector2 p2 = p3 + points[p_index + 1].in; return _bezier_interp(p_offset, p0, p1, p2, p3); @@ -632,15 +632,15 @@ Vector2 Curve2D::interpolatef(real_t p_findex) const { return interpolate((int)p_findex, Math::fmod(p_findex, (real_t)1.0)); } -void Curve2D::_bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, float p_tol) const { - float mp = p_begin + (p_end - p_begin) * 0.5; +void Curve2D::_bake_segment2d(Map<real_t, Vector2> &r_bake, real_t p_begin, real_t p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, real_t p_tol) const { + real_t mp = p_begin + (p_end - p_begin) * 0.5; Vector2 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b); Vector2 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b); Vector2 end = _bezier_interp(p_end, p_a, p_a + p_out, p_b + p_in, p_b); Vector2 na = (mid - beg).normalized(); Vector2 nb = (end - mid).normalized(); - float dp = na.dot(nb); + real_t dp = na.dot(nb); if (dp < Math::cos(Math::deg2rad(p_tol))) { r_bake[mp] = mid; @@ -668,47 +668,47 @@ void Curve2D::_bake() const { if (points.size() == 1) { baked_point_cache.resize(1); - baked_point_cache.set(0, points[0].pos); + baked_point_cache.set(0, points[0].position); baked_dist_cache.resize(1); baked_dist_cache.set(0, 0.0); return; } - Vector2 pos = points[0].pos; - float dist = 0.0; + Vector2 position = points[0].position; + real_t dist = 0.0; List<Vector2> pointlist; - List<float> distlist; + List<real_t> distlist; - pointlist.push_back(pos); //start always from origin + pointlist.push_back(position); //start always from origin distlist.push_back(0.0); for (int i = 0; i < points.size() - 1; i++) { - float step = 0.1; // at least 10 substeps ought to be enough? - float p = 0.0; + real_t step = 0.1; // at least 10 substeps ought to be enough? + real_t p = 0.0; while (p < 1.0) { - float np = p + step; + real_t np = p + step; if (np > 1.0) { np = 1.0; } - Vector2 npp = _bezier_interp(np, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos); - float d = pos.distance_to(npp); + Vector2 npp = _bezier_interp(np, points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position); + real_t d = position.distance_to(npp); if (d > bake_interval) { // OK! between P and NP there _has_ to be Something, let's go searching! int iterations = 10; //lots of detail! - float low = p; - float hi = np; - float mid = low + (hi - low) * 0.5; + real_t low = p; + real_t hi = np; + real_t mid = low + (hi - low) * 0.5; for (int j = 0; j < iterations; j++) { - npp = _bezier_interp(mid, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos); - d = pos.distance_to(npp); + npp = _bezier_interp(mid, points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position); + d = position.distance_to(npp); if (bake_interval < d) { hi = mid; @@ -718,11 +718,11 @@ void Curve2D::_bake() const { mid = low + (hi - low) * 0.5; } - pos = npp; + position = npp; p = mid; dist += d; - pointlist.push_back(pos); + pointlist.push_back(position); distlist.push_back(dist); } else { p = np; @@ -730,9 +730,9 @@ void Curve2D::_bake() const { } } - Vector2 lastpos = points[points.size() - 1].pos; + Vector2 lastpos = points[points.size() - 1].position; - float rem = pos.distance_to(lastpos); + real_t rem = position.distance_to(lastpos); dist += rem; baked_max_ofs = dist; pointlist.push_back(lastpos); @@ -742,7 +742,7 @@ void Curve2D::_bake() const { baked_dist_cache.resize(distlist.size()); Vector2 *w = baked_point_cache.ptrw(); - float *wd = baked_dist_cache.ptrw(); + real_t *wd = baked_dist_cache.ptrw(); for (int i = 0; i < pointlist.size(); i++) { w[i] = pointlist[i]; @@ -750,7 +750,7 @@ void Curve2D::_bake() const { } } -float Curve2D::get_baked_length() const { +real_t Curve2D::get_baked_length() const { if (baked_cache_dirty) { _bake(); } @@ -758,7 +758,7 @@ float Curve2D::get_baked_length() const { return baked_max_ofs; } -Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const { +Vector2 Curve2D::interpolate_baked(real_t p_offset, bool p_cubic) const { if (baked_cache_dirty) { _bake(); } @@ -784,7 +784,7 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const { int start = 0, end = bpc, idx = (end + start) / 2; // binary search to find baked points while (start < idx) { - float offset = baked_dist_cache[idx]; + real_t offset = baked_dist_cache[idx]; if (p_offset <= offset) { end = idx; } else { @@ -793,13 +793,13 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const { idx = (end + start) / 2; } - float offset_begin = baked_dist_cache[idx]; - float offset_end = baked_dist_cache[idx + 1]; + real_t offset_begin = baked_dist_cache[idx]; + real_t offset_end = baked_dist_cache[idx + 1]; - float idx_interval = offset_end - offset_begin; + real_t idx_interval = offset_end - offset_begin; ERR_FAIL_COND_V_MSG(p_offset < offset_begin || p_offset > offset_end, Vector2(), "failed to find baked segment"); - float frac = (p_offset - offset_begin) / idx_interval; + real_t frac = (p_offset - offset_begin) / idx_interval; if (p_cubic) { Vector2 pre = idx > 0 ? r[idx - 1] : r[idx]; @@ -818,13 +818,13 @@ PackedVector2Array Curve2D::get_baked_points() const { return baked_point_cache; } -void Curve2D::set_bake_interval(float p_tolerance) { +void Curve2D::set_bake_interval(real_t p_tolerance) { bake_interval = p_tolerance; baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } -float Curve2D::get_bake_interval() const { +real_t Curve2D::get_bake_interval() const { return bake_interval; } @@ -846,16 +846,16 @@ Vector2 Curve2D::get_closest_point(const Vector2 &p_to_point) const { const Vector2 *r = baked_point_cache.ptr(); Vector2 nearest; - float nearest_dist = -1.0f; + real_t nearest_dist = -1.0f; for (int i = 0; i < pc - 1; i++) { Vector2 origin = r[i]; Vector2 direction = (r[i + 1] - origin) / bake_interval; - float d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); + real_t d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); Vector2 proj = origin + direction * d; - float dist = proj.distance_squared_to(p_to_point); + real_t dist = proj.distance_squared_to(p_to_point); if (nearest_dist < 0.0f || dist < nearest_dist) { nearest = proj; @@ -866,7 +866,7 @@ Vector2 Curve2D::get_closest_point(const Vector2 &p_to_point) const { return nearest; } -float Curve2D::get_closest_offset(const Vector2 &p_to_point) const { +real_t Curve2D::get_closest_offset(const Vector2 &p_to_point) const { // Brute force method if (baked_cache_dirty) { @@ -883,18 +883,18 @@ float Curve2D::get_closest_offset(const Vector2 &p_to_point) const { const Vector2 *r = baked_point_cache.ptr(); - float nearest = 0.0f; - float nearest_dist = -1.0f; - float offset = 0.0f; + real_t nearest = 0.0f; + real_t nearest_dist = -1.0f; + real_t offset = 0.0f; for (int i = 0; i < pc - 1; i++) { Vector2 origin = r[i]; Vector2 direction = (r[i + 1] - origin) / bake_interval; - float d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); + real_t d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); Vector2 proj = origin + direction * d; - float dist = proj.distance_squared_to(p_to_point); + real_t dist = proj.distance_squared_to(p_to_point); if (nearest_dist < 0.0f || dist < nearest_dist) { nearest = offset + d; @@ -917,7 +917,7 @@ Dictionary Curve2D::_get_data() const { for (int i = 0; i < points.size(); i++) { w[i * 3 + 0] = points[i].in; w[i * 3 + 1] = points[i].out; - w[i * 3 + 2] = points[i].pos; + w[i * 3 + 2] = points[i].position; } dc["points"] = d; @@ -937,42 +937,42 @@ void Curve2D::_set_data(const Dictionary &p_data) { for (int i = 0; i < points.size(); i++) { points.write[i].in = r[i * 3 + 0]; points.write[i].out = r[i * 3 + 1]; - points.write[i].pos = r[i * 3 + 2]; + points.write[i].position = r[i * 3 + 2]; } baked_cache_dirty = true; } -PackedVector2Array Curve2D::tessellate(int p_max_stages, float p_tolerance) const { +PackedVector2Array Curve2D::tessellate(int p_max_stages, real_t p_tolerance) const { PackedVector2Array tess; if (points.size() == 0) { return tess; } - Vector<Map<float, Vector2>> midpoints; + Vector<Map<real_t, Vector2>> midpoints; midpoints.resize(points.size() - 1); int pc = 1; for (int i = 0; i < points.size() - 1; i++) { - _bake_segment2d(midpoints.write[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance); + _bake_segment2d(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[i + 1].position, points[i + 1].in, 0, p_max_stages, p_tolerance); pc++; pc += midpoints[i].size(); } tess.resize(pc); Vector2 *bpw = tess.ptrw(); - bpw[0] = points[0].pos; + bpw[0] = points[0].position; int pidx = 0; for (int i = 0; i < points.size() - 1; i++) { - for (const KeyValue<float, Vector2> &E : midpoints[i]) { + for (const KeyValue<real_t, Vector2> &E : midpoints[i]) { pidx++; bpw[pidx] = E.value; } pidx++; - bpw[pidx] = points[i + 1].pos; + bpw[pidx] = points[i + 1].position; } return tess; @@ -1026,9 +1026,9 @@ int Curve3D::get_point_count() const { return points.size(); } -void Curve3D::add_point(const Vector3 &p_pos, const Vector3 &p_in, const Vector3 &p_out, int p_atpos) { +void Curve3D::add_point(const Vector3 &p_position, const Vector3 &p_in, const Vector3 &p_out, int p_atpos) { Point n; - n.pos = p_pos; + n.position = p_position; n.in = p_in; n.out = p_out; if (p_atpos >= 0 && p_atpos < points.size()) { @@ -1041,20 +1041,20 @@ void Curve3D::add_point(const Vector3 &p_pos, const Vector3 &p_in, const Vector3 emit_signal(CoreStringNames::get_singleton()->changed); } -void Curve3D::set_point_position(int p_index, const Vector3 &p_pos) { +void Curve3D::set_point_position(int p_index, const Vector3 &p_position) { ERR_FAIL_INDEX(p_index, points.size()); - points.write[p_index].pos = p_pos; + points.write[p_index].position = p_position; baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } Vector3 Curve3D::get_point_position(int p_index) const { ERR_FAIL_INDEX_V(p_index, points.size(), Vector3()); - return points[p_index].pos; + return points[p_index].position; } -void Curve3D::set_point_tilt(int p_index, float p_tilt) { +void Curve3D::set_point_tilt(int p_index, real_t p_tilt) { ERR_FAIL_INDEX(p_index, points.size()); points.write[p_index].tilt = p_tilt; @@ -1062,7 +1062,7 @@ void Curve3D::set_point_tilt(int p_index, float p_tilt) { emit_signal(CoreStringNames::get_singleton()->changed); } -float Curve3D::get_point_tilt(int p_index) const { +real_t Curve3D::get_point_tilt(int p_index) const { ERR_FAIL_INDEX_V(p_index, points.size(), 0); return points[p_index].tilt; } @@ -1095,7 +1095,7 @@ Vector3 Curve3D::get_point_out(int p_index) const { void Curve3D::remove_point(int p_index) { ERR_FAIL_INDEX(p_index, points.size()); - points.remove(p_index); + points.remove_at(p_index); baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } @@ -1108,19 +1108,19 @@ void Curve3D::clear_points() { } } -Vector3 Curve3D::interpolate(int p_index, float p_offset) const { +Vector3 Curve3D::interpolate(int p_index, real_t p_offset) const { int pc = points.size(); ERR_FAIL_COND_V(pc == 0, Vector3()); if (p_index >= pc - 1) { - return points[pc - 1].pos; + return points[pc - 1].position; } else if (p_index < 0) { - return points[0].pos; + return points[0].position; } - Vector3 p0 = points[p_index].pos; + Vector3 p0 = points[p_index].position; Vector3 p1 = p0 + points[p_index].out; - Vector3 p3 = points[p_index + 1].pos; + Vector3 p3 = points[p_index + 1].position; Vector3 p2 = p3 + points[p_index + 1].in; return _bezier_interp(p_offset, p0, p1, p2, p3); @@ -1136,15 +1136,15 @@ Vector3 Curve3D::interpolatef(real_t p_findex) const { return interpolate((int)p_findex, Math::fmod(p_findex, (real_t)1.0)); } -void Curve3D::_bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, float p_tol) const { - float mp = p_begin + (p_end - p_begin) * 0.5; +void Curve3D::_bake_segment3d(Map<real_t, Vector3> &r_bake, real_t p_begin, real_t p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, real_t p_tol) const { + real_t mp = p_begin + (p_end - p_begin) * 0.5; Vector3 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b); Vector3 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b); Vector3 end = _bezier_interp(p_end, p_a, p_a + p_out, p_b + p_in, p_b); Vector3 na = (mid - beg).normalized(); Vector3 nb = (end - mid).normalized(); - float dp = na.dot(nb); + real_t dp = na.dot(nb); if (dp < Math::cos(Math::deg2rad(p_tol))) { r_bake[mp] = mid; @@ -1173,7 +1173,7 @@ void Curve3D::_bake() const { if (points.size() == 1) { baked_point_cache.resize(1); - baked_point_cache.set(0, points[0].pos); + baked_point_cache.set(0, points[0].position); baked_tilt_cache.resize(1); baked_tilt_cache.set(0, points[0].tilt); baked_dist_cache.resize(1); @@ -1189,39 +1189,39 @@ void Curve3D::_bake() const { return; } - Vector3 pos = points[0].pos; - float dist = 0.0; + Vector3 position = points[0].position; + real_t dist = 0.0; List<Plane> pointlist; - List<float> distlist; + List<real_t> distlist; - pointlist.push_back(Plane(pos, points[0].tilt)); + pointlist.push_back(Plane(position, points[0].tilt)); distlist.push_back(0.0); for (int i = 0; i < points.size() - 1; i++) { - float step = 0.1; // at least 10 substeps ought to be enough? - float p = 0.0; + real_t step = 0.1; // at least 10 substeps ought to be enough? + real_t p = 0.0; while (p < 1.0) { - float np = p + step; + real_t np = p + step; if (np > 1.0) { np = 1.0; } - Vector3 npp = _bezier_interp(np, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos); - float d = pos.distance_to(npp); + Vector3 npp = _bezier_interp(np, points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position); + real_t d = position.distance_to(npp); if (d > bake_interval) { // OK! between P and NP there _has_ to be Something, let's go searching! int iterations = 10; //lots of detail! - float low = p; - float hi = np; - float mid = low + (hi - low) * 0.5; + real_t low = p; + real_t hi = np; + real_t mid = low + (hi - low) * 0.5; for (int j = 0; j < iterations; j++) { - npp = _bezier_interp(mid, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos); - d = pos.distance_to(npp); + npp = _bezier_interp(mid, points[i].position, points[i].position + points[i].out, points[i + 1].position + points[i + 1].in, points[i + 1].position); + d = position.distance_to(npp); if (bake_interval < d) { hi = mid; @@ -1231,10 +1231,10 @@ void Curve3D::_bake() const { mid = low + (hi - low) * 0.5; } - pos = npp; + position = npp; p = mid; Plane post; - post.normal = pos; + post.normal = position; post.d = Math::lerp(points[i].tilt, points[i + 1].tilt, mid); dist += d; @@ -1246,10 +1246,10 @@ void Curve3D::_bake() const { } } - Vector3 lastpos = points[points.size() - 1].pos; - float lastilt = points[points.size() - 1].tilt; + Vector3 lastpos = points[points.size() - 1].position; + real_t lastilt = points[points.size() - 1].tilt; - float rem = pos.distance_to(lastpos); + real_t rem = position.distance_to(lastpos); dist += rem; baked_max_ofs = dist; pointlist.push_back(Plane(lastpos, lastilt)); @@ -1266,7 +1266,7 @@ void Curve3D::_bake() const { Vector3 *up_write = baked_up_vector_cache.ptrw(); baked_dist_cache.resize(pointlist.size()); - float *wd = baked_dist_cache.ptrw(); + real_t *wd = baked_dist_cache.ptrw(); Vector3 sideways; Vector3 up; @@ -1288,7 +1288,7 @@ void Curve3D::_bake() const { forward = idx > 0 ? (w[idx] - w[idx - 1]).normalized() : prev_forward; - float y_dot = prev_up.dot(forward); + real_t y_dot = prev_up.dot(forward); if (y_dot > (1.0f - CMP_EPSILON)) { sideways = prev_sideways; @@ -1315,7 +1315,7 @@ void Curve3D::_bake() const { } } -float Curve3D::get_baked_length() const { +real_t Curve3D::get_baked_length() const { if (baked_cache_dirty) { _bake(); } @@ -1323,7 +1323,7 @@ float Curve3D::get_baked_length() const { return baked_max_ofs; } -Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const { +Vector3 Curve3D::interpolate_baked(real_t p_offset, bool p_cubic) const { if (baked_cache_dirty) { _bake(); } @@ -1349,7 +1349,7 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const { int start = 0, end = bpc, idx = (end + start) / 2; // binary search to find baked points while (start < idx) { - float offset = baked_dist_cache[idx]; + real_t offset = baked_dist_cache[idx]; if (p_offset <= offset) { end = idx; } else { @@ -1358,13 +1358,13 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const { idx = (end + start) / 2; } - float offset_begin = baked_dist_cache[idx]; - float offset_end = baked_dist_cache[idx + 1]; + real_t offset_begin = baked_dist_cache[idx]; + real_t offset_end = baked_dist_cache[idx + 1]; - float idx_interval = offset_end - offset_begin; + real_t idx_interval = offset_end - offset_begin; ERR_FAIL_COND_V_MSG(p_offset < offset_begin || p_offset > offset_end, Vector3(), "failed to find baked segment"); - float frac = (p_offset - offset_begin) / idx_interval; + real_t frac = (p_offset - offset_begin) / idx_interval; if (p_cubic) { Vector3 pre = idx > 0 ? r[idx - 1] : r[idx]; @@ -1375,7 +1375,7 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const { } } -float Curve3D::interpolate_baked_tilt(float p_offset) const { +real_t Curve3D::interpolate_baked_tilt(real_t p_offset) const { if (baked_cache_dirty) { _bake(); } @@ -1399,7 +1399,7 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const { } int idx = Math::floor((double)p_offset / (double)bake_interval); - float frac = Math::fmod(p_offset, bake_interval); + real_t frac = Math::fmod(p_offset, bake_interval); if (idx >= bpc - 1) { return r[bpc - 1]; @@ -1414,7 +1414,7 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const { return Math::lerp(r[idx], r[idx + 1], (real_t)frac); } -Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt) const { +Vector3 Curve3D::interpolate_baked_up_vector(real_t p_offset, bool p_apply_tilt) const { if (baked_cache_dirty) { _bake(); } @@ -1432,10 +1432,10 @@ Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt) const Vector3 *rp = baked_point_cache.ptr(); const real_t *rt = baked_tilt_cache.ptr(); - float offset = CLAMP(p_offset, 0.0f, baked_max_ofs); + real_t offset = CLAMP(p_offset, 0.0f, baked_max_ofs); int idx = Math::floor((double)offset / (double)bake_interval); - float frac = Math::fmod(offset, bake_interval) / bake_interval; + real_t frac = Math::fmod(offset, bake_interval) / bake_interval; if (idx == count - 1) { return p_apply_tilt ? r[idx].rotated((rp[idx] - rp[idx - 1]).normalized(), rt[idx]) : r[idx]; @@ -1503,16 +1503,16 @@ Vector3 Curve3D::get_closest_point(const Vector3 &p_to_point) const { const Vector3 *r = baked_point_cache.ptr(); Vector3 nearest; - float nearest_dist = -1.0f; + real_t nearest_dist = -1.0f; for (int i = 0; i < pc - 1; i++) { Vector3 origin = r[i]; Vector3 direction = (r[i + 1] - origin) / bake_interval; - float d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); + real_t d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); Vector3 proj = origin + direction * d; - float dist = proj.distance_squared_to(p_to_point); + real_t dist = proj.distance_squared_to(p_to_point); if (nearest_dist < 0.0f || dist < nearest_dist) { nearest = proj; @@ -1523,7 +1523,7 @@ Vector3 Curve3D::get_closest_point(const Vector3 &p_to_point) const { return nearest; } -float Curve3D::get_closest_offset(const Vector3 &p_to_point) const { +real_t Curve3D::get_closest_offset(const Vector3 &p_to_point) const { // Brute force method if (baked_cache_dirty) { @@ -1540,18 +1540,18 @@ float Curve3D::get_closest_offset(const Vector3 &p_to_point) const { const Vector3 *r = baked_point_cache.ptr(); - float nearest = 0.0f; - float nearest_dist = -1.0f; - float offset = 0.0f; + real_t nearest = 0.0f; + real_t nearest_dist = -1.0f; + real_t offset = 0.0f; for (int i = 0; i < pc - 1; i++) { Vector3 origin = r[i]; Vector3 direction = (r[i + 1] - origin) / bake_interval; - float d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); + real_t d = CLAMP((p_to_point - origin).dot(direction), 0.0f, bake_interval); Vector3 proj = origin + direction * d; - float dist = proj.distance_squared_to(p_to_point); + real_t dist = proj.distance_squared_to(p_to_point); if (nearest_dist < 0.0f || dist < nearest_dist) { nearest = offset + d; @@ -1564,13 +1564,13 @@ float Curve3D::get_closest_offset(const Vector3 &p_to_point) const { return nearest; } -void Curve3D::set_bake_interval(float p_tolerance) { +void Curve3D::set_bake_interval(real_t p_tolerance) { bake_interval = p_tolerance; baked_cache_dirty = true; emit_signal(CoreStringNames::get_singleton()->changed); } -float Curve3D::get_bake_interval() const { +real_t Curve3D::get_bake_interval() const { return bake_interval; } @@ -1597,7 +1597,7 @@ Dictionary Curve3D::_get_data() const { for (int i = 0; i < points.size(); i++) { w[i * 3 + 0] = points[i].in; w[i * 3 + 1] = points[i].out; - w[i * 3 + 2] = points[i].pos; + w[i * 3 + 2] = points[i].position; wt[i] = points[i].tilt; } @@ -1622,43 +1622,43 @@ void Curve3D::_set_data(const Dictionary &p_data) { for (int i = 0; i < points.size(); i++) { points.write[i].in = r[i * 3 + 0]; points.write[i].out = r[i * 3 + 1]; - points.write[i].pos = r[i * 3 + 2]; + points.write[i].position = r[i * 3 + 2]; points.write[i].tilt = rt[i]; } baked_cache_dirty = true; } -PackedVector3Array Curve3D::tessellate(int p_max_stages, float p_tolerance) const { +PackedVector3Array Curve3D::tessellate(int p_max_stages, real_t p_tolerance) const { PackedVector3Array tess; if (points.size() == 0) { return tess; } - Vector<Map<float, Vector3>> midpoints; + Vector<Map<real_t, Vector3>> midpoints; midpoints.resize(points.size() - 1); int pc = 1; for (int i = 0; i < points.size() - 1; i++) { - _bake_segment3d(midpoints.write[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance); + _bake_segment3d(midpoints.write[i], 0, 1, points[i].position, points[i].out, points[i + 1].position, points[i + 1].in, 0, p_max_stages, p_tolerance); pc++; pc += midpoints[i].size(); } tess.resize(pc); Vector3 *bpw = tess.ptrw(); - bpw[0] = points[0].pos; + bpw[0] = points[0].position; int pidx = 0; for (int i = 0; i < points.size() - 1; i++) { - for (const KeyValue<float, Vector3> &E : midpoints[i]) { + for (const KeyValue<real_t, Vector3> &E : midpoints[i]) { pidx++; bpw[pidx] = E.value; } pidx++; - bpw[pidx] = points[i + 1].pos; + bpw[pidx] = points[i + 1].position; } return tess; diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 5808fd6508..16facda85a 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -50,7 +50,7 @@ public: }; struct Point { - Vector2 pos; + Vector2 position; real_t left_tangent = 0.0; real_t right_tangent = 0.0; TangentMode left_mode = TANGENT_FREE; @@ -59,12 +59,12 @@ public: Point() { } - Point(Vector2 p_pos, + Point(const Vector2 &p_position, real_t p_left = 0.0, real_t p_right = 0.0, TangentMode p_left_mode = TANGENT_FREE, TangentMode p_right_mode = TANGENT_FREE) { - pos = p_pos; + position = p_position; left_tangent = p_left; right_tangent = p_right; left_mode = p_left_mode; @@ -76,7 +76,7 @@ public: int get_point_count() const { return _points.size(); } - int add_point(Vector2 p_pos, + int add_point(Vector2 p_position, real_t left_tangent = 0, real_t right_tangent = 0, TangentMode left_mode = TANGENT_FREE, @@ -85,34 +85,34 @@ public: void remove_point(int p_index); void clear_points(); - int get_index(real_t offset) const; + int get_index(real_t p_offset) const; - void set_point_value(int p_index, real_t pos); - int set_point_offset(int p_index, float offset); + void set_point_value(int p_index, real_t p_position); + int set_point_offset(int p_index, real_t p_offset); Vector2 get_point_position(int p_index) const; Point get_point(int p_index) const; - float get_min_value() const { return _min_value; } - void set_min_value(float p_min); + real_t get_min_value() const { return _min_value; } + void set_min_value(real_t p_min); - float get_max_value() const { return _max_value; } - void set_max_value(float p_max); + real_t get_max_value() const { return _max_value; } + void set_max_value(real_t p_max); - real_t interpolate(real_t offset) const; - real_t interpolate_local_nocheck(int index, real_t local_offset) const; + real_t interpolate(real_t p_offset) const; + real_t interpolate_local_nocheck(int p_index, real_t p_local_offset) const; void clean_dupes(); - void set_point_left_tangent(int i, real_t tangent); - void set_point_right_tangent(int i, real_t tangent); - void set_point_left_mode(int i, TangentMode p_mode); - void set_point_right_mode(int i, TangentMode p_mode); + void set_point_left_tangent(int p_index, real_t p_tangent); + void set_point_right_tangent(int p_index, real_t p_tangent); + void set_point_left_mode(int p_index, TangentMode p_mode); + void set_point_right_mode(int p_index, TangentMode p_mode); - real_t get_point_left_tangent(int i) const; - real_t get_point_right_tangent(int i) const; - TangentMode get_point_left_mode(int i) const; - TangentMode get_point_right_mode(int i) const; + real_t get_point_left_tangent(int p_index) const; + real_t get_point_right_tangent(int p_index) const; + TangentMode get_point_left_mode(int p_index) const; + TangentMode get_point_right_mode(int p_index) const; void update_auto_tangents(int i); @@ -122,9 +122,9 @@ public: void bake(); int get_bake_resolution() const { return _bake_resolution; } void set_bake_resolution(int p_resolution); - real_t interpolate_baked(real_t offset) const; + real_t interpolate_baked(real_t p_offset) const; - void ensure_default_setup(float p_min, float p_max); + void ensure_default_setup(real_t p_min, real_t p_max); protected: static void _bind_methods(); @@ -136,8 +136,8 @@ private: bool _baked_cache_dirty = false; Vector<real_t> _baked_cache; int _bake_resolution = 100; - float _min_value = 0.0; - float _max_value = 1.0; + real_t _min_value = 0.0; + real_t _max_value = 1.0; int _minmax_set_once = 0b00; // Encodes whether min and max have been set a first time, first bit for min and second for max. }; @@ -149,26 +149,26 @@ class Curve2D : public Resource { struct Point { Vector2 in; Vector2 out; - Vector2 pos; + Vector2 position; }; Vector<Point> points; struct BakedPoint { - float ofs = 0.0; + real_t ofs = 0.0; Vector2 point; }; mutable bool baked_cache_dirty = false; mutable PackedVector2Array baked_point_cache; - mutable PackedFloat32Array baked_dist_cache; - mutable float baked_max_ofs = 0.0; + mutable Vector<real_t> baked_dist_cache; + mutable real_t baked_max_ofs = 0.0; void _bake() const; - float bake_interval = 5.0; + real_t bake_interval = 5.0; - void _bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, float p_tol) const; + void _bake_segment2d(Map<real_t, Vector2> &r_bake, real_t p_begin, real_t p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, real_t p_tol) const; Dictionary _get_data() const; void _set_data(const Dictionary &p_data); @@ -177,8 +177,8 @@ protected: public: int get_point_count() const; - void add_point(const Vector2 &p_pos, const Vector2 &p_in = Vector2(), const Vector2 &p_out = Vector2(), int p_atpos = -1); - void set_point_position(int p_index, const Vector2 &p_pos); + void add_point(const Vector2 &p_position, const Vector2 &p_in = Vector2(), const Vector2 &p_out = Vector2(), int p_atpos = -1); + void set_point_position(int p_index, const Vector2 &p_position); Vector2 get_point_position(int p_index) const; void set_point_in(int p_index, const Vector2 &p_in); Vector2 get_point_in(int p_index) const; @@ -187,19 +187,19 @@ public: void remove_point(int p_index); void clear_points(); - Vector2 interpolate(int p_index, float p_offset) const; + Vector2 interpolate(int p_index, real_t p_offset) const; Vector2 interpolatef(real_t p_findex) const; - void set_bake_interval(float p_tolerance); - float get_bake_interval() const; + void set_bake_interval(real_t p_tolerance); + real_t get_bake_interval() const; - float get_baked_length() const; - Vector2 interpolate_baked(float p_offset, bool p_cubic = false) const; + real_t get_baked_length() const; + Vector2 interpolate_baked(real_t p_offset, bool p_cubic = false) const; PackedVector2Array get_baked_points() const; //useful for going through Vector2 get_closest_point(const Vector2 &p_to_point) const; - float get_closest_offset(const Vector2 &p_to_point) const; + real_t get_closest_offset(const Vector2 &p_to_point) const; - PackedVector2Array tessellate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display + PackedVector2Array tessellate(int p_max_stages = 5, real_t p_tolerance = 4) const; //useful for display Curve2D(); }; @@ -210,14 +210,14 @@ class Curve3D : public Resource { struct Point { Vector3 in; Vector3 out; - Vector3 pos; - float tilt = 0.0; + Vector3 position; + real_t tilt = 0.0; }; Vector<Point> points; struct BakedPoint { - float ofs = 0.0; + real_t ofs = 0.0; Vector3 point; }; @@ -225,15 +225,15 @@ class Curve3D : public Resource { mutable PackedVector3Array baked_point_cache; mutable Vector<real_t> baked_tilt_cache; mutable PackedVector3Array baked_up_vector_cache; - mutable PackedFloat32Array baked_dist_cache; - mutable float baked_max_ofs = 0.0; + mutable Vector<real_t> baked_dist_cache; + mutable real_t baked_max_ofs = 0.0; void _bake() const; - float bake_interval = 0.2; + real_t bake_interval = 0.2; bool up_vector_enabled = true; - void _bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, float p_tol) const; + void _bake_segment3d(Map<real_t, Vector3> &r_bake, real_t p_begin, real_t p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, real_t p_tol) const; Dictionary _get_data() const; void _set_data(const Dictionary &p_data); @@ -242,11 +242,11 @@ protected: public: int get_point_count() const; - void add_point(const Vector3 &p_pos, const Vector3 &p_in = Vector3(), const Vector3 &p_out = Vector3(), int p_atpos = -1); - void set_point_position(int p_index, const Vector3 &p_pos); + void add_point(const Vector3 &p_position, const Vector3 &p_in = Vector3(), const Vector3 &p_out = Vector3(), int p_atpos = -1); + void set_point_position(int p_index, const Vector3 &p_position); Vector3 get_point_position(int p_index) const; - void set_point_tilt(int p_index, float p_tilt); - float get_point_tilt(int p_index) const; + void set_point_tilt(int p_index, real_t p_tilt); + real_t get_point_tilt(int p_index) const; void set_point_in(int p_index, const Vector3 &p_in); Vector3 get_point_in(int p_index) const; void set_point_out(int p_index, const Vector3 &p_out); @@ -254,25 +254,25 @@ public: void remove_point(int p_index); void clear_points(); - Vector3 interpolate(int p_index, float p_offset) const; + Vector3 interpolate(int p_index, real_t p_offset) const; Vector3 interpolatef(real_t p_findex) const; - void set_bake_interval(float p_tolerance); - float get_bake_interval() const; + void set_bake_interval(real_t p_tolerance); + real_t get_bake_interval() const; void set_up_vector_enabled(bool p_enable); bool is_up_vector_enabled() const; - float get_baked_length() const; - Vector3 interpolate_baked(float p_offset, bool p_cubic = false) const; - float interpolate_baked_tilt(float p_offset) const; - Vector3 interpolate_baked_up_vector(float p_offset, bool p_apply_tilt = false) const; + real_t get_baked_length() const; + Vector3 interpolate_baked(real_t p_offset, bool p_cubic = false) const; + real_t interpolate_baked_tilt(real_t p_offset) const; + Vector3 interpolate_baked_up_vector(real_t p_offset, bool p_apply_tilt = false) const; PackedVector3Array get_baked_points() const; //useful for going through Vector<real_t> get_baked_tilts() const; //useful for going through PackedVector3Array get_baked_up_vectors() const; Vector3 get_closest_point(const Vector3 &p_to_point) const; - float get_closest_offset(const Vector3 &p_to_point) const; + real_t get_closest_offset(const Vector3 &p_to_point) const; - PackedVector3Array tessellate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display + PackedVector3Array tessellate(int p_max_stages = 5, real_t p_tolerance = 4) const; //useful for display Curve3D(); }; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 6cd42e1456..d88a2c557b 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -752,7 +752,7 @@ void FontData::remove_cache(int p_cache_index) { if (cache[p_cache_index].is_valid()) { TS->free(cache.write[p_cache_index]); } - cache.remove(p_cache_index); + cache.remove_at(p_cache_index); emit_changed(); } @@ -1356,8 +1356,8 @@ void Font::remove_data(int p_idx) { data.write[p_idx]->disconnect(SNAME("changed"), callable_mp(this, &Font::_data_changed)); } - data.remove(p_idx); - rids.remove(p_idx); + data.remove_at(p_idx); + rids.remove_at(p_idx); cache.clear(); cache_wrap.clear(); diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp index 4559b4ce0a..95ec141df6 100644 --- a/scene/resources/gradient.cpp +++ b/scene/resources/gradient.cpp @@ -144,7 +144,7 @@ void Gradient::add_point(float p_offset, const Color &p_color) { void Gradient::remove_point(int p_index) { ERR_FAIL_INDEX(p_index, points.size()); ERR_FAIL_COND(points.size() <= 1); - points.remove(p_index); + points.remove_at(p_index); emit_signal(CoreStringNames::get_singleton()->changed); } diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index fe7124de9e..4f9a055bfb 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -144,6 +144,7 @@ void ImmediateMesh::surface_add_vertex_2d(const Vector2 &p_vertex) { active_surface_data.vertex_2d = true; } + void ImmediateMesh::surface_end() { ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it."); ERR_FAIL_COND_MSG(!vertices.size(), "No vertices were added, surface can't be created."); @@ -185,7 +186,7 @@ void ImmediateMesh::surface_end() { vtx[2] = vertices[i].z; } if (i == 0) { - aabb.position = vertices[i]; + aabb = AABB(vertices[i], SMALL_VEC3); // Must have a bit of size. } else { aabb.expand_to(vertices[i]); } diff --git a/scene/resources/immediate_mesh.h b/scene/resources/immediate_mesh.h index 6673ee6f3d..92bf91441d 100644 --- a/scene/resources/immediate_mesh.h +++ b/scene/resources/immediate_mesh.h @@ -75,6 +75,8 @@ class ImmediateMesh : public Mesh { Vector<uint8_t> surface_vertex_create_cache; Vector<uint8_t> surface_attribute_create_cache; + const Vector3 SMALL_VEC3 = Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON); + protected: static void _bind_methods(); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 8399b14a56..98bda4ad1b 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1658,13 +1658,28 @@ bool BaseMaterial3D::get_feature(Feature p_feature) const { void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture) { ERR_FAIL_INDEX(p_param, TEXTURE_MAX); + + if (get_texture(TEXTURE_ROUGHNESS).is_null() && p_texture.is_valid() && p_param == TEXTURE_ROUGHNESS) { + // If no roughness texture is currently set, automatically set the recommended value + // for roughness when using a roughness map. + set_roughness(1.0); + } + + if (get_texture(TEXTURE_METALLIC).is_null() && p_texture.is_valid() && p_param == TEXTURE_METALLIC) { + // If no metallic texture is currently set, automatically set the recommended value + // for metallic when using a metallic map. + set_metallic(1.0); + } + textures[p_param] = p_texture; RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID(); RS::get_singleton()->material_set_param(_get_material(), shader_names->texture_names[p_param], rid); + if (p_texture.is_valid() && p_param == TEXTURE_ALBEDO) { RS::get_singleton()->material_set_param(_get_material(), shader_names->albedo_texture_size, Vector2i(p_texture->get_width(), p_texture->get_height())); } + notify_property_list_changed(); _queue_shader_change(); } @@ -2884,7 +2899,7 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value) idx++; } - print_line("remapped parameter not found: " + String(p_name)); + WARN_PRINT("Godot 3.x SpatialMaterial remapped parameter not found: " + String(p_name)); return true; } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 51b4e1fbd8..e14d6be235 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -994,9 +994,9 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { } //clear unused flags - print_line("format pre: " + itos(old_format)); + print_verbose("Mesh format pre-conversion: " + itos(old_format)); - print_line("format post: " + itos(new_format)); + print_verbose("Mesh format post-conversion: " + itos(new_format)); ERR_FAIL_COND_V(!d.has("aabb"), false); AABB aabb = d["aabb"]; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 3f4765d20f..c39f59d535 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -62,7 +62,7 @@ static Array _sanitize_node_pinned_properties(Node *p_node) { if (storable_properties.has(pinned[i])) { i++; } else { - pinned.remove(i); + pinned.remove_at(i); } } while (i < pinned.size()); if (pinned.is_empty()) { diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index e77f5a0be7..5ceb90d511 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -584,7 +584,7 @@ void ParticlesMaterial::_update_shader() { code += " float base_angle = (tex_angle) * mix(initial_angle_min, initial_angle_max, rand_from_seed(alt_seed));\n"; code += " base_angle += CUSTOM.y * LIFETIME * (tex_angular_velocity) * mix(angular_velocity_min,angular_velocity_max, rand_from_seed(alt_seed));\n"; code += " CUSTOM.x = base_angle * degree_to_rad;\n"; // angle - code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + CUSTOM.y * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));\n"; // angle + code += " CUSTOM.z = (tex_anim_offset) * mix(anim_offset_min, anim_offset_max, rand_from_seed(alt_seed)) + tv * tex_anim_speed * mix(anim_speed_min, anim_speed_max, rand_from_seed(alt_seed));\n"; // angle // apply color // apply hue rotation diff --git a/scene/resources/skeleton_modification_stack_2d.cpp b/scene/resources/skeleton_modification_stack_2d.cpp index 25c3e9d2ef..e596390f78 100644 --- a/scene/resources/skeleton_modification_stack_2d.cpp +++ b/scene/resources/skeleton_modification_stack_2d.cpp @@ -172,7 +172,7 @@ void SkeletonModificationStack2D::add_modification(Ref<SkeletonModification2D> p void SkeletonModificationStack2D::delete_modification(int p_mod_idx) { ERR_FAIL_INDEX(p_mod_idx, modifications.size()); - modifications.remove(p_mod_idx); + modifications.remove_at(p_mod_idx); #ifdef TOOLS_ENABLED set_editor_gizmos_dirty(true); diff --git a/scene/resources/skeleton_modification_stack_3d.cpp b/scene/resources/skeleton_modification_stack_3d.cpp index 301811f0b6..e5b7771251 100644 --- a/scene/resources/skeleton_modification_stack_3d.cpp +++ b/scene/resources/skeleton_modification_stack_3d.cpp @@ -133,7 +133,7 @@ void SkeletonModificationStack3D::add_modification(Ref<SkeletonModification3D> p void SkeletonModificationStack3D::delete_modification(int p_mod_idx) { const int modifications_size = modifications.size(); ERR_FAIL_INDEX(p_mod_idx, modifications_size); - modifications.remove(p_mod_idx); + modifications.remove_at(p_mod_idx); } void SkeletonModificationStack3D::set_modification(int p_mod_idx, Ref<SkeletonModification3D> p_mod) { @@ -141,7 +141,7 @@ void SkeletonModificationStack3D::set_modification(int p_mod_idx, Ref<SkeletonMo ERR_FAIL_INDEX(p_mod_idx, modifications_size); if (p_mod == nullptr) { - modifications.remove(p_mod_idx); + modifications.remove_at(p_mod_idx); } else { p_mod->_setup_modification(this); modifications[p_mod_idx] = p_mod; diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp index 5524d59dc7..71ed96cf15 100644 --- a/scene/resources/sprite_frames.cpp +++ b/scene/resources/sprite_frames.cpp @@ -56,7 +56,7 @@ void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) { Map<StringName, Anim>::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); - E->get().frames.remove(p_idx); + E->get().frames.remove_at(p_idx); emit_changed(); } diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp index 52a3abf74d..cfb5ac2ca6 100644 --- a/scene/resources/syntax_highlighter.cpp +++ b/scene/resources/syntax_highlighter.cpp @@ -501,7 +501,7 @@ void CodeHighlighter::add_color_region(const String &p_start_key, const String & void CodeHighlighter::remove_color_region(const String &p_start_key) { for (int i = 0; i < color_regions.size(); i++) { if (color_regions[i].start_key == p_start_key) { - color_regions.remove(i); + color_regions.remove_at(i); break; } } diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 8c92445338..34fe7c0b87 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -560,7 +560,7 @@ void TileSet::move_occlusion_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, occlusion_layers.size()); ERR_FAIL_INDEX(p_to_pos, occlusion_layers.size() + 1); occlusion_layers.insert(p_to_pos, occlusion_layers[p_from_index]); - occlusion_layers.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + occlusion_layers.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->move_occlusion_layer(p_from_index, p_to_pos); } @@ -570,7 +570,7 @@ void TileSet::move_occlusion_layer(int p_from_index, int p_to_pos) { void TileSet::remove_occlusion_layer(int p_index) { ERR_FAIL_INDEX(p_index, occlusion_layers.size()); - occlusion_layers.remove(p_index); + occlusion_layers.remove_at(p_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->remove_occlusion_layer(p_index); } @@ -623,7 +623,7 @@ void TileSet::move_physics_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, physics_layers.size()); ERR_FAIL_INDEX(p_to_pos, physics_layers.size() + 1); physics_layers.insert(p_to_pos, physics_layers[p_from_index]); - physics_layers.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + physics_layers.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->move_physics_layer(p_from_index, p_to_pos); } @@ -633,7 +633,7 @@ void TileSet::move_physics_layer(int p_from_index, int p_to_pos) { void TileSet::remove_physics_layer(int p_index) { ERR_FAIL_INDEX(p_index, physics_layers.size()); - physics_layers.remove(p_index); + physics_layers.remove_at(p_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->remove_physics_layer(p_index); } @@ -698,7 +698,7 @@ void TileSet::move_terrain_set(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, terrain_sets.size()); ERR_FAIL_INDEX(p_to_pos, terrain_sets.size() + 1); terrain_sets.insert(p_to_pos, terrain_sets[p_from_index]); - terrain_sets.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + terrain_sets.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->move_terrain_set(p_from_index, p_to_pos); } @@ -709,7 +709,7 @@ void TileSet::move_terrain_set(int p_from_index, int p_to_pos) { void TileSet::remove_terrain_set(int p_index) { ERR_FAIL_INDEX(p_index, terrain_sets.size()); - terrain_sets.remove(p_index); + terrain_sets.remove_at(p_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->remove_terrain_set(p_index); } @@ -772,7 +772,7 @@ void TileSet::move_terrain(int p_terrain_set, int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, terrains.size()); ERR_FAIL_INDEX(p_to_pos, terrains.size() + 1); terrains.insert(p_to_pos, terrains[p_from_index]); - terrains.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + terrains.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->move_terrain(p_terrain_set, p_from_index, p_to_pos); } @@ -786,7 +786,7 @@ void TileSet::remove_terrain(int p_terrain_set, int p_index) { Vector<Terrain> &terrains = terrain_sets.write[p_terrain_set].terrains; ERR_FAIL_INDEX(p_index, terrains.size()); - terrains.remove(p_index); + terrains.remove_at(p_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->remove_terrain(p_terrain_set, p_index); } @@ -941,7 +941,7 @@ void TileSet::move_navigation_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, navigation_layers.size()); ERR_FAIL_INDEX(p_to_pos, navigation_layers.size() + 1); navigation_layers.insert(p_to_pos, navigation_layers[p_from_index]); - navigation_layers.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + navigation_layers.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->move_navigation_layer(p_from_index, p_to_pos); } @@ -951,7 +951,7 @@ void TileSet::move_navigation_layer(int p_from_index, int p_to_pos) { void TileSet::remove_navigation_layer(int p_index) { ERR_FAIL_INDEX(p_index, navigation_layers.size()); - navigation_layers.remove(p_index); + navigation_layers.remove_at(p_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->remove_navigation_layer(p_index); } @@ -994,7 +994,7 @@ void TileSet::move_custom_data_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, custom_data_layers.size()); ERR_FAIL_INDEX(p_to_pos, custom_data_layers.size() + 1); custom_data_layers.insert(p_to_pos, custom_data_layers[p_from_index]); - custom_data_layers.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + custom_data_layers.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); for (KeyValue<int, Ref<TileSetSource>> source : sources) { source.value->move_custom_data_layer(p_from_index, p_to_pos); } @@ -1004,7 +1004,7 @@ void TileSet::move_custom_data_layer(int p_from_index, int p_to_pos) { void TileSet::remove_custom_data_layer(int p_index) { ERR_FAIL_INDEX(p_index, custom_data_layers.size()); - custom_data_layers.remove(p_index); + custom_data_layers.remove_at(p_index); for (KeyValue<String, int> E : custom_data_layers_by_name) { if (E.value == p_index) { custom_data_layers_by_name.erase(E.key); @@ -1340,7 +1340,7 @@ Ref<TileMapPattern> TileSet::get_pattern(int p_index) { void TileSet::remove_pattern(int p_index) { ERR_FAIL_INDEX(p_index, (int)patterns.size()); - patterns.remove(p_index); + patterns.remove_at(p_index); emit_changed(); } @@ -4707,12 +4707,12 @@ void TileData::move_occlusion_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, occluders.size()); ERR_FAIL_INDEX(p_to_pos, occluders.size() + 1); occluders.insert(p_to_pos, occluders[p_from_index]); - occluders.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + occluders.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); } void TileData::remove_occlusion_layer(int p_index) { ERR_FAIL_INDEX(p_index, occluders.size()); - occluders.remove(p_index); + occluders.remove_at(p_index); } void TileData::add_physics_layer(int p_to_pos) { @@ -4727,12 +4727,12 @@ void TileData::move_physics_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, physics.size()); ERR_FAIL_INDEX(p_to_pos, physics.size() + 1); physics.insert(p_to_pos, physics[p_from_index]); - physics.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + physics.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); } void TileData::remove_physics_layer(int p_index) { ERR_FAIL_INDEX(p_index, physics.size()); - physics.remove(p_index); + physics.remove_at(p_index); } void TileData::add_terrain_set(int p_to_pos) { @@ -4816,12 +4816,12 @@ void TileData::move_navigation_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, navigation.size()); ERR_FAIL_INDEX(p_to_pos, navigation.size() + 1); navigation.insert(p_to_pos, navigation[p_from_index]); - navigation.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + navigation.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); } void TileData::remove_navigation_layer(int p_index) { ERR_FAIL_INDEX(p_index, navigation.size()); - navigation.remove(p_index); + navigation.remove_at(p_index); } void TileData::add_custom_data_layer(int p_to_pos) { @@ -4836,12 +4836,12 @@ void TileData::move_custom_data_layer(int p_from_index, int p_to_pos) { ERR_FAIL_INDEX(p_from_index, custom_data.size()); ERR_FAIL_INDEX(p_to_pos, custom_data.size() + 1); custom_data.insert(p_to_pos, navigation[p_from_index]); - custom_data.remove(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); + custom_data.remove_at(p_to_pos < p_from_index ? p_from_index + 1 : p_from_index); } void TileData::remove_custom_data_layer(int p_index) { ERR_FAIL_INDEX(p_index, custom_data.size()); - custom_data.remove(p_index); + custom_data.remove_at(p_index); } void TileData::reset_state() { @@ -5019,7 +5019,7 @@ void TileData::add_collision_polygon(int p_layer_id) { void TileData::remove_collision_polygon(int p_layer_id, int p_polygon_index) { ERR_FAIL_INDEX(p_layer_id, physics.size()); ERR_FAIL_INDEX(p_polygon_index, physics[p_layer_id].polygons.size()); - physics.write[p_layer_id].polygons.remove(p_polygon_index); + physics.write[p_layer_id].polygons.remove_at(p_polygon_index); emit_signal(SNAME("changed")); } diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 87ff225de9..41e78e0bc8 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -367,7 +367,7 @@ String VisualShaderNodeCustom::generate_code(Shader::Mode p_mode, VisualShader:: if (!nend) { code += "\n }"; } else { - code.remove(code.size() - 1); + code.remove_at(code.size() - 1); code += "}"; } code += "\n"; diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 951870fe34..e6870971d4 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -1647,6 +1647,21 @@ String VisualShaderNodeIntOp::generate_code(Shader::Mode p_mode, VisualShader::T case OP_MIN: code += "min(" + p_input_vars[0] + ", " + p_input_vars[1] + ");\n"; break; + case OP_BITWISE_AND: + code += p_input_vars[0] + " & " + p_input_vars[1] + ";\n"; + break; + case OP_BITWISE_OR: + code += p_input_vars[0] + " | " + p_input_vars[1] + ";\n"; + break; + case OP_BITWISE_XOR: + code += p_input_vars[0] + " ^ " + p_input_vars[1] + ";\n"; + break; + case OP_BITWISE_LEFT_SHIFT: + code += p_input_vars[0] + " << " + p_input_vars[1] + ";\n"; + break; + case OP_BITWISE_RIGHT_SHIFT: + code += p_input_vars[0] + " >> " + p_input_vars[1] + ";\n"; + break; default: break; } @@ -1677,7 +1692,7 @@ void VisualShaderNodeIntOp::_bind_methods() { ClassDB::bind_method(D_METHOD("set_operator", "op"), &VisualShaderNodeIntOp::set_operator); ClassDB::bind_method(D_METHOD("get_operator"), &VisualShaderNodeIntOp::get_operator); - ADD_PROPERTY(PropertyInfo(Variant::INT, "operator", PROPERTY_HINT_ENUM, "Add,Subtract,Multiply,Divide,Remainder,Max,Min"), "set_operator", "get_operator"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "operator", PROPERTY_HINT_ENUM, "Add,Subtract,Multiply,Divide,Remainder,Max,Min,Bitwise AND,Bitwise OR,Bitwise XOR,Bitwise Left Shift,Bitwise Right Shift"), "set_operator", "get_operator"); BIND_ENUM_CONSTANT(OP_ADD); BIND_ENUM_CONSTANT(OP_SUB); @@ -1686,6 +1701,11 @@ void VisualShaderNodeIntOp::_bind_methods() { BIND_ENUM_CONSTANT(OP_MOD); BIND_ENUM_CONSTANT(OP_MAX); BIND_ENUM_CONSTANT(OP_MIN); + BIND_ENUM_CONSTANT(OP_BITWISE_AND); + BIND_ENUM_CONSTANT(OP_BITWISE_OR); + BIND_ENUM_CONSTANT(OP_BITWISE_XOR); + BIND_ENUM_CONSTANT(OP_BITWISE_LEFT_SHIFT); + BIND_ENUM_CONSTANT(OP_BITWISE_RIGHT_SHIFT); BIND_ENUM_CONSTANT(OP_ENUM_SIZE); } @@ -2333,7 +2353,8 @@ String VisualShaderNodeIntFunc::generate_code(Shader::Mode p_mode, VisualShader: static const char *functions[FUNC_MAX] = { "abs($)", "-($)", - "sign($)" + "sign($)", + "~($)" }; return " " + p_output_vars[0] + " = " + String(functions[func]).replace("$", p_input_vars[0]) + ";\n"; @@ -2362,11 +2383,12 @@ void VisualShaderNodeIntFunc::_bind_methods() { ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeIntFunc::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeIntFunc::get_function); - ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "Abs,Negate,Sign"), "set_function", "get_function"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "Abs,Negate,Sign,Bitwise NOT"), "set_function", "get_function"); BIND_ENUM_CONSTANT(FUNC_ABS); BIND_ENUM_CONSTANT(FUNC_NEGATE); BIND_ENUM_CONSTANT(FUNC_SIGN); + BIND_ENUM_CONSTANT(FUNC_BITWISE_NOT); BIND_ENUM_CONSTANT(FUNC_MAX); } diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 2c952300fe..2f3400404c 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -579,6 +579,11 @@ public: OP_MOD, OP_MAX, OP_MIN, + OP_BITWISE_AND, + OP_BITWISE_OR, + OP_BITWISE_XOR, + OP_BITWISE_LEFT_SHIFT, + OP_BITWISE_RIGHT_SHIFT, OP_ENUM_SIZE, }; @@ -882,6 +887,7 @@ public: FUNC_ABS, FUNC_NEGATE, FUNC_SIGN, + FUNC_BITWISE_NOT, FUNC_MAX, }; diff --git a/scene/resources/visual_shader_particle_nodes.cpp b/scene/resources/visual_shader_particle_nodes.cpp index 1a829968e3..a7c20b2cb9 100644 --- a/scene/resources/visual_shader_particle_nodes.cpp +++ b/scene/resources/visual_shader_particle_nodes.cpp @@ -318,26 +318,24 @@ String VisualShaderNodeParticleMeshEmitter::get_input_port_name(int p_port) cons String VisualShaderNodeParticleMeshEmitter::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const { String code; - if (mesh.is_valid()) { - if (is_output_port_connected(0)) { // position - code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_vx") + ";\n"; - } + if (is_output_port_connected(0)) { // position + code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_vx") + ";\n"; + } - if (is_output_port_connected(1)) { // normal - code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_nm") + ";\n"; - } + if (is_output_port_connected(1)) { // normal + code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_nm") + ";\n"; + } - if (is_output_port_connected(2) || is_output_port_connected(3)) { // color & alpha - code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_col") + ";\n"; - } + if (is_output_port_connected(2) || is_output_port_connected(3)) { // color & alpha + code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_col") + ";\n"; + } - if (is_output_port_connected(4)) { // uv - code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_uv") + ";\n"; - } + if (is_output_port_connected(4)) { // uv + code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_uv") + ";\n"; + } - if (is_output_port_connected(5)) { // uv2 - code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_uv2") + ";\n"; - } + if (is_output_port_connected(5)) { // uv2 + code += "uniform sampler2D " + make_unique_id(p_type, p_id, "mesh_uv2") + ";\n"; } return code; @@ -503,67 +501,97 @@ void VisualShaderNodeParticleMeshEmitter::_update_textures() { Vector<Vector2> uvs; Vector<Vector2> uvs2; + const int surface_count = mesh->get_surface_count(); + if (use_all_surfaces) { - for (int i = 0; i < max_surface_index; i++) { + for (int i = 0; i < surface_count; i++) { + const Array surface_arrays = mesh->surface_get_arrays(i); + const int surface_arrays_size = surface_arrays.size(); + // position - Array vertex_array = mesh->surface_get_arrays(i)[Mesh::ARRAY_VERTEX]; - for (int j = 0; j < vertex_array.size(); j++) { - vertices.push_back((Vector3)vertex_array[j]); + if (surface_arrays_size > Mesh::ARRAY_VERTEX) { + Array vertex_array = surface_arrays[Mesh::ARRAY_VERTEX]; + for (int j = 0; j < vertex_array.size(); j++) { + vertices.push_back((Vector3)vertex_array[j]); + } } // normal - Array normal_array = mesh->surface_get_arrays(i)[Mesh::ARRAY_NORMAL]; - for (int j = 0; j < normal_array.size(); j++) { - normals.push_back((Vector3)normal_array[j]); + if (surface_arrays_size > Mesh::ARRAY_NORMAL) { + Array normal_array = surface_arrays[Mesh::ARRAY_NORMAL]; + for (int j = 0; j < normal_array.size(); j++) { + normals.push_back((Vector3)normal_array[j]); + } } // color - Array color_array = mesh->surface_get_arrays(i)[Mesh::ARRAY_COLOR]; - for (int j = 0; j < color_array.size(); j++) { - colors.push_back((Color)color_array[j]); + if (surface_arrays_size > Mesh::ARRAY_COLOR) { + Array color_array = surface_arrays[Mesh::ARRAY_COLOR]; + for (int j = 0; j < color_array.size(); j++) { + colors.push_back((Color)color_array[j]); + } } // uv - Array uv_array = mesh->surface_get_arrays(i)[Mesh::ARRAY_TEX_UV]; - for (int j = 0; j < uv_array.size(); j++) { - uvs.push_back((Vector2)uv_array[j]); + if (surface_arrays_size > Mesh::ARRAY_TEX_UV) { + Array uv_array = surface_arrays[Mesh::ARRAY_TEX_UV]; + for (int j = 0; j < uv_array.size(); j++) { + uvs.push_back((Vector2)uv_array[j]); + } } // uv2 - Array uv2_array = mesh->surface_get_arrays(i)[Mesh::ARRAY_TEX_UV2]; - for (int j = 0; j < uv2_array.size(); j++) { - uvs2.push_back((Vector2)uv2_array[j]); + if (surface_arrays_size > Mesh::ARRAY_TEX_UV2) { + Array uv2_array = surface_arrays[Mesh::ARRAY_TEX_UV2]; + for (int j = 0; j < uv2_array.size(); j++) { + uvs2.push_back((Vector2)uv2_array[j]); + } } } } else { - // position - Array vertex_array = mesh->surface_get_arrays(surface_index)[Mesh::ARRAY_VERTEX]; - for (int i = 0; i < vertex_array.size(); i++) { - vertices.push_back((Vector3)vertex_array[i]); - } + if (surface_index >= 0 && surface_index < surface_count) { + const Array surface_arrays = mesh->surface_get_arrays(surface_index); + const int surface_arrays_size = surface_arrays.size(); - // normal - Array normal_array = mesh->surface_get_arrays(surface_index)[Mesh::ARRAY_NORMAL]; - for (int i = 0; i < normal_array.size(); i++) { - normals.push_back((Vector3)normal_array[i]); - } + // position + if (surface_arrays_size > Mesh::ARRAY_VERTEX) { + Array vertex_array = surface_arrays[Mesh::ARRAY_VERTEX]; + for (int i = 0; i < vertex_array.size(); i++) { + vertices.push_back((Vector3)vertex_array[i]); + } + } - // color - Array color_array = mesh->surface_get_arrays(surface_index)[Mesh::ARRAY_COLOR]; - for (int i = 0; i < color_array.size(); i++) { - colors.push_back((Color)color_array[i]); - } + // normal + if (surface_arrays_size > Mesh::ARRAY_NORMAL) { + Array normal_array = surface_arrays[Mesh::ARRAY_NORMAL]; + for (int i = 0; i < normal_array.size(); i++) { + normals.push_back((Vector3)normal_array[i]); + } + } - // uv - Array uv_array = mesh->surface_get_arrays(surface_index)[Mesh::ARRAY_TEX_UV]; - for (int j = 0; j < uv_array.size(); j++) { - uvs.push_back((Vector2)uv_array[j]); - } + // color + if (surface_arrays_size > Mesh::ARRAY_COLOR) { + Array color_array = surface_arrays[Mesh::ARRAY_COLOR]; + for (int i = 0; i < color_array.size(); i++) { + colors.push_back((Color)color_array[i]); + } + } + + // uv + if (surface_arrays_size > Mesh::ARRAY_TEX_UV) { + Array uv_array = surface_arrays[Mesh::ARRAY_TEX_UV]; + for (int j = 0; j < uv_array.size(); j++) { + uvs.push_back((Vector2)uv_array[j]); + } + } - // uv2 - Array uv2_array = mesh->surface_get_arrays(surface_index)[Mesh::ARRAY_TEX_UV2]; - for (int j = 0; j < uv2_array.size(); j++) { - uvs2.push_back((Vector2)uv2_array[j]); + // uv2 + if (surface_arrays_size > Mesh::ARRAY_TEX_UV2) { + Array uv2_array = surface_arrays[Mesh::ARRAY_TEX_UV2]; + for (int j = 0; j < uv2_array.size(); j++) { + uvs2.push_back((Vector2)uv2_array[j]); + } + } } } @@ -579,12 +607,6 @@ void VisualShaderNodeParticleMeshEmitter::set_mesh(Ref<Mesh> p_mesh) { return; } - if (p_mesh.is_valid()) { - max_surface_index = p_mesh->get_surface_count(); - } else { - max_surface_index = 0; - } - if (mesh.is_valid()) { Callable callable = callable_mp(this, &VisualShaderNodeParticleMeshEmitter::_update_textures); @@ -623,7 +645,16 @@ bool VisualShaderNodeParticleMeshEmitter::is_use_all_surfaces() const { } void VisualShaderNodeParticleMeshEmitter::set_surface_index(int p_surface_index) { - if (p_surface_index == surface_index || p_surface_index < 0 || p_surface_index >= max_surface_index) { + if (mesh.is_valid()) { + if (mesh->get_surface_count() > 0) { + p_surface_index = CLAMP(p_surface_index, 0, mesh->get_surface_count() - 1); + } else { + p_surface_index = 0; + } + } else if (p_surface_index < 0) { + p_surface_index = 0; + } + if (surface_index == p_surface_index) { return; } surface_index = p_surface_index; diff --git a/scene/resources/visual_shader_particle_nodes.h b/scene/resources/visual_shader_particle_nodes.h index 79459432f1..ae7ea69225 100644 --- a/scene/resources/visual_shader_particle_nodes.h +++ b/scene/resources/visual_shader_particle_nodes.h @@ -111,7 +111,6 @@ class VisualShaderNodeParticleMeshEmitter : public VisualShaderNodeParticleEmitt Ref<Mesh> mesh; bool use_all_surfaces = true; int surface_index = 0; - int max_surface_index = 0; Ref<ImageTexture> position_texture; Ref<ImageTexture> normal_texture; diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 186764e69e..a5ed27cb7b 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -61,6 +61,7 @@ SceneStringNames::SceneStringNames() { animation_finished = StaticCString::create("animation_finished"); animation_changed = StaticCString::create("animation_changed"); animation_started = StaticCString::create("animation_started"); + RESET = StaticCString::create("RESET"); pose_updated = StaticCString::create("pose_updated"); bone_pose_changed = StaticCString::create("bone_pose_changed"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 67007c85e0..b1ace1748c 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -97,6 +97,7 @@ public: StringName animation_finished; StringName animation_changed; StringName animation_started; + StringName RESET; StringName pose_updated; StringName bone_pose_changed; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 774a5b1da0..f7c8f0921c 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -762,7 +762,7 @@ void AudioServer::remove_bus(int p_index) { lock(); bus_map.erase(buses[p_index]->name); memdelete(buses[p_index]); - buses.remove(p_index); + buses.remove_at(p_index); unlock(); emit_signal(SNAME("bus_layout_changed")); @@ -833,7 +833,7 @@ void AudioServer::move_bus(int p_bus, int p_to_pos) { } Bus *bus = buses[p_bus]; - buses.remove(p_bus); + buses.remove_at(p_bus); if (p_to_pos == -1) { buses.push_back(bus); @@ -1026,7 +1026,7 @@ void AudioServer::remove_bus_effect(int p_bus, int p_effect) { lock(); - buses[p_bus]->effects.remove(p_effect); + buses[p_bus]->effects.remove_at(p_effect); _update_bus_effects(p_bus); unlock(); diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index 6f506d0f7a..8391a2ee2e 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -124,7 +124,7 @@ void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { #endif // remove it from our array, if this results in our feed being unreferenced it will be destroyed - feeds.remove(i); + feeds.remove_at(i); // let whomever is interested know emit_signal(SNAME("camera_feed_removed"), feed_id); diff --git a/servers/display_server_headless.h b/servers/display_server_headless.h index d9ee91084f..0837e41db8 100644 --- a/servers/display_server_headless.h +++ b/servers/display_server_headless.h @@ -65,7 +65,11 @@ public: Vector<DisplayServer::WindowID> get_window_list() const override { return Vector<DisplayServer::WindowID>(); } - WindowID get_window_at_screen_position(const Point2i &p_position) const override { return -1; } + WindowID create_sub_window(WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Rect2i &p_rect = Rect2i()) override { return 0; } + void show_window(WindowID p_id) override {} + void delete_sub_window(WindowID p_id) override {} + + WindowID get_window_at_screen_position(const Point2i &p_position) const override { return 0; } void window_attach_instance_id(ObjectID p_instance, WindowID p_window = MAIN_WINDOW_ID) override {} ObjectID window_get_attached_instance_id(WindowID p_window = MAIN_WINDOW_ID) const override { return ObjectID(); } @@ -93,7 +97,7 @@ public: Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override { return Size2i(); } void window_set_min_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override {} - Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override { return Size2i(); }; + Size2i window_get_min_size(WindowID p_window = MAIN_WINDOW_ID) const override { return Size2i(); } void window_set_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override {} Size2i window_get_size(WindowID p_window = MAIN_WINDOW_ID) const override { return Size2i(); } @@ -102,10 +106,13 @@ public: void window_set_mode(WindowMode p_mode, WindowID p_window = MAIN_WINDOW_ID) override {} WindowMode window_get_mode(WindowID p_window = MAIN_WINDOW_ID) const override { return WINDOW_MODE_MINIMIZED; } + void window_set_vsync_mode(VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override {} + VSyncMode window_get_vsync_mode(WindowID p_window) const override { return VSyncMode::VSYNC_ENABLED; } + bool window_is_maximize_allowed(WindowID p_window = MAIN_WINDOW_ID) const override { return false; } void window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window = MAIN_WINDOW_ID) override {} - virtual bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override { return false; } + bool window_get_flag(WindowFlags p_flag, WindowID p_window = MAIN_WINDOW_ID) const override { return false; } void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override {} void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override {} @@ -114,6 +121,9 @@ public: bool can_any_window_draw() const override { return false; } + void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID) override {} + void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID) override {} + void process_events() override {} void set_icon(const Ref<Image> &p_icon) override {} diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp index 6d1c5539aa..44da5d4f3b 100644 --- a/servers/physics_2d/godot_body_2d.cpp +++ b/servers/physics_2d/godot_body_2d.cpp @@ -549,6 +549,9 @@ void GodotBody2D::integrate_forces(real_t p_step) { gravity *= gravity_scale; + prev_linear_velocity = linear_velocity; + prev_angular_velocity = angular_velocity; + Vector2 motion; bool do_motion = false; diff --git a/servers/physics_2d/godot_body_2d.h b/servers/physics_2d/godot_body_2d.h index d1dbf92c1b..ba4c39737a 100644 --- a/servers/physics_2d/godot_body_2d.h +++ b/servers/physics_2d/godot_body_2d.h @@ -50,6 +50,9 @@ class GodotBody2D : public GodotCollisionObject2D { Vector2 linear_velocity; real_t angular_velocity = 0.0; + Vector2 prev_linear_velocity; + real_t prev_angular_velocity = 0.0; + Vector2 constant_linear_velocity; real_t constant_angular_velocity = 0.0; @@ -169,7 +172,7 @@ public: if (index > -1) { areas.write[index].refCount -= 1; if (areas[index].refCount < 1) { - areas.remove(index); + areas.remove_at(index); } } } @@ -209,6 +212,9 @@ public: _FORCE_INLINE_ void set_angular_velocity(real_t p_velocity) { angular_velocity = p_velocity; } _FORCE_INLINE_ real_t get_angular_velocity() const { return angular_velocity; } + _FORCE_INLINE_ Vector2 get_prev_linear_velocity() const { return prev_linear_velocity; } + _FORCE_INLINE_ real_t get_prev_angular_velocity() const { return prev_angular_velocity; } + _FORCE_INLINE_ void set_biased_linear_velocity(const Vector2 &p_velocity) { biased_linear_velocity = p_velocity; } _FORCE_INLINE_ Vector2 get_biased_linear_velocity() const { return biased_linear_velocity; } diff --git a/servers/physics_2d/godot_body_pair_2d.cpp b/servers/physics_2d/godot_body_pair_2d.cpp index 97eeefbfe6..67b0f21456 100644 --- a/servers/physics_2d/godot_body_pair_2d.cpp +++ b/servers/physics_2d/godot_body_pair_2d.cpp @@ -32,7 +32,6 @@ #include "godot_collision_solver_2d.h" #include "godot_space_2d.h" -#define POSITION_CORRECTION #define ACCUMULATE_IMPULSES void GodotBodyPair2D::_add_contact(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_self) { @@ -453,9 +452,9 @@ bool GodotBodyPair2D::pre_solve(real_t p_step) { c.bounce = combine_bounce(A, B); if (c.bounce) { - Vector2 crA(-A->get_angular_velocity() * c.rA.y, A->get_angular_velocity() * c.rA.x); - Vector2 crB(-B->get_angular_velocity() * c.rB.y, B->get_angular_velocity() * c.rB.x); - Vector2 dv = B->get_linear_velocity() + crB - A->get_linear_velocity() - crA; + Vector2 crA(-A->get_prev_angular_velocity() * c.rA.y, A->get_prev_angular_velocity() * c.rA.x); + Vector2 crB(-B->get_prev_angular_velocity() * c.rB.y, B->get_prev_angular_velocity() * c.rB.x); + Vector2 dv = B->get_prev_linear_velocity() + crB - A->get_prev_linear_velocity() - crA; c.bounce = c.bounce * dv.dot(c.normal); } diff --git a/servers/physics_2d/godot_collision_object_2d.cpp b/servers/physics_2d/godot_collision_object_2d.cpp index 3d4ebbedcd..719d9c874a 100644 --- a/servers/physics_2d/godot_collision_object_2d.cpp +++ b/servers/physics_2d/godot_collision_object_2d.cpp @@ -121,7 +121,7 @@ void GodotCollisionObject2D::remove_shape(int p_index) { shapes.write[i].bpid = 0; } shapes[p_index].shape->remove_owner(this); - shapes.remove(p_index); + shapes.remove_at(p_index); if (!pending_shape_update_list.in_list()) { GodotPhysicsServer2D::godot_singleton->pending_shape_update_list.add(&pending_shape_update_list); diff --git a/servers/physics_3d/godot_body_3d.cpp b/servers/physics_3d/godot_body_3d.cpp index 40d946655d..d5098a2a5f 100644 --- a/servers/physics_3d/godot_body_3d.cpp +++ b/servers/physics_3d/godot_body_3d.cpp @@ -604,6 +604,9 @@ void GodotBody3D::integrate_forces(real_t p_step) { gravity *= gravity_scale; + prev_linear_velocity = linear_velocity; + prev_angular_velocity = angular_velocity; + Vector3 motion; bool do_motion = false; diff --git a/servers/physics_3d/godot_body_3d.h b/servers/physics_3d/godot_body_3d.h index ac3131ab44..6ea6d1fcaa 100644 --- a/servers/physics_3d/godot_body_3d.h +++ b/servers/physics_3d/godot_body_3d.h @@ -45,6 +45,9 @@ class GodotBody3D : public GodotCollisionObject3D { Vector3 linear_velocity; Vector3 angular_velocity; + Vector3 prev_linear_velocity; + Vector3 prev_angular_velocity; + Vector3 constant_linear_velocity; Vector3 constant_angular_velocity; @@ -163,7 +166,7 @@ public: if (index > -1) { areas.write[index].refCount -= 1; if (areas[index].refCount < 1) { - areas.remove(index); + areas.remove_at(index); } } } @@ -207,6 +210,9 @@ public: _FORCE_INLINE_ void set_angular_velocity(const Vector3 &p_velocity) { angular_velocity = p_velocity; } _FORCE_INLINE_ Vector3 get_angular_velocity() const { return angular_velocity; } + _FORCE_INLINE_ Vector3 get_prev_linear_velocity() const { return prev_linear_velocity; } + _FORCE_INLINE_ Vector3 get_prev_angular_velocity() const { return prev_angular_velocity; } + _FORCE_INLINE_ const Vector3 &get_biased_linear_velocity() const { return biased_linear_velocity; } _FORCE_INLINE_ const Vector3 &get_biased_angular_velocity() const { return biased_angular_velocity; } diff --git a/servers/physics_3d/godot_body_pair_3d.cpp b/servers/physics_3d/godot_body_pair_3d.cpp index f0002870ae..8a701466ed 100644 --- a/servers/physics_3d/godot_body_pair_3d.cpp +++ b/servers/physics_3d/godot_body_pair_3d.cpp @@ -35,18 +35,6 @@ #include "core/os/os.h" -/* -#define NO_ACCUMULATE_IMPULSES -#define NO_SPLIT_IMPULSES - -#define NO_FRICTION -*/ - -#define NO_TANGENTIALS -/* BODY PAIR */ - -//#define ALLOWED_PENETRATION 0.01 -#define RELAXATION_TIMESTEPS 3 #define MIN_VELOCITY 0.0001 #define MAX_BIAS_ROTATION (Math_PI / 8) @@ -370,10 +358,9 @@ bool GodotBodyPair3D::pre_solve(real_t p_step) { c.bounce = combine_bounce(A, B); if (c.bounce) { - Vector3 crA = A->get_angular_velocity().cross(c.rA); - Vector3 crB = B->get_angular_velocity().cross(c.rB); - Vector3 dv = B->get_linear_velocity() + crB - A->get_linear_velocity() - crA; - //normal impule + Vector3 crA = A->get_prev_angular_velocity().cross(c.rA); + Vector3 crB = B->get_prev_angular_velocity().cross(c.rB); + Vector3 dv = B->get_prev_linear_velocity() + crB - A->get_prev_linear_velocity() - crA; c.bounce = c.bounce * dv.dot(c.normal); } } diff --git a/servers/physics_3d/godot_collision_object_3d.cpp b/servers/physics_3d/godot_collision_object_3d.cpp index deb058b3ac..421291011b 100644 --- a/servers/physics_3d/godot_collision_object_3d.cpp +++ b/servers/physics_3d/godot_collision_object_3d.cpp @@ -118,7 +118,7 @@ void GodotCollisionObject3D::remove_shape(int p_index) { shapes.write[i].bpid = 0; } shapes[p_index].shape->remove_owner(this); - shapes.remove(p_index); + shapes.remove_at(p_index); if (!pending_shape_update_list.in_list()) { GodotPhysicsServer3D::godot_singleton->pending_shape_update_list.add(&pending_shape_update_list); diff --git a/servers/physics_3d/godot_soft_body_3d.cpp b/servers/physics_3d/godot_soft_body_3d.cpp index 231b8686f5..43d4433302 100644 --- a/servers/physics_3d/godot_soft_body_3d.cpp +++ b/servers/physics_3d/godot_soft_body_3d.cpp @@ -374,7 +374,7 @@ void GodotSoftBody3D::unpin_vertex(int p_index) { uint32_t pinned_count = pinned_vertices.size(); for (uint32_t i = 0; i < pinned_count; ++i) { if (p_index == pinned_vertices[i]) { - pinned_vertices.remove(i); + pinned_vertices.remove_at(i); if (!soft_mesh.is_null()) { ERR_FAIL_COND(p_index >= (int)map_visual_to_physics.size()); diff --git a/servers/physics_3d/godot_soft_body_3d.h b/servers/physics_3d/godot_soft_body_3d.h index 5198186b5d..14ddc419cf 100644 --- a/servers/physics_3d/godot_soft_body_3d.h +++ b/servers/physics_3d/godot_soft_body_3d.h @@ -148,7 +148,7 @@ public: if (index > -1) { areas.write[index].refCount -= 1; if (areas[index].refCount < 1) { - areas.remove(index); + areas.remove_at(index); } } } diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 2bff8f5dcb..c76ec5a5b1 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -758,10 +758,9 @@ class PhysicsServer2DManager { name(p_ci.name), create_callback(p_ci.create_callback) {} - ClassInfo &operator=(const ClassInfo &p_ci) { + void operator=(const ClassInfo &p_ci) { name = p_ci.name; create_callback = p_ci.create_callback; - return *this; } }; diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index 89a7eeee96..bd5a3eb4b7 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -965,10 +965,9 @@ class PhysicsServer3DManager { name(p_ci.name), create_callback(p_ci.create_callback) {} - ClassInfo &operator=(const ClassInfo &p_ci) { + void operator=(const ClassInfo &p_ci) { name = p_ci.name; create_callback = p_ci.create_callback; - return *this; } }; diff --git a/servers/rendering/rasterizer_dummy.h b/servers/rendering/rasterizer_dummy.h index cecb009aa0..3451ea2d39 100644 --- a/servers/rendering/rasterizer_dummy.h +++ b/servers/rendering/rasterizer_dummy.h @@ -195,7 +195,7 @@ public: void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) override {} RID render_buffers_create() override { return RID(); } - void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override {} + void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override {} void gi_set_use_half_resolution(bool p_enable) override {} void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) override {} diff --git a/servers/rendering/renderer_canvas_cull.h b/servers/rendering/renderer_canvas_cull.h index a2fdf95c76..bdd61123df 100644 --- a/servers/rendering/renderer_canvas_cull.h +++ b/servers/rendering/renderer_canvas_cull.h @@ -152,7 +152,7 @@ public: void erase_item(Item *p_item) { int idx = find_item(p_item); if (idx >= 0) { - child_items.remove(idx); + child_items.remove_at(idx); } } diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index 1971c3e781..4526354d17 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -67,6 +67,7 @@ private: protected: static RendererCompositor *(*_create_func)(); + bool back_end = false; public: static RendererCompositor *create(); @@ -88,7 +89,7 @@ public: virtual uint64_t get_frame_number() const = 0; virtual double get_frame_delta_time() const = 0; - virtual bool is_low_end() const = 0; + _FORCE_INLINE_ virtual bool is_low_end() const { return back_end; }; virtual bool is_xr_enabled() const; RendererCompositor(); diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.cpp b/servers/rendering/renderer_rd/cluster_builder_rd.cpp index b952ecbff0..4a98cf0831 100644 --- a/servers/rendering/renderer_rd/cluster_builder_rd.cpp +++ b/servers/rendering/renderer_rd/cluster_builder_rd.cpp @@ -460,14 +460,6 @@ void ClusterBuilderRD::bake_cluster() { RD::get_singleton()->draw_list_set_push_constant(draw_list, &push_constant, sizeof(ClusterBuilderSharedDataRD::ClusterRender::PushConstant)); uint32_t instances = 1; -#if 0 - for (uint32_t j = i+1; j < element_count; j++) { - if (elements[i].type!=elements[j].type) { - break; - } - instances++; - } -#endif RD::get_singleton()->draw_list_draw(draw_list, true, instances); i += instances; } diff --git a/servers/rendering/renderer_rd/effects_rd.cpp b/servers/rendering/renderer_rd/effects_rd.cpp index fdd6939a8b..cf943901d4 100644 --- a/servers/rendering/renderer_rd/effects_rd.cpp +++ b/servers/rendering/renderer_rd/effects_rd.cpp @@ -237,6 +237,43 @@ RID EffectsRD::_get_compute_uniform_set_from_image_pair(RID p_texture1, RID p_te return uniform_set; } +void EffectsRD::fsr_upscale(RID p_source_rd_texture, RID p_secondary_texture, RID p_destination_texture, const Size2i &p_internal_size, const Size2i &p_size, float p_fsr_upscale_sharpness) { + memset(&FSR_upscale.push_constant, 0, sizeof(FSRUpscalePushConstant)); + + int dispatch_x = (p_size.x + 15) / 16; + int dispatch_y = (p_size.y + 15) / 16; + + RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); + RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, FSR_upscale.pipeline); + + FSR_upscale.push_constant.resolution_width = p_internal_size.width; + FSR_upscale.push_constant.resolution_height = p_internal_size.height; + FSR_upscale.push_constant.upscaled_width = p_size.width; + FSR_upscale.push_constant.upscaled_height = p_size.height; + FSR_upscale.push_constant.sharpness = p_fsr_upscale_sharpness; + + //FSR Easc + FSR_upscale.push_constant.pass = FSR_UPSCALE_PASS_EASU; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_rd_texture), 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_secondary_texture), 1); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &FSR_upscale.push_constant, sizeof(FSRUpscalePushConstant)); + + RD::get_singleton()->compute_list_dispatch(compute_list, dispatch_x, dispatch_y, 1); + RD::get_singleton()->compute_list_add_barrier(compute_list); + + //FSR Rcas + FSR_upscale.push_constant.pass = FSR_UPSCALE_PASS_RCAS; + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_secondary_texture), 0); + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_destination_texture), 1); + + RD::get_singleton()->compute_list_set_push_constant(compute_list, &FSR_upscale.push_constant, sizeof(FSRUpscalePushConstant)); + + RD::get_singleton()->compute_list_dispatch(compute_list, dispatch_x, dispatch_y, 1); + + RD::get_singleton()->compute_list_end(compute_list); +} + void EffectsRD::copy_to_atlas_fb(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2 &p_uv_rect, RD::DrawListID p_draw_list, bool p_flip_y, bool p_panorama) { memset(©_to_fb.push_constant, 0, sizeof(CopyToFbPushConstant)); @@ -1888,6 +1925,27 @@ void EffectsRD::sort_buffer(RID p_uniform_set, int p_size) { } EffectsRD::EffectsRD(bool p_prefer_raster_effects) { + { + Vector<String> FSR_upscale_modes; + +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + // MoltenVK does not support some of the operations used by the normal mode of FSR. Fallback works just fine though. + FSR_upscale_modes.push_back("\n#define MODE_FSR_UPSCALE_FALLBACK\n"); +#else + // Everyone else can use normal mode when available. + if (RD::get_singleton()->get_device_capabilities()->supports_fsr_half_float) { + FSR_upscale_modes.push_back("\n#define MODE_FSR_UPSCALE_NORMAL\n"); + } else { + FSR_upscale_modes.push_back("\n#define MODE_FSR_UPSCALE_FALLBACK\n"); + } +#endif + + FSR_upscale.shader.initialize(FSR_upscale_modes); + + FSR_upscale.shader_version = FSR_upscale.shader.version_create(); + FSR_upscale.pipeline = RD::get_singleton()->compute_pipeline_create(FSR_upscale.shader.version_get_shader(FSR_upscale.shader_version, 0)); + } + prefer_raster_effects = p_prefer_raster_effects; if (prefer_raster_effects) { @@ -2523,6 +2581,7 @@ EffectsRD::~EffectsRD() { RD::get_singleton()->free(index_buffer); //array gets freed as dependency RD::get_singleton()->free(filter.coefficient_buffer); + FSR_upscale.shader.version_free(FSR_upscale.shader_version); if (prefer_raster_effects) { blur_raster.shader.version_free(blur_raster.shader_version); bokeh.raster_shader.version_free(blur_raster.shader_version); diff --git a/servers/rendering/renderer_rd/effects_rd.h b/servers/rendering/renderer_rd/effects_rd.h index 551e50ed25..6037127e82 100644 --- a/servers/rendering/renderer_rd/effects_rd.h +++ b/servers/rendering/renderer_rd/effects_rd.h @@ -45,6 +45,7 @@ #include "servers/rendering/renderer_rd/shaders/cubemap_filter_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/cubemap_roughness.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/cubemap_roughness_raster.glsl.gen.h" +#include "servers/rendering/renderer_rd/shaders/fsr_upscale.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/luminance_reduce.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/luminance_reduce_raster.glsl.gen.h" #include "servers/rendering/renderer_rd/shaders/resolve.glsl.gen.h" @@ -69,6 +70,28 @@ class EffectsRD { private: bool prefer_raster_effects; + enum FSRUpscalePass { + FSR_UPSCALE_PASS_EASU = 0, + FSR_UPSCALE_PASS_RCAS = 1 + }; + + struct FSRUpscalePushConstant { + float resolution_width; + float resolution_height; + float upscaled_width; + float upscaled_height; + float sharpness; + int pass; + int _unused0, _unused1; + }; + + struct FSRUpscale { + FSRUpscalePushConstant push_constant; + FsrUpscaleShaderRD shader; + RID shader_version; + RID pipeline; + } FSR_upscale; + enum BlurRasterMode { BLUR_MIPMAP, @@ -754,6 +777,7 @@ private: public: bool get_prefer_raster_effects(); + void fsr_upscale(RID p_source_rd_texture, RID p_secondary_texture, RID p_destination_texture, const Size2i &p_internal_size, const Size2i &p_size, float p_fsr_upscale_sharpness); void copy_to_fb_rect(RID p_source_rd_texture, RID p_dest_framebuffer, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_alpha_to_zero = false, bool p_srgb = false, RID p_secondary = RID()); void copy_to_rect(RID p_source_rd_texture, RID p_dest_texture, const Rect2i &p_rect, bool p_flip_y = false, bool p_force_luminance = false, bool p_all_source = false, bool p_8_bit_dst = false, bool p_alpha_to_one = false); void copy_cubemap_to_panorama(RID p_source_cube, RID p_dest_panorama, const Size2i &p_panorama_size, float p_lod, bool p_is_array); diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 6d85c1f4c1..03ce2690bf 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -1954,7 +1954,9 @@ void RenderForwardClustered::_base_uniforms_changed() { } void RenderForwardClustered::_update_render_base_uniform_set() { - if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != storage->lightmap_array_get_version())) { + if (render_base_uniform_set.is_null() || !RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set) || (lightmap_texture_array_version != storage->lightmap_array_get_version()) || base_uniform_set_updated) { + base_uniform_set_updated = false; + if (render_base_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(render_base_uniform_set)) { RD::get_singleton()->free(render_base_uniform_set); } @@ -1969,18 +1971,18 @@ void RenderForwardClustered::_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(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); + ids_ptr[0] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[1] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[2] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[3] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[4] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[5] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + ids_ptr[6] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[7] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[8] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[9] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[10] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); + ids_ptr[11] = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); uniforms.push_back(u); } @@ -1999,19 +2001,19 @@ void RenderForwardClustered::_update_render_base_uniform_set() { RID sampler; switch (decals_get_filter()) { case RS::DECAL_FILTER_NEAREST: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::DECAL_FILTER_NEAREST_MIPMAPS: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::DECAL_FILTER_LINEAR: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::DECAL_FILTER_LINEAR_MIPMAPS: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::DECAL_FILTER_LINEAR_MIPMAPS_ANISOTROPIC: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; } @@ -2026,19 +2028,19 @@ void RenderForwardClustered::_update_render_base_uniform_set() { RID sampler; switch (light_projectors_get_filter()) { case RS::LIGHT_PROJECTOR_FILTER_NEAREST: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::LIGHT_PROJECTOR_FILTER_NEAREST_MIPMAPS: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::LIGHT_PROJECTOR_FILTER_LINEAR: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; case RS::LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS_ANISOTROPIC: { - sampler = storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); + sampler = storage->sampler_rd_get_custom(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED); } break; } diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h index 7707d77296..d6ab4d1db2 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h @@ -129,6 +129,7 @@ class RenderForwardClustered : public RendererSceneRenderRD { virtual void _base_uniforms_changed() override; virtual RID _render_buffers_get_normal_texture(RID p_render_buffers) override; + bool base_uniform_set_updated = false; void _update_render_base_uniform_set(); RID _setup_sdfgi_render_pass_uniform_set(RID p_albedo_texture, RID p_emission_texture, RID p_emission_aniso_texture, RID p_geom_facing_texture); RID _setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas = false, int p_index = 0); @@ -603,6 +604,11 @@ protected: virtual void _render_particle_collider_heightfield(RID p_fb, const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, const PagedArray<GeometryInstance *> &p_instances) override; public: + _FORCE_INLINE_ virtual void update_uniform_sets() override { + base_uniform_set_updated = true; + _update_render_base_uniform_set(); + } + virtual GeometryInstance *geometry_instance_create(RID p_base) override; virtual void geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) override; virtual void geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) override; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 559e6d5ad7..522a8e8112 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -281,12 +281,12 @@ RendererCompositorRD::RendererCompositorRD() { storage = memnew(RendererStorageRD); canvas = memnew(RendererCanvasRenderRD(storage)); - uint32_t back_end = GLOBAL_GET("rendering/vulkan/rendering/back_end"); + back_end = (bool)(int)GLOBAL_GET("rendering/vulkan/rendering/back_end"); uint32_t textures_per_stage = RD::get_singleton()->limit_get(RD::LIMIT_MAX_TEXTURES_PER_SHADER_STAGE); - if (back_end == 1 || textures_per_stage < 48) { + if (back_end || textures_per_stage < 48) { scene = memnew(RendererSceneRenderImplementation::RenderForwardMobile(storage)); - } else { // back_end == 0 + } else { // back_end == false // default to our high end renderer scene = memnew(RendererSceneRenderImplementation::RenderForwardClustered(storage)); } diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index 0230c46800..f69e40e0ff 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -116,8 +116,6 @@ public: _create_func = _create_current; } - virtual bool is_low_end() const { return false; } - static RendererCompositorRD *singleton; RendererCompositorRD(); ~RendererCompositorRD(); diff --git a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp index 807af00c8e..5acb1cb99c 100644 --- a/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_gi_rd.cpp @@ -1305,7 +1305,6 @@ void RendererSceneGIRD::SDFGI::debug_probes(RD::DrawListID p_draw_list, RID p_fr RD::get_singleton()->draw_list_draw(p_draw_list, false, total_probes, total_points); if (gi->sdfgi_debug_probe_dir != Vector3()) { - print_line("CLICK DEBUG ME?"); uint32_t cascade = 0; Vector3 offset = Vector3((Vector3i(1, 1, 1) * -int32_t(cascade_size >> 1) + cascades[cascade].position)) * cascades[cascade].cell_size * Vector3(1.0, 1.0 / y_mult, 1.0); Vector3 probe_size = cascades[cascade].cell_size * (cascade_size / SDFGI::PROBE_DIVISOR) * Vector3(1.0, 1.0 / y_mult, 1.0); @@ -1333,11 +1332,6 @@ void RendererSceneGIRD::SDFGI::debug_probes(RD::DrawListID p_draw_list, RID p_fr } } - if (gi->sdfgi_debug_probe_enabled) { - print_line("found: " + gi->sdfgi_debug_probe_index); - } else { - print_line("no found"); - } gi->sdfgi_debug_probe_dir = Vector3(); } @@ -3132,8 +3126,8 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_ RD::TextureFormat tf; tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf.width = rb->width; - tf.height = rb->height; + tf.width = rb->internal_width; + tf.height = rb->internal_height; if (half_resolution) { tf.width >>= 1; tf.height >>= 1; @@ -3146,13 +3140,13 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_ PushConstant push_constant; - push_constant.screen_size[0] = rb->width; - push_constant.screen_size[1] = rb->height; + push_constant.screen_size[0] = rb->internal_width; + push_constant.screen_size[1] = rb->internal_height; push_constant.z_near = p_projection.get_z_near(); push_constant.z_far = p_projection.get_z_far(); push_constant.orthogonal = p_projection.is_orthogonal(); - push_constant.proj_info[0] = -2.0f / (rb->width * p_projection.matrix[0][0]); - push_constant.proj_info[1] = -2.0f / (rb->height * p_projection.matrix[1][1]); + push_constant.proj_info[0] = -2.0f / (rb->internal_width * p_projection.matrix[0][0]); + push_constant.proj_info[1] = -2.0f / (rb->internal_height * p_projection.matrix[1][1]); push_constant.proj_info[2] = (1.0f - p_projection.matrix[0][2]) / p_projection.matrix[0][0]; push_constant.proj_info[3] = (1.0f + p_projection.matrix[1][2]) / p_projection.matrix[1][1]; push_constant.max_voxel_gi_instances = MIN((uint64_t)MAX_VOXEL_GI_INSTANCES, p_voxel_gi_instances.size()); @@ -3344,9 +3338,9 @@ void RendererSceneGIRD::process_gi(RID p_render_buffers, RID p_normal_roughness_ RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(PushConstant)); if (rb->gi.using_half_size_gi) { - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width >> 1, rb->height >> 1, 1); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->internal_width >> 1, rb->internal_height >> 1, 1); } else { - RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->width, rb->height, 1); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, rb->internal_width, rb->internal_height, 1); } //do barrier later to allow oeverlap //RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_NO_BARRIER); //no barriers, let other compute, raster and transfer happen at the same time diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index b8e9f40bc4..ae8d91a73b 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1503,8 +1503,8 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { RD::TextureFormat tf; tf.format = _render_buffers_get_color_format(); // RD::DATA_FORMAT_R16G16B16A16_SFLOAT; - tf.width = rb->width; - tf.height = rb->height; + tf.width = rb->internal_width; + tf.height = rb->internal_height; tf.texture_type = rb->view_count > 1 ? RD::TEXTURE_TYPE_2D_ARRAY : RD::TEXTURE_TYPE_2D; tf.array_layers = rb->view_count; tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; @@ -1515,6 +1515,10 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { } tf.mipmaps = mipmaps_required; + rb->sss_texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + tf.width = rb->internal_width; + tf.height = rb->internal_height; rb->blur[0].texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); //the second one is smaller (only used for separatable part of blur) tf.width >>= 1; @@ -1522,8 +1526,8 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { tf.mipmaps--; rb->blur[1].texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); - int base_width = rb->width; - int base_height = rb->height; + int base_width = rb->internal_width; + int base_height = rb->internal_height; for (uint32_t i = 0; i < mipmaps_required; i++) { RenderBuffers::Blur::Mipmap mm; @@ -1577,8 +1581,8 @@ void RendererSceneRenderRD::_allocate_blur_textures(RenderBuffers *rb) { // create 4 weight textures, 2 full size, 2 half size tf.format = RD::DATA_FORMAT_R16_SFLOAT; // We could probably use DATA_FORMAT_R8_SNORM if we don't pre-multiply by blur_size but that depends on whether we can remove DEPTH_GAP - tf.width = rb->width; - tf.height = rb->height; + tf.width = rb->internal_width; + tf.height = rb->internal_height; tf.texture_type = rb->view_count > 1 ? RD::TEXTURE_TYPE_2D_ARRAY : RD::TEXTURE_TYPE_2D; tf.array_layers = rb->view_count; tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; @@ -1656,8 +1660,8 @@ void RendererSceneRenderRD::_allocate_depth_backbuffer_textures(RenderBuffers *r void RendererSceneRenderRD::_allocate_luminance_textures(RenderBuffers *rb) { ERR_FAIL_COND(!rb->luminance.current.is_null()); - int w = rb->width; - int h = rb->height; + int w = rb->internal_width; + int h = rb->internal_height; while (true) { w = MAX(w / 8, 1); @@ -1709,9 +1713,26 @@ void RendererSceneRenderRD::_free_render_buffer_data(RenderBuffers *rb) { rb->texture_fb = RID(); } - if (rb->texture.is_valid()) { - RD::get_singleton()->free(rb->texture); + if (rb->internal_texture == rb->texture && rb->internal_texture.is_valid()) { + RD::get_singleton()->free(rb->internal_texture); rb->texture = RID(); + rb->internal_texture = RID(); + rb->upscale_texture = RID(); + } else { + if (rb->texture.is_valid()) { + RD::get_singleton()->free(rb->texture); + rb->texture = RID(); + } + + if (rb->internal_texture.is_valid()) { + RD::get_singleton()->free(rb->internal_texture); + rb->internal_texture = RID(); + } + + if (rb->upscale_texture.is_valid()) { + RD::get_singleton()->free(rb->upscale_texture); + rb->upscale_texture = RID(); + } } if (rb->depth_texture.is_valid()) { @@ -1729,6 +1750,11 @@ void RendererSceneRenderRD::_free_render_buffer_data(RenderBuffers *rb) { rb->depth_back_texture = RID(); } + if (rb->sss_texture.is_valid()) { + RD::get_singleton()->free(rb->sss_texture); + rb->sss_texture = RID(); + } + for (int i = 0; i < 2; i++) { for (int m = 0; m < rb->blur[i].mipmaps.size(); m++) { // do we free the texture slice here? or is it enough to free the main texture? @@ -1818,7 +1844,7 @@ void RendererSceneRenderRD::_process_sss(RID p_render_buffers, const CameraMatri RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers); ERR_FAIL_COND(!rb); - bool can_use_effects = rb->width >= 8 && rb->height >= 8; + bool can_use_effects = rb->internal_width >= 8 && rb->internal_height >= 8; if (!can_use_effects) { //just copy @@ -1829,18 +1855,18 @@ void RendererSceneRenderRD::_process_sss(RID p_render_buffers, const CameraMatri _allocate_blur_textures(rb); } - storage->get_effects()->sub_surface_scattering(rb->texture, rb->blur[0].mipmaps[0].texture, rb->depth_texture, p_camera, Size2i(rb->width, rb->height), sss_scale, sss_depth_scale, sss_quality); + storage->get_effects()->sub_surface_scattering(rb->internal_texture, rb->sss_texture, rb->depth_texture, p_camera, Size2i(rb->internal_width, rb->internal_height), sss_scale, sss_depth_scale, sss_quality); } void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffer, RID p_normal_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.get_or_null(p_render_buffers); ERR_FAIL_COND(!rb); - bool can_use_effects = rb->width >= 8 && rb->height >= 8; + bool can_use_effects = rb->internal_width >= 8 && rb->internal_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()); + storage->get_effects()->merge_specular(p_dest_framebuffer, p_specular_buffer, p_use_additive ? RID() : rb->internal_texture, RID()); return; } @@ -1852,8 +1878,8 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb 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.width = rb->internal_width / 2; + tf.height = rb->internal_height / 2; tf.texture_type = RD::TEXTURE_TYPE_2D; tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT; @@ -1867,8 +1893,8 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb 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.width = rb->internal_width / 2; + tf.height = rb->internal_height / 2; tf.texture_type = RD::TEXTURE_TYPE_2D; tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; @@ -1880,8 +1906,8 @@ void RendererSceneRenderRD::_process_ssr(RID p_render_buffers, RID p_dest_frameb _allocate_blur_textures(rb); } - storage->get_effects()->screen_space_reflection(rb->texture, p_normal_buffer, ssr_roughness_quality, 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); + storage->get_effects()->screen_space_reflection(rb->internal_texture, p_normal_buffer, ssr_roughness_quality, 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->internal_width / 2, rb->internal_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->internal_texture, rb->blur[0].mipmaps[1].texture); } void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environment, RID p_normal_buffer, const CameraMatrix &p_projection) { @@ -1918,15 +1944,15 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen int half_width; int half_height; if (ssao_half_size) { - buffer_width = (rb->width + 3) / 4; - buffer_height = (rb->height + 3) / 4; - half_width = (rb->width + 7) / 8; - half_height = (rb->height + 7) / 8; + buffer_width = (rb->internal_width + 3) / 4; + buffer_height = (rb->internal_height + 3) / 4; + half_width = (rb->internal_width + 7) / 8; + half_height = (rb->internal_height + 7) / 8; } else { - buffer_width = (rb->width + 1) / 2; - buffer_height = (rb->height + 1) / 2; - half_width = (rb->width + 3) / 4; - half_height = (rb->height + 3) / 4; + buffer_width = (rb->internal_width + 1) / 2; + buffer_height = (rb->internal_height + 1) / 2; + half_width = (rb->internal_width + 3) / 4; + half_height = (rb->internal_height + 3) / 4; } bool uniform_sets_are_invalid = false; if (rb->ssao.depth.is_null()) { @@ -1998,8 +2024,8 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen { RD::TextureFormat tf; tf.format = RD::DATA_FORMAT_R8_UNORM; - tf.width = rb->width; - tf.height = rb->height; + tf.width = rb->internal_width; + tf.height = rb->internal_height; tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT; rb->ssao.ao_final = RD::get_singleton()->texture_create(tf, RD::TextureView()); RD::get_singleton()->set_resource_name(rb->ssao.ao_final, "SSAO Final"); @@ -2022,7 +2048,7 @@ void RendererSceneRenderRD::_process_ssao(RID p_render_buffers, RID p_environmen settings.blur_passes = ssao_blur_passes; settings.fadeout_from = ssao_fadeout_from; settings.fadeout_to = ssao_fadeout_to; - settings.full_screen_size = Size2i(rb->width, rb->height); + settings.full_screen_size = Size2i(rb->internal_width, rb->internal_height); settings.half_screen_size = Size2i(buffer_width, buffer_height); settings.quarter_screen_size = Size2i(half_width, half_height); @@ -2102,9 +2128,9 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende EffectsRD::BokehBuffers buffers; - // Textures we use. - buffers.base_texture_size = Size2i(rb->width, rb->height); - buffers.base_texture = rb->texture; + // Textures we use + buffers.base_texture_size = Size2i(rb->internal_width, rb->internal_height); + buffers.base_texture = rb->internal_texture; buffers.depth_texture = rb->depth_texture; buffers.secondary_texture = rb->blur[0].mipmaps[0].texture; buffers.half_texture[0] = rb->blur[1].mipmaps[0].texture; @@ -2143,9 +2169,9 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende double step = env->auto_exp_speed * time_step; if (can_use_storage) { - storage->get_effects()->luminance_reduction(rb->texture, Size2i(rb->width, rb->height), rb->luminance.reduce, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); + storage->get_effects()->luminance_reduction(rb->internal_texture, Size2i(rb->internal_width, rb->internal_height), rb->luminance.reduce, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); } else { - storage->get_effects()->luminance_reduction_raster(rb->texture, Size2i(rb->width, rb->height), rb->luminance.reduce, rb->luminance.fb, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); + storage->get_effects()->luminance_reduction_raster(rb->internal_texture, Size2i(rb->internal_width, rb->internal_height), rb->luminance.reduce, rb->luminance.fb, rb->luminance.current, env->min_luminance, env->max_luminance, step, set_immediate); } // Swap final reduce with prev luminance. SWAP(rb->luminance.current, rb->luminance.reduce.write[rb->luminance.reduce.size() - 1]); @@ -2188,9 +2214,9 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende luminance_texture = rb->luminance.current; } if (can_use_storage) { - storage->get_effects()->gaussian_glow(rb->texture, rb->blur[1].mipmaps[i].texture, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); + storage->get_effects()->gaussian_glow(rb->internal_texture, rb->blur[1].mipmaps[i].texture, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); } else { - storage->get_effects()->gaussian_glow_raster(rb->texture, rb->blur[1].mipmaps[i].half_fb, rb->blur[1].mipmaps[i].half_texture, rb->blur[1].mipmaps[i].fb, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); + storage->get_effects()->gaussian_glow_raster(rb->internal_texture, rb->blur[1].mipmaps[i].half_fb, rb->blur[1].mipmaps[i].half_texture, rb->blur[1].mipmaps[i].fb, Size2i(vp_w, vp_h), env->glow_strength, glow_high_quality, true, env->glow_hdr_luminance_cap, env->exposure, env->glow_bloom, env->glow_hdr_bleed_threshold, env->glow_hdr_bleed_scale, luminance_texture, env->auto_exp_scale); } } else { if (can_use_storage) { @@ -2237,7 +2263,7 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende } tonemap.use_debanding = rb->use_debanding; - tonemap.texture_size = Vector2i(rb->width, rb->height); + tonemap.texture_size = Vector2i(rb->internal_width, rb->internal_height); if (env) { tonemap.tonemap_mode = env->tone_mapper; @@ -2268,7 +2294,15 @@ void RendererSceneRenderRD::_render_buffers_post_process_and_tonemap(const Rende tonemap.luminance_multiplier = _render_buffers_get_luminance_multiplier(); tonemap.view_count = p_render_data->view_count; - storage->get_effects()->tonemapper(rb->texture, storage->render_target_get_rd_framebuffer(rb->render_target), tonemap); + storage->get_effects()->tonemapper(rb->internal_texture, storage->render_target_get_rd_framebuffer(rb->render_target), tonemap); + + RD::get_singleton()->draw_command_end_label(); + } + + if (can_use_effects && can_use_storage && (rb->internal_width != rb->width || rb->internal_height != rb->height)) { + RD::get_singleton()->draw_command_begin_label("FSR Upscale"); + + storage->get_effects()->fsr_upscale(rb->internal_texture, rb->upscale_texture, rb->texture, Size2i(rb->internal_width, rb->internal_height), Size2i(rb->width, rb->height), rb->fsr_sharpness); RD::get_singleton()->draw_command_end_label(); } @@ -2628,14 +2662,28 @@ bool RendererSceneRenderRD::_render_buffers_can_be_storage() { return true; } -void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { +void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) { ERR_FAIL_COND_MSG(p_view_count == 0, "Must have at least 1 view"); + if (!_render_buffers_can_be_storage()) { + p_internal_height = p_height; + p_internal_width = p_width; + } + + if (p_width != p_internal_width) { + float fsr_mipmap_bias = -log2f(p_width / p_internal_width) + p_fsr_mipmap_bias; + storage->sampler_rd_configure_custom(fsr_mipmap_bias); + update_uniform_sets(); + } + RenderBuffers *rb = render_buffers_owner.get_or_null(p_render_buffers); // Should we add an overrule per viewport? + rb->internal_width = p_internal_width; + rb->internal_height = p_internal_height; rb->width = p_width; rb->height = p_height; + rb->fsr_sharpness = p_fsr_sharpness; rb->render_target = p_render_target; rb->msaa = p_msaa; rb->screen_space_aa = p_screen_space_aa; @@ -2657,8 +2705,8 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p tf.texture_type = RD::TEXTURE_TYPE_2D_ARRAY; } tf.format = _render_buffers_get_color_format(); - tf.width = rb->width; - tf.height = rb->height; + tf.width = rb->internal_width; // If set to rb->width, msaa won't crash + tf.height = rb->internal_height; // If set to rb->width, msaa won't crash tf.array_layers = rb->view_count; // create a layer for every view tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | (_render_buffers_can_be_storage() ? RD::TEXTURE_USAGE_STORAGE_BIT : 0) | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) { @@ -2666,7 +2714,17 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p } tf.usage_bits |= RD::TEXTURE_USAGE_INPUT_ATTACHMENT_BIT; // only needed when using subpasses in the mobile renderer - rb->texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + rb->internal_texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + + if ((p_internal_width != p_width || p_internal_height != p_height)) { + tf.width = rb->width; + tf.height = rb->height; + rb->texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + rb->upscale_texture = RD::get_singleton()->texture_create(tf, RD::TextureView()); + } else { + rb->texture = rb->internal_texture; + rb->upscale_texture = rb->internal_texture; + } } { @@ -2680,8 +2738,8 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p tf.format = RD::DATA_FORMAT_R32_SFLOAT; } - tf.width = rb->width; - tf.height = rb->height; + tf.width = rb->internal_width; + tf.height = rb->internal_height; tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT; tf.array_layers = rb->view_count; // create a layer for every view @@ -2697,16 +2755,16 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p if (!_render_buffers_can_be_storage()) { // ONLY USED ON MOBILE RENDERER, ONLY USED FOR POST EFFECTS! Vector<RID> fb; - fb.push_back(rb->texture); + fb.push_back(rb->internal_texture); rb->texture_fb = RD::get_singleton()->framebuffer_create(fb, RenderingDevice::INVALID_ID, rb->view_count); } RID target_texture = storage->render_target_get_rd_texture(rb->render_target); - rb->data->configure(rb->texture, rb->depth_texture, target_texture, rb->width, rb->height, p_msaa, p_view_count); + rb->data->configure(rb->internal_texture, rb->depth_texture, target_texture, p_internal_width, p_internal_height, p_msaa, p_view_count); if (is_clustered_enabled()) { - rb->cluster_builder->setup(Size2i(rb->width, rb->height), max_cluster_elements, rb->depth_texture, storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED), rb->texture); + rb->cluster_builder->setup(Size2i(p_internal_width, p_internal_height), max_cluster_elements, rb->depth_texture, storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED), rb->internal_texture); } } @@ -3796,6 +3854,18 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e rb->volumetric_fog->fog_map = RD::get_singleton()->texture_create(tf, RD::TextureView()); RD::get_singleton()->set_resource_name(rb->volumetric_fog->fog_map, "Fog map"); +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + Vector<uint8_t> dm; + dm.resize(target_width * target_height * volumetric_fog_depth * 4); + dm.fill(0); + + rb->volumetric_fog->density_map = RD::get_singleton()->storage_buffer_create(dm.size(), dm); + RD::get_singleton()->set_resource_name(rb->volumetric_fog->density_map, "Fog density map"); + rb->volumetric_fog->light_map = RD::get_singleton()->storage_buffer_create(dm.size(), dm); + RD::get_singleton()->set_resource_name(rb->volumetric_fog->light_map, "Fog light map"); + rb->volumetric_fog->emissive_map = RD::get_singleton()->storage_buffer_create(dm.size(), dm); + RD::get_singleton()->set_resource_name(rb->volumetric_fog->emissive_map, "Fog emissive map"); +#else tf.format = RD::DATA_FORMAT_R32_UINT; tf.usage_bits = RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_COPY_TO_BIT; rb->volumetric_fog->density_map = RD::get_singleton()->texture_create(tf, RD::TextureView()); @@ -3807,6 +3877,7 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e rb->volumetric_fog->emissive_map = RD::get_singleton()->texture_create(tf, RD::TextureView()); RD::get_singleton()->set_resource_name(rb->volumetric_fog->emissive_map, "Fog emissive map"); RD::get_singleton()->texture_clear(rb->volumetric_fog->emissive_map, Color(0, 0, 0, 0), 0, 1, 0, 1); +#endif Vector<RD::Uniform> uniforms; { @@ -3872,7 +3943,11 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e { RD::Uniform u; +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; +#else u.uniform_type = RD::UNIFORM_TYPE_IMAGE; +#endif u.binding = 1; u.ids.push_back(rb->volumetric_fog->emissive_map); uniforms.push_back(u); @@ -3888,7 +3963,11 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e { RD::Uniform u; +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; +#else u.uniform_type = RD::UNIFORM_TYPE_IMAGE; +#endif u.binding = 3; u.ids.push_back(rb->volumetric_fog->density_map); uniforms.push_back(u); @@ -3896,7 +3975,11 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e { RD::Uniform u; +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; +#else u.uniform_type = RD::UNIFORM_TYPE_IMAGE; +#endif u.binding = 4; u.ids.push_back(rb->volumetric_fog->light_map); uniforms.push_back(u); @@ -4163,14 +4246,22 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e } { RD::Uniform u; +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; +#else u.uniform_type = RD::UNIFORM_TYPE_IMAGE; +#endif u.binding = 16; u.ids.push_back(rb->volumetric_fog->density_map); uniforms.push_back(u); } { RD::Uniform u; +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; +#else u.uniform_type = RD::UNIFORM_TYPE_IMAGE; +#endif u.binding = 17; u.ids.push_back(rb->volumetric_fog->light_map); uniforms.push_back(u); @@ -4178,7 +4269,11 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e { RD::Uniform u; +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + u.uniform_type = RD::UNIFORM_TYPE_STORAGE_BUFFER; +#else u.uniform_type = RD::UNIFORM_TYPE_IMAGE; +#endif u.binding = 18; u.ids.push_back(rb->volumetric_fog->emissive_map); uniforms.push_back(u); @@ -4704,9 +4799,7 @@ void RendererSceneRenderRD::render_scene(RID p_render_buffers, const CameraData if (p_render_buffers.is_valid()) { /* _debug_draw_cluster(p_render_buffers); - RENDER_TIMESTAMP("Tonemap"); - _render_buffers_post_process_and_tonemap(&render_data); */ diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index 740e0e75ce..98ab1a2c3c 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -456,7 +456,11 @@ private: struct RenderBuffers { RenderBufferData *data = nullptr; - int width = 0, height = 0; + int internal_width = 0; + int internal_height = 0; + int width = 0; + int height = 0; + float fsr_sharpness = 0.2f; RS::ViewportMSAA msaa = RS::VIEWPORT_MSAA_DISABLED; RS::ViewportScreenSpaceAA screen_space_aa = RS::VIEWPORT_SCREEN_SPACE_AA_DISABLED; bool use_debanding = false; @@ -466,9 +470,12 @@ private: uint64_t auto_exposure_version = 1; - RID texture; //main texture for rendering to, must be filled after done rendering + RID sss_texture; //texture for sss. This needs to be a different resolution than blur[0] + RID internal_texture; //main texture for rendering to, must be filled after done rendering + RID texture; //upscaled version of main texture (This uses the same resource as internal_texture if there is no upscaling) RID depth_texture; //main depth texture RID texture_fb; // framebuffer for the main texture, ONLY USED FOR MOBILE RENDERER POST EFFECTS, DO NOT USE FOR RENDERING 3D!!! + RID upscale_texture; //used when upscaling internal_texture (This uses the same resource as internal_texture if there is no upscaling) RendererSceneGIRD::SDFGI *sdfgi = nullptr; VolumetricFog *volumetric_fog = nullptr; @@ -1332,7 +1339,7 @@ public: virtual RD::DataFormat _render_buffers_get_color_format(); virtual bool _render_buffers_can_be_storage(); virtual RID render_buffers_create() override; - virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override; + virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override; virtual void gi_set_use_half_resolution(bool p_enable) override; RID render_buffers_get_depth_texture(RID p_render_buffers); @@ -1363,6 +1370,8 @@ public: float render_buffers_get_volumetric_fog_end(RID p_render_buffers); float render_buffers_get_volumetric_fog_detail_spread(RID p_render_buffers); + virtual void update_uniform_sets(){}; + virtual void render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, const PagedArray<RID> &p_fog_volumes, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_render_info = nullptr) override; virtual void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override; diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 04753d7a9b..cd5d70e12f 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -1227,6 +1227,100 @@ RendererStorageRD::CanvasTexture::~CanvasTexture() { clear_sets(); } +void RendererStorageRD::sampler_rd_configure_custom(float p_mipmap_bias) { + 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 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 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 RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS: { + sampler_state.mag_filter = RD::SAMPLER_FILTER_NEAREST; + sampler_state.min_filter = RD::SAMPLER_FILTER_NEAREST; + if (GLOBAL_GET("rendering/textures/default_filters/use_nearest_mipmap_filter")) { + sampler_state.mip_filter = RD::SAMPLER_FILTER_NEAREST; + } else { + sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; + } + sampler_state.lod_bias = p_mipmap_bias; + } break; + 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; + if (GLOBAL_GET("rendering/textures/default_filters/use_nearest_mipmap_filter")) { + sampler_state.mip_filter = RD::SAMPLER_FILTER_NEAREST; + } else { + sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; + } + sampler_state.lod_bias = p_mipmap_bias; + + } break; + 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_NEAREST; + if (GLOBAL_GET("rendering/textures/default_filters/use_nearest_mipmap_filter")) { + sampler_state.mip_filter = RD::SAMPLER_FILTER_NEAREST; + } else { + sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; + } + sampler_state.lod_bias = p_mipmap_bias; + sampler_state.use_anisotropy = true; + sampler_state.anisotropy_max = 1 << int(GLOBAL_GET("rendering/textures/default_filters/anisotropic_filtering_level")); + } break; + 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; + if (GLOBAL_GET("rendering/textures/default_filters/use_nearest_mipmap_filter")) { + sampler_state.mip_filter = RD::SAMPLER_FILTER_NEAREST; + } else { + sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR; + } + sampler_state.lod_bias = p_mipmap_bias; + sampler_state.use_anisotropy = true; + sampler_state.anisotropy_max = 1 << int(GLOBAL_GET("rendering/textures/default_filters/anisotropic_filtering_level")); + + } break; + default: { + } + } + switch (j) { + 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; + sampler_state.repeat_w = RD::SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE; + + } break; + 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; + sampler_state.repeat_w = RD::SAMPLER_REPEAT_MODE_REPEAT; + } break; + 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; + sampler_state.repeat_w = RD::SAMPLER_REPEAT_MODE_MIRRORED_REPEAT; + } break; + default: { + } + } + + if (custom_rd_samplers[i][j].is_valid()) { + RD::get_singleton()->free(custom_rd_samplers[i][j]); + } + + custom_rd_samplers[i][j] = RD::get_singleton()->sampler_create(sampler_state); + } + } +} + RID RendererStorageRD::canvas_texture_allocate() { return canvas_texture_owner.allocate_rid(); } @@ -2558,7 +2652,17 @@ void RendererStorageRD::MaterialData::update_uniform_buffer(const Map<StringName //regular uniform uint32_t offset = p_uniform_offsets[E.value.order]; #ifdef DEBUG_ENABLED - uint32_t size = ShaderLanguage::get_type_size(E.value.type); + uint32_t size = 0U; + // The following code enforces a 16-byte alignment of uniform arrays. + if (E.value.array_size > 0) { + size = ShaderLanguage::get_type_size(E.value.type) * E.value.array_size; + int m = (16 * E.value.array_size); + if ((size % m) != 0U) { + size += m - (size % m); + } + } else { + size = ShaderLanguage::get_type_size(E.value.type); + } ERR_CONTINUE(offset + size > p_buffer_size); #endif uint8_t *data = &p_buffer[offset]; @@ -9161,7 +9265,6 @@ void RendererStorageRD::_update_global_variables() { ERR_CONTINUE(!material); //wtf _material_queue_update(material, false, true); - print_line("update material texture?"); } global_variables.must_update_texture_materials = false; @@ -9774,6 +9877,9 @@ RendererStorageRD::RendererStorageRD() { } } + //custom sampler + sampler_rd_configure_custom(0.0f); + //default rd buffers { Vector<uint8_t> buffer; @@ -9926,7 +10032,7 @@ RendererStorageRD::RendererStorageRD() { actions.renames["RESTART"] = "restart"; actions.renames["CUSTOM"] = "PARTICLE.custom"; actions.renames["TRANSFORM"] = "PARTICLE.xform"; - actions.renames["TIME"] = "FRAME.time"; + actions.renames["TIME"] = "frame_history.data[0].time"; actions.renames["PI"] = _MKSTR(Math_PI); actions.renames["TAU"] = _MKSTR(Math_TAU); actions.renames["E"] = _MKSTR(Math_E); @@ -10104,6 +10210,15 @@ RendererStorageRD::~RendererStorageRD() { } } + //custom samplers + for (int i = 1; i < RS::CANVAS_ITEM_TEXTURE_FILTER_MAX; i++) { + for (int j = 0; j < RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX; j++) { + if (custom_rd_samplers[i][j].is_valid()) { + RD::get_singleton()->free(custom_rd_samplers[i][j]); + } + } + } + //def buffers for (int i = 0; i < DEFAULT_RD_BUFFER_MAX; i++) { RD::get_singleton()->free(mesh_default_rd_buffers[i]); diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.h b/servers/rendering/renderer_rd/renderer_storage_rd.h index 2cd3a01c66..9a64480c3e 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.h +++ b/servers/rendering/renderer_rd/renderer_storage_rd.h @@ -320,6 +320,7 @@ private: RID default_rd_textures[DEFAULT_RD_TEXTURE_MAX]; RID default_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX]; + RID custom_rd_samplers[RS::CANVAS_ITEM_TEXTURE_FILTER_MAX][RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX]; RID default_rd_storage_buffer; /* DECAL ATLAS */ @@ -1391,6 +1392,13 @@ public: _FORCE_INLINE_ RID sampler_rd_get_default(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) { return default_rd_samplers[p_filter][p_repeat]; } + _FORCE_INLINE_ RID sampler_rd_get_custom(RS::CanvasItemTextureFilter p_filter, RS::CanvasItemTextureRepeat p_repeat) { + return custom_rd_samplers[p_filter][p_repeat]; + } + + void sampler_rd_configure_custom(float mipmap_bias); + + void sampler_rd_set_default(float p_mipmap_bias); /* CANVAS TEXTURE API */ diff --git a/servers/rendering/renderer_rd/shader_compiler_rd.cpp b/servers/rendering/renderer_rd/shader_compiler_rd.cpp index f7c8ca1487..b02b3d2723 100644 --- a/servers/rendering/renderer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/renderer_rd/shader_compiler_rd.cpp @@ -661,6 +661,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge uniform_sizes.write[uniform.order] = _get_datatype_size(ShaderLanguage::TYPE_UINT); uniform_alignments.write[uniform.order] = _get_datatype_alignment(ShaderLanguage::TYPE_UINT); } else { + // The following code enforces a 16-byte alignment of uniform arrays. if (uniform.array_size > 0) { int size = _get_datatype_size(uniform.type) * uniform.array_size; int m = (16 * uniform.array_size); @@ -668,10 +669,11 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge size += m - (size % m); } uniform_sizes.write[uniform.order] = size; + uniform_alignments.write[uniform.order] = 16; } else { uniform_sizes.write[uniform.order] = _get_datatype_size(uniform.type); + uniform_alignments.write[uniform.order] = _get_datatype_alignment(uniform.type); } - uniform_alignments.write[uniform.order] = _get_datatype_alignment(uniform.type); } } @@ -1316,6 +1318,9 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge code += ")"; } break; + case SL::OP_EMPTY: { + // Semicolon (or empty statement) - ignored. + } break; default: { if (p_use_scope) { diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index b9a8947fa2..2568090918 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -177,6 +177,9 @@ void ShaderRD::_build_variant_code(StringBuilder &builder, uint32_t p_variant, c for (const KeyValue<StringName, CharString> &E : p_version->code_sections) { builder.append(String("#define ") + String(E.key) + "_CODE_USED\n"); } +#if defined(OSX_ENABLED) || defined(IPHONE_ENABLED) + builder.append("#define MOLTENVK_USED\n"); +#endif } break; case StageTemplate::Chunk::TYPE_MATERIAL_UNIFORMS: { builder.append(p_version->uniforms.get_data()); //uniforms (same for vertex and fragment) diff --git a/servers/rendering/renderer_rd/shaders/fsr_upscale.glsl b/servers/rendering/renderer_rd/shaders/fsr_upscale.glsl new file mode 100644 index 0000000000..4e2ba84033 --- /dev/null +++ b/servers/rendering/renderer_rd/shaders/fsr_upscale.glsl @@ -0,0 +1,173 @@ +/*************************************************************************/ +/* fsr_upscale.glsl */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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. */ +/*************************************************************************/ + +#[compute] + +#version 450 + +#VERSION_DEFINES + +#define A_GPU +#define A_GLSL + +#ifdef MODE_FSR_UPSCALE_NORMAL + +#define A_HALF + +#endif + +#include "thirdparty/amd-fsr/ffx_a.h" + +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(rgba16f, set = 1, binding = 0) uniform restrict writeonly image2D fsr_image; +layout(set = 0, binding = 0) uniform sampler2D source_image; + +#define FSR_UPSCALE_PASS_TYPE_EASU 0 +#define FSR_UPSCALE_PASS_TYPE_RCAS 1 + +layout(push_constant, binding = 1, std430) uniform Params { + float resolution_width; + float resolution_height; + float upscaled_width; + float upscaled_height; + float sharpness; + int pass; +} +params; + +AU4 Const0, Const1, Const2, Const3; + +#ifdef MODE_FSR_UPSCALE_FALLBACK + +#define FSR_EASU_F +AF4 FsrEasuRF(AF2 p) { + AF4 res = textureGather(source_image, p, 0); + return res; +} +AF4 FsrEasuGF(AF2 p) { + AF4 res = textureGather(source_image, p, 1); + return res; +} +AF4 FsrEasuBF(AF2 p) { + AF4 res = textureGather(source_image, p, 2); + return res; +} + +#define FSR_RCAS_F +AF4 FsrRcasLoadF(ASU2 p) { + return AF4(texelFetch(source_image, ASU2(p), 0)); +} +void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {} + +#else + +#define FSR_EASU_H +AH4 FsrEasuRH(AF2 p) { + AH4 res = AH4(textureGather(source_image, p, 0)); + return res; +} +AH4 FsrEasuGH(AF2 p) { + AH4 res = AH4(textureGather(source_image, p, 1)); + return res; +} +AH4 FsrEasuBH(AF2 p) { + AH4 res = AH4(textureGather(source_image, p, 2)); + return res; +} + +#define FSR_RCAS_H +AH4 FsrRcasLoadH(ASW2 p) { + return AH4(texelFetch(source_image, ASU2(p), 0)); +} +void FsrRcasInputH(inout AH1 r, inout AH1 g, inout AH1 b) {} + +#endif + +#include "thirdparty/amd-fsr/ffx_fsr1.h" + +void fsr_easu_pass(AU2 pos) { +#ifdef MODE_FSR_UPSCALE_NORMAL + + AH3 Gamma2Color = AH3(0, 0, 0); + FsrEasuH(Gamma2Color, pos, Const0, Const1, Const2, Const3); + imageStore(fsr_image, ASU2(pos), AH4(Gamma2Color, 1)); + +#else + + AF3 Gamma2Color = AF3(0, 0, 0); + FsrEasuF(Gamma2Color, pos, Const0, Const1, Const2, Const3); + imageStore(fsr_image, ASU2(pos), AF4(Gamma2Color, 1)); + +#endif +} + +void fsr_rcas_pass(AU2 pos) { +#ifdef MODE_FSR_UPSCALE_NORMAL + + AH3 Gamma2Color = AH3(0, 0, 0); + FsrRcasH(Gamma2Color.r, Gamma2Color.g, Gamma2Color.b, pos, Const0); + imageStore(fsr_image, ASU2(pos), AH4(Gamma2Color, 1)); + +#else + + AF3 Gamma2Color = AF3(0, 0, 0); + FsrRcasF(Gamma2Color.r, Gamma2Color.g, Gamma2Color.b, pos, Const0); + imageStore(fsr_image, ASU2(pos), AF4(Gamma2Color, 1)); + +#endif +} + +void fsr_pass(AU2 pos) { + if (params.pass == FSR_UPSCALE_PASS_TYPE_EASU) { + fsr_easu_pass(pos); + } else if (params.pass == FSR_UPSCALE_PASS_TYPE_RCAS) { + fsr_rcas_pass(pos); + } +} + +void main() { + // Clang does not like unused functions. If ffx_a.h is included in the binary, clang will throw a fit and not compile so we must configure FSR in this shader + if (params.pass == FSR_UPSCALE_PASS_TYPE_EASU) { + FsrEasuCon(Const0, Const1, Const2, Const3, params.resolution_width, params.resolution_height, params.resolution_width, params.resolution_height, params.upscaled_width, params.upscaled_height); + } else if (params.pass == FSR_UPSCALE_PASS_TYPE_RCAS) { + FsrRcasCon(Const0, params.sharpness); + } + + AU2 gxy = ARmp8x8(gl_LocalInvocationID.x) + AU2(gl_WorkGroupID.x << 4u, gl_WorkGroupID.y << 4u); + + fsr_pass(gxy); + gxy.x += 8u; + fsr_pass(gxy); + gxy.y += 8u; + fsr_pass(gxy); + gxy.x -= 8u; + fsr_pass(gxy); +} diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 8e33610ae2..e4628b2d5a 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -1757,7 +1757,11 @@ void main() { } } +#ifdef MOLTENVK_USED + imageStore(geom_facing_grid, grid_pos, uvec4(imageLoad(geom_facing_grid, grid_pos).r | facing_bits)); //store facing bits +#else imageAtomicOr(geom_facing_grid, grid_pos, facing_bits); //store facing bits +#endif if (length(emission) > 0.001) { float lumas[6]; diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl index afc5d68776..181d3b272f 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl @@ -47,7 +47,13 @@ layout(push_constant, binding = 0, std430) uniform Params { } params; +#ifdef MOLTENVK_USED +layout(set = 1, binding = 1) volatile buffer emissive_only_map_buffer { + uint emissive_only_map[]; +}; +#else layout(r32ui, set = 1, binding = 1) uniform volatile uimage3D emissive_only_map; +#endif layout(set = 1, binding = 2, std140) uniform SceneParams { vec2 fog_frustum_size_begin; @@ -71,8 +77,17 @@ layout(set = 1, binding = 2, std140) uniform SceneParams { } scene_params; +#ifdef MOLTENVK_USED +layout(set = 1, binding = 3) volatile buffer density_only_map_buffer { + uint density_only_map[]; +}; +layout(set = 1, binding = 4) volatile buffer light_only_map_buffer { + uint light_only_map[]; +}; +#else layout(r32ui, set = 1, binding = 3) uniform volatile uimage3D density_only_map; layout(r32ui, set = 1, binding = 4) uniform volatile uimage3D light_only_map; +#endif #ifdef MATERIAL_UNIFORMS_USED layout(set = 2, binding = 0, std140) uniform MaterialUniforms{ @@ -115,6 +130,9 @@ void main() { if (any(greaterThanEqual(pos, scene_params.fog_volume_size))) { return; //do not compute } +#ifdef MOLTENVK_USED + uint lpos = pos.z * scene_params.fog_volume_size.x * scene_params.fog_volume_size.y + pos.y * scene_params.fog_volume_size.x + pos.x; +#endif vec3 posf = vec3(pos); @@ -197,7 +215,11 @@ void main() { density *= cull_mask; if (abs(density) > 0.001) { int final_density = int(density * DENSITY_SCALE); +#ifdef MOLTENVK_USED + atomicAdd(density_only_map[lpos], uint(final_density)); +#else imageAtomicAdd(density_only_map, pos, uint(final_density)); +#endif #ifdef EMISSION_USED { @@ -207,7 +229,11 @@ void main() { uvec3 emission_u = uvec3(emission.r * 511.0, emission.g * 511.0, emission.b * 255.0); // R and G have 11 bits each and B has 10. Then pack them into a 32 bit uint uint final_emission = emission_u.r << 21 | emission_u.g << 10 | emission_u.b; +#ifdef MOLTENVK_USED + uint prev_emission = atomicAdd(emissive_only_map[lpos], final_emission); +#else uint prev_emission = imageAtomicAdd(emissive_only_map, pos, final_emission); +#endif // Adding can lead to colors overflowing, so validate uvec3 prev_emission_u = uvec3(prev_emission >> 21, (prev_emission << 11) >> 21, prev_emission % 1024); @@ -219,7 +245,11 @@ void main() { if (any(overflowing)) { uvec3 overflow_factor = mix(uvec3(0), uvec3(2047 << 21, 2047 << 10, 1023), overflowing); uint force_max = overflow_factor.r | overflow_factor.g | overflow_factor.b; +#ifdef MOLTENVK_USED + atomicOr(emissive_only_map[lpos], force_max); +#else imageAtomicOr(emissive_only_map, pos, force_max); +#endif } } #endif @@ -230,7 +260,11 @@ void main() { uvec3 scattering_u = uvec3(scattering.r * 2047.0, scattering.g * 2047.0, scattering.b * 1023.0); // R and G have 11 bits each and B has 10. Then pack them into a 32 bit uint uint final_scattering = scattering_u.r << 21 | scattering_u.g << 10 | scattering_u.b; +#ifdef MOLTENVK_USED + uint prev_scattering = atomicAdd(light_only_map[lpos], final_scattering); +#else uint prev_scattering = imageAtomicAdd(light_only_map, pos, final_scattering); +#endif // Adding can lead to colors overflowing, so validate uvec3 prev_scattering_u = uvec3(prev_scattering >> 21, (prev_scattering << 11) >> 21, prev_scattering % 1024); @@ -242,7 +276,11 @@ void main() { if (any(overflowing)) { uvec3 overflow_factor = mix(uvec3(0), uvec3(2047 << 21, 2047 << 10, 1023), overflowing); uint force_max = overflow_factor.r | overflow_factor.g | overflow_factor.b; +#ifdef MOLTENVK_USED + atomicOr(light_only_map[lpos], force_max); +#else imageAtomicOr(light_only_map, pos, force_max); +#endif } } #endif // ALBEDO_USED diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl index 3d6fbb5653..747f88960c 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl @@ -190,9 +190,22 @@ params; #ifndef MODE_COPY layout(set = 0, binding = 15) uniform texture3D prev_density_texture; +#ifdef MOLTENVK_USED +layout(set = 0, binding = 16) buffer density_only_map_buffer { + uint density_only_map[]; +}; +layout(set = 0, binding = 17) buffer light_only_map_buffer { + uint light_only_map[]; +}; +layout(set = 0, binding = 18) buffer emissive_only_map_buffer { + uint emissive_only_map[]; +}; +#else layout(r32ui, set = 0, binding = 16) uniform uimage3D density_only_map; layout(r32ui, set = 0, binding = 17) uniform uimage3D light_only_map; layout(r32ui, set = 0, binding = 18) uniform uimage3D emissive_only_map; +#endif + #ifdef USE_RADIANCE_CUBEMAP_ARRAY layout(set = 0, binding = 19) uniform textureCubeArray sky_texture; #else @@ -272,6 +285,9 @@ void main() { if (any(greaterThanEqual(pos, params.fog_volume_size))) { return; //do not compute } +#ifdef MOLTENVK_USED + uint lpos = pos.z * params.fog_volume_size.x * params.fog_volume_size.y + pos.y * params.fog_volume_size.x + pos.x; +#endif vec3 posf = vec3(pos); @@ -335,15 +351,28 @@ void main() { vec3 total_light = vec3(0.0); float total_density = params.base_density; +#ifdef MOLTENVK_USED + uint local_density = density_only_map[lpos]; +#else uint local_density = imageLoad(density_only_map, pos).x; +#endif + total_density += float(int(local_density)) / DENSITY_SCALE; total_density = max(0.0, total_density); +#ifdef MOLTENVK_USED + uint scattering_u = light_only_map[lpos]; +#else uint scattering_u = imageLoad(light_only_map, pos).x; +#endif vec3 scattering = vec3(scattering_u >> 21, (scattering_u << 11) >> 21, scattering_u % 1024) / vec3(2047.0, 2047.0, 1023.0); scattering += params.base_scattering * params.base_density; +#ifdef MOLTENVK_USED + uint emission_u = emissive_only_map[lpos]; +#else uint emission_u = imageLoad(emissive_only_map, pos).x; +#endif vec3 emission = vec3(emission_u >> 21, (emission_u << 11) >> 21, emission_u % 1024) / vec3(511.0, 511.0, 255.0); emission += params.base_emission * params.base_density; @@ -673,10 +702,16 @@ void main() { final_density = mix(final_density, reprojected_density, reproject_amount); imageStore(density_map, pos, final_density); +#ifdef MOLTENVK_USED + density_only_map[lpos] = 0; + light_only_map[lpos] = 0; + emissive_only_map[lpos] = 0; +#else imageStore(density_only_map, pos, uvec4(0)); imageStore(light_only_map, pos, uvec4(0)); imageStore(emissive_only_map, pos, uvec4(0)); #endif +#endif #ifdef MODE_FOG diff --git a/servers/rendering/renderer_scene.h b/servers/rendering/renderer_scene.h index b6e99e4be5..02c845581c 100644 --- a/servers/rendering/renderer_scene.h +++ b/servers/rendering/renderer_scene.h @@ -191,7 +191,7 @@ public: 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, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) = 0; + virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) = 0; virtual void gi_set_use_half_resolution(bool p_enable) = 0; diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 7b4e2d34df..5b834db178 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -1313,7 +1313,7 @@ void RendererSceneCull::_update_instance_visibility_dependencies(Instance *p_ins bool needs_visibility_cull = has_visibility_range && is_geometry_instance && p_instance->array_index != -1; if (!needs_visibility_cull && p_instance->visibility_index != -1) { - p_instance->scenario->instance_visibility.remove(p_instance->visibility_index); + p_instance->scenario->instance_visibility.remove_at(p_instance->visibility_index); p_instance->visibility_index = -1; } else if (needs_visibility_cull && p_instance->visibility_index == -1) { InstanceVisibilityData vd; diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index 2bfcfd462c..e51a1fc02e 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -1155,7 +1155,7 @@ public: /* Render Buffers */ PASS0R(RID, render_buffers_create) - PASS8(render_buffers_configure, RID, RID, int, int, RS::ViewportMSAA, RS::ViewportScreenSpaceAA, bool, uint32_t) + PASS12(render_buffers_configure, RID, RID, int, int, int, int, float, float, RS::ViewportMSAA, RS::ViewportScreenSpaceAA, bool, uint32_t) PASS1(gi_set_use_half_resolution, bool) /* Shadow Atlas */ diff --git a/servers/rendering/renderer_scene_render.h b/servers/rendering/renderer_scene_render.h index 200ddc55d4..0d71ea22da 100644 --- a/servers/rendering/renderer_scene_render.h +++ b/servers/rendering/renderer_scene_render.h @@ -256,7 +256,7 @@ public: 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, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) = 0; + virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_internal_width, int p_internal_height, int p_width, int p_height, float p_fsr_sharpness, float p_fsr_mipmap_bias, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) = 0; virtual void gi_set_use_half_resolution(bool p_enable) = 0; virtual void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_limit) = 0; diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index c3d57a13ad..eddf5bf53d 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -77,18 +77,69 @@ void RendererViewport::_configure_3d_render_buffers(Viewport *p_viewport) { RSG::scene->free(p_viewport->render_buffers); p_viewport->render_buffers = RID(); } else { - float scale_3d = p_viewport->scale_3d; - if (Engine::get_singleton()->is_editor_hint()) { - // Ignore the 3D viewport render scaling inside of the editor. - // The Half Resolution 3D editor viewport option should be used instead. - scale_3d = 1.0; + float scaling_3d_scale = p_viewport->scaling_3d_scale; + + RS::ViewportScaling3DMode scaling_3d_mode = p_viewport->scaling_3d_mode; + bool scaling_enabled = true; + + if ((scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR) && (scaling_3d_scale > 1.0)) { + // FSR is not design for downsampling. + // Throw a warning and fallback to VIEWPORT_SCALING_3D_MODE_BILINEAR + WARN_PRINT_ONCE("FSR 3D resolution scaling does not support supersampling. Falling back to bilinear scaling."); + scaling_3d_mode = RS::VIEWPORT_SCALING_3D_MODE_BILINEAR; } - // Clamp 3D rendering resolution to reasonable values supported on most hardware. - // This prevents freezing the engine or outright crashing on lower-end GPUs. - const int width = CLAMP(p_viewport->size.width * scale_3d, 1, 16384); - const int height = CLAMP(p_viewport->size.height * scale_3d, 1, 16384); - RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, width, height, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_debanding, p_viewport->get_view_count()); + if ((scaling_3d_mode == RS::VIEWPORT_SCALING_3D_MODE_FSR) && !p_viewport->fsr_enabled) { + // FSR is not actually available. + // Throw a warning and fallback to disable scaling + WARN_PRINT_ONCE("FSR 3D resolution scaling is not available. Disabling 3D resolution scaling."); + scaling_enabled = false; + } + + if (scaling_3d_scale == 1.0) { + scaling_enabled = false; + } + + int width; + int height; + int render_width; + int render_height; + + if (scaling_enabled) { + switch (scaling_3d_mode) { + case RS::VIEWPORT_SCALING_3D_MODE_BILINEAR: + // Clamp 3D rendering resolution to reasonable values supported on most hardware. + // This prevents freezing the engine or outright crashing on lower-end GPUs. + width = CLAMP(p_viewport->size.width * scaling_3d_scale, 1, 16384); + height = CLAMP(p_viewport->size.height * scaling_3d_scale, 1, 16384); + render_width = width; + render_height = height; + break; + case RS::VIEWPORT_SCALING_3D_MODE_FSR: + width = p_viewport->size.width; + height = p_viewport->size.height; + render_width = MAX(width * scaling_3d_scale, 1.0); // width / (width * scaling) + render_height = MAX(height * scaling_3d_scale, 1.0); + break; + default: + // This is an unknown mode. + WARN_PRINT_ONCE(vformat("Unknown scaling mode: %d. Disabling 3D resolution scaling.", scaling_3d_mode)); + width = p_viewport->size.width; + height = p_viewport->size.height; + render_width = width; + render_height = height; + break; + } + } else { + width = p_viewport->size.width; + height = p_viewport->size.height; + render_width = width; + render_height = height; + } + + p_viewport->internal_size = Size2(render_width, render_height); + + RSG::scene->render_buffers_configure(p_viewport->render_buffers, p_viewport->render_target, render_width, render_height, width, height, p_viewport->fsr_sharpness, p_viewport->fsr_mipmap_bias, p_viewport->msaa, p_viewport->screen_space_aa, p_viewport->use_debanding, p_viewport->get_view_count()); } } } @@ -117,7 +168,7 @@ void RendererViewport::_draw_3d(Viewport *p_viewport) { } float screen_lod_threshold = p_viewport->lod_threshold / float(p_viewport->size.width); - RSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->self, p_viewport->size, screen_lod_threshold, p_viewport->shadow_atlas, xr_interface, &p_viewport->render_info); + RSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->self, p_viewport->internal_size, screen_lod_threshold, p_viewport->shadow_atlas, xr_interface, &p_viewport->render_info); RENDER_TIMESTAMP("<End Rendering 3D Scene"); } @@ -571,7 +622,7 @@ void RendererViewport::draw_viewports() { // override our size, make sure it matches our required size and is created as a stereo target vp->size = xr_interface->get_render_target_size(); uint32_t view_count = xr_interface->get_view_count(); - RSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y, view_count); + RSG::storage->render_target_set_size(vp->render_target, vp->internal_size.x, vp->internal_size.y, view_count); // check for an external texture destination (disabled for now, not yet supported) // RSG::storage->render_target_set_external_texture(vp->render_target, xr_interface->get_external_texture_for_eye(leftOrMono)); @@ -662,6 +713,8 @@ void RendererViewport::viewport_initialize(RID p_rid) { viewport->render_target = RSG::storage->render_target_create(); viewport->shadow_atlas = RSG::scene->shadow_atlas_create(); viewport->viewport_render_direct_to_screen = false; + + viewport->fsr_enabled = !RSG::rasterizer->is_low_end() && !viewport->disable_3d; } void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) { @@ -676,18 +729,42 @@ void RendererViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) { _configure_3d_render_buffers(viewport); } -void RendererViewport::viewport_set_scale_3d(RID p_viewport, float p_scale_3d) { +void RendererViewport::viewport_set_scaling_3d_mode(RID p_viewport, RS::ViewportScaling3DMode p_mode) { + Viewport *viewport = viewport_owner.get_or_null(p_viewport); + ERR_FAIL_COND(!viewport); + + viewport->scaling_3d_mode = p_mode; + _configure_3d_render_buffers(viewport); +} + +void RendererViewport::viewport_set_fsr_sharpness(RID p_viewport, float p_sharpness) { + Viewport *viewport = viewport_owner.get_or_null(p_viewport); + ERR_FAIL_COND(!viewport); + + viewport->fsr_sharpness = p_sharpness; + _configure_3d_render_buffers(viewport); +} + +void RendererViewport::viewport_set_fsr_mipmap_bias(RID p_viewport, float p_mipmap_bias) { + Viewport *viewport = viewport_owner.get_or_null(p_viewport); + ERR_FAIL_COND(!viewport); + + viewport->fsr_mipmap_bias = p_mipmap_bias; + _configure_3d_render_buffers(viewport); +} + +void RendererViewport::viewport_set_scaling_3d_scale(RID p_viewport, float p_scaling_3d_scale) { Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_COND(!viewport); // Clamp to reasonable values that are actually useful. // Values above 2.0 don't serve a practical purpose since the viewport // isn't displayed with mipmaps. - if (viewport->scale_3d == CLAMP(p_scale_3d, 0.1, 2.0)) { + if (viewport->scaling_3d_scale == CLAMP(p_scaling_3d_scale, 0.1, 2.0)) { return; } - viewport->scale_3d = CLAMP(p_scale_3d, 0.1, 2.0); + viewport->scaling_3d_scale = CLAMP(p_scaling_3d_scale, 0.1, 2.0); _configure_3d_render_buffers(viewport); } @@ -713,6 +790,7 @@ void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_heig ERR_FAIL_COND(!viewport); viewport->size = Size2(p_width, p_height); + uint32_t view_count = viewport->get_view_count(); RSG::storage->render_target_set_size(viewport->render_target, p_width, p_height, view_count); _configure_3d_render_buffers(viewport); @@ -765,7 +843,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_ // if render_direct_to_screen was used, reset size and position if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { 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->get_view_count()); + RSG::storage->render_target_set_size(viewport->render_target, viewport->internal_size.x, viewport->internal_size.y, viewport->get_view_count()); } viewport->viewport_to_screen_rect = Rect2(); diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h index f6e6cc8e84..5bb4dbbc6f 100644 --- a/servers/rendering/renderer_viewport.h +++ b/servers/rendering/renderer_viewport.h @@ -49,12 +49,16 @@ public: bool use_xr; /* use xr interface to override camera positioning and projection matrices and control output */ - float scale_3d = 1.0; - + Size2i internal_size; Size2i size; RID camera; RID scenario; + RS::ViewportScaling3DMode scaling_3d_mode; + float scaling_3d_scale = 1.0; + float fsr_sharpness = 0.2f; + float fsr_mipmap_bias = 0.0f; + bool fsr_enabled; RS::ViewportUpdateMode update_mode; RID render_target; RID render_target_texture; @@ -207,7 +211,6 @@ public: void viewport_initialize(RID p_rid); void viewport_set_use_xr(RID p_viewport, bool p_use_xr); - void viewport_set_scale_3d(RID p_viewport, float p_scale_3d); void viewport_set_size(RID p_viewport, int p_width, int p_height); @@ -216,6 +219,12 @@ 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_scaling_3d_mode(RID p_viewport, RS::ViewportScaling3DMode p_mode); + void viewport_set_scaling_3d_scale(RID p_viewport, float p_scaling_3d_scale); + void viewport_set_fsr_sharpness(RID p_viewport, float p_sharpness); + void viewport_set_fsr_mipmap_bias(RID p_viewport, float p_mipmap_bias); + void viewport_set_update_mode(RID p_viewport, RS::ViewportUpdateMode p_mode); void viewport_set_vflip(RID p_viewport, bool p_enable); diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index dcbc5f5c8e..5602bb197b 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -185,9 +185,13 @@ Ref<RDShaderSPIRV> RenderingDevice::_shader_compile_spirv_from_source(const Ref< String error; ShaderStage stage = ShaderStage(i); - Vector<uint8_t> spirv = shader_compile_spirv_from_source(stage, p_source->get_stage_source(stage), p_source->get_language(), &error, p_allow_cache); - bytecode->set_stage_bytecode(stage, spirv); - bytecode->set_stage_compile_error(stage, error); + String source = p_source->get_stage_source(stage); + + if (!source.is_empty()) { + Vector<uint8_t> spirv = shader_compile_spirv_from_source(stage, source, p_source->get_language(), &error, p_allow_cache); + bytecode->set_stage_bytecode(stage, spirv); + bytecode->set_stage_compile_error(stage, error); + } } return bytecode; } diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 5eb8f1cead..563a80c12c 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -120,6 +120,7 @@ public: // features bool supports_multiview = false; // If true this device supports multiview options + bool supports_fsr_half_float = false; // If true this device supports FSR scaling 3D in half float mode, otherwise use the fallback mode }; typedef String (*ShaderSPIRVGetCacheKeyFunction)(const Capabilities *p_capabilities); diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index f75bca600e..b50631bb21 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -528,7 +528,6 @@ public: FUNCRIDSPLIT(viewport) FUNC2(viewport_set_use_xr, RID, bool) - FUNC2(viewport_set_scale_3d, RID, float) FUNC3(viewport_set_size, RID, int, int) FUNC2(viewport_set_active, RID, bool) @@ -539,6 +538,11 @@ public: FUNC3(viewport_attach_to_screen, RID, const Rect2 &, int) FUNC2(viewport_set_render_direct_to_screen, RID, bool) + FUNC2(viewport_set_scaling_3d_mode, RID, ViewportScaling3DMode) + FUNC2(viewport_set_scaling_3d_scale, RID, float) + FUNC2(viewport_set_fsr_sharpness, RID, float) + FUNC2(viewport_set_fsr_mipmap_bias, RID, float) + FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode) FUNC1RC(RID, viewport_get_texture, RID) diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index f865aab677..f5e91d0423 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -88,7 +88,8 @@ String ShaderLanguage::get_operator_text(Operator p_op) { "--", "()", "construct", - "index" }; + "index", + "empty" }; return op_names[p_op]; } @@ -474,6 +475,10 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { case ':': return _make_token(TK_COLON); case '^': + if (GETCHAR(0) == '=') { + char_idx++; + return _make_token(TK_OP_ASSIGN_BIT_XOR); + } return _make_token(TK_OP_BIT_XOR); case '~': return _make_token(TK_OP_BIT_INVERT); @@ -4293,7 +4298,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_array_size(BlockNode *p_block, cons return n; } -Error ShaderLanguage::_parse_global_array_size(int &r_array_size) { +Error ShaderLanguage::_parse_global_array_size(int &r_array_size, const FunctionInfo &p_function_info) { if (r_array_size > 0) { _set_error("Array size is already defined!"); return ERR_PARSE_ERROR; @@ -4305,7 +4310,7 @@ Error ShaderLanguage::_parse_global_array_size(int &r_array_size) { if (tk.type != TK_INT_CONSTANT || ((int)tk.constant) <= 0) { _set_tkpos(pos); - Node *n = _parse_array_size(nullptr, FunctionInfo(), array_size); + Node *n = _parse_array_size(nullptr, p_function_info, array_size); if (!n) { return ERR_PARSE_ERROR; } @@ -5208,9 +5213,21 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons expression.push_back(e); continue; } else { - _set_error("Expected expression, found: " + get_token_text(tk)); - return nullptr; - //nothing + if (tk.type != TK_SEMICOLON) { + _set_error("Expected expression, found: " + get_token_text(tk)); + return nullptr; + } else { +#if DEBUG_ENABLED + if (check_warnings && HAS_WARNING(ShaderWarning::FORMATTING_ERROR_FLAG)) { + _add_line_warning(ShaderWarning::FORMATTING_ERROR, "Empty statement. Remove ';' to fix this warning."); + } +#endif // DEBUG_ENABLED + _set_tkpos(prepos); + + OperatorNode *func = alloc_node<OperatorNode>(); + func->op = OP_EMPTY; + expr = func; + } } ERR_FAIL_COND_V(!expr, nullptr); @@ -6073,7 +6090,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons _set_error("Invalid arguments to unary operator '" + get_operator_text(op->op) + "' :" + at); return nullptr; } - expression.remove(i + 1); + expression.remove_at(i + 1); } } else if (is_ternary) { @@ -6113,7 +6130,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } for (int i = 0; i < 4; i++) { - expression.remove(next_op); + expression.remove_at(next_op); } } else { @@ -6174,8 +6191,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons return nullptr; } - expression.remove(next_op); - expression.remove(next_op); + expression.remove_at(next_op); + expression.remove_at(next_op); } } @@ -6386,7 +6403,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun ArrayDeclarationNode::Declaration adecl; if (tk.type != TK_IDENTIFIER && tk.type != TK_BRACKET_OPEN) { - _set_error("Expected identifier or '[' after type."); + _set_error("Expected identifier or '[' after datatype."); return ERR_PARSE_ERROR; } @@ -7441,10 +7458,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct int texture_uniforms = 0; int texture_binding = 0; + int uniforms = 0; int instance_index = 0; ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL; stages = &p_functions; + const FunctionInfo &constants = p_functions.has("constants") ? p_functions["constants"] : FunctionInfo(); while (tk.type != TK_EOF) { switch (tk.type) { @@ -7488,7 +7507,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_IDENTIFIER) { st.name = tk.text; - if (shader->structs.has(st.name)) { + if (shader->constants.has(st.name) || shader->structs.has(st.name)) { _set_error("Redefinition of '" + String(st.name) + "'"); return ERR_PARSE_ERROR; } @@ -7560,7 +7579,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct int array_size = 0; if (tk.type == TK_BRACKET_OPEN) { - Error error = _parse_global_array_size(array_size); + Error error = _parse_global_array_size(array_size, constants); if (error != OK) { return error; } @@ -7587,7 +7606,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_BRACKET_OPEN) { - Error error = _parse_global_array_size(member->array_size); + Error error = _parse_global_array_size(member->array_size, constants); if (error != OK) { return error; } @@ -7714,7 +7733,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } if (tk.type == TK_BRACKET_OPEN) { - Error error = _parse_global_array_size(array_size); + Error error = _parse_global_array_size(array_size, constants); if (error != OK) { return error; } @@ -7729,7 +7748,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct prev_pos = _get_tkpos(); name = tk.text; - if (_find_identifier(nullptr, false, FunctionInfo(), name)) { + if (_find_identifier(nullptr, false, constants, name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -7762,7 +7781,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_BRACKET_OPEN) { - Error error = _parse_global_array_size(uniform2.array_size); + Error error = _parse_global_array_size(uniform2.array_size, constants); if (error != OK) { return error; } @@ -7791,6 +7810,9 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } uniform2.texture_order = -1; + if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) { + uniform2.order = uniforms++; + } } if (uniform2.array_size > 0) { @@ -8013,7 +8035,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } - Node *expr = _parse_and_reduce_expression(nullptr, FunctionInfo()); + Node *expr = _parse_and_reduce_expression(nullptr, constants); if (!expr) { return ERR_PARSE_ERROR; } @@ -8109,7 +8131,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct DataPrecision precision = PRECISION_DEFAULT; DataType type; StringName name; - int return_array_size = 0; + int array_size = 0; if (tk.type == TK_CONST) { is_constant = true; @@ -8148,13 +8170,19 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct prev_pos = _get_tkpos(); tk = _get_token(); + bool unknown_size = false; + if (tk.type == TK_BRACKET_OPEN) { + if (is_constant && RenderingServer::get_singleton()->is_low_end()) { + _set_error("Global const arrays are only supported on high-end platform!"); + return ERR_PARSE_ERROR; + } bool error = false; tk = _get_token(); if (tk.type == TK_INT_CONSTANT) { - return_array_size = (int)tk.constant; - if (return_array_size > 0) { + array_size = (int)tk.constant; + if (array_size > 0) { tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); @@ -8163,11 +8191,13 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } else { error = true; } + } else if (tk.type == TK_BRACKET_CLOSE) { + unknown_size = true; } else { error = true; } if (error) { - _set_error("Expected integer constant > 0"); + _set_error("Expected integer constant > 0 or ']'"); return ERR_PARSE_ERROR; } @@ -8179,16 +8209,15 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct _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(nullptr, false, FunctionInfo(), name)) { - _set_error("Redefinition of '" + String(name) + "'"); + if (is_constant) { + _set_error("Expected identifier or '[' after datatype."); + } else { + _set_error("Expected function name after datatype."); + } return ERR_PARSE_ERROR; } - if (has_builtin(p_functions, name)) { + if (shader->structs.has(name) || _find_identifier(nullptr, false, constants, name) || has_builtin(p_functions, name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -8201,7 +8230,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } //variable - + bool first = true; while (true) { ShaderNode::Constant constant; constant.name = name; @@ -8209,16 +8238,18 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct constant.type_str = struct_name; constant.precision = precision; constant.initializer = nullptr; - constant.array_size = 0; - - bool unknown_size = false; + constant.array_size = (first ? array_size : 0); + first = false; if (tk.type == TK_BRACKET_OPEN) { if (RenderingServer::get_singleton()->is_low_end()) { - _set_error("Global const arrays are supported only on high-end platform!"); + _set_error("Global const arrays are only supported on high-end platform!"); + return ERR_PARSE_ERROR; + } + if (constant.array_size > 0 || unknown_size) { + _set_error("Array size is already defined!"); return ERR_PARSE_ERROR; } - tk = _get_token(); if (tk.type == TK_BRACKET_CLOSE) { unknown_size = true; @@ -8296,7 +8327,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } else { _set_tkpos(prev_pos); - Node *n = _parse_and_reduce_expression(nullptr, FunctionInfo()); + Node *n = _parse_and_reduce_expression(nullptr, constants); if (!n || n->type != Node::TYPE_CONSTANT || n->get_datatype() != TYPE_INT) { _set_error("Expected single integer constant > 0"); return ERR_PARSE_ERROR; @@ -8377,7 +8408,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct if (tk.type == TK_PARENTHESIS_OPEN || curly) { // initialization while (true) { - Node *n = _parse_and_reduce_expression(nullptr, FunctionInfo()); + Node *n = _parse_and_reduce_expression(nullptr, constants); if (!n) { return ERR_PARSE_ERROR; } @@ -8432,7 +8463,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct constant.initializer = static_cast<ConstantNode *>(expr); } else { //variable created with assignment! must parse an expression - Node *expr = _parse_and_reduce_expression(nullptr, FunctionInfo()); + Node *expr = _parse_and_reduce_expression(nullptr, constants); if (!expr) { return ERR_PARSE_ERROR; } @@ -8448,7 +8479,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct constant.initializer = static_cast<ConstantNode *>(expr); - if (!_compare_datatypes(type, struct_name, 0, expr->get_datatype(), expr->get_datatype_name(), 0)) { + if (!_compare_datatypes(type, struct_name, 0, expr->get_datatype(), expr->get_datatype_name(), expr->get_array_size())) { return ERR_PARSE_ERROR; } } @@ -8479,7 +8510,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } name = tk.text; - if (_find_identifier(nullptr, false, FunctionInfo(), name)) { + if (_find_identifier(nullptr, false, constants, name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } @@ -8513,6 +8544,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } } + if (p_functions.has("constants")) { // Adds global constants: 'PI', 'TAU', 'E' + for (const KeyValue<StringName, BuiltInInfo> &E : p_functions["constants"].built_ins) { + builtins.built_ins.insert(E.key, E.value); + } + } + ShaderNode::Function function; function.callable = !p_functions.has(name); @@ -8528,7 +8565,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct func_node->return_type = type; func_node->return_struct_name = struct_name; func_node->return_precision = precision; - func_node->return_array_size = return_array_size; + func_node->return_array_size = array_size; if (p_functions.has(name)) { func_node->can_discard = p_functions[name].can_discard; @@ -8582,7 +8619,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct StringName param_struct_name; DataPrecision pprecision = PRECISION_DEFAULT; bool use_precision = false; - int array_size = 0; + int arg_array_size = 0; if (is_token_precision(tk.type)) { pprecision = get_token_precision(tk.type); @@ -8633,9 +8670,9 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_INT_CONSTANT) { - array_size = (int)tk.constant; + arg_array_size = (int)tk.constant; - if (array_size > 0) { + if (arg_array_size > 0) { tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); @@ -8687,7 +8724,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_BRACKET_OPEN) { - if (array_size > 0) { + if (arg_array_size > 0) { _set_error("Array size is already defined!"); return ERR_PARSE_ERROR; } @@ -8695,9 +8732,9 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_INT_CONSTANT) { - array_size = (int)tk.constant; + arg_array_size = (int)tk.constant; - if (array_size > 0) { + if (arg_array_size > 0) { tk = _get_token(); if (tk.type != TK_BRACKET_CLOSE) { _set_error("Expected ']'"); @@ -8717,7 +8754,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); } - arg.array_size = array_size; + arg.array_size = arg_array_size; func_node->arguments.push_back(arg); if (tk.type == TK_COMMA) { @@ -8769,20 +8806,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); } - int uniforms = 0; - - // Need to push arrays to first place in a uniform buffer in order to correct work. - for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { - if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size > 0) { - E->get().order = uniforms++; - } - } - for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { - if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size == 0) { - E->get().order = uniforms++; - } - } - int error_line; String error_message; if (!_check_varying_usages(&error_line, &error_message)) { @@ -9077,6 +9100,16 @@ Error ShaderLanguage::complete(const String &p_code, const Map<StringName, Funct } } + if (p_functions.has("constants")) { + for (const KeyValue<StringName, BuiltInInfo> &E : p_functions["constants"].built_ins) { + ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; + if (E.value.constant) { + kind = ScriptCodeCompletionOption::KIND_CONSTANT; + } + matches.insert(E.key, kind); + } + } + if (skip_function != StringName() && p_functions.has(skip_function)) { for (const KeyValue<StringName, BuiltInInfo> &E : p_functions[skip_function].built_ins) { ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_MEMBER; diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index c82f71d10d..3de89a89a5 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -287,6 +287,7 @@ public: OP_CONSTRUCT, OP_STRUCT, OP_INDEX, + OP_EMPTY, OP_MAX }; @@ -989,7 +990,7 @@ private: bool _check_node_constness(const Node *p_node) const; Node *_parse_array_size(BlockNode *p_block, const FunctionInfo &p_function_info, int &r_array_size); - Error _parse_global_array_size(int &r_array_size); + Error _parse_global_array_size(int &r_array_size, const FunctionInfo &p_function_info); Error _parse_local_array_size(BlockNode *p_block, const FunctionInfo &p_function_info, ArrayDeclarationNode *p_node, ArrayDeclarationNode::Declaration *p_decl, int &r_array_size, bool &r_is_unknown_size); Node *_parse_expression(BlockNode *p_block, const FunctionInfo &p_function_info); diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp index eb5c9e66e8..359196e096 100644 --- a/servers/rendering/shader_types.cpp +++ b/servers/rendering/shader_types.cpp @@ -59,9 +59,9 @@ ShaderTypes::ShaderTypes() { /*************** SPATIAL ***********************/ shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_SPATIAL].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SPATIAL].functions["constants"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SPATIAL].functions["constants"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SPATIAL].functions["constants"].built_ins["E"] = 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; @@ -241,9 +241,9 @@ ShaderTypes::ShaderTypes() { /************ CANVAS ITEM **************************/ shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_CANVAS_ITEM].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["constants"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["constants"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_CANVAS_ITEM].functions["constants"].built_ins["E"] = 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; @@ -334,9 +334,9 @@ ShaderTypes::ShaderTypes() { /************ PARTICLES **************************/ shader_modes[RS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_PARTICLES].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_PARTICLES].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_PARTICLES].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_PARTICLES].functions["constants"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_PARTICLES].functions["constants"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_PARTICLES].functions["constants"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[RS::SHADER_PARTICLES].functions["start"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; shader_modes[RS::SHADER_PARTICLES].functions["start"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3; @@ -367,7 +367,7 @@ ShaderTypes::ShaderTypes() { shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["LIFETIME"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["DELTA"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["NUMBER"] = constt(ShaderLanguage::TYPE_UINT); - shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["INDEX"] = constt(ShaderLanguage::TYPE_INT); + shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["INDEX"] = constt(ShaderLanguage::TYPE_UINT); shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["EMISSION_TRANSFORM"] = constt(ShaderLanguage::TYPE_MAT4); shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["RANDOM_SEED"] = constt(ShaderLanguage::TYPE_UINT); shader_modes[RS::SHADER_PARTICLES].functions["process"].built_ins["FLAG_EMIT_POSITION"] = constt(ShaderLanguage::TYPE_UINT); @@ -400,9 +400,9 @@ ShaderTypes::ShaderTypes() { /************ SKY **************************/ shader_modes[RS::SHADER_SKY].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_SKY].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_SKY].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_SKY].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["constants"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["constants"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_SKY].functions["constants"].built_ins["E"] = 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); @@ -446,9 +446,9 @@ ShaderTypes::ShaderTypes() { /************ FOG **************************/ shader_modes[RS::SHADER_FOG].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_FOG].functions["global"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_FOG].functions["global"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); - shader_modes[RS::SHADER_FOG].functions["global"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_FOG].functions["constants"].built_ins["PI"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_FOG].functions["constants"].built_ins["TAU"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[RS::SHADER_FOG].functions["constants"].built_ins["E"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["WORLD_POSITION"] = constt(ShaderLanguage::TYPE_VEC3); shader_modes[RS::SHADER_FOG].functions["fog"].built_ins["OBJECT_POSITION"] = constt(ShaderLanguage::TYPE_VEC3); diff --git a/servers/rendering/shader_warnings.cpp b/servers/rendering/shader_warnings.cpp index 0b8476478c..bffae484a8 100644 --- a/servers/rendering/shader_warnings.cpp +++ b/servers/rendering/shader_warnings.cpp @@ -61,6 +61,8 @@ String ShaderWarning::get_message() const { return vformat("The varying '%s' is declared but never used.", subject); case UNUSED_LOCAL_VARIABLE: return vformat("The local variable '%s' is declared but never used.", subject); + case FORMATTING_ERROR: + return subject; default: break; } @@ -82,6 +84,7 @@ String ShaderWarning::get_name_from_code(Code p_code) { "UNUSED_UNIFORM", "UNUSED_VARYING", "UNUSED_LOCAL_VARIABLE", + "FORMATTING_ERROR", }; static_assert((sizeof(names) / sizeof(*names)) == WARNING_MAX, "Amount of warning types don't match the amount of warning names."); @@ -110,6 +113,7 @@ static void init_code_to_flags_map() { code_to_flags_map->insert(ShaderWarning::UNUSED_UNIFORM, ShaderWarning::UNUSED_UNIFORM_FLAG); code_to_flags_map->insert(ShaderWarning::UNUSED_VARYING, ShaderWarning::UNUSED_VARYING_FLAG); code_to_flags_map->insert(ShaderWarning::UNUSED_LOCAL_VARIABLE, ShaderWarning::UNUSED_LOCAL_VARIABLE_FLAG); + code_to_flags_map->insert(ShaderWarning::FORMATTING_ERROR, ShaderWarning::FORMATTING_ERROR_FLAG); } ShaderWarning::CodeFlags ShaderWarning::get_flags_from_codemap(const Map<Code, bool> &p_map) { diff --git a/servers/rendering/shader_warnings.h b/servers/rendering/shader_warnings.h index db872d8fb1..18915fffd8 100644 --- a/servers/rendering/shader_warnings.h +++ b/servers/rendering/shader_warnings.h @@ -47,6 +47,7 @@ public: UNUSED_UNIFORM, UNUSED_VARYING, UNUSED_LOCAL_VARIABLE, + FORMATTING_ERROR, WARNING_MAX, }; @@ -59,6 +60,7 @@ public: UNUSED_UNIFORM_FLAG = 16U, UNUSED_VARYING_FLAG = 32U, UNUSED_LOCAL_VARIABLE_FLAG = 64U, + FORMATTING_ERROR_FLAG = 128U, }; private: diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index ae72f47a44..a23911e81a 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -199,11 +199,11 @@ RID RenderingServer::_make_test_cube() { normal_points[j][i % 3] = (i >= 3 ? -1 : 1); } - //tri 1 + // Tri 1 ADD_VTX(0); ADD_VTX(1); ADD_VTX(2); - //tri 2 + // Tri 2 ADD_VTX(2); ADD_VTX(3); ADD_VTX(0); @@ -317,9 +317,6 @@ RID RenderingServer::get_white_texture() { return white_texture; } -#define SMALL_VEC2 Vector2(0.00001, 0.00001) -#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001) - Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_vertex_stride, uint32_t p_attrib_stride, uint32_t p_skin_stride, Vector<uint8_t> &r_vertex_array, Vector<uint8_t> &r_attrib_array, Vector<uint8_t> &r_skin_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 *aw = r_attrib_array.ptrw(); @@ -333,7 +330,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint int max_bone = 0; for (int ai = 0; ai < RS::ARRAY_MAX; ai++) { - if (!(p_format & (1 << ai))) { // no array + if (!(p_format & (1 << ai))) { // No array continue; } @@ -345,7 +342,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint const Vector2 *src = array.ptr(); - // setting vertices means regenerating the AABB + // Setting vertices means regenerating the AABB. Rect2 aabb; { @@ -355,7 +352,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint memcpy(&vw[p_offsets[ai] + i * p_vertex_stride], vector, sizeof(float) * 2); if (i == 0) { - aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size + aabb = Rect2(src[i], SMALL_VEC2); // Must have a bit of size. } else { aabb.expand_to(src[i]); } @@ -370,7 +367,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint const Vector3 *src = array.ptr(); - // setting vertices means regenerating the AABB + // Setting vertices means regenerating the AABB. AABB aabb; { @@ -505,7 +502,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint case ARRAY_CUSTOM_RGBA8_UNORM: case ARRAY_CUSTOM_RGBA8_SNORM: case ARRAY_CUSTOM_RG_HALF: { - //size 4 + // Size 4 ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER); Vector<uint8_t> array = p_arrays[ai]; @@ -520,7 +517,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint } break; case ARRAY_CUSTOM_RGBA_HALF: { - //size 8 + // Size 8 ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_BYTE_ARRAY, ERR_INVALID_PARAMETER); Vector<uint8_t> array = p_arrays[ai]; @@ -537,7 +534,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint case ARRAY_CUSTOM_RG_FLOAT: case ARRAY_CUSTOM_RGB_FLOAT: case ARRAY_CUSTOM_RGBA_FLOAT: { - //RF + // RF ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::PACKED_FLOAT32_ARRAY, ERR_INVALID_PARAMETER); Vector<float> array = p_arrays[ai]; @@ -646,7 +643,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint } if (p_format & RS::ARRAY_FORMAT_BONES) { - //create AABBs for each detected bone + // Create AABBs for each detected bone. int total_bones = max_bone + 1; bool first = r_bone_aabb.size() == 0; @@ -657,7 +654,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint if (first) { for (int i = 0; i < total_bones; i++) { - r_bone_aabb.write[i].size = Vector3(-1, -1, -1); //negative means unused + r_bone_aabb.write[i].size = Vector3(-1, -1, -1); // Negative means unused. } } @@ -686,7 +683,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA); if (bptr[idx].size.x < 0) { - //first + // First bptr[idx] = AABB(v, SMALL_VEC3); any_valid = true; } else { @@ -749,7 +746,7 @@ void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, i uint32_t *size_accum; for (int i = 0; i < RS::ARRAY_MAX; i++) { - r_offsets[i] = 0; //reset + r_offsets[i] = 0; // Reset if (i == RS::ARRAY_VERTEX) { size_accum = &r_vertex_element_size; @@ -759,7 +756,7 @@ void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, i size_accum = &r_skin_element_size; } - if (!(p_format & (1 << i))) { // no array + if (!(p_format & (1 << i))) { // No array continue; } @@ -873,7 +870,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa uint32_t format = 0; - // validation + // Validation int index_array_len = 0; int array_len = 0; @@ -921,10 +918,10 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa } } - ERR_FAIL_COND_V((format & RS::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 + // Validate format for morphs. for (int i = 0; i < p_blend_shapes.size(); i++) { uint32_t bsformat = 0; Array arr = p_blend_shapes[i]; @@ -939,7 +936,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa } for (uint32_t i = 0; i < RS::ARRAY_CUSTOM_COUNT; ++i) { - // include custom array format type. + // Include custom array format type. if (format & (1 << (ARRAY_CUSTOM0 + i))) { format |= (RS::ARRAY_FORMAT_CUSTOM_MASK << (RS::ARRAY_FORMAT_CUSTOM_BASE + i * RS::ARRAY_FORMAT_CUSTOM_BITS)) & p_compress_format; } @@ -954,7 +951,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa mesh_surface_make_offsets_from_format(format, array_len, index_array_len, offsets, vertex_element_size, attrib_element_size, skin_element_size); uint32_t mask = (1 << ARRAY_MAX) - 1; - format |= (~mask) & p_compress_format; //make the full format + format |= (~mask) & p_compress_format; // Make the full format. int vertex_array_size = vertex_element_size * array_len; int attrib_array_size = attrib_element_size * array_len; @@ -1010,13 +1007,13 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa Vector<int> indices = p_lods[E]; ERR_CONTINUE(indices.size() == 0); uint32_t index_count = indices.size(); - ERR_CONTINUE(index_count >= (uint32_t)index_array_len); //should be smaller.. + ERR_CONTINUE(index_count >= (uint32_t)index_array_len); // Should be smaller.. const int *r = indices.ptr(); Vector<uint8_t> data; if (array_len <= 65536) { - //16 bits indices + // 16 bits indices data.resize(indices.size() * 2); uint8_t *w = data.ptrw(); uint16_t *index_ptr = (uint16_t *)w; @@ -1024,7 +1021,7 @@ Error RenderingServer::mesh_create_surface_data_from_arrays(SurfaceData *r_surfa index_ptr[i] = r[i]; } } else { - //32 bits indices + // 32 bits indices data.resize(indices.size() * 4); uint8_t *w = data.ptrw(); uint32_t *index_ptr = (uint32_t *)w; @@ -1204,7 +1201,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t case ARRAY_CUSTOM_RGBA8_SNORM: case ARRAY_CUSTOM_RG_HALF: case ARRAY_CUSTOM_RGBA_HALF: { - //size 4 + // Size 4 int s = type == ARRAY_CUSTOM_RGBA_HALF ? 8 : 4; Vector<uint8_t> arr; arr.resize(p_vertex_len * s); @@ -1472,12 +1469,12 @@ ShaderLanguage::DataType RenderingServer::global_variable_type_get_shader_dataty case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: return ShaderLanguage::TYPE_SAMPLERCUBE; default: - return ShaderLanguage::TYPE_MAX; //invalid or not found + return ShaderLanguage::TYPE_MAX; // Invalid or not found. } } RenderingDevice *RenderingServer::get_rendering_device() const { - // return the rendering device we're using globally + // Return the rendering device we're using globally. return RenderingDevice::get_singleton(); } @@ -2165,13 +2162,16 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create); ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr); - ClassDB::bind_method(D_METHOD("viewport_set_scale_3d", "viewport", "scale"), &RenderingServer::viewport_set_scale_3d); 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_scaling_3d_mode", "viewport", "scaling_3d_mode"), &RenderingServer::viewport_set_scaling_3d_mode); + ClassDB::bind_method(D_METHOD("viewport_set_scaling_3d_scale", "viewport", "scale"), &RenderingServer::viewport_set_scaling_3d_scale); + ClassDB::bind_method(D_METHOD("viewport_set_fsr_sharpness", "viewport", "sharpness"), &RenderingServer::viewport_set_fsr_sharpness); + ClassDB::bind_method(D_METHOD("viewport_set_fsr_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_fsr_mipmap_bias); 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); @@ -2213,9 +2213,13 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("viewport_get_measured_render_time_gpu", "viewport"), &RenderingServer::viewport_get_measured_render_time_gpu); + BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_BILINEAR); + BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_FSR); + BIND_ENUM_CONSTANT(VIEWPORT_SCALING_3D_MODE_MAX); + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_DISABLED); - BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); //then goes to disabled); must be manually updated - BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); // default + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ONCE); // Then goes to disabled); must be manually updated. + BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_VISIBLE); // Default BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE); BIND_ENUM_CONSTANT(VIEWPORT_UPDATE_ALWAYS); @@ -2546,7 +2550,8 @@ void RenderingServer::_bind_methods() { 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); - //primitives + + /* Primitives */ ClassDB::bind_method(D_METHOD("canvas_item_add_line", "item", "from", "to", "color", "width"), &RenderingServer::canvas_item_add_line, DEFVAL(1.0)); ClassDB::bind_method(D_METHOD("canvas_item_add_polyline", "item", "points", "colors", "width", "antialiased"), &RenderingServer::canvas_item_add_polyline, DEFVAL(1.0), DEFVAL(false)); @@ -2697,7 +2702,7 @@ void RenderingServer::_bind_methods() { BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_MAX); /* Free */ - ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free); // shouldn't conflict with Object::free() + ClassDB::bind_method(D_METHOD("free_rid", "rid"), &RenderingServer::free); // Shouldn't conflict with Object::free(). /* Misc */ @@ -2837,12 +2842,6 @@ RenderingServer::RenderingServer() { GLOBAL_DEF("rendering/vulkan/staging_buffer/texture_upload_region_size_px", 64); GLOBAL_DEF("rendering/vulkan/descriptor_pools/max_descriptors_per_pool", 64); - GLOBAL_DEF("rendering/3d/viewport/scale", 1.0); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/3d/viewport/scale", - PropertyInfo(Variant::FLOAT, - "rendering/3d/viewport/scale", - PROPERTY_HINT_RANGE, "0.25,2.0,0.01")); - GLOBAL_DEF("rendering/shader_compiler/shader_cache/enabled", true); GLOBAL_DEF("rendering/shader_compiler/shader_cache/compress", true); GLOBAL_DEF("rendering/shader_compiler/shader_cache/use_zstd_compression", true); @@ -2903,6 +2902,29 @@ RenderingServer::RenderingServer() { ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/screen_space_roughness_limiter/amount", PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/amount", PROPERTY_HINT_RANGE, "0.01,4.0,0.01")); ProjectSettings::get_singleton()->set_custom_property_info("rendering/anti_aliasing/screen_space_roughness_limiter/limit", PropertyInfo(Variant::FLOAT, "rendering/anti_aliasing/screen_space_roughness_limiter/limit", PROPERTY_HINT_RANGE, "0.01,1.0,0.01")); + GLOBAL_DEF_RST("rendering/scaling_3d/mode", 0); + GLOBAL_DEF_RST("rendering/scaling_3d/scale", 1.0); + GLOBAL_DEF_RST("rendering/scaling_3d/fsr_sharpness", 0.2f); + GLOBAL_DEF_RST("rendering/scaling_3d/fsr_mipmap_bias", 0.0f); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/scaling_3d/mode", + PropertyInfo(Variant::INT, + "rendering/scaling_3d/mode", + PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR (Fast)")); + + ProjectSettings::get_singleton()->set_custom_property_info("rendering/scaling_3d/scale", + PropertyInfo(Variant::FLOAT, + "rendering/scaling_3d/scale", + PROPERTY_HINT_RANGE, "0.25,2.0,0.01")); + + ProjectSettings::get_singleton()->set_custom_property_info("rendering/scaling_3d/fsr_sharpness", + PropertyInfo(Variant::FLOAT, + "rendering/scaling_3d/fsr_sharpness", + PROPERTY_HINT_RANGE, "0,2,0.1")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/scaling_3d/fsr_mipmap_bias", + PropertyInfo(Variant::FLOAT, + "rendering/scaling_3d/fsr_mipmap_bias", + PROPERTY_HINT_RANGE, "-2,2,0.1")); + GLOBAL_DEF("rendering/textures/decals/filter", DECAL_FILTER_LINEAR_MIPMAPS); ProjectSettings::get_singleton()->set_custom_property_info("rendering/textures/decals/filter", PropertyInfo(Variant::INT, "rendering/textures/decals/filter", PROPERTY_HINT_ENUM, "Nearest (Fast),Nearest+Mipmaps,Linear,Linear+Mipmaps,Linear+Mipmaps Anisotropic (Slow)")); GLOBAL_DEF("rendering/textures/light_projectors/filter", LIGHT_PROJECTOR_FILTER_LINEAR_MIPMAPS); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 32ec0197ee..230132651f 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -55,6 +55,9 @@ class RenderingServer : public Object { RendererThreadPool *thread_pool = nullptr; + const Vector2 SMALL_VEC2 = Vector2(CMP_EPSILON, CMP_EPSILON); + const Vector3 SMALL_VEC3 = Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON); + protected: RID _make_test_cube(); void _free_internal_rids(); @@ -108,7 +111,7 @@ public: virtual void texture_3d_update(RID p_texture, const Vector<Ref<Image>> &p_data) = 0; virtual void texture_proxy_update(RID p_texture, RID p_proxy_to) = 0; - //these two APIs can be used together or in combination with the others. + // These two APIs can be used together or in combination with the others. virtual RID texture_2d_placeholder_create() = 0; virtual RID texture_2d_layered_placeholder_create(TextureLayeredType p_layered_type) = 0; virtual RID texture_3d_placeholder_create() = 0; @@ -210,18 +213,18 @@ public: enum ArrayType { ARRAY_VERTEX = 0, // RG32F or RGB32F (depending on 2D bit) - ARRAY_NORMAL = 1, // A2B10G10R10, A is ignored - ARRAY_TANGENT = 2, // A2B10G10R10, A flips sign of binormal + ARRAY_NORMAL = 1, // A2B10G10R10, A is ignored. + ARRAY_TANGENT = 2, // A2B10G10R10, A flips sign of binormal. ARRAY_COLOR = 3, // RGBA8 ARRAY_TEX_UV = 4, // RG32F ARRAY_TEX_UV2 = 5, // RG32F - ARRAY_CUSTOM0 = 6, // depends on ArrayCustomFormat + ARRAY_CUSTOM0 = 6, // Depends on ArrayCustomFormat. ARRAY_CUSTOM1 = 7, ARRAY_CUSTOM2 = 8, ARRAY_CUSTOM3 = 9, ARRAY_BONES = 10, // RGBA16UI (x2 if 8 weights) ARRAY_WEIGHTS = 11, // RGBA16UNORM (x2 if 8 weights) - ARRAY_INDEX = 12, // 16 or 32 bits depending on length > 0xFFFF + ARRAY_INDEX = 12, // 16 or 32 bits depending on length > 0xFFFF. ARRAY_MAX = 13 }; @@ -243,7 +246,7 @@ public: enum ArrayFormat { /* ARRAY FORMAT FLAGS */ - ARRAY_FORMAT_VERTEX = 1 << ARRAY_VERTEX, // mandatory + ARRAY_FORMAT_VERTEX = 1 << ARRAY_VERTEX, // Mandatory ARRAY_FORMAT_NORMAL = 1 << ARRAY_NORMAL, ARRAY_FORMAT_TANGENT = 1 << ARRAY_TANGENT, ARRAY_FORMAT_COLOR = 1 << ARRAY_COLOR, @@ -287,9 +290,9 @@ public: PrimitiveType primitive = PRIMITIVE_MAX; uint32_t format = 0; - Vector<uint8_t> vertex_data; // vertex, normal, tangent (change with skinning, blendshape) - Vector<uint8_t> attribute_data; // color,uv, uv2, custom0-3 - Vector<uint8_t> skin_data; // bone index, bone weight + Vector<uint8_t> vertex_data; // Vertex, Normal, Tangent (change with skinning, blendshape). + Vector<uint8_t> attribute_data; // Color, UV, UV2, Custom0-3. + Vector<uint8_t> skin_data; // Bone index, Bone weight. uint32_t vertex_count = 0; Vector<uint8_t> index_data; uint32_t index_count = 0; @@ -452,7 +455,7 @@ public: virtual void light_set_bake_mode(RID p_light, LightBakeMode p_bake_mode) = 0; virtual void light_set_max_sdfgi_cascade(RID p_light, uint32_t p_cascade) = 0; - // omni light + // Omni light enum LightOmniShadowMode { LIGHT_OMNI_SHADOW_DUAL_PARABOLOID, LIGHT_OMNI_SHADOW_CUBE, @@ -460,7 +463,7 @@ public: virtual void light_omni_set_shadow_mode(RID p_light, LightOmniShadowMode p_mode) = 0; - // directional light + // Directional light enum LightDirectionalShadowMode { LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL, LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS, @@ -671,7 +674,7 @@ public: virtual AABB particles_get_current_aabb(RID p_particles) = 0; - virtual void particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) = 0; //this is only used for 2D, in 3D it's automatic + virtual void particles_set_emission_transform(RID p_particles, const Transform3D &p_transform) = 0; // This is only used for 2D, in 3D it's automatic. /* PARTICLES COLLISION API */ @@ -689,16 +692,16 @@ public: virtual void particles_collision_set_collision_type(RID p_particles_collision, ParticlesCollisionType p_type) = 0; virtual void particles_collision_set_cull_mask(RID p_particles_collision, uint32_t p_cull_mask) = 0; - virtual void particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) = 0; //for spheres - virtual void particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) = 0; //for non-spheres + virtual void particles_collision_set_sphere_radius(RID p_particles_collision, real_t p_radius) = 0; // For spheres. + virtual void particles_collision_set_box_extents(RID p_particles_collision, const Vector3 &p_extents) = 0; // For non-spheres. virtual void particles_collision_set_attractor_strength(RID p_particles_collision, real_t p_strength) = 0; virtual void particles_collision_set_attractor_directionality(RID p_particles_collision, real_t p_directionality) = 0; virtual void particles_collision_set_attractor_attenuation(RID p_particles_collision, real_t p_curve) = 0; - virtual void particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) = 0; //for SDF and vector field, heightfield is dynamic + virtual void particles_collision_set_field_texture(RID p_particles_collision, RID p_texture) = 0; // For SDF and vector field, heightfield is dynamic. - virtual void particles_collision_height_field_update(RID p_particles_collision) = 0; //for SDF and vector field + virtual void particles_collision_height_field_update(RID p_particles_collision) = 0; // For SDF and vector field. - enum ParticlesCollisionHeightfieldResolution { //longest axis resolution + enum ParticlesCollisionHeightfieldResolution { // Longest axis resolution. PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_256, PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_512, PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_1024, @@ -708,7 +711,7 @@ public: PARTICLES_COLLISION_HEIGHTFIELD_RESOLUTION_MAX, }; - virtual void particles_collision_set_height_field_resolution(RID p_particles_collision, ParticlesCollisionHeightfieldResolution p_resolution) = 0; //for SDF and vector field + virtual void particles_collision_set_height_field_resolution(RID p_particles_collision, ParticlesCollisionHeightfieldResolution p_resolution) = 0; // For SDF and vector field. /* FOG VOLUME API */ @@ -750,7 +753,7 @@ public: /* VIEWPORT API */ enum CanvasItemTextureFilter { - CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, //uses canvas item setting for draw command, uses global setting for canvas item + CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, // Uses canvas item setting for draw command, uses global setting for canvas item. CANVAS_ITEM_TEXTURE_FILTER_NEAREST, CANVAS_ITEM_TEXTURE_FILTER_LINEAR, CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, @@ -761,7 +764,7 @@ public: }; enum CanvasItemTextureRepeat { - CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, //uses canvas item setting for draw command, uses global setting for canvas item + CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, // Uses canvas item setting for draw command, uses global setting for canvas item. CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, CANVAS_ITEM_TEXTURE_REPEAT_MIRROR, @@ -770,8 +773,13 @@ public: virtual RID viewport_create() = 0; + enum ViewportScaling3DMode { + VIEWPORT_SCALING_3D_MODE_BILINEAR, + VIEWPORT_SCALING_3D_MODE_FSR, + VIEWPORT_SCALING_3D_MODE_MAX + }; + virtual void viewport_set_use_xr(RID p_viewport, bool p_use_xr) = 0; - virtual void viewport_set_scale_3d(RID p_viewport, float p_scale_3d) = 0; virtual void viewport_set_size(RID p_viewport, int p_width, int p_height) = 0; virtual void viewport_set_active(RID p_viewport, bool p_active) = 0; virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0; @@ -779,10 +787,15 @@ public: virtual void viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect = Rect2(), DisplayServer::WindowID p_screen = DisplayServer::MAIN_WINDOW_ID) = 0; virtual void viewport_set_render_direct_to_screen(RID p_viewport, bool p_enable) = 0; + virtual void viewport_set_scaling_3d_mode(RID p_viewport, ViewportScaling3DMode p_scaling_3d_mode) = 0; + virtual void viewport_set_scaling_3d_scale(RID p_viewport, float p_scaling_3d_scale) = 0; + virtual void viewport_set_fsr_sharpness(RID p_viewport, float p_fsr_sharpness) = 0; + virtual void viewport_set_fsr_mipmap_bias(RID p_viewport, float p_fsr_mipmap_bias) = 0; + enum ViewportUpdateMode { VIEWPORT_UPDATE_DISABLED, - VIEWPORT_UPDATE_ONCE, //then goes to disabled, must be manually updated - VIEWPORT_UPDATE_WHEN_VISIBLE, // default + VIEWPORT_UPDATE_ONCE, // Then goes to disabled, must be manually updated. + VIEWPORT_UPDATE_WHEN_VISIBLE, // Default VIEWPORT_UPDATE_WHEN_PARENT_VISIBLE, VIEWPORT_UPDATE_ALWAYS }; @@ -1161,7 +1174,7 @@ public: virtual void instance_set_ignore_culling(RID p_instance, bool p_enabled) = 0; - // don't use these in a game! + // Don't use these in a game! virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0; @@ -1235,7 +1248,7 @@ public: virtual void canvas_texture_set_channel(RID p_canvas_texture, CanvasTextureChannel p_channel, RID p_texture) = 0; virtual void canvas_texture_set_shading_parameters(RID p_canvas_texture, const Color &p_base_color, float p_shininess) = 0; - //takes effect only for new draw commands + // Takes effect only for new draw commands. virtual void canvas_texture_set_texture_filter(RID p_canvas_texture, CanvasItemTextureFilter p_filter) = 0; virtual void canvas_texture_set_texture_repeat(RID p_canvas_texture, CanvasItemTextureRepeat p_repeat) = 0; @@ -1433,7 +1446,7 @@ public: /* FREE */ - virtual void free(RID p_rid) = 0; ///< free RIDs associated with the rendering server + virtual void free(RID p_rid) = 0; // Free RIDs associated with the rendering server. /* EVENT QUEUING */ @@ -1519,7 +1532,7 @@ public: virtual ~RenderingServer(); private: - //binder helpers + // Binder helpers RID _texture_2d_layered_create(const TypedArray<Image> &p_layers, TextureLayeredType p_layered_type); RID _texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const TypedArray<Image> &p_data); void _texture_3d_update(RID p_texture, const TypedArray<Image> &p_data); @@ -1533,7 +1546,7 @@ private: void _particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses); }; -// make variant understand the enums +// Make variant understand the enums. VARIANT_ENUM_CAST(RenderingServer::TextureLayeredType); VARIANT_ENUM_CAST(RenderingServer::CubeMapLayer); VARIANT_ENUM_CAST(RenderingServer::ShaderMode); @@ -1561,6 +1574,7 @@ VARIANT_ENUM_CAST(RenderingServer::ParticlesEmitFlags); VARIANT_ENUM_CAST(RenderingServer::ParticlesCollisionType); VARIANT_ENUM_CAST(RenderingServer::ParticlesCollisionHeightfieldResolution); VARIANT_ENUM_CAST(RenderingServer::FogVolumeShape); +VARIANT_ENUM_CAST(RenderingServer::ViewportScaling3DMode); VARIANT_ENUM_CAST(RenderingServer::ViewportUpdateMode); VARIANT_ENUM_CAST(RenderingServer::ViewportClearMode); VARIANT_ENUM_CAST(RenderingServer::ViewportMSAA); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index 8fc1b56ae4..3b71dc1d92 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -78,7 +78,7 @@ void TextServerManager::remove_interface(const Ref<TextServer> &p_interface) { ERR_FAIL_COND(idx == -1); print_verbose("TextServer: Removed interface \"" + p_interface->get_name() + "\""); emit_signal(SNAME("interface_removed"), p_interface->get_name()); - interfaces.remove(idx); + interfaces.remove_at(idx); } int TextServerManager::get_interface_count() const { @@ -141,7 +141,7 @@ TextServerManager::~TextServerManager() { primary_interface.unref(); } while (interfaces.size() > 0) { - interfaces.remove(0); + interfaces.remove_at(0); } singleton = nullptr; } @@ -1024,7 +1024,7 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start, while (j < ranges.size()) { if (Math::is_equal_approx(ranges[i].y, ranges[j].x, (real_t)UNIT_EPSILON)) { ranges.write[i].y = ranges[j].y; - ranges.remove(j); + ranges.remove_at(j); continue; } j++; diff --git a/servers/xr_server.cpp b/servers/xr_server.cpp index d0367ba95e..959288497d 100644 --- a/servers/xr_server.cpp +++ b/servers/xr_server.cpp @@ -193,7 +193,7 @@ void XRServer::remove_interface(const Ref<XRInterface> &p_interface) { print_verbose("XR: Removed interface" + p_interface->get_name()); emit_signal(SNAME("interface_removed"), p_interface->get_name()); - interfaces.remove(idx); + interfaces.remove_at(idx); }; int XRServer::get_interface_count() const { @@ -396,7 +396,7 @@ XRServer::~XRServer() { primary_interface.unref(); while (interfaces.size() > 0) { - interfaces.remove(0); + interfaces.remove_at(0); } // TODO pretty sure there is a clear function or something... diff --git a/tests/core/io/test_image.h b/tests/core/io/test_image.h index c4c5f1e18b..643d2f31ec 100644 --- a/tests/core/io/test_image.h +++ b/tests/core/io/test_image.h @@ -52,6 +52,13 @@ TEST_CASE("[Image] Instantiation") { "A newly created image should not be compressed."); CHECK(!image->has_mipmaps()); + PackedByteArray image_data = image->get_data(); + for (int i = 0; i < image_data.size(); i++) { + CHECK_MESSAGE( + image_data[i] == 0, + "An image created without data specified should have its data zeroed out."); + } + Ref<Image> image_copy = memnew(Image()); CHECK_MESSAGE( image_copy->is_empty(), @@ -62,7 +69,7 @@ TEST_CASE("[Image] Instantiation") { image->get_data() == image_copy->get_data(), "Duplicated images should have the same data."); - PackedByteArray image_data = image->get_data(); + image_data = image->get_data(); Ref<Image> image_from_data = memnew(Image(8, 4, false, Image::FORMAT_RGBA8, image_data)); CHECK_MESSAGE( image->get_data() == image_from_data->get_data(), @@ -214,14 +221,51 @@ TEST_CASE("[Image] Modifying pixels of an image") { // Fill image with color image2->fill(Color(0.5, 0.5, 0.5, 0.5)); - for (int x = 0; x < image2->get_width(); x++) { - for (int y = 0; y < image2->get_height(); y++) { + for (int y = 0; y < image2->get_height(); y++) { + for (int x = 0; x < image2->get_width(); x++) { CHECK_MESSAGE( image2->get_pixel(x, y).r > 0.49, "fill() should colorize all pixels of the image."); } } + // Fill rect with color + { + const int img_width = 3; + const int img_height = 3; + Vector<Rect2> rects; + rects.push_back(Rect2()); + rects.push_back(Rect2(-5, -5, 3, 3)); + rects.push_back(Rect2(img_width, 0, 12, 12)); + rects.push_back(Rect2(0, img_height, 12, 12)); + rects.push_back(Rect2(img_width + 1, img_height + 2, 12, 12)); + rects.push_back(Rect2(1, 1, 1, 1)); + rects.push_back(Rect2(0, 1, 2, 3)); + rects.push_back(Rect2(-5, 0, img_width + 10, 2)); + rects.push_back(Rect2(0, -5, 2, img_height + 10)); + rects.push_back(Rect2(-1, -1, img_width + 1, img_height + 1)); + + for (const Rect2 &rect : rects) { + Ref<Image> img = memnew(Image(img_width, img_height, false, Image::FORMAT_RGBA8)); + CHECK_NOTHROW_MESSAGE( + img->fill_rect(rect, Color(1, 1, 1, 1)), + "fill_rect() shouldn't throw for any rect."); + for (int y = 0; y < img->get_height(); y++) { + for (int x = 0; x < img->get_width(); x++) { + if (rect.abs().has_point(Point2(x, y))) { + CHECK_MESSAGE( + img->get_pixel(x, y).is_equal_approx(Color(1, 1, 1, 1)), + "fill_rect() should colorize all image pixels within rect bounds."); + } else { + CHECK_MESSAGE( + !img->get_pixel(x, y).is_equal_approx(Color(1, 1, 1, 1)), + "fill_rect() shouldn't colorize any image pixel out of rect bounds."); + } + } + } + } + } + // Blend two images together image->blend_rect(image2, Rect2(Vector2(0, 0), image2->get_size()), Vector2(0, 0)); CHECK_MESSAGE( diff --git a/tests/core/math/test_aabb.h b/tests/core/math/test_aabb.h index b838bed171..f5076ce1ed 100644 --- a/tests/core/math/test_aabb.h +++ b/tests/core/math/test_aabb.h @@ -349,14 +349,27 @@ TEST_CASE("[AABB] Has point") { aabb.has_point(Vector3(2, 3, 0)), "has_point() with contained point should return the expected value."); CHECK_MESSAGE( + !aabb.has_point(Vector3(-20, 0, 0)), + "has_point() with non-contained point should return the expected value."); + + CHECK_MESSAGE( aabb.has_point(Vector3(-1.5, 3, 0)), - "has_point() with contained point on negative edge should return the expected value."); + "has_point() with positive size should include point on near face (X axis)."); CHECK_MESSAGE( aabb.has_point(Vector3(2.5, 3, 0)), - "has_point() with contained point on positive edge should return the expected value."); + "has_point() with positive size should include point on far face (X axis)."); CHECK_MESSAGE( - !aabb.has_point(Vector3(-20, 0, 0)), - "has_point() with non-contained point should return the expected value."); + aabb.has_point(Vector3(0, 2, 0)), + "has_point() with positive size should include point on near face (Y axis)."); + CHECK_MESSAGE( + aabb.has_point(Vector3(0, 7, 0)), + "has_point() with positive size should include point on far face (Y axis)."); + CHECK_MESSAGE( + aabb.has_point(Vector3(0, 3, -2.5)), + "has_point() with positive size should include point on near face (Z axis)."); + CHECK_MESSAGE( + aabb.has_point(Vector3(0, 3, 3.5)), + "has_point() with positive size should include point on far face (Z axis)."); } TEST_CASE("[AABB] Expanding") { diff --git a/tests/core/templates/test_local_vector.h b/tests/core/templates/test_local_vector.h index eff2a16abc..67bcf515f9 100644 --- a/tests/core/templates/test_local_vector.h +++ b/tests/core/templates/test_local_vector.h @@ -84,25 +84,25 @@ TEST_CASE("[LocalVector] Remove.") { vector.push_back(3); vector.push_back(4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 3); CHECK(vector[3] == 4); - vector.remove(2); + vector.remove_at(2); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 4); - vector.remove(1); + vector.remove_at(1); CHECK(vector[0] == 1); CHECK(vector[1] == 4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 4); } @@ -117,7 +117,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.size() == 5); - vector.remove_unordered(0); + vector.remove_at_unordered(0); CHECK(vector.size() == 4); @@ -128,7 +128,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(4) != -1); // Now the vector is no more ordered. - vector.remove_unordered(vector.find(3)); + vector.remove_at_unordered(vector.find(3)); CHECK(vector.size() == 3); @@ -137,7 +137,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(2) != -1); CHECK(vector.find(4) != -1); - vector.remove_unordered(vector.find(2)); + vector.remove_at_unordered(vector.find(2)); CHECK(vector.size() == 2); @@ -145,7 +145,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(1) != -1); CHECK(vector.find(4) != -1); - vector.remove_unordered(vector.find(4)); + vector.remove_at_unordered(vector.find(4)); CHECK(vector.size() == 1); @@ -153,7 +153,7 @@ TEST_CASE("[LocalVector] Remove Unordered.") { CHECK(vector.find(1) != -1); // Remove the last one. - vector.remove_unordered(0); + vector.remove_at_unordered(0); CHECK(vector.is_empty()); CHECK(vector.size() == 0); @@ -193,9 +193,9 @@ TEST_CASE("[LocalVector] Size / Resize / Reserve.") { // Capacity is supposed to change only when the size increase. CHECK(vector.get_capacity() >= 10); - vector.remove(0); - vector.remove(0); - vector.remove(0); + vector.remove_at(0); + vector.remove_at(0); + vector.remove_at(0); CHECK(vector.size() == 2); // Capacity is supposed to change only when the size increase. diff --git a/tests/core/templates/test_oa_hash_map.cpp b/tests/core/templates/test_oa_hash_map.cpp index 904c01642d..f7b2b7cdb0 100644 --- a/tests/core/templates/test_oa_hash_map.cpp +++ b/tests/core/templates/test_oa_hash_map.cpp @@ -55,7 +55,10 @@ struct CountedItem { count++; } - CountedItem &operator=(const CountedItem &p_other) = default; + void operator=(const CountedItem &p_other) { + id = p_other.id; + count++; + } ~CountedItem() { CRASH_COND(destroyed); diff --git a/tests/core/templates/test_vector.h b/tests/core/templates/test_vector.h index bfdf389aa7..658ca5adf1 100644 --- a/tests/core/templates/test_vector.h +++ b/tests/core/templates/test_vector.h @@ -129,7 +129,7 @@ TEST_CASE("[Vector] Fill large array and modify it") { CHECK(vector[200] == 0); CHECK(vector[499'999] == 0x60d07); CHECK(vector[999'999] == 0x60d07); - vector.remove(200); + vector.remove_at(200); CHECK(vector[200] == 0x60d07); vector.clear(); @@ -145,7 +145,7 @@ TEST_CASE("[Vector] Copy creation") { vector.push_back(4); Vector<int> vector_other = Vector<int>(vector); - vector_other.remove(0); + vector_other.remove_at(0); CHECK(vector_other[0] == 1); CHECK(vector_other[1] == 2); CHECK(vector_other[2] == 3); @@ -168,7 +168,7 @@ TEST_CASE("[Vector] Duplicate") { vector.push_back(4); Vector<int> vector_other = vector.duplicate(); - vector_other.remove(0); + vector_other.remove_at(0); CHECK(vector_other[0] == 1); CHECK(vector_other[1] == 2); CHECK(vector_other[2] == 3); @@ -302,7 +302,7 @@ TEST_CASE("[Vector] Find, has") { CHECK(!vector.has(5)); } -TEST_CASE("[Vector] Remove") { +TEST_CASE("[Vector] Remove at") { Vector<int> vector; vector.push_back(0); vector.push_back(1); @@ -310,30 +310,30 @@ TEST_CASE("[Vector] Remove") { vector.push_back(3); vector.push_back(4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 3); CHECK(vector[3] == 4); - vector.remove(2); + vector.remove_at(2); CHECK(vector[0] == 1); CHECK(vector[1] == 2); CHECK(vector[2] == 4); - vector.remove(1); + vector.remove_at(1); CHECK(vector[0] == 1); CHECK(vector[1] == 4); - vector.remove(0); + vector.remove_at(0); CHECK(vector[0] == 4); } -TEST_CASE("[Vector] Remove and find") { +TEST_CASE("[Vector] Remove at and find") { Vector<int> vector; vector.push_back(0); vector.push_back(1); @@ -343,7 +343,7 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.size() == 5); - vector.remove(0); + vector.remove_at(0); CHECK(vector.size() == 4); @@ -353,7 +353,7 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.find(3) != -1); CHECK(vector.find(4) != -1); - vector.remove(vector.find(3)); + vector.remove_at(vector.find(3)); CHECK(vector.size() == 3); @@ -362,7 +362,7 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.find(2) != -1); CHECK(vector.find(4) != -1); - vector.remove(vector.find(2)); + vector.remove_at(vector.find(2)); CHECK(vector.size() == 2); @@ -370,14 +370,14 @@ TEST_CASE("[Vector] Remove and find") { CHECK(vector.find(1) != -1); CHECK(vector.find(4) != -1); - vector.remove(vector.find(4)); + vector.remove_at(vector.find(4)); CHECK(vector.size() == 1); CHECK(vector.find(4) == -1); CHECK(vector.find(1) != -1); - vector.remove(0); + vector.remove_at(0); CHECK(vector.is_empty()); CHECK(vector.size() == 0); @@ -412,9 +412,9 @@ TEST_CASE("[Vector] Size, resize, reserve") { CHECK(vector.size() == 5); - vector.remove(0); - vector.remove(0); - vector.remove(0); + vector.remove_at(0); + vector.remove_at(0); + vector.remove_at(0); CHECK(vector.size() == 2); diff --git a/tests/core/variant/test_array.h b/tests/core/variant/test_array.h index 298bd2ff63..e2e84f2962 100644 --- a/tests/core/variant/test_array.h +++ b/tests/core/variant/test_array.h @@ -129,20 +129,20 @@ TEST_CASE("[Array] has() and count()") { CHECK(arr.count(2) == 0); } -TEST_CASE("[Array] remove()") { +TEST_CASE("[Array] remove_at()") { Array arr; arr.push_back(1); arr.push_back(2); - arr.remove(0); + arr.remove_at(0); CHECK(arr.size() == 1); CHECK(int(arr[0]) == 2); - arr.remove(0); + arr.remove_at(0); CHECK(arr.size() == 0); - // The array is now empty; try to use `remove()` again. + // The array is now empty; try to use `remove_at()` again. // Normally, this prints an error message so we silence it. ERR_PRINT_OFF; - arr.remove(0); + arr.remove_at(0); ERR_PRINT_ON; CHECK(arr.size() == 0); diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index a95dd02ba5..0467d4417b 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -2332,6 +2332,20 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { CHECK_FALSE(code_edit->is_line_folded(2)); CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + // Indent with blank lines. + code_edit->set_text("line1\n\tline2\n\n\nline3"); + CHECK(code_edit->can_fold_line(0)); + for (int i = 1; i < 2; i++) { + CHECK_FALSE(code_edit->can_fold_line(i)); + code_edit->fold_line(i); + CHECK_FALSE(code_edit->is_line_folded(i)); + } + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(1)); + CHECK_FALSE(code_edit->is_line_folded(2)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + // Nested indents. code_edit->set_text("line1\n\tline2\n\t\tline3\nline4"); CHECK(code_edit->can_fold_line(0)); @@ -2408,7 +2422,7 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { for (int i = 1; i < code_edit->get_line_count(); i++) { CHECK_FALSE(code_edit->is_line_folded(i)); } - CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 6); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 5); // End of file. code_edit->set_text("line1\n\tline2"); @@ -2490,7 +2504,7 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { // Multiline blocks. code_edit->add_comment_delimiter("&", "&", false); - code_edit->set_text("&line1\n\tline2&"); + code_edit->set_text("&line1\n\tline2&\nline3"); CHECK(code_edit->can_fold_line(0)); CHECK_FALSE(code_edit->can_fold_line(1)); code_edit->fold_line(1); @@ -2498,7 +2512,17 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { code_edit->fold_line(0); CHECK(code_edit->is_line_folded(0)); CHECK_FALSE(code_edit->is_line_folded(1)); - CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 1); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + + // Multiline comment before last line. + code_edit->set_text("&line1\nline2&\ntest"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(2)); + code_edit->fold_line(1); + CHECK_FALSE(code_edit->is_line_folded(1)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); // Has to be full line. code_edit->set_text("test &line1\n\tline2&"); @@ -2554,7 +2578,7 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { CHECK_FALSE(code_edit->is_line_folded(1)); CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 1); - // Non-indented comments/ strings. + // Non-indented comments/strings. // Single line code_edit->set_text("test\n\tline1\n#line1\n#line2\n\ttest"); CHECK(code_edit->can_fold_line(0)); @@ -2576,6 +2600,50 @@ TEST_CASE("[SceneTree][CodeEdit] folding") { CHECK_FALSE(code_edit->is_line_folded(1)); CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 4); + // Indent level 0->1, comment after lines + code_edit->set_text("line1\n\tline2\n#test"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(1)); + code_edit->fold_line(1); + CHECK_FALSE(code_edit->is_line_folded(1)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(1)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + + // Indent level 0->1, comment between lines + code_edit->set_text("line1\n#test\n\tline2\nline3"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(2)); + code_edit->fold_line(2); + CHECK_FALSE(code_edit->is_line_folded(2)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(2)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 3); + + // Indent level 1->2, comment after lines + code_edit->set_text("\tline1\n\t\tline2\n#test"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(1)); + code_edit->fold_line(1); + CHECK_FALSE(code_edit->is_line_folded(1)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(1)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 2); + + // Indent level 1->2, comment between lines + code_edit->set_text("\tline1\n#test\n\t\tline2\nline3"); + CHECK(code_edit->can_fold_line(0)); + CHECK_FALSE(code_edit->can_fold_line(2)); + code_edit->fold_line(2); + CHECK_FALSE(code_edit->is_line_folded(2)); + code_edit->fold_line(0); + CHECK(code_edit->is_line_folded(0)); + CHECK_FALSE(code_edit->is_line_folded(2)); + CHECK(code_edit->get_next_visible_line_offset_from(1, 1) == 3); + // Multiline code_edit->set_text("test\n\tline1\n&line1\nline2&\n\ttest"); CHECK(code_edit->can_fold_line(0)); diff --git a/tests/scene/test_curve.h b/tests/scene/test_curve.h index 60eafad460..4ee1a1c15c 100644 --- a/tests/scene/test_curve.h +++ b/tests/scene/test_curve.h @@ -219,35 +219,33 @@ TEST_CASE("[Curve] Custom curve with linear tangents") { TEST_CASE("[Curve2D] Linear sampling should return exact value") { Ref<Curve2D> curve = memnew(Curve2D); - int len = 2048; + real_t len = 2048.0; curve->add_point(Vector2(0, 0)); - curve->add_point(Vector2((float)len, 0)); + curve->add_point(Vector2(len, 0)); - float baked_length = curve->get_baked_length(); - CHECK((float)len == baked_length); + real_t baked_length = curve->get_baked_length(); + CHECK(len == baked_length); for (int i = 0; i < len; i++) { - float expected = (float)i; - Vector2 pos = curve->interpolate_baked(expected); - CHECK_MESSAGE(pos.x == expected, "interpolate_baked should return exact value"); + Vector2 pos = curve->interpolate_baked(i); + CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value"); } } TEST_CASE("[Curve3D] Linear sampling should return exact value") { Ref<Curve3D> curve = memnew(Curve3D); - int len = 2048; + real_t len = 2048.0; curve->add_point(Vector3(0, 0, 0)); - curve->add_point(Vector3((float)len, 0, 0)); + curve->add_point(Vector3(len, 0, 0)); - float baked_length = curve->get_baked_length(); - CHECK((float)len == baked_length); + real_t baked_length = curve->get_baked_length(); + CHECK(len == baked_length); for (int i = 0; i < len; i++) { - float expected = (float)i; - Vector3 pos = curve->interpolate_baked(expected); - CHECK_MESSAGE(pos.x == expected, "interpolate_baked should return exact value"); + Vector3 pos = curve->interpolate_baked(i); + CHECK_MESSAGE(pos.x == i, "interpolate_baked should return exact value"); } } diff --git a/tests/servers/test_shader_lang.cpp b/tests/servers/test_shader_lang.cpp index 0591bf6adf..f4a32c6723 100644 --- a/tests/servers/test_shader_lang.cpp +++ b/tests/servers/test_shader_lang.cpp @@ -261,6 +261,8 @@ static String dump_node_code(SL::Node *p_node, int p_level) { } code += ")"; break; + case SL::OP_EMPTY: + break; default: { code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; break; diff --git a/thirdparty/README.md b/thirdparty/README.md index 6ebcffb7ae..f8055ac3e7 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -5,6 +5,18 @@ respective folder names. Use two empty lines to separate categories for readability. +## amd-fsr + +Upstream: https://github.com/GPUOpen-Effects/FidelityFX-FSR +Version: 1.0.2 (a21ffb8f6c13233ba336352bdff293894c706575, 2021) +License: MIT + +Files extracted from upstream source: + +- `ffx_a.h` and `ffx_fsr1.h` from `ffx-fsr` +- `license.txt` + + ## basis_universal - Upstream: https://github.com/BinomialLLC/basis_universal @@ -189,7 +201,7 @@ Files extracted from upstream source: ## harfbuzz - Upstream: https://github.com/harfbuzz/harfbuzz -- Version: 3.1.1 (cd5c6cd0419ac5e4de975d6c476fb760bf06d2ce, 2021) +- Version: 3.1.2 (8aed5c21a31eece6a9f3cd775fda8facb6c28b9b, 2021) - License: MIT Files extracted from upstream source: @@ -347,6 +359,19 @@ instead of a combination of distance and attribute errors. Patches for both chan found in the `patches` directory. +## minimp3 + +- Upstream: https://github.com/lieff/minimp3 +- Version: git (afb604c06bc8beb145fecd42c0ceb5bda8795144, 2021) +- License: CC0 1.0 + +Files extracted from upstream repository: + +- `minimp3.h` +- `minimp3_ex.h` +- `LICENSE` + + ## miniupnpc - Upstream: https://github.com/miniupnp/miniupnp diff --git a/thirdparty/amd-fsr/ffx_a.h b/thirdparty/amd-fsr/ffx_a.h new file mode 100644 index 0000000000..d04bff55cb --- /dev/null +++ b/thirdparty/amd-fsr/ffx_a.h @@ -0,0 +1,2656 @@ +//============================================================================================================================== +// +// [A] SHADER PORTABILITY 1.20210629 +// +//============================================================================================================================== +// FidelityFX Super Resolution Sample +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// 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. +//------------------------------------------------------------------------------------------------------------------------------ +// MIT LICENSE +// =========== +// Copyright (c) 2014 Michal Drobot (for concepts used in "FLOAT APPROXIMATIONS"). +// ----------- +// 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. +//------------------------------------------------------------------------------------------------------------------------------ +// ABOUT +// ===== +// Common central point for high-level shading language and C portability for various shader headers. +//------------------------------------------------------------------------------------------------------------------------------ +// DEFINES +// ======= +// A_CPU ..... Include the CPU related code. +// A_GPU ..... Include the GPU related code. +// A_GLSL .... Using GLSL. +// A_HLSL .... Using HLSL. +// A_HLSL_6_2 Using HLSL 6.2 with new 'uint16_t' and related types (requires '-enable-16bit-types'). +// A_NO_16_BIT_CAST Don't use instructions that are not availabe in SPIR-V (needed for running A_HLSL_6_2 on Vulkan) +// A_GCC ..... Using a GCC compatible compiler (else assume MSVC compatible compiler by default). +// ======= +// A_BYTE .... Support 8-bit integer. +// A_HALF .... Support 16-bit integer and floating point. +// A_LONG .... Support 64-bit integer. +// A_DUBL .... Support 64-bit floating point. +// ======= +// A_WAVE .... Support wave-wide operations. +//------------------------------------------------------------------------------------------------------------------------------ +// To get #include "ffx_a.h" working in GLSL use '#extension GL_GOOGLE_include_directive:require'. +//------------------------------------------------------------------------------------------------------------------------------ +// SIMPLIFIED TYPE SYSTEM +// ====================== +// - All ints will be unsigned with exception of when signed is required. +// - Type naming simplified and shortened "A<type><#components>", +// - H = 16-bit float (half) +// - F = 32-bit float (float) +// - D = 64-bit float (double) +// - P = 1-bit integer (predicate, not using bool because 'B' is used for byte) +// - B = 8-bit integer (byte) +// - W = 16-bit integer (word) +// - U = 32-bit integer (unsigned) +// - L = 64-bit integer (long) +// - Using "AS<type><#components>" for signed when required. +//------------------------------------------------------------------------------------------------------------------------------ +// TODO +// ==== +// - Make sure 'ALerp*(a,b,m)' does 'b*m+(-a*m+a)' (2 ops). +//------------------------------------------------------------------------------------------------------------------------------ +// CHANGE LOG +// ========== +// 20200914 - Expanded wave ops and prx code. +// 20200713 - Added [ZOL] section, fixed serious bugs in sRGB and Rec.709 color conversion code, etc. +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// COMMON +//============================================================================================================================== +#define A_2PI 6.28318530718 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// CPU +// +// +//============================================================================================================================== +#ifdef A_CPU + // Supporting user defined overrides. + #ifndef A_RESTRICT + #define A_RESTRICT __restrict + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifndef A_STATIC + #define A_STATIC static + #endif +//------------------------------------------------------------------------------------------------------------------------------ + // Same types across CPU and GPU. + // Predicate uses 32-bit integer (C friendly bool). + typedef uint32_t AP1; + typedef float AF1; + typedef double AD1; + typedef uint8_t AB1; + typedef uint16_t AW1; + typedef uint32_t AU1; + typedef uint64_t AL1; + typedef int8_t ASB1; + typedef int16_t ASW1; + typedef int32_t ASU1; + typedef int64_t ASL1; +//------------------------------------------------------------------------------------------------------------------------------ + #define AD1_(a) ((AD1)(a)) + #define AF1_(a) ((AF1)(a)) + #define AL1_(a) ((AL1)(a)) + #define AU1_(a) ((AU1)(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ASL1_(a) ((ASL1)(a)) + #define ASU1_(a) ((ASU1)(a)) +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AU1 AU1_AF1(AF1 a){union{AF1 f;AU1 u;}bits;bits.f=a;return bits.u;} +//------------------------------------------------------------------------------------------------------------------------------ + #define A_TRUE 1 + #define A_FALSE 0 +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// CPU/GPU PORTING +// +//------------------------------------------------------------------------------------------------------------------------------ +// Get CPU and GPU to share all setup code, without duplicate code paths. +// This uses a lower-case prefix for special vector constructs. +// - In C restrict pointers are used. +// - In the shading language, in/inout/out arguments are used. +// This depends on the ability to access a vector value in both languages via array syntax (aka color[2]). +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR ARGUMENT/RETURN/INITIALIZATION PORTABILITY +//============================================================================================================================== + #define retAD2 AD1 *A_RESTRICT + #define retAD3 AD1 *A_RESTRICT + #define retAD4 AD1 *A_RESTRICT + #define retAF2 AF1 *A_RESTRICT + #define retAF3 AF1 *A_RESTRICT + #define retAF4 AF1 *A_RESTRICT + #define retAL2 AL1 *A_RESTRICT + #define retAL3 AL1 *A_RESTRICT + #define retAL4 AL1 *A_RESTRICT + #define retAU2 AU1 *A_RESTRICT + #define retAU3 AU1 *A_RESTRICT + #define retAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define inAD2 AD1 *A_RESTRICT + #define inAD3 AD1 *A_RESTRICT + #define inAD4 AD1 *A_RESTRICT + #define inAF2 AF1 *A_RESTRICT + #define inAF3 AF1 *A_RESTRICT + #define inAF4 AF1 *A_RESTRICT + #define inAL2 AL1 *A_RESTRICT + #define inAL3 AL1 *A_RESTRICT + #define inAL4 AL1 *A_RESTRICT + #define inAU2 AU1 *A_RESTRICT + #define inAU3 AU1 *A_RESTRICT + #define inAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define inoutAD2 AD1 *A_RESTRICT + #define inoutAD3 AD1 *A_RESTRICT + #define inoutAD4 AD1 *A_RESTRICT + #define inoutAF2 AF1 *A_RESTRICT + #define inoutAF3 AF1 *A_RESTRICT + #define inoutAF4 AF1 *A_RESTRICT + #define inoutAL2 AL1 *A_RESTRICT + #define inoutAL3 AL1 *A_RESTRICT + #define inoutAL4 AL1 *A_RESTRICT + #define inoutAU2 AU1 *A_RESTRICT + #define inoutAU3 AU1 *A_RESTRICT + #define inoutAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define outAD2 AD1 *A_RESTRICT + #define outAD3 AD1 *A_RESTRICT + #define outAD4 AD1 *A_RESTRICT + #define outAF2 AF1 *A_RESTRICT + #define outAF3 AF1 *A_RESTRICT + #define outAF4 AF1 *A_RESTRICT + #define outAL2 AL1 *A_RESTRICT + #define outAL3 AL1 *A_RESTRICT + #define outAL4 AL1 *A_RESTRICT + #define outAU2 AU1 *A_RESTRICT + #define outAU3 AU1 *A_RESTRICT + #define outAU4 AU1 *A_RESTRICT +//------------------------------------------------------------------------------------------------------------------------------ + #define varAD2(x) AD1 x[2] + #define varAD3(x) AD1 x[3] + #define varAD4(x) AD1 x[4] + #define varAF2(x) AF1 x[2] + #define varAF3(x) AF1 x[3] + #define varAF4(x) AF1 x[4] + #define varAL2(x) AL1 x[2] + #define varAL3(x) AL1 x[3] + #define varAL4(x) AL1 x[4] + #define varAU2(x) AU1 x[2] + #define varAU3(x) AU1 x[3] + #define varAU4(x) AU1 x[4] +//------------------------------------------------------------------------------------------------------------------------------ + #define initAD2(x,y) {x,y} + #define initAD3(x,y,z) {x,y,z} + #define initAD4(x,y,z,w) {x,y,z,w} + #define initAF2(x,y) {x,y} + #define initAF3(x,y,z) {x,y,z} + #define initAF4(x,y,z,w) {x,y,z,w} + #define initAL2(x,y) {x,y} + #define initAL3(x,y,z) {x,y,z} + #define initAL4(x,y,z,w) {x,y,z,w} + #define initAU2(x,y) {x,y} + #define initAU3(x,y,z) {x,y,z} + #define initAU4(x,y,z,w) {x,y,z,w} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS +//------------------------------------------------------------------------------------------------------------------------------ +// TODO +// ==== +// - Replace transcendentals with manual versions. +//============================================================================================================================== + #ifdef A_GCC + A_STATIC AD1 AAbsD1(AD1 a){return __builtin_fabs(a);} + A_STATIC AF1 AAbsF1(AF1 a){return __builtin_fabsf(a);} + A_STATIC AU1 AAbsSU1(AU1 a){return AU1_(__builtin_abs(ASU1_(a)));} + A_STATIC AL1 AAbsSL1(AL1 a){return AL1_(__builtin_llabs(ASL1_(a)));} + #else + A_STATIC AD1 AAbsD1(AD1 a){return fabs(a);} + A_STATIC AF1 AAbsF1(AF1 a){return fabsf(a);} + A_STATIC AU1 AAbsSU1(AU1 a){return AU1_(abs(ASU1_(a)));} + A_STATIC AL1 AAbsSL1(AL1 a){return AL1_(labs((long)ASL1_(a)));} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ACosD1(AD1 a){return __builtin_cos(a);} + A_STATIC AF1 ACosF1(AF1 a){return __builtin_cosf(a);} + #else + A_STATIC AD1 ACosD1(AD1 a){return cos(a);} + A_STATIC AF1 ACosF1(AF1 a){return cosf(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ADotD2(inAD2 a,inAD2 b){return a[0]*b[0]+a[1]*b[1];} + A_STATIC AD1 ADotD3(inAD3 a,inAD3 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];} + A_STATIC AD1 ADotD4(inAD4 a,inAD4 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3];} + A_STATIC AF1 ADotF2(inAF2 a,inAF2 b){return a[0]*b[0]+a[1]*b[1];} + A_STATIC AF1 ADotF3(inAF3 a,inAF3 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];} + A_STATIC AF1 ADotF4(inAF4 a,inAF4 b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3];} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 AExp2D1(AD1 a){return __builtin_exp2(a);} + A_STATIC AF1 AExp2F1(AF1 a){return __builtin_exp2f(a);} + #else + A_STATIC AD1 AExp2D1(AD1 a){return exp2(a);} + A_STATIC AF1 AExp2F1(AF1 a){return exp2f(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 AFloorD1(AD1 a){return __builtin_floor(a);} + A_STATIC AF1 AFloorF1(AF1 a){return __builtin_floorf(a);} + #else + A_STATIC AD1 AFloorD1(AD1 a){return floor(a);} + A_STATIC AF1 AFloorF1(AF1 a){return floorf(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ALerpD1(AD1 a,AD1 b,AD1 c){return b*c+(-a*c+a);} + A_STATIC AF1 ALerpF1(AF1 a,AF1 b,AF1 c){return b*c+(-a*c+a);} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ALog2D1(AD1 a){return __builtin_log2(a);} + A_STATIC AF1 ALog2F1(AF1 a){return __builtin_log2f(a);} + #else + A_STATIC AD1 ALog2D1(AD1 a){return log2(a);} + A_STATIC AF1 ALog2F1(AF1 a){return log2f(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 AMaxD1(AD1 a,AD1 b){return a>b?a:b;} + A_STATIC AF1 AMaxF1(AF1 a,AF1 b){return a>b?a:b;} + A_STATIC AL1 AMaxL1(AL1 a,AL1 b){return a>b?a:b;} + A_STATIC AU1 AMaxU1(AU1 a,AU1 b){return a>b?a:b;} +//------------------------------------------------------------------------------------------------------------------------------ + // These follow the convention that A integer types don't have signage, until they are operated on. + A_STATIC AL1 AMaxSL1(AL1 a,AL1 b){return (ASL1_(a)>ASL1_(b))?a:b;} + A_STATIC AU1 AMaxSU1(AU1 a,AU1 b){return (ASU1_(a)>ASU1_(b))?a:b;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 AMinD1(AD1 a,AD1 b){return a<b?a:b;} + A_STATIC AF1 AMinF1(AF1 a,AF1 b){return a<b?a:b;} + A_STATIC AL1 AMinL1(AL1 a,AL1 b){return a<b?a:b;} + A_STATIC AU1 AMinU1(AU1 a,AU1 b){return a<b?a:b;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AL1 AMinSL1(AL1 a,AL1 b){return (ASL1_(a)<ASL1_(b))?a:b;} + A_STATIC AU1 AMinSU1(AU1 a,AU1 b){return (ASU1_(a)<ASU1_(b))?a:b;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ARcpD1(AD1 a){return 1.0/a;} + A_STATIC AF1 ARcpF1(AF1 a){return 1.0f/a;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AL1 AShrSL1(AL1 a,AL1 b){return AL1_(ASL1_(a)>>ASL1_(b));} + A_STATIC AU1 AShrSU1(AU1 a,AU1 b){return AU1_(ASU1_(a)>>ASU1_(b));} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ASinD1(AD1 a){return __builtin_sin(a);} + A_STATIC AF1 ASinF1(AF1 a){return __builtin_sinf(a);} + #else + A_STATIC AD1 ASinD1(AD1 a){return sin(a);} + A_STATIC AF1 ASinF1(AF1 a){return sinf(a);} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_GCC + A_STATIC AD1 ASqrtD1(AD1 a){return __builtin_sqrt(a);} + A_STATIC AF1 ASqrtF1(AF1 a){return __builtin_sqrtf(a);} + #else + A_STATIC AD1 ASqrtD1(AD1 a){return sqrt(a);} + A_STATIC AF1 ASqrtF1(AF1 a){return sqrtf(a);} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS - DEPENDENT +//============================================================================================================================== + A_STATIC AD1 AClampD1(AD1 x,AD1 n,AD1 m){return AMaxD1(n,AMinD1(x,m));} + A_STATIC AF1 AClampF1(AF1 x,AF1 n,AF1 m){return AMaxF1(n,AMinF1(x,m));} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 AFractD1(AD1 a){return a-AFloorD1(a);} + A_STATIC AF1 AFractF1(AF1 a){return a-AFloorF1(a);} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 APowD1(AD1 a,AD1 b){return AExp2D1(b*ALog2D1(a));} + A_STATIC AF1 APowF1(AF1 a,AF1 b){return AExp2F1(b*ALog2F1(a));} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ARsqD1(AD1 a){return ARcpD1(ASqrtD1(a));} + A_STATIC AF1 ARsqF1(AF1 a){return ARcpF1(ASqrtF1(a));} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC AD1 ASatD1(AD1 a){return AMinD1(1.0,AMaxD1(0.0,a));} + A_STATIC AF1 ASatF1(AF1 a){return AMinF1(1.0f,AMaxF1(0.0f,a));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR OPS +//------------------------------------------------------------------------------------------------------------------------------ +// These are added as needed for production or prototyping, so not necessarily a complete set. +// They follow a convention of taking in a destination and also returning the destination value to increase utility. +//============================================================================================================================== + A_STATIC retAD2 opAAbsD2(outAD2 d,inAD2 a){d[0]=AAbsD1(a[0]);d[1]=AAbsD1(a[1]);return d;} + A_STATIC retAD3 opAAbsD3(outAD3 d,inAD3 a){d[0]=AAbsD1(a[0]);d[1]=AAbsD1(a[1]);d[2]=AAbsD1(a[2]);return d;} + A_STATIC retAD4 opAAbsD4(outAD4 d,inAD4 a){d[0]=AAbsD1(a[0]);d[1]=AAbsD1(a[1]);d[2]=AAbsD1(a[2]);d[3]=AAbsD1(a[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAAbsF2(outAF2 d,inAF2 a){d[0]=AAbsF1(a[0]);d[1]=AAbsF1(a[1]);return d;} + A_STATIC retAF3 opAAbsF3(outAF3 d,inAF3 a){d[0]=AAbsF1(a[0]);d[1]=AAbsF1(a[1]);d[2]=AAbsF1(a[2]);return d;} + A_STATIC retAF4 opAAbsF4(outAF4 d,inAF4 a){d[0]=AAbsF1(a[0]);d[1]=AAbsF1(a[1]);d[2]=AAbsF1(a[2]);d[3]=AAbsF1(a[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAAddD2(outAD2 d,inAD2 a,inAD2 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];return d;} + A_STATIC retAD3 opAAddD3(outAD3 d,inAD3 a,inAD3 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];return d;} + A_STATIC retAD4 opAAddD4(outAD4 d,inAD4 a,inAD4 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];d[3]=a[3]+b[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAAddF2(outAF2 d,inAF2 a,inAF2 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];return d;} + A_STATIC retAF3 opAAddF3(outAF3 d,inAF3 a,inAF3 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];return d;} + A_STATIC retAF4 opAAddF4(outAF4 d,inAF4 a,inAF4 b){d[0]=a[0]+b[0];d[1]=a[1]+b[1];d[2]=a[2]+b[2];d[3]=a[3]+b[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opAAddOneD2(outAD2 d,inAD2 a,AD1 b){d[0]=a[0]+b;d[1]=a[1]+b;return d;} + A_STATIC retAD3 opAAddOneD3(outAD3 d,inAD3 a,AD1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;return d;} + A_STATIC retAD4 opAAddOneD4(outAD4 d,inAD4 a,AD1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;d[3]=a[3]+b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAAddOneF2(outAF2 d,inAF2 a,AF1 b){d[0]=a[0]+b;d[1]=a[1]+b;return d;} + A_STATIC retAF3 opAAddOneF3(outAF3 d,inAF3 a,AF1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;return d;} + A_STATIC retAF4 opAAddOneF4(outAF4 d,inAF4 a,AF1 b){d[0]=a[0]+b;d[1]=a[1]+b;d[2]=a[2]+b;d[3]=a[3]+b;return d;} +//============================================================================================================================== + A_STATIC retAD2 opACpyD2(outAD2 d,inAD2 a){d[0]=a[0];d[1]=a[1];return d;} + A_STATIC retAD3 opACpyD3(outAD3 d,inAD3 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];return d;} + A_STATIC retAD4 opACpyD4(outAD4 d,inAD4 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];d[3]=a[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opACpyF2(outAF2 d,inAF2 a){d[0]=a[0];d[1]=a[1];return d;} + A_STATIC retAF3 opACpyF3(outAF3 d,inAF3 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];return d;} + A_STATIC retAF4 opACpyF4(outAF4 d,inAF4 a){d[0]=a[0];d[1]=a[1];d[2]=a[2];d[3]=a[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opALerpD2(outAD2 d,inAD2 a,inAD2 b,inAD2 c){d[0]=ALerpD1(a[0],b[0],c[0]);d[1]=ALerpD1(a[1],b[1],c[1]);return d;} + A_STATIC retAD3 opALerpD3(outAD3 d,inAD3 a,inAD3 b,inAD3 c){d[0]=ALerpD1(a[0],b[0],c[0]);d[1]=ALerpD1(a[1],b[1],c[1]);d[2]=ALerpD1(a[2],b[2],c[2]);return d;} + A_STATIC retAD4 opALerpD4(outAD4 d,inAD4 a,inAD4 b,inAD4 c){d[0]=ALerpD1(a[0],b[0],c[0]);d[1]=ALerpD1(a[1],b[1],c[1]);d[2]=ALerpD1(a[2],b[2],c[2]);d[3]=ALerpD1(a[3],b[3],c[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opALerpF2(outAF2 d,inAF2 a,inAF2 b,inAF2 c){d[0]=ALerpF1(a[0],b[0],c[0]);d[1]=ALerpF1(a[1],b[1],c[1]);return d;} + A_STATIC retAF3 opALerpF3(outAF3 d,inAF3 a,inAF3 b,inAF3 c){d[0]=ALerpF1(a[0],b[0],c[0]);d[1]=ALerpF1(a[1],b[1],c[1]);d[2]=ALerpF1(a[2],b[2],c[2]);return d;} + A_STATIC retAF4 opALerpF4(outAF4 d,inAF4 a,inAF4 b,inAF4 c){d[0]=ALerpF1(a[0],b[0],c[0]);d[1]=ALerpF1(a[1],b[1],c[1]);d[2]=ALerpF1(a[2],b[2],c[2]);d[3]=ALerpF1(a[3],b[3],c[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opALerpOneD2(outAD2 d,inAD2 a,inAD2 b,AD1 c){d[0]=ALerpD1(a[0],b[0],c);d[1]=ALerpD1(a[1],b[1],c);return d;} + A_STATIC retAD3 opALerpOneD3(outAD3 d,inAD3 a,inAD3 b,AD1 c){d[0]=ALerpD1(a[0],b[0],c);d[1]=ALerpD1(a[1],b[1],c);d[2]=ALerpD1(a[2],b[2],c);return d;} + A_STATIC retAD4 opALerpOneD4(outAD4 d,inAD4 a,inAD4 b,AD1 c){d[0]=ALerpD1(a[0],b[0],c);d[1]=ALerpD1(a[1],b[1],c);d[2]=ALerpD1(a[2],b[2],c);d[3]=ALerpD1(a[3],b[3],c);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opALerpOneF2(outAF2 d,inAF2 a,inAF2 b,AF1 c){d[0]=ALerpF1(a[0],b[0],c);d[1]=ALerpF1(a[1],b[1],c);return d;} + A_STATIC retAF3 opALerpOneF3(outAF3 d,inAF3 a,inAF3 b,AF1 c){d[0]=ALerpF1(a[0],b[0],c);d[1]=ALerpF1(a[1],b[1],c);d[2]=ALerpF1(a[2],b[2],c);return d;} + A_STATIC retAF4 opALerpOneF4(outAF4 d,inAF4 a,inAF4 b,AF1 c){d[0]=ALerpF1(a[0],b[0],c);d[1]=ALerpF1(a[1],b[1],c);d[2]=ALerpF1(a[2],b[2],c);d[3]=ALerpF1(a[3],b[3],c);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMaxD2(outAD2 d,inAD2 a,inAD2 b){d[0]=AMaxD1(a[0],b[0]);d[1]=AMaxD1(a[1],b[1]);return d;} + A_STATIC retAD3 opAMaxD3(outAD3 d,inAD3 a,inAD3 b){d[0]=AMaxD1(a[0],b[0]);d[1]=AMaxD1(a[1],b[1]);d[2]=AMaxD1(a[2],b[2]);return d;} + A_STATIC retAD4 opAMaxD4(outAD4 d,inAD4 a,inAD4 b){d[0]=AMaxD1(a[0],b[0]);d[1]=AMaxD1(a[1],b[1]);d[2]=AMaxD1(a[2],b[2]);d[3]=AMaxD1(a[3],b[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMaxF2(outAF2 d,inAF2 a,inAF2 b){d[0]=AMaxF1(a[0],b[0]);d[1]=AMaxF1(a[1],b[1]);return d;} + A_STATIC retAF3 opAMaxF3(outAF3 d,inAF3 a,inAF3 b){d[0]=AMaxF1(a[0],b[0]);d[1]=AMaxF1(a[1],b[1]);d[2]=AMaxF1(a[2],b[2]);return d;} + A_STATIC retAF4 opAMaxF4(outAF4 d,inAF4 a,inAF4 b){d[0]=AMaxF1(a[0],b[0]);d[1]=AMaxF1(a[1],b[1]);d[2]=AMaxF1(a[2],b[2]);d[3]=AMaxF1(a[3],b[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMinD2(outAD2 d,inAD2 a,inAD2 b){d[0]=AMinD1(a[0],b[0]);d[1]=AMinD1(a[1],b[1]);return d;} + A_STATIC retAD3 opAMinD3(outAD3 d,inAD3 a,inAD3 b){d[0]=AMinD1(a[0],b[0]);d[1]=AMinD1(a[1],b[1]);d[2]=AMinD1(a[2],b[2]);return d;} + A_STATIC retAD4 opAMinD4(outAD4 d,inAD4 a,inAD4 b){d[0]=AMinD1(a[0],b[0]);d[1]=AMinD1(a[1],b[1]);d[2]=AMinD1(a[2],b[2]);d[3]=AMinD1(a[3],b[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMinF2(outAF2 d,inAF2 a,inAF2 b){d[0]=AMinF1(a[0],b[0]);d[1]=AMinF1(a[1],b[1]);return d;} + A_STATIC retAF3 opAMinF3(outAF3 d,inAF3 a,inAF3 b){d[0]=AMinF1(a[0],b[0]);d[1]=AMinF1(a[1],b[1]);d[2]=AMinF1(a[2],b[2]);return d;} + A_STATIC retAF4 opAMinF4(outAF4 d,inAF4 a,inAF4 b){d[0]=AMinF1(a[0],b[0]);d[1]=AMinF1(a[1],b[1]);d[2]=AMinF1(a[2],b[2]);d[3]=AMinF1(a[3],b[3]);return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMulD2(outAD2 d,inAD2 a,inAD2 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];return d;} + A_STATIC retAD3 opAMulD3(outAD3 d,inAD3 a,inAD3 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];return d;} + A_STATIC retAD4 opAMulD4(outAD4 d,inAD4 a,inAD4 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];d[3]=a[3]*b[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMulF2(outAF2 d,inAF2 a,inAF2 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];return d;} + A_STATIC retAF3 opAMulF3(outAF3 d,inAF3 a,inAF3 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];return d;} + A_STATIC retAF4 opAMulF4(outAF4 d,inAF4 a,inAF4 b){d[0]=a[0]*b[0];d[1]=a[1]*b[1];d[2]=a[2]*b[2];d[3]=a[3]*b[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opAMulOneD2(outAD2 d,inAD2 a,AD1 b){d[0]=a[0]*b;d[1]=a[1]*b;return d;} + A_STATIC retAD3 opAMulOneD3(outAD3 d,inAD3 a,AD1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;return d;} + A_STATIC retAD4 opAMulOneD4(outAD4 d,inAD4 a,AD1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;d[3]=a[3]*b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opAMulOneF2(outAF2 d,inAF2 a,AF1 b){d[0]=a[0]*b;d[1]=a[1]*b;return d;} + A_STATIC retAF3 opAMulOneF3(outAF3 d,inAF3 a,AF1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;return d;} + A_STATIC retAF4 opAMulOneF4(outAF4 d,inAF4 a,AF1 b){d[0]=a[0]*b;d[1]=a[1]*b;d[2]=a[2]*b;d[3]=a[3]*b;return d;} +//============================================================================================================================== + A_STATIC retAD2 opANegD2(outAD2 d,inAD2 a){d[0]=-a[0];d[1]=-a[1];return d;} + A_STATIC retAD3 opANegD3(outAD3 d,inAD3 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];return d;} + A_STATIC retAD4 opANegD4(outAD4 d,inAD4 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];d[3]=-a[3];return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opANegF2(outAF2 d,inAF2 a){d[0]=-a[0];d[1]=-a[1];return d;} + A_STATIC retAF3 opANegF3(outAF3 d,inAF3 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];return d;} + A_STATIC retAF4 opANegF4(outAF4 d,inAF4 a){d[0]=-a[0];d[1]=-a[1];d[2]=-a[2];d[3]=-a[3];return d;} +//============================================================================================================================== + A_STATIC retAD2 opARcpD2(outAD2 d,inAD2 a){d[0]=ARcpD1(a[0]);d[1]=ARcpD1(a[1]);return d;} + A_STATIC retAD3 opARcpD3(outAD3 d,inAD3 a){d[0]=ARcpD1(a[0]);d[1]=ARcpD1(a[1]);d[2]=ARcpD1(a[2]);return d;} + A_STATIC retAD4 opARcpD4(outAD4 d,inAD4 a){d[0]=ARcpD1(a[0]);d[1]=ARcpD1(a[1]);d[2]=ARcpD1(a[2]);d[3]=ARcpD1(a[3]);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + A_STATIC retAF2 opARcpF2(outAF2 d,inAF2 a){d[0]=ARcpF1(a[0]);d[1]=ARcpF1(a[1]);return d;} + A_STATIC retAF3 opARcpF3(outAF3 d,inAF3 a){d[0]=ARcpF1(a[0]);d[1]=ARcpF1(a[1]);d[2]=ARcpF1(a[2]);return d;} + A_STATIC retAF4 opARcpF4(outAF4 d,inAF4 a){d[0]=ARcpF1(a[0]);d[1]=ARcpF1(a[1]);d[2]=ARcpF1(a[2]);d[3]=ARcpF1(a[3]);return d;} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HALF FLOAT PACKING +//============================================================================================================================== + // Convert float to half (in lower 16-bits of output). + // Same fast technique as documented here: ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf + // Supports denormals. + // Conversion rules are to make computations possibly "safer" on the GPU, + // -INF & -NaN -> -65504 + // +INF & +NaN -> +65504 + A_STATIC AU1 AU1_AH1_AF1(AF1 f){ + static AW1 base[512]={ + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, + 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100, + 0x0200,0x0400,0x0800,0x0c00,0x1000,0x1400,0x1800,0x1c00,0x2000,0x2400,0x2800,0x2c00,0x3000,0x3400,0x3800,0x3c00, + 0x4000,0x4400,0x4800,0x4c00,0x5000,0x5400,0x5800,0x5c00,0x6000,0x6400,0x6800,0x6c00,0x7000,0x7400,0x7800,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff,0x7bff, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8001,0x8002,0x8004,0x8008,0x8010,0x8020,0x8040,0x8080,0x8100, + 0x8200,0x8400,0x8800,0x8c00,0x9000,0x9400,0x9800,0x9c00,0xa000,0xa400,0xa800,0xac00,0xb000,0xb400,0xb800,0xbc00, + 0xc000,0xc400,0xc800,0xcc00,0xd000,0xd400,0xd800,0xdc00,0xe000,0xe400,0xe800,0xec00,0xf000,0xf400,0xf800,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff, + 0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff,0xfbff}; + static AB1 shift[512]={ + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0f, + 0x0e,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d, + 0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0f, + 0x0e,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d, + 0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x0d,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, + 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18}; + union{AF1 f;AU1 u;}bits;bits.f=f;AU1 u=bits.u;AU1 i=u>>23;return (AU1)(base[i])+((u&0x7fffff)>>shift[i]);} +//------------------------------------------------------------------------------------------------------------------------------ + // Used to output packed constant. + A_STATIC AU1 AU1_AH2_AF2(inAF2 a){return AU1_AH1_AF1(a[0])+(AU1_AH1_AF1(a[1])<<16);} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// GLSL +// +// +//============================================================================================================================== +#if defined(A_GLSL) && defined(A_GPU) + #ifndef A_SKIP_EXT + #ifdef A_HALF + #extension GL_EXT_shader_16bit_storage:require + #extension GL_EXT_shader_explicit_arithmetic_types:require + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_LONG + #extension GL_ARB_gpu_shader_int64:require + #extension GL_NV_shader_atomic_int64:require + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_WAVE + #extension GL_KHR_shader_subgroup_arithmetic:require + #extension GL_KHR_shader_subgroup_ballot:require + #extension GL_KHR_shader_subgroup_quad:require + #extension GL_KHR_shader_subgroup_shuffle:require + #endif + #endif +//============================================================================================================================== + #define AP1 bool + #define AP2 bvec2 + #define AP3 bvec3 + #define AP4 bvec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF1 float + #define AF2 vec2 + #define AF3 vec3 + #define AF4 vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1 uint + #define AU2 uvec2 + #define AU3 uvec3 + #define AU4 uvec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASU1 int + #define ASU2 ivec2 + #define ASU3 ivec3 + #define ASU4 ivec4 +//============================================================================================================================== + #define AF1_AU1(x) uintBitsToFloat(AU1(x)) + #define AF2_AU2(x) uintBitsToFloat(AU2(x)) + #define AF3_AU3(x) uintBitsToFloat(AU3(x)) + #define AF4_AU4(x) uintBitsToFloat(AU4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AF1(x) floatBitsToUint(AF1(x)) + #define AU2_AF2(x) floatBitsToUint(AF2(x)) + #define AU3_AF3(x) floatBitsToUint(AF3(x)) + #define AU4_AF4(x) floatBitsToUint(AF4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH1_AF1_x(AF1 a){return packHalf2x16(AF2(a,0.0));} + #define AU1_AH1_AF1(a) AU1_AH1_AF1_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AH2_AF2 packHalf2x16 + #define AU1_AW2Unorm_AF2 packUnorm2x16 + #define AU1_AB4Unorm_AF4 packUnorm4x8 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF2_AH2_AU1 unpackHalf2x16 + #define AF2_AW2Unorm_AU1 unpackUnorm2x16 + #define AF4_AB4Unorm_AU1 unpackUnorm4x8 +//============================================================================================================================== + AF1 AF1_x(AF1 a){return AF1(a);} + AF2 AF2_x(AF1 a){return AF2(a,a);} + AF3 AF3_x(AF1 a){return AF3(a,a,a);} + AF4 AF4_x(AF1 a){return AF4(a,a,a,a);} + #define AF1_(a) AF1_x(AF1(a)) + #define AF2_(a) AF2_x(AF1(a)) + #define AF3_(a) AF3_x(AF1(a)) + #define AF4_(a) AF4_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_x(AU1 a){return AU1(a);} + AU2 AU2_x(AU1 a){return AU2(a,a);} + AU3 AU3_x(AU1 a){return AU3(a,a,a);} + AU4 AU4_x(AU1 a){return AU4(a,a,a,a);} + #define AU1_(a) AU1_x(AU1(a)) + #define AU2_(a) AU2_x(AU1(a)) + #define AU3_(a) AU3_x(AU1(a)) + #define AU4_(a) AU4_x(AU1(a)) +//============================================================================================================================== + AU1 AAbsSU1(AU1 a){return AU1(abs(ASU1(a)));} + AU2 AAbsSU2(AU2 a){return AU2(abs(ASU2(a)));} + AU3 AAbsSU3(AU3 a){return AU3(abs(ASU3(a)));} + AU4 AAbsSU4(AU4 a){return AU4(abs(ASU4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 ABfe(AU1 src,AU1 off,AU1 bits){return bitfieldExtract(src,ASU1(off),ASU1(bits));} + AU1 ABfi(AU1 src,AU1 ins,AU1 mask){return (ins&mask)|(src&(~mask));} + // Proxy for V_BFI_B32 where the 'mask' is set as 'bits', 'mask=(1<<bits)-1', and 'bits' needs to be an immediate. + AU1 ABfiM(AU1 src,AU1 ins,AU1 bits){return bitfieldInsert(src,ins,0,ASU1(bits));} +//------------------------------------------------------------------------------------------------------------------------------ + // V_MED3_F32. + AF1 AClampF1(AF1 x,AF1 n,AF1 m){return clamp(x,n,m);} + AF2 AClampF2(AF2 x,AF2 n,AF2 m){return clamp(x,n,m);} + AF3 AClampF3(AF3 x,AF3 n,AF3 m){return clamp(x,n,m);} + AF4 AClampF4(AF4 x,AF4 n,AF4 m){return clamp(x,n,m);} +//------------------------------------------------------------------------------------------------------------------------------ + // V_FRACT_F32 (note DX frac() is different). + AF1 AFractF1(AF1 x){return fract(x);} + AF2 AFractF2(AF2 x){return fract(x);} + AF3 AFractF3(AF3 x){return fract(x);} + AF4 AFractF4(AF4 x){return fract(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ALerpF1(AF1 x,AF1 y,AF1 a){return mix(x,y,a);} + AF2 ALerpF2(AF2 x,AF2 y,AF2 a){return mix(x,y,a);} + AF3 ALerpF3(AF3 x,AF3 y,AF3 a){return mix(x,y,a);} + AF4 ALerpF4(AF4 x,AF4 y,AF4 a){return mix(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + // V_MAX3_F32. + AF1 AMax3F1(AF1 x,AF1 y,AF1 z){return max(x,max(y,z));} + AF2 AMax3F2(AF2 x,AF2 y,AF2 z){return max(x,max(y,z));} + AF3 AMax3F3(AF3 x,AF3 y,AF3 z){return max(x,max(y,z));} + AF4 AMax3F4(AF4 x,AF4 y,AF4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMax3SU1(AU1 x,AU1 y,AU1 z){return AU1(max(ASU1(x),max(ASU1(y),ASU1(z))));} + AU2 AMax3SU2(AU2 x,AU2 y,AU2 z){return AU2(max(ASU2(x),max(ASU2(y),ASU2(z))));} + AU3 AMax3SU3(AU3 x,AU3 y,AU3 z){return AU3(max(ASU3(x),max(ASU3(y),ASU3(z))));} + AU4 AMax3SU4(AU4 x,AU4 y,AU4 z){return AU4(max(ASU4(x),max(ASU4(y),ASU4(z))));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMax3U1(AU1 x,AU1 y,AU1 z){return max(x,max(y,z));} + AU2 AMax3U2(AU2 x,AU2 y,AU2 z){return max(x,max(y,z));} + AU3 AMax3U3(AU3 x,AU3 y,AU3 z){return max(x,max(y,z));} + AU4 AMax3U4(AU4 x,AU4 y,AU4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMaxSU1(AU1 a,AU1 b){return AU1(max(ASU1(a),ASU1(b)));} + AU2 AMaxSU2(AU2 a,AU2 b){return AU2(max(ASU2(a),ASU2(b)));} + AU3 AMaxSU3(AU3 a,AU3 b){return AU3(max(ASU3(a),ASU3(b)));} + AU4 AMaxSU4(AU4 a,AU4 b){return AU4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + // Clamp has an easier pattern match for med3 when some ordering is known. + // V_MED3_F32. + AF1 AMed3F1(AF1 x,AF1 y,AF1 z){return max(min(x,y),min(max(x,y),z));} + AF2 AMed3F2(AF2 x,AF2 y,AF2 z){return max(min(x,y),min(max(x,y),z));} + AF3 AMed3F3(AF3 x,AF3 y,AF3 z){return max(min(x,y),min(max(x,y),z));} + AF4 AMed3F4(AF4 x,AF4 y,AF4 z){return max(min(x,y),min(max(x,y),z));} +//------------------------------------------------------------------------------------------------------------------------------ + // V_MIN3_F32. + AF1 AMin3F1(AF1 x,AF1 y,AF1 z){return min(x,min(y,z));} + AF2 AMin3F2(AF2 x,AF2 y,AF2 z){return min(x,min(y,z));} + AF3 AMin3F3(AF3 x,AF3 y,AF3 z){return min(x,min(y,z));} + AF4 AMin3F4(AF4 x,AF4 y,AF4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMin3SU1(AU1 x,AU1 y,AU1 z){return AU1(min(ASU1(x),min(ASU1(y),ASU1(z))));} + AU2 AMin3SU2(AU2 x,AU2 y,AU2 z){return AU2(min(ASU2(x),min(ASU2(y),ASU2(z))));} + AU3 AMin3SU3(AU3 x,AU3 y,AU3 z){return AU3(min(ASU3(x),min(ASU3(y),ASU3(z))));} + AU4 AMin3SU4(AU4 x,AU4 y,AU4 z){return AU4(min(ASU4(x),min(ASU4(y),ASU4(z))));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMin3U1(AU1 x,AU1 y,AU1 z){return min(x,min(y,z));} + AU2 AMin3U2(AU2 x,AU2 y,AU2 z){return min(x,min(y,z));} + AU3 AMin3U3(AU3 x,AU3 y,AU3 z){return min(x,min(y,z));} + AU4 AMin3U4(AU4 x,AU4 y,AU4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMinSU1(AU1 a,AU1 b){return AU1(min(ASU1(a),ASU1(b)));} + AU2 AMinSU2(AU2 a,AU2 b){return AU2(min(ASU2(a),ASU2(b)));} + AU3 AMinSU3(AU3 a,AU3 b){return AU3(min(ASU3(a),ASU3(b)));} + AU4 AMinSU4(AU4 a,AU4 b){return AU4(min(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + // Normalized trig. Valid input domain is {-256 to +256}. No GLSL compiler intrinsic exists to map to this currently. + // V_COS_F32. + AF1 ANCosF1(AF1 x){return cos(x*AF1_(A_2PI));} + AF2 ANCosF2(AF2 x){return cos(x*AF2_(A_2PI));} + AF3 ANCosF3(AF3 x){return cos(x*AF3_(A_2PI));} + AF4 ANCosF4(AF4 x){return cos(x*AF4_(A_2PI));} +//------------------------------------------------------------------------------------------------------------------------------ + // Normalized trig. Valid input domain is {-256 to +256}. No GLSL compiler intrinsic exists to map to this currently. + // V_SIN_F32. + AF1 ANSinF1(AF1 x){return sin(x*AF1_(A_2PI));} + AF2 ANSinF2(AF2 x){return sin(x*AF2_(A_2PI));} + AF3 ANSinF3(AF3 x){return sin(x*AF3_(A_2PI));} + AF4 ANSinF4(AF4 x){return sin(x*AF4_(A_2PI));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ARcpF1(AF1 x){return AF1_(1.0)/x;} + AF2 ARcpF2(AF2 x){return AF2_(1.0)/x;} + AF3 ARcpF3(AF3 x){return AF3_(1.0)/x;} + AF4 ARcpF4(AF4 x){return AF4_(1.0)/x;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ARsqF1(AF1 x){return AF1_(1.0)/sqrt(x);} + AF2 ARsqF2(AF2 x){return AF2_(1.0)/sqrt(x);} + AF3 ARsqF3(AF3 x){return AF3_(1.0)/sqrt(x);} + AF4 ARsqF4(AF4 x){return AF4_(1.0)/sqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ASatF1(AF1 x){return clamp(x,AF1_(0.0),AF1_(1.0));} + AF2 ASatF2(AF2 x){return clamp(x,AF2_(0.0),AF2_(1.0));} + AF3 ASatF3(AF3 x){return clamp(x,AF3_(0.0),AF3_(1.0));} + AF4 ASatF4(AF4 x){return clamp(x,AF4_(0.0),AF4_(1.0));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AShrSU1(AU1 a,AU1 b){return AU1(ASU1(a)>>ASU1(b));} + AU2 AShrSU2(AU2 a,AU2 b){return AU2(ASU2(a)>>ASU2(b));} + AU3 AShrSU3(AU3 a,AU3 b){return AU3(ASU3(a)>>ASU3(b));} + AU4 AShrSU4(AU4 a,AU4 b){return AU4(ASU4(a)>>ASU4(b));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL BYTE +//============================================================================================================================== + #ifdef A_BYTE + #define AB1 uint8_t + #define AB2 u8vec2 + #define AB3 u8vec3 + #define AB4 u8vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASB1 int8_t + #define ASB2 i8vec2 + #define ASB3 i8vec3 + #define ASB4 i8vec4 +//------------------------------------------------------------------------------------------------------------------------------ + AB1 AB1_x(AB1 a){return AB1(a);} + AB2 AB2_x(AB1 a){return AB2(a,a);} + AB3 AB3_x(AB1 a){return AB3(a,a,a);} + AB4 AB4_x(AB1 a){return AB4(a,a,a,a);} + #define AB1_(a) AB1_x(AB1(a)) + #define AB2_(a) AB2_x(AB1(a)) + #define AB3_(a) AB3_x(AB1(a)) + #define AB4_(a) AB4_x(AB1(a)) + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL HALF +//============================================================================================================================== + #ifdef A_HALF + #define AH1 float16_t + #define AH2 f16vec2 + #define AH3 f16vec3 + #define AH4 f16vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AW1 uint16_t + #define AW2 u16vec2 + #define AW3 u16vec3 + #define AW4 u16vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASW1 int16_t + #define ASW2 i16vec2 + #define ASW3 i16vec3 + #define ASW4 i16vec4 +//============================================================================================================================== + #define AH2_AU1(x) unpackFloat2x16(AU1(x)) + AH4 AH4_AU2_x(AU2 x){return AH4(unpackFloat2x16(x.x),unpackFloat2x16(x.y));} + #define AH4_AU2(x) AH4_AU2_x(AU2(x)) + #define AW2_AU1(x) unpackUint2x16(AU1(x)) + #define AW4_AU2(x) unpackUint4x16(pack64(AU2(x))) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AH2(x) packFloat2x16(AH2(x)) + AU2 AU2_AH4_x(AH4 x){return AU2(packFloat2x16(x.xy),packFloat2x16(x.zw));} + #define AU2_AH4(x) AU2_AH4_x(AH4(x)) + #define AU1_AW2(x) packUint2x16(AW2(x)) + #define AU2_AW4(x) unpack32(packUint4x16(AW4(x))) +//============================================================================================================================== + #define AW1_AH1(x) halfBitsToUint16(AH1(x)) + #define AW2_AH2(x) halfBitsToUint16(AH2(x)) + #define AW3_AH3(x) halfBitsToUint16(AH3(x)) + #define AW4_AH4(x) halfBitsToUint16(AH4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AH1_AW1(x) uint16BitsToHalf(AW1(x)) + #define AH2_AW2(x) uint16BitsToHalf(AW2(x)) + #define AH3_AW3(x) uint16BitsToHalf(AW3(x)) + #define AH4_AW4(x) uint16BitsToHalf(AW4(x)) +//============================================================================================================================== + AH1 AH1_x(AH1 a){return AH1(a);} + AH2 AH2_x(AH1 a){return AH2(a,a);} + AH3 AH3_x(AH1 a){return AH3(a,a,a);} + AH4 AH4_x(AH1 a){return AH4(a,a,a,a);} + #define AH1_(a) AH1_x(AH1(a)) + #define AH2_(a) AH2_x(AH1(a)) + #define AH3_(a) AH3_x(AH1(a)) + #define AH4_(a) AH4_x(AH1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AW1_x(AW1 a){return AW1(a);} + AW2 AW2_x(AW1 a){return AW2(a,a);} + AW3 AW3_x(AW1 a){return AW3(a,a,a);} + AW4 AW4_x(AW1 a){return AW4(a,a,a,a);} + #define AW1_(a) AW1_x(AW1(a)) + #define AW2_(a) AW2_x(AW1(a)) + #define AW3_(a) AW3_x(AW1(a)) + #define AW4_(a) AW4_x(AW1(a)) +//============================================================================================================================== + AW1 AAbsSW1(AW1 a){return AW1(abs(ASW1(a)));} + AW2 AAbsSW2(AW2 a){return AW2(abs(ASW2(a)));} + AW3 AAbsSW3(AW3 a){return AW3(abs(ASW3(a)));} + AW4 AAbsSW4(AW4 a){return AW4(abs(ASW4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AClampH1(AH1 x,AH1 n,AH1 m){return clamp(x,n,m);} + AH2 AClampH2(AH2 x,AH2 n,AH2 m){return clamp(x,n,m);} + AH3 AClampH3(AH3 x,AH3 n,AH3 m){return clamp(x,n,m);} + AH4 AClampH4(AH4 x,AH4 n,AH4 m){return clamp(x,n,m);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFractH1(AH1 x){return fract(x);} + AH2 AFractH2(AH2 x){return fract(x);} + AH3 AFractH3(AH3 x){return fract(x);} + AH4 AFractH4(AH4 x){return fract(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ALerpH1(AH1 x,AH1 y,AH1 a){return mix(x,y,a);} + AH2 ALerpH2(AH2 x,AH2 y,AH2 a){return mix(x,y,a);} + AH3 ALerpH3(AH3 x,AH3 y,AH3 a){return mix(x,y,a);} + AH4 ALerpH4(AH4 x,AH4 y,AH4 a){return mix(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + // No packed version of max3. + AH1 AMax3H1(AH1 x,AH1 y,AH1 z){return max(x,max(y,z));} + AH2 AMax3H2(AH2 x,AH2 y,AH2 z){return max(x,max(y,z));} + AH3 AMax3H3(AH3 x,AH3 y,AH3 z){return max(x,max(y,z));} + AH4 AMax3H4(AH4 x,AH4 y,AH4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMaxSW1(AW1 a,AW1 b){return AW1(max(ASU1(a),ASU1(b)));} + AW2 AMaxSW2(AW2 a,AW2 b){return AW2(max(ASU2(a),ASU2(b)));} + AW3 AMaxSW3(AW3 a,AW3 b){return AW3(max(ASU3(a),ASU3(b)));} + AW4 AMaxSW4(AW4 a,AW4 b){return AW4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + // No packed version of min3. + AH1 AMin3H1(AH1 x,AH1 y,AH1 z){return min(x,min(y,z));} + AH2 AMin3H2(AH2 x,AH2 y,AH2 z){return min(x,min(y,z));} + AH3 AMin3H3(AH3 x,AH3 y,AH3 z){return min(x,min(y,z));} + AH4 AMin3H4(AH4 x,AH4 y,AH4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMinSW1(AW1 a,AW1 b){return AW1(min(ASU1(a),ASU1(b)));} + AW2 AMinSW2(AW2 a,AW2 b){return AW2(min(ASU2(a),ASU2(b)));} + AW3 AMinSW3(AW3 a,AW3 b){return AW3(min(ASU3(a),ASU3(b)));} + AW4 AMinSW4(AW4 a,AW4 b){return AW4(min(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARcpH1(AH1 x){return AH1_(1.0)/x;} + AH2 ARcpH2(AH2 x){return AH2_(1.0)/x;} + AH3 ARcpH3(AH3 x){return AH3_(1.0)/x;} + AH4 ARcpH4(AH4 x){return AH4_(1.0)/x;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARsqH1(AH1 x){return AH1_(1.0)/sqrt(x);} + AH2 ARsqH2(AH2 x){return AH2_(1.0)/sqrt(x);} + AH3 ARsqH3(AH3 x){return AH3_(1.0)/sqrt(x);} + AH4 ARsqH4(AH4 x){return AH4_(1.0)/sqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASatH1(AH1 x){return clamp(x,AH1_(0.0),AH1_(1.0));} + AH2 ASatH2(AH2 x){return clamp(x,AH2_(0.0),AH2_(1.0));} + AH3 ASatH3(AH3 x){return clamp(x,AH3_(0.0),AH3_(1.0));} + AH4 ASatH4(AH4 x){return clamp(x,AH4_(0.0),AH4_(1.0));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AShrSW1(AW1 a,AW1 b){return AW1(ASW1(a)>>ASW1(b));} + AW2 AShrSW2(AW2 a,AW2 b){return AW2(ASW2(a)>>ASW2(b));} + AW3 AShrSW3(AW3 a,AW3 b){return AW3(ASW3(a)>>ASW3(b));} + AW4 AShrSW4(AW4 a,AW4 b){return AW4(ASW4(a)>>ASW4(b));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL DOUBLE +//============================================================================================================================== + #ifdef A_DUBL + #define AD1 double + #define AD2 dvec2 + #define AD3 dvec3 + #define AD4 dvec4 +//------------------------------------------------------------------------------------------------------------------------------ + AD1 AD1_x(AD1 a){return AD1(a);} + AD2 AD2_x(AD1 a){return AD2(a,a);} + AD3 AD3_x(AD1 a){return AD3(a,a,a);} + AD4 AD4_x(AD1 a){return AD4(a,a,a,a);} + #define AD1_(a) AD1_x(AD1(a)) + #define AD2_(a) AD2_x(AD1(a)) + #define AD3_(a) AD3_x(AD1(a)) + #define AD4_(a) AD4_x(AD1(a)) +//============================================================================================================================== + AD1 AFractD1(AD1 x){return fract(x);} + AD2 AFractD2(AD2 x){return fract(x);} + AD3 AFractD3(AD3 x){return fract(x);} + AD4 AFractD4(AD4 x){return fract(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ALerpD1(AD1 x,AD1 y,AD1 a){return mix(x,y,a);} + AD2 ALerpD2(AD2 x,AD2 y,AD2 a){return mix(x,y,a);} + AD3 ALerpD3(AD3 x,AD3 y,AD3 a){return mix(x,y,a);} + AD4 ALerpD4(AD4 x,AD4 y,AD4 a){return mix(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARcpD1(AD1 x){return AD1_(1.0)/x;} + AD2 ARcpD2(AD2 x){return AD2_(1.0)/x;} + AD3 ARcpD3(AD3 x){return AD3_(1.0)/x;} + AD4 ARcpD4(AD4 x){return AD4_(1.0)/x;} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARsqD1(AD1 x){return AD1_(1.0)/sqrt(x);} + AD2 ARsqD2(AD2 x){return AD2_(1.0)/sqrt(x);} + AD3 ARsqD3(AD3 x){return AD3_(1.0)/sqrt(x);} + AD4 ARsqD4(AD4 x){return AD4_(1.0)/sqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ASatD1(AD1 x){return clamp(x,AD1_(0.0),AD1_(1.0));} + AD2 ASatD2(AD2 x){return clamp(x,AD2_(0.0),AD2_(1.0));} + AD3 ASatD3(AD3 x){return clamp(x,AD3_(0.0),AD3_(1.0));} + AD4 ASatD4(AD4 x){return clamp(x,AD4_(0.0),AD4_(1.0));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// GLSL LONG +//============================================================================================================================== + #ifdef A_LONG + #define AL1 uint64_t + #define AL2 u64vec2 + #define AL3 u64vec3 + #define AL4 u64vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASL1 int64_t + #define ASL2 i64vec2 + #define ASL3 i64vec3 + #define ASL4 i64vec4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AL1_AU2(x) packUint2x32(AU2(x)) + #define AU2_AL1(x) unpackUint2x32(AL1(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AL1 AL1_x(AL1 a){return AL1(a);} + AL2 AL2_x(AL1 a){return AL2(a,a);} + AL3 AL3_x(AL1 a){return AL3(a,a,a);} + AL4 AL4_x(AL1 a){return AL4(a,a,a,a);} + #define AL1_(a) AL1_x(AL1(a)) + #define AL2_(a) AL2_x(AL1(a)) + #define AL3_(a) AL3_x(AL1(a)) + #define AL4_(a) AL4_x(AL1(a)) +//============================================================================================================================== + AL1 AAbsSL1(AL1 a){return AL1(abs(ASL1(a)));} + AL2 AAbsSL2(AL2 a){return AL2(abs(ASL2(a)));} + AL3 AAbsSL3(AL3 a){return AL3(abs(ASL3(a)));} + AL4 AAbsSL4(AL4 a){return AL4(abs(ASL4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AL1 AMaxSL1(AL1 a,AL1 b){return AL1(max(ASU1(a),ASU1(b)));} + AL2 AMaxSL2(AL2 a,AL2 b){return AL2(max(ASU2(a),ASU2(b)));} + AL3 AMaxSL3(AL3 a,AL3 b){return AL3(max(ASU3(a),ASU3(b)));} + AL4 AMaxSL4(AL4 a,AL4 b){return AL4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AL1 AMinSL1(AL1 a,AL1 b){return AL1(min(ASU1(a),ASU1(b)));} + AL2 AMinSL2(AL2 a,AL2 b){return AL2(min(ASU2(a),ASU2(b)));} + AL3 AMinSL3(AL3 a,AL3 b){return AL3(min(ASU3(a),ASU3(b)));} + AL4 AMinSL4(AL4 a,AL4 b){return AL4(min(ASU4(a),ASU4(b)));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// WAVE OPERATIONS +//============================================================================================================================== + #ifdef A_WAVE + // Where 'x' must be a compile time literal. + AF1 AWaveXorF1(AF1 v,AU1 x){return subgroupShuffleXor(v,x);} + AF2 AWaveXorF2(AF2 v,AU1 x){return subgroupShuffleXor(v,x);} + AF3 AWaveXorF3(AF3 v,AU1 x){return subgroupShuffleXor(v,x);} + AF4 AWaveXorF4(AF4 v,AU1 x){return subgroupShuffleXor(v,x);} + AU1 AWaveXorU1(AU1 v,AU1 x){return subgroupShuffleXor(v,x);} + AU2 AWaveXorU2(AU2 v,AU1 x){return subgroupShuffleXor(v,x);} + AU3 AWaveXorU3(AU3 v,AU1 x){return subgroupShuffleXor(v,x);} + AU4 AWaveXorU4(AU4 v,AU1 x){return subgroupShuffleXor(v,x);} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + AH2 AWaveXorH2(AH2 v,AU1 x){return AH2_AU1(subgroupShuffleXor(AU1_AH2(v),x));} + AH4 AWaveXorH4(AH4 v,AU1 x){return AH4_AU2(subgroupShuffleXor(AU2_AH4(v),x));} + AW2 AWaveXorW2(AW2 v,AU1 x){return AW2_AU1(subgroupShuffleXor(AU1_AW2(v),x));} + AW4 AWaveXorW4(AW4 v,AU1 x){return AW4_AU2(subgroupShuffleXor(AU2_AW4(v),x));} + #endif + #endif +//============================================================================================================================== +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// HLSL +// +// +//============================================================================================================================== +#if defined(A_HLSL) && defined(A_GPU) + #ifdef A_HLSL_6_2 + #define AP1 bool + #define AP2 bool2 + #define AP3 bool3 + #define AP4 bool4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF1 float32_t + #define AF2 float32_t2 + #define AF3 float32_t3 + #define AF4 float32_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1 uint32_t + #define AU2 uint32_t2 + #define AU3 uint32_t3 + #define AU4 uint32_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASU1 int32_t + #define ASU2 int32_t2 + #define ASU3 int32_t3 + #define ASU4 int32_t4 + #else + #define AP1 bool + #define AP2 bool2 + #define AP3 bool3 + #define AP4 bool4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AF1 float + #define AF2 float2 + #define AF3 float3 + #define AF4 float4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1 uint + #define AU2 uint2 + #define AU3 uint3 + #define AU4 uint4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASU1 int + #define ASU2 int2 + #define ASU3 int3 + #define ASU4 int4 + #endif +//============================================================================================================================== + #define AF1_AU1(x) asfloat(AU1(x)) + #define AF2_AU2(x) asfloat(AU2(x)) + #define AF3_AU3(x) asfloat(AU3(x)) + #define AF4_AU4(x) asfloat(AU4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AU1_AF1(x) asuint(AF1(x)) + #define AU2_AF2(x) asuint(AF2(x)) + #define AU3_AF3(x) asuint(AF3(x)) + #define AU4_AF4(x) asuint(AF4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH1_AF1_x(AF1 a){return f32tof16(a);} + #define AU1_AH1_AF1(a) AU1_AH1_AF1_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH2_AF2_x(AF2 a){return f32tof16(a.x)|(f32tof16(a.y)<<16);} + #define AU1_AH2_AF2(a) AU1_AH2_AF2_x(AF2(a)) + #define AU1_AB4Unorm_AF4(x) D3DCOLORtoUBYTE4(AF4(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AF2 AF2_AH2_AU1_x(AU1 x){return AF2(f16tof32(x&0xFFFF),f16tof32(x>>16));} + #define AF2_AH2_AU1(x) AF2_AH2_AU1_x(AU1(x)) +//============================================================================================================================== + AF1 AF1_x(AF1 a){return AF1(a);} + AF2 AF2_x(AF1 a){return AF2(a,a);} + AF3 AF3_x(AF1 a){return AF3(a,a,a);} + AF4 AF4_x(AF1 a){return AF4(a,a,a,a);} + #define AF1_(a) AF1_x(AF1(a)) + #define AF2_(a) AF2_x(AF1(a)) + #define AF3_(a) AF3_x(AF1(a)) + #define AF4_(a) AF4_x(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_x(AU1 a){return AU1(a);} + AU2 AU2_x(AU1 a){return AU2(a,a);} + AU3 AU3_x(AU1 a){return AU3(a,a,a);} + AU4 AU4_x(AU1 a){return AU4(a,a,a,a);} + #define AU1_(a) AU1_x(AU1(a)) + #define AU2_(a) AU2_x(AU1(a)) + #define AU3_(a) AU3_x(AU1(a)) + #define AU4_(a) AU4_x(AU1(a)) +//============================================================================================================================== + AU1 AAbsSU1(AU1 a){return AU1(abs(ASU1(a)));} + AU2 AAbsSU2(AU2 a){return AU2(abs(ASU2(a)));} + AU3 AAbsSU3(AU3 a){return AU3(abs(ASU3(a)));} + AU4 AAbsSU4(AU4 a){return AU4(abs(ASU4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 ABfe(AU1 src,AU1 off,AU1 bits){AU1 mask=(1u<<bits)-1;return (src>>off)&mask;} + AU1 ABfi(AU1 src,AU1 ins,AU1 mask){return (ins&mask)|(src&(~mask));} + AU1 ABfiM(AU1 src,AU1 ins,AU1 bits){AU1 mask=(1u<<bits)-1;return (ins&mask)|(src&(~mask));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AClampF1(AF1 x,AF1 n,AF1 m){return max(n,min(x,m));} + AF2 AClampF2(AF2 x,AF2 n,AF2 m){return max(n,min(x,m));} + AF3 AClampF3(AF3 x,AF3 n,AF3 m){return max(n,min(x,m));} + AF4 AClampF4(AF4 x,AF4 n,AF4 m){return max(n,min(x,m));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFractF1(AF1 x){return x-floor(x);} + AF2 AFractF2(AF2 x){return x-floor(x);} + AF3 AFractF3(AF3 x){return x-floor(x);} + AF4 AFractF4(AF4 x){return x-floor(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ALerpF1(AF1 x,AF1 y,AF1 a){return lerp(x,y,a);} + AF2 ALerpF2(AF2 x,AF2 y,AF2 a){return lerp(x,y,a);} + AF3 ALerpF3(AF3 x,AF3 y,AF3 a){return lerp(x,y,a);} + AF4 ALerpF4(AF4 x,AF4 y,AF4 a){return lerp(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AMax3F1(AF1 x,AF1 y,AF1 z){return max(x,max(y,z));} + AF2 AMax3F2(AF2 x,AF2 y,AF2 z){return max(x,max(y,z));} + AF3 AMax3F3(AF3 x,AF3 y,AF3 z){return max(x,max(y,z));} + AF4 AMax3F4(AF4 x,AF4 y,AF4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMax3SU1(AU1 x,AU1 y,AU1 z){return AU1(max(ASU1(x),max(ASU1(y),ASU1(z))));} + AU2 AMax3SU2(AU2 x,AU2 y,AU2 z){return AU2(max(ASU2(x),max(ASU2(y),ASU2(z))));} + AU3 AMax3SU3(AU3 x,AU3 y,AU3 z){return AU3(max(ASU3(x),max(ASU3(y),ASU3(z))));} + AU4 AMax3SU4(AU4 x,AU4 y,AU4 z){return AU4(max(ASU4(x),max(ASU4(y),ASU4(z))));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMax3U1(AU1 x,AU1 y,AU1 z){return max(x,max(y,z));} + AU2 AMax3U2(AU2 x,AU2 y,AU2 z){return max(x,max(y,z));} + AU3 AMax3U3(AU3 x,AU3 y,AU3 z){return max(x,max(y,z));} + AU4 AMax3U4(AU4 x,AU4 y,AU4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMaxSU1(AU1 a,AU1 b){return AU1(max(ASU1(a),ASU1(b)));} + AU2 AMaxSU2(AU2 a,AU2 b){return AU2(max(ASU2(a),ASU2(b)));} + AU3 AMaxSU3(AU3 a,AU3 b){return AU3(max(ASU3(a),ASU3(b)));} + AU4 AMaxSU4(AU4 a,AU4 b){return AU4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AMed3F1(AF1 x,AF1 y,AF1 z){return max(min(x,y),min(max(x,y),z));} + AF2 AMed3F2(AF2 x,AF2 y,AF2 z){return max(min(x,y),min(max(x,y),z));} + AF3 AMed3F3(AF3 x,AF3 y,AF3 z){return max(min(x,y),min(max(x,y),z));} + AF4 AMed3F4(AF4 x,AF4 y,AF4 z){return max(min(x,y),min(max(x,y),z));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AMin3F1(AF1 x,AF1 y,AF1 z){return min(x,min(y,z));} + AF2 AMin3F2(AF2 x,AF2 y,AF2 z){return min(x,min(y,z));} + AF3 AMin3F3(AF3 x,AF3 y,AF3 z){return min(x,min(y,z));} + AF4 AMin3F4(AF4 x,AF4 y,AF4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMin3SU1(AU1 x,AU1 y,AU1 z){return AU1(min(ASU1(x),min(ASU1(y),ASU1(z))));} + AU2 AMin3SU2(AU2 x,AU2 y,AU2 z){return AU2(min(ASU2(x),min(ASU2(y),ASU2(z))));} + AU3 AMin3SU3(AU3 x,AU3 y,AU3 z){return AU3(min(ASU3(x),min(ASU3(y),ASU3(z))));} + AU4 AMin3SU4(AU4 x,AU4 y,AU4 z){return AU4(min(ASU4(x),min(ASU4(y),ASU4(z))));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMin3U1(AU1 x,AU1 y,AU1 z){return min(x,min(y,z));} + AU2 AMin3U2(AU2 x,AU2 y,AU2 z){return min(x,min(y,z));} + AU3 AMin3U3(AU3 x,AU3 y,AU3 z){return min(x,min(y,z));} + AU4 AMin3U4(AU4 x,AU4 y,AU4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AMinSU1(AU1 a,AU1 b){return AU1(min(ASU1(a),ASU1(b)));} + AU2 AMinSU2(AU2 a,AU2 b){return AU2(min(ASU2(a),ASU2(b)));} + AU3 AMinSU3(AU3 a,AU3 b){return AU3(min(ASU3(a),ASU3(b)));} + AU4 AMinSU4(AU4 a,AU4 b){return AU4(min(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ANCosF1(AF1 x){return cos(x*AF1_(A_2PI));} + AF2 ANCosF2(AF2 x){return cos(x*AF2_(A_2PI));} + AF3 ANCosF3(AF3 x){return cos(x*AF3_(A_2PI));} + AF4 ANCosF4(AF4 x){return cos(x*AF4_(A_2PI));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ANSinF1(AF1 x){return sin(x*AF1_(A_2PI));} + AF2 ANSinF2(AF2 x){return sin(x*AF2_(A_2PI));} + AF3 ANSinF3(AF3 x){return sin(x*AF3_(A_2PI));} + AF4 ANSinF4(AF4 x){return sin(x*AF4_(A_2PI));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ARcpF1(AF1 x){return rcp(x);} + AF2 ARcpF2(AF2 x){return rcp(x);} + AF3 ARcpF3(AF3 x){return rcp(x);} + AF4 ARcpF4(AF4 x){return rcp(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ARsqF1(AF1 x){return rsqrt(x);} + AF2 ARsqF2(AF2 x){return rsqrt(x);} + AF3 ARsqF3(AF3 x){return rsqrt(x);} + AF4 ARsqF4(AF4 x){return rsqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ASatF1(AF1 x){return saturate(x);} + AF2 ASatF2(AF2 x){return saturate(x);} + AF3 ASatF3(AF3 x){return saturate(x);} + AF4 ASatF4(AF4 x){return saturate(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AShrSU1(AU1 a,AU1 b){return AU1(ASU1(a)>>ASU1(b));} + AU2 AShrSU2(AU2 a,AU2 b){return AU2(ASU2(a)>>ASU2(b));} + AU3 AShrSU3(AU3 a,AU3 b){return AU3(ASU3(a)>>ASU3(b));} + AU4 AShrSU4(AU4 a,AU4 b){return AU4(ASU4(a)>>ASU4(b));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HLSL BYTE +//============================================================================================================================== + #ifdef A_BYTE + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HLSL HALF +//============================================================================================================================== + #ifdef A_HALF + #ifdef A_HLSL_6_2 + #define AH1 float16_t + #define AH2 float16_t2 + #define AH3 float16_t3 + #define AH4 float16_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AW1 uint16_t + #define AW2 uint16_t2 + #define AW3 uint16_t3 + #define AW4 uint16_t4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASW1 int16_t + #define ASW2 int16_t2 + #define ASW3 int16_t3 + #define ASW4 int16_t4 + #else + #define AH1 min16float + #define AH2 min16float2 + #define AH3 min16float3 + #define AH4 min16float4 +//------------------------------------------------------------------------------------------------------------------------------ + #define AW1 min16uint + #define AW2 min16uint2 + #define AW3 min16uint3 + #define AW4 min16uint4 +//------------------------------------------------------------------------------------------------------------------------------ + #define ASW1 min16int + #define ASW2 min16int2 + #define ASW3 min16int3 + #define ASW4 min16int4 + #endif +//============================================================================================================================== + // Need to use manual unpack to get optimal execution (don't use packed types in buffers directly). + // Unpack requires this pattern: https://gpuopen.com/first-steps-implementing-fp16/ + AH2 AH2_AU1_x(AU1 x){AF2 t=f16tof32(AU2(x&0xFFFF,x>>16));return AH2(t);} + AH4 AH4_AU2_x(AU2 x){return AH4(AH2_AU1_x(x.x),AH2_AU1_x(x.y));} + AW2 AW2_AU1_x(AU1 x){AU2 t=AU2(x&0xFFFF,x>>16);return AW2(t);} + AW4 AW4_AU2_x(AU2 x){return AW4(AW2_AU1_x(x.x),AW2_AU1_x(x.y));} + #define AH2_AU1(x) AH2_AU1_x(AU1(x)) + #define AH4_AU2(x) AH4_AU2_x(AU2(x)) + #define AW2_AU1(x) AW2_AU1_x(AU1(x)) + #define AW4_AU2(x) AW4_AU2_x(AU2(x)) +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AU1_AH2_x(AH2 x){return f32tof16(x.x)+(f32tof16(x.y)<<16);} + AU2 AU2_AH4_x(AH4 x){return AU2(AU1_AH2_x(x.xy),AU1_AH2_x(x.zw));} + AU1 AU1_AW2_x(AW2 x){return AU1(x.x)+(AU1(x.y)<<16);} + AU2 AU2_AW4_x(AW4 x){return AU2(AU1_AW2_x(x.xy),AU1_AW2_x(x.zw));} + #define AU1_AH2(x) AU1_AH2_x(AH2(x)) + #define AU2_AH4(x) AU2_AH4_x(AH4(x)) + #define AU1_AW2(x) AU1_AW2_x(AW2(x)) + #define AU2_AW4(x) AU2_AW4_x(AW4(x)) +//============================================================================================================================== + #if defined(A_HLSL_6_2) && !defined(A_NO_16_BIT_CAST) + #define AW1_AH1(x) asuint16(x) + #define AW2_AH2(x) asuint16(x) + #define AW3_AH3(x) asuint16(x) + #define AW4_AH4(x) asuint16(x) + #else + #define AW1_AH1(a) AW1(f32tof16(AF1(a))) + #define AW2_AH2(a) AW2(AW1_AH1((a).x),AW1_AH1((a).y)) + #define AW3_AH3(a) AW3(AW1_AH1((a).x),AW1_AH1((a).y),AW1_AH1((a).z)) + #define AW4_AH4(a) AW4(AW1_AH1((a).x),AW1_AH1((a).y),AW1_AH1((a).z),AW1_AH1((a).w)) + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #if defined(A_HLSL_6_2) && !defined(A_NO_16_BIT_CAST) + #define AH1_AW1(x) asfloat16(x) + #define AH2_AW2(x) asfloat16(x) + #define AH3_AW3(x) asfloat16(x) + #define AH4_AW4(x) asfloat16(x) + #else + #define AH1_AW1(a) AH1(f16tof32(AU1(a))) + #define AH2_AW2(a) AH2(AH1_AW1((a).x),AH1_AW1((a).y)) + #define AH3_AW3(a) AH3(AH1_AW1((a).x),AH1_AW1((a).y),AH1_AW1((a).z)) + #define AH4_AW4(a) AH4(AH1_AW1((a).x),AH1_AW1((a).y),AH1_AW1((a).z),AH1_AW1((a).w)) + #endif +//============================================================================================================================== + AH1 AH1_x(AH1 a){return AH1(a);} + AH2 AH2_x(AH1 a){return AH2(a,a);} + AH3 AH3_x(AH1 a){return AH3(a,a,a);} + AH4 AH4_x(AH1 a){return AH4(a,a,a,a);} + #define AH1_(a) AH1_x(AH1(a)) + #define AH2_(a) AH2_x(AH1(a)) + #define AH3_(a) AH3_x(AH1(a)) + #define AH4_(a) AH4_x(AH1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AW1_x(AW1 a){return AW1(a);} + AW2 AW2_x(AW1 a){return AW2(a,a);} + AW3 AW3_x(AW1 a){return AW3(a,a,a);} + AW4 AW4_x(AW1 a){return AW4(a,a,a,a);} + #define AW1_(a) AW1_x(AW1(a)) + #define AW2_(a) AW2_x(AW1(a)) + #define AW3_(a) AW3_x(AW1(a)) + #define AW4_(a) AW4_x(AW1(a)) +//============================================================================================================================== + AW1 AAbsSW1(AW1 a){return AW1(abs(ASW1(a)));} + AW2 AAbsSW2(AW2 a){return AW2(abs(ASW2(a)));} + AW3 AAbsSW3(AW3 a){return AW3(abs(ASW3(a)));} + AW4 AAbsSW4(AW4 a){return AW4(abs(ASW4(a)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AClampH1(AH1 x,AH1 n,AH1 m){return max(n,min(x,m));} + AH2 AClampH2(AH2 x,AH2 n,AH2 m){return max(n,min(x,m));} + AH3 AClampH3(AH3 x,AH3 n,AH3 m){return max(n,min(x,m));} + AH4 AClampH4(AH4 x,AH4 n,AH4 m){return max(n,min(x,m));} +//------------------------------------------------------------------------------------------------------------------------------ + // V_FRACT_F16 (note DX frac() is different). + AH1 AFractH1(AH1 x){return x-floor(x);} + AH2 AFractH2(AH2 x){return x-floor(x);} + AH3 AFractH3(AH3 x){return x-floor(x);} + AH4 AFractH4(AH4 x){return x-floor(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ALerpH1(AH1 x,AH1 y,AH1 a){return lerp(x,y,a);} + AH2 ALerpH2(AH2 x,AH2 y,AH2 a){return lerp(x,y,a);} + AH3 ALerpH3(AH3 x,AH3 y,AH3 a){return lerp(x,y,a);} + AH4 ALerpH4(AH4 x,AH4 y,AH4 a){return lerp(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AMax3H1(AH1 x,AH1 y,AH1 z){return max(x,max(y,z));} + AH2 AMax3H2(AH2 x,AH2 y,AH2 z){return max(x,max(y,z));} + AH3 AMax3H3(AH3 x,AH3 y,AH3 z){return max(x,max(y,z));} + AH4 AMax3H4(AH4 x,AH4 y,AH4 z){return max(x,max(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMaxSW1(AW1 a,AW1 b){return AW1(max(ASU1(a),ASU1(b)));} + AW2 AMaxSW2(AW2 a,AW2 b){return AW2(max(ASU2(a),ASU2(b)));} + AW3 AMaxSW3(AW3 a,AW3 b){return AW3(max(ASU3(a),ASU3(b)));} + AW4 AMaxSW4(AW4 a,AW4 b){return AW4(max(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AMin3H1(AH1 x,AH1 y,AH1 z){return min(x,min(y,z));} + AH2 AMin3H2(AH2 x,AH2 y,AH2 z){return min(x,min(y,z));} + AH3 AMin3H3(AH3 x,AH3 y,AH3 z){return min(x,min(y,z));} + AH4 AMin3H4(AH4 x,AH4 y,AH4 z){return min(x,min(y,z));} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AMinSW1(AW1 a,AW1 b){return AW1(min(ASU1(a),ASU1(b)));} + AW2 AMinSW2(AW2 a,AW2 b){return AW2(min(ASU2(a),ASU2(b)));} + AW3 AMinSW3(AW3 a,AW3 b){return AW3(min(ASU3(a),ASU3(b)));} + AW4 AMinSW4(AW4 a,AW4 b){return AW4(min(ASU4(a),ASU4(b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARcpH1(AH1 x){return rcp(x);} + AH2 ARcpH2(AH2 x){return rcp(x);} + AH3 ARcpH3(AH3 x){return rcp(x);} + AH4 ARcpH4(AH4 x){return rcp(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ARsqH1(AH1 x){return rsqrt(x);} + AH2 ARsqH2(AH2 x){return rsqrt(x);} + AH3 ARsqH3(AH3 x){return rsqrt(x);} + AH4 ARsqH4(AH4 x){return rsqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASatH1(AH1 x){return saturate(x);} + AH2 ASatH2(AH2 x){return saturate(x);} + AH3 ASatH3(AH3 x){return saturate(x);} + AH4 ASatH4(AH4 x){return saturate(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AShrSW1(AW1 a,AW1 b){return AW1(ASW1(a)>>ASW1(b));} + AW2 AShrSW2(AW2 a,AW2 b){return AW2(ASW2(a)>>ASW2(b));} + AW3 AShrSW3(AW3 a,AW3 b){return AW3(ASW3(a)>>ASW3(b));} + AW4 AShrSW4(AW4 a,AW4 b){return AW4(ASW4(a)>>ASW4(b));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HLSL DOUBLE +//============================================================================================================================== + #ifdef A_DUBL + #ifdef A_HLSL_6_2 + #define AD1 float64_t + #define AD2 float64_t2 + #define AD3 float64_t3 + #define AD4 float64_t4 + #else + #define AD1 double + #define AD2 double2 + #define AD3 double3 + #define AD4 double4 + #endif +//------------------------------------------------------------------------------------------------------------------------------ + AD1 AD1_x(AD1 a){return AD1(a);} + AD2 AD2_x(AD1 a){return AD2(a,a);} + AD3 AD3_x(AD1 a){return AD3(a,a,a);} + AD4 AD4_x(AD1 a){return AD4(a,a,a,a);} + #define AD1_(a) AD1_x(AD1(a)) + #define AD2_(a) AD2_x(AD1(a)) + #define AD3_(a) AD3_x(AD1(a)) + #define AD4_(a) AD4_x(AD1(a)) +//============================================================================================================================== + AD1 AFractD1(AD1 a){return a-floor(a);} + AD2 AFractD2(AD2 a){return a-floor(a);} + AD3 AFractD3(AD3 a){return a-floor(a);} + AD4 AFractD4(AD4 a){return a-floor(a);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ALerpD1(AD1 x,AD1 y,AD1 a){return lerp(x,y,a);} + AD2 ALerpD2(AD2 x,AD2 y,AD2 a){return lerp(x,y,a);} + AD3 ALerpD3(AD3 x,AD3 y,AD3 a){return lerp(x,y,a);} + AD4 ALerpD4(AD4 x,AD4 y,AD4 a){return lerp(x,y,a);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARcpD1(AD1 x){return rcp(x);} + AD2 ARcpD2(AD2 x){return rcp(x);} + AD3 ARcpD3(AD3 x){return rcp(x);} + AD4 ARcpD4(AD4 x){return rcp(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ARsqD1(AD1 x){return rsqrt(x);} + AD2 ARsqD2(AD2 x){return rsqrt(x);} + AD3 ARsqD3(AD3 x){return rsqrt(x);} + AD4 ARsqD4(AD4 x){return rsqrt(x);} +//------------------------------------------------------------------------------------------------------------------------------ + AD1 ASatD1(AD1 x){return saturate(x);} + AD2 ASatD2(AD2 x){return saturate(x);} + AD3 ASatD3(AD3 x){return saturate(x);} + AD4 ASatD4(AD4 x){return saturate(x);} + #endif +//============================================================================================================================== +// HLSL WAVE +//============================================================================================================================== + #ifdef A_WAVE + // Where 'x' must be a compile time literal. + AF1 AWaveXorF1(AF1 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AF2 AWaveXorF2(AF2 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AF3 AWaveXorF3(AF3 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AF4 AWaveXorF4(AF4 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU1 AWaveXorU1(AU1 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU2 AWaveXorU1(AU2 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU3 AWaveXorU1(AU3 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} + AU4 AWaveXorU1(AU4 v,AU1 x){return WaveReadLaneAt(v,WaveGetLaneIndex()^x);} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + AH2 AWaveXorH2(AH2 v,AU1 x){return AH2_AU1(WaveReadLaneAt(AU1_AH2(v),WaveGetLaneIndex()^x));} + AH4 AWaveXorH4(AH4 v,AU1 x){return AH4_AU2(WaveReadLaneAt(AU2_AH4(v),WaveGetLaneIndex()^x));} + AW2 AWaveXorW2(AW2 v,AU1 x){return AW2_AU1(WaveReadLaneAt(AU1_AW2(v),WaveGetLaneIndex()^x));} + AW4 AWaveXorW4(AW4 v,AU1 x){return AW4_AU1(WaveReadLaneAt(AU1_AW4(v),WaveGetLaneIndex()^x));} + #endif + #endif +//============================================================================================================================== +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// GPU COMMON +// +// +//============================================================================================================================== +#ifdef A_GPU + // Negative and positive infinity. + #define A_INFP_F AF1_AU1(0x7f800000u) + #define A_INFN_F AF1_AU1(0xff800000u) +//------------------------------------------------------------------------------------------------------------------------------ + // Copy sign from 's' to positive 'd'. + AF1 ACpySgnF1(AF1 d,AF1 s){return AF1_AU1(AU1_AF1(d)|(AU1_AF1(s)&AU1_(0x80000000u)));} + AF2 ACpySgnF2(AF2 d,AF2 s){return AF2_AU2(AU2_AF2(d)|(AU2_AF2(s)&AU2_(0x80000000u)));} + AF3 ACpySgnF3(AF3 d,AF3 s){return AF3_AU3(AU3_AF3(d)|(AU3_AF3(s)&AU3_(0x80000000u)));} + AF4 ACpySgnF4(AF4 d,AF4 s){return AF4_AU4(AU4_AF4(d)|(AU4_AF4(s)&AU4_(0x80000000u)));} +//------------------------------------------------------------------------------------------------------------------------------ + // Single operation to return (useful to create a mask to use in lerp for branch free logic), + // m=NaN := 0 + // m>=0 := 0 + // m<0 := 1 + // Uses the following useful floating point logic, + // saturate(+a*(-INF)==-INF) := 0 + // saturate( 0*(-INF)== NaN) := 0 + // saturate(-a*(-INF)==+INF) := 1 + AF1 ASignedF1(AF1 m){return ASatF1(m*AF1_(A_INFN_F));} + AF2 ASignedF2(AF2 m){return ASatF2(m*AF2_(A_INFN_F));} + AF3 ASignedF3(AF3 m){return ASatF3(m*AF3_(A_INFN_F));} + AF4 ASignedF4(AF4 m){return ASatF4(m*AF4_(A_INFN_F));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AGtZeroF1(AF1 m){return ASatF1(m*AF1_(A_INFP_F));} + AF2 AGtZeroF2(AF2 m){return ASatF2(m*AF2_(A_INFP_F));} + AF3 AGtZeroF3(AF3 m){return ASatF3(m*AF3_(A_INFP_F));} + AF4 AGtZeroF4(AF4 m){return ASatF4(m*AF4_(A_INFP_F));} +//============================================================================================================================== + #ifdef A_HALF + #ifdef A_HLSL_6_2 + #define A_INFP_H AH1_AW1((uint16_t)0x7c00u) + #define A_INFN_H AH1_AW1((uint16_t)0xfc00u) + #else + #define A_INFP_H AH1_AW1(0x7c00u) + #define A_INFN_H AH1_AW1(0xfc00u) + #endif + +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ACpySgnH1(AH1 d,AH1 s){return AH1_AW1(AW1_AH1(d)|(AW1_AH1(s)&AW1_(0x8000u)));} + AH2 ACpySgnH2(AH2 d,AH2 s){return AH2_AW2(AW2_AH2(d)|(AW2_AH2(s)&AW2_(0x8000u)));} + AH3 ACpySgnH3(AH3 d,AH3 s){return AH3_AW3(AW3_AH3(d)|(AW3_AH3(s)&AW3_(0x8000u)));} + AH4 ACpySgnH4(AH4 d,AH4 s){return AH4_AW4(AW4_AH4(d)|(AW4_AH4(s)&AW4_(0x8000u)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASignedH1(AH1 m){return ASatH1(m*AH1_(A_INFN_H));} + AH2 ASignedH2(AH2 m){return ASatH2(m*AH2_(A_INFN_H));} + AH3 ASignedH3(AH3 m){return ASatH3(m*AH3_(A_INFN_H));} + AH4 ASignedH4(AH4 m){return ASatH4(m*AH4_(A_INFN_H));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AGtZeroH1(AH1 m){return ASatH1(m*AH1_(A_INFP_H));} + AH2 AGtZeroH2(AH2 m){return ASatH2(m*AH2_(A_INFP_H));} + AH3 AGtZeroH3(AH3 m){return ASatH3(m*AH3_(A_INFP_H));} + AH4 AGtZeroH4(AH4 m){return ASatH4(m*AH4_(A_INFP_H));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [FIS] FLOAT INTEGER SORTABLE +//------------------------------------------------------------------------------------------------------------------------------ +// Float to integer sortable. +// - If sign bit=0, flip the sign bit (positives). +// - If sign bit=1, flip all bits (negatives). +// Integer sortable to float. +// - If sign bit=1, flip the sign bit (positives). +// - If sign bit=0, flip all bits (negatives). +// Has nice side effects. +// - Larger integers are more positive values. +// - Float zero is mapped to center of integers (so clear to integer zero is a nice default for atomic max usage). +// Burns 3 ops for conversion {shift,or,xor}. +//============================================================================================================================== + AU1 AFisToU1(AU1 x){return x^(( AShrSU1(x,AU1_(31)))|AU1_(0x80000000));} + AU1 AFisFromU1(AU1 x){return x^((~AShrSU1(x,AU1_(31)))|AU1_(0x80000000));} +//------------------------------------------------------------------------------------------------------------------------------ + // Just adjust high 16-bit value (useful when upper part of 32-bit word is a 16-bit float value). + AU1 AFisToHiU1(AU1 x){return x^(( AShrSU1(x,AU1_(15)))|AU1_(0x80000000));} + AU1 AFisFromHiU1(AU1 x){return x^((~AShrSU1(x,AU1_(15)))|AU1_(0x80000000));} +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + AW1 AFisToW1(AW1 x){return x^(( AShrSW1(x,AW1_(15)))|AW1_(0x8000));} + AW1 AFisFromW1(AW1 x){return x^((~AShrSW1(x,AW1_(15)))|AW1_(0x8000));} +//------------------------------------------------------------------------------------------------------------------------------ + AW2 AFisToW2(AW2 x){return x^(( AShrSW2(x,AW2_(15)))|AW2_(0x8000));} + AW2 AFisFromW2(AW2 x){return x^((~AShrSW2(x,AW2_(15)))|AW2_(0x8000));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [PERM] V_PERM_B32 +//------------------------------------------------------------------------------------------------------------------------------ +// Support for V_PERM_B32 started in the 3rd generation of GCN. +//------------------------------------------------------------------------------------------------------------------------------ +// yyyyxxxx - The 'i' input. +// 76543210 +// ======== +// HGFEDCBA - Naming on permutation. +//------------------------------------------------------------------------------------------------------------------------------ +// TODO +// ==== +// - Make sure compiler optimizes this. +//============================================================================================================================== + #ifdef A_HALF + AU1 APerm0E0A(AU2 i){return((i.x )&0xffu)|((i.y<<16)&0xff0000u);} + AU1 APerm0F0B(AU2 i){return((i.x>> 8)&0xffu)|((i.y<< 8)&0xff0000u);} + AU1 APerm0G0C(AU2 i){return((i.x>>16)&0xffu)|((i.y )&0xff0000u);} + AU1 APerm0H0D(AU2 i){return((i.x>>24)&0xffu)|((i.y>> 8)&0xff0000u);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 APermHGFA(AU2 i){return((i.x )&0x000000ffu)|(i.y&0xffffff00u);} + AU1 APermHGFC(AU2 i){return((i.x>>16)&0x000000ffu)|(i.y&0xffffff00u);} + AU1 APermHGAE(AU2 i){return((i.x<< 8)&0x0000ff00u)|(i.y&0xffff00ffu);} + AU1 APermHGCE(AU2 i){return((i.x>> 8)&0x0000ff00u)|(i.y&0xffff00ffu);} + AU1 APermHAFE(AU2 i){return((i.x<<16)&0x00ff0000u)|(i.y&0xff00ffffu);} + AU1 APermHCFE(AU2 i){return((i.x )&0x00ff0000u)|(i.y&0xff00ffffu);} + AU1 APermAGFE(AU2 i){return((i.x<<24)&0xff000000u)|(i.y&0x00ffffffu);} + AU1 APermCGFE(AU2 i){return((i.x<< 8)&0xff000000u)|(i.y&0x00ffffffu);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 APermGCEA(AU2 i){return((i.x)&0x00ff00ffu)|((i.y<<8)&0xff00ff00u);} + AU1 APermGECA(AU2 i){return(((i.x)&0xffu)|((i.x>>8)&0xff00u)|((i.y<<16)&0xff0000u)|((i.y<<8)&0xff000000u));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [BUC] BYTE UNSIGNED CONVERSION +//------------------------------------------------------------------------------------------------------------------------------ +// Designed to use the optimal conversion, enables the scaling to possibly be factored into other computation. +// Works on a range of {0 to A_BUC_<32,16>}, for <32-bit, and 16-bit> respectively. +//------------------------------------------------------------------------------------------------------------------------------ +// OPCODE NOTES +// ============ +// GCN does not do UNORM or SNORM for bytes in opcodes. +// - V_CVT_F32_UBYTE{0,1,2,3} - Unsigned byte to float. +// - V_CVT_PKACC_U8_F32 - Float to unsigned byte (does bit-field insert into 32-bit integer). +// V_PERM_B32 does byte packing with ability to zero fill bytes as well. +// - Can pull out byte values from two sources, and zero fill upper 8-bits of packed hi and lo. +//------------------------------------------------------------------------------------------------------------------------------ +// BYTE : FLOAT - ABuc{0,1,2,3}{To,From}U1() - Designed for V_CVT_F32_UBYTE* and V_CVT_PKACCUM_U8_F32 ops. +// ==== ===== +// 0 : 0 +// 1 : 1 +// ... +// 255 : 255 +// : 256 (just outside the encoding range) +//------------------------------------------------------------------------------------------------------------------------------ +// BYTE : FLOAT - ABuc{0,1,2,3}{To,From}U2() - Designed for 16-bit denormal tricks and V_PERM_B32. +// ==== ===== +// 0 : 0 +// 1 : 1/512 +// 2 : 1/256 +// ... +// 64 : 1/8 +// 128 : 1/4 +// 255 : 255/512 +// : 1/2 (just outside the encoding range) +//------------------------------------------------------------------------------------------------------------------------------ +// OPTIMAL IMPLEMENTATIONS ON AMD ARCHITECTURES +// ============================================ +// r=ABuc0FromU1(i) +// V_CVT_F32_UBYTE0 r,i +// -------------------------------------------- +// r=ABuc0ToU1(d,i) +// V_CVT_PKACCUM_U8_F32 r,i,0,d +// -------------------------------------------- +// d=ABuc0FromU2(i) +// Where 'k0' is an SGPR with 0x0E0A +// Where 'k1' is an SGPR with {32768.0} packed into the lower 16-bits +// V_PERM_B32 d,i.x,i.y,k0 +// V_PK_FMA_F16 d,d,k1.x,0 +// -------------------------------------------- +// r=ABuc0ToU2(d,i) +// Where 'k0' is an SGPR with {1.0/32768.0} packed into the lower 16-bits +// Where 'k1' is an SGPR with 0x???? +// Where 'k2' is an SGPR with 0x???? +// V_PK_FMA_F16 i,i,k0.x,0 +// V_PERM_B32 r.x,i,i,k1 +// V_PERM_B32 r.y,i,i,k2 +//============================================================================================================================== + // Peak range for 32-bit and 16-bit operations. + #define A_BUC_32 (255.0) + #define A_BUC_16 (255.0/512.0) +//============================================================================================================================== + #if 1 + // Designed to be one V_CVT_PKACCUM_U8_F32. + // The extra min is required to pattern match to V_CVT_PKACCUM_U8_F32. + AU1 ABuc0ToU1(AU1 d,AF1 i){return (d&0xffffff00u)|((min(AU1(i),255u) )&(0x000000ffu));} + AU1 ABuc1ToU1(AU1 d,AF1 i){return (d&0xffff00ffu)|((min(AU1(i),255u)<< 8)&(0x0000ff00u));} + AU1 ABuc2ToU1(AU1 d,AF1 i){return (d&0xff00ffffu)|((min(AU1(i),255u)<<16)&(0x00ff0000u));} + AU1 ABuc3ToU1(AU1 d,AF1 i){return (d&0x00ffffffu)|((min(AU1(i),255u)<<24)&(0xff000000u));} +//------------------------------------------------------------------------------------------------------------------------------ + // Designed to be one V_CVT_F32_UBYTE*. + AF1 ABuc0FromU1(AU1 i){return AF1((i )&255u);} + AF1 ABuc1FromU1(AU1 i){return AF1((i>> 8)&255u);} + AF1 ABuc2FromU1(AU1 i){return AF1((i>>16)&255u);} + AF1 ABuc3FromU1(AU1 i){return AF1((i>>24)&255u);} + #endif +//============================================================================================================================== + #ifdef A_HALF + // Takes {x0,x1} and {y0,y1} and builds {{x0,y0},{x1,y1}}. + AW2 ABuc01ToW2(AH2 x,AH2 y){x*=AH2_(1.0/32768.0);y*=AH2_(1.0/32768.0); + return AW2_AU1(APermGCEA(AU2(AU1_AW2(AW2_AH2(x)),AU1_AW2(AW2_AH2(y)))));} +//------------------------------------------------------------------------------------------------------------------------------ + // Designed for 3 ops to do SOA to AOS and conversion. + AU2 ABuc0ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermHGFA(AU2(d.x,b)),APermHGFC(AU2(d.y,b)));} + AU2 ABuc1ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermHGAE(AU2(d.x,b)),APermHGCE(AU2(d.y,b)));} + AU2 ABuc2ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermHAFE(AU2(d.x,b)),APermHCFE(AU2(d.y,b)));} + AU2 ABuc3ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0))); + return AU2(APermAGFE(AU2(d.x,b)),APermCGFE(AU2(d.y,b)));} +//------------------------------------------------------------------------------------------------------------------------------ + // Designed for 2 ops to do both AOS to SOA, and conversion. + AH2 ABuc0FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0E0A(i)))*AH2_(32768.0);} + AH2 ABuc1FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0F0B(i)))*AH2_(32768.0);} + AH2 ABuc2FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0G0C(i)))*AH2_(32768.0);} + AH2 ABuc3FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0H0D(i)))*AH2_(32768.0);} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [BSC] BYTE SIGNED CONVERSION +//------------------------------------------------------------------------------------------------------------------------------ +// Similar to [BUC]. +// Works on a range of {-/+ A_BSC_<32,16>}, for <32-bit, and 16-bit> respectively. +//------------------------------------------------------------------------------------------------------------------------------ +// ENCODING (without zero-based encoding) +// ======== +// 0 = unused (can be used to mean something else) +// 1 = lowest value +// 128 = exact zero center (zero based encoding +// 255 = highest value +//------------------------------------------------------------------------------------------------------------------------------ +// Zero-based [Zb] flips the MSB bit of the byte (making 128 "exact zero" actually zero). +// This is useful if there is a desire for cleared values to decode as zero. +//------------------------------------------------------------------------------------------------------------------------------ +// BYTE : FLOAT - ABsc{0,1,2,3}{To,From}U2() - Designed for 16-bit denormal tricks and V_PERM_B32. +// ==== ===== +// 0 : -127/512 (unused) +// 1 : -126/512 +// 2 : -125/512 +// ... +// 128 : 0 +// ... +// 255 : 127/512 +// : 1/4 (just outside the encoding range) +//============================================================================================================================== + // Peak range for 32-bit and 16-bit operations. + #define A_BSC_32 (127.0) + #define A_BSC_16 (127.0/512.0) +//============================================================================================================================== + #if 1 + AU1 ABsc0ToU1(AU1 d,AF1 i){return (d&0xffffff00u)|((min(AU1(i+128.0),255u) )&(0x000000ffu));} + AU1 ABsc1ToU1(AU1 d,AF1 i){return (d&0xffff00ffu)|((min(AU1(i+128.0),255u)<< 8)&(0x0000ff00u));} + AU1 ABsc2ToU1(AU1 d,AF1 i){return (d&0xff00ffffu)|((min(AU1(i+128.0),255u)<<16)&(0x00ff0000u));} + AU1 ABsc3ToU1(AU1 d,AF1 i){return (d&0x00ffffffu)|((min(AU1(i+128.0),255u)<<24)&(0xff000000u));} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 ABsc0ToZbU1(AU1 d,AF1 i){return ((d&0xffffff00u)|((min(AU1(trunc(i)+128.0),255u) )&(0x000000ffu)))^0x00000080u;} + AU1 ABsc1ToZbU1(AU1 d,AF1 i){return ((d&0xffff00ffu)|((min(AU1(trunc(i)+128.0),255u)<< 8)&(0x0000ff00u)))^0x00008000u;} + AU1 ABsc2ToZbU1(AU1 d,AF1 i){return ((d&0xff00ffffu)|((min(AU1(trunc(i)+128.0),255u)<<16)&(0x00ff0000u)))^0x00800000u;} + AU1 ABsc3ToZbU1(AU1 d,AF1 i){return ((d&0x00ffffffu)|((min(AU1(trunc(i)+128.0),255u)<<24)&(0xff000000u)))^0x80000000u;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ABsc0FromU1(AU1 i){return AF1((i )&255u)-128.0;} + AF1 ABsc1FromU1(AU1 i){return AF1((i>> 8)&255u)-128.0;} + AF1 ABsc2FromU1(AU1 i){return AF1((i>>16)&255u)-128.0;} + AF1 ABsc3FromU1(AU1 i){return AF1((i>>24)&255u)-128.0;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ABsc0FromZbU1(AU1 i){return AF1(((i )&255u)^0x80u)-128.0;} + AF1 ABsc1FromZbU1(AU1 i){return AF1(((i>> 8)&255u)^0x80u)-128.0;} + AF1 ABsc2FromZbU1(AU1 i){return AF1(((i>>16)&255u)^0x80u)-128.0;} + AF1 ABsc3FromZbU1(AU1 i){return AF1(((i>>24)&255u)^0x80u)-128.0;} + #endif +//============================================================================================================================== + #ifdef A_HALF + // Takes {x0,x1} and {y0,y1} and builds {{x0,y0},{x1,y1}}. + AW2 ABsc01ToW2(AH2 x,AH2 y){x=x*AH2_(1.0/32768.0)+AH2_(0.25/32768.0);y=y*AH2_(1.0/32768.0)+AH2_(0.25/32768.0); + return AW2_AU1(APermGCEA(AU2(AU1_AW2(AW2_AH2(x)),AU1_AW2(AW2_AH2(y)))));} +//------------------------------------------------------------------------------------------------------------------------------ + AU2 ABsc0ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermHGFA(AU2(d.x,b)),APermHGFC(AU2(d.y,b)));} + AU2 ABsc1ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermHGAE(AU2(d.x,b)),APermHGCE(AU2(d.y,b)));} + AU2 ABsc2ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermHAFE(AU2(d.x,b)),APermHCFE(AU2(d.y,b)));} + AU2 ABsc3ToU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0))); + return AU2(APermAGFE(AU2(d.x,b)),APermCGFE(AU2(d.y,b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AU2 ABsc0ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermHGFA(AU2(d.x,b)),APermHGFC(AU2(d.y,b)));} + AU2 ABsc1ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermHGAE(AU2(d.x,b)),APermHGCE(AU2(d.y,b)));} + AU2 ABsc2ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermHAFE(AU2(d.x,b)),APermHCFE(AU2(d.y,b)));} + AU2 ABsc3ToZbU2(AU2 d,AH2 i){AU1 b=AU1_AW2(AW2_AH2(i*AH2_(1.0/32768.0)+AH2_(0.25/32768.0)))^0x00800080u; + return AU2(APermAGFE(AU2(d.x,b)),APermCGFE(AU2(d.y,b)));} +//------------------------------------------------------------------------------------------------------------------------------ + AH2 ABsc0FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0E0A(i)))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc1FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0F0B(i)))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc2FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0G0C(i)))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc3FromU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0H0D(i)))*AH2_(32768.0)-AH2_(0.25);} +//------------------------------------------------------------------------------------------------------------------------------ + AH2 ABsc0FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0E0A(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc1FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0F0B(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc2FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0G0C(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + AH2 ABsc3FromZbU2(AU2 i){return AH2_AW2(AW2_AU1(APerm0H0D(i)^0x00800080u))*AH2_(32768.0)-AH2_(0.25);} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// HALF APPROXIMATIONS +//------------------------------------------------------------------------------------------------------------------------------ +// These support only positive inputs. +// Did not see value yet in specialization for range. +// Using quick testing, ended up mostly getting the same "best" approximation for various ranges. +// With hardware that can co-execute transcendentals, the value in approximations could be less than expected. +// However from a latency perspective, if execution of a transcendental is 4 clk, with no packed support, -> 8 clk total. +// And co-execution would require a compiler interleaving a lot of independent work for packed usage. +//------------------------------------------------------------------------------------------------------------------------------ +// The one Newton Raphson iteration form of rsq() was skipped (requires 6 ops total). +// Same with sqrt(), as this could be x*rsq() (7 ops). +//============================================================================================================================== + #ifdef A_HALF + // Minimize squared error across full positive range, 2 ops. + // The 0x1de2 based approximation maps {0 to 1} input maps to < 1 output. + AH1 APrxLoSqrtH1(AH1 a){return AH1_AW1((AW1_AH1(a)>>AW1_(1))+AW1_(0x1de2));} + AH2 APrxLoSqrtH2(AH2 a){return AH2_AW2((AW2_AH2(a)>>AW2_(1))+AW2_(0x1de2));} + AH3 APrxLoSqrtH3(AH3 a){return AH3_AW3((AW3_AH3(a)>>AW3_(1))+AW3_(0x1de2));} + AH4 APrxLoSqrtH4(AH4 a){return AH4_AW4((AW4_AH4(a)>>AW4_(1))+AW4_(0x1de2));} +//------------------------------------------------------------------------------------------------------------------------------ + // Lower precision estimation, 1 op. + // Minimize squared error across {smallest normal to 16384.0}. + AH1 APrxLoRcpH1(AH1 a){return AH1_AW1(AW1_(0x7784)-AW1_AH1(a));} + AH2 APrxLoRcpH2(AH2 a){return AH2_AW2(AW2_(0x7784)-AW2_AH2(a));} + AH3 APrxLoRcpH3(AH3 a){return AH3_AW3(AW3_(0x7784)-AW3_AH3(a));} + AH4 APrxLoRcpH4(AH4 a){return AH4_AW4(AW4_(0x7784)-AW4_AH4(a));} +//------------------------------------------------------------------------------------------------------------------------------ + // Medium precision estimation, one Newton Raphson iteration, 3 ops. + AH1 APrxMedRcpH1(AH1 a){AH1 b=AH1_AW1(AW1_(0x778d)-AW1_AH1(a));return b*(-b*a+AH1_(2.0));} + AH2 APrxMedRcpH2(AH2 a){AH2 b=AH2_AW2(AW2_(0x778d)-AW2_AH2(a));return b*(-b*a+AH2_(2.0));} + AH3 APrxMedRcpH3(AH3 a){AH3 b=AH3_AW3(AW3_(0x778d)-AW3_AH3(a));return b*(-b*a+AH3_(2.0));} + AH4 APrxMedRcpH4(AH4 a){AH4 b=AH4_AW4(AW4_(0x778d)-AW4_AH4(a));return b*(-b*a+AH4_(2.0));} +//------------------------------------------------------------------------------------------------------------------------------ + // Minimize squared error across {smallest normal to 16384.0}, 2 ops. + AH1 APrxLoRsqH1(AH1 a){return AH1_AW1(AW1_(0x59a3)-(AW1_AH1(a)>>AW1_(1)));} + AH2 APrxLoRsqH2(AH2 a){return AH2_AW2(AW2_(0x59a3)-(AW2_AH2(a)>>AW2_(1)));} + AH3 APrxLoRsqH3(AH3 a){return AH3_AW3(AW3_(0x59a3)-(AW3_AH3(a)>>AW3_(1)));} + AH4 APrxLoRsqH4(AH4 a){return AH4_AW4(AW4_(0x59a3)-(AW4_AH4(a)>>AW4_(1)));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// FLOAT APPROXIMATIONS +//------------------------------------------------------------------------------------------------------------------------------ +// Michal Drobot has an excellent presentation on these: "Low Level Optimizations For GCN", +// - Idea dates back to SGI, then to Quake 3, etc. +// - https://michaldrobot.files.wordpress.com/2014/05/gcn_alu_opt_digitaldragons2014.pdf +// - sqrt(x)=rsqrt(x)*x +// - rcp(x)=rsqrt(x)*rsqrt(x) for positive x +// - https://github.com/michaldrobot/ShaderFastLibs/blob/master/ShaderFastMathLib.h +//------------------------------------------------------------------------------------------------------------------------------ +// These below are from perhaps less complete searching for optimal. +// Used FP16 normal range for testing with +4096 32-bit step size for sampling error. +// So these match up well with the half approximations. +//============================================================================================================================== + AF1 APrxLoSqrtF1(AF1 a){return AF1_AU1((AU1_AF1(a)>>AU1_(1))+AU1_(0x1fbc4639));} + AF1 APrxLoRcpF1(AF1 a){return AF1_AU1(AU1_(0x7ef07ebb)-AU1_AF1(a));} + AF1 APrxMedRcpF1(AF1 a){AF1 b=AF1_AU1(AU1_(0x7ef19fff)-AU1_AF1(a));return b*(-b*a+AF1_(2.0));} + AF1 APrxLoRsqF1(AF1 a){return AF1_AU1(AU1_(0x5f347d74)-(AU1_AF1(a)>>AU1_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 APrxLoSqrtF2(AF2 a){return AF2_AU2((AU2_AF2(a)>>AU2_(1))+AU2_(0x1fbc4639));} + AF2 APrxLoRcpF2(AF2 a){return AF2_AU2(AU2_(0x7ef07ebb)-AU2_AF2(a));} + AF2 APrxMedRcpF2(AF2 a){AF2 b=AF2_AU2(AU2_(0x7ef19fff)-AU2_AF2(a));return b*(-b*a+AF2_(2.0));} + AF2 APrxLoRsqF2(AF2 a){return AF2_AU2(AU2_(0x5f347d74)-(AU2_AF2(a)>>AU2_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF3 APrxLoSqrtF3(AF3 a){return AF3_AU3((AU3_AF3(a)>>AU3_(1))+AU3_(0x1fbc4639));} + AF3 APrxLoRcpF3(AF3 a){return AF3_AU3(AU3_(0x7ef07ebb)-AU3_AF3(a));} + AF3 APrxMedRcpF3(AF3 a){AF3 b=AF3_AU3(AU3_(0x7ef19fff)-AU3_AF3(a));return b*(-b*a+AF3_(2.0));} + AF3 APrxLoRsqF3(AF3 a){return AF3_AU3(AU3_(0x5f347d74)-(AU3_AF3(a)>>AU3_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + AF4 APrxLoSqrtF4(AF4 a){return AF4_AU4((AU4_AF4(a)>>AU4_(1))+AU4_(0x1fbc4639));} + AF4 APrxLoRcpF4(AF4 a){return AF4_AU4(AU4_(0x7ef07ebb)-AU4_AF4(a));} + AF4 APrxMedRcpF4(AF4 a){AF4 b=AF4_AU4(AU4_(0x7ef19fff)-AU4_AF4(a));return b*(-b*a+AF4_(2.0));} + AF4 APrxLoRsqF4(AF4 a){return AF4_AU4(AU4_(0x5f347d74)-(AU4_AF4(a)>>AU4_(1)));} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PQ APPROXIMATIONS +//------------------------------------------------------------------------------------------------------------------------------ +// PQ is very close to x^(1/8). The functions below Use the fast float approximation method to do +// PQ<~>Gamma2 (4th power and fast 4th root) and PQ<~>Linear (8th power and fast 8th root). Maximum error is ~0.2%. +//============================================================================================================================== +// Helpers + AF1 Quart(AF1 a) { a = a * a; return a * a;} + AF1 Oct(AF1 a) { a = a * a; a = a * a; return a * a; } + AF2 Quart(AF2 a) { a = a * a; return a * a; } + AF2 Oct(AF2 a) { a = a * a; a = a * a; return a * a; } + AF3 Quart(AF3 a) { a = a * a; return a * a; } + AF3 Oct(AF3 a) { a = a * a; a = a * a; return a * a; } + AF4 Quart(AF4 a) { a = a * a; return a * a; } + AF4 Oct(AF4 a) { a = a * a; a = a * a; return a * a; } + //------------------------------------------------------------------------------------------------------------------------------ + AF1 APrxPQToGamma2(AF1 a) { return Quart(a); } + AF1 APrxPQToLinear(AF1 a) { return Oct(a); } + AF1 APrxLoGamma2ToPQ(AF1 a) { return AF1_AU1((AU1_AF1(a) >> AU1_(2)) + AU1_(0x2F9A4E46)); } + AF1 APrxMedGamma2ToPQ(AF1 a) { AF1 b = AF1_AU1((AU1_AF1(a) >> AU1_(2)) + AU1_(0x2F9A4E46)); AF1 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF1 APrxHighGamma2ToPQ(AF1 a) { return sqrt(sqrt(a)); } + AF1 APrxLoLinearToPQ(AF1 a) { return AF1_AU1((AU1_AF1(a) >> AU1_(3)) + AU1_(0x378D8723)); } + AF1 APrxMedLinearToPQ(AF1 a) { AF1 b = AF1_AU1((AU1_AF1(a) >> AU1_(3)) + AU1_(0x378D8723)); AF1 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF1 APrxHighLinearToPQ(AF1 a) { return sqrt(sqrt(sqrt(a))); } + //------------------------------------------------------------------------------------------------------------------------------ + AF2 APrxPQToGamma2(AF2 a) { return Quart(a); } + AF2 APrxPQToLinear(AF2 a) { return Oct(a); } + AF2 APrxLoGamma2ToPQ(AF2 a) { return AF2_AU2((AU2_AF2(a) >> AU2_(2)) + AU2_(0x2F9A4E46)); } + AF2 APrxMedGamma2ToPQ(AF2 a) { AF2 b = AF2_AU2((AU2_AF2(a) >> AU2_(2)) + AU2_(0x2F9A4E46)); AF2 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF2 APrxHighGamma2ToPQ(AF2 a) { return sqrt(sqrt(a)); } + AF2 APrxLoLinearToPQ(AF2 a) { return AF2_AU2((AU2_AF2(a) >> AU2_(3)) + AU2_(0x378D8723)); } + AF2 APrxMedLinearToPQ(AF2 a) { AF2 b = AF2_AU2((AU2_AF2(a) >> AU2_(3)) + AU2_(0x378D8723)); AF2 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF2 APrxHighLinearToPQ(AF2 a) { return sqrt(sqrt(sqrt(a))); } + //------------------------------------------------------------------------------------------------------------------------------ + AF3 APrxPQToGamma2(AF3 a) { return Quart(a); } + AF3 APrxPQToLinear(AF3 a) { return Oct(a); } + AF3 APrxLoGamma2ToPQ(AF3 a) { return AF3_AU3((AU3_AF3(a) >> AU3_(2)) + AU3_(0x2F9A4E46)); } + AF3 APrxMedGamma2ToPQ(AF3 a) { AF3 b = AF3_AU3((AU3_AF3(a) >> AU3_(2)) + AU3_(0x2F9A4E46)); AF3 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF3 APrxHighGamma2ToPQ(AF3 a) { return sqrt(sqrt(a)); } + AF3 APrxLoLinearToPQ(AF3 a) { return AF3_AU3((AU3_AF3(a) >> AU3_(3)) + AU3_(0x378D8723)); } + AF3 APrxMedLinearToPQ(AF3 a) { AF3 b = AF3_AU3((AU3_AF3(a) >> AU3_(3)) + AU3_(0x378D8723)); AF3 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF3 APrxHighLinearToPQ(AF3 a) { return sqrt(sqrt(sqrt(a))); } + //------------------------------------------------------------------------------------------------------------------------------ + AF4 APrxPQToGamma2(AF4 a) { return Quart(a); } + AF4 APrxPQToLinear(AF4 a) { return Oct(a); } + AF4 APrxLoGamma2ToPQ(AF4 a) { return AF4_AU4((AU4_AF4(a) >> AU4_(2)) + AU4_(0x2F9A4E46)); } + AF4 APrxMedGamma2ToPQ(AF4 a) { AF4 b = AF4_AU4((AU4_AF4(a) >> AU4_(2)) + AU4_(0x2F9A4E46)); AF4 b4 = Quart(b); return b - b * (b4 - a) / (AF1_(4.0) * b4); } + AF4 APrxHighGamma2ToPQ(AF4 a) { return sqrt(sqrt(a)); } + AF4 APrxLoLinearToPQ(AF4 a) { return AF4_AU4((AU4_AF4(a) >> AU4_(3)) + AU4_(0x378D8723)); } + AF4 APrxMedLinearToPQ(AF4 a) { AF4 b = AF4_AU4((AU4_AF4(a) >> AU4_(3)) + AU4_(0x378D8723)); AF4 b8 = Oct(b); return b - b * (b8 - a) / (AF1_(8.0) * b8); } + AF4 APrxHighLinearToPQ(AF4 a) { return sqrt(sqrt(sqrt(a))); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PARABOLIC SIN & COS +//------------------------------------------------------------------------------------------------------------------------------ +// Approximate answers to transcendental questions. +//------------------------------------------------------------------------------------------------------------------------------ +//============================================================================================================================== + #if 1 + // Valid input range is {-1 to 1} representing {0 to 2 pi}. + // Output range is {-1/4 to 1/4} representing {-1 to 1}. + AF1 APSinF1(AF1 x){return x*abs(x)-x;} // MAD. + AF2 APSinF2(AF2 x){return x*abs(x)-x;} + AF1 APCosF1(AF1 x){x=AFractF1(x*AF1_(0.5)+AF1_(0.75));x=x*AF1_(2.0)-AF1_(1.0);return APSinF1(x);} // 3x MAD, FRACT + AF2 APCosF2(AF2 x){x=AFractF2(x*AF2_(0.5)+AF2_(0.75));x=x*AF2_(2.0)-AF2_(1.0);return APSinF2(x);} + AF2 APSinCosF1(AF1 x){AF1 y=AFractF1(x*AF1_(0.5)+AF1_(0.75));y=y*AF1_(2.0)-AF1_(1.0);return APSinF2(AF2(x,y));} + #endif +//------------------------------------------------------------------------------------------------------------------------------ + #ifdef A_HALF + // For a packed {sin,cos} pair, + // - Native takes 16 clocks and 4 issue slots (no packed transcendentals). + // - Parabolic takes 8 clocks and 8 issue slots (only fract is non-packed). + AH1 APSinH1(AH1 x){return x*abs(x)-x;} + AH2 APSinH2(AH2 x){return x*abs(x)-x;} // AND,FMA + AH1 APCosH1(AH1 x){x=AFractH1(x*AH1_(0.5)+AH1_(0.75));x=x*AH1_(2.0)-AH1_(1.0);return APSinH1(x);} + AH2 APCosH2(AH2 x){x=AFractH2(x*AH2_(0.5)+AH2_(0.75));x=x*AH2_(2.0)-AH2_(1.0);return APSinH2(x);} // 3x FMA, 2xFRACT, AND + AH2 APSinCosH1(AH1 x){AH1 y=AFractH1(x*AH1_(0.5)+AH1_(0.75));y=y*AH1_(2.0)-AH1_(1.0);return APSinH2(AH2(x,y));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// [ZOL] ZERO ONE LOGIC +//------------------------------------------------------------------------------------------------------------------------------ +// Conditional free logic designed for easy 16-bit packing, and backwards porting to 32-bit. +//------------------------------------------------------------------------------------------------------------------------------ +// 0 := false +// 1 := true +//------------------------------------------------------------------------------------------------------------------------------ +// AndNot(x,y) -> !(x&y) .... One op. +// AndOr(x,y,z) -> (x&y)|z ... One op. +// GtZero(x) -> x>0.0 ..... One op. +// Sel(x,y,z) -> x?y:z ..... Two ops, has no precision loss. +// Signed(x) -> x<0.0 ..... One op. +// ZeroPass(x,y) -> x?0:y ..... Two ops, 'y' is a pass through safe for aliasing as integer. +//------------------------------------------------------------------------------------------------------------------------------ +// OPTIMIZATION NOTES +// ================== +// - On Vega to use 2 constants in a packed op, pass in as one AW2 or one AH2 'k.xy' and use as 'k.xx' and 'k.yy'. +// For example 'a.xy*k.xx+k.yy'. +//============================================================================================================================== + #if 1 + AU1 AZolAndU1(AU1 x,AU1 y){return min(x,y);} + AU2 AZolAndU2(AU2 x,AU2 y){return min(x,y);} + AU3 AZolAndU3(AU3 x,AU3 y){return min(x,y);} + AU4 AZolAndU4(AU4 x,AU4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AZolNotU1(AU1 x){return x^AU1_(1);} + AU2 AZolNotU2(AU2 x){return x^AU2_(1);} + AU3 AZolNotU3(AU3 x){return x^AU3_(1);} + AU4 AZolNotU4(AU4 x){return x^AU4_(1);} +//------------------------------------------------------------------------------------------------------------------------------ + AU1 AZolOrU1(AU1 x,AU1 y){return max(x,y);} + AU2 AZolOrU2(AU2 x,AU2 y){return max(x,y);} + AU3 AZolOrU3(AU3 x,AU3 y){return max(x,y);} + AU4 AZolOrU4(AU4 x,AU4 y){return max(x,y);} +//============================================================================================================================== + AU1 AZolF1ToU1(AF1 x){return AU1(x);} + AU2 AZolF2ToU2(AF2 x){return AU2(x);} + AU3 AZolF3ToU3(AF3 x){return AU3(x);} + AU4 AZolF4ToU4(AF4 x){return AU4(x);} +//------------------------------------------------------------------------------------------------------------------------------ + // 2 ops, denormals don't work in 32-bit on PC (and if they are enabled, OMOD is disabled). + AU1 AZolNotF1ToU1(AF1 x){return AU1(AF1_(1.0)-x);} + AU2 AZolNotF2ToU2(AF2 x){return AU2(AF2_(1.0)-x);} + AU3 AZolNotF3ToU3(AF3 x){return AU3(AF3_(1.0)-x);} + AU4 AZolNotF4ToU4(AF4 x){return AU4(AF4_(1.0)-x);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolU1ToF1(AU1 x){return AF1(x);} + AF2 AZolU2ToF2(AU2 x){return AF2(x);} + AF3 AZolU3ToF3(AU3 x){return AF3(x);} + AF4 AZolU4ToF4(AU4 x){return AF4(x);} +//============================================================================================================================== + AF1 AZolAndF1(AF1 x,AF1 y){return min(x,y);} + AF2 AZolAndF2(AF2 x,AF2 y){return min(x,y);} + AF3 AZolAndF3(AF3 x,AF3 y){return min(x,y);} + AF4 AZolAndF4(AF4 x,AF4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 ASolAndNotF1(AF1 x,AF1 y){return (-x)*y+AF1_(1.0);} + AF2 ASolAndNotF2(AF2 x,AF2 y){return (-x)*y+AF2_(1.0);} + AF3 ASolAndNotF3(AF3 x,AF3 y){return (-x)*y+AF3_(1.0);} + AF4 ASolAndNotF4(AF4 x,AF4 y){return (-x)*y+AF4_(1.0);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolAndOrF1(AF1 x,AF1 y,AF1 z){return ASatF1(x*y+z);} + AF2 AZolAndOrF2(AF2 x,AF2 y,AF2 z){return ASatF2(x*y+z);} + AF3 AZolAndOrF3(AF3 x,AF3 y,AF3 z){return ASatF3(x*y+z);} + AF4 AZolAndOrF4(AF4 x,AF4 y,AF4 z){return ASatF4(x*y+z);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolGtZeroF1(AF1 x){return ASatF1(x*AF1_(A_INFP_F));} + AF2 AZolGtZeroF2(AF2 x){return ASatF2(x*AF2_(A_INFP_F));} + AF3 AZolGtZeroF3(AF3 x){return ASatF3(x*AF3_(A_INFP_F));} + AF4 AZolGtZeroF4(AF4 x){return ASatF4(x*AF4_(A_INFP_F));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolNotF1(AF1 x){return AF1_(1.0)-x;} + AF2 AZolNotF2(AF2 x){return AF2_(1.0)-x;} + AF3 AZolNotF3(AF3 x){return AF3_(1.0)-x;} + AF4 AZolNotF4(AF4 x){return AF4_(1.0)-x;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolOrF1(AF1 x,AF1 y){return max(x,y);} + AF2 AZolOrF2(AF2 x,AF2 y){return max(x,y);} + AF3 AZolOrF3(AF3 x,AF3 y){return max(x,y);} + AF4 AZolOrF4(AF4 x,AF4 y){return max(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolSelF1(AF1 x,AF1 y,AF1 z){AF1 r=(-x)*z+z;return x*y+r;} + AF2 AZolSelF2(AF2 x,AF2 y,AF2 z){AF2 r=(-x)*z+z;return x*y+r;} + AF3 AZolSelF3(AF3 x,AF3 y,AF3 z){AF3 r=(-x)*z+z;return x*y+r;} + AF4 AZolSelF4(AF4 x,AF4 y,AF4 z){AF4 r=(-x)*z+z;return x*y+r;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolSignedF1(AF1 x){return ASatF1(x*AF1_(A_INFN_F));} + AF2 AZolSignedF2(AF2 x){return ASatF2(x*AF2_(A_INFN_F));} + AF3 AZolSignedF3(AF3 x){return ASatF3(x*AF3_(A_INFN_F));} + AF4 AZolSignedF4(AF4 x){return ASatF4(x*AF4_(A_INFN_F));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AZolZeroPassF1(AF1 x,AF1 y){return AF1_AU1((AU1_AF1(x)!=AU1_(0))?AU1_(0):AU1_AF1(y));} + AF2 AZolZeroPassF2(AF2 x,AF2 y){return AF2_AU2((AU2_AF2(x)!=AU2_(0))?AU2_(0):AU2_AF2(y));} + AF3 AZolZeroPassF3(AF3 x,AF3 y){return AF3_AU3((AU3_AF3(x)!=AU3_(0))?AU3_(0):AU3_AF3(y));} + AF4 AZolZeroPassF4(AF4 x,AF4 y){return AF4_AU4((AU4_AF4(x)!=AU4_(0))?AU4_(0):AU4_AF4(y));} + #endif +//============================================================================================================================== + #ifdef A_HALF + AW1 AZolAndW1(AW1 x,AW1 y){return min(x,y);} + AW2 AZolAndW2(AW2 x,AW2 y){return min(x,y);} + AW3 AZolAndW3(AW3 x,AW3 y){return min(x,y);} + AW4 AZolAndW4(AW4 x,AW4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AZolNotW1(AW1 x){return x^AW1_(1);} + AW2 AZolNotW2(AW2 x){return x^AW2_(1);} + AW3 AZolNotW3(AW3 x){return x^AW3_(1);} + AW4 AZolNotW4(AW4 x){return x^AW4_(1);} +//------------------------------------------------------------------------------------------------------------------------------ + AW1 AZolOrW1(AW1 x,AW1 y){return max(x,y);} + AW2 AZolOrW2(AW2 x,AW2 y){return max(x,y);} + AW3 AZolOrW3(AW3 x,AW3 y){return max(x,y);} + AW4 AZolOrW4(AW4 x,AW4 y){return max(x,y);} +//============================================================================================================================== + // Uses denormal trick. + AW1 AZolH1ToW1(AH1 x){return AW1_AH1(x*AH1_AW1(AW1_(1)));} + AW2 AZolH2ToW2(AH2 x){return AW2_AH2(x*AH2_AW2(AW2_(1)));} + AW3 AZolH3ToW3(AH3 x){return AW3_AH3(x*AH3_AW3(AW3_(1)));} + AW4 AZolH4ToW4(AH4 x){return AW4_AH4(x*AH4_AW4(AW4_(1)));} +//------------------------------------------------------------------------------------------------------------------------------ + // AMD arch lacks a packed conversion opcode. + AH1 AZolW1ToH1(AW1 x){return AH1_AW1(x*AW1_AH1(AH1_(1.0)));} + AH2 AZolW2ToH2(AW2 x){return AH2_AW2(x*AW2_AH2(AH2_(1.0)));} + AH3 AZolW1ToH3(AW3 x){return AH3_AW3(x*AW3_AH3(AH3_(1.0)));} + AH4 AZolW2ToH4(AW4 x){return AH4_AW4(x*AW4_AH4(AH4_(1.0)));} +//============================================================================================================================== + AH1 AZolAndH1(AH1 x,AH1 y){return min(x,y);} + AH2 AZolAndH2(AH2 x,AH2 y){return min(x,y);} + AH3 AZolAndH3(AH3 x,AH3 y){return min(x,y);} + AH4 AZolAndH4(AH4 x,AH4 y){return min(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 ASolAndNotH1(AH1 x,AH1 y){return (-x)*y+AH1_(1.0);} + AH2 ASolAndNotH2(AH2 x,AH2 y){return (-x)*y+AH2_(1.0);} + AH3 ASolAndNotH3(AH3 x,AH3 y){return (-x)*y+AH3_(1.0);} + AH4 ASolAndNotH4(AH4 x,AH4 y){return (-x)*y+AH4_(1.0);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolAndOrH1(AH1 x,AH1 y,AH1 z){return ASatH1(x*y+z);} + AH2 AZolAndOrH2(AH2 x,AH2 y,AH2 z){return ASatH2(x*y+z);} + AH3 AZolAndOrH3(AH3 x,AH3 y,AH3 z){return ASatH3(x*y+z);} + AH4 AZolAndOrH4(AH4 x,AH4 y,AH4 z){return ASatH4(x*y+z);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolGtZeroH1(AH1 x){return ASatH1(x*AH1_(A_INFP_H));} + AH2 AZolGtZeroH2(AH2 x){return ASatH2(x*AH2_(A_INFP_H));} + AH3 AZolGtZeroH3(AH3 x){return ASatH3(x*AH3_(A_INFP_H));} + AH4 AZolGtZeroH4(AH4 x){return ASatH4(x*AH4_(A_INFP_H));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolNotH1(AH1 x){return AH1_(1.0)-x;} + AH2 AZolNotH2(AH2 x){return AH2_(1.0)-x;} + AH3 AZolNotH3(AH3 x){return AH3_(1.0)-x;} + AH4 AZolNotH4(AH4 x){return AH4_(1.0)-x;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolOrH1(AH1 x,AH1 y){return max(x,y);} + AH2 AZolOrH2(AH2 x,AH2 y){return max(x,y);} + AH3 AZolOrH3(AH3 x,AH3 y){return max(x,y);} + AH4 AZolOrH4(AH4 x,AH4 y){return max(x,y);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolSelH1(AH1 x,AH1 y,AH1 z){AH1 r=(-x)*z+z;return x*y+r;} + AH2 AZolSelH2(AH2 x,AH2 y,AH2 z){AH2 r=(-x)*z+z;return x*y+r;} + AH3 AZolSelH3(AH3 x,AH3 y,AH3 z){AH3 r=(-x)*z+z;return x*y+r;} + AH4 AZolSelH4(AH4 x,AH4 y,AH4 z){AH4 r=(-x)*z+z;return x*y+r;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AZolSignedH1(AH1 x){return ASatH1(x*AH1_(A_INFN_H));} + AH2 AZolSignedH2(AH2 x){return ASatH2(x*AH2_(A_INFN_H));} + AH3 AZolSignedH3(AH3 x){return ASatH3(x*AH3_(A_INFN_H));} + AH4 AZolSignedH4(AH4 x){return ASatH4(x*AH4_(A_INFN_H));} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// COLOR CONVERSIONS +//------------------------------------------------------------------------------------------------------------------------------ +// These are all linear to/from some other space (where 'linear' has been shortened out of the function name). +// So 'ToGamma' is 'LinearToGamma', and 'FromGamma' is 'LinearFromGamma'. +// These are branch free implementations. +// The AToSrgbF1() function is useful for stores for compute shaders for GPUs without hardware linear->sRGB store conversion. +//------------------------------------------------------------------------------------------------------------------------------ +// TRANSFER FUNCTIONS +// ================== +// 709 ..... Rec709 used for some HDTVs +// Gamma ... Typically 2.2 for some PC displays, or 2.4-2.5 for CRTs, or 2.2 FreeSync2 native +// Pq ...... PQ native for HDR10 +// Srgb .... The sRGB output, typical of PC displays, useful for 10-bit output, or storing to 8-bit UNORM without SRGB type +// Two ..... Gamma 2.0, fastest conversion (useful for intermediate pass approximations) +// Three ... Gamma 3.0, less fast, but good for HDR. +//------------------------------------------------------------------------------------------------------------------------------ +// KEEPING TO SPEC +// =============== +// Both Rec.709 and sRGB have a linear segment which as spec'ed would intersect the curved segment 2 times. +// (a.) For 8-bit sRGB, steps {0 to 10.3} are in the linear region (4% of the encoding range). +// (b.) For 8-bit 709, steps {0 to 20.7} are in the linear region (8% of the encoding range). +// Also there is a slight step in the transition regions. +// Precision of the coefficients in the spec being the likely cause. +// Main usage case of the sRGB code is to do the linear->sRGB converstion in a compute shader before store. +// This is to work around lack of hardware (typically only ROP does the conversion for free). +// To "correct" the linear segment, would be to introduce error, because hardware decode of sRGB->linear is fixed (and free). +// So this header keeps with the spec. +// For linear->sRGB transforms, the linear segment in some respects reduces error, because rounding in that region is linear. +// Rounding in the curved region in hardware (and fast software code) introduces error due to rounding in non-linear. +//------------------------------------------------------------------------------------------------------------------------------ +// FOR PQ +// ====== +// Both input and output is {0.0-1.0}, and where output 1.0 represents 10000.0 cd/m^2. +// All constants are only specified to FP32 precision. +// External PQ source reference, +// - https://github.com/ampas/aces-dev/blob/master/transforms/ctl/utilities/ACESlib.Utilities_Color.a1.0.1.ctl +//------------------------------------------------------------------------------------------------------------------------------ +// PACKED VERSIONS +// =============== +// These are the A*H2() functions. +// There is no PQ functions as FP16 seemed to not have enough precision for the conversion. +// The remaining functions are "good enough" for 8-bit, and maybe 10-bit if not concerned about a few 1-bit errors. +// Precision is lowest in the 709 conversion, higher in sRGB, higher still in Two and Gamma (when using 2.2 at least). +//------------------------------------------------------------------------------------------------------------------------------ +// NOTES +// ===== +// Could be faster for PQ conversions to be in ALU or a texture lookup depending on usage case. +//============================================================================================================================== + #if 1 + AF1 ATo709F1(AF1 c){AF3 j=AF3(0.018*4.5,4.5,0.45);AF2 k=AF2(1.099,-0.099); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AF2 ATo709F2(AF2 c){AF3 j=AF3(0.018*4.5,4.5,0.45);AF2 k=AF2(1.099,-0.099); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AF3 ATo709F3(AF3 c){AF3 j=AF3(0.018*4.5,4.5,0.45);AF2 k=AF2(1.099,-0.099); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + // Note 'rcpX' is '1/x', where the 'x' is what would be used in AFromGamma(). + AF1 AToGammaF1(AF1 c,AF1 rcpX){return pow(c,AF1_(rcpX));} + AF2 AToGammaF2(AF2 c,AF1 rcpX){return pow(c,AF2_(rcpX));} + AF3 AToGammaF3(AF3 c,AF1 rcpX){return pow(c,AF3_(rcpX));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToPqF1(AF1 x){AF1 p=pow(x,AF1_(0.159302)); + return pow((AF1_(0.835938)+AF1_(18.8516)*p)/(AF1_(1.0)+AF1_(18.6875)*p),AF1_(78.8438));} + AF2 AToPqF1(AF2 x){AF2 p=pow(x,AF2_(0.159302)); + return pow((AF2_(0.835938)+AF2_(18.8516)*p)/(AF2_(1.0)+AF2_(18.6875)*p),AF2_(78.8438));} + AF3 AToPqF1(AF3 x){AF3 p=pow(x,AF3_(0.159302)); + return pow((AF3_(0.835938)+AF3_(18.8516)*p)/(AF3_(1.0)+AF3_(18.6875)*p),AF3_(78.8438));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToSrgbF1(AF1 c){AF3 j=AF3(0.0031308*12.92,12.92,1.0/2.4);AF2 k=AF2(1.055,-0.055); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AF2 AToSrgbF2(AF2 c){AF3 j=AF3(0.0031308*12.92,12.92,1.0/2.4);AF2 k=AF2(1.055,-0.055); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AF3 AToSrgbF3(AF3 c){AF3 j=AF3(0.0031308*12.92,12.92,1.0/2.4);AF2 k=AF2(1.055,-0.055); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToTwoF1(AF1 c){return sqrt(c);} + AF2 AToTwoF2(AF2 c){return sqrt(c);} + AF3 AToTwoF3(AF3 c){return sqrt(c);} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AToThreeF1(AF1 c){return pow(c,AF1_(1.0/3.0));} + AF2 AToThreeF2(AF2 c){return pow(c,AF2_(1.0/3.0));} + AF3 AToThreeF3(AF3 c){return pow(c,AF3_(1.0/3.0));} + #endif +//============================================================================================================================== + #if 1 + // Unfortunately median won't work here. + AF1 AFrom709F1(AF1 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); + return AZolSelF1(AZolSignedF1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AF2 AFrom709F2(AF2 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); + return AZolSelF2(AZolSignedF2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AF3 AFrom709F3(AF3 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); + return AZolSelF3(AZolSignedF3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromGammaF1(AF1 c,AF1 x){return pow(c,AF1_(x));} + AF2 AFromGammaF2(AF2 c,AF1 x){return pow(c,AF2_(x));} + AF3 AFromGammaF3(AF3 c,AF1 x){return pow(c,AF3_(x));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromPqF1(AF1 x){AF1 p=pow(x,AF1_(0.0126833)); + return pow(ASatF1(p-AF1_(0.835938))/(AF1_(18.8516)-AF1_(18.6875)*p),AF1_(6.27739));} + AF2 AFromPqF1(AF2 x){AF2 p=pow(x,AF2_(0.0126833)); + return pow(ASatF2(p-AF2_(0.835938))/(AF2_(18.8516)-AF2_(18.6875)*p),AF2_(6.27739));} + AF3 AFromPqF1(AF3 x){AF3 p=pow(x,AF3_(0.0126833)); + return pow(ASatF3(p-AF3_(0.835938))/(AF3_(18.8516)-AF3_(18.6875)*p),AF3_(6.27739));} +//------------------------------------------------------------------------------------------------------------------------------ + // Unfortunately median won't work here. + AF1 AFromSrgbF1(AF1 c){AF3 j=AF3(0.04045/12.92,1.0/12.92,2.4);AF2 k=AF2(1.0/1.055,0.055/1.055); + return AZolSelF1(AZolSignedF1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AF2 AFromSrgbF2(AF2 c){AF3 j=AF3(0.04045/12.92,1.0/12.92,2.4);AF2 k=AF2(1.0/1.055,0.055/1.055); + return AZolSelF2(AZolSignedF2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AF3 AFromSrgbF3(AF3 c){AF3 j=AF3(0.04045/12.92,1.0/12.92,2.4);AF2 k=AF2(1.0/1.055,0.055/1.055); + return AZolSelF3(AZolSignedF3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromTwoF1(AF1 c){return c*c;} + AF2 AFromTwoF2(AF2 c){return c*c;} + AF3 AFromTwoF3(AF3 c){return c*c;} +//------------------------------------------------------------------------------------------------------------------------------ + AF1 AFromThreeF1(AF1 c){return c*c*c;} + AF2 AFromThreeF2(AF2 c){return c*c*c;} + AF3 AFromThreeF3(AF3 c){return c*c*c;} + #endif +//============================================================================================================================== + #ifdef A_HALF + AH1 ATo709H1(AH1 c){AH3 j=AH3(0.018*4.5,4.5,0.45);AH2 k=AH2(1.099,-0.099); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AH2 ATo709H2(AH2 c){AH3 j=AH3(0.018*4.5,4.5,0.45);AH2 k=AH2(1.099,-0.099); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AH3 ATo709H3(AH3 c){AH3 j=AH3(0.018*4.5,4.5,0.45);AH2 k=AH2(1.099,-0.099); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToGammaH1(AH1 c,AH1 rcpX){return pow(c,AH1_(rcpX));} + AH2 AToGammaH2(AH2 c,AH1 rcpX){return pow(c,AH2_(rcpX));} + AH3 AToGammaH3(AH3 c,AH1 rcpX){return pow(c,AH3_(rcpX));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToSrgbH1(AH1 c){AH3 j=AH3(0.0031308*12.92,12.92,1.0/2.4);AH2 k=AH2(1.055,-0.055); + return clamp(j.x ,c*j.y ,pow(c,j.z )*k.x +k.y );} + AH2 AToSrgbH2(AH2 c){AH3 j=AH3(0.0031308*12.92,12.92,1.0/2.4);AH2 k=AH2(1.055,-0.055); + return clamp(j.xx ,c*j.yy ,pow(c,j.zz )*k.xx +k.yy );} + AH3 AToSrgbH3(AH3 c){AH3 j=AH3(0.0031308*12.92,12.92,1.0/2.4);AH2 k=AH2(1.055,-0.055); + return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToTwoH1(AH1 c){return sqrt(c);} + AH2 AToTwoH2(AH2 c){return sqrt(c);} + AH3 AToTwoH3(AH3 c){return sqrt(c);} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AToThreeF1(AH1 c){return pow(c,AH1_(1.0/3.0));} + AH2 AToThreeF2(AH2 c){return pow(c,AH2_(1.0/3.0));} + AH3 AToThreeF3(AH3 c){return pow(c,AH3_(1.0/3.0));} + #endif +//============================================================================================================================== + #ifdef A_HALF + AH1 AFrom709H1(AH1 c){AH3 j=AH3(0.081/4.5,1.0/4.5,1.0/0.45);AH2 k=AH2(1.0/1.099,0.099/1.099); + return AZolSelH1(AZolSignedH1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AH2 AFrom709H2(AH2 c){AH3 j=AH3(0.081/4.5,1.0/4.5,1.0/0.45);AH2 k=AH2(1.0/1.099,0.099/1.099); + return AZolSelH2(AZolSignedH2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AH3 AFrom709H3(AH3 c){AH3 j=AH3(0.081/4.5,1.0/4.5,1.0/0.45);AH2 k=AH2(1.0/1.099,0.099/1.099); + return AZolSelH3(AZolSignedH3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFromGammaH1(AH1 c,AH1 x){return pow(c,AH1_(x));} + AH2 AFromGammaH2(AH2 c,AH1 x){return pow(c,AH2_(x));} + AH3 AFromGammaH3(AH3 c,AH1 x){return pow(c,AH3_(x));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AHromSrgbF1(AH1 c){AH3 j=AH3(0.04045/12.92,1.0/12.92,2.4);AH2 k=AH2(1.0/1.055,0.055/1.055); + return AZolSelH1(AZolSignedH1(c-j.x ),c*j.y ,pow(c*k.x +k.y ,j.z ));} + AH2 AHromSrgbF2(AH2 c){AH3 j=AH3(0.04045/12.92,1.0/12.92,2.4);AH2 k=AH2(1.0/1.055,0.055/1.055); + return AZolSelH2(AZolSignedH2(c-j.xx ),c*j.yy ,pow(c*k.xx +k.yy ,j.zz ));} + AH3 AHromSrgbF3(AH3 c){AH3 j=AH3(0.04045/12.92,1.0/12.92,2.4);AH2 k=AH2(1.0/1.055,0.055/1.055); + return AZolSelH3(AZolSignedH3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFromTwoH1(AH1 c){return c*c;} + AH2 AFromTwoH2(AH2 c){return c*c;} + AH3 AFromTwoH3(AH3 c){return c*c;} +//------------------------------------------------------------------------------------------------------------------------------ + AH1 AFromThreeH1(AH1 c){return c*c*c;} + AH2 AFromThreeH2(AH2 c){return c*c*c;} + AH3 AFromThreeH3(AH3 c){return c*c*c;} + #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// CS REMAP +//============================================================================================================================== + // Simple remap 64x1 to 8x8 with rotated 2x2 pixel quads in quad linear. + // 543210 + // ====== + // ..xxx. + // yy...y + AU2 ARmp8x8(AU1 a){return AU2(ABfe(a,1u,3u),ABfiM(ABfe(a,3u,3u),a,1u));} +//============================================================================================================================== + // More complex remap 64x1 to 8x8 which is necessary for 2D wave reductions. + // 543210 + // ====== + // .xx..x + // y..yy. + // Details, + // LANE TO 8x8 MAPPING + // =================== + // 00 01 08 09 10 11 18 19 + // 02 03 0a 0b 12 13 1a 1b + // 04 05 0c 0d 14 15 1c 1d + // 06 07 0e 0f 16 17 1e 1f + // 20 21 28 29 30 31 38 39 + // 22 23 2a 2b 32 33 3a 3b + // 24 25 2c 2d 34 35 3c 3d + // 26 27 2e 2f 36 37 3e 3f + AU2 ARmpRed8x8(AU1 a){return AU2(ABfiM(ABfe(a,2u,3u),a,1u),ABfiM(ABfe(a,3u,3u),ABfe(a,1u,2u),2u));} +//============================================================================================================================== + #ifdef A_HALF + AW2 ARmp8x8H(AU1 a){return AW2(ABfe(a,1u,3u),ABfiM(ABfe(a,3u,3u),a,1u));} + AW2 ARmpRed8x8H(AU1 a){return AW2(ABfiM(ABfe(a,2u,3u),a,1u),ABfiM(ABfe(a,3u,3u),ABfe(a,1u,2u),2u));} + #endif +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// REFERENCE +// +//------------------------------------------------------------------------------------------------------------------------------ +// IEEE FLOAT RULES +// ================ +// - saturate(NaN)=0, saturate(-INF)=0, saturate(+INF)=1 +// - {+/-}0 * {+/-}INF = NaN +// - -INF + (+INF) = NaN +// - {+/-}0 / {+/-}0 = NaN +// - {+/-}INF / {+/-}INF = NaN +// - a<(-0) := sqrt(a) = NaN (a=-0.0 won't NaN) +// - 0 == -0 +// - 4/0 = +INF +// - 4/-0 = -INF +// - 4+INF = +INF +// - 4-INF = -INF +// - 4*(+INF) = +INF +// - 4*(-INF) = -INF +// - -4*(+INF) = -INF +// - sqrt(+INF) = +INF +//------------------------------------------------------------------------------------------------------------------------------ +// FP16 ENCODING +// ============= +// fedcba9876543210 +// ---------------- +// ......mmmmmmmmmm 10-bit mantissa (encodes 11-bit 0.5 to 1.0 except for denormals) +// .eeeee.......... 5-bit exponent +// .00000.......... denormals +// .00001.......... -14 exponent +// .11110.......... 15 exponent +// .111110000000000 infinity +// .11111nnnnnnnnnn NaN with n!=0 +// s............... sign +//------------------------------------------------------------------------------------------------------------------------------ +// FP16/INT16 ALIASING DENORMAL +// ============================ +// 11-bit unsigned integers alias with half float denormal/normal values, +// 1 = 2^(-24) = 1/16777216 ....................... first denormal value +// 2 = 2^(-23) +// ... +// 1023 = 2^(-14)*(1-2^(-10)) = 2^(-14)*(1-1/1024) ... last denormal value +// 1024 = 2^(-14) = 1/16384 .......................... first normal value that still maps to integers +// 2047 .............................................. last normal value that still maps to integers +// Scaling limits, +// 2^15 = 32768 ...................................... largest power of 2 scaling +// Largest pow2 conversion mapping is at *32768, +// 1 : 2^(-9) = 1/512 +// 2 : 1/256 +// 4 : 1/128 +// 8 : 1/64 +// 16 : 1/32 +// 32 : 1/16 +// 64 : 1/8 +// 128 : 1/4 +// 256 : 1/2 +// 512 : 1 +// 1024 : 2 +// 2047 : a little less than 4 +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// GPU/CPU PORTABILITY +// +// +//------------------------------------------------------------------------------------------------------------------------------ +// This is the GPU implementation. +// See the CPU implementation for docs. +//============================================================================================================================== +#ifdef A_GPU + #define A_TRUE true + #define A_FALSE false + #define A_STATIC +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR ARGUMENT/RETURN/INITIALIZATION PORTABILITY +//============================================================================================================================== + #define retAD2 AD2 + #define retAD3 AD3 + #define retAD4 AD4 + #define retAF2 AF2 + #define retAF3 AF3 + #define retAF4 AF4 + #define retAL2 AL2 + #define retAL3 AL3 + #define retAL4 AL4 + #define retAU2 AU2 + #define retAU3 AU3 + #define retAU4 AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define inAD2 in AD2 + #define inAD3 in AD3 + #define inAD4 in AD4 + #define inAF2 in AF2 + #define inAF3 in AF3 + #define inAF4 in AF4 + #define inAL2 in AL2 + #define inAL3 in AL3 + #define inAL4 in AL4 + #define inAU2 in AU2 + #define inAU3 in AU3 + #define inAU4 in AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define inoutAD2 inout AD2 + #define inoutAD3 inout AD3 + #define inoutAD4 inout AD4 + #define inoutAF2 inout AF2 + #define inoutAF3 inout AF3 + #define inoutAF4 inout AF4 + #define inoutAL2 inout AL2 + #define inoutAL3 inout AL3 + #define inoutAL4 inout AL4 + #define inoutAU2 inout AU2 + #define inoutAU3 inout AU3 + #define inoutAU4 inout AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define outAD2 out AD2 + #define outAD3 out AD3 + #define outAD4 out AD4 + #define outAF2 out AF2 + #define outAF3 out AF3 + #define outAF4 out AF4 + #define outAL2 out AL2 + #define outAL3 out AL3 + #define outAL4 out AL4 + #define outAU2 out AU2 + #define outAU3 out AU3 + #define outAU4 out AU4 +//------------------------------------------------------------------------------------------------------------------------------ + #define varAD2(x) AD2 x + #define varAD3(x) AD3 x + #define varAD4(x) AD4 x + #define varAF2(x) AF2 x + #define varAF3(x) AF3 x + #define varAF4(x) AF4 x + #define varAL2(x) AL2 x + #define varAL3(x) AL3 x + #define varAL4(x) AL4 x + #define varAU2(x) AU2 x + #define varAU3(x) AU3 x + #define varAU4(x) AU4 x +//------------------------------------------------------------------------------------------------------------------------------ + #define initAD2(x,y) AD2(x,y) + #define initAD3(x,y,z) AD3(x,y,z) + #define initAD4(x,y,z,w) AD4(x,y,z,w) + #define initAF2(x,y) AF2(x,y) + #define initAF3(x,y,z) AF3(x,y,z) + #define initAF4(x,y,z,w) AF4(x,y,z,w) + #define initAL2(x,y) AL2(x,y) + #define initAL3(x,y,z) AL3(x,y,z) + #define initAL4(x,y,z,w) AL4(x,y,z,w) + #define initAU2(x,y) AU2(x,y) + #define initAU3(x,y,z) AU3(x,y,z) + #define initAU4(x,y,z,w) AU4(x,y,z,w) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS +//============================================================================================================================== + #define AAbsD1(a) abs(AD1(a)) + #define AAbsF1(a) abs(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ACosD1(a) cos(AD1(a)) + #define ACosF1(a) cos(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ADotD2(a,b) dot(AD2(a),AD2(b)) + #define ADotD3(a,b) dot(AD3(a),AD3(b)) + #define ADotD4(a,b) dot(AD4(a),AD4(b)) + #define ADotF2(a,b) dot(AF2(a),AF2(b)) + #define ADotF3(a,b) dot(AF3(a),AF3(b)) + #define ADotF4(a,b) dot(AF4(a),AF4(b)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AExp2D1(a) exp2(AD1(a)) + #define AExp2F1(a) exp2(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AFloorD1(a) floor(AD1(a)) + #define AFloorF1(a) floor(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ALog2D1(a) log2(AD1(a)) + #define ALog2F1(a) log2(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define AMaxD1(a,b) max(a,b) + #define AMaxF1(a,b) max(a,b) + #define AMaxL1(a,b) max(a,b) + #define AMaxU1(a,b) max(a,b) +//------------------------------------------------------------------------------------------------------------------------------ + #define AMinD1(a,b) min(a,b) + #define AMinF1(a,b) min(a,b) + #define AMinL1(a,b) min(a,b) + #define AMinU1(a,b) min(a,b) +//------------------------------------------------------------------------------------------------------------------------------ + #define ASinD1(a) sin(AD1(a)) + #define ASinF1(a) sin(AF1(a)) +//------------------------------------------------------------------------------------------------------------------------------ + #define ASqrtD1(a) sqrt(AD1(a)) + #define ASqrtF1(a) sqrt(AF1(a)) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// SCALAR RETURN OPS - DEPENDENT +//============================================================================================================================== + #define APowD1(a,b) pow(AD1(a),AF1(b)) + #define APowF1(a,b) pow(AF1(a),AF1(b)) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// VECTOR OPS +//------------------------------------------------------------------------------------------------------------------------------ +// These are added as needed for production or prototyping, so not necessarily a complete set. +// They follow a convention of taking in a destination and also returning the destination value to increase utility. +//============================================================================================================================== + #ifdef A_DUBL + AD2 opAAbsD2(outAD2 d,inAD2 a){d=abs(a);return d;} + AD3 opAAbsD3(outAD3 d,inAD3 a){d=abs(a);return d;} + AD4 opAAbsD4(outAD4 d,inAD4 a){d=abs(a);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAAddD2(outAD2 d,inAD2 a,inAD2 b){d=a+b;return d;} + AD3 opAAddD3(outAD3 d,inAD3 a,inAD3 b){d=a+b;return d;} + AD4 opAAddD4(outAD4 d,inAD4 a,inAD4 b){d=a+b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAAddOneD2(outAD2 d,inAD2 a,AD1 b){d=a+AD2_(b);return d;} + AD3 opAAddOneD3(outAD3 d,inAD3 a,AD1 b){d=a+AD3_(b);return d;} + AD4 opAAddOneD4(outAD4 d,inAD4 a,AD1 b){d=a+AD4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opACpyD2(outAD2 d,inAD2 a){d=a;return d;} + AD3 opACpyD3(outAD3 d,inAD3 a){d=a;return d;} + AD4 opACpyD4(outAD4 d,inAD4 a){d=a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opALerpD2(outAD2 d,inAD2 a,inAD2 b,inAD2 c){d=ALerpD2(a,b,c);return d;} + AD3 opALerpD3(outAD3 d,inAD3 a,inAD3 b,inAD3 c){d=ALerpD3(a,b,c);return d;} + AD4 opALerpD4(outAD4 d,inAD4 a,inAD4 b,inAD4 c){d=ALerpD4(a,b,c);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opALerpOneD2(outAD2 d,inAD2 a,inAD2 b,AD1 c){d=ALerpD2(a,b,AD2_(c));return d;} + AD3 opALerpOneD3(outAD3 d,inAD3 a,inAD3 b,AD1 c){d=ALerpD3(a,b,AD3_(c));return d;} + AD4 opALerpOneD4(outAD4 d,inAD4 a,inAD4 b,AD1 c){d=ALerpD4(a,b,AD4_(c));return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMaxD2(outAD2 d,inAD2 a,inAD2 b){d=max(a,b);return d;} + AD3 opAMaxD3(outAD3 d,inAD3 a,inAD3 b){d=max(a,b);return d;} + AD4 opAMaxD4(outAD4 d,inAD4 a,inAD4 b){d=max(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMinD2(outAD2 d,inAD2 a,inAD2 b){d=min(a,b);return d;} + AD3 opAMinD3(outAD3 d,inAD3 a,inAD3 b){d=min(a,b);return d;} + AD4 opAMinD4(outAD4 d,inAD4 a,inAD4 b){d=min(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMulD2(outAD2 d,inAD2 a,inAD2 b){d=a*b;return d;} + AD3 opAMulD3(outAD3 d,inAD3 a,inAD3 b){d=a*b;return d;} + AD4 opAMulD4(outAD4 d,inAD4 a,inAD4 b){d=a*b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opAMulOneD2(outAD2 d,inAD2 a,AD1 b){d=a*AD2_(b);return d;} + AD3 opAMulOneD3(outAD3 d,inAD3 a,AD1 b){d=a*AD3_(b);return d;} + AD4 opAMulOneD4(outAD4 d,inAD4 a,AD1 b){d=a*AD4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opANegD2(outAD2 d,inAD2 a){d=-a;return d;} + AD3 opANegD3(outAD3 d,inAD3 a){d=-a;return d;} + AD4 opANegD4(outAD4 d,inAD4 a){d=-a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AD2 opARcpD2(outAD2 d,inAD2 a){d=ARcpD2(a);return d;} + AD3 opARcpD3(outAD3 d,inAD3 a){d=ARcpD3(a);return d;} + AD4 opARcpD4(outAD4 d,inAD4 a){d=ARcpD4(a);return d;} + #endif +//============================================================================================================================== + AF2 opAAbsF2(outAF2 d,inAF2 a){d=abs(a);return d;} + AF3 opAAbsF3(outAF3 d,inAF3 a){d=abs(a);return d;} + AF4 opAAbsF4(outAF4 d,inAF4 a){d=abs(a);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAAddF2(outAF2 d,inAF2 a,inAF2 b){d=a+b;return d;} + AF3 opAAddF3(outAF3 d,inAF3 a,inAF3 b){d=a+b;return d;} + AF4 opAAddF4(outAF4 d,inAF4 a,inAF4 b){d=a+b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAAddOneF2(outAF2 d,inAF2 a,AF1 b){d=a+AF2_(b);return d;} + AF3 opAAddOneF3(outAF3 d,inAF3 a,AF1 b){d=a+AF3_(b);return d;} + AF4 opAAddOneF4(outAF4 d,inAF4 a,AF1 b){d=a+AF4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opACpyF2(outAF2 d,inAF2 a){d=a;return d;} + AF3 opACpyF3(outAF3 d,inAF3 a){d=a;return d;} + AF4 opACpyF4(outAF4 d,inAF4 a){d=a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opALerpF2(outAF2 d,inAF2 a,inAF2 b,inAF2 c){d=ALerpF2(a,b,c);return d;} + AF3 opALerpF3(outAF3 d,inAF3 a,inAF3 b,inAF3 c){d=ALerpF3(a,b,c);return d;} + AF4 opALerpF4(outAF4 d,inAF4 a,inAF4 b,inAF4 c){d=ALerpF4(a,b,c);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opALerpOneF2(outAF2 d,inAF2 a,inAF2 b,AF1 c){d=ALerpF2(a,b,AF2_(c));return d;} + AF3 opALerpOneF3(outAF3 d,inAF3 a,inAF3 b,AF1 c){d=ALerpF3(a,b,AF3_(c));return d;} + AF4 opALerpOneF4(outAF4 d,inAF4 a,inAF4 b,AF1 c){d=ALerpF4(a,b,AF4_(c));return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMaxF2(outAF2 d,inAF2 a,inAF2 b){d=max(a,b);return d;} + AF3 opAMaxF3(outAF3 d,inAF3 a,inAF3 b){d=max(a,b);return d;} + AF4 opAMaxF4(outAF4 d,inAF4 a,inAF4 b){d=max(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMinF2(outAF2 d,inAF2 a,inAF2 b){d=min(a,b);return d;} + AF3 opAMinF3(outAF3 d,inAF3 a,inAF3 b){d=min(a,b);return d;} + AF4 opAMinF4(outAF4 d,inAF4 a,inAF4 b){d=min(a,b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMulF2(outAF2 d,inAF2 a,inAF2 b){d=a*b;return d;} + AF3 opAMulF3(outAF3 d,inAF3 a,inAF3 b){d=a*b;return d;} + AF4 opAMulF4(outAF4 d,inAF4 a,inAF4 b){d=a*b;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opAMulOneF2(outAF2 d,inAF2 a,AF1 b){d=a*AF2_(b);return d;} + AF3 opAMulOneF3(outAF3 d,inAF3 a,AF1 b){d=a*AF3_(b);return d;} + AF4 opAMulOneF4(outAF4 d,inAF4 a,AF1 b){d=a*AF4_(b);return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opANegF2(outAF2 d,inAF2 a){d=-a;return d;} + AF3 opANegF3(outAF3 d,inAF3 a){d=-a;return d;} + AF4 opANegF4(outAF4 d,inAF4 a){d=-a;return d;} +//------------------------------------------------------------------------------------------------------------------------------ + AF2 opARcpF2(outAF2 d,inAF2 a){d=ARcpF2(a);return d;} + AF3 opARcpF3(outAF3 d,inAF3 a){d=ARcpF3(a);return d;} + AF4 opARcpF4(outAF4 d,inAF4 a){d=ARcpF4(a);return d;} +#endif diff --git a/thirdparty/amd-fsr/ffx_fsr1.h b/thirdparty/amd-fsr/ffx_fsr1.h new file mode 100644 index 0000000000..4e0b3d5485 --- /dev/null +++ b/thirdparty/amd-fsr/ffx_fsr1.h @@ -0,0 +1,1199 @@ +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// +// AMD FidelityFX SUPER RESOLUTION [FSR 1] ::: SPATIAL SCALING & EXTRAS - v1.20210629 +// +// +//------------------------------------------------------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------ +// FidelityFX Super Resolution Sample +// +// Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. +// 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. +//------------------------------------------------------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------ +// ABOUT +// ===== +// FSR is a collection of algorithms relating to generating a higher resolution image. +// This specific header focuses on single-image non-temporal image scaling, and related tools. +// +// The core functions are EASU and RCAS: +// [EASU] Edge Adaptive Spatial Upsampling ....... 1x to 4x area range spatial scaling, clamped adaptive elliptical filter. +// [RCAS] Robust Contrast Adaptive Sharpening .... A non-scaling variation on CAS. +// RCAS needs to be applied after EASU as a separate pass. +// +// Optional utility functions are: +// [LFGA] Linear Film Grain Applicator ........... Tool to apply film grain after scaling. +// [SRTM] Simple Reversible Tone-Mapper .......... Linear HDR {0 to FP16_MAX} to {0 to 1} and back. +// [TEPD] Temporal Energy Preserving Dither ...... Temporally energy preserving dithered {0 to 1} linear to gamma 2.0 conversion. +// See each individual sub-section for inline documentation. +//------------------------------------------------------------------------------------------------------------------------------ +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------------------------------------------------------------------------ +// FUNCTION PERMUTATIONS +// ===================== +// *F() ..... Single item computation with 32-bit. +// *H() ..... Single item computation with 16-bit, with packing (aka two 16-bit ops in parallel) when possible. +// *Hx2() ... Processing two items in parallel with 16-bit, easier packing. +// Not all interfaces in this file have a *Hx2() form. +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [EASU] EDGE ADAPTIVE SPATIAL UPSAMPLING +// +//------------------------------------------------------------------------------------------------------------------------------ +// EASU provides a high quality spatial-only scaling at relatively low cost. +// Meaning EASU is appropiate for laptops and other low-end GPUs. +// Quality from 1x to 4x area scaling is good. +//------------------------------------------------------------------------------------------------------------------------------ +// The scalar uses a modified fast approximation to the standard lanczos(size=2) kernel. +// EASU runs in a single pass, so it applies a directionally and anisotropically adaptive radial lanczos. +// This is also kept as simple as possible to have minimum runtime. +//------------------------------------------------------------------------------------------------------------------------------ +// The lanzcos filter has negative lobes, so by itself it will introduce ringing. +// To remove all ringing, the algorithm uses the nearest 2x2 input texels as a neighborhood, +// and limits output to the minimum and maximum of that neighborhood. +//------------------------------------------------------------------------------------------------------------------------------ +// Input image requirements: +// +// Color needs to be encoded as 3 channel[red, green, blue](e.g.XYZ not supported) +// Each channel needs to be in the range[0, 1] +// Any color primaries are supported +// Display / tonemapping curve needs to be as if presenting to sRGB display or similar(e.g.Gamma 2.0) +// There should be no banding in the input +// There should be no high amplitude noise in the input +// There should be no noise in the input that is not at input pixel granularity +// For performance purposes, use 32bpp formats +//------------------------------------------------------------------------------------------------------------------------------ +// Best to apply EASU at the end of the frame after tonemapping +// but before film grain or composite of the UI. +//------------------------------------------------------------------------------------------------------------------------------ +// Example of including this header for D3D HLSL : +// +// #define A_GPU 1 +// #define A_HLSL 1 +// #define A_HALF 1 +// #include "ffx_a.h" +// #define FSR_EASU_H 1 +// #define FSR_RCAS_H 1 +// //declare input callbacks +// #include "ffx_fsr1.h" +// +// Example of including this header for Vulkan GLSL : +// +// #define A_GPU 1 +// #define A_GLSL 1 +// #define A_HALF 1 +// #include "ffx_a.h" +// #define FSR_EASU_H 1 +// #define FSR_RCAS_H 1 +// //declare input callbacks +// #include "ffx_fsr1.h" +// +// Example of including this header for Vulkan HLSL : +// +// #define A_GPU 1 +// #define A_HLSL 1 +// #define A_HLSL_6_2 1 +// #define A_NO_16_BIT_CAST 1 +// #define A_HALF 1 +// #include "ffx_a.h" +// #define FSR_EASU_H 1 +// #define FSR_RCAS_H 1 +// //declare input callbacks +// #include "ffx_fsr1.h" +// +// Example of declaring the required input callbacks for GLSL : +// The callbacks need to gather4 for each color channel using the specified texture coordinate 'p'. +// EASU uses gather4 to reduce position computation logic and for free Arrays of Structures to Structures of Arrays conversion. +// +// AH4 FsrEasuRH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,0));} +// AH4 FsrEasuGH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,1));} +// AH4 FsrEasuBH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,2));} +// ... +// The FsrEasuCon function needs to be called from the CPU or GPU to set up constants. +// The difference in viewport and input image size is there to support Dynamic Resolution Scaling. +// To use FsrEasuCon() on the CPU, define A_CPU before including ffx_a and ffx_fsr1. +// Including a GPU example here, the 'con0' through 'con3' values would be stored out to a constant buffer. +// AU4 con0,con1,con2,con3; +// FsrEasuCon(con0,con1,con2,con3, +// 1920.0,1080.0, // Viewport size (top left aligned) in the input image which is to be scaled. +// 3840.0,2160.0, // The size of the input image. +// 2560.0,1440.0); // The output resolution. +//============================================================================================================================== +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// CONSTANT SETUP +//============================================================================================================================== +// Call to setup required constant values (works on CPU or GPU). +A_STATIC void FsrEasuCon( +outAU4 con0, +outAU4 con1, +outAU4 con2, +outAU4 con3, +// This the rendered image resolution being upscaled +AF1 inputViewportInPixelsX, +AF1 inputViewportInPixelsY, +// This is the resolution of the resource containing the input image (useful for dynamic resolution) +AF1 inputSizeInPixelsX, +AF1 inputSizeInPixelsY, +// This is the display resolution which the input image gets upscaled to +AF1 outputSizeInPixelsX, +AF1 outputSizeInPixelsY){ + // Output integer position to a pixel position in viewport. + con0[0]=AU1_AF1(inputViewportInPixelsX*ARcpF1(outputSizeInPixelsX)); + con0[1]=AU1_AF1(inputViewportInPixelsY*ARcpF1(outputSizeInPixelsY)); + con0[2]=AU1_AF1(AF1_(0.5)*inputViewportInPixelsX*ARcpF1(outputSizeInPixelsX)-AF1_(0.5)); + con0[3]=AU1_AF1(AF1_(0.5)*inputViewportInPixelsY*ARcpF1(outputSizeInPixelsY)-AF1_(0.5)); + // Viewport pixel position to normalized image space. + // This is used to get upper-left of 'F' tap. + con1[0]=AU1_AF1(ARcpF1(inputSizeInPixelsX)); + con1[1]=AU1_AF1(ARcpF1(inputSizeInPixelsY)); + // Centers of gather4, first offset from upper-left of 'F'. + // +---+---+ + // | | | + // +--(0)--+ + // | b | c | + // +---F---+---+---+ + // | e | f | g | h | + // +--(1)--+--(2)--+ + // | i | j | k | l | + // +---+---+---+---+ + // | n | o | + // +--(3)--+ + // | | | + // +---+---+ + con1[2]=AU1_AF1(AF1_( 1.0)*ARcpF1(inputSizeInPixelsX)); + con1[3]=AU1_AF1(AF1_(-1.0)*ARcpF1(inputSizeInPixelsY)); + // These are from (0) instead of 'F'. + con2[0]=AU1_AF1(AF1_(-1.0)*ARcpF1(inputSizeInPixelsX)); + con2[1]=AU1_AF1(AF1_( 2.0)*ARcpF1(inputSizeInPixelsY)); + con2[2]=AU1_AF1(AF1_( 1.0)*ARcpF1(inputSizeInPixelsX)); + con2[3]=AU1_AF1(AF1_( 2.0)*ARcpF1(inputSizeInPixelsY)); + con3[0]=AU1_AF1(AF1_( 0.0)*ARcpF1(inputSizeInPixelsX)); + con3[1]=AU1_AF1(AF1_( 4.0)*ARcpF1(inputSizeInPixelsY)); + con3[2]=con3[3]=0;} + +//If the an offset into the input image resource +A_STATIC void FsrEasuConOffset( + outAU4 con0, + outAU4 con1, + outAU4 con2, + outAU4 con3, + // This the rendered image resolution being upscaled + AF1 inputViewportInPixelsX, + AF1 inputViewportInPixelsY, + // This is the resolution of the resource containing the input image (useful for dynamic resolution) + AF1 inputSizeInPixelsX, + AF1 inputSizeInPixelsY, + // This is the display resolution which the input image gets upscaled to + AF1 outputSizeInPixelsX, + AF1 outputSizeInPixelsY, + // This is the input image offset into the resource containing it (useful for dynamic resolution) + AF1 inputOffsetInPixelsX, + AF1 inputOffsetInPixelsY) { + FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); + con0[2] = AU1_AF1(AF1_(0.5) * inputViewportInPixelsX * ARcpF1(outputSizeInPixelsX) - AF1_(0.5) + inputOffsetInPixelsX); + con0[3] = AU1_AF1(AF1_(0.5) * inputViewportInPixelsY * ARcpF1(outputSizeInPixelsY) - AF1_(0.5) + inputOffsetInPixelsY); +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// NON-PACKED 32-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(FSR_EASU_F) + // Input callback prototypes, need to be implemented by calling shader + AF4 FsrEasuRF(AF2 p); + AF4 FsrEasuGF(AF2 p); + AF4 FsrEasuBF(AF2 p); +//------------------------------------------------------------------------------------------------------------------------------ + // Filtering for a given tap for the scalar. + void FsrEasuTapF( + inout AF3 aC, // Accumulated color, with negative lobe. + inout AF1 aW, // Accumulated weight. + AF2 off, // Pixel offset from resolve position to tap. + AF2 dir, // Gradient direction. + AF2 len, // Length. + AF1 lob, // Negative lobe strength. + AF1 clp, // Clipping point. + AF3 c){ // Tap color. + // Rotate offset by direction. + AF2 v; + v.x=(off.x*( dir.x))+(off.y*dir.y); + v.y=(off.x*(-dir.y))+(off.y*dir.x); + // Anisotropy. + v*=len; + // Compute distance^2. + AF1 d2=v.x*v.x+v.y*v.y; + // Limit to the window as at corner, 2 taps can easily be outside. + d2=min(d2,clp); + // Approximation of lancos2 without sin() or rcp(), or sqrt() to get x. + // (25/16 * (2/5 * x^2 - 1)^2 - (25/16 - 1)) * (1/4 * x^2 - 1)^2 + // |_______________________________________| |_______________| + // base window + // The general form of the 'base' is, + // (a*(b*x^2-1)^2-(a-1)) + // Where 'a=1/(2*b-b^2)' and 'b' moves around the negative lobe. + AF1 wB=AF1_(2.0/5.0)*d2+AF1_(-1.0); + AF1 wA=lob*d2+AF1_(-1.0); + wB*=wB; + wA*=wA; + wB=AF1_(25.0/16.0)*wB+AF1_(-(25.0/16.0-1.0)); + AF1 w=wB*wA; + // Do weighted average. + aC+=c*w;aW+=w;} +//------------------------------------------------------------------------------------------------------------------------------ + // Accumulate direction and length. + void FsrEasuSetF( + inout AF2 dir, + inout AF1 len, + AF2 pp, + AP1 biS,AP1 biT,AP1 biU,AP1 biV, + AF1 lA,AF1 lB,AF1 lC,AF1 lD,AF1 lE){ + // Compute bilinear weight, branches factor out as predicates are compiler time immediates. + // s t + // u v + AF1 w = AF1_(0.0); + if(biS)w=(AF1_(1.0)-pp.x)*(AF1_(1.0)-pp.y); + if(biT)w= pp.x *(AF1_(1.0)-pp.y); + if(biU)w=(AF1_(1.0)-pp.x)* pp.y ; + if(biV)w= pp.x * pp.y ; + // Direction is the '+' diff. + // a + // b c d + // e + // Then takes magnitude from abs average of both sides of 'c'. + // Length converts gradient reversal to 0, smoothly to non-reversal at 1, shaped, then adding horz and vert terms. + AF1 dc=lD-lC; + AF1 cb=lC-lB; + AF1 lenX=max(abs(dc),abs(cb)); + lenX=APrxLoRcpF1(lenX); + AF1 dirX=lD-lB; + dir.x+=dirX*w; + lenX=ASatF1(abs(dirX)*lenX); + lenX*=lenX; + len+=lenX*w; + // Repeat for the y axis. + AF1 ec=lE-lC; + AF1 ca=lC-lA; + AF1 lenY=max(abs(ec),abs(ca)); + lenY=APrxLoRcpF1(lenY); + AF1 dirY=lE-lA; + dir.y+=dirY*w; + lenY=ASatF1(abs(dirY)*lenY); + lenY*=lenY; + len+=lenY*w;} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrEasuF( + out AF3 pix, + AU2 ip, // Integer pixel position in output. + AU4 con0, // Constants generated by FsrEasuCon(). + AU4 con1, + AU4 con2, + AU4 con3){ +//------------------------------------------------------------------------------------------------------------------------------ + // Get position of 'f'. + AF2 pp=AF2(ip)*AF2_AU2(con0.xy)+AF2_AU2(con0.zw); + AF2 fp=floor(pp); + pp-=fp; +//------------------------------------------------------------------------------------------------------------------------------ + // 12-tap kernel. + // b c + // e f g h + // i j k l + // n o + // Gather 4 ordering. + // a b + // r g + // For packed FP16, need either {rg} or {ab} so using the following setup for gather in all versions, + // a b <- unused (z) + // r g + // a b a b + // r g r g + // a b + // r g <- unused (z) + // Allowing dead-code removal to remove the 'z's. + AF2 p0=fp*AF2_AU2(con1.xy)+AF2_AU2(con1.zw); + // These are from p0 to avoid pulling two constants on pre-Navi hardware. + AF2 p1=p0+AF2_AU2(con2.xy); + AF2 p2=p0+AF2_AU2(con2.zw); + AF2 p3=p0+AF2_AU2(con3.xy); + AF4 bczzR=FsrEasuRF(p0); + AF4 bczzG=FsrEasuGF(p0); + AF4 bczzB=FsrEasuBF(p0); + AF4 ijfeR=FsrEasuRF(p1); + AF4 ijfeG=FsrEasuGF(p1); + AF4 ijfeB=FsrEasuBF(p1); + AF4 klhgR=FsrEasuRF(p2); + AF4 klhgG=FsrEasuGF(p2); + AF4 klhgB=FsrEasuBF(p2); + AF4 zzonR=FsrEasuRF(p3); + AF4 zzonG=FsrEasuGF(p3); + AF4 zzonB=FsrEasuBF(p3); +//------------------------------------------------------------------------------------------------------------------------------ + // Simplest multi-channel approximate luma possible (luma times 2, in 2 FMA/MAD). + AF4 bczzL=bczzB*AF4_(0.5)+(bczzR*AF4_(0.5)+bczzG); + AF4 ijfeL=ijfeB*AF4_(0.5)+(ijfeR*AF4_(0.5)+ijfeG); + AF4 klhgL=klhgB*AF4_(0.5)+(klhgR*AF4_(0.5)+klhgG); + AF4 zzonL=zzonB*AF4_(0.5)+(zzonR*AF4_(0.5)+zzonG); + // Rename. + AF1 bL=bczzL.x; + AF1 cL=bczzL.y; + AF1 iL=ijfeL.x; + AF1 jL=ijfeL.y; + AF1 fL=ijfeL.z; + AF1 eL=ijfeL.w; + AF1 kL=klhgL.x; + AF1 lL=klhgL.y; + AF1 hL=klhgL.z; + AF1 gL=klhgL.w; + AF1 oL=zzonL.z; + AF1 nL=zzonL.w; + // Accumulate for bilinear interpolation. + AF2 dir=AF2_(0.0); + AF1 len=AF1_(0.0); + FsrEasuSetF(dir,len,pp,true, false,false,false,bL,eL,fL,gL,jL); + FsrEasuSetF(dir,len,pp,false,true ,false,false,cL,fL,gL,hL,kL); + FsrEasuSetF(dir,len,pp,false,false,true ,false,fL,iL,jL,kL,nL); + FsrEasuSetF(dir,len,pp,false,false,false,true ,gL,jL,kL,lL,oL); +//------------------------------------------------------------------------------------------------------------------------------ + // Normalize with approximation, and cleanup close to zero. + AF2 dir2=dir*dir; + AF1 dirR=dir2.x+dir2.y; + AP1 zro=dirR<AF1_(1.0/32768.0); + dirR=APrxLoRsqF1(dirR); + dirR=zro?AF1_(1.0):dirR; + dir.x=zro?AF1_(1.0):dir.x; + dir*=AF2_(dirR); + // Transform from {0 to 2} to {0 to 1} range, and shape with square. + len=len*AF1_(0.5); + len*=len; + // Stretch kernel {1.0 vert|horz, to sqrt(2.0) on diagonal}. + AF1 stretch=(dir.x*dir.x+dir.y*dir.y)*APrxLoRcpF1(max(abs(dir.x),abs(dir.y))); + // Anisotropic length after rotation, + // x := 1.0 lerp to 'stretch' on edges + // y := 1.0 lerp to 2x on edges + AF2 len2=AF2(AF1_(1.0)+(stretch-AF1_(1.0))*len,AF1_(1.0)+AF1_(-0.5)*len); + // Based on the amount of 'edge', + // the window shifts from +/-{sqrt(2.0) to slightly beyond 2.0}. + AF1 lob=AF1_(0.5)+AF1_((1.0/4.0-0.04)-0.5)*len; + // Set distance^2 clipping point to the end of the adjustable window. + AF1 clp=APrxLoRcpF1(lob); +//------------------------------------------------------------------------------------------------------------------------------ + // Accumulation mixed with min/max of 4 nearest. + // b c + // e f g h + // i j k l + // n o + AF3 min4=min(AMin3F3(AF3(ijfeR.z,ijfeG.z,ijfeB.z),AF3(klhgR.w,klhgG.w,klhgB.w),AF3(ijfeR.y,ijfeG.y,ijfeB.y)), + AF3(klhgR.x,klhgG.x,klhgB.x)); + AF3 max4=max(AMax3F3(AF3(ijfeR.z,ijfeG.z,ijfeB.z),AF3(klhgR.w,klhgG.w,klhgB.w),AF3(ijfeR.y,ijfeG.y,ijfeB.y)), + AF3(klhgR.x,klhgG.x,klhgB.x)); + // Accumulation. + AF3 aC=AF3_(0.0); + AF1 aW=AF1_(0.0); + FsrEasuTapF(aC,aW,AF2( 0.0,-1.0)-pp,dir,len2,lob,clp,AF3(bczzR.x,bczzG.x,bczzB.x)); // b + FsrEasuTapF(aC,aW,AF2( 1.0,-1.0)-pp,dir,len2,lob,clp,AF3(bczzR.y,bczzG.y,bczzB.y)); // c + FsrEasuTapF(aC,aW,AF2(-1.0, 1.0)-pp,dir,len2,lob,clp,AF3(ijfeR.x,ijfeG.x,ijfeB.x)); // i + FsrEasuTapF(aC,aW,AF2( 0.0, 1.0)-pp,dir,len2,lob,clp,AF3(ijfeR.y,ijfeG.y,ijfeB.y)); // j + FsrEasuTapF(aC,aW,AF2( 0.0, 0.0)-pp,dir,len2,lob,clp,AF3(ijfeR.z,ijfeG.z,ijfeB.z)); // f + FsrEasuTapF(aC,aW,AF2(-1.0, 0.0)-pp,dir,len2,lob,clp,AF3(ijfeR.w,ijfeG.w,ijfeB.w)); // e + FsrEasuTapF(aC,aW,AF2( 1.0, 1.0)-pp,dir,len2,lob,clp,AF3(klhgR.x,klhgG.x,klhgB.x)); // k + FsrEasuTapF(aC,aW,AF2( 2.0, 1.0)-pp,dir,len2,lob,clp,AF3(klhgR.y,klhgG.y,klhgB.y)); // l + FsrEasuTapF(aC,aW,AF2( 2.0, 0.0)-pp,dir,len2,lob,clp,AF3(klhgR.z,klhgG.z,klhgB.z)); // h + FsrEasuTapF(aC,aW,AF2( 1.0, 0.0)-pp,dir,len2,lob,clp,AF3(klhgR.w,klhgG.w,klhgB.w)); // g + FsrEasuTapF(aC,aW,AF2( 1.0, 2.0)-pp,dir,len2,lob,clp,AF3(zzonR.z,zzonG.z,zzonB.z)); // o + FsrEasuTapF(aC,aW,AF2( 0.0, 2.0)-pp,dir,len2,lob,clp,AF3(zzonR.w,zzonG.w,zzonB.w)); // n +//------------------------------------------------------------------------------------------------------------------------------ + // Normalize and dering. + pix=min(max4,max(min4,aC*AF3_(ARcpF1(aW))));} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PACKED 16-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF)&&defined(FSR_EASU_H) +// Input callback prototypes, need to be implemented by calling shader + AH4 FsrEasuRH(AF2 p); + AH4 FsrEasuGH(AF2 p); + AH4 FsrEasuBH(AF2 p); +//------------------------------------------------------------------------------------------------------------------------------ + // This runs 2 taps in parallel. + void FsrEasuTapH( + inout AH2 aCR,inout AH2 aCG,inout AH2 aCB, + inout AH2 aW, + AH2 offX,AH2 offY, + AH2 dir, + AH2 len, + AH1 lob, + AH1 clp, + AH2 cR,AH2 cG,AH2 cB){ + AH2 vX,vY; + vX=offX* dir.xx +offY*dir.yy; + vY=offX*(-dir.yy)+offY*dir.xx; + vX*=len.x;vY*=len.y; + AH2 d2=vX*vX+vY*vY; + d2=min(d2,AH2_(clp)); + AH2 wB=AH2_(2.0/5.0)*d2+AH2_(-1.0); + AH2 wA=AH2_(lob)*d2+AH2_(-1.0); + wB*=wB; + wA*=wA; + wB=AH2_(25.0/16.0)*wB+AH2_(-(25.0/16.0-1.0)); + AH2 w=wB*wA; + aCR+=cR*w;aCG+=cG*w;aCB+=cB*w;aW+=w;} +//------------------------------------------------------------------------------------------------------------------------------ + // This runs 2 taps in parallel. + void FsrEasuSetH( + inout AH2 dirPX,inout AH2 dirPY, + inout AH2 lenP, + AH2 pp, + AP1 biST,AP1 biUV, + AH2 lA,AH2 lB,AH2 lC,AH2 lD,AH2 lE){ + AH2 w = AH2_(0.0); + if(biST)w=(AH2(1.0,0.0)+AH2(-pp.x,pp.x))*AH2_(AH1_(1.0)-pp.y); + if(biUV)w=(AH2(1.0,0.0)+AH2(-pp.x,pp.x))*AH2_( pp.y); + // ABS is not free in the packed FP16 path. + AH2 dc=lD-lC; + AH2 cb=lC-lB; + AH2 lenX=max(abs(dc),abs(cb)); + lenX=ARcpH2(lenX); + AH2 dirX=lD-lB; + dirPX+=dirX*w; + lenX=ASatH2(abs(dirX)*lenX); + lenX*=lenX; + lenP+=lenX*w; + AH2 ec=lE-lC; + AH2 ca=lC-lA; + AH2 lenY=max(abs(ec),abs(ca)); + lenY=ARcpH2(lenY); + AH2 dirY=lE-lA; + dirPY+=dirY*w; + lenY=ASatH2(abs(dirY)*lenY); + lenY*=lenY; + lenP+=lenY*w;} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrEasuH( + out AH3 pix, + AU2 ip, + AU4 con0, + AU4 con1, + AU4 con2, + AU4 con3){ +//------------------------------------------------------------------------------------------------------------------------------ + AF2 pp=AF2(ip)*AF2_AU2(con0.xy)+AF2_AU2(con0.zw); + AF2 fp=floor(pp); + pp-=fp; + AH2 ppp=AH2(pp); +//------------------------------------------------------------------------------------------------------------------------------ + AF2 p0=fp*AF2_AU2(con1.xy)+AF2_AU2(con1.zw); + AF2 p1=p0+AF2_AU2(con2.xy); + AF2 p2=p0+AF2_AU2(con2.zw); + AF2 p3=p0+AF2_AU2(con3.xy); + AH4 bczzR=FsrEasuRH(p0); + AH4 bczzG=FsrEasuGH(p0); + AH4 bczzB=FsrEasuBH(p0); + AH4 ijfeR=FsrEasuRH(p1); + AH4 ijfeG=FsrEasuGH(p1); + AH4 ijfeB=FsrEasuBH(p1); + AH4 klhgR=FsrEasuRH(p2); + AH4 klhgG=FsrEasuGH(p2); + AH4 klhgB=FsrEasuBH(p2); + AH4 zzonR=FsrEasuRH(p3); + AH4 zzonG=FsrEasuGH(p3); + AH4 zzonB=FsrEasuBH(p3); +//------------------------------------------------------------------------------------------------------------------------------ + AH4 bczzL=bczzB*AH4_(0.5)+(bczzR*AH4_(0.5)+bczzG); + AH4 ijfeL=ijfeB*AH4_(0.5)+(ijfeR*AH4_(0.5)+ijfeG); + AH4 klhgL=klhgB*AH4_(0.5)+(klhgR*AH4_(0.5)+klhgG); + AH4 zzonL=zzonB*AH4_(0.5)+(zzonR*AH4_(0.5)+zzonG); + AH1 bL=bczzL.x; + AH1 cL=bczzL.y; + AH1 iL=ijfeL.x; + AH1 jL=ijfeL.y; + AH1 fL=ijfeL.z; + AH1 eL=ijfeL.w; + AH1 kL=klhgL.x; + AH1 lL=klhgL.y; + AH1 hL=klhgL.z; + AH1 gL=klhgL.w; + AH1 oL=zzonL.z; + AH1 nL=zzonL.w; + // This part is different, accumulating 2 taps in parallel. + AH2 dirPX=AH2_(0.0); + AH2 dirPY=AH2_(0.0); + AH2 lenP=AH2_(0.0); + FsrEasuSetH(dirPX,dirPY,lenP,ppp,true, false,AH2(bL,cL),AH2(eL,fL),AH2(fL,gL),AH2(gL,hL),AH2(jL,kL)); + FsrEasuSetH(dirPX,dirPY,lenP,ppp,false,true ,AH2(fL,gL),AH2(iL,jL),AH2(jL,kL),AH2(kL,lL),AH2(nL,oL)); + AH2 dir=AH2(dirPX.r+dirPX.g,dirPY.r+dirPY.g); + AH1 len=lenP.r+lenP.g; +//------------------------------------------------------------------------------------------------------------------------------ + AH2 dir2=dir*dir; + AH1 dirR=dir2.x+dir2.y; + AP1 zro=dirR<AH1_(1.0/32768.0); + dirR=APrxLoRsqH1(dirR); + dirR=zro?AH1_(1.0):dirR; + dir.x=zro?AH1_(1.0):dir.x; + dir*=AH2_(dirR); + len=len*AH1_(0.5); + len*=len; + AH1 stretch=(dir.x*dir.x+dir.y*dir.y)*APrxLoRcpH1(max(abs(dir.x),abs(dir.y))); + AH2 len2=AH2(AH1_(1.0)+(stretch-AH1_(1.0))*len,AH1_(1.0)+AH1_(-0.5)*len); + AH1 lob=AH1_(0.5)+AH1_((1.0/4.0-0.04)-0.5)*len; + AH1 clp=APrxLoRcpH1(lob); +//------------------------------------------------------------------------------------------------------------------------------ + // FP16 is different, using packed trick to do min and max in same operation. + AH2 bothR=max(max(AH2(-ijfeR.z,ijfeR.z),AH2(-klhgR.w,klhgR.w)),max(AH2(-ijfeR.y,ijfeR.y),AH2(-klhgR.x,klhgR.x))); + AH2 bothG=max(max(AH2(-ijfeG.z,ijfeG.z),AH2(-klhgG.w,klhgG.w)),max(AH2(-ijfeG.y,ijfeG.y),AH2(-klhgG.x,klhgG.x))); + AH2 bothB=max(max(AH2(-ijfeB.z,ijfeB.z),AH2(-klhgB.w,klhgB.w)),max(AH2(-ijfeB.y,ijfeB.y),AH2(-klhgB.x,klhgB.x))); + // This part is different for FP16, working pairs of taps at a time. + AH2 pR=AH2_(0.0); + AH2 pG=AH2_(0.0); + AH2 pB=AH2_(0.0); + AH2 pW=AH2_(0.0); + FsrEasuTapH(pR,pG,pB,pW,AH2( 0.0, 1.0)-ppp.xx,AH2(-1.0,-1.0)-ppp.yy,dir,len2,lob,clp,bczzR.xy,bczzG.xy,bczzB.xy); + FsrEasuTapH(pR,pG,pB,pW,AH2(-1.0, 0.0)-ppp.xx,AH2( 1.0, 1.0)-ppp.yy,dir,len2,lob,clp,ijfeR.xy,ijfeG.xy,ijfeB.xy); + FsrEasuTapH(pR,pG,pB,pW,AH2( 0.0,-1.0)-ppp.xx,AH2( 0.0, 0.0)-ppp.yy,dir,len2,lob,clp,ijfeR.zw,ijfeG.zw,ijfeB.zw); + FsrEasuTapH(pR,pG,pB,pW,AH2( 1.0, 2.0)-ppp.xx,AH2( 1.0, 1.0)-ppp.yy,dir,len2,lob,clp,klhgR.xy,klhgG.xy,klhgB.xy); + FsrEasuTapH(pR,pG,pB,pW,AH2( 2.0, 1.0)-ppp.xx,AH2( 0.0, 0.0)-ppp.yy,dir,len2,lob,clp,klhgR.zw,klhgG.zw,klhgB.zw); + FsrEasuTapH(pR,pG,pB,pW,AH2( 1.0, 0.0)-ppp.xx,AH2( 2.0, 2.0)-ppp.yy,dir,len2,lob,clp,zzonR.zw,zzonG.zw,zzonB.zw); + AH3 aC=AH3(pR.x+pR.y,pG.x+pG.y,pB.x+pB.y); + AH1 aW=pW.x+pW.y; +//------------------------------------------------------------------------------------------------------------------------------ + // Slightly different for FP16 version due to combined min and max. + pix=min(AH3(bothR.y,bothG.y,bothB.y),max(-AH3(bothR.x,bothG.x,bothB.x),aC*AH3_(ARcpH1(aW))));} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [RCAS] ROBUST CONTRAST ADAPTIVE SHARPENING +// +//------------------------------------------------------------------------------------------------------------------------------ +// CAS uses a simplified mechanism to convert local contrast into a variable amount of sharpness. +// RCAS uses a more exact mechanism, solving for the maximum local sharpness possible before clipping. +// RCAS also has a built in process to limit sharpening of what it detects as possible noise. +// RCAS sharper does not support scaling, as it should be applied after EASU scaling. +// Pass EASU output straight into RCAS, no color conversions necessary. +//------------------------------------------------------------------------------------------------------------------------------ +// RCAS is based on the following logic. +// RCAS uses a 5 tap filter in a cross pattern (same as CAS), +// w n +// w 1 w for taps w m e +// w s +// Where 'w' is the negative lobe weight. +// output = (w*(n+e+w+s)+m)/(4*w+1) +// RCAS solves for 'w' by seeing where the signal might clip out of the {0 to 1} input range, +// 0 == (w*(n+e+w+s)+m)/(4*w+1) -> w = -m/(n+e+w+s) +// 1 == (w*(n+e+w+s)+m)/(4*w+1) -> w = (1-m)/(n+e+w+s-4*1) +// Then chooses the 'w' which results in no clipping, limits 'w', and multiplies by the 'sharp' amount. +// This solution above has issues with MSAA input as the steps along the gradient cause edge detection issues. +// So RCAS uses 4x the maximum and 4x the minimum (depending on equation)in place of the individual taps. +// As well as switching from 'm' to either the minimum or maximum (depending on side), to help in energy conservation. +// This stabilizes RCAS. +// RCAS does a simple highpass which is normalized against the local contrast then shaped, +// 0.25 +// 0.25 -1 0.25 +// 0.25 +// This is used as a noise detection filter, to reduce the effect of RCAS on grain, and focus on real edges. +// +// GLSL example for the required callbacks : +// +// AH4 FsrRcasLoadH(ASW2 p){return AH4(imageLoad(imgSrc,ASU2(p)));} +// void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b) +// { +// //do any simple input color conversions here or leave empty if none needed +// } +// +// FsrRcasCon need to be called from the CPU or GPU to set up constants. +// Including a GPU example here, the 'con' value would be stored out to a constant buffer. +// +// AU4 con; +// FsrRcasCon(con, +// 0.0); // The scale is {0.0 := maximum sharpness, to N>0, where N is the number of stops (halving) of the reduction of sharpness}. +// --------------- +// RCAS sharpening supports a CAS-like pass-through alpha via, +// #define FSR_RCAS_PASSTHROUGH_ALPHA 1 +// RCAS also supports a define to enable a more expensive path to avoid some sharpening of noise. +// Would suggest it is better to apply film grain after RCAS sharpening (and after scaling) instead of using this define, +// #define FSR_RCAS_DENOISE 1 +//============================================================================================================================== +// This is set at the limit of providing unnatural results for sharpening. +#define FSR_RCAS_LIMIT (0.25-(1.0/16.0)) +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// CONSTANT SETUP +//============================================================================================================================== +// Call to setup required constant values (works on CPU or GPU). +A_STATIC void FsrRcasCon( +outAU4 con, +// The scale is {0.0 := maximum, to N>0, where N is the number of stops (halving) of the reduction of sharpness}. +AF1 sharpness){ + // Transform from stops to linear value. + sharpness=AExp2F1(-sharpness); + varAF2(hSharp)=initAF2(sharpness,sharpness); + con[0]=AU1_AF1(sharpness); + con[1]=AU1_AH2_AF2(hSharp); + con[2]=0; + con[3]=0;} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// NON-PACKED 32-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(FSR_RCAS_F) + // Input callback prototypes that need to be implemented by calling shader + AF4 FsrRcasLoadF(ASU2 p); + void FsrRcasInputF(inout AF1 r,inout AF1 g,inout AF1 b); +//------------------------------------------------------------------------------------------------------------------------------ + void FsrRcasF( + out AF1 pixR, // Output values, non-vector so port between RcasFilter() and RcasFilterH() is easy. + out AF1 pixG, + out AF1 pixB, + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + out AF1 pixA, + #endif + AU2 ip, // Integer pixel position in output. + AU4 con){ // Constant generated by RcasSetup(). + // Algorithm uses minimal 3x3 pixel neighborhood. + // b + // d e f + // h + ASU2 sp=ASU2(ip); + AF3 b=FsrRcasLoadF(sp+ASU2( 0,-1)).rgb; + AF3 d=FsrRcasLoadF(sp+ASU2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AF4 ee=FsrRcasLoadF(sp); + AF3 e=ee.rgb;pixA=ee.a; + #else + AF3 e=FsrRcasLoadF(sp).rgb; + #endif + AF3 f=FsrRcasLoadF(sp+ASU2( 1, 0)).rgb; + AF3 h=FsrRcasLoadF(sp+ASU2( 0, 1)).rgb; + // Rename (32-bit) or regroup (16-bit). + AF1 bR=b.r; + AF1 bG=b.g; + AF1 bB=b.b; + AF1 dR=d.r; + AF1 dG=d.g; + AF1 dB=d.b; + AF1 eR=e.r; + AF1 eG=e.g; + AF1 eB=e.b; + AF1 fR=f.r; + AF1 fG=f.g; + AF1 fB=f.b; + AF1 hR=h.r; + AF1 hG=h.g; + AF1 hB=h.b; + // Run optional input transform. + FsrRcasInputF(bR,bG,bB); + FsrRcasInputF(dR,dG,dB); + FsrRcasInputF(eR,eG,eB); + FsrRcasInputF(fR,fG,fB); + FsrRcasInputF(hR,hG,hB); + // Luma times 2. + AF1 bL=bB*AF1_(0.5)+(bR*AF1_(0.5)+bG); + AF1 dL=dB*AF1_(0.5)+(dR*AF1_(0.5)+dG); + AF1 eL=eB*AF1_(0.5)+(eR*AF1_(0.5)+eG); + AF1 fL=fB*AF1_(0.5)+(fR*AF1_(0.5)+fG); + AF1 hL=hB*AF1_(0.5)+(hR*AF1_(0.5)+hG); + // Noise detection. + AF1 nz=AF1_(0.25)*bL+AF1_(0.25)*dL+AF1_(0.25)*fL+AF1_(0.25)*hL-eL; + nz=ASatF1(abs(nz)*APrxMedRcpF1(AMax3F1(AMax3F1(bL,dL,eL),fL,hL)-AMin3F1(AMin3F1(bL,dL,eL),fL,hL))); + nz=AF1_(-0.5)*nz+AF1_(1.0); + // Min and max of ring. + AF1 mn4R=min(AMin3F1(bR,dR,fR),hR); + AF1 mn4G=min(AMin3F1(bG,dG,fG),hG); + AF1 mn4B=min(AMin3F1(bB,dB,fB),hB); + AF1 mx4R=max(AMax3F1(bR,dR,fR),hR); + AF1 mx4G=max(AMax3F1(bG,dG,fG),hG); + AF1 mx4B=max(AMax3F1(bB,dB,fB),hB); + // Immediate constants for peak range. + AF2 peakC=AF2(1.0,-1.0*4.0); + // Limiters, these need to be high precision RCPs. + AF1 hitMinR=min(mn4R,eR)*ARcpF1(AF1_(4.0)*mx4R); + AF1 hitMinG=min(mn4G,eG)*ARcpF1(AF1_(4.0)*mx4G); + AF1 hitMinB=min(mn4B,eB)*ARcpF1(AF1_(4.0)*mx4B); + AF1 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpF1(AF1_(4.0)*mn4R+peakC.y); + AF1 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpF1(AF1_(4.0)*mn4G+peakC.y); + AF1 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpF1(AF1_(4.0)*mn4B+peakC.y); + AF1 lobeR=max(-hitMinR,hitMaxR); + AF1 lobeG=max(-hitMinG,hitMaxG); + AF1 lobeB=max(-hitMinB,hitMaxB); + AF1 lobe=max(AF1_(-FSR_RCAS_LIMIT),min(AMax3F1(lobeR,lobeG,lobeB),AF1_(0.0)))*AF1_AU1(con.x); + // Apply noise removal. + #ifdef FSR_RCAS_DENOISE + lobe*=nz; + #endif + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + AF1 rcpL=APrxMedRcpF1(AF1_(4.0)*lobe+AF1_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL; + return;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// NON-PACKED 16-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF)&&defined(FSR_RCAS_H) + // Input callback prototypes that need to be implemented by calling shader + AH4 FsrRcasLoadH(ASW2 p); + void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b); +//------------------------------------------------------------------------------------------------------------------------------ + void FsrRcasH( + out AH1 pixR, // Output values, non-vector so port between RcasFilter() and RcasFilterH() is easy. + out AH1 pixG, + out AH1 pixB, + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + out AH1 pixA, + #endif + AU2 ip, // Integer pixel position in output. + AU4 con){ // Constant generated by RcasSetup(). + // Sharpening algorithm uses minimal 3x3 pixel neighborhood. + // b + // d e f + // h + ASW2 sp=ASW2(ip); + AH3 b=FsrRcasLoadH(sp+ASW2( 0,-1)).rgb; + AH3 d=FsrRcasLoadH(sp+ASW2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AH4 ee=FsrRcasLoadH(sp); + AH3 e=ee.rgb;pixA=ee.a; + #else + AH3 e=FsrRcasLoadH(sp).rgb; + #endif + AH3 f=FsrRcasLoadH(sp+ASW2( 1, 0)).rgb; + AH3 h=FsrRcasLoadH(sp+ASW2( 0, 1)).rgb; + // Rename (32-bit) or regroup (16-bit). + AH1 bR=b.r; + AH1 bG=b.g; + AH1 bB=b.b; + AH1 dR=d.r; + AH1 dG=d.g; + AH1 dB=d.b; + AH1 eR=e.r; + AH1 eG=e.g; + AH1 eB=e.b; + AH1 fR=f.r; + AH1 fG=f.g; + AH1 fB=f.b; + AH1 hR=h.r; + AH1 hG=h.g; + AH1 hB=h.b; + // Run optional input transform. + FsrRcasInputH(bR,bG,bB); + FsrRcasInputH(dR,dG,dB); + FsrRcasInputH(eR,eG,eB); + FsrRcasInputH(fR,fG,fB); + FsrRcasInputH(hR,hG,hB); + // Luma times 2. + AH1 bL=bB*AH1_(0.5)+(bR*AH1_(0.5)+bG); + AH1 dL=dB*AH1_(0.5)+(dR*AH1_(0.5)+dG); + AH1 eL=eB*AH1_(0.5)+(eR*AH1_(0.5)+eG); + AH1 fL=fB*AH1_(0.5)+(fR*AH1_(0.5)+fG); + AH1 hL=hB*AH1_(0.5)+(hR*AH1_(0.5)+hG); + // Noise detection. + AH1 nz=AH1_(0.25)*bL+AH1_(0.25)*dL+AH1_(0.25)*fL+AH1_(0.25)*hL-eL; + nz=ASatH1(abs(nz)*APrxMedRcpH1(AMax3H1(AMax3H1(bL,dL,eL),fL,hL)-AMin3H1(AMin3H1(bL,dL,eL),fL,hL))); + nz=AH1_(-0.5)*nz+AH1_(1.0); + // Min and max of ring. + AH1 mn4R=min(AMin3H1(bR,dR,fR),hR); + AH1 mn4G=min(AMin3H1(bG,dG,fG),hG); + AH1 mn4B=min(AMin3H1(bB,dB,fB),hB); + AH1 mx4R=max(AMax3H1(bR,dR,fR),hR); + AH1 mx4G=max(AMax3H1(bG,dG,fG),hG); + AH1 mx4B=max(AMax3H1(bB,dB,fB),hB); + // Immediate constants for peak range. + AH2 peakC=AH2(1.0,-1.0*4.0); + // Limiters, these need to be high precision RCPs. + AH1 hitMinR=min(mn4R,eR)*ARcpH1(AH1_(4.0)*mx4R); + AH1 hitMinG=min(mn4G,eG)*ARcpH1(AH1_(4.0)*mx4G); + AH1 hitMinB=min(mn4B,eB)*ARcpH1(AH1_(4.0)*mx4B); + AH1 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpH1(AH1_(4.0)*mn4R+peakC.y); + AH1 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpH1(AH1_(4.0)*mn4G+peakC.y); + AH1 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpH1(AH1_(4.0)*mn4B+peakC.y); + AH1 lobeR=max(-hitMinR,hitMaxR); + AH1 lobeG=max(-hitMinG,hitMaxG); + AH1 lobeB=max(-hitMinB,hitMaxB); + AH1 lobe=max(AH1_(-FSR_RCAS_LIMIT),min(AMax3H1(lobeR,lobeG,lobeB),AH1_(0.0)))*AH2_AU1(con.y).x; + // Apply noise removal. + #ifdef FSR_RCAS_DENOISE + lobe*=nz; + #endif + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + AH1 rcpL=APrxMedRcpH1(AH1_(4.0)*lobe+AH1_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// PACKED 16-BIT VERSION +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF)&&defined(FSR_RCAS_HX2) + // Input callback prototypes that need to be implemented by the calling shader + AH4 FsrRcasLoadHx2(ASW2 p); + void FsrRcasInputHx2(inout AH2 r,inout AH2 g,inout AH2 b); +//------------------------------------------------------------------------------------------------------------------------------ + // Can be used to convert from packed Structures of Arrays to Arrays of Structures for store. + void FsrRcasDepackHx2(out AH4 pix0,out AH4 pix1,AH2 pixR,AH2 pixG,AH2 pixB){ + #ifdef A_HLSL + // Invoke a slower path for DX only, since it won't allow uninitialized values. + pix0.a=pix1.a=0.0; + #endif + pix0.rgb=AH3(pixR.x,pixG.x,pixB.x); + pix1.rgb=AH3(pixR.y,pixG.y,pixB.y);} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrRcasHx2( + // Output values are for 2 8x8 tiles in a 16x8 region. + // pix<R,G,B>.x = left 8x8 tile + // pix<R,G,B>.y = right 8x8 tile + // This enables later processing to easily be packed as well. + out AH2 pixR, + out AH2 pixG, + out AH2 pixB, + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + out AH2 pixA, + #endif + AU2 ip, // Integer pixel position in output. + AU4 con){ // Constant generated by RcasSetup(). + // No scaling algorithm uses minimal 3x3 pixel neighborhood. + ASW2 sp0=ASW2(ip); + AH3 b0=FsrRcasLoadHx2(sp0+ASW2( 0,-1)).rgb; + AH3 d0=FsrRcasLoadHx2(sp0+ASW2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AH4 ee0=FsrRcasLoadHx2(sp0); + AH3 e0=ee0.rgb;pixA.r=ee0.a; + #else + AH3 e0=FsrRcasLoadHx2(sp0).rgb; + #endif + AH3 f0=FsrRcasLoadHx2(sp0+ASW2( 1, 0)).rgb; + AH3 h0=FsrRcasLoadHx2(sp0+ASW2( 0, 1)).rgb; + ASW2 sp1=sp0+ASW2(8,0); + AH3 b1=FsrRcasLoadHx2(sp1+ASW2( 0,-1)).rgb; + AH3 d1=FsrRcasLoadHx2(sp1+ASW2(-1, 0)).rgb; + #ifdef FSR_RCAS_PASSTHROUGH_ALPHA + AH4 ee1=FsrRcasLoadHx2(sp1); + AH3 e1=ee1.rgb;pixA.g=ee1.a; + #else + AH3 e1=FsrRcasLoadHx2(sp1).rgb; + #endif + AH3 f1=FsrRcasLoadHx2(sp1+ASW2( 1, 0)).rgb; + AH3 h1=FsrRcasLoadHx2(sp1+ASW2( 0, 1)).rgb; + // Arrays of Structures to Structures of Arrays conversion. + AH2 bR=AH2(b0.r,b1.r); + AH2 bG=AH2(b0.g,b1.g); + AH2 bB=AH2(b0.b,b1.b); + AH2 dR=AH2(d0.r,d1.r); + AH2 dG=AH2(d0.g,d1.g); + AH2 dB=AH2(d0.b,d1.b); + AH2 eR=AH2(e0.r,e1.r); + AH2 eG=AH2(e0.g,e1.g); + AH2 eB=AH2(e0.b,e1.b); + AH2 fR=AH2(f0.r,f1.r); + AH2 fG=AH2(f0.g,f1.g); + AH2 fB=AH2(f0.b,f1.b); + AH2 hR=AH2(h0.r,h1.r); + AH2 hG=AH2(h0.g,h1.g); + AH2 hB=AH2(h0.b,h1.b); + // Run optional input transform. + FsrRcasInputHx2(bR,bG,bB); + FsrRcasInputHx2(dR,dG,dB); + FsrRcasInputHx2(eR,eG,eB); + FsrRcasInputHx2(fR,fG,fB); + FsrRcasInputHx2(hR,hG,hB); + // Luma times 2. + AH2 bL=bB*AH2_(0.5)+(bR*AH2_(0.5)+bG); + AH2 dL=dB*AH2_(0.5)+(dR*AH2_(0.5)+dG); + AH2 eL=eB*AH2_(0.5)+(eR*AH2_(0.5)+eG); + AH2 fL=fB*AH2_(0.5)+(fR*AH2_(0.5)+fG); + AH2 hL=hB*AH2_(0.5)+(hR*AH2_(0.5)+hG); + // Noise detection. + AH2 nz=AH2_(0.25)*bL+AH2_(0.25)*dL+AH2_(0.25)*fL+AH2_(0.25)*hL-eL; + nz=ASatH2(abs(nz)*APrxMedRcpH2(AMax3H2(AMax3H2(bL,dL,eL),fL,hL)-AMin3H2(AMin3H2(bL,dL,eL),fL,hL))); + nz=AH2_(-0.5)*nz+AH2_(1.0); + // Min and max of ring. + AH2 mn4R=min(AMin3H2(bR,dR,fR),hR); + AH2 mn4G=min(AMin3H2(bG,dG,fG),hG); + AH2 mn4B=min(AMin3H2(bB,dB,fB),hB); + AH2 mx4R=max(AMax3H2(bR,dR,fR),hR); + AH2 mx4G=max(AMax3H2(bG,dG,fG),hG); + AH2 mx4B=max(AMax3H2(bB,dB,fB),hB); + // Immediate constants for peak range. + AH2 peakC=AH2(1.0,-1.0*4.0); + // Limiters, these need to be high precision RCPs. + AH2 hitMinR=min(mn4R,eR)*ARcpH2(AH2_(4.0)*mx4R); + AH2 hitMinG=min(mn4G,eG)*ARcpH2(AH2_(4.0)*mx4G); + AH2 hitMinB=min(mn4B,eB)*ARcpH2(AH2_(4.0)*mx4B); + AH2 hitMaxR=(peakC.x-max(mx4R,eR))*ARcpH2(AH2_(4.0)*mn4R+peakC.y); + AH2 hitMaxG=(peakC.x-max(mx4G,eG))*ARcpH2(AH2_(4.0)*mn4G+peakC.y); + AH2 hitMaxB=(peakC.x-max(mx4B,eB))*ARcpH2(AH2_(4.0)*mn4B+peakC.y); + AH2 lobeR=max(-hitMinR,hitMaxR); + AH2 lobeG=max(-hitMinG,hitMaxG); + AH2 lobeB=max(-hitMinB,hitMaxB); + AH2 lobe=max(AH2_(-FSR_RCAS_LIMIT),min(AMax3H2(lobeR,lobeG,lobeB),AH2_(0.0)))*AH2_(AH2_AU1(con.y).x); + // Apply noise removal. + #ifdef FSR_RCAS_DENOISE + lobe*=nz; + #endif + // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes. + AH2 rcpL=APrxMedRcpH2(AH2_(4.0)*lobe+AH2_(1.0)); + pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; + pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; + pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [LFGA] LINEAR FILM GRAIN APPLICATOR +// +//------------------------------------------------------------------------------------------------------------------------------ +// Adding output-resolution film grain after scaling is a good way to mask both rendering and scaling artifacts. +// Suggest using tiled blue noise as film grain input, with peak noise frequency set for a specific look and feel. +// The 'Lfga*()' functions provide a convenient way to introduce grain. +// These functions limit grain based on distance to signal limits. +// This is done so that the grain is temporally energy preserving, and thus won't modify image tonality. +// Grain application should be done in a linear colorspace. +// The grain should be temporally changing, but have a temporal sum per pixel that adds to zero (non-biased). +//------------------------------------------------------------------------------------------------------------------------------ +// Usage, +// FsrLfga*( +// color, // In/out linear colorspace color {0 to 1} ranged. +// grain, // Per pixel grain texture value {-0.5 to 0.5} ranged, input is 3-channel to support colored grain. +// amount); // Amount of grain (0 to 1} ranged. +//------------------------------------------------------------------------------------------------------------------------------ +// Example if grain texture is monochrome: 'FsrLfgaF(color,AF3_(grain),amount)' +//============================================================================================================================== +#if defined(A_GPU) + // Maximum grain is the minimum distance to the signal limit. + void FsrLfgaF(inout AF3 c,AF3 t,AF1 a){c+=(t*AF3_(a))*min(AF3_(1.0)-c,c);} +#endif +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF) + // Half precision version (slower). + void FsrLfgaH(inout AH3 c,AH3 t,AH1 a){c+=(t*AH3_(a))*min(AH3_(1.0)-c,c);} +//------------------------------------------------------------------------------------------------------------------------------ + // Packed half precision version (faster). + void FsrLfgaHx2(inout AH2 cR,inout AH2 cG,inout AH2 cB,AH2 tR,AH2 tG,AH2 tB,AH1 a){ + cR+=(tR*AH2_(a))*min(AH2_(1.0)-cR,cR);cG+=(tG*AH2_(a))*min(AH2_(1.0)-cG,cG);cB+=(tB*AH2_(a))*min(AH2_(1.0)-cB,cB);} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [SRTM] SIMPLE REVERSIBLE TONE-MAPPER +// +//------------------------------------------------------------------------------------------------------------------------------ +// This provides a way to take linear HDR color {0 to FP16_MAX} and convert it into a temporary {0 to 1} ranged post-tonemapped linear. +// The tonemapper preserves RGB ratio, which helps maintain HDR color bleed during filtering. +//------------------------------------------------------------------------------------------------------------------------------ +// Reversible tonemapper usage, +// FsrSrtm*(color); // {0 to FP16_MAX} converted to {0 to 1}. +// FsrSrtmInv*(color); // {0 to 1} converted into {0 to 32768, output peak safe for FP16}. +//============================================================================================================================== +#if defined(A_GPU) + void FsrSrtmF(inout AF3 c){c*=AF3_(ARcpF1(AMax3F1(c.r,c.g,c.b)+AF1_(1.0)));} + // The extra max solves the c=1.0 case (which is a /0). + void FsrSrtmInvF(inout AF3 c){c*=AF3_(ARcpF1(max(AF1_(1.0/32768.0),AF1_(1.0)-AMax3F1(c.r,c.g,c.b))));} +#endif +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF) + void FsrSrtmH(inout AH3 c){c*=AH3_(ARcpH1(AMax3H1(c.r,c.g,c.b)+AH1_(1.0)));} + void FsrSrtmInvH(inout AH3 c){c*=AH3_(ARcpH1(max(AH1_(1.0/32768.0),AH1_(1.0)-AMax3H1(c.r,c.g,c.b))));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrSrtmHx2(inout AH2 cR,inout AH2 cG,inout AH2 cB){ + AH2 rcp=ARcpH2(AMax3H2(cR,cG,cB)+AH2_(1.0));cR*=rcp;cG*=rcp;cB*=rcp;} + void FsrSrtmInvHx2(inout AH2 cR,inout AH2 cG,inout AH2 cB){ + AH2 rcp=ARcpH2(max(AH2_(1.0/32768.0),AH2_(1.0)-AMax3H2(cR,cG,cB)));cR*=rcp;cG*=rcp;cB*=rcp;} +#endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//_____________________________________________________________/\_______________________________________________________________ +//============================================================================================================================== +// +// FSR - [TEPD] TEMPORAL ENERGY PRESERVING DITHER +// +//------------------------------------------------------------------------------------------------------------------------------ +// Temporally energy preserving dithered {0 to 1} linear to gamma 2.0 conversion. +// Gamma 2.0 is used so that the conversion back to linear is just to square the color. +// The conversion comes in 8-bit and 10-bit modes, designed for output to 8-bit UNORM or 10:10:10:2 respectively. +// Given good non-biased temporal blue noise as dither input, +// the output dither will temporally conserve energy. +// This is done by choosing the linear nearest step point instead of perceptual nearest. +// See code below for details. +//------------------------------------------------------------------------------------------------------------------------------ +// DX SPEC RULES FOR FLOAT->UNORM 8-BIT CONVERSION +// =============================================== +// - Output is 'uint(floor(saturate(n)*255.0+0.5))'. +// - Thus rounding is to nearest. +// - NaN gets converted to zero. +// - INF is clamped to {0.0 to 1.0}. +//============================================================================================================================== +#if defined(A_GPU) + // Hand tuned integer position to dither value, with more values than simple checkerboard. + // Only 32-bit has enough precision for this compddation. + // Output is {0 to <1}. + AF1 FsrTepdDitF(AU2 p,AU1 f){ + AF1 x=AF1_(p.x+f); + AF1 y=AF1_(p.y); + // The 1.61803 golden ratio. + AF1 a=AF1_((1.0+sqrt(5.0))/2.0); + // Number designed to provide a good visual pattern. + AF1 b=AF1_(1.0/3.69); + x=x*a+(y*b); + return AFractF1(x);} +//------------------------------------------------------------------------------------------------------------------------------ + // This version is 8-bit gamma 2.0. + // The 'c' input is {0 to 1}. + // Output is {0 to 1} ready for image store. + void FsrTepdC8F(inout AF3 c,AF1 dit){ + AF3 n=sqrt(c); + n=floor(n*AF3_(255.0))*AF3_(1.0/255.0); + AF3 a=n*n; + AF3 b=n+AF3_(1.0/255.0);b=b*b; + // Ratio of 'a' to 'b' required to produce 'c'. + // APrxLoRcpF1() won't work here (at least for very high dynamic ranges). + // APrxMedRcpF1() is an IADD,FMA,MUL. + AF3 r=(c-b)*APrxMedRcpF3(a-b); + // Use the ratio as a cutoff to choose 'a' or 'b'. + // AGtZeroF1() is a MUL. + c=ASatF3(n+AGtZeroF3(AF3_(dit)-r)*AF3_(1.0/255.0));} +//------------------------------------------------------------------------------------------------------------------------------ + // This version is 10-bit gamma 2.0. + // The 'c' input is {0 to 1}. + // Output is {0 to 1} ready for image store. + void FsrTepdC10F(inout AF3 c,AF1 dit){ + AF3 n=sqrt(c); + n=floor(n*AF3_(1023.0))*AF3_(1.0/1023.0); + AF3 a=n*n; + AF3 b=n+AF3_(1.0/1023.0);b=b*b; + AF3 r=(c-b)*APrxMedRcpF3(a-b); + c=ASatF3(n+AGtZeroF3(AF3_(dit)-r)*AF3_(1.0/1023.0));} +#endif +//============================================================================================================================== +#if defined(A_GPU)&&defined(A_HALF) + AH1 FsrTepdDitH(AU2 p,AU1 f){ + AF1 x=AF1_(p.x+f); + AF1 y=AF1_(p.y); + AF1 a=AF1_((1.0+sqrt(5.0))/2.0); + AF1 b=AF1_(1.0/3.69); + x=x*a+(y*b); + return AH1(AFractF1(x));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC8H(inout AH3 c,AH1 dit){ + AH3 n=sqrt(c); + n=floor(n*AH3_(255.0))*AH3_(1.0/255.0); + AH3 a=n*n; + AH3 b=n+AH3_(1.0/255.0);b=b*b; + AH3 r=(c-b)*APrxMedRcpH3(a-b); + c=ASatH3(n+AGtZeroH3(AH3_(dit)-r)*AH3_(1.0/255.0));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC10H(inout AH3 c,AH1 dit){ + AH3 n=sqrt(c); + n=floor(n*AH3_(1023.0))*AH3_(1.0/1023.0); + AH3 a=n*n; + AH3 b=n+AH3_(1.0/1023.0);b=b*b; + AH3 r=(c-b)*APrxMedRcpH3(a-b); + c=ASatH3(n+AGtZeroH3(AH3_(dit)-r)*AH3_(1.0/1023.0));} +//============================================================================================================================== + // This computes dither for positions 'p' and 'p+{8,0}'. + AH2 FsrTepdDitHx2(AU2 p,AU1 f){ + AF2 x; + x.x=AF1_(p.x+f); + x.y=x.x+AF1_(8.0); + AF1 y=AF1_(p.y); + AF1 a=AF1_((1.0+sqrt(5.0))/2.0); + AF1 b=AF1_(1.0/3.69); + x=x*AF2_(a)+AF2_(y*b); + return AH2(AFractF2(x));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC8Hx2(inout AH2 cR,inout AH2 cG,inout AH2 cB,AH2 dit){ + AH2 nR=sqrt(cR); + AH2 nG=sqrt(cG); + AH2 nB=sqrt(cB); + nR=floor(nR*AH2_(255.0))*AH2_(1.0/255.0); + nG=floor(nG*AH2_(255.0))*AH2_(1.0/255.0); + nB=floor(nB*AH2_(255.0))*AH2_(1.0/255.0); + AH2 aR=nR*nR; + AH2 aG=nG*nG; + AH2 aB=nB*nB; + AH2 bR=nR+AH2_(1.0/255.0);bR=bR*bR; + AH2 bG=nG+AH2_(1.0/255.0);bG=bG*bG; + AH2 bB=nB+AH2_(1.0/255.0);bB=bB*bB; + AH2 rR=(cR-bR)*APrxMedRcpH2(aR-bR); + AH2 rG=(cG-bG)*APrxMedRcpH2(aG-bG); + AH2 rB=(cB-bB)*APrxMedRcpH2(aB-bB); + cR=ASatH2(nR+AGtZeroH2(dit-rR)*AH2_(1.0/255.0)); + cG=ASatH2(nG+AGtZeroH2(dit-rG)*AH2_(1.0/255.0)); + cB=ASatH2(nB+AGtZeroH2(dit-rB)*AH2_(1.0/255.0));} +//------------------------------------------------------------------------------------------------------------------------------ + void FsrTepdC10Hx2(inout AH2 cR,inout AH2 cG,inout AH2 cB,AH2 dit){ + AH2 nR=sqrt(cR); + AH2 nG=sqrt(cG); + AH2 nB=sqrt(cB); + nR=floor(nR*AH2_(1023.0))*AH2_(1.0/1023.0); + nG=floor(nG*AH2_(1023.0))*AH2_(1.0/1023.0); + nB=floor(nB*AH2_(1023.0))*AH2_(1.0/1023.0); + AH2 aR=nR*nR; + AH2 aG=nG*nG; + AH2 aB=nB*nB; + AH2 bR=nR+AH2_(1.0/1023.0);bR=bR*bR; + AH2 bG=nG+AH2_(1.0/1023.0);bG=bG*bG; + AH2 bB=nB+AH2_(1.0/1023.0);bB=bB*bB; + AH2 rR=(cR-bR)*APrxMedRcpH2(aR-bR); + AH2 rG=(cG-bG)*APrxMedRcpH2(aG-bG); + AH2 rB=(cB-bB)*APrxMedRcpH2(aB-bB); + cR=ASatH2(nR+AGtZeroH2(dit-rR)*AH2_(1.0/1023.0)); + cG=ASatH2(nG+AGtZeroH2(dit-rG)*AH2_(1.0/1023.0)); + cB=ASatH2(nB+AGtZeroH2(dit-rB)*AH2_(1.0/1023.0));} +#endif diff --git a/thirdparty/amd-fsr/license.txt b/thirdparty/amd-fsr/license.txt new file mode 100644 index 0000000000..324cba594d --- /dev/null +++ b/thirdparty/amd-fsr/license.txt @@ -0,0 +1,19 @@ +Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. + +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. diff --git a/thirdparty/embree/common/sys/platform.h b/thirdparty/embree/common/sys/platform.h index 697e07bb86..3e386c4944 100644 --- a/thirdparty/embree/common/sys/platform.h +++ b/thirdparty/embree/common/sys/platform.h @@ -183,7 +183,7 @@ // #define THROW_RUNTIME_ERROR(str) // throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)); #define THROW_RUNTIME_ERROR(str) \ - printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort(); + printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort(); // -- GODOT end -- #else // -- GODOT start -- diff --git a/thirdparty/embree/kernels/common/rtcore.h b/thirdparty/embree/kernels/common/rtcore.h index 373e49a689..f8aad7c7cb 100644 --- a/thirdparty/embree/kernels/common/rtcore.h +++ b/thirdparty/embree/kernels/common/rtcore.h @@ -126,7 +126,7 @@ namespace embree // #define throw_RTCError(error,str) \ // throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)); #define throw_RTCError(error,str) \ - printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort(); + printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort(); // -- GODOT end -- #else // -- GODOT begin -- diff --git a/thirdparty/embree/patches/godot-changes-noexcept.patch b/thirdparty/embree/patches/godot-changes-noexcept.patch index c587a0e2be..598a7f2ddc 100644 --- a/thirdparty/embree/patches/godot-changes-noexcept.patch +++ b/thirdparty/embree/patches/godot-changes-noexcept.patch @@ -259,7 +259,7 @@ index 8a6d9fa0a9..697e07bb86 100644 + // throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)); #define THROW_RUNTIME_ERROR(str) \ - throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)); -+ printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort(); ++ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort(); + // -- GODOT end -- #else + // -- GODOT start -- @@ -583,7 +583,7 @@ index 4e4b24e9c2..373e49a689 100644 + // throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)); #define throw_RTCError(error,str) \ - throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)); -+ printf(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str)), abort(); ++ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort(); + // -- GODOT end -- #else + // -- GODOT begin -- diff --git a/thirdparty/harfbuzz/src/hb-array.hh b/thirdparty/harfbuzz/src/hb-array.hh index dd61509b2e..0beffb078f 100644 --- a/thirdparty/harfbuzz/src/hb-array.hh +++ b/thirdparty/harfbuzz/src/hb-array.hh @@ -51,13 +51,19 @@ struct hb_array_t : hb_iter_with_fallback_t<hb_array_t<Type>, Type&> * Constructors. */ hb_array_t () = default; - hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {} + hb_array_t (const hb_array_t&) = default; + ~hb_array_t () = default; + hb_array_t& operator= (const hb_array_t&) = default; + hb_array_t& operator= (hb_array_t&&) = default; + + constexpr hb_array_t (std::nullptr_t) : hb_array_t () {} + constexpr hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {} template <unsigned int length_> - hb_array_t (Type (&array_)[length_]) : hb_array_t (array_, length_) {} + constexpr hb_array_t (Type (&array_)[length_]) : hb_array_t (array_, length_) {} template <typename U, hb_enable_if (hb_is_cr_convertible(U, Type))> - hb_array_t (const hb_array_t<U> &o) : + constexpr hb_array_t (const hb_array_t<U> &o) : hb_iter_with_fallback_t<hb_array_t, Type&> (), arrayZ (o.arrayZ), length (o.length), backwards_length (o.backwards_length) {} template <typename U, @@ -303,13 +309,19 @@ struct hb_sorted_array_t : static constexpr bool is_sorted_iterator = true; hb_sorted_array_t () = default; - hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {} + hb_sorted_array_t (const hb_sorted_array_t&) = default; + ~hb_sorted_array_t () = default; + hb_sorted_array_t& operator= (const hb_sorted_array_t&) = default; + hb_sorted_array_t& operator= (hb_sorted_array_t&&) = default; + + constexpr hb_sorted_array_t (std::nullptr_t) : hb_sorted_array_t () {} + constexpr hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {} template <unsigned int length_> - hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {} + constexpr hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {} template <typename U, hb_enable_if (hb_is_cr_convertible(U, Type))> - hb_sorted_array_t (const hb_array_t<U> &o) : + constexpr hb_sorted_array_t (const hb_array_t<U> &o) : hb_iter_t<hb_sorted_array_t, Type&> (), hb_array_t<Type> (o) {} template <typename U, diff --git a/thirdparty/harfbuzz/src/hb-map.hh b/thirdparty/harfbuzz/src/hb-map.hh index bb4a0eb5d1..793dcf22ca 100644 --- a/thirdparty/harfbuzz/src/hb-map.hh +++ b/thirdparty/harfbuzz/src/hb-map.hh @@ -35,8 +35,10 @@ */ template <typename K, typename V, - K kINVALID = hb_is_pointer (K) ? 0 : std::is_signed<K>::value ? hb_int_min (K) : (K) -1, - V vINVALID = hb_is_pointer (V) ? 0 : std::is_signed<V>::value ? hb_int_min (V) : (V) -1> + typename k_invalid_t = K, + typename v_invalid_t = V, + k_invalid_t kINVALID = hb_is_pointer (K) ? 0 : std::is_signed<K>::value ? hb_int_min (K) : (K) -1, + v_invalid_t vINVALID = hb_is_pointer (V) ? 0 : std::is_signed<V>::value ? hb_int_min (V) : (V) -1> struct hb_hashmap_t { static constexpr K INVALID_KEY = kINVALID; @@ -62,8 +64,10 @@ struct hb_hashmap_t hb_copy (o, *this); } - static_assert (std::is_integral<K>::value || hb_is_pointer (K), ""); - static_assert (std::is_integral<V>::value || hb_is_pointer (V), ""); + static_assert (std::is_trivially_copyable<K>::value, ""); + static_assert (std::is_trivially_copyable<V>::value, ""); + static_assert (std::is_trivially_destructible<K>::value, ""); + static_assert (std::is_trivially_destructible<V>::value, ""); struct item_t { @@ -348,19 +352,23 @@ struct hb_hashmap_t struct hb_map_t : hb_hashmap_t<hb_codepoint_t, hb_codepoint_t, + hb_codepoint_t, + hb_codepoint_t, HB_MAP_VALUE_INVALID, HB_MAP_VALUE_INVALID> { using hashmap = hb_hashmap_t<hb_codepoint_t, hb_codepoint_t, + hb_codepoint_t, + hb_codepoint_t, HB_MAP_VALUE_INVALID, HB_MAP_VALUE_INVALID>; hb_map_t () = default; ~hb_map_t () = default; - hb_map_t (hb_map_t& o) = default; - hb_map_t& operator= (const hb_map_t& other) = default; - hb_map_t& operator= (hb_map_t&& other) = default; + hb_map_t (hb_map_t&) = default; + hb_map_t& operator= (const hb_map_t&) = default; + hb_map_t& operator= (hb_map_t&&) = default; hb_map_t (std::initializer_list<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> lst) : hashmap (lst) {} template <typename Iterable, hb_requires (hb_is_iterable (Iterable))> diff --git a/thirdparty/harfbuzz/src/hb-ot-color-colr-table.hh b/thirdparty/harfbuzz/src/hb-ot-color-colr-table.hh index 03476faba7..a3c55fa8f4 100644 --- a/thirdparty/harfbuzz/src/hb-ot-color-colr-table.hh +++ b/thirdparty/harfbuzz/src/hb-ot-color-colr-table.hh @@ -38,8 +38,8 @@ */ #define HB_OT_TAG_COLR HB_TAG('C','O','L','R') -#ifndef COLRV1_MAX_NESTING_LEVEL -#define COLRV1_MAX_NESTING_LEVEL 100 +#ifndef HB_COLRV1_MAX_NESTING_LEVEL +#define HB_COLRV1_MAX_NESTING_LEVEL 100 #endif #ifndef COLRV1_ENABLE_SUBSETTING @@ -102,7 +102,7 @@ struct hb_colrv1_closure_context_t : hb_set_t *glyphs_, hb_set_t *layer_indices_, hb_set_t *palette_indices_, - unsigned nesting_level_left_ = COLRV1_MAX_NESTING_LEVEL) : + unsigned nesting_level_left_ = HB_COLRV1_MAX_NESTING_LEVEL) : base (base_), glyphs (glyphs_), layer_indices (layer_indices_), @@ -985,7 +985,7 @@ struct ClipList for (const hb_codepoint_t _ : gids.iter ()) { if (_ == start_gid) continue; - + offset = gid_offset_map.get (_); if (_ == prev_gid + 1 && offset == prev_offset) { @@ -1027,7 +1027,7 @@ struct ClipList const hb_set_t& glyphset = *c->plan->_glyphset; const hb_map_t &glyph_map = *c->plan->glyph_map; - + hb_map_t new_gid_offset_map; hb_set_t new_gids; for (const ClipRecord& record : clips.iter ()) @@ -1062,6 +1062,18 @@ struct ClipList struct Paint { + + template <typename ...Ts> + bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const + { + TRACE_SANITIZE (this); + + if (unlikely (!c->check_start_recursion (HB_COLRV1_MAX_NESTING_LEVEL))) + return_trace (c->no_dispatch_return_value ()); + + return_trace (c->end_recursion (this->dispatch (c, std::forward<Ts> (ds)...))); + } + template <typename context_t, typename ...Ts> typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const { diff --git a/thirdparty/harfbuzz/src/hb-ot-layout-common.hh b/thirdparty/harfbuzz/src/hb-ot-layout-common.hh index 5d98278bed..882c3ae96f 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout-common.hh +++ b/thirdparty/harfbuzz/src/hb-ot-layout-common.hh @@ -98,7 +98,7 @@ static void ClassDef_remap_and_serialize (hb_serialize_context_t *c, struct hb_prune_langsys_context_t { hb_prune_langsys_context_t (const void *table_, - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *script_langsys_map_, + hb_hashmap_t<unsigned, hb_set_t *> *script_langsys_map_, const hb_map_t *duplicate_feature_map_, hb_set_t *new_collected_feature_indexes_) :table (table_), @@ -137,7 +137,7 @@ struct hb_prune_langsys_context_t public: const void *table; - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *script_langsys_map; + hb_hashmap_t<unsigned, hb_set_t *> *script_langsys_map; const hb_map_t *duplicate_feature_map; hb_set_t *new_feature_indexes; @@ -179,14 +179,14 @@ struct hb_subset_layout_context_t : hb_subset_context_t *subset_context; const hb_tag_t table_tag; const hb_map_t *lookup_index_map; - const hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *script_langsys_map; + const hb_hashmap_t<unsigned, hb_set_t *> *script_langsys_map; const hb_map_t *feature_index_map; unsigned cur_script_index; hb_subset_layout_context_t (hb_subset_context_t *c_, hb_tag_t tag_, hb_map_t *lookup_map_, - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *script_langsys_map_, + hb_hashmap_t<unsigned, hb_set_t *> *script_langsys_map_, hb_map_t *feature_index_map_) : subset_context (c_), table_tag (tag_), @@ -1357,7 +1357,7 @@ struct Lookup if (unlikely (!get_subtables<TSubTable> ().sanitize (c, this, get_type ()))) return_trace (false); - if (unlikely (get_type () == TSubTable::Extension && !c->get_edit_count ())) + if (unlikely (get_type () == TSubTable::Extension && subtables && !c->get_edit_count ())) { /* The spec says all subtables of an Extension lookup should * have the same type, which shall not be the Extension type diff --git a/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh b/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh index c0ed2bcc03..6bc06b50ed 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh +++ b/thirdparty/harfbuzz/src/hb-ot-layout-gsubgpos.hh @@ -163,7 +163,7 @@ struct hb_closure_context_t : hb_set_t *glyphs_, hb_set_t *cur_intersected_glyphs_, hb_map_t *done_lookups_glyph_count_, - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *done_lookups_glyph_set_, + hb_hashmap_t<unsigned, hb_set_t *> *done_lookups_glyph_set_, unsigned int nesting_level_left_ = HB_MAX_NESTING_LEVEL) : face (face_), glyphs (glyphs_), @@ -192,7 +192,7 @@ struct hb_closure_context_t : private: hb_map_t *done_lookups_glyph_count; - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *done_lookups_glyph_set; + hb_hashmap_t<unsigned, hb_set_t *> *done_lookups_glyph_set; unsigned int lookup_count; }; @@ -1642,9 +1642,8 @@ struct Rule const hb_map_t *klass_map = nullptr) const { TRACE_SUBSET (this); - - const hb_array_t<const HBUINT16> input = inputZ.as_array ((inputCount ? inputCount - 1 : 0)); - if (!input.length) return_trace (false); + if (unlikely (!inputCount)) return_trace (false); + const hb_array_t<const HBUINT16> input = inputZ.as_array (inputCount - 1); const hb_map_t *mapping = klass_map == nullptr ? c->plan->glyph_map : klass_map; if (!hb_all (input, mapping)) return_trace (false); @@ -3631,7 +3630,7 @@ struct GSUBGPOS } void prune_langsys (const hb_map_t *duplicate_feature_map, - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *script_langsys_map, + hb_hashmap_t<unsigned, hb_set_t *> *script_langsys_map, hb_set_t *new_feature_indexes /* OUT */) const { hb_prune_langsys_context_t c (this, script_langsys_map, duplicate_feature_map, new_feature_indexes); @@ -3689,7 +3688,7 @@ struct GSUBGPOS hb_map_t *duplicate_feature_map /* OUT */) const { if (feature_indices->is_empty ()) return; - hb_hashmap_t<hb_tag_t, hb_set_t *, (unsigned)-1, nullptr> unique_features; + hb_hashmap_t<hb_tag_t, hb_set_t *> unique_features; //find out duplicate features after subset for (unsigned i : feature_indices->iter ()) { @@ -3784,8 +3783,12 @@ struct GSUBGPOS // http://lists.freedesktop.org/archives/harfbuzz/2012-November/002660.html continue; - if (f.featureParams.is_null () - && !f.intersects_lookup_indexes (lookup_indices) + + if (!f.featureParams.is_null () && + tag == HB_TAG ('s', 'i', 'z', 'e')) + continue; + + if (!f.intersects_lookup_indexes (lookup_indices) #ifndef HB_NO_VAR && !alternate_feature_indices.has (i) #endif diff --git a/thirdparty/harfbuzz/src/hb-ot-layout.cc b/thirdparty/harfbuzz/src/hb-ot-layout.cc index fbdedd0e20..4e1d23eba5 100644 --- a/thirdparty/harfbuzz/src/hb-ot-layout.cc +++ b/thirdparty/harfbuzz/src/hb-ot-layout.cc @@ -1493,7 +1493,7 @@ hb_ot_layout_lookup_substitute_closure (hb_face_t *face, { hb_set_t cur_intersected_glyphs; hb_map_t done_lookups_glyph_count; - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> done_lookups_glyph_set; + hb_hashmap_t<unsigned, hb_set_t *> done_lookups_glyph_set; OT::hb_closure_context_t c (face, glyphs, &cur_intersected_glyphs, &done_lookups_glyph_count, &done_lookups_glyph_set); const OT::SubstLookup& l = face->table.GSUB->table->get_lookup (lookup_index); @@ -1522,7 +1522,7 @@ hb_ot_layout_lookups_substitute_closure (hb_face_t *face, { hb_set_t cur_intersected_glyphs; hb_map_t done_lookups_glyph_count; - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> done_lookups_glyph_set; + hb_hashmap_t<unsigned, hb_set_t *> done_lookups_glyph_set; OT::hb_closure_context_t c (face, glyphs, &cur_intersected_glyphs, &done_lookups_glyph_count, &done_lookups_glyph_set); const OT::GSUB& gsub = *face->table.GSUB->table; diff --git a/thirdparty/harfbuzz/src/hb-ot-post-table-v2subset.hh b/thirdparty/harfbuzz/src/hb-ot-post-table-v2subset.hh index 94450eb53a..504de2de74 100644 --- a/thirdparty/harfbuzz/src/hb-ot-post-table-v2subset.hh +++ b/thirdparty/harfbuzz/src/hb-ot-post-table-v2subset.hh @@ -79,6 +79,7 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const post::accelerator_t _post; _post.init (c->plan->source); + hb_hashmap_t<hb_bytes_t, unsigned, std::nullptr_t, unsigned, nullptr, (unsigned)-1> glyph_name_to_new_index; for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++) { hb_codepoint_t old_gid = reverse_glyph_map.get (new_gid); @@ -90,22 +91,28 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const else { hb_bytes_t s = _post.find_glyph_name (old_gid); - int standard_glyph_index = -1; - for (unsigned i = 0; i < format1_names_length; i++) + new_index = glyph_name_to_new_index.get (s); + if (new_index == (unsigned)-1) { - if (s == format1_names (i)) + int standard_glyph_index = -1; + for (unsigned i = 0; i < format1_names_length; i++) { - standard_glyph_index = i; - break; + if (s == format1_names (i)) + { + standard_glyph_index = i; + break; + } } + + if (standard_glyph_index == -1) + { + new_index = 258 + i; + i++; + } + else + { new_index = standard_glyph_index; } + glyph_name_to_new_index.set (s, new_index); } - if (standard_glyph_index == -1) - { - new_index = 258 + i; - i++; - } - else - { new_index = standard_glyph_index; } old_new_index_map.set (old_index, new_index); } old_gid_new_index_map.set (old_gid, new_index); diff --git a/thirdparty/harfbuzz/src/hb-sanitize.hh b/thirdparty/harfbuzz/src/hb-sanitize.hh index 2e536c7a81..65c2772201 100644 --- a/thirdparty/harfbuzz/src/hb-sanitize.hh +++ b/thirdparty/harfbuzz/src/hb-sanitize.hh @@ -123,6 +123,7 @@ struct hb_sanitize_context_t : hb_sanitize_context_t () : start (nullptr), end (nullptr), max_ops (0), max_subtables (0), + recursion_depth (0), writable (false), edit_count (0), blob (nullptr), num_glyphs (65536), @@ -205,6 +206,7 @@ struct hb_sanitize_context_t : (unsigned) HB_SANITIZE_MAX_OPS_MAX); this->edit_count = 0; this->debug_depth = 0; + this->recursion_depth = 0; DEBUG_MSG_LEVEL (SANITIZE, start, 0, +1, "start [%p..%p] (%lu bytes)", @@ -278,6 +280,18 @@ struct hb_sanitize_context_t : return this->check_range (base, a, b, hb_static_size (T)); } + bool check_start_recursion (int max_depth) + { + if (unlikely (recursion_depth >= max_depth)) return false; + return ++recursion_depth; + } + + bool end_recursion (bool result) + { + recursion_depth--; + return result; + } + template <typename Type> bool check_struct (const Type *obj) const { return likely (this->check_range (obj, obj->min_size)); } @@ -389,6 +403,7 @@ struct hb_sanitize_context_t : const char *start, *end; mutable int max_ops, max_subtables; private: + int recursion_depth; bool writable; unsigned int edit_count; hb_blob_t *blob; diff --git a/thirdparty/harfbuzz/src/hb-serialize.hh b/thirdparty/harfbuzz/src/hb-serialize.hh index 57689916f6..d22ae06087 100644 --- a/thirdparty/harfbuzz/src/hb-serialize.hh +++ b/thirdparty/harfbuzz/src/hb-serialize.hh @@ -652,7 +652,9 @@ struct hb_serialize_context_t hb_vector_t<object_t *> packed; /* Map view of packed objects. */ - hb_hashmap_t<const object_t *, objidx_t, nullptr, 0> packed_map; + hb_hashmap_t<const object_t *, objidx_t, + const object_t *, objidx_t, + nullptr, 0> packed_map; }; #endif /* HB_SERIALIZE_HH */ diff --git a/thirdparty/harfbuzz/src/hb-set.hh b/thirdparty/harfbuzz/src/hb-set.hh index 8841427189..af02e9e12b 100644 --- a/thirdparty/harfbuzz/src/hb-set.hh +++ b/thirdparty/harfbuzz/src/hb-set.hh @@ -157,9 +157,9 @@ struct hb_set_t : hb_sparseset_t<hb_bit_set_invertible_t> { hb_set_t () = default; ~hb_set_t () = default; - hb_set_t (hb_set_t& o) = default; - hb_set_t& operator= (const hb_set_t& other) = default; - hb_set_t& operator= (hb_set_t&& other) = default; + hb_set_t (hb_set_t&) = default; + hb_set_t& operator= (const hb_set_t&) = default; + hb_set_t& operator= (hb_set_t&&) = default; hb_set_t (std::initializer_list<hb_codepoint_t> lst) : hb_sparseset_t<hb_bit_set_invertible_t> (lst) {} template <typename Iterable, hb_requires (hb_is_iterable (Iterable))> diff --git a/thirdparty/harfbuzz/src/hb-subset-plan.cc b/thirdparty/harfbuzz/src/hb-subset-plan.cc index 1e195ff660..53f8664d92 100644 --- a/thirdparty/harfbuzz/src/hb-subset-plan.cc +++ b/thirdparty/harfbuzz/src/hb-subset-plan.cc @@ -41,7 +41,7 @@ #include "hb-ot-math-table.hh" -typedef hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> script_langsys_map; +typedef hb_hashmap_t<unsigned, hb_set_t *> script_langsys_map; #ifndef HB_NO_SUBSET_CFF static inline void _add_cff_seac_components (const OT::cff1::accelerator_t &cff, @@ -100,11 +100,23 @@ static void _collect_layout_indices (hb_face_t *face, if (!features.alloc (table.get_feature_count () + 1)) return; + hb_set_t visited_features; + bool retain_all_features = true; for (unsigned i = 0; i < table.get_feature_count (); i++) { hb_tag_t tag = table.get_feature_tag (i); - if (tag && layout_features_to_retain->has (tag)) - features.push (tag); + if (!tag) continue; + if (!layout_features_to_retain->has (tag)) + { + retain_all_features = false; + continue; + } + + if (visited_features.has (tag)) + continue; + + features.push (tag); + visited_features.add (tag); } if (!features) @@ -113,7 +125,7 @@ static void _collect_layout_indices (hb_face_t *face, // The collect function needs a null element to signal end of the array. features.push (0); - if (features.get_size () == table.get_feature_count () + 1) + if (retain_all_features) { // Looking for all features, trigger the faster collection method. layout_collect_func (face, diff --git a/thirdparty/harfbuzz/src/hb-subset-plan.hh b/thirdparty/harfbuzz/src/hb-subset-plan.hh index c30feeb42f..c0232480bf 100644 --- a/thirdparty/harfbuzz/src/hb-subset-plan.hh +++ b/thirdparty/harfbuzz/src/hb-subset-plan.hh @@ -84,8 +84,8 @@ struct hb_subset_plan_t hb_map_t *gpos_lookups; //active langsys we'd like to retain - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *gsub_langsys; - hb_hashmap_t<unsigned, hb_set_t *, (unsigned)-1, nullptr> *gpos_langsys; + hb_hashmap_t<unsigned, hb_set_t *> *gsub_langsys; + hb_hashmap_t<unsigned, hb_set_t *> *gpos_langsys; //active features after removing redundant langsys and prune_features hb_map_t *gsub_features; diff --git a/thirdparty/harfbuzz/src/hb-version.h b/thirdparty/harfbuzz/src/hb-version.h index 1a4f0bf62a..c9fefa1df6 100644 --- a/thirdparty/harfbuzz/src/hb-version.h +++ b/thirdparty/harfbuzz/src/hb-version.h @@ -53,14 +53,14 @@ HB_BEGIN_DECLS * * The micro component of the library version available at compile-time. */ -#define HB_VERSION_MICRO 1 +#define HB_VERSION_MICRO 2 /** * HB_VERSION_STRING: * * A string literal containing the library version available at compile-time. */ -#define HB_VERSION_STRING "3.1.1" +#define HB_VERSION_STRING "3.1.2" /** * HB_VERSION_ATLEAST: diff --git a/thirdparty/minimp3/minimp3.h b/thirdparty/minimp3/minimp3.h index 796cbc1f8e..3220ae1a85 100644 --- a/thirdparty/minimp3/minimp3.h +++ b/thirdparty/minimp3/minimp3.h @@ -881,12 +881,22 @@ static void L3_midside_stereo(float *left, int n) int i = 0; float *right = left + 576; #if HAVE_SIMD - if (have_simd()) for (; i < n - 3; i += 4) + if (have_simd()) { - f4 vl = VLD(left + i); - f4 vr = VLD(right + i); - VSTORE(left + i, VADD(vl, vr)); - VSTORE(right + i, VSUB(vl, vr)); + for (; i < n - 3; i += 4) + { + f4 vl = VLD(left + i); + f4 vr = VLD(right + i); + VSTORE(left + i, VADD(vl, vr)); + VSTORE(right + i, VSUB(vl, vr)); + } +#ifdef __GNUC__ + /* Workaround for spurious -Waggressive-loop-optimizations warning from gcc. + * For more info see: https://github.com/lieff/minimp3/issues/88 + */ + if (__builtin_constant_p(n % 4 == 0) && n % 4 == 0) + return; +#endif } #endif /* HAVE_SIMD */ for (; i < n; i++) @@ -1353,7 +1363,7 @@ static void mp3d_DCT_II(float *grbuf, int n) } else #endif /* HAVE_SIMD */ #ifdef MINIMP3_ONLY_SIMD - {} + {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */ #else /* MINIMP3_ONLY_SIMD */ for (; k < n; k++) { @@ -1583,7 +1593,7 @@ static void mp3d_synth(float *xl, mp3d_sample_t *dstl, int nch, float *lins) } else #endif /* HAVE_SIMD */ #ifdef MINIMP3_ONLY_SIMD - {} + {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */ #else /* MINIMP3_ONLY_SIMD */ for (i = 14; i >= 0; i--) { diff --git a/thirdparty/minimp3/minimp3_ex.h b/thirdparty/minimp3/minimp3_ex.h index e29dd15b2e..2871705df3 100644 --- a/thirdparty/minimp3/minimp3_ex.h +++ b/thirdparty/minimp3/minimp3_ex.h @@ -6,6 +6,7 @@ This software is distributed without any warranty. See <http://creativecommons.org/publicdomain/zero/1.0/>. */ +#include <stddef.h> #include "minimp3.h" /* flags for mp3dec_ex_open_* functions */ @@ -128,8 +129,10 @@ int mp3dec_ex_open_w(mp3dec_ex_t *dec, const wchar_t *file_name, int flags); #endif #endif /*MINIMP3_EXT_H*/ -#ifdef MINIMP3_IMPLEMENTATION +#if defined(MINIMP3_IMPLEMENTATION) && !defined(_MINIMP3_EX_IMPLEMENTATION_GUARD) +#define _MINIMP3_EX_IMPLEMENTATION_GUARD #include <limits.h> +#include "minimp3.h" static void mp3dec_skip_id3v1(const uint8_t *buf, size_t *pbuf_size) { @@ -1391,4 +1394,4 @@ void mp3dec_ex_close(mp3dec_ex_t *dec) } #endif -#endif /*MINIMP3_IMPLEMENTATION*/ +#endif /* MINIMP3_IMPLEMENTATION && !_MINIMP3_EX_IMPLEMENTATION_GUARD */ |