diff options
12 files changed, 105 insertions, 131 deletions
diff --git a/doc/classes/AudioEffectCapture.xml b/doc/classes/AudioEffectCapture.xml index 5ab4403be5..7a7f1f8e8a 100644 --- a/doc/classes/AudioEffectCapture.xml +++ b/doc/classes/AudioEffectCapture.xml @@ -5,7 +5,7 @@ </brief_description> <description> AudioEffectCapture is an AudioEffect which copies all audio frames from the attached audio effect bus into its internal ring buffer. - Application code should consume these audio frames from this ring buffer using [method get_buffer] and process it as needed, for example to capture data from a microphone, implement application defined effects, or to transmit audio over the network. + Application code should consume these audio frames from this ring buffer using [method get_buffer] and process it as needed, for example to capture data from a microphone, implement application defined effects, or to transmit audio over the network. When capturing audio data from a microphone, the format of the samples will be stereo 32-bit floating point PCM. </description> <tutorials> </tutorials> diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index fa106979be..3c3fe77e28 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1405,7 +1405,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_pressed_color", "LinkButton", accent_color); theme->set_color("font_disabled_color", "LinkButton", font_disabled_color); - // TooltipPanel + // TooltipPanel + TooltipLabel + // TooltipPanel is also used for custom tooltips, while TooltipLabel + // is only relevant for default tooltips. Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate(); style_tooltip->set_shadow_size(0); style_tooltip->set_default_margin(SIDE_LEFT, default_margin_size * EDSCALE * 0.5); diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt index c05ed965ca..a1ade722e8 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt @@ -1,5 +1,5 @@ /*************************************************************************/ -/* GodotEditor.java */ +/* GodotEditor.kt */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,23 +28,17 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -package org.godotengine.editor; +package org.godotengine.editor -import org.godotengine.godot.FullScreenGodotApp; -import org.godotengine.godot.utils.PermissionsUtil; - -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.os.Debug; - -import androidx.annotation.Nullable; -import androidx.window.layout.WindowMetrics; -import androidx.window.layout.WindowMetricsCalculator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import android.content.Intent +import android.os.Build +import android.os.Bundle +import android.os.Debug +import androidx.window.layout.WindowMetricsCalculator +import org.godotengine.godot.FullScreenGodotApp +import org.godotengine.godot.utils.PermissionsUtil +import java.util.* +import kotlin.math.min /** * Base class for the Godot Android Editor activities. @@ -55,97 +49,98 @@ import java.util.List; * * It also plays the role of the primary editor window. */ -public class GodotEditor extends FullScreenGodotApp { - private static final boolean WAIT_FOR_DEBUGGER = false; - private static final String COMMAND_LINE_PARAMS = "command_line_params"; +open class GodotEditor : FullScreenGodotApp() { - private static final String EDITOR_ARG = "--editor"; - private static final String PROJECT_MANAGER_ARG = "--project-manager"; + companion object { + private const val WAIT_FOR_DEBUGGER = false - private final List<String> commandLineParams = new ArrayList<>(); + private const val COMMAND_LINE_PARAMS = "command_line_params" - @Override - public void onCreate(Bundle savedInstanceState) { - PermissionsUtil.requestManifestPermissions(this); + private const val EDITOR_ARG = "--editor" + private const val PROJECT_MANAGER_ARG = "--project-manager" + } - String[] params = getIntent().getStringArrayExtra(COMMAND_LINE_PARAMS); - updateCommandLineParams(params); + private val commandLineParams = ArrayList<String>() - if (BuildConfig.BUILD_TYPE.equals("debug") && WAIT_FOR_DEBUGGER) { - Debug.waitForDebugger(); + override fun onCreate(savedInstanceState: Bundle?) { + PermissionsUtil.requestManifestPermissions(this) + + val params = intent.getStringArrayExtra(COMMAND_LINE_PARAMS) + updateCommandLineParams(params) + + if (BuildConfig.BUILD_TYPE == "debug" && WAIT_FOR_DEBUGGER) { + Debug.waitForDebugger() } - super.onCreate(savedInstanceState); + + super.onCreate(savedInstanceState) } - private void updateCommandLineParams(@Nullable String[] args) { + private fun updateCommandLineParams(args: Array<String>?) { // Update the list of command line params with the new args - commandLineParams.clear(); - if (args != null && args.length > 0) { - commandLineParams.addAll(Arrays.asList(args)); + commandLineParams.clear() + if (args != null && args.isNotEmpty()) { + commandLineParams.addAll(listOf(*args)) } } - @Override - public List<String> getCommandLine() { - return commandLineParams; - } + override fun getCommandLine() = commandLineParams - @Override - public void onNewGodotInstanceRequested(String[] args) { + override fun onNewGodotInstanceRequested(args: Array<String>) { // Parse the arguments to figure out which activity to start. - Class<?> targetClass = GodotGame.class; + var targetClass: Class<*> = GodotGame::class.java + // Whether we should launch the new godot instance in an adjacent window // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT - boolean launchAdjacent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode() || isLargeScreen()); - - for (String arg : args) { - if (EDITOR_ARG.equals(arg)) { - targetClass = GodotEditor.class; - launchAdjacent = false; - break; + var launchAdjacent = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode || isLargeScreen) + + for (arg in args) { + if (EDITOR_ARG == arg) { + targetClass = GodotEditor::class.java + launchAdjacent = false + break } - if (PROJECT_MANAGER_ARG.equals(arg)) { - targetClass = GodotProjectManager.class; - launchAdjacent = false; - break; + if (PROJECT_MANAGER_ARG == arg) { + targetClass = GodotProjectManager::class.java + launchAdjacent = false + break } } // Launch a new activity - Intent newInstance = new Intent(this, targetClass) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - .putExtra(COMMAND_LINE_PARAMS, args); + val newInstance = Intent(this, targetClass) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .putExtra(COMMAND_LINE_PARAMS, args) if (launchAdjacent) { - newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT); + newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT) } - startActivity(newInstance); + startActivity(newInstance) } - protected boolean isLargeScreen() { - WindowMetrics metrics = - WindowMetricsCalculator.getOrCreate().computeMaximumWindowMetrics(this); + // Get the screen's density scale + protected val isLargeScreen: Boolean + // Get the minimum window size // Correspond to the EXPANDED window size class. + get() { + val metrics = WindowMetricsCalculator.getOrCreate().computeMaximumWindowMetrics(this) - // Get the screen's density scale - float scale = getResources().getDisplayMetrics().density; + // Get the screen's density scale + val scale = resources.displayMetrics.density - // Get the minimum window size - float minSize = Math.min(metrics.getBounds().width(), metrics.getBounds().height()); - float minSizeDp = minSize / scale; - return minSizeDp >= 840f; // Correspond to the EXPANDED window size class. - } + // Get the minimum window size + val minSize = min(metrics.bounds.width(), metrics.bounds.height()).toFloat() + val minSizeDp = minSize / scale + return minSizeDp >= 840f // Correspond to the EXPANDED window size class. + } - @Override - public void setRequestedOrientation(int requestedOrientation) { + override fun setRequestedOrientation(requestedOrientation: Int) { if (!overrideOrientationRequest()) { - super.setRequestedOrientation(requestedOrientation); + super.setRequestedOrientation(requestedOrientation) } } /** * The Godot Android Editor sets its own orientation via its AndroidManifest */ - protected boolean overrideOrientationRequest() { - return true; - } + protected open fun overrideOrientationRequest() = true } diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.java b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt index 12766775a8..783095f93a 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.java +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt @@ -1,5 +1,5 @@ /*************************************************************************/ -/* GodotGame.java */ +/* GodotGame.kt */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -package org.godotengine.editor; +package org.godotengine.editor /** * Drives the 'run project' window of the Godot Editor. */ -public class GodotGame extends GodotEditor { - protected boolean overrideOrientationRequest() { - return false; - } +class GodotGame : GodotEditor() { + override fun overrideOrientationRequest() = false } diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotProjectManager.java b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotProjectManager.kt index d30f66bb8c..bcf4659603 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotProjectManager.java +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotProjectManager.kt @@ -1,5 +1,5 @@ /*************************************************************************/ -/* GodotProjectManager.java */ +/* GodotProjectManager.kt */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -package org.godotengine.editor; +package org.godotengine.editor /** * Launcher activity for the Godot Android Editor. * * It presents the user with the project manager interface. * Upon selection of a project, this activity (via its parent logic) starts the - * {@link GodotEditor} activity. + * [GodotEditor] activity. */ -public class GodotProjectManager extends GodotEditor { -} +class GodotProjectManager : GodotEditor() diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index fa600d24ef..540250c8e9 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -312,7 +312,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { selection.end = text.length(); selection.double_click = true; last_dblclk = 0; - caret_column = selection.begin; + set_caret_column(selection.begin); if (!pass && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CLIPBOARD_PRIMARY)) { DisplayServer::get_singleton()->clipboard_set_primary(text); } @@ -327,7 +327,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { selection.begin = words[i]; selection.end = words[i + 1]; selection.double_click = true; - caret_column = selection.end; + set_caret_column(selection.end); break; } } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 772bb2bbd1..0e00e51181 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -161,29 +161,6 @@ ViewportTexture::~ViewportTexture() { } } -///////////////////////////////////// - -// Aliases used to provide custom styles to tooltips in the default -// theme and editor theme. -// TooltipPanel is also used for custom tooltips, while TooltipLabel -// is only relevant for default tooltips. - -class TooltipPanel : public PopupPanel { - GDCLASS(TooltipPanel, PopupPanel); - -public: - TooltipPanel() {} -}; - -class TooltipLabel : public Label { - GDCLASS(TooltipLabel, Label); - -public: - TooltipLabel() {} -}; - -///////////////////////////////////// - void Viewport::_sub_window_update_order() { for (int i = 0; i < gui.sub_windows.size(); i++) { RS::get_singleton()->canvas_item_set_draw_index(gui.sub_windows[i].canvas_item, i); @@ -1221,7 +1198,8 @@ void Viewport::_gui_show_tooltip() { } // Popup window which houses the tooltip content. - TooltipPanel *panel = memnew(TooltipPanel); + PopupPanel *panel = memnew(PopupPanel); + panel->set_theme_type_variation(SNAME("TooltipPanel")); // Controls can implement `make_custom_tooltip` to provide their own tooltip. // This should be a Control node which will be added as child to a TooltipPanel. @@ -1229,7 +1207,8 @@ void Viewport::_gui_show_tooltip() { // If no custom tooltip is given, use a default implementation. if (!base_tooltip) { - gui.tooltip_label = memnew(TooltipLabel); + gui.tooltip_label = memnew(Label); + gui.tooltip_label->set_theme_type_variation(SNAME("TooltipLabel")); gui.tooltip_label->set_auto_translate(gui.tooltip_control->is_auto_translating()); gui.tooltip_label->set_text(tooltip_text); base_tooltip = gui.tooltip_label; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index afff05c688..f6ffc8db53 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1179,7 +1179,7 @@ void Environment::_bind_methods() { ADD_GROUP("Sky", "sky_"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sky_custom_fov", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), "set_sky_custom_fov", "get_sky_custom_fov"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "sky_rotation"), "set_sky_rotation", "get_sky_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "sky_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater,radians"), "set_sky_rotation", "get_sky_rotation"); // Ambient light diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 0429687342..cfb30ef2f3 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -621,7 +621,7 @@ void SceneShaderForwardClustered::init(RendererStorageRD *p_storage, const Strin //builtins - actions.renames["TIME"] = "scene_data.time"; + actions.renames["TIME"] = "scene_data_block.data.time"; actions.renames["PI"] = _MKSTR(Math_PI); actions.renames["TAU"] = _MKSTR(Math_TAU); actions.renames["E"] = _MKSTR(Math_E); diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index a3cabb0693..f66ad529de 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -529,7 +529,7 @@ void SceneShaderForwardMobile::init(RendererStorageRD *p_storage, const String p //builtins - actions.renames["TIME"] = "scene_data.time"; + actions.renames["TIME"] = "scene_data_block.data.time"; actions.renames["PI"] = _MKSTR(Math_PI); actions.renames["TAU"] = _MKSTR(Math_TAU); actions.renames["E"] = _MKSTR(Math_E); diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index 7adc5a23f2..3a237dbd8c 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -1531,7 +1531,7 @@ void RendererSceneSkyRD::draw(RendererSceneEnvironmentRD *p_env, bool p_can_cont projections = &camera; } - sky_transform = p_transform.basis * sky_transform; + sky_transform = sky_transform * p_transform.basis; if (shader_data->uses_quarter_res) { PipelineCacheRD *pipeline = &shader_data->pipelines[view_count > 1 ? SKY_VERSION_QUARTER_RES_MULTIVIEW : SKY_VERSION_QUARTER_RES]; diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl index 9f27cea843..92c4fc3d67 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl @@ -384,14 +384,13 @@ void main() { instance_index_interp = instance_index; - SceneData scene_data = scene_data_block.data; mat4 model_matrix = instances.data[instance_index].transform; #if defined(MOTION_VECTORS) vertex_shader(instance_index, is_multimesh, scene_data_block.prev_data, instances.data[instance_index].prev_transform, prev_screen_position); - vertex_shader(instance_index, is_multimesh, scene_data, model_matrix, screen_position); + vertex_shader(instance_index, is_multimesh, scene_data_block.data, model_matrix, screen_position); #else vec4 screen_position; - vertex_shader(instance_index, is_multimesh, scene_data, model_matrix, screen_position); + vertex_shader(instance_index, is_multimesh, scene_data_block.data, model_matrix, screen_position); #endif } @@ -630,15 +629,7 @@ uint cluster_get_range_clip_mask(uint i, uint z_min, uint z_max) { #endif //!MODE_RENDER DEPTH -void main() { -#ifdef MODE_DUAL_PARABOLOID - - if (dp_clip > 0.0) - discard; -#endif - - SceneData scene_data = scene_data_block.data; - SceneData prev_scene_data = scene_data_block.prev_data; +void fragment_shader(in SceneData scene_data) { uint instance_index = instance_index_interp; //lay out everything, whatever is unused is optimized away anyway @@ -2048,7 +2039,7 @@ void main() { #endif //MODE_RENDER_DEPTH #ifdef MOTION_VECTORS vec2 position_clip = (screen_position.xy / screen_position.w) - scene_data.taa_jitter; - vec2 prev_position_clip = (prev_screen_position.xy / prev_screen_position.w) - prev_scene_data.taa_jitter; + vec2 prev_position_clip = (prev_screen_position.xy / prev_screen_position.w) - scene_data_block.prev_data.taa_jitter; vec2 position_uv = position_clip * vec2(0.5, 0.5); vec2 prev_position_uv = prev_position_clip * vec2(0.5, 0.5); @@ -2056,3 +2047,13 @@ void main() { motion_vector = position_uv - prev_position_uv; #endif } + +void main() { +#ifdef MODE_DUAL_PARABOLOID + + if (dp_clip > 0.0) + discard; +#endif + + fragment_shader(scene_data_block.data); +} |