OBJ: in exporter faces loop, move material index accessor outside of the loop
While the cost of creating AttributeAccessor and finding the "material_index" attribute is not large, there's really no need to do that for each polygon. Move the access outside of the per-polygon loop.
This commit is contained in:
parent
eaef8d50bc
commit
da4e2fe7fe
|
@ -337,6 +337,9 @@ void OBJWriter::write_poly_elements(FormatHandler &fh,
|
|||
const int tot_polygons = obj_mesh_data.tot_polygons();
|
||||
const int tot_deform_groups = obj_mesh_data.tot_deform_groups();
|
||||
threading::EnumerableThreadSpecific<Vector<float>> group_weights;
|
||||
const bke::AttributeAccessor attributes = obj_mesh_data.get_mesh()->attributes();
|
||||
const VArray<int> material_indices = attributes.lookup_or_default<int>(
|
||||
"material_index", ATTR_DOMAIN_FACE, 0);
|
||||
|
||||
obj_parallel_chunked_output(fh, tot_polygons, [&](FormatHandler &buf, int idx) {
|
||||
/* Polygon order for writing into the file is not necessarily the same
|
||||
|
@ -372,10 +375,6 @@ void OBJWriter::write_poly_elements(FormatHandler &fh,
|
|||
}
|
||||
}
|
||||
|
||||
const bke::AttributeAccessor attributes = obj_mesh_data.get_mesh()->attributes();
|
||||
const VArray<int> material_indices = attributes.lookup_or_default<int>(
|
||||
"material_index", ATTR_DOMAIN_FACE, 0);
|
||||
|
||||
/* Write material name and material group if different from previous. */
|
||||
if (export_params_.export_materials && obj_mesh_data.tot_materials() > 0) {
|
||||
const int16_t prev_mat = idx == 0 ? NEGATIVE_INIT : std::max(0, material_indices[prev_i]);
|
||||
|
|
Loading…
Reference in New Issue