summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkleonc <9283098+kleonc@users.noreply.github.com>2023-03-25 11:38:55 +0100
committerYuri Sizov <yuris@humnom.net>2023-04-24 16:52:25 +0200
commitebcc7b4b9883c287d5e90551b6a0704e74b71d6c (patch)
treefd5da60357e813f3661a4ac412f176d6e268dae8
parent756d809ef18224c4ade3d49bfb8120794533f049 (diff)
Fix OBJ mesh importer smoothing handling
(cherry picked from commit e8900a2cac901d9b7d596af7be185eec54c7b858)
-rw-r--r--editor/import/resource_importer_obj.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 3dd01754a3..89e2e36b77 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -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();
@@ -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);
}
@@ -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