[Bf-blender-cvs] [81d46ef2bdb] soc-2020-io-performance: Null check: Break if no UV layer found.
Ankit Meel
noreply at git.blender.org
Wed Jul 15 17:26:44 CEST 2020
Commit: 81d46ef2bdbc993ef4ac12f4297454162e789521
Author: Ankit Meel
Date: Wed Jul 15 20:56:05 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB81d46ef2bdbc993ef4ac12f4297454162e789521
Null check: Break if no UV layer found.
Also conditionally add an UV layer, not always.
===================================================================
M source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
===================================================================
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
index 6d329d9fad4..f10b5822fa9 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
@@ -61,14 +61,20 @@ OBJMeshFromRaw::OBJMeshFromRaw(class OBJRawObject &curr_object)
}
int uv_vert_index = 0;
- ED_mesh_uv_texture_ensure(mesh_from_bm_.get(), nullptr);
+ if (curr_object.tot_uv_verts > 0) {
+ ED_mesh_uv_texture_ensure(mesh_from_bm_.get(), nullptr);
+ }
for (int i = 0; i < tot_face_elems; ++i) {
const OBJFaceElem curr_face = curr_object.face_elements[i];
for (int j = 0; j < curr_face.face_corners.size(); ++j) {
const OBJFaceCorner curr_corner = curr_face.face_corners[j];
MLoopUV *mluv_dst = (MLoopUV *)CustomData_get_layer(&mesh_from_bm_->ldata, CD_MLOOPUV);
+ if (!mluv_dst) {
+ fprintf(stderr, "No UV layer found.\n");
+ break;
+ }
if (curr_corner.tex_vert_index < 0 ||
- curr_corner.tex_vert_index >= curr_object.tot_uv_verts || !mluv_dst) {
+ curr_corner.tex_vert_index >= curr_object.tot_uv_verts) {
continue;
}
MLoopUV *mluv_src = &curr_object.texture_vertices[curr_corner.tex_vert_index];
More information about the Bf-blender-cvs
mailing list