diff options
Diffstat (limited to 'source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh')
-rw-r--r-- | source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh index 3ec670d2203..4ab7567aa0f 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh @@ -101,6 +101,10 @@ class OBJMesh : NonCopyable { * Polygon aligned array of their smooth groups. */ int *poly_smooth_groups_ = nullptr; + /** + * Order in which the polygons should be written into the file (sorted by material index). + */ + Vector<int> poly_order_; public: /** @@ -212,6 +216,22 @@ class OBJMesh : NonCopyable { */ std::optional<std::array<int, 2>> calc_loose_edge_vert_indices(int edge_index) const; + /** + * Calculate the order in which the polygons should be written into the file (sorted by material + * index). + */ + void calc_poly_order(); + + /** + * Remap polygon index according to polygon writing order. + * When materials are not being written, the polygon order array + * might be empty, in which case remap is a no-op. + */ + int remap_poly_index(int i) const + { + return i < 0 || i >= poly_order_.size() ? i : poly_order_[i]; + } + private: /** * Free the mesh if _the exporter_ created it. |