Skip to content

Commit

Permalink
Merge pull request godotengine#98620 from zeux/lodgen-cleanup
Browse files Browse the repository at this point in the history
LOD: Remove "Raycast Normals" and associated "Normal Split Angle" settings
  • Loading branch information
clayjohn authored Oct 31, 2024
2 parents a997001 + 494fe2f commit 7187c25
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 309 deletions.
3 changes: 2 additions & 1 deletion doc/classes/ImporterMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<param index="2" name="bone_transform_array" type="Array" />
<description>
Generates all lods for this ImporterMesh.
[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.
[param normal_merge_angle] is in degrees and used in the same way as the importer settings in [code]lods[/code].
[param normal_split_angle] is not used and only remains for compatibility with older versions of the API.
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].
[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.
</description>
Expand Down
2 changes: 1 addition & 1 deletion editor/import/3d/resource_importer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static Error _parse_obj(const String &p_path, List<Ref<ImporterMesh>> &r_meshes,

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

if (p_generate_shadow_mesh) {
Expand Down
14 changes: 1 addition & 13 deletions editor/import/3d/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2043,9 +2043,7 @@ void ResourceImporterScene::get_internal_import_options(InternalImportCategory p
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/shadow_meshes", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lightmap_uv", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "generate/lods", PROPERTY_HINT_ENUM, "Default,Enable,Disable"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_split_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 25.0f));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "lods/normal_merge_angle", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), 60.0f));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "lods/raycast_normals", PROPERTY_HINT_NONE, ""), false));
} break;
case INTERNAL_IMPORT_CATEGORY_MATERIAL: {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "use_external/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
Expand Down Expand Up @@ -2474,9 +2472,7 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
//do mesh processing

bool generate_lods = p_generate_lods;
float split_angle = 25.0f;
float merge_angle = 60.0f;
bool raycast_normals = false;
bool create_shadow_meshes = p_create_shadow_meshes;
bool bake_lightmaps = p_light_bake_mode == LIGHT_BAKE_STATIC_LIGHTMAPS;
String save_to_file;
Expand Down Expand Up @@ -2523,18 +2519,10 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_
}
}

if (mesh_settings.has("lods/normal_split_angle")) {
split_angle = mesh_settings["lods/normal_split_angle"];
}

if (mesh_settings.has("lods/normal_merge_angle")) {
merge_angle = mesh_settings["lods/normal_merge_angle"];
}

if (mesh_settings.has("lods/raycast_normals")) {
raycast_normals = mesh_settings["lods/raycast_normals"];
}

if (bool(mesh_settings.get("save_to_file/enabled", false))) {
save_to_file = mesh_settings.get("save_to_file/path", String());
if (!save_to_file.is_resource_file()) {
Expand Down Expand Up @@ -2583,7 +2571,7 @@ Node *ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_

if (generate_lods) {
Array skin_pose_transform_array = _get_skinned_pose_transforms(src_mesh_node);
src_mesh_node->get_mesh()->generate_lods(merge_angle, split_angle, skin_pose_transform_array, raycast_normals);
src_mesh_node->get_mesh()->generate_lods(merge_angle, skin_pose_transform_array);
}

if (create_shadow_meshes) {
Expand Down
Loading

0 comments on commit 7187c25

Please sign in to comment.