diff options
-rw-r--r-- | doc/classes/CanvasItem.xml | 2 | ||||
-rw-r--r-- | doc/classes/NavigationServer2D.xml | 4 | ||||
-rw-r--r-- | doc/classes/NavigationServer3D.xml | 4 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 4 | ||||
-rw-r--r-- | main/main.cpp | 10 | ||||
-rw-r--r-- | platform/android/java/app/config.gradle | 2 | ||||
-rw-r--r-- | platform/android/java/editor/build.gradle | 2 | ||||
-rw-r--r-- | platform/android/java/editor/src/main/AndroidManifest.xml | 7 | ||||
-rw-r--r-- | platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.java | 29 | ||||
-rw-r--r-- | platform/android/java/editor/src/main/res/values/dimens.xml | 5 | ||||
-rw-r--r-- | platform/android/java/lib/src/org/godotengine/godot/GodotIO.java | 24 | ||||
-rw-r--r-- | servers/register_server_types.cpp | 4 | ||||
-rw-r--r-- | servers/register_server_types.h | 1 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/renderer_storage_rd.cpp | 4 | ||||
-rw-r--r-- | servers/rendering/rendering_server_default.cpp | 8 | ||||
-rw-r--r-- | servers/rendering_server.cpp | 2 | ||||
-rw-r--r-- | servers/rendering_server.h | 2 |
17 files changed, 93 insertions, 21 deletions
diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index 6cd2da520f..98a498d719 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -67,7 +67,7 @@ <argument index="1" name="radius" type="float" /> <argument index="2" name="color" type="Color" /> <description> - Draws a colored, unfilled circle. See also [method draw_arc], [method draw_polyline] and [method draw_polygon]. + Draws a colored, filled circle. See also [method draw_arc], [method draw_polyline] and [method draw_polygon]. </description> </method> <method name="draw_colored_polygon"> diff --git a/doc/classes/NavigationServer2D.xml b/doc/classes/NavigationServer2D.xml index 928834101f..1994a7a4c4 100644 --- a/doc/classes/NavigationServer2D.xml +++ b/doc/classes/NavigationServer2D.xml @@ -5,7 +5,9 @@ </brief_description> <description> NavigationServer2D is the server responsible for all 2D navigation. It handles several objects, namely maps, regions and agents. - Maps are made up of regions, which are made of navigation polygons. Together, they define the navigable areas in the 2D world. For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than [code]edge_connection_margin[/code] to the respective other edge's vertex. + Maps are made up of regions, which are made of navigation polygons. Together, they define the navigable areas in the 2D world. + [b]Note:[/b] Most NavigationServer changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation related Nodes in the SceneTree or made through scripts. + For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than [code]edge_connection_margin[/code] to the respective other edge's vertex. You may assign navigation layers to regions with [method NavigationServer2D.region_set_layers], which then can be checked upon when requesting a path with [method NavigationServer2D.map_get_path]. This allows allowing or forbidding some areas to 2D objects. To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity. [b]Note:[/b] The collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine. diff --git a/doc/classes/NavigationServer3D.xml b/doc/classes/NavigationServer3D.xml index 8c83fe5485..2a729e7108 100644 --- a/doc/classes/NavigationServer3D.xml +++ b/doc/classes/NavigationServer3D.xml @@ -5,7 +5,9 @@ </brief_description> <description> NavigationServer3D is the server responsible for all 3D navigation. It handles several objects, namely maps, regions and agents. - Maps are made up of regions, which are made of navigation meshes. Together, they define the navigable areas in the 3D world. For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than [code]edge_connection_margin[/code] to the respective other edge's vertex. + Maps are made up of regions, which are made of navigation meshes. Together, they define the navigable areas in the 3D world. + [b]Note:[/b] Most NavigationServer changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation related Nodes in the SceneTree or made through scripts. + For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than [code]edge_connection_margin[/code] to the respective other edge's vertex. You may assign navigation layers to regions with [method NavigationServer3D.region_set_layers], which then can be checked upon when requesting a path with [method NavigationServer3D.map_get_path]. This allows allowing or forbidding some areas to 3D objects. To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity. [b]Note:[/b] The collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine. diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 49c5045453..012cda953c 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -442,6 +442,10 @@ bool RasterizerStorageGLES3::free(RID p_rid) { } bool RasterizerStorageGLES3::has_os_feature(const String &p_feature) const { + if (!config) { + return false; + } + if (p_feature == "rgtc") { return config->rgtc_supported; } diff --git a/main/main.cpp b/main/main.cpp index fff78d9e8f..20270190b3 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -411,8 +411,6 @@ Error Main::test_setup() { initialize_modules(MODULE_INITIALIZATION_LEVEL_CORE); register_core_extensions(); - preregister_server_types(); - register_core_singletons(); /** INITIALIZE SERVERS **/ @@ -1598,7 +1596,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) { tsman->add_interface(ts); } - preregister_server_types(); + register_server_types(); + initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS); + NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS); // Print engine name and version print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE)); @@ -1763,10 +1763,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) { DisplayServer::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid); } - register_server_types(); - initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS); - NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS); - MAIN_PRINT("Main: Load Boot Image"); Color clear = GLOBAL_DEF("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3)); diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle index d474ef8de2..73a412a2b0 100644 --- a/platform/android/java/app/config.gradle +++ b/platform/android/java/app/config.gradle @@ -1,6 +1,6 @@ ext.versions = [ androidGradlePlugin: '7.0.3', - compileSdk : 30, + compileSdk : 31, minSdk : 19, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION' targetSdk : 30, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION' buildTools : '30.0.3', diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle index 857c072e0c..dd167c3880 100644 --- a/platform/android/java/editor/build.gradle +++ b/platform/android/java/editor/build.gradle @@ -8,6 +8,8 @@ dependencies { implementation libraries.kotlinStdLib implementation libraries.androidxFragment implementation project(":lib") + + implementation "androidx.window:window:1.0.0" } android { diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml index bae075d929..659caf7ab4 100644 --- a/platform/android/java/editor/src/main/AndroidManifest.xml +++ b/platform/android/java/editor/src/main/AndroidManifest.xml @@ -34,6 +34,9 @@ android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:process=":GodotProjectManager"> + <layout android:defaultHeight="@dimen/editor_default_window_height" + android:defaultWidth="@dimen/editor_default_window_width" /> + <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> @@ -47,6 +50,8 @@ android:launchMode="singleTask" android:screenOrientation="userLandscape" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> + <layout android:defaultHeight="@dimen/editor_default_window_height" + android:defaultWidth="@dimen/editor_default_window_width" /> </activity> <activity @@ -57,6 +62,8 @@ android:launchMode="singleTask" android:screenOrientation="userLandscape" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> + <layout android:defaultHeight="@dimen/editor_default_window_height" + android:defaultWidth="@dimen/editor_default_window_width" /> </activity> </application> 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.java index 8a6bf88267..c05ed965ca 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.java @@ -34,10 +34,13 @@ 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; @@ -91,23 +94,47 @@ public class GodotEditor extends FullScreenGodotApp { public void onNewGodotInstanceRequested(String[] args) { // Parse the arguments to figure out which activity to start. Class<?> targetClass = GodotGame.class; + // 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; } if (PROJECT_MANAGER_ARG.equals(arg)) { targetClass = GodotProjectManager.class; + launchAdjacent = false; break; } } // Launch a new activity - Intent newInstance = new Intent(this, targetClass).putExtra(COMMAND_LINE_PARAMS, args); + Intent newInstance = new Intent(this, targetClass) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .putExtra(COMMAND_LINE_PARAMS, args); + if (launchAdjacent) { + newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT); + } startActivity(newInstance); } + protected boolean isLargeScreen() { + WindowMetrics metrics = + WindowMetricsCalculator.getOrCreate().computeMaximumWindowMetrics(this); + + // Get the screen's density scale + float scale = getResources().getDisplayMetrics().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. + } + @Override public void setRequestedOrientation(int requestedOrientation) { if (!overrideOrientationRequest()) { diff --git a/platform/android/java/editor/src/main/res/values/dimens.xml b/platform/android/java/editor/src/main/res/values/dimens.xml new file mode 100644 index 0000000000..03fb6184d2 --- /dev/null +++ b/platform/android/java/editor/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <dimen name="editor_default_window_height">600dp</dimen> + <dimen name="editor_default_window_width">800dp</dimen> +</resources> diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java index b69d25dd8b..a8e3669ac6 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java @@ -224,12 +224,30 @@ public class GodotIO { } public int getScreenDPI() { - DisplayMetrics metrics = activity.getResources().getDisplayMetrics(); - return (int)(metrics.density * 160f); + return activity.getResources().getDisplayMetrics().densityDpi; } + /** + * Returns bucketized density values. + */ public float getScaledDensity() { - return activity.getResources().getDisplayMetrics().scaledDensity; + int densityDpi = activity.getResources().getDisplayMetrics().densityDpi; + float selectedScaledDensity; + if (densityDpi >= DisplayMetrics.DENSITY_XXXHIGH) { + selectedScaledDensity = 4.0f; + } else if (densityDpi >= DisplayMetrics.DENSITY_XXHIGH) { + selectedScaledDensity = 3.0f; + } else if (densityDpi >= DisplayMetrics.DENSITY_XHIGH) { + selectedScaledDensity = 2.0f; + } else if (densityDpi >= DisplayMetrics.DENSITY_HIGH) { + selectedScaledDensity = 1.5f; + } else if (densityDpi >= DisplayMetrics.DENSITY_MEDIUM) { + selectedScaledDensity = 1.0f; + } else { + selectedScaledDensity = 0.75f; + } + Log.d(TAG, "Selected scaled density: " + selectedScaledDensity); + return selectedScaledDensity; } public double getScreenRefreshRate(double fallback) { diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 275a42a4e3..8bbe987cb7 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -107,7 +107,7 @@ static bool has_server_feature_callback(const String &p_feature) { return false; } -void preregister_server_types() { +void register_server_types() { shader_types = memnew(ShaderTypes); GDREGISTER_CLASS(TextServerManager); @@ -119,9 +119,7 @@ void preregister_server_types() { GDREGISTER_NATIVE_STRUCT(CaretInfo, "Rect2 leading_caret;Rect2 trailing_caret;TextServer::Direction leading_direction;TextServer::Direction trailing_direction"); Engine::get_singleton()->add_singleton(Engine::Singleton("TextServerManager", TextServerManager::get_singleton(), "TextServerManager")); -} -void register_server_types() { OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback); GDREGISTER_ABSTRACT_CLASS(DisplayServer); diff --git a/servers/register_server_types.h b/servers/register_server_types.h index cf6364eee3..32fd944bea 100644 --- a/servers/register_server_types.h +++ b/servers/register_server_types.h @@ -31,7 +31,6 @@ #ifndef REGISTER_SERVER_TYPES_H #define REGISTER_SERVER_TYPES_H -void preregister_server_types(); void register_server_types(); void unregister_server_types(); diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index 1b9e0faa00..d5166c6905 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -592,6 +592,10 @@ void RendererStorageRD::update_dirty_resources() { } bool RendererStorageRD::has_os_feature(const String &p_feature) const { + if (!RD::get_singleton()) { + return false; + } + if (p_feature == "rgtc" && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC5_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT)) { return true; } diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index c4538e0776..718f20f80a 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -313,7 +313,11 @@ RID RenderingServerDefault::get_test_cube() { } bool RenderingServerDefault::has_os_feature(const String &p_feature) const { - return RSG::storage->has_os_feature(p_feature); + if (RSG::storage) { + return RSG::storage->has_os_feature(p_feature); + } else { + return false; + } } void RenderingServerDefault::set_debug_generate_wireframes(bool p_generate) { @@ -384,6 +388,8 @@ void RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) { RenderingServerDefault::RenderingServerDefault(bool p_create_thread) : command_queue(p_create_thread) { + RenderingServer::init(); + create_thread = p_create_thread; if (!p_create_thread) { diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 8f285aeaad..366c011f86 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2821,7 +2821,9 @@ RenderingServer::RenderingServer() { thread_pool = memnew(RendererThreadPool); singleton = this; +} +void RenderingServer::init() { GLOBAL_DEF_RST("rendering/textures/vram_compression/import_bptc", false); GLOBAL_DEF_RST("rendering/textures/vram_compression/import_s3tc", true); GLOBAL_DEF_RST("rendering/textures/vram_compression/import_etc", false); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index 1ac48053d8..c6c4b9d275 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -1471,7 +1471,7 @@ public: virtual void draw(bool p_swap_buffers = true, double frame_step = 0.0) = 0; virtual void sync() = 0; virtual bool has_changed() const = 0; - virtual void init() = 0; + virtual void init(); virtual void finish() = 0; /* STATUS INFORMATION */ |