summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/linux_builds.yml2
-rw-r--r--doc/classes/Camera2D.xml2
-rw-r--r--editor/editor_fonts.cpp10
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp7
-rw-r--r--main/main.cpp20
-rw-r--r--misc/dist/shell/_godot.zsh-completion27
-rw-r--r--misc/dist/shell/godot.bash-completion17
-rw-r--r--misc/dist/shell/godot.fish26
-rw-r--r--scene/2d/camera_2d.cpp19
-rw-r--r--scene/2d/camera_2d.h1
-rw-r--r--scene/2d/line_2d.cpp6
-rw-r--r--scene/2d/node_2d.cpp3
-rw-r--r--scene/2d/polygon_2d.cpp4
-rw-r--r--scene/main/viewport.cpp14
-rw-r--r--scene/main/viewport.h1
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl6
16 files changed, 108 insertions, 57 deletions
diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml
index d75680b4b5..d41bfc009e 100644
--- a/.github/workflows/linux_builds.yml
+++ b/.github/workflows/linux_builds.yml
@@ -146,7 +146,7 @@ jobs:
- name: Open and close editor
if: ${{ matrix.proj-test }}
run: |
- VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy -e -q --path test_project 2>&1 | tee sanitizers_log.txt || true
+ VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true
misc/scripts/check_ci_log.py sanitizers_log.txt
# Run test project
diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml
index 3350735ca2..b9373676e2 100644
--- a/doc/classes/Camera2D.xml
+++ b/doc/classes/Camera2D.xml
@@ -157,7 +157,7 @@
Speed in pixels per second of the camera's smoothing effect when [member smoothing_enabled] is [code]true[/code].
</member>
<member name="zoom" type="Vector2" setter="set_zoom" getter="get_zoom" default="Vector2(1, 1)">
- The camera's zoom relative to the viewport. Values larger than [code]Vector2(1, 1)[/code] zoom out and smaller values zoom in. For an example, use [code]Vector2(0.5, 0.5)[/code] for a 2× zoom-in, and [code]Vector2(4, 4)[/code] for a 4× zoom-out.
+ The camera's zoom. A zoom of [code]Vector(2, 2)[/code] doubles the size seen in the viewport. A zoom of [code]Vector(0.5, 0.5)[/code] halves the size seen in the viewport.
</member>
</members>
<constants>
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index cd9298a122..7b72e09bd7 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -206,7 +206,8 @@ void editor_register_fonts(Ref<Theme> p_theme) {
break;
}
- int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
+ const int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE;
+ const float embolden_strength = 0.6;
String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font");
Ref<FontData> CustomFont;
@@ -226,6 +227,11 @@ void editor_register_fonts(Ref<Theme> p_theme) {
EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", "");
}
+ if (CustomFont.is_valid() && !CustomFontBold.is_valid()) {
+ CustomFontBold = CustomFont->duplicate();
+ CustomFontBold->set_embolden(embolden_strength);
+ }
+
/* Custom source code font */
String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font");
@@ -268,8 +274,6 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<FontData> FontFallback = load_cached_internal_font(_font_DroidSansFallback, _font_DroidSansFallback_size, font_hinting, font_antialiased, true, font_subpixel_positioning);
Ref<FontData> FontJapanese = load_cached_internal_font(_font_DroidSansJapanese, _font_DroidSansJapanese_size, font_hinting, font_antialiased, true, font_subpixel_positioning);
- const float embolden_strength = 0.6;
-
Ref<FontData> FontFallbackBold = FontFallback->duplicate();
FontFallbackBold->set_embolden(embolden_strength);
Ref<FontData> FontJapaneseBold = FontJapanese->duplicate();
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 5a2696fff1..22e0a3dabb 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -292,15 +292,14 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
_commit_action();
return true;
} else {
- Vector<Vector2> vertices2 = _get_polygon(insert.polygon);
- pre_move_edit = vertices2;
+ pre_move_edit = vertices;
edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos));
- vertices2.insert(edited_point.vertex, edited_point.pos);
+ vertices.insert(edited_point.vertex, edited_point.pos);
selected_point = Vertex(edited_point.polygon, edited_point.vertex);
edge_point = PosVertex();
undo_redo->create_action(TTR("Insert Point"));
- _action_set_polygon(insert.polygon, vertices2);
+ _action_set_polygon(insert.polygon, vertices);
_commit_action();
return true;
}
diff --git a/main/main.cpp b/main/main.cpp
index 4ed55cabf0..e0331f4945 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -273,7 +273,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -h, --help Display this help message.\n");
OS::get_singleton()->print(" --version Display the version string.\n");
OS::get_singleton()->print(" -v, --verbose Use verbose stdout mode.\n");
- OS::get_singleton()->print(" --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n");
+ OS::get_singleton()->print(" -q, --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Run options:\n");
@@ -282,7 +282,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
OS::get_singleton()->print(" --debug-server <uri> Start the editor debug server (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007)\n");
#endif
- OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n");
+ OS::get_singleton()->print(" --quit Quit after the first iteration.\n");
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
OS::get_singleton()->print(" --path <directory> Path to a project (<directory> must contain a 'project.godot' file).\n");
OS::get_singleton()->print(" -u, --upwards Scan folders upwards for project.godot file.\n");
@@ -319,9 +319,8 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --rendering-driver <driver> Rendering driver (depends on display driver).\n");
OS::get_singleton()->print(" --gpu-index <device_index> Use a specific GPU (run with --verbose to get available device list).\n");
-
OS::get_singleton()->print(" --text-driver <driver> Text driver (Fonts, BiDi, shaping)\n");
-
+ OS::get_singleton()->print(" --tablet-driver <driver> Pen tablet input driver.\n");
OS::get_singleton()->print(" --headless Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script.\n");
OS::get_singleton()->print("\n");
@@ -334,15 +333,15 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --resolution <W>x<H> Request window resolution.\n");
OS::get_singleton()->print(" --position <X>,<Y> Request window position.\n");
OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n");
- OS::get_singleton()->print(" --tablet-driver Pen tablet input driver.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Debug options:\n");
OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n");
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
- OS::get_singleton()->print(" --vk-layers Enable Vulkan Validation layers for debugging.\n");
-#ifdef DEBUG_ENABLED
+ OS::get_singleton()->print(" --gpu-profile Show a GPU profile of the tasks that took the most time during frame rendering.\n");
+ OS::get_singleton()->print(" --vk-layers Enable Vulkan validation layers for debugging.\n");
+#if DEBUG_ENABLED
OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
#endif
OS::get_singleton()->print(" --remote-debug <uri> Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).\n");
@@ -356,7 +355,6 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --disable-crash-handler Disable crash handler when supported by the platform code.\n");
OS::get_singleton()->print(" --fixed-fps <fps> Force a fixed number of frames per second. This setting disables real-time synchronization.\n");
OS::get_singleton()->print(" --print-fps Print the frames per second to the stdout.\n");
- OS::get_singleton()->print(" --profile-gpu Show a simple profile of the tasks that took more time during frame rendering.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Standalone tools:\n");
@@ -644,7 +642,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
OS::get_singleton()->_verbose_stdout = true;
- } else if (I->get() == "--quiet") { // quieter output
+ } else if (I->get() == "-q" || I->get() == "--quiet") { // quieter output
quiet_stdout = true;
@@ -787,7 +785,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
Engine::singleton->gpu_idx = I->next()->get().to_int();
N = I->next()->next();
} else {
- OS::get_singleton()->print("Missing gpu index argument, aborting.\n");
+ OS::get_singleton()->print("Missing GPU index argument, aborting.\n");
goto error;
}
} else if (I->get() == "--vk-layers") {
@@ -978,7 +976,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (I->get() == "-u" || I->get() == "--upwards") { // scan folders upwards
upwards = true;
- } else if (I->get() == "-q" || I->get() == "--quit") { // Auto quit at the end of the first main loop iteration
+ } else if (I->get() == "--quit") { // Auto quit at the end of the first main loop iteration
auto_quit = true;
} else if (I->get().ends_with("project.godot")) {
String path;
diff --git a/misc/dist/shell/_godot.zsh-completion b/misc/dist/shell/_godot.zsh-completion
index 8548b18cb0..98ab41ac58 100644
--- a/misc/dist/shell/_godot.zsh-completion
+++ b/misc/dist/shell/_godot.zsh-completion
@@ -30,10 +30,11 @@ _arguments \
'(-h --help)'{-h,--help}'[display the full help message]' \
'--version[display the version string]' \
'(-v --verbose)'{-v,--verbose}'[use verbose stdout mode]' \
- '--quiet[quiet mode, silences stdout messages (errors are still displayed)]' \
+ '(-q --quiet)'{-q,--quiet}'[quiet mode, silences stdout messages (errors are still displayed)]' \
'(-e --editor)'{-e,--editor}'[start the editor instead of running the scene]' \
'(-p --project-manager)'{-p,--project-manager}'[start the project manager, even if a project is auto-detected]' \
- '(-q --quit)'{-q,--quit}'[quit after the first iteration]' \
+ '--debug-server[start the editor debug server]:editor debugger listen address' \
+ '--quit[quit after the first iteration]' \
'(-l --language)'{-l,--language}'[use a specific locale (<locale> being a two-letter code)]:two-letter locale code' \
"--path[path to a project (<directory> must contain a 'project.godot' file)]:path to directory with 'project.godot' file:_dirs" \
'(-u --upwards)'{-u,--upwards}'[scan folders upwards for project.godot file]' \
@@ -42,7 +43,12 @@ _arguments \
'--remote-fs[use a remote filesystem]:remote filesystem address' \
'--remote-fs-password[password for remote filesystem]:remote filesystem password' \
'--audio-driver[set the audio driver]:audio driver name' \
- "--video-driver[set the video driver]:video driver name:((Vulkan\:'Vulkan renderer' GLES2\:'OpenGL ES 2.0 renderer'))" \
+ '--display-driver[set the display driver]:display driver name' \
+ "--rendering-driver[set the rendering driver]:rendering driver name:((vulkan\:'Vulkan renderer' opengl3\:'OpenGL ES 3.0 renderer' dummy\:'Dummy renderer'))" \
+ "--gpu-index[use a specific GPU (run with --verbose to get available device list)]:device index" \
+ '--text-driver[set the text driver]:text driver name' \
+ '--tablet-driver[set the pen tablet input driver]:tablet driver name' \
+ '--headless[enable headless mode (--display-driver headless --audio-driver Dummy), useful for servers and with --script]' \
'(-f --fullscreen)'{-f,--fullscreen}'[request fullscreen mode]' \
'(-m --maximized)'{-m,--maximized}'[request a maximized window]' \
'(-w --windowed)'{-w,--windowed}'[request windowed mode]' \
@@ -50,9 +56,13 @@ _arguments \
'--resolution[request window resolution]:resolution in WxH format' \
'--position[request window position]:position in X,Y format' \
'--headless[enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script]' \
+ '--single-window[use a single window (no separate subwindows)]' \
'(-d --debug)'{-d,--debug}'[debug (local stdout debugger)]' \
'(-b --breakpoints)'{-b,--breakpoints}'[specify the breakpoint list as source::line comma-separated pairs, no spaces (use %20 instead)]:breakpoint list' \
'--profiling[enable profiling in the script debugger]' \
+ '--gpu-profile[show a GPU profile of the tasks that took the most time during frame rendering]' \
+ '--vk-layers[enable Vulkan validation layers for debugging]' \
+ '--gpu-abort[abort on GPU errors (usually validation layer errors)]' \
'--remote-debug[enable remote debugging]:remote debugger address' \
'--debug-collisions[show collision shapes when running the scene]' \
'--debug-navigation[show navigation polygons when running the scene]' \
@@ -64,10 +74,11 @@ _arguments \
'--print-fps[print the frames per second to the stdout]' \
'(-s, --script)'{-s,--script}'[run a script]:path to script:_files' \
'--check-only[only parse for errors and quit (use with --script)]' \
- '--export[export the project using the given preset and matching release template]:export preset name' \
- '--export-debug[same as --export, but using the debug template]:export preset name' \
- '--export-pack[same as --export, but only export the game pack for the given preset]:export preset name' \
- '--doctool[dump the engine API reference to the given path in XML format, merging if existing files are found]:path to base Godot build directory:_dirs' \
+ '--export[export the project using the given preset and matching release template]:export preset name then path' \
+ '--export-debug[same as --export, but using the debug template]:export preset name then path' \
+ '--export-pack[same as --export, but only export the game pack for the given preset]:export preset name then path' \
+ '--doctool[dump the engine API reference to the given path in XML format, merging if existing files are found]:path to base Godot build directory (optional):_dirs' \
'--no-docbase[disallow dumping the base types (used with --doctool)]' \
'--build-solutions[build the scripting solutions (e.g. for C# projects)]' \
- '--test[run a unit test]:unit test name'
+ '--dump-extension-api[generate JSON dump of the Godot API for GDExtension bindings named "extension_api.json" in the current folder]' \
+ '--test[run all unit tests; run with "--test --help" for more information]'
diff --git a/misc/dist/shell/godot.bash-completion b/misc/dist/shell/godot.bash-completion
index 56bf23a268..5784e15c6e 100644
--- a/misc/dist/shell/godot.bash-completion
+++ b/misc/dist/shell/godot.bash-completion
@@ -36,6 +36,7 @@ _complete_godot_options() {
--quiet
--editor
--project-manager
+--debug-server
--quit
--language
--path
@@ -45,7 +46,12 @@ _complete_godot_options() {
--remote-fs
--remote-fs-password
--audio-driver
---video-driver
+--display-driver
+--rendering-driver
+--gpu-index
+--text-driver
+--tablet-driver
+--headless
--fullscreen
--maximized
--windowed
@@ -53,9 +59,13 @@ _complete_godot_options() {
--resolution
--position
--headless
+--single-window
--debug
--breakpoints
--profiling
+--gpu-profile
+--vk-layers
+--gpu-abort
--remote-debug
--debug-collisions
--debug-navigation
@@ -73,6 +83,7 @@ _complete_godot_options() {
--doctool
--no-docbase
--build-solutions
+--dump-extension-api
--test
" -- "$1"))
}
@@ -98,10 +109,10 @@ _complete_godot_bash() {
local IFS=$' \n\t'
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "unsafe safe separate" -- "$cur"))
- elif [[ $prev == "--video-driver" ]]; then
+ elif [[ $prev == "--rendering-driver" ]]; then
local IFS=$' \n\t'
# shellcheck disable=SC2207
- COMPREPLY=($(compgen -W "Vulkan GLES2" -- "$cur"))
+ COMPREPLY=($(compgen -W "vulkan opengl3 dummy" -- "$cur"))
elif [[ $prev == "--path" || $prev == "--doctool" ]]; then
local IFS=$'\n\t'
# shellcheck disable=SC2207
diff --git a/misc/dist/shell/godot.fish b/misc/dist/shell/godot.fish
index 6aa3f38f1f..880851dd23 100644
--- a/misc/dist/shell/godot.fish
+++ b/misc/dist/shell/godot.fish
@@ -23,10 +23,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-function godot_video_driver_args
+function godot_rendering_driver_args
# Use a function instead of a fixed string to customize the argument descriptions.
- echo -e "Vulkan\tVulkan renderer"
- echo -e "GLES2\tOpenGL ES 2.0 renderer"
+ echo -e "vulkan\tVulkan renderer"
+ echo -e "opengl3\tOpenGL ES 3.0 renderer"
+ echo -e "dummy\tDummy renderer"
end
# Erase existing completions for Godot.
@@ -36,12 +37,13 @@ complete -c godot -e
complete -c godot -s h -l help -d "Display the full help message"
complete -c godot -l version -d "Display the version string"
complete -c godot -s v -l verbose -d "Use verbose stdout mode"
-complete -c godot -l quiet -d "Quiet mode, silences stdout messages (errors are still displayed)"
+complete -c godot -s q -l quiet -d "Quiet mode, silences stdout messages (errors are still displayed)"
# Run options:
complete -c godot -s e -l editor -d "Start the editor instead of running the scene"
complete -c godot -s p -l project-manager -d "Start the project manager, even if a project is auto-detected"
-complete -c godot -s q -l quit -d "Quit after the first iteration"
+complete -c godot -l debug-server -d "Start the editor debug server (<protocol>://<host/IP>[:<port>] address)" -x
+complete -c godot -l quit -d "Quit after the first iteration"
complete -c godot -s l -l language -d "Use a specific locale (<locale> being a two-letter code)" -x
complete -c godot -l path -d "Path to a project (<directory> must contain a 'project.godot' file)" -r
complete -c godot -s u -l upwards -d "Scan folders upwards for project.godot file"
@@ -50,7 +52,12 @@ complete -c godot -l render-thread -d "Set the render thread mode" -x -a "unsafe
complete -c godot -l remote-fs -d "Use a remote filesystem (<host/IP>[:<port>] address)" -x
complete -c godot -l remote-fs-password -d "Password for remote filesystem" -x
complete -c godot -l audio-driver -d "Set the audio driver" -x
-complete -c godot -l video-driver -d "Set the video driver" -x -a "(godot_video_driver_args)"
+complete -c godot -l display-driver -d "Set the display driver" -x
+complete -c godot -l rendering-driver -d "Set the rendering driver" -x -a "(godot_rendering_driver_args)"
+complete -c godot -l gpu-index -d "Use a specific GPU (run with --verbose to get available device list)" -x
+complete -c godot -l text-driver -d "Set the text driver" -x
+complete -c godot -l tablet-driver -d "Set the pen tablet input driver" -x
+complete -c godot -l headless -d "Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script"
# Display options:
complete -c godot -s f -l fullscreen -d "Request fullscreen mode"
@@ -60,11 +67,15 @@ complete -c godot -s t -l always-on-top -d "Request an always-on-top window"
complete -c godot -l resolution -d "Request window resolution" -x
complete -c godot -l position -d "Request window position" -x
complete -c godot -l headless -d "Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script"
+complete -c godot -l single-window -d "Use a single window (no separate subwindows)"
# Debug options:
complete -c godot -s d -l debug -d "Debug (local stdout debugger)"
complete -c godot -s b -l breakpoints -d "Specify the breakpoint list as source::line comma-separated pairs, no spaces (use %20 instead)" -x
complete -c godot -l profiling -d "Enable profiling in the script debugger"
+complete -c godot -l gpu-profile -d "Show a GPU profile of the tasks that took the most time during frame rendering"
+complete -c godot -l vk-layers -d "Enable Vulkan validation layers for debugging"
+complete -c godot -l gpu-abort -d "Abort on GPU errors (usually validation layer errors)"
complete -c godot -l remote-debug -d "Enable remote debugging"
complete -c godot -l debug-collisions -d "Show collision shapes when running the scene"
complete -c godot -l debug-navigation -d "Show navigation polygons when running the scene"
@@ -84,4 +95,5 @@ complete -c godot -l export-pack -d "Same as --export, but only export the game
complete -c godot -l doctool -d "Dump the engine API reference to the given path in XML format, merging if existing files are found" -r
complete -c godot -l no-docbase -d "Disallow dumping the base types (used with --doctool)"
complete -c godot -l build-solutions -d "Build the scripting solutions (e.g. for C# projects)"
-complete -c godot -l test -d "Run a unit test" -x
+complete -c godot -l dump-extension-api -d "Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder"
+complete -c godot -l test -d "Run all unit tests; run with '--test --help' for more information" -x
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 390e6685b1..efde8d8a2b 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -79,6 +79,7 @@ void Camera2D::set_zoom(const Vector2 &p_zoom) {
ERR_FAIL_COND_MSG(Math::is_zero_approx(p_zoom.x) || Math::is_zero_approx(p_zoom.y), "Zoom level must be different from 0 (can be negative).");
zoom = p_zoom;
+ zoom_scale = Vector2(1, 1) / zoom;
Point2 old_smoothed_camera_pos = smoothed_camera_pos;
_update_scroll();
smoothed_camera_pos = old_smoothed_camera_pos;
@@ -103,8 +104,8 @@ Transform2D Camera2D::get_camera_transform() {
if (!first) {
if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
if (drag_horizontal_enabled && !Engine::get_singleton()->is_editor_hint() && !drag_horizontal_offset_changed) {
- camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * zoom.x * drag_margin[SIDE_LEFT]));
- camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * zoom.x * drag_margin[SIDE_RIGHT]));
+ camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * zoom_scale.x * drag_margin[SIDE_LEFT]));
+ camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * zoom_scale.x * drag_margin[SIDE_RIGHT]));
} else {
if (drag_horizontal_offset < 0) {
camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[SIDE_RIGHT] * drag_horizontal_offset;
@@ -116,8 +117,8 @@ Transform2D Camera2D::get_camera_transform() {
}
if (drag_vertical_enabled && !Engine::get_singleton()->is_editor_hint() && !drag_vertical_offset_changed) {
- camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * zoom.y * drag_margin[SIDE_TOP]));
- camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * zoom.y * drag_margin[SIDE_BOTTOM]));
+ camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * zoom_scale.y * drag_margin[SIDE_TOP]));
+ camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * zoom_scale.y * drag_margin[SIDE_BOTTOM]));
} else {
if (drag_vertical_offset < 0) {
@@ -133,8 +134,8 @@ Transform2D Camera2D::get_camera_transform() {
camera_pos = new_camera_pos;
}
- Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2());
- Rect2 screen_rect(-screen_offset + camera_pos, screen_size * zoom);
+ Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom_scale) : Point2());
+ Rect2 screen_rect(-screen_offset + camera_pos, screen_size * zoom_scale);
if (limit_smoothing_enabled) {
if (screen_rect.position.x < limit[SIDE_LEFT]) {
@@ -168,14 +169,14 @@ Transform2D Camera2D::get_camera_transform() {
first = false;
}
- Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2());
+ Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom_scale) : Point2());
real_t angle = get_global_rotation();
if (rotating) {
screen_offset = screen_offset.rotated(angle);
}
- Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
+ Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom_scale);
if (!smoothing_enabled || !limit_smoothing_enabled) {
if (screen_rect.position.x < limit[SIDE_LEFT]) {
@@ -202,7 +203,7 @@ Transform2D Camera2D::get_camera_transform() {
camera_screen_center = screen_rect.get_center();
Transform2D xform;
- xform.scale_basis(zoom);
+ xform.scale_basis(zoom_scale);
if (rotating) {
xform.set_rotation(angle);
}
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 662bee3612..294a6fcb80 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -61,6 +61,7 @@ protected:
RID canvas;
Vector2 offset;
Vector2 zoom = Vector2(1, 1);
+ Vector2 zoom_scale = Vector2(1, 1);
AnchorMode anchor_mode = ANCHOR_MODE_DRAG_CENTER;
bool rotating = false;
bool current = false;
diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp
index 2716bb2e25..8cbcc9acf6 100644
--- a/scene/2d/line_2d.cpp
+++ b/scene/2d/line_2d.cpp
@@ -265,15 +265,15 @@ bool Line2D::get_antialiased() const {
}
void Line2D::_draw() {
- if (_points.size() <= 1 || _width == 0.f) {
+ int len = _points.size();
+ if (len <= 1 || _width == 0.f) {
return;
}
// TODO Is this really needed?
// Copy points for faster access
Vector<Vector2> points;
- points.resize(_points.size());
- int len = points.size();
+ points.resize(len);
{
const Vector2 *points_read = _points.ptr();
for (int i = 0; i < len; ++i) {
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 9d26543243..dd88bda304 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -244,10 +244,9 @@ Point2 Node2D::get_global_position() const {
}
void Node2D::set_global_position(const Point2 &p_pos) {
- Transform2D inv;
CanvasItem *pi = get_parent_item();
if (pi) {
- inv = pi->get_global_transform().affine_inverse();
+ Transform2D inv = pi->get_global_transform().affine_inverse();
set_position(inv.xform(p_pos));
} else {
set_position(p_pos);
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 1fe4adb4db..f9986c2f30 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -295,14 +295,14 @@ void Polygon2D::_notification(int p_what) {
}
Vector<Color> colors;
+ colors.resize(len);
+
if (vertex_colors.size() == points.size()) {
- colors.resize(len);
const Color *color_r = vertex_colors.ptr();
for (int i = 0; i < len; i++) {
colors.write[i] = color_r[i];
}
} else {
- colors.resize(len);
for (int i = 0; i < len; i++) {
colors.write[i] = color;
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index e580e64db6..712ad4f1ea 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2033,6 +2033,17 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
+void Viewport::_gui_cleanup_internal_state(Ref<InputEvent> p_event) {
+ ERR_FAIL_COND(p_event.is_null());
+
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
+ if (!mb->is_pressed()) {
+ gui.mouse_focus_mask &= ~mouse_button_to_mask(mb->get_button_index()); // Remove from mask.
+ }
+ }
+}
+
List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) {
gui.roots_order_dirty = true;
return gui.roots.push_back(p_control);
@@ -2695,6 +2706,9 @@ void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
if (!is_input_handled()) {
_gui_input_event(ev);
+ } else {
+ // Cleanup internal GUI state after accepting event during _input().
+ _gui_cleanup_internal_state(ev);
}
event_count++;
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 1976b20502..e4912f31c5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -388,6 +388,7 @@ private:
Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform);
void _gui_input_event(Ref<InputEvent> p_event);
+ void _gui_cleanup_internal_state(Ref<InputEvent> p_event);
_FORCE_INLINE_ Transform2D _get_input_pre_xform() const;
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
index 1c9b08b6d3..bd1c2b5758 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
@@ -1,9 +1,9 @@
// Functions related to lighting
float D_GGX(float cos_theta_m, float alpha) {
- float alpha2 = alpha * alpha;
- float d = 1.0 + (alpha2 - 1.0) * cos_theta_m * cos_theta_m;
- return alpha2 / (M_PI * d * d);
+ float a = cos_theta_m * alpha;
+ float k = alpha / (1.0 - cos_theta_m * cos_theta_m + a * a);
+ return k * k * (1.0 / M_PI);
}
// From Earl Hammon, Jr. "PBR Diffuse Lighting for GGX+Smith Microsurfaces" https://www.gdcvault.com/play/1024478/PBR-Diffuse-Lighting-for-GGX