Skip to content

Commit 494fe2f

Browse files
committed
LOD: Remove "Raycast Normals" and associated "Normal Split Angle" settings
"Raycast Normals" was introduced in 4.4 dev and defaulted to "false". The limited testing results at the time suggested that raycasting generally reduces normal quality compared to native simplifier results, at the same time increasing vertex memory and import time. To play it safe, we introduced a setting that defaulted to false, with the goal of removing it later in 4.4 development cycle if no regressions are noticed. Since we already had three dev snapshots and no reports, this change removes the setting and associated code. "Normal Split Angle" was only used when raycast normals were enabled; this change removes it from the settings, but keeps it in the script binding for compatibility. Existing meshes import exactly the same after this change (unless they chose to override raycasting which would be surprising). split_normals helper was only used in this code path and is also removed for simplicity; it is unlikely that this code will be useful as is, as it can only regenerate normals without fixing tangents or updating positions.
1 parent a308047 commit 494fe2f

File tree

5 files changed

+9
-309
lines changed

5 files changed

+9
-309
lines changed

doc/classes/ImporterMesh.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
<param index="2" name="bone_transform_array" type="Array" />
5050
<description>
5151
Generates all lods for this ImporterMesh.
52-
[param normal_merge_angle] and [param normal_split_angle] are in degrees and used in the same way as the importer settings in [code]lods[/code]. As a good default, use 25 and 60 respectively.
52+
[param normal_merge_angle] is in degrees and used in the same way as the importer settings in [code]lods[/code].
53+
[param normal_split_angle] is not used and only remains for compatibility with older versions of the API.
5354
The number of generated lods can be accessed using [method get_surface_lod_count], and each LOD is available in [method get_surface_lod_size] and [method get_surface_lod_indices].
5455
[param bone_transform_array] is an [Array] which can be either empty or contain [Transform3D]s which, for each of the mesh's bone IDs, will apply mesh skinning when generating the LOD mesh variations. This is usually used to account for discrepancies in scale between the mesh itself and its skinning data.
5556
</description>

editor/import/3d/resource_importer_obj.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,
539539

540540
if (p_generate_lods) {
541541
// Use normal merge/split angles that match the defaults used for 3D scene importing.
542-
mesh->generate_lods(60.0f, 25.0f, {});
542+
mesh->generate_lods(60.0f, {});
543543
}
544544

545545
if (p_generate_shadow_mesh) {

editor/import/3d/resource_importer_scene.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,9 +2043,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
20432043
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/shadow_meshes", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
20442044
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lightmap_uv", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
20452045
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lods", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
2046-
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_split_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 25.0f));
20472046
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_merge_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 60.0f));
2048-
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "lods/raycast_normals", PROPERTY_HINT_NONE, ""), false));
20492047
} break;
20502048
case INTERNAL_IMPORT_CATEGORY_MATERIAL: {
20512049
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "use_external/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
@@ -2474,9 +2472,7 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
24742472
//do mesh processing
24752473

24762474
bool generate_lods = p_generate_lods;
2477-
float split_angle = 25.0f;
24782475
float merge_angle = 60.0f;
2479-
bool raycast_normals = false;
24802476
bool create_shadow_meshes = p_create_shadow_meshes;
24812477
bool bake_lightmaps = p_light_bake_mode == LIGHT_BAKE_STATIC_LIGHTMAPS;
24822478
String save_to_file;
@@ -2523,18 +2519,10 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
25232519
}
25242520
}
25252521

2526-
if (mesh_settings.has("lods/normal_split_angle")) {
2527-
split_angle = mesh_settings["lods/normal_split_angle"];
2528-
}
2529-
25302522
if (mesh_settings.has("lods/normal_merge_angle")) {
25312523
merge_angle = mesh_settings["lods/normal_merge_angle"];
25322524
}
25332525

2534-
if (mesh_settings.has("lods/raycast_normals")) {
2535-
raycast_normals = mesh_settings["lods/raycast_normals"];
2536-
}
2537-
25382526
if (bool(mesh_settings.get("save_to_file/enabled", false))) {
25392527
save_to_file = mesh_settings.get("save_to_file/path", String());
25402528
if (!save_to_file.is_resource_file()) {
@@ -2583,7 +2571,7 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
25832571

25842572
if (generate_lods) {
25852573
Array skin_pose_transform_array = _get_skinned_pose_transforms(src_mesh_node);
2586-
src_mesh_node->get_mesh()->generate_lods(merge_angle, split_angle, skin_pose_transform_array, raycast_normals);
2574+
src_mesh_node->get_mesh()->generate_lods(merge_angle, skin_pose_transform_array);
25872575
}
25882576

25892577
if (create_shadow_meshes) {

0 commit comments

Comments
 (0)