diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-11-12 13:46:08 -0500 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-12 13:46:59 -0500 |
commit | 3a73c6ebd18bff0fa125be58d3ac9c7a63bab61d (patch) | |
tree | c7341bd56c977259578b127886c9a88eeef11820 /scene/resources | |
parent | 5094c2a5f7d506b0e685120f14d1df42e1e9d495 (diff) | |
parent | cb411fa960f0b7fdbd97dcdb4c90f9346360ee0e (diff) | |
download | redot-engine-3a73c6ebd18bff0fa125be58d3ac9c7a63bab61d.tar.gz |
Merge commit godotengine/godot@cb411fa960f0b7fdbd97dcdb4c90f9346360ee0e
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/2d/navigation_mesh_source_geometry_data_2d.h | 2 | ||||
-rw-r--r-- | scene/resources/3d/shape_3d.cpp | 2 | ||||
-rw-r--r-- | scene/resources/curve.cpp | 21 | ||||
-rw-r--r-- | scene/resources/mesh.cpp | 2 | ||||
-rw-r--r-- | scene/resources/navigation_mesh.cpp | 4 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 4 | ||||
-rw-r--r-- | scene/resources/portable_compressed_texture.cpp | 4 | ||||
-rw-r--r-- | scene/resources/resource_format_text.cpp | 4 | ||||
-rw-r--r-- | scene/resources/resource_format_text.h | 1 | ||||
-rw-r--r-- | scene/resources/texture_rd.cpp | 2 |
10 files changed, 37 insertions, 9 deletions
diff --git a/scene/resources/2d/navigation_mesh_source_geometry_data_2d.h b/scene/resources/2d/navigation_mesh_source_geometry_data_2d.h index 98c6c67c99..89167b5e98 100644 --- a/scene/resources/2d/navigation_mesh_source_geometry_data_2d.h +++ b/scene/resources/2d/navigation_mesh_source_geometry_data_2d.h @@ -38,6 +38,8 @@ #include "scene/resources/2d/navigation_polygon.h" class NavigationMeshSourceGeometryData2D : public Resource { + friend class NavMeshGenerator2D; + GDCLASS(NavigationMeshSourceGeometryData2D, Resource); RWLock geometry_rwlock; diff --git a/scene/resources/3d/shape_3d.cpp b/scene/resources/3d/shape_3d.cpp index 8c5a260cb9..04f1653d2e 100644 --- a/scene/resources/3d/shape_3d.cpp +++ b/scene/resources/3d/shape_3d.cpp @@ -75,7 +75,7 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() { Vector<Vector3> lines = get_debug_mesh_lines(); - debug_mesh_cache = Ref<ArrayMesh>(memnew(ArrayMesh)); + debug_mesh_cache.instantiate(); if (!lines.is_empty()) { //make mesh diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index c2880f0072..e7e8d88b51 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -481,6 +481,9 @@ void Curve::set_bake_resolution(int p_resolution) { } real_t Curve::sample_baked(real_t p_offset) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), 0, "Offset is non-finite"); + if (_baked_cache_dirty) { // Last-second bake if not done already const_cast<Curve *>(this)->bake(); @@ -983,6 +986,9 @@ Transform2D Curve2D::_sample_posture(Interval p_interval) const { } Vector2 Curve2D::sample_baked(real_t p_offset, bool p_cubic) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), Vector2(), "Offset is non-finite"); + if (baked_cache_dirty) { _bake(); } @@ -1002,6 +1008,9 @@ Vector2 Curve2D::sample_baked(real_t p_offset, bool p_cubic) const { } Transform2D Curve2D::sample_baked_with_rotation(real_t p_offset, bool p_cubic) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), Transform2D(), "Offset is non-finite"); + if (baked_cache_dirty) { _bake(); } @@ -1883,6 +1892,9 @@ Basis Curve3D::get_point_baked_posture(int p_index, bool p_apply_tilt) const { #endif Vector3 Curve3D::sample_baked(real_t p_offset, bool p_cubic) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), Vector3(), "Offset is non-finite"); + if (baked_cache_dirty) { _bake(); } @@ -1902,6 +1914,9 @@ Vector3 Curve3D::sample_baked(real_t p_offset, bool p_cubic) const { } Transform3D Curve3D::sample_baked_with_rotation(real_t p_offset, bool p_cubic, bool p_apply_tilt) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), Transform3D(), "Offset is non-finite"); + if (baked_cache_dirty) { _bake(); } @@ -1931,6 +1946,9 @@ Transform3D Curve3D::sample_baked_with_rotation(real_t p_offset, bool p_cubic, b } real_t Curve3D::sample_baked_tilt(real_t p_offset) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), 0, "Offset is non-finite"); + if (baked_cache_dirty) { _bake(); } @@ -1950,6 +1968,9 @@ real_t Curve3D::sample_baked_tilt(real_t p_offset) const { } Vector3 Curve3D::sample_baked_up_vector(real_t p_offset, bool p_apply_tilt) const { + // Make sure that p_offset is finite. + ERR_FAIL_COND_V_MSG(!Math::is_finite(p_offset), Vector3(0, 1, 0), "Offset is non-finite"); + if (baked_cache_dirty) { _bake(); } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 53ff75294b..c62adbd1da 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -387,7 +387,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const { } } - triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); + triangle_mesh.instantiate(); triangle_mesh->create(faces); return triangle_mesh; diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp index f76b9d8325..95acc159d8 100644 --- a/scene/resources/navigation_mesh.cpp +++ b/scene/resources/navigation_mesh.cpp @@ -394,8 +394,8 @@ Ref<ArrayMesh> NavigationMesh::get_debug_mesh() { return debug_mesh; } - if (!debug_mesh.is_valid()) { - debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); + if (debug_mesh.is_null()) { + debug_mesh.instantiate(); } else { debug_mesh->clear_surfaces(); } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 723f3a7a2c..fa37805a7a 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -2197,7 +2197,7 @@ void PackedScene::replace_state(Ref<SceneState> p_by) { } void PackedScene::recreate_state() { - state = Ref<SceneState>(memnew(SceneState)); + state.instantiate(); state->set_path(get_path()); #ifdef TOOLS_ENABLED state->set_last_modified_time(get_last_modified_time()); @@ -2288,5 +2288,5 @@ void PackedScene::_bind_methods() { } PackedScene::PackedScene() { - state = Ref<SceneState>(memnew(SceneState)); + state.instantiate(); } diff --git a/scene/resources/portable_compressed_texture.cpp b/scene/resources/portable_compressed_texture.cpp index f1de15179e..89d7c46faa 100644 --- a/scene/resources/portable_compressed_texture.cpp +++ b/scene/resources/portable_compressed_texture.cpp @@ -91,7 +91,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) { data_size -= mipsize; } - image = Ref<Image>(memnew(Image(size.width, size.height, mipmaps, format, image_data))); + image.instantiate(size.width, size.height, mipmaps, format, image_data); } break; case COMPRESSION_MODE_BASIS_UNIVERSAL: { @@ -102,7 +102,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) { case COMPRESSION_MODE_S3TC: case COMPRESSION_MODE_ETC2: case COMPRESSION_MODE_BPTC: { - image = Ref<Image>(memnew(Image(size.width, size.height, mipmaps, format, p_data.slice(20)))); + image.instantiate(size.width, size.height, mipmaps, format, p_data.slice(20)); } break; } ERR_FAIL_COND(image.is_null()); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 52bc866fb0..23d972eb96 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1528,6 +1528,10 @@ ResourceUID::ID ResourceFormatLoaderText::get_resource_uid(const String &p_path) return loader.get_uid(f); } +bool ResourceFormatLoaderText::has_custom_uid_support() const { + return true; +} + void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ); if (f.is_null()) { diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index c7c48f16a5..0dc801d28d 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -157,6 +157,7 @@ public: virtual String get_resource_type(const String &p_path) const override; virtual String get_resource_script_class(const String &p_path) const override; virtual ResourceUID::ID get_resource_uid(const String &p_path) const override; + virtual bool has_custom_uid_support() const override; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false) override; virtual Error rename_dependencies(const String &p_path, const HashMap<String, String> &p_map) override; diff --git a/scene/resources/texture_rd.cpp b/scene/resources/texture_rd.cpp index 65783f4d1c..0882a3d349 100644 --- a/scene/resources/texture_rd.cpp +++ b/scene/resources/texture_rd.cpp @@ -199,7 +199,7 @@ void TextureLayeredRD::_set_texture_rd_rid(RID p_texture_rd_rid) { RS::TextureLayeredType rs_layer_type; RD::TextureFormat tf = RD::get_singleton()->texture_get_format(p_texture_rd_rid); - ERR_FAIL_COND(tf.texture_type != RD::TEXTURE_TYPE_2D_ARRAY); + ERR_FAIL_COND(tf.texture_type != RD::TEXTURE_TYPE_2D_ARRAY && tf.texture_type != RD::TEXTURE_TYPE_CUBE && tf.texture_type != RD::TEXTURE_TYPE_CUBE_ARRAY); ERR_FAIL_COND(tf.depth > 1); switch (layer_type) { case LAYERED_TYPE_2D_ARRAY: { |