[Bf-blender-cvs] [da4e2fe7fe8] master: OBJ: in exporter faces loop, move material index accessor outside of the loop
Aras Pranckevicius
noreply at git.blender.org
Mon Jan 2 15:16:22 CET 2023
Commit: da4e2fe7fe8fb006ce4574d1a642c9129eaa549a
Author: Aras Pranckevicius
Date: Mon Jan 2 16:14:51 2023 +0200
Branches: master
https://developer.blender.org/rBda4e2fe7fe8fb006ce4574d1a642c9129eaa549a
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.
===================================================================
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 ec09a145f1b..6957e07dadd 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
@@ -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]);
More information about the Bf-blender-cvs
mailing list