diff options
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/editor/editor_internal_calls.cpp | 1 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs | 18 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs | 18 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs | 18 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 14 |
5 files changed, 33 insertions, 36 deletions
diff --git a/modules/mono/editor/editor_internal_calls.cpp b/modules/mono/editor/editor_internal_calls.cpp index 3c02ea0e8e..f7f710f3f1 100644 --- a/modules/mono/editor/editor_internal_calls.cpp +++ b/modules/mono/editor/editor_internal_calls.cpp @@ -34,6 +34,7 @@ #include <unistd.h> // access #endif +#include "core/config/project_settings.h" #include "core/os/os.h" #include "core/version.h" #include "editor/debugger/editor_debugger_node.h" diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index bfe9600084..ce213da6a7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -180,6 +180,24 @@ namespace Godot } /// <summary> + /// Cubic interpolates between two values by a normalized value with pre and post values. + /// </summary> + /// <param name="from">The start value for interpolation.</param> + /// <param name="to">The destination value for interpolation.</param> + /// <param name="pre">The value which before "from" value for interpolation.</param> + /// <param name="post">The value which after "to" value for interpolation.</param> + /// <param name="weight">A value on the range of 0.0 to 1.0, representing the amount of interpolation.</param> + /// <returns>The resulting value of the interpolation.</returns> + public static real_t CubicInterpolate(real_t from, real_t to, real_t pre, real_t post, real_t weight) + { + return 0.5f * + ((from * 2.0f) + + (-pre + to) * weight + + (2.0f * pre - 5.0f * from + 4.0f * to - post) * (weight * weight) + + (-pre + 3.0f * from - 3.0f * to + post) * (weight * weight * weight)); + } + + /// <summary> /// Converts an angle expressed in degrees to radians. /// </summary> /// <param name="deg">An angle expressed in degrees.</param> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs index fa7838633c..8679f28132 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs @@ -204,20 +204,10 @@ namespace Godot /// <returns>The interpolated vector.</returns> public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, real_t weight) { - Vector2 p0 = preA; - Vector2 p1 = this; - Vector2 p2 = b; - Vector2 p3 = postB; - - real_t t = weight; - real_t t2 = t * t; - real_t t3 = t2 * t; - - return 0.5f * ( - (p1 * 2.0f) + - ((-p0 + p2) * t) + - (((2.0f * p0) - (5.0f * p1) + (4 * p2) - p3) * t2) + - ((-p0 + (3.0f * p1) - (3.0f * p2) + p3) * t3) + return new Vector2 + ( + Mathf.CubicInterpolate(x, b.x, preA.x, postB.x, weight), + Mathf.CubicInterpolate(y, b.y, preA.y, postB.y, weight) ); } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs index 0faf13f8b7..1e60fb9523 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs @@ -195,19 +195,11 @@ namespace Godot /// <returns>The interpolated vector.</returns> public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, real_t weight) { - Vector3 p0 = preA; - Vector3 p1 = this; - Vector3 p2 = b; - Vector3 p3 = postB; - - real_t t = weight; - real_t t2 = t * t; - real_t t3 = t2 * t; - - return 0.5f * ( - (p1 * 2.0f) + ((-p0 + p2) * t) + - (((2.0f * p0) - (5.0f * p1) + (4f * p2) - p3) * t2) + - ((-p0 + (3.0f * p1) - (3.0f * p2) + p3) * t3) + return new Vector3 + ( + Mathf.CubicInterpolate(x, b.x, preA.x, postB.x, weight), + Mathf.CubicInterpolate(y, b.y, preA.y, postB.y, weight), + Mathf.CubicInterpolate(z, b.z, preA.z, postB.z, weight) ); } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 6f542a67e7..a7269d7f87 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -52,10 +52,6 @@ #include "gd_mono_marshal.h" #include "gd_mono_utils.h" -#ifdef TOOLS_ENABLED -#include "main/main.h" -#endif - #ifdef ANDROID_ENABLED #include "android_mono_config.h" #include "support/android_support.h" @@ -143,7 +139,7 @@ void gd_mono_debug_init() { if (Engine::get_singleton()->is_editor_hint() || ProjectSettings::get_singleton()->get_resource_path().is_empty() || - Main::is_project_manager()) { + Engine::get_singleton()->is_project_manager_hint()) { if (da_args.size() == 0) { return; } @@ -423,7 +419,7 @@ void GDMono::initialize_load_assemblies() { bool tool_assemblies_loaded = _load_tools_assemblies(); CRASH_COND_MSG(!tool_assemblies_loaded, "Mono: Failed to load '" TOOLS_ASM_NAME "' assemblies."); - if (Main::is_project_manager()) { + if (Engine::get_singleton()->is_project_manager_hint()) { return; } #endif @@ -815,7 +811,7 @@ bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, c // For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date // If running the project manager, load it from the prebuilt API directory - String assembly_dir = !Main::is_project_manager() + String assembly_dir = !Engine::get_singleton()->is_project_manager_hint() ? GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config); @@ -848,7 +844,7 @@ bool GDMono::_load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, // For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date // If running the project manager, load it from the prebuilt API directory - String assembly_dir = !Main::is_project_manager() + String assembly_dir = !Engine::get_singleton()->is_project_manager_hint() ? GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config); @@ -932,7 +928,7 @@ void GDMono::_load_api_assemblies() { // this time update them from the prebuilt assemblies directory before trying to load them again. // Shouldn't happen. The project manager loads the prebuilt API assemblies - CRASH_COND_MSG(Main::is_project_manager(), "Failed to load one of the prebuilt API assemblies."); + CRASH_COND_MSG(Engine::get_singleton()->is_project_manager_hint(), "Failed to load one of the prebuilt API assemblies."); // 1. Unload the scripts domain Error domain_unload_err = _unload_scripts_domain(); |