Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OBJ mesh importer smoothing handling #75315

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions editor/import/resource_importer_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
String current_group;
uint32_t smooth_group = 0;
bool smoothing = true;
const uint32_t no_smoothing_smooth_group = (uint32_t)-1;

while (true) {
String l = f->get_line().strip_edges();
Expand Down Expand Up @@ -349,10 +350,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
if (!colors.is_empty()) {
surf_tool->set_color(colors[vtx]);
}
if (!smoothing) {
smooth_group++;
}
surf_tool->set_smooth_group(smooth_group);
surf_tool->set_smooth_group(smoothing ? smooth_group : no_smoothing_smooth_group);
surf_tool->add_vertex(vertex);
}

Expand All @@ -367,8 +365,10 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
do_smooth = true;
}
if (do_smooth != smoothing) {
smooth_group++;
smoothing = do_smooth;
if (smoothing) {
smooth_group++;
}
}
} else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh
//groups are too annoying
Expand Down