From 5962db093f2f1fcf735ceaaa1ba6bbd25efc397f Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Tue, 3 May 2022 14:45:44 +0300 Subject: Fix T97793, Fix T97795: Use correct defaults for missing values in new OBJ importer - Fix T97793: when a UV coordinate after vt is missing, use zero. While at it, also use zeroes for positions & normals, since "maximum possible float" is very likely to cause issues in imported meshes. - Fix T97795: use 1.0 default if -bm value is missing, instead of zero. Reviewed By: Howard Trickey Differential Revision: https://developer.blender.org/D14826 --- .../blender/io/wavefront_obj/importer/obj_import_file_reader.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index 3724eaaa361..8df2a6bf16a 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -71,7 +71,7 @@ static void geom_add_vertex(Geometry *geom, GlobalVertices &r_global_vertices) { float3 vert; - parse_floats(line, FLT_MAX, vert, 3); + parse_floats(line, 0.0f, vert, 3); r_global_vertices.vertices.append(vert); geom->vertex_count_++; } @@ -81,7 +81,7 @@ static void geom_add_vertex_normal(Geometry *geom, GlobalVertices &r_global_vertices) { float3 normal; - parse_floats(line, FLT_MAX, normal, 3); + parse_floats(line, 0.0f, normal, 3); r_global_vertices.vertex_normals.append(normal); geom->has_vertex_normals_ = true; } @@ -89,7 +89,7 @@ static void geom_add_vertex_normal(Geometry *geom, static void geom_add_uv_vertex(const StringRef line, GlobalVertices &r_global_vertices) { float2 uv; - parse_floats(line, FLT_MAX, uv, 2); + parse_floats(line, 0.0f, uv, 2); r_global_vertices.uv_vertices.append(uv); } @@ -558,7 +558,7 @@ static bool parse_texture_option(StringRef &line, MTLMaterial *material, tex_map return true; } if (parse_keyword(line, "-bm")) { - line = parse_float(line, 0.0f, material->map_Bump_strength); + line = parse_float(line, 1.0f, material->map_Bump_strength); return true; } if (parse_keyword(line, "-type")) { -- cgit v1.2.3