Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAras Pranckevicius <aras@nesnausk.org>2022-10-03 11:07:35 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-10-03 14:13:09 +0300
commit3f30c1c042b3852882139d7cabe0c223da1e0e14 (patch)
tree43c85ea330e51e9da149ea3c407ce4338c299139 /source
parent86538e31f5945009b6fae0f14b958ed07762f016 (diff)
Fix T101487: New OBJ importer handles UVs incorrectly when some faces of an object don't have UVs
The UV data filling logic was incorrectly just skipping over loop entries that don't have a UV coordinate, instead of assigning the default zero UV for them. This was a problem only for meshes where some faces did have UVs, but some other faces did not (T101487).
Diffstat (limited to 'source')
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_mesh.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
index 6b19d6573af..ab6c81f798b 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
@@ -268,12 +268,13 @@ void MeshFromGeometry::create_uv_verts(Mesh *mesh)
for (const PolyElem &curr_face : mesh_geometry_.face_elements_) {
for (int idx = 0; idx < curr_face.corner_count_; ++idx) {
const PolyCorner &curr_corner = mesh_geometry_.face_corners_[curr_face.start_index_ + idx];
- if (curr_corner.uv_vert_index >= 0 &&
- curr_corner.uv_vert_index < global_vertices_.uv_vertices.size()) {
- const float2 &mluv_src = global_vertices_.uv_vertices[curr_corner.uv_vert_index];
- copy_v2_v2(mluv_dst[tot_loop_idx].uv, mluv_src);
- tot_loop_idx++;
+ const int uv_index = curr_corner.uv_vert_index;
+ float2 uv(0, 0);
+ if (uv_index >= 0 && uv_index < global_vertices_.uv_vertices.size()) {
+ uv = global_vertices_.uv_vertices[uv_index];
}
+ copy_v2_v2(mluv_dst[tot_loop_idx].uv, uv);
+ tot_loop_idx++;
}
}
}