[Bf-blender-cvs] [984ab4719db] soc-2020-io-performance: Fix crash when UVs are not asked to be exported.
Howard Trickey
noreply at git.blender.org
Sun Jun 6 05:57:03 CEST 2021
Commit: 984ab4719dbcf763e7ad220014160706d514d2bb
Author: Howard Trickey
Date: Sat Jun 5 20:56:20 2021 -0700
Branches: soc-2020-io-performance
https://developer.blender.org/rB984ab4719dbcf763e7ad220014160706d514d2bb
Fix crash when UVs are not asked to be exported.
===================================================================
M source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
===================================================================
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
index e4ad268da27..2895c3fb647 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
@@ -356,6 +356,9 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data,
/* Number of normals may not be equal to number of polygons due to smooth shading. */
int per_object_tot_normals = 0;
const int tot_polygons = obj_mesh_data.tot_polygons();
+ /* If we aren't exporting UVs, need an array for the ignored argument to poly_element_writer. */
+ Array<int> dummy_uvs(0);
+ Span<int> uvs = dummy_uvs.as_span();
for (int i = 0; i < tot_polygons; i++) {
Vector<int> poly_vertex_indices = obj_mesh_data.calc_poly_vertex_indices(i);
/* For an Object, a normal index depends on how many of its normals have been written before
@@ -370,8 +373,10 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data,
last_poly_smooth_group = write_smooth_group(obj_mesh_data, i, last_poly_smooth_group);
last_poly_vertex_group = write_vertex_group(obj_mesh_data, i, last_poly_vertex_group);
last_poly_mat_nr = write_poly_material(obj_mesh_data, i, last_poly_mat_nr, matname_fn);
- (this->*poly_element_writer)(
- poly_vertex_indices, obj_mesh_data.uv_indices(i), poly_normal_indices);
+ if (export_params_.export_uv) {
+ uvs = obj_mesh_data.uv_indices(i);
+ }
+ (this->*poly_element_writer)(poly_vertex_indices, uvs, poly_normal_indices);
}
/* Unusual: Other indices are updated in #OBJWriter::update_index_offsets. */
index_offsets_.normal_offset += per_object_tot_normals;
More information about the Bf-blender-cvs
mailing list