diff options
50 files changed, 663 insertions, 324 deletions
diff --git a/SConstruct b/SConstruct index fee9786234..c5071e9861 100644 --- a/SConstruct +++ b/SConstruct @@ -409,44 +409,7 @@ if selected_platform in platform_list: # Microsoft Visual Studio Project Generation if (env['vsproj']) == "yes": - - AddToVSProject(env.core_sources) - AddToVSProject(env.main_sources) - AddToVSProject(env.modules_sources) - AddToVSProject(env.scene_sources) - AddToVSProject(env.servers_sources) - AddToVSProject(env.editor_sources) - - # this env flag won't work, it needs to be set in env_base=Environment(MSVC_VERSION='9.0') - # Even then, SCons still seems to ignore it and builds with the latest MSVC... - # That said, it's not needed to be set so far but I'm leaving it here so that this comment - # has a purpose. - # env['MSVS_VERSION']='9.0' - - # Calls a CMD with /C(lose) and /V(delayed environment variable expansion) options. - # And runs vcvarsall bat for the proper architecture and scons for proper configuration - env['MSVSBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! -j2' - env['MSVSREBUILDCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) & call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j2' - env['MSVSCLEANCOM'] = 'cmd /V /C set "plat=$(PlatformTarget)" ^& (if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64")) ^& set "tools=yes" ^& (if "$(Configuration)"=="release" (set "tools=no")) ^& call "$(VCInstallDir)vcvarsall.bat" !plat! ^& scons --clean platform=windows target=$(Configuration) tools=!tools! -j2' - - # This version information (Win32, x64, Debug, Release, Release_Debug seems to be - # required for Visual Studio to understand that it needs to generate an NMAKE - # project. Do not modify without knowing what you are doing. - debug_variants = ['debug|Win32'] + ['debug|x64'] - release_variants = ['release|Win32'] + ['release|x64'] - release_debug_variants = ['release_debug|Win32'] + ['release_debug|x64'] - variants = debug_variants + release_variants + release_debug_variants - debug_targets = ['bin\\godot.windows.tools.32.exe'] + ['bin\\godot.windows.tools.64.exe'] - release_targets = ['bin\\godot.windows.opt.32.exe'] + ['bin\\godot.windows.opt.64.exe'] - release_debug_targets = ['bin\\godot.windows.opt.tools.32.exe'] + ['bin\\godot.windows.opt.tools.64.exe'] - targets = debug_targets + release_targets + release_debug_targets - msvproj = env.MSVSProject(target=['#godot' + env['MSVSPROJECTSUFFIX']], - incs=env.vs_incs, - srcs=env.vs_srcs, - runfile=targets, - buildtarget=targets, - auto_build_solution=1, - variant=variants) + methods.generate_vs_project(env, GetOption("num_jobs")) else: diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index 5a4f29fe67..69ff791a3a 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -32,13 +32,17 @@ #include "os/os.h" #include "variant_parser.h" -Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type) const { +Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid) const { Error err; FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err); - if (!f) + if (!f) { + if (r_valid) { + *r_valid = false; + } return err; + } VariantParser::StreamFile stream; stream.f = f; @@ -47,6 +51,10 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy Variant value; VariantParser::Tag next_tag; + if (r_valid) { + *r_valid = true; + } + int lines = 0; String error_text; bool path_found = false; //first match must have priority @@ -79,6 +87,10 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy path_found = true; //first match must have priority } else if (assign == "type") { r_path_and_type.type = value; + } else if (assign == "valid") { + if (r_valid) { + *r_valid = value; + } } } else if (next_tag.name != "remap") { @@ -245,6 +257,14 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat memdelete(f); } +bool ResourceFormatImporter::is_import_valid(const String &p_path) const { + + bool valid = true; + PathAndType pat; + _get_path_and_type(p_path, pat, &valid); + return valid; +} + String ResourceFormatImporter::get_resource_type(const String &p_path) const { PathAndType pat; diff --git a/core/io/resource_import.h b/core/io/resource_import.h index bf0bf3987a..b10255fbab 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -40,7 +40,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { String type; }; - Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type) const; + Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = NULL) const; static ResourceFormatImporter *singleton; @@ -54,6 +54,7 @@ public: virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual bool is_import_valid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual bool can_be_imported(const String &p_path) const; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index f0e804e2fa..30ae9f5681 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -296,6 +296,31 @@ void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_l } } +bool ResourceLoader::is_import_valid(const String &p_path) { + + String path = _path_remap(p_path); + + String local_path; + if (path.is_rel_path()) + local_path = "res://" + path; + else + local_path = ProjectSettings::get_singleton()->localize_path(path); + + for (int i = 0; i < loader_count; i++) { + + if (!loader[i]->recognize_path(local_path)) + continue; + /* + if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + continue; + */ + + return loader[i]->is_import_valid(p_path); + } + + return false; //not found +} + void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { String path = _path_remap(p_path); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 9e059c2977..91f0c939bf 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -66,6 +66,7 @@ public: virtual String get_resource_type(const String &p_path) const = 0; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map) { return OK; } + virtual bool is_import_valid(const String &p_path) const { return true; } virtual ~ResourceFormatLoader() {} }; @@ -104,6 +105,7 @@ public: static String get_resource_type(const String &p_path); static void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); + static bool is_import_valid(const String &p_path); static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load = p_timestamp; } diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index c7e2a8f307..9732a1ff37 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -107,6 +107,13 @@ bool Basis::is_orthogonal() const { return is_equal_approx(id, m); } +bool Basis::is_diagonal() const { + return ( + Math::is_equal_approx(elements[0][1], 0) && Math::is_equal_approx(elements[0][2], 0) && + Math::is_equal_approx(elements[1][0], 0) && Math::is_equal_approx(elements[1][2], 0) && + Math::is_equal_approx(elements[2][0], 0) && Math::is_equal_approx(elements[2][1], 0)); +} + bool Basis::is_rotation() const { return Math::is_equal_approx(determinant(), 1) && is_orthogonal(); } @@ -241,12 +248,13 @@ Vector3 Basis::get_scale() const { // This may lead to confusion for some users though. // // The convention we use here is to absorb the sign flip into the scaling matrix. - // The same convention is also used in other similar functions such as set_scale, - // get_rotation_axis_angle, get_rotation, set_rotation_axis_angle, set_rotation_euler, ... + // The same convention is also used in other similar functions such as get_rotation_axis_angle, get_rotation, ... // // A proper way to get rid of this issue would be to store the scaling values (or at least their signs) // as a part of Basis. However, if we go that path, we need to disable direct (write) access to the // matrix elements. + // + // The rotation part of this decomposition is returned by get_rotation* functions. real_t det_sign = determinant() > 0 ? 1 : -1; return det_sign * Vector3( Vector3(elements[0][0], elements[1][0], elements[2][0]).length(), @@ -254,15 +262,24 @@ Vector3 Basis::get_scale() const { Vector3(elements[0][2], elements[1][2], elements[2][2]).length()); } -// Sets scaling while preserving rotation. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_scale(const Vector3 &p_scale) { - Vector3 e = get_euler(); - Basis(); // reset to identity - scale(p_scale); - rotate(e); +// Decomposes a Basis into a rotation-reflection matrix (an element of the group O(3)) and a positive scaling matrix as B = O.S. +// Returns the rotation-reflection matrix via reference argument, and scaling information is returned as a Vector3. +// This (internal) function is too specıfıc and named too ugly to expose to users, and probably there's no need to do so. +Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const { +#ifdef MATH_CHECKS + ERR_FAIL_COND_V(determinant() == 0, Vector3()); + + Basis m = transposed() * (*this); + ERR_FAIL_COND_V(m.is_diagonal() == false, Vector3()); +#endif + Vector3 scale = get_scale(); + Basis inv_scale = Basis().scaled(scale.inverse()); // this will also absorb the sign of scale + rotref = (*this) * inv_scale; + +#ifdef MATH_CHECKS + ERR_FAIL_COND_V(rotref.is_orthogonal() == false, Vector3()); +#endif + return scale.abs(); } // Multiplies the matrix from left by the rotation matrix: M -> R.M @@ -316,28 +333,6 @@ void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const { m.get_axis_angle(p_axis, p_angle); } -// Sets rotation while preserving scaling. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_rotation_euler(const Vector3 &p_euler) { - Vector3 s = get_scale(); - Basis(); // reset to identity - scale(s); - rotate(p_euler); -} - -// Sets rotation while preserving scaling. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) { - Vector3 s = get_scale(); - Basis(); // reset to identity - scale(s); - rotate(p_axis, p_angle); -} - // get_euler_xyz returns a vector containing the Euler angles in the format // (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last // (following the convention they are commonly defined in the literature). @@ -364,8 +359,9 @@ Vector3 Basis::get_euler_xyz() const { euler.y = Math::asin(elements[0][2]); if (euler.y < Math_PI * 0.5) { if (euler.y > -Math_PI * 0.5) { - //if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case. + // is this a pure Y rotation? if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) { + // return the simplest form euler.x = 0; euler.y = atan2(elements[0][2], elements[0][0]); euler.z = 0; @@ -432,7 +428,9 @@ Vector3 Basis::get_euler_yxz() const { if (m12 < 1) { if (m12 > -1) { - if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { // use pure x rotation + // is this a pure X rotation? + if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { + // return the simplest form euler.x = atan2(-m12, elements[1][1]); euler.y = 0; euler.z = 0; diff --git a/core/math/matrix3.h b/core/math/matrix3.h index be85c244bd..9c9080ac46 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -81,8 +81,7 @@ public: Vector3 get_rotation() const; void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const; - void set_rotation_euler(const Vector3 &p_euler); - void set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle); + Vector3 rotref_posscale_decomposition(Basis &rotref) const; Vector3 get_euler_xyz() const; void set_euler_xyz(const Vector3 &p_euler); @@ -99,7 +98,6 @@ public: Basis scaled(const Vector3 &p_scale) const; Vector3 get_scale() const; - void set_scale(const Vector3 &p_scale); // transposed dot products _FORCE_INLINE_ real_t tdotx(const Vector3 &v) const { @@ -132,6 +130,7 @@ public: void set_orthogonal_index(int p_index); bool is_orthogonal() const; + bool is_diagonal() const; bool is_rotation() const; operator String() const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 77372d1e60..ad15f8f5cb 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -729,9 +729,6 @@ struct _VariantCall { VCALL_PTR1R(Basis, scaled); VCALL_PTR0R(Basis, get_scale); VCALL_PTR0R(Basis, get_euler); - VCALL_PTR1(Basis, set_scale); - VCALL_PTR1(Basis, set_rotation_euler); - VCALL_PTR2(Basis, set_rotation_axis_angle); VCALL_PTR1R(Basis, tdotx); VCALL_PTR1R(Basis, tdoty); VCALL_PTR1R(Basis, tdotz); @@ -1700,9 +1697,6 @@ void register_variant_methods() { ADDFUNC0(BASIS, REAL, Basis, determinant, varray()); ADDFUNC2(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray()); ADDFUNC1(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); - ADDFUNC1(BASIS, NIL, Basis, set_scale, VECTOR3, "scale", varray()); - ADDFUNC1(BASIS, NIL, Basis, set_rotation_euler, VECTOR3, "euler", varray()); - ADDFUNC2(BASIS, NIL, Basis, set_rotation_axis_angle, VECTOR3, "axis", REAL, "angle", varray()); ADDFUNC0(BASIS, VECTOR3, Basis, get_scale, varray()); ADDFUNC0(BASIS, VECTOR3, Basis, get_euler, varray()); ADDFUNC1(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray()); diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 26c0b81428..8af7385934 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -7741,29 +7741,6 @@ Introduce an additional scaling specified by the given 3D scaling factor. Only relevant when the matrix is being used as a part of [Transform]. </description> </method> - <method name="set_rotation_axis_angle"> - <argument index="0" name="axis" type="Vector3"> - </argument> - <argument index="1" name="angle" type="float"> - </argument> - <description> - Changes only the rotation part of the [Basis] to a rotation around given axis by phi, while preserving the scaling part (as determined by get_scale). - </description> - </method> - <method name="set_rotation_euler"> - <argument index="0" name="euler" type="Vector3"> - </argument> - <description> - Changes only the rotation part of the [Basis] to a rotation corresponding to given Euler angles, while preserving the scaling part (as determined by get_scale). - </description> - </method> - <method name="set_scale"> - <argument index="0" name="scale" type="Vector3"> - </argument> - <description> - Changes only the scaling part of the Basis to the specified scaling, while preserving the rotation part (as determined by get_rotation). - </description> - </method> <method name="tdotx"> <return type="float"> </return> diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index f4dd9682a1..a492629dae 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4445,9 +4445,10 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_ } } + float bias_mult = Math::lerp(1.0f, light_instance->shadow_transform[p_pass].bias_scale, light->param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE]); zfar = light->param[VS::LIGHT_PARAM_RANGE]; - bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS] * light_instance->shadow_transform[p_pass].bias_scale; - normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * light_instance->shadow_transform[p_pass].bias_scale; + bias = light->param[VS::LIGHT_PARAM_SHADOW_BIAS] * bias_mult; + normal_bias = light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] * bias_mult; fbo = directional_shadow.fbo; vp_height = directional_shadow.size; diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index c5c9140874..4cc6dcd5fb 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -4448,6 +4448,7 @@ RID RasterizerStorageGLES3::light_create(VS::LightType p_type) { light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_2_OFFSET] = 0.3; light->param[VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET] = 0.6; light->param[VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS] = 0.1; + light->param[VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE] = 0.1; light->color = Color(1, 1, 1, 1); light->shadow = false; diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index f0dc14c35a..bb645f31a0 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -572,13 +572,11 @@ FRAGMENT_SHADER_CODE #ifdef SHADOW_FILTER_PCF5 - SHADOW_TEST(su+shadowpixel_size*3.0); SHADOW_TEST(su+shadowpixel_size*2.0); SHADOW_TEST(su+shadowpixel_size); SHADOW_TEST(su); SHADOW_TEST(su-shadowpixel_size); SHADOW_TEST(su-shadowpixel_size*2.0); - SHADOW_TEST(su-shadowpixel_size*3.0); shadow_attenuation/=5.0; #endif @@ -635,4 +633,3 @@ FRAGMENT_SHADER_CODE frag_color = color; } - diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 9d110c7136..c175886d14 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -118,6 +118,12 @@ Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const { return files[p_idx]->deps; } +bool EditorFileSystemDirectory::get_file_import_is_valid(int p_idx) const { + + ERR_FAIL_INDEX_V(p_idx, files.size(), false); + return files[p_idx]->import_valid; +} + StringName EditorFileSystemDirectory::get_file_type(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, files.size(), ""); @@ -142,6 +148,7 @@ void EditorFileSystemDirectory::_bind_methods() { ClassDB::bind_method(D_METHOD("get_file", "idx"), &EditorFileSystemDirectory::get_file); ClassDB::bind_method(D_METHOD("get_file_path", "idx"), &EditorFileSystemDirectory::get_file_path); ClassDB::bind_method(D_METHOD("get_file_type", "idx"), &EditorFileSystemDirectory::get_file_type); + ClassDB::bind_method(D_METHOD("get_file_import_is_valid", "idx"), &EditorFileSystemDirectory::get_file_import_is_valid); ClassDB::bind_method(D_METHOD("get_name"), &EditorFileSystemDirectory::get_name); ClassDB::bind_method(D_METHOD("get_path"), &EditorFileSystemDirectory::get_path); ClassDB::bind_method(D_METHOD("get_parent"), &EditorFileSystemDirectory::get_parent); @@ -181,7 +188,7 @@ void EditorFileSystem::_scan_filesystem() { String project = ProjectSettings::get_singleton()->get_resource_path(); - String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2"); + String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache3"); FileAccess *f = FileAccess::open(fscache, FileAccess::READ); if (f) { @@ -201,7 +208,7 @@ void EditorFileSystem::_scan_filesystem() { } else { Vector<String> split = l.split("::"); - ERR_CONTINUE(split.size() != 5); + ERR_CONTINUE(split.size() != 6); String name = split[0]; String file; @@ -212,8 +219,9 @@ void EditorFileSystem::_scan_filesystem() { fc.type = split[1]; fc.modification_time = split[2].to_int64(); fc.import_modification_time = split[3].to_int64(); + fc.import_valid = split[4].to_int64() != 0; - String deps = split[4].strip_edges(); + String deps = split[5].strip_edges(); if (deps.length()) { Vector<String> dp = deps.split("<>"); for (int i = 0; i < dp.size(); i++) { @@ -230,7 +238,7 @@ void EditorFileSystem::_scan_filesystem() { memdelete(f); } - String update_cache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2"); + String update_cache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update3"); print_line("try to see fs update2"); if (FileAccess::exists(update_cache)) { @@ -282,7 +290,7 @@ void EditorFileSystem::_scan_filesystem() { } void EditorFileSystem::_save_filesystem_cache() { - String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2"); + String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache3"); FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE); _save_filesystem_cache(filesystem, f); @@ -622,6 +630,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess fi->deps = fc->deps; fi->modified_time = fc->modification_time; fi->import_modified_time = fc->import_modification_time; + fi->import_valid = fc->import_valid; if (fc->type == String()) { fi->type = ResourceLoader::get_resource_type(path); //there is also the chance that file type changed due to reimport, must probably check this somehow here (or kind of note it for next time in another file?) @@ -648,6 +657,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess print_line("import extension tried resource type for " + path + " and its " + fi->type); fi->modified_time = 0; fi->import_modified_time = 0; + fi->import_valid = ResourceLoader::is_import_valid(path); ItemAction ia; ia.action = ItemAction::ACTION_FILE_REIMPORT; @@ -663,6 +673,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess fi->modified_time = fc->modification_time; fi->deps = fc->deps; fi->import_modified_time = 0; + fi->import_valid = true; } else { //new or modified time fi->type = ResourceLoader::get_resource_type(path); @@ -670,6 +681,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess print_line("regular import tried resource type for " + path + " and its " + fi->type); fi->modified_time = mt; fi->import_modified_time = 0; + fi->import_valid = true; } } @@ -766,6 +778,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const fi->modified_time = FileAccess::get_modified_time(path); fi->import_modified_time = 0; fi->type = ResourceLoader::get_resource_type(path); + fi->import_valid = ResourceLoader::is_import_valid(path); { ItemAction ia; @@ -1036,7 +1049,7 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, for (int i = 0; i < p_dir->files.size(); i++) { - String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time); + String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid); s += "::"; for (int j = 0; j < p_dir->files[i]->deps.size(); j++) { @@ -1217,7 +1230,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p void EditorFileSystem::_save_late_updated_files() { //files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file - String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2"); + String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update3"); FileAccessRef f = FileAccess::open(fscache, FileAccess::WRITE); for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) { f->store_line(E->get()); @@ -1281,6 +1294,7 @@ void EditorFileSystem::update_file(const String &p_file) { EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); fi->file = p_file.get_file(); fi->import_modified_time = 0; + fi->import_valid = ResourceLoader::is_import_valid(p_file); if (idx == fs->files.size()) { fs->files.push_back(fi); @@ -1301,6 +1315,7 @@ void EditorFileSystem::update_file(const String &p_file) { fs->files[cpos]->type = type; fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file); fs->files[cpos]->deps = _get_dependencies(p_file); + fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); //if (FileAccess::exists(p_file+".import")) { // fs->files[cpos]->import_modified_time=FileAccess::get_modified_time(p_file+".import"); //} @@ -1404,19 +1419,26 @@ void EditorFileSystem::_reimport_file(const String &p_file) { f->store_line("type=\"" + importer->get_resource_type() + "\""); } - if (importer->get_save_extension() == "") { - //no path - } else if (import_variants.size()) { - //import with variants - for (List<String>::Element *E = import_variants.front(); E; E = E->next()) { + if (err == OK) { + + if (importer->get_save_extension() == "") { + //no path + } else if (import_variants.size()) { + //import with variants + for (List<String>::Element *E = import_variants.front(); E; E = E->next()) { - String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); + String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); - f->store_line("path." + E->get() + "=\"" + path + "\""); + f->store_line("path." + E->get() + "=\"" + path + "\""); + } + } else { + + f->store_line("path=\"" + base_path + "." + importer->get_save_extension() + "\""); } + } else { - f->store_line("path=\"" + base_path + "." + importer->get_save_extension() + "\""); + f->store_line("valid=false"); } f->store_line(""); @@ -1455,6 +1477,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import"); fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->type = importer->get_resource_type(); + fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it //to reload properly diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 4d9a96d233..cee3219b43 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -54,6 +54,7 @@ class EditorFileSystemDirectory : public Object { StringName type; uint64_t modified_time; uint64_t import_modified_time; + bool import_valid; Vector<String> deps; bool verified; //used for checking changes }; @@ -83,6 +84,7 @@ public: String get_file_path(int p_idx) const; StringName get_file_type(int p_idx) const; Vector<String> get_file_deps(int p_idx) const; + bool get_file_import_is_valid(int p_idx) const; EditorFileSystemDirectory *get_parent(); @@ -153,6 +155,7 @@ class EditorFileSystem : public Node { uint64_t modification_time; uint64_t import_modification_time; Vector<String> deps; + bool import_valid; }; HashMap<String, FileCache> file_cache; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index e998f5bd9f..15de8206aa 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4802,6 +4802,38 @@ EditorNode::EditorNode() { prev_scene->set_position(Point2(3, 24)); prev_scene->hide(); + accept = memnew(AcceptDialog); + gui_base->add_child(accept); + accept->connect("confirmed", this, "_menu_confirm_current"); + + project_export = memnew(ProjectExportDialog); + gui_base->add_child(project_export); + + dependency_error = memnew(DependencyErrorDialog); + gui_base->add_child(dependency_error); + + dependency_fixer = memnew(DependencyEditor); + gui_base->add_child(dependency_fixer); + + settings_config_dialog = memnew(EditorSettingsDialog); + gui_base->add_child(settings_config_dialog); + + project_settings = memnew(ProjectSettingsEditor(&editor_data)); + gui_base->add_child(project_settings); + + run_settings_dialog = memnew(RunSettingsDialog); + gui_base->add_child(run_settings_dialog); + + export_template_manager = memnew(ExportTemplateManager); + gui_base->add_child(export_template_manager); + + about = memnew(EditorAbout); + about->get_logo()->set_texture(gui_base->get_icon("Logo", "EditorIcons")); + gui_base->add_child(about); + + warning = memnew(AcceptDialog); + gui_base->add_child(warning); + ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB); ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB); ED_SHORTCUT("editor/filter_files", TTR("Filter Files.."), KEY_MASK_ALT + KEY_MASK_CMD + KEY_P); @@ -5226,38 +5258,6 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); - accept = memnew(AcceptDialog); - gui_base->add_child(accept); - accept->connect("confirmed", this, "_menu_confirm_current"); - - project_export = memnew(ProjectExportDialog); - gui_base->add_child(project_export); - - dependency_error = memnew(DependencyErrorDialog); - gui_base->add_child(dependency_error); - - dependency_fixer = memnew(DependencyEditor); - gui_base->add_child(dependency_fixer); - - settings_config_dialog = memnew(EditorSettingsDialog); - gui_base->add_child(settings_config_dialog); - - project_settings = memnew(ProjectSettingsEditor(&editor_data)); - gui_base->add_child(project_settings); - - run_settings_dialog = memnew(RunSettingsDialog); - gui_base->add_child(run_settings_dialog); - - export_template_manager = memnew(ExportTemplateManager); - gui_base->add_child(export_template_manager); - - about = memnew(EditorAbout); - about->get_logo()->set_texture(gui_base->get_icon("Logo", "EditorIcons")); - gui_base->add_child(about); - - warning = memnew(AcceptDialog); - gui_base->add_child(warning); - file_templates = memnew(FileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 8d11679509..0ad7b25e4a 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -389,6 +389,7 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> * fi.name = file; fi.type = p_path->get_file_type(i); fi.path = p_path->get_file_path(i); + fi.import_broken = !p_path->get_file_import_is_valid(i); fi.import_status = 0; matches->push_back(fi); @@ -423,6 +424,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) { thumbnail_size *= EDSCALE; Ref<Texture> folder_thumbnail; Ref<Texture> file_thumbnail; + Ref<Texture> file_thumbnail_broken; bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS); bool use_folders = search_box->get_text().length() == 0 && split_mode; @@ -456,8 +458,18 @@ void FileSystemDock::_update_files(bool p_keep_selection) { Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file); } + if (!has_icon("ResizedFileBroken", "EditorIcons")) { + Ref<ImageTexture> file = get_icon("FileBigBroken", "EditorIcons"); + Ref<Image> img = file->get_data(); + img->resize(thumbnail_size, thumbnail_size); + Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture)); + resized_file->create_from_image(img, 0); + Theme::get_default()->set_icon("ResizedFileBroken", "EditorIcons", resized_file); + } + file_thumbnail = get_icon("ResizedFile", "EditorIcons"); + file_thumbnail_broken = get_icon("ResizedFileBroken", "EditorIcons"); } else { files->set_icon_mode(ItemList::ICON_MODE_LEFT); @@ -518,6 +530,7 @@ void FileSystemDock::_update_files(bool p_keep_selection) { fi.name = efd->get_file(i); fi.path = path.plus_file(fi.name); fi.type = efd->get_file_type(i); + fi.import_broken = !efd->get_file_import_is_valid(i); fi.import_status = 0; filelist.push_back(fi); @@ -533,24 +546,21 @@ void FileSystemDock::_update_files(bool p_keep_selection) { StringName type = E->get().type; Ref<Texture> type_icon; + Ref<Texture> big_icon = file_thumbnail; String tooltip = fname; - if (E->get().import_status == 0) { + if (!E->get().import_broken) { if (has_icon(type, ei)) { type_icon = get_icon(type, ei); } else { type_icon = get_icon(oi, ei); } - } else if (E->get().import_status == 1) { - type_icon = get_icon("DependencyOk", "EditorIcons"); - } else if (E->get().import_status == 2) { - type_icon = get_icon("DependencyChanged", "EditorIcons"); - tooltip += TTR("\nStatus: Needs Re-Import"); - } else if (E->get().import_status == 3) { + } else { type_icon = get_icon("ImportFail", "EditorIcons"); - tooltip += ("\nStatus: Missing Dependencies"); + big_icon = file_thumbnail_broken; + tooltip += TTR("\nStatus: Import of file failed. Please fix file and reimport manually."); } if (E->get().sources.size()) { @@ -560,14 +570,16 @@ void FileSystemDock::_update_files(bool p_keep_selection) { } if (use_thumbnails) { - files->add_item(fname, file_thumbnail, true); + files->add_item(fname, big_icon, true); files->set_item_metadata(files->get_item_count() - 1, fp); files->set_item_tag_icon(files->get_item_count() - 1, type_icon); Array udata; udata.resize(2); udata[0] = files->get_item_count() - 1; udata[1] = fname; - EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata); + if (!E->get().import_broken) { + EditorResourcePreview::get_singleton()->queue_resource_preview(fp, this, "_thumbnail_done", udata); + } } else { files->add_item(fname, type_icon, true); files->set_item_metadata(files->get_item_count() - 1, fp); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index c33a745ce4..a35b145085 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -169,6 +169,7 @@ private: StringName type; int import_status; //0 not imported, 1 - ok, 2- must reimport, 3- broken Vector<String> sources; + bool import_broken; bool operator<(const FileInfo &fi) const { return name < fi.name; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index dd98494504..7fa76713f3 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -933,13 +933,13 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), meshes_out ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), (meshes_out || materials_out) ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Built-In,Files", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_on_reimport"), materials_out ? true : false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? true : false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), "")); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index bf8d88ce0a..9c3d5e7876 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -83,9 +83,9 @@ class ResourceImporterScene : public ResourceImporter { static ResourceImporterScene *singleton; enum Presets { - PRESET_SINGLE_SCENE, PRESET_SEPARATE_MATERIALS, PRESET_SEPARATE_MESHES, + PRESET_SINGLE_SCENE, PRESET_SEPARATE_MESHES_AND_MATERIALS, PRESET_MULTIPLE_SCENES, PRESET_MULTIPLE_SCENES_AND_MATERIALS, diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index c90462db1d..38f95d8278 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -344,6 +344,10 @@ void CollisionPolygon2DEditor::edit(Node *p_collision_polygon) { if (p_collision_polygon) { node = Object::cast_to<CollisionPolygon2D>(p_collision_polygon); + //Enable the pencil tool if the polygon is empty + if (node->get_polygon().size() == 0) { + _menu_option(MODE_CREATE); + } if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); wip.clear(); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 3ac055e650..24c4813771 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -468,6 +468,10 @@ void CollisionPolygonEditor::edit(Node *p_collision_polygon) { if (p_collision_polygon) { node = Object::cast_to<CollisionPolygon>(p_collision_polygon); + //Enable the pencil tool if the polygon is empty + if (node->get_polygon().size() == 0) { + _menu_option(MODE_CREATE); + } wip.clear(); wip_active = false; edited_point = -1; diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 76e969a339..de8d4f9618 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -69,6 +69,7 @@ void NavigationPolygonEditor::_create_nav() { undo_redo->add_do_method(node, "set_navigation_polygon", Ref<NavigationPolygon>(memnew(NavigationPolygon))); undo_redo->add_undo_method(node, "set_navigation_polygon", Variant(REF())); undo_redo->commit_action(); + _menu_option(MODE_CREATE); } void NavigationPolygonEditor::_menu_option(int p_option) { @@ -423,6 +424,11 @@ void NavigationPolygonEditor::edit(Node *p_collision_polygon) { if (p_collision_polygon) { node = Object::cast_to<NavigationPolygonInstance>(p_collision_polygon); + //Enable the pencil tool if the polygon is empty + if (!node->get_navigation_polygon().is_null()) { + if (node->get_navigation_polygon()->get_polygon_count() == 0) + _menu_option(MODE_CREATE); + } if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); wip.clear(); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index d04184f055..a3195c05d6 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -402,10 +402,13 @@ bool Polygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { cpoint = canvas_item_editor->snap_point(cpoint); edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); - Vector<Vector2> poly = Variant(node->get_polygon()); - ERR_FAIL_INDEX_V(edited_point, poly.size(), false); - poly[edited_point] = edited_point_pos - node->get_offset(); - node->set_polygon(Variant(poly)); + if (!wip_active) { + + Vector<Vector2> poly = Variant(node->get_polygon()); + ERR_FAIL_INDEX_V(edited_point, poly.size(), false); + poly[edited_point] = edited_point_pos - node->get_offset(); + node->set_polygon(Variant(poly)); + } canvas_item_editor->get_viewport_control()->update(); } @@ -430,7 +433,7 @@ void Polygon2DEditor::_canvas_draw() { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons"); - if (edited_point >= 0 && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) { + if (!wip_active && edited_point >= 0 && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) { const Color col = node->get_color().contrasted(); const int n = pre_move_edit.size(); @@ -720,6 +723,10 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) { if (p_collision_polygon) { node = Object::cast_to<Polygon2D>(p_collision_polygon); + //Enable the pencil tool if the polygon is empty + if (node->get_polygon().size() == 0) { + _menu_option(MODE_CREATE); + } if (!canvas_item_editor->get_viewport_control()->is_connected("draw", this, "_canvas_draw")) canvas_item_editor->get_viewport_control()->connect("draw", this, "_canvas_draw"); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 11590ec69a..a529f152dc 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -47,7 +47,7 @@ void ScriptEditorBase::_bind_methods() { ADD_SIGNAL(MethodInfo("name_changed")); - ADD_SIGNAL(MethodInfo("script_changed")); + ADD_SIGNAL(MethodInfo("edited_script_changed")); ADD_SIGNAL(MethodInfo("request_help_search", PropertyInfo(Variant::STRING, "topic"))); ADD_SIGNAL(MethodInfo("request_help_index")); ADD_SIGNAL(MethodInfo("request_open_script_at_line", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::INT, "line"))); @@ -1629,7 +1629,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool _update_script_names(); _save_layout(); se->connect("name_changed", this, "_update_script_names"); - se->connect("script_changed", this, "_script_changed"); + se->connect("edited_script_changed", this, "_script_changed"); se->connect("request_help_search", this, "_help_search"); se->connect("request_open_script_at_line", this, "_goto_script_line"); se->connect("go_to_help", this, "_help_class_goto"); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 89dc358d02..a8f1b00776 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -529,7 +529,7 @@ void ScriptTextEditor::_validate_script() { } emit_signal("name_changed"); - emit_signal("script_changed"); + emit_signal("edited_script_changed"); } static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index f36c3ca8b2..8672892b5a 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -197,8 +197,6 @@ void ShaderTextEditor::_validate_script() { } void ShaderTextEditor::_bind_methods() { - - //ADD_SIGNAL( MethodInfo("script_changed") ); } ShaderTextEditor::ShaderTextEditor() { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index f226ab2636..bc5c700959 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -50,6 +50,9 @@ #define GIZMO_RING_HALF_WIDTH 0.1 //#define GIZMO_SCALE_DEFAULT 0.28 #define GIZMO_SCALE_DEFAULT 0.15 +#define GIZMO_PLANE_SIZE 0.2 +#define GIZMO_PLANE_DST 0.3 +#define GIZMO_CIRCLE_SIZE 0.9 #define ZOOM_MIN_DISTANCE 0.001 #define ZOOM_MULTIPLIER 1.08 @@ -588,6 +591,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig float grabber_radius = gs * GIZMO_ARROW_SIZE; Vector3 r; + if (Geometry::segment_intersects_sphere(ray_pos, ray_pos + ray * 10000.0, grabber_pos, grabber_radius, &r)) { float d = r.distance_to(ray_pos); if (d < col_d) { @@ -597,17 +601,49 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } } + bool is_plane_translate = false; + // second try + if (col_axis == -1) { + col_d = 1e20; + + for (int i = 0; i < 3; i++) { + + Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); + Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); + + Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST); + + Vector3 r; + Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); + + if (plane.intersects_ray(ray_pos, ray, &r)) { + + float dist = r.distance_to(grabber_pos); + if (dist < (gs * GIZMO_PLANE_SIZE)) { + + float d = ray_pos.distance_to(r); + if (d < col_d) { + col_d = d; + col_axis = i; + + is_plane_translate = true; + } + } + } + } + } + if (col_axis != -1) { if (p_highlight_only) { - spatial_editor->select_gizmo_highlight_axis(col_axis); + spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_translate ? 6 : 0)); } else { - //handle rotate + //handle plane translate _edit.mode = TRANSFORM_TRANSLATE; _compute_edit(Point2(p_screenpos.x, p_screenpos.y)); - _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis); + _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis + (is_plane_translate ? 3 : 0)); } return true; } @@ -627,7 +663,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig float dist = r.distance_to(gt.origin); - if (dist > gs * (1 - GIZMO_RING_HALF_WIDTH) && dist < gs * (1 + GIZMO_RING_HALF_WIDTH)) { + if (dist > gs * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gs * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) { float d = ray_pos.distance_to(r); if (d < col_d) { @@ -921,7 +957,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (get_selected_count() == 0) break; //bye - //handle rotate + //handle translate _edit.mode = TRANSFORM_TRANSLATE; _compute_edit(b->get_position()); break; @@ -1175,6 +1211,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 motion_mask; Plane plane; + bool plane_mv; switch (_edit.plane) { case TRANSFORM_VIEW: @@ -1193,6 +1230,21 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2); plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); break; + case TRANSFORM_YZ: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0)); + plane_mv = true; + break; + case TRANSFORM_XZ: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1)); + plane_mv = true; + break; + case TRANSFORM_XY: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2)); + plane_mv = true; + break; } Vector3 intersection; @@ -1206,7 +1258,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { //_validate_selection(); Vector3 motion = intersection - click; if (motion_mask != Vector3()) { - motion = motion_mask.dot(motion) * motion_mask; + if (plane_mv) + motion *= motion_mask; + else + motion = motion_mask.dot(motion) * motion_mask; } //set_message("Translating: "+motion); @@ -2185,6 +2240,14 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer); + move_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); + VS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid()); + VS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + VS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); + //VS::get_singleton()->instance_geometry_set_flag(move_plane_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); + VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); + VS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer); + rotate_gizmo_instance[i] = VS::get_singleton()->instance_create(); VS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid()); VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); @@ -2199,6 +2262,7 @@ void SpatialEditorViewport::_finish_gizmo_instances() { for (int i = 0; i < 3; i++) { VS::get_singleton()->free(move_gizmo_instance[i]); + VS::get_singleton()->free(move_plane_gizmo_instance[i]); VS::get_singleton()->free(rotate_gizmo_instance[i]); } } @@ -2290,6 +2354,8 @@ void SpatialEditorViewport::update_transform_gizmo_view() { for (int i = 0; i < 3; i++) { VisualServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform); VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE)); + VisualServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform); + VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE)); VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE)); } @@ -2848,6 +2914,7 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { for (int i = 0; i < 3; i++) { move_gizmo[i]->surface_set_material(0, i == p_axis ? gizmo_hl : gizmo_color[i]); + move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? gizmo_hl : plane_gizmo_color[i]); rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_hl : gizmo_color[i]); } } @@ -3441,10 +3508,12 @@ void SpatialEditor::_init_indicators() { gizmo_hl->set_flag(SpatialMaterial::FLAG_ONTOP, true); gizmo_hl->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); gizmo_hl->set_albedo(Color(1, 1, 1, gizmo_alph + 0.2f)); + gizmo_hl->set_cull_mode(SpatialMaterial::CULL_DISABLED); for (int i = 0; i < 3; i++) { move_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); + move_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); Ref<SpatialMaterial> mat = memnew(SpatialMaterial); @@ -3455,6 +3524,7 @@ void SpatialEditor::_init_indicators() { col[i] = 1.0; col.a = gizmo_alph; mat->set_albedo(col); + gizmo_color[i] = mat; Vector3 ivec; @@ -3512,17 +3582,60 @@ void SpatialEditor::_init_indicators() { surftool->commit(move_gizmo[i]); } + // plane translation + { + Ref<SurfaceTool> surftool = memnew(SurfaceTool); + surftool->begin(Mesh::PRIMITIVE_TRIANGLES); + + Vector3 vec = ivec2 - ivec3; + Vector3 plane[4] = { + vec * GIZMO_PLANE_DST, + vec * GIZMO_PLANE_DST + ivec2 * GIZMO_PLANE_SIZE, + vec * (GIZMO_PLANE_DST + GIZMO_PLANE_SIZE), + vec * GIZMO_PLANE_DST - ivec3 * GIZMO_PLANE_SIZE + }; + + Basis ma(ivec, Math_PI / 2); + + Vector3 points[4] = { + ma.xform(plane[0]), + ma.xform(plane[1]), + ma.xform(plane[2]), + ma.xform(plane[3]), + }; + surftool->add_vertex(points[0]); + surftool->add_vertex(points[1]); + surftool->add_vertex(points[2]); + + surftool->add_vertex(points[0]); + surftool->add_vertex(points[2]); + surftool->add_vertex(points[3]); + + Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial); + plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + plane_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true); + plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + Color col; + col[i] = 1.0; + col.a = gizmo_alph; + plane_mat->set_albedo(col); + plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides + surftool->set_material(plane_mat); + surftool->commit(move_plane_gizmo[i]); + } + { Ref<SurfaceTool> surftool = memnew(SurfaceTool); surftool->begin(Mesh::PRIMITIVE_TRIANGLES); Vector3 circle[5] = { - ivec * 0.02 + ivec2 * 0.02 + ivec2 * 1.0, - ivec * -0.02 + ivec2 * 0.02 + ivec2 * 1.0, - ivec * -0.02 + ivec2 * -0.02 + ivec2 * 1.0, - ivec * 0.02 + ivec2 * -0.02 + ivec2 * 1.0, - ivec * 0.02 + ivec2 * 0.02 + ivec2 * 1.0, + ivec * 0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE, + ivec * -0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE, + ivec * -0.02 + ivec2 * -0.02 + ivec2 * GIZMO_CIRCLE_SIZE, + ivec * 0.02 + ivec2 * -0.02 + ivec2 * GIZMO_CIRCLE_SIZE, + ivec * 0.02 + ivec2 * 0.02 + ivec2 * GIZMO_CIRCLE_SIZE, }; for (int k = 0; k < 33; k++) { diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index b024a8bd93..374861b5e7 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -196,6 +196,9 @@ private: TRANSFORM_X_AXIS, TRANSFORM_Y_AXIS, TRANSFORM_Z_AXIS, + TRANSFORM_YZ, + TRANSFORM_XZ, + TRANSFORM_XY, }; struct EditData { @@ -233,7 +236,7 @@ private: real_t zoom_indicator_delay; - RID move_gizmo_instance[3], rotate_gizmo_instance[3]; + RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3]; String last_message; String message; @@ -378,8 +381,9 @@ private: bool grid_enable[3]; //should be always visible if true bool grid_enabled; - Ref<ArrayMesh> move_gizmo[3], rotate_gizmo[3]; + Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3]; Ref<SpatialMaterial> gizmo_color[3]; + Ref<SpatialMaterial> plane_gizmo_color[3]; Ref<SpatialMaterial> gizmo_hl; int over_gizmo_handle; @@ -519,6 +523,7 @@ public: bool are_local_coords_enabled() const { return transform_menu->get_popup()->is_item_checked(transform_menu->get_popup()->get_item_index(SpatialEditor::MENU_TRANSFORM_LOCAL_COORDS)); } Ref<ArrayMesh> get_move_gizmo(int idx) const { return move_gizmo[idx]; } + Ref<ArrayMesh> get_move_plane_gizmo(int idx) const { return move_plane_gizmo[idx]; } Ref<ArrayMesh> get_rotate_gizmo(int idx) const { return rotate_gizmo[idx]; } void update_transform_gizmo(); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index d86b255f38..c127b9a2f1 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -298,12 +298,23 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi } void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 size) { + ERR_FAIL_COND(!spatial_node); + CubeMesh cubem; cubem.set_size(size); Ref<ArrayMesh> m = memnew(ArrayMesh); m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), cubem.surface_get_arrays(0)); m->surface_set_material(0, p_material); add_mesh(m); + + Instance ins; + ins.mesh = m; + if (valid) { + ins.create_instance(spatial_node); + VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + } + + instances.push_back(ins); } void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) { @@ -877,10 +888,6 @@ void LightSpatialGizmo::redraw() { Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w; Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * w; - /*points.push_back(Vector3(a.x,0,a.y)); - points.push_back(Vector3(b.x,0,b.y)); - points.push_back(Vector3(0,a.x,a.y)); - points.push_back(Vector3(0,b.x,b.y));*/ points.push_back(Vector3(a.x, a.y, -d)); points.push_back(Vector3(b.x, b.y, -d)); diff --git a/methods.py b/methods.py index 25093ac530..ec7e658a3b 100644 --- a/methods.py +++ b/methods.py @@ -1680,6 +1680,59 @@ def detect_visual_c_compiler_version(tools_env): return vc_chosen_compiler_str +def find_visual_c_batch_file(env): + from SCons.Tool.MSCommon.vc import get_default_version, get_host_target, find_batch_file + + version = get_default_version(env) + (host_platform, target_platform,req_target_platform) = get_host_target(env) + return find_batch_file(env, version, host_platform, target_platform)[0] + + +def generate_vs_project(env, num_jobs): + batch_file = find_visual_c_batch_file(env) + if batch_file: + def build_commandline(commands): + common_build_prefix = ['cmd /V /C set "plat=$(PlatformTarget)"', + '(if "$(PlatformTarget)"=="x64" (set "plat=x86_amd64"))', + 'set "tools=yes"', + '(if "$(Configuration)"=="release" (set "tools=no"))', + 'call "' + batch_file + '" !plat!'] + + result = " ^& ".join(common_build_prefix + [commands]) + # print("Building commandline: ", result) + return result + + env.AddToVSProject(env.core_sources) + env.AddToVSProject(env.main_sources) + env.AddToVSProject(env.modules_sources) + env.AddToVSProject(env.scene_sources) + env.AddToVSProject(env.servers_sources) + env.AddToVSProject(env.editor_sources) + + env['MSVSBUILDCOM'] = build_commandline('scons platform=windows target=$(Configuration) tools=!tools! -j' + str(num_jobs)) + env['MSVSREBUILDCOM'] = build_commandline('scons platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j' + str(num_jobs)) + env['MSVSCLEANCOM'] = build_commandline('scons --clean platform=windows target=$(Configuration) tools=!tools! -j' + str(num_jobs)) + + # This version information (Win32, x64, Debug, Release, Release_Debug seems to be + # required for Visual Studio to understand that it needs to generate an NMAKE + # project. Do not modify without knowing what you are doing. + debug_variants = ['debug|Win32'] + ['debug|x64'] + release_variants = ['release|Win32'] + ['release|x64'] + release_debug_variants = ['release_debug|Win32'] + ['release_debug|x64'] + variants = debug_variants + release_variants + release_debug_variants + debug_targets = ['bin\\godot.windows.tools.32.exe'] + ['bin\\godot.windows.tools.64.exe'] + release_targets = ['bin\\godot.windows.opt.32.exe'] + ['bin\\godot.windows.opt.64.exe'] + release_debug_targets = ['bin\\godot.windows.opt.tools.32.exe'] + ['bin\\godot.windows.opt.tools.64.exe'] + targets = debug_targets + release_targets + release_debug_targets + msvproj = env.MSVSProject(target=['#godot' + env['MSVSPROJECTSUFFIX']], + incs=env.vs_incs, + srcs=env.vs_srcs, + runfile=targets, + buildtarget=targets, + auto_build_solution=1, + variant=variants) + else: + print("Could not locate Visual Studio batch file for setting up the build environment. Not generating VS project.") def precious_program(env, program, sources, **args): program = env.ProgramOriginal(program, sources, **args) diff --git a/modules/etc/SCsub b/modules/etc/SCsub index 8f5937017e..f0c1ee64b9 100644 --- a/modules/etc/SCsub +++ b/modules/etc/SCsub @@ -35,3 +35,7 @@ env_etc.add_source_files(env.modules_sources, "*.cpp") # upstream uses c++11 env_etc.Append(CXXFLAGS="-std=gnu++11") +# -ffast-math seems to be incompatible with ec2comp on recent versions of +# GCC and Clang +if '-ffast-math' in env_etc['CCFLAGS']: + env_etc['CCFLAGS'].remove('-ffast-math') diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py index 4f89ca0d4c..9f57b9bb74 100644 --- a/modules/gdnative/config.py +++ b/modules/gdnative/config.py @@ -1,7 +1,7 @@ def can_build(platform): - return False + return True def configure(env): diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/godot/basis.cpp index 8433355c12..1d7aa18a70 100644 --- a/modules/gdnative/godot/basis.cpp +++ b/modules/gdnative/godot/basis.cpp @@ -107,24 +107,6 @@ godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vect return dest; } -void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale) { - Basis *self = (Basis *)p_self; - const Vector3 *scale = (const Vector3 *)p_scale; - self->set_scale(*scale); -} - -void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler) { - Basis *self = (Basis *)p_self; - const Vector3 *euler = (const Vector3 *)p_euler; - self->set_rotation_euler(*euler); -} - -void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle) { - Basis *self = (Basis *)p_self; - const Vector3 *axis = (const Vector3 *)p_axis; - self->set_rotation_axis_angle(*axis, p_angle); -} - godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) { godot_vector3 dest; const Basis *self = (const Basis *)p_self; diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/godot/basis.h index d336bb9bc1..f36d2199de 100644 --- a/modules/gdnative/godot/basis.h +++ b/modules/gdnative/godot/basis.h @@ -67,12 +67,6 @@ godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vec godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale); -void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale); - -void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler); - -void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle); - godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self); godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self); diff --git a/modules/nativescript/api_generator.cpp b/modules/nativescript/api_generator.cpp index 4490197bdb..fdd5a2ea19 100644 --- a/modules/nativescript/api_generator.cpp +++ b/modules/nativescript/api_generator.cpp @@ -33,6 +33,7 @@ #include "class_db.h" #include "core/global_constants.h" +#include "core/pair.h" #include "core/project_settings.h" #include "os/file_access.h" @@ -93,6 +94,11 @@ struct SignalAPI { Map<int, Variant> default_arguments; }; +struct EnumAPI { + String name; + List<Pair<int, String> > values; +}; + struct ClassAPI { String class_name; String super_class_name; @@ -109,8 +115,28 @@ struct ClassAPI { List<PropertyAPI> properties; List<ConstantAPI> constants; List<SignalAPI> signals_; + List<EnumAPI> enums; }; +static String get_type_name(const PropertyInfo &info) { + if (info.type == Variant::INT && (info.usage & PROPERTY_USAGE_CLASS_IS_ENUM)) { + return String("enum.") + String(info.class_name).replace(".", "::"); + } + if (info.class_name != StringName()) { + return info.class_name; + } + if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) { + return info.hint_string; + } + if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) { + return "Variant"; + } + if (info.type == Variant::NIL) { + return "void"; + } + return Variant::get_type_name(info.type); +} + /* * Reads the entire Godot API to a list */ @@ -194,12 +220,8 @@ List<ClassAPI> generate_c_api_classes() { if (argument.name.find(":") != -1) { type = argument.name.get_slice(":", 1); name = argument.name.get_slice(":", 0); - } else if (argument.hint == PROPERTY_HINT_RESOURCE_TYPE) { - type = argument.hint_string; - } else if (argument.type == Variant::NIL) { - type = "Variant"; } else { - type = Variant::get_type_name(argument.type); + type = get_type_name(argument); } signal.argument_names.push_back(name); @@ -233,12 +255,8 @@ List<ClassAPI> generate_c_api_classes() { if (p->get().name.find(":") != -1) { property_api.type = p->get().name.get_slice(":", 1); property_api.name = p->get().name.get_slice(":", 0); - } else if (p->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - property_api.type = p->get().hint_string; - } else if (p->get().type == Variant::NIL) { - property_api.type = "Variant"; } else { - property_api.type = Variant::get_type_name(p->get().type); + property_api.type = get_type_name(p->get()); } if (!property_api.setter.empty() || !property_api.getter.empty()) { @@ -260,17 +278,11 @@ List<ClassAPI> generate_c_api_classes() { //method name method_api.method_name = m->get().name; //method return type - if (method_bind && method_bind->get_return_type() != StringName()) { - method_api.return_type = method_bind->get_return_type(); - } else if (method_api.method_name.find(":") != -1) { + if (method_api.method_name.find(":") != -1) { method_api.return_type = method_api.method_name.get_slice(":", 1); method_api.method_name = method_api.method_name.get_slice(":", 0); - } else if (m->get().return_val.type != Variant::NIL) { - method_api.return_type = m->get().return_val.hint == PROPERTY_HINT_RESOURCE_TYPE ? m->get().return_val.hint_string : Variant::get_type_name(m->get().return_val.type); - } else if (m->get().return_val.name != "") { - method_api.return_type = m->get().return_val.name; } else { - method_api.return_type = "void"; + method_api.return_type = get_type_name(m->get().return_val); } method_api.argument_count = method_info.arguments.size(); @@ -321,6 +333,25 @@ List<ClassAPI> generate_c_api_classes() { } } + // enums + { + List<EnumAPI> enums; + List<StringName> enum_names; + ClassDB::get_enum_list(class_name, &enum_names, true); + for (List<StringName>::Element *E = enum_names.front(); E; E = E->next()) { + List<StringName> value_names; + EnumAPI enum_api; + enum_api.name = E->get(); + ClassDB::get_enum_constants(class_name, E->get(), &value_names, true); + for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) { + int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL); + enum_api.values.push_back(Pair<int, String>(int_val, val_e->get())); + } + enum_api.values.sort_custom<PairSort<int, String> >(); + class_api.enums.push_back(enum_api); + } + } + api.push_back(class_api); } @@ -410,11 +441,24 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back("\t\t\t\t]\n"); source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); } + source.push_back("\t\t],\n"); + + source.push_back("\t\t\"enums\": [\n"); + for (List<EnumAPI>::Element *e = api.enums.front(); e; e = e->next()) { + source.push_back("\t\t\t{\n"); + source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n"); + source.push_back("\t\t\t\t\"values\": {\n"); + for (List<Pair<int, String> >::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) { + source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first)); + source.push_back(String((val_e->next() ? "," : "")) + "\n"); + } + source.push_back("\t\t\t\t}\n"); + source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n"); + } source.push_back("\t\t]\n"); source.push_back(String("\t}") + (c->next() ? "," : "") + "\n"); } - source.push_back("]"); return source; diff --git a/modules/nativescript/config.py b/modules/nativescript/config.py index 4f89ca0d4c..9f57b9bb74 100644 --- a/modules/nativescript/config.py +++ b/modules/nativescript/config.py @@ -1,7 +1,7 @@ def can_build(platform): - return False + return True def configure(env): diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 7ab2a93b55..05ceb7a38f 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -886,8 +886,8 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); - undo_redo->add_do_method(this, "emit_signal", "script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "script_changed"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); // _update_graph(); @@ -903,8 +903,8 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, 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", "script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "script_changed"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); return; //or crash because it will become invalid @@ -918,8 +918,8 @@ void VisualScriptEditor::_member_edited() { undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, 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", "script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "script_changed"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); return; //or crash because it will become invalid @@ -1057,8 +1057,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt undo_redo->add_undo_method(this, "_update_members"); undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); - undo_redo->add_do_method(this, "emit_signal", "script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "script_changed"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); _update_graph(); @@ -1077,8 +1077,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt undo_redo->add_undo_method(script.ptr(), "remove_variable", 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", "script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "script_changed"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); return; //or crash because it will become invalid } @@ -1093,8 +1093,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt undo_redo->add_undo_method(script.ptr(), "remove_custom_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", "script_changed"); - undo_redo->add_undo_method(this, "emit_signal", "script_changed"); + undo_redo->add_do_method(this, "emit_signal", "edited_script_changed"); + undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed"); undo_redo->commit_action(); return; //or crash because it will become invalid } diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8b3a64bbe6..ef348d8685 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -204,7 +204,7 @@ class EditorExportAndroid : public EditorExportPlatform { String id; String name; String description; - int release; + int api_level; }; struct APKExportData { @@ -278,7 +278,7 @@ class EditorExportAndroid : public EditorExportPlatform { if (ea->devices[j].id == ldevices[i]) { d.description = ea->devices[j].description; d.name = ea->devices[j].name; - d.release = ea->devices[j].release; + d.api_level = ea->devices[j].api_level; } } @@ -299,7 +299,7 @@ class EditorExportAndroid : public EditorExportPlatform { String vendor; String device; d.description + "Device ID: " + d.id + "\n"; - d.release = 0; + d.api_level = 0; for (int j = 0; j < props.size(); j++) { String p = props[j]; @@ -310,9 +310,9 @@ class EditorExportAndroid : public EditorExportPlatform { } else if (p.begins_with("ro.build.display.id=")) { d.description += "Build: " + p.get_slice("=", 1).strip_edges() + "\n"; } else if (p.begins_with("ro.build.version.release=")) { - const String release_str = p.get_slice("=", 1).strip_edges(); - d.description += "Release: " + release_str + "\n"; - d.release = release_str.to_int(); + d.description += "Release: " + p.get_slice("=", 1).strip_edges() + "\n"; + } else if (p.begins_with("ro.build.version.sdk=")) { + d.api_level = p.get_slice("=", 1).to_int(); } else if (p.begins_with("ro.product.cpu.abi=")) { d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n"; } else if (p.begins_with("ro.product.manufacturer=")) { @@ -1073,7 +1073,11 @@ public: //export_temp ep.step("Exporting APK", 0); - p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; + const bool use_remote = (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) || (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT); + const bool use_reverse = devices[p_device].api_level >= 21; + + if (use_reverse) + p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk"; Error err = export_project(p_preset, true, export_to, p_debug_flags); @@ -1119,40 +1123,54 @@ public: return ERR_CANT_CREATE; } - if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) { + if (use_remote) { + if (use_reverse) { - args.clear(); - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("reverse"); - args.push_back("--remove-all"); - OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + static const char *const msg = "** Device API >= 21; debugging over USB **"; + EditorNode::get_singleton()->get_log()->add_message(msg); + print_line(String(msg).to_upper()); - int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port"); - args.clear(); - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("reverse"); - args.push_back("tcp:" + itos(dbg_port)); - args.push_back("tcp:" + itos(dbg_port)); + args.clear(); + args.push_back("-s"); + args.push_back(devices[p_device].id); + args.push_back("reverse"); + args.push_back("--remove-all"); + OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); - OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); - print_line("Reverse result: " + itos(rv)); - } + if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) { - if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) { + int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port"); + args.clear(); + args.push_back("-s"); + args.push_back(devices[p_device].id); + args.push_back("reverse"); + args.push_back("tcp:" + itos(dbg_port)); + args.push_back("tcp:" + itos(dbg_port)); - int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); + OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + print_line("Reverse result: " + itos(rv)); + } - args.clear(); - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("reverse"); - args.push_back("tcp:" + itos(fs_port)); - args.push_back("tcp:" + itos(fs_port)); + if (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT) { - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); - print_line("Reverse result2: " + itos(rv)); + int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); + + args.clear(); + args.push_back("-s"); + args.push_back(devices[p_device].id); + args.push_back("reverse"); + args.push_back("tcp:" + itos(fs_port)); + args.push_back("tcp:" + itos(fs_port)); + + err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + print_line("Reverse result2: " + itos(rv)); + } + } else { + + static const char *const msg = "** Device API < 21; debugging over Wi-Fi **"; + EditorNode::get_singleton()->get_log()->add_message(msg); + print_line(String(msg).to_upper()); + } } ep.step("Running on Device..", 3); @@ -1162,7 +1180,7 @@ public: args.push_back("shell"); args.push_back("am"); args.push_back("start"); - if ((bool)EditorSettings::get_singleton()->get("export/android/force_system_user") && devices[p_device].release >= 17) { // Multi-user introduced in Android 17 + if ((bool)EditorSettings::get_singleton()->get("export/android/force_system_user") && devices[p_device].api_level >= 17) { // Multi-user introduced in Android 17 args.push_back("--user"); args.push_back("0"); } diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 5bfed1ee50..ebaebd84ce 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -160,6 +160,8 @@ public: virtual MainLoop *get_main_loop() const; + virtual String get_system_dir(SystemDir p_dir) const; + virtual bool can_draw() const; virtual void set_clipboard(const String &p_text); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index f1260bc088..f502fb9a9c 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1327,6 +1327,46 @@ MainLoop *OS_OSX::get_main_loop() const { return main_loop; } +String OS_OSX::get_system_dir(SystemDir p_dir) const { + + NSSearchPathDirectory id = 0; + + switch (p_dir) { + case SYSTEM_DIR_DESKTOP: { + id = NSDesktopDirectory; + } break; + case SYSTEM_DIR_DOCUMENTS: { + id = NSDocumentDirectory; + } break; + case SYSTEM_DIR_DOWNLOADS: { + id = NSDownloadsDirectory; + } break; + case SYSTEM_DIR_MOVIES: { + id = NSMoviesDirectory; + } break; + case SYSTEM_DIR_MUSIC: { + id = NSMusicDirectory; + } break; + case SYSTEM_DIR_PICTURES: { + id = NSPicturesDirectory; + } break; + } + + String ret; + if (id) { + + NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES); + if (paths && [paths count] >= 1) { + + char *utfs = strdup([[paths firstObject] UTF8String]); + ret.parse_utf8(utfs); + free(utfs); + } + } + + return ret; +} + bool OS_OSX::can_draw() const { return true; diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 79778136ad..f355de0eb3 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -74,7 +74,9 @@ def configure(env): ## Build type if (env["target"] == "release"): - env.Prepend(CCFLAGS=['-Ofast']) + # -O3 -ffast-math is identical to -Ofast. We need to split it out so we can selectively disable + # -ffast-math in code for which it generates wrong results. + env.Prepend(CCFLAGS=['-O3', '-ffast-math']) if (env["debug_release"] == "yes"): env.Prepend(CCFLAGS=['-g2']) diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 3a99e917eb..5a0a9c6e6a 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -291,10 +291,10 @@ public: RID get_canvas() const; Ref<World2D> get_world_2d() const; - void set_material(const Ref<Material> &p_material); + virtual void set_material(const Ref<Material> &p_material); Ref<Material> get_material() const; - void set_use_parent_material(bool p_use_parent_material); + virtual void set_use_parent_material(bool p_use_parent_material); bool get_use_parent_material() const; Ref<InputEvent> make_input_local(const Ref<InputEvent> &p_event) const; diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index fa488b6b23..74d835dfb2 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -476,7 +476,6 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect Polygon *left_poly = end_poly; Polygon *right_poly = end_poly; Polygon *p = end_poly; - path.push_back(end_point); while (p) { @@ -534,7 +533,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect left_poly = p; portal_left = apex_point; portal_right = apex_point; - if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) + if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) path.push_back(apex_point); skip = true; //print_line("addpoint left"); @@ -555,7 +554,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect right_poly = p; portal_right = apex_point; portal_left = apex_point; - if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) + if (!path.size() || path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON) path.push_back(apex_point); //print_line("addpoint right"); //print_line("***CLIP RIGHT"); @@ -568,16 +567,10 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect p = NULL; } - if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON) - path.push_back(begin_point); - - path.invert(); - } else { //midpoints Polygon *p = end_poly; - path.push_back(end_point); while (true) { int prev = p->prev_edge; int prev_n = (p->prev_edge + 1) % p->edges.size(); @@ -587,11 +580,20 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect if (p == begin_poly) break; } + } - if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON) - path.push_back(begin_point); + if (!path.size() || path[path.size() - 1].distance_squared_to(begin_point) > CMP_EPSILON) { + path.push_back(begin_point); // Add the begin point + } else { + path[path.size() - 1] = begin_point; // Replace first midpoint by the exact begin point + } + + path.invert(); - path.invert(); + if (path.size() <= 1 || path[path.size() - 1].distance_squared_to(end_point) > CMP_EPSILON) { + path.push_back(end_point); // Add the end point + } else { + path[path.size() - 1] = end_point; // Replace last midpoint by the exact end point } return path; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index d41db1dce5..b1cc8c226a 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -336,6 +336,7 @@ void TileMap::_update_dirty_quadrants() { if (mat.is_valid()) vs->canvas_item_set_material(canvas_item, mat->get_rid()); vs->canvas_item_set_parent(canvas_item, get_canvas_item()); + _update_item_material_state(canvas_item); Transform2D xform; xform.set_origin(q.pos); vs->canvas_item_set_transform(canvas_item, xform); @@ -780,6 +781,35 @@ void TileMap::_clear_quadrants() { } } +void TileMap::set_material(const Ref<Material> &p_material) { + + CanvasItem::set_material(p_material); + _update_all_items_material_state(); +} + +void TileMap::set_use_parent_material(bool p_use_parent_material) { + + CanvasItem::set_use_parent_material(p_use_parent_material); + _update_all_items_material_state(); +} + +void TileMap::_update_all_items_material_state() { + + for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) { + + Quadrant &q = E->get(); + for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) { + + _update_item_material_state(E->get()); + } + } +} + +void TileMap::_update_item_material_state(const RID &p_canvas_item) { + + VS::get_singleton()->canvas_item_set_use_parent_material(p_canvas_item, get_use_parent_material() || get_material().is_valid()); +} + void TileMap::clear() { _clear_quadrants(); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index f401d51eeb..c9d14e09d1 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -183,6 +183,9 @@ private: void _update_quadrant_transform(); void _recompute_rect_cache(); + void _update_all_items_material_state(); + _FORCE_INLINE_ void _update_item_material_state(const RID &p_canvas_item); + _FORCE_INLINE_ int _get_quadrant_size() const; void _set_tile_data(const PoolVector<int> &p_data); @@ -278,6 +281,10 @@ public: virtual void set_light_mask(int p_light_mask); + virtual void set_material(const Ref<Material> &p_material); + + virtual void set_use_parent_material(bool p_use_parent_material); + void clear(); TileMap(); diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index 545be8bc5f..caf313190b 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -264,7 +264,7 @@ void ARVRAnchor::_notification(int p_what) { // our basis is scaled to the size of the plane the anchor is tracking // extract the size from our basis and reset the scale size = transform.basis.get_scale() * world_scale; - transform.basis.set_scale(Vector3(1.0, 1.0, 1.0)); + transform.basis.orthonormalize(); // apply our reference frame and set our transform set_transform(arvr_server->get_reference_frame() * transform); diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 5b48ee4af8..09b253b309 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -334,6 +334,7 @@ void DirectionalLight::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_split_3", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_param", "get_param", PARAM_SHADOW_SPLIT_3_OFFSET); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE); BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL); BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS); @@ -343,9 +344,10 @@ void DirectionalLight::_bind_methods() { DirectionalLight::DirectionalLight() : Light(VisualServer::LIGHT_DIRECTIONAL) { - set_param(PARAM_SHADOW_NORMAL_BIAS, 0.2); - set_param(PARAM_SHADOW_BIAS, 1.0); + set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8); + set_param(PARAM_SHADOW_BIAS, 0.1); set_param(PARAM_SHADOW_MAX_DISTANCE, 200); + set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25); set_shadow_mode(SHADOW_PARALLEL_4_SPLITS); blend_splits = false; diff --git a/scene/3d/light.h b/scene/3d/light.h index 93dd4828da..5d589d33e5 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -58,6 +58,7 @@ public: PARAM_SHADOW_SPLIT_3_OFFSET = VS::LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET, PARAM_SHADOW_NORMAL_BIAS = VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS, PARAM_SHADOW_BIAS = VS::LIGHT_PARAM_SHADOW_BIAS, + PARAM_SHADOW_BIAS_SPLIT_SCALE = VS::LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE, PARAM_MAX = VS::LIGHT_PARAM_MAX }; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 3cd953773f..fb61c43d5c 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -560,12 +560,16 @@ void Tween::_tween_process(float p_delta) { switch (data.type) { case INTER_PROPERTY: - case INTER_METHOD: - break; + case INTER_METHOD: { + Variant result = _run_equation(data); + emit_signal("tween_step", object, data.key, data.elapsed, result); + _apply_tween_value(data, result); + if (data.finish) + _apply_tween_value(data, data.final_val); + } break; + case INTER_CALLBACK: if (data.finish) { - - Variant::CallError error; if (data.call_deferred) { switch (data.args) { @@ -588,8 +592,8 @@ void Tween::_tween_process(float p_delta) { object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]); break; } - } else { + Variant::CallError error; Variant *arg[5] = { &data.arg[0], &data.arg[1], @@ -599,19 +603,11 @@ void Tween::_tween_process(float p_delta) { }; object->call(data.key, (const Variant **)arg, data.args, error); } - if (!repeat) - call_deferred("_remove", object, data.key, true); } - continue; + break; } - Variant result = _run_equation(data); - emit_signal("tween_step", object, data.key, data.elapsed, result); - - _apply_tween_value(data, result); - if (data.finish) { - _apply_tween_value(data, data.final_val); emit_signal("tween_completed", object, data.key); // not repeat mode, remove completed action if (!repeat) diff --git a/servers/visual_server.h b/servers/visual_server.h index 9f2d685531..acf5675aa5 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -358,6 +358,7 @@ public: LIGHT_PARAM_SHADOW_SPLIT_3_OFFSET, LIGHT_PARAM_SHADOW_NORMAL_BIAS, LIGHT_PARAM_SHADOW_BIAS, + LIGHT_PARAM_SHADOW_BIAS_SPLIT_SCALE, LIGHT_PARAM_MAX }; |