diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/environment.cpp | 19 | ||||
-rw-r--r-- | scene/resources/environment.h | 3 | ||||
-rw-r--r-- | scene/resources/font.cpp | 6 | ||||
-rw-r--r-- | scene/resources/importer_mesh.cpp | 45 | ||||
-rw-r--r-- | scene/resources/importer_mesh.h | 1 | ||||
-rw-r--r-- | scene/resources/mesh.cpp | 2 | ||||
-rw-r--r-- | scene/resources/skeleton_modification_stack_2d.cpp | 2 | ||||
-rw-r--r-- | scene/resources/skeleton_modification_stack_3d.cpp | 2 | ||||
-rw-r--r-- | scene/resources/sky_material.cpp | 14 | ||||
-rw-r--r-- | scene/resources/tile_set.cpp | 11 | ||||
-rw-r--r-- | scene/resources/tile_set.h | 1 |
11 files changed, 54 insertions, 52 deletions
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index cab6c0378a..9a3f081a8b 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -173,23 +173,13 @@ Environment::ReflectionSource Environment::get_reflection_source() const { return reflection_source; } -void Environment::set_ao_color(const Color &p_color) { - ao_color = p_color; - _update_ambient_light(); -} - -Color Environment::get_ao_color() const { - return ao_color; -} - void Environment::_update_ambient_light() { RS::get_singleton()->environment_set_ambient_light( environment, ambient_color, RS::EnvironmentAmbientSource(ambient_source), ambient_energy, - ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source), - ao_color); + ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source)); } // Tonemap @@ -302,7 +292,7 @@ int Environment::get_ssr_max_steps() const { } void Environment::set_ssr_fade_in(float p_fade_in) { - ssr_fade_in = p_fade_in; + ssr_fade_in = MAX(p_fade_in, 0.0f); _update_ssr(); } @@ -311,7 +301,7 @@ float Environment::get_ssr_fade_in() const { } void Environment::set_ssr_fade_out(float p_fade_out) { - ssr_fade_out = p_fade_out; + ssr_fade_out = MAX(p_fade_out, 0.0f); _update_ssr(); } @@ -1092,15 +1082,12 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution); ClassDB::bind_method(D_METHOD("set_reflection_source", "source"), &Environment::set_reflection_source); ClassDB::bind_method(D_METHOD("get_reflection_source"), &Environment::get_reflection_source); - ClassDB::bind_method(D_METHOD("set_ao_color", "color"), &Environment::set_ao_color); - ClassDB::bind_method(D_METHOD("get_ao_color"), &Environment::get_ao_color); ADD_GROUP("Ambient Light", "ambient_light_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "ambient_light_source", PROPERTY_HINT_ENUM, "Background,Disabled,Color,Sky"), "set_ambient_source", "get_ambient_source"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_light_color"), "set_ambient_light_color", "get_ambient_light_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_light_sky_contribution", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ambient_light_sky_contribution", "get_ambient_light_sky_contribution"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_light_energy", "get_ambient_light_energy"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_light_occlusion_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ao_color", "get_ao_color"); ADD_GROUP("Reflected Light", "reflected_light_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "reflected_light_source", PROPERTY_HINT_ENUM, "Background,Disabled,Sky"), "set_reflection_source", "get_reflection_source"); diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 0df2c3cc27..46842754f4 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -116,7 +116,6 @@ private: float ambient_energy = 1.0; float ambient_sky_contribution = 1.0; ReflectionSource reflection_source = REFLECTION_SOURCE_BG; - Color ao_color; void _update_ambient_light(); // Tonemap @@ -250,8 +249,6 @@ public: float get_ambient_light_sky_contribution() const; void set_reflection_source(ReflectionSource p_source); ReflectionSource get_reflection_source() const; - void set_ao_color(const Color &p_color); - Color get_ao_color() const; // Tonemap void set_tonemapper(ToneMapper p_tone_mapper); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index c1d42dff09..04e2b0dc70 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -116,8 +116,8 @@ void FontData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_scale", "cache_index", "size", "scale"), &FontData::set_scale); ClassDB::bind_method(D_METHOD("get_scale", "cache_index", "size"), &FontData::get_scale); - ClassDB::bind_method(D_METHOD("set_spacing", "cache_index", "size", "spacing"), &FontData::set_spacing); - ClassDB::bind_method(D_METHOD("get_spacing", "cache_index", "size"), &FontData::get_spacing); + ClassDB::bind_method(D_METHOD("set_spacing", "cache_index", "size", "spacing_type", "value"), &FontData::set_spacing); + ClassDB::bind_method(D_METHOD("get_spacing", "cache_index", "size", "spacing_type"), &FontData::get_spacing); ClassDB::bind_method(D_METHOD("get_texture_count", "cache_index", "size"), &FontData::get_texture_count); ClassDB::bind_method(D_METHOD("clear_textures", "cache_index", "size"), &FontData::clear_textures); @@ -175,7 +175,7 @@ void FontData::_bind_methods() { ClassDB::bind_method(D_METHOD("has_char", "char"), &FontData::has_char); ClassDB::bind_method(D_METHOD("get_supported_chars"), &FontData::get_supported_chars); - ClassDB::bind_method(D_METHOD("get_glyph_index", "char", "variation_selector"), &FontData::get_glyph_index); + ClassDB::bind_method(D_METHOD("get_glyph_index", "size", "char", "variation_selector"), &FontData::get_glyph_index); ClassDB::bind_method(D_METHOD("get_supported_feature_list"), &FontData::get_supported_feature_list); ClassDB::bind_method(D_METHOD("get_supported_variation_list"), &FontData::get_supported_variation_list); diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index af69b799cc..2572c5de33 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -37,26 +37,34 @@ #include <cstdint> void ImporterMesh::Surface::split_normals(const LocalVector<int> &p_indices, const LocalVector<Vector3> &p_normals) { - ERR_FAIL_COND(arrays.size() != RS::ARRAY_MAX); + _split_normals(arrays, p_indices, p_normals); - const PackedVector3Array &vertices = arrays[RS::ARRAY_VERTEX]; + for (BlendShape &blend_shape : blend_shape_data) { + _split_normals(blend_shape.arrays, p_indices, p_normals); + } +} + +void ImporterMesh::Surface::_split_normals(Array &r_arrays, const LocalVector<int> &p_indices, const LocalVector<Vector3> &p_normals) { + ERR_FAIL_COND(r_arrays.size() != RS::ARRAY_MAX); + + const PackedVector3Array &vertices = r_arrays[RS::ARRAY_VERTEX]; int current_vertex_count = vertices.size(); int new_vertex_count = p_indices.size(); int final_vertex_count = current_vertex_count + new_vertex_count; const int *indices_ptr = p_indices.ptr(); - for (int i = 0; i < arrays.size(); i++) { + for (int i = 0; i < r_arrays.size(); i++) { if (i == RS::ARRAY_INDEX) { continue; } - if (arrays[i].get_type() == Variant::NIL) { + if (r_arrays[i].get_type() == Variant::NIL) { continue; } - switch (arrays[i].get_type()) { + switch (r_arrays[i].get_type()) { case Variant::PACKED_VECTOR3_ARRAY: { - PackedVector3Array data = arrays[i]; + PackedVector3Array data = r_arrays[i]; data.resize(final_vertex_count); Vector3 *data_ptr = data.ptrw(); if (i == RS::ARRAY_NORMAL) { @@ -67,55 +75,55 @@ void ImporterMesh::Surface::split_normals(const LocalVector<int> &p_indices, con data_ptr[current_vertex_count + j] = data_ptr[indices_ptr[j]]; } } - arrays[i] = data; + r_arrays[i] = data; } break; case Variant::PACKED_VECTOR2_ARRAY: { - PackedVector2Array data = arrays[i]; + PackedVector2Array data = r_arrays[i]; data.resize(final_vertex_count); Vector2 *data_ptr = data.ptrw(); for (int j = 0; j < new_vertex_count; j++) { data_ptr[current_vertex_count + j] = data_ptr[indices_ptr[j]]; } - arrays[i] = data; + r_arrays[i] = data; } break; case Variant::PACKED_FLOAT32_ARRAY: { - PackedFloat32Array data = arrays[i]; + PackedFloat32Array data = r_arrays[i]; int elements = data.size() / current_vertex_count; data.resize(final_vertex_count * elements); float *data_ptr = data.ptrw(); for (int j = 0; j < new_vertex_count; j++) { memcpy(&data_ptr[(current_vertex_count + j) * elements], &data_ptr[indices_ptr[j] * elements], sizeof(float) * elements); } - arrays[i] = data; + r_arrays[i] = data; } break; case Variant::PACKED_INT32_ARRAY: { - PackedInt32Array data = arrays[i]; + PackedInt32Array data = r_arrays[i]; int elements = data.size() / current_vertex_count; data.resize(final_vertex_count * elements); int32_t *data_ptr = data.ptrw(); for (int j = 0; j < new_vertex_count; j++) { memcpy(&data_ptr[(current_vertex_count + j) * elements], &data_ptr[indices_ptr[j] * elements], sizeof(int32_t) * elements); } - arrays[i] = data; + r_arrays[i] = data; } break; case Variant::PACKED_BYTE_ARRAY: { - PackedByteArray data = arrays[i]; + PackedByteArray data = r_arrays[i]; int elements = data.size() / current_vertex_count; data.resize(final_vertex_count * elements); uint8_t *data_ptr = data.ptrw(); for (int j = 0; j < new_vertex_count; j++) { memcpy(&data_ptr[(current_vertex_count + j) * elements], &data_ptr[indices_ptr[j] * elements], sizeof(uint8_t) * elements); } - arrays[i] = data; + r_arrays[i] = data; } break; case Variant::PACKED_COLOR_ARRAY: { - PackedColorArray data = arrays[i]; + PackedColorArray data = r_arrays[i]; data.resize(final_vertex_count); Color *data_ptr = data.ptrw(); for (int j = 0; j < new_vertex_count; j++) { data_ptr[current_vertex_count + j] = data_ptr[indices_ptr[j]]; } - arrays[i] = data; + r_arrays[i] = data; } break; default: { ERR_FAIL_MSG("Unhandled array type."); @@ -261,9 +269,6 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli if (surfaces[i].primitive != Mesh::PRIMITIVE_TRIANGLES) { continue; } - if (get_blend_shape_count()) { - continue; - } surfaces.write[i].lods.clear(); Vector<Vector3> vertices = surfaces[i].arrays[RS::ARRAY_VERTEX]; diff --git a/scene/resources/importer_mesh.h b/scene/resources/importer_mesh.h index 89909f17f0..8576312a8a 100644 --- a/scene/resources/importer_mesh.h +++ b/scene/resources/importer_mesh.h @@ -70,6 +70,7 @@ class ImporterMesh : public Resource { }; void split_normals(const LocalVector<int> &p_indices, const LocalVector<Vector3> &p_normals); + static void _split_normals(Array &r_arrays, const LocalVector<int> &p_indices, const LocalVector<Vector3> &p_normals); }; Vector<Surface> surfaces; Vector<String> blend_shapes; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 18e6a51118..7ffe0b03e1 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1577,7 +1577,7 @@ void ArrayMesh::regen_normal_maps() { } //dirty hack -bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, const uint8_t *p_cache_data, bool *r_use_cache, uint8_t **r_mesh_cache, int *r_mesh_cache_size, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) = NULL; +bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, int p_index_count, const uint8_t *p_cache_data, bool *r_use_cache, uint8_t **r_mesh_cache, int *r_mesh_cache_size, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) = nullptr; struct ArrayMeshLightmapSurface { Ref<Material> material; diff --git a/scene/resources/skeleton_modification_stack_2d.cpp b/scene/resources/skeleton_modification_stack_2d.cpp index 72c1c330ef..db9fe62b4d 100644 --- a/scene/resources/skeleton_modification_stack_2d.cpp +++ b/scene/resources/skeleton_modification_stack_2d.cpp @@ -247,7 +247,7 @@ void SkeletonModificationStack2D::_bind_methods() { ClassDB::bind_method(D_METHOD("delete_modification", "mod_idx"), &SkeletonModificationStack2D::delete_modification); ClassDB::bind_method(D_METHOD("set_modification", "mod_idx", "modification"), &SkeletonModificationStack2D::set_modification); - ClassDB::bind_method(D_METHOD("set_modification_count"), &SkeletonModificationStack2D::set_modification_count); + ClassDB::bind_method(D_METHOD("set_modification_count", "count"), &SkeletonModificationStack2D::set_modification_count); ClassDB::bind_method(D_METHOD("get_modification_count"), &SkeletonModificationStack2D::get_modification_count); ClassDB::bind_method(D_METHOD("get_is_setup"), &SkeletonModificationStack2D::get_is_setup); diff --git a/scene/resources/skeleton_modification_stack_3d.cpp b/scene/resources/skeleton_modification_stack_3d.cpp index 3fce0e5dbd..a724b732b9 100644 --- a/scene/resources/skeleton_modification_stack_3d.cpp +++ b/scene/resources/skeleton_modification_stack_3d.cpp @@ -200,7 +200,7 @@ void SkeletonModificationStack3D::_bind_methods() { ClassDB::bind_method(D_METHOD("delete_modification", "mod_idx"), &SkeletonModificationStack3D::delete_modification); ClassDB::bind_method(D_METHOD("set_modification", "mod_idx", "modification"), &SkeletonModificationStack3D::set_modification); - ClassDB::bind_method(D_METHOD("set_modification_count"), &SkeletonModificationStack3D::set_modification_count); + ClassDB::bind_method(D_METHOD("set_modification_count", "count"), &SkeletonModificationStack3D::set_modification_count); ClassDB::bind_method(D_METHOD("get_modification_count"), &SkeletonModificationStack3D::get_modification_count); ClassDB::bind_method(D_METHOD("get_is_setup"), &SkeletonModificationStack3D::get_is_setup); diff --git a/scene/resources/sky_material.cpp b/scene/resources/sky_material.cpp index b6d3c96cb7..de94c92cac 100644 --- a/scene/resources/sky_material.cpp +++ b/scene/resources/sky_material.cpp @@ -175,14 +175,14 @@ void ProceduralSkyMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("get_sun_curve"), &ProceduralSkyMaterial::get_sun_curve); ADD_GROUP("Sky", "sky_"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_top_color"), "set_sky_top_color", "get_sky_top_color"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_horizon_color"), "set_sky_horizon_color", "get_sky_horizon_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_top_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_sky_top_color", "get_sky_top_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_horizon_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_sky_horizon_color", "get_sky_horizon_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sky_curve", PROPERTY_HINT_EXP_EASING), "set_sky_curve", "get_sky_curve"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sky_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sky_energy", "get_sky_energy"); ADD_GROUP("Ground", "ground_"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_bottom_color"), "set_ground_bottom_color", "get_ground_bottom_color"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_horizon_color"), "set_ground_horizon_color", "get_ground_horizon_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_bottom_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ground_bottom_color", "get_ground_bottom_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_horizon_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ground_horizon_color", "get_ground_horizon_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ground_curve", PROPERTY_HINT_EXP_EASING), "set_ground_curve", "get_ground_curve"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ground_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_ground_energy", "get_ground_energy"); @@ -531,16 +531,16 @@ void PhysicalSkyMaterial::_bind_methods() { ADD_GROUP("Rayleigh", "rayleigh_"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rayleigh_coefficient", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_rayleigh_coefficient", "get_rayleigh_coefficient"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "rayleigh_color"), "set_rayleigh_color", "get_rayleigh_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "rayleigh_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_rayleigh_color", "get_rayleigh_color"); ADD_GROUP("Mie", "mie_"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mie_coefficient", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_mie_coefficient", "get_mie_coefficient"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mie_eccentricity", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_mie_eccentricity", "get_mie_eccentricity"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "mie_color"), "set_mie_color", "get_mie_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "mie_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_mie_color", "get_mie_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "turbidity", PROPERTY_HINT_RANGE, "0,1000,0.01"), "set_turbidity", "get_turbidity"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sun_disk_scale", PROPERTY_HINT_RANGE, "0,360,0.01"), "set_sun_disk_scale", "get_sun_disk_scale"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_color"), "set_ground_color", "get_ground_color"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ground_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ground_color", "get_ground_color"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "exposure", PROPERTY_HINT_RANGE, "0,128,0.01"), "set_exposure", "get_exposure"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dither_strength", PROPERTY_HINT_RANGE, "0,10,0.01"), "set_dither_strength", "get_dither_strength"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "night_sky", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_night_sky", "get_night_sky"); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 40eedb63c1..f5e52b70e6 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -72,6 +72,7 @@ void TileSet::set_tile_shape(TileSet::TileShape p_shape) { terrain_bits_meshes_dirty = true; tile_meshes_dirty = true; + notify_property_list_changed(); emit_changed(); } TileSet::TileShape TileSet::get_tile_shape() const { @@ -170,6 +171,8 @@ void TileSet::set_source_id(int p_source_id, int p_new_source_id) { source_ids.append(p_new_source_id); source_ids.sort(); + _compute_next_source_id(); + emit_changed(); } @@ -2685,6 +2688,14 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::ARRAY, "tile_proxies/alternative_level", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } +void TileSet::_validate_property(PropertyInfo &property) const { + if (property.name == "tile_layout" && tile_shape == TILE_SHAPE_SQUARE) { + property.usage ^= PROPERTY_USAGE_READ_ONLY; + } else if (property.name == "tile_offset_axis" && tile_shape == TILE_SHAPE_SQUARE) { + property.usage ^= PROPERTY_USAGE_READ_ONLY; + } +} + void TileSet::_bind_methods() { // Sources management. ClassDB::bind_method(D_METHOD("get_next_source_id"), &TileSet::get_next_source_id); diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 2b4929b3df..716b66405f 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -180,6 +180,7 @@ protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; + virtual void _validate_property(PropertyInfo &property) const override; private: // --- TileSet data --- |