Cleanup: OBJ: Simplify access to loose edges
Implementing this with a separate function just added extra code, there wasn't much benefit to it.
This commit is contained in:
parent
59af0fba9d
commit
23dafa4ad6
|
@ -7,8 +7,9 @@
|
|||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_blender_version.h"
|
||||
#include "BKE_geometry_set.hh"
|
||||
#include "BKE_mesh.h"
|
||||
|
||||
#include "BLI_color.hh"
|
||||
#include "BLI_enumerable_thread_specific.hh"
|
||||
|
@ -416,15 +417,12 @@ void OBJWriter::write_edges_indices(FormatHandler &fh,
|
|||
const OBJMesh &obj_mesh_data) const
|
||||
{
|
||||
/* NOTE: ensure_mesh_edges should be called before. */
|
||||
const int tot_edges = obj_mesh_data.tot_edges();
|
||||
for (int edge_index = 0; edge_index < tot_edges; edge_index++) {
|
||||
const std::optional<std::array<int, 2>> vertex_indices =
|
||||
obj_mesh_data.calc_loose_edge_vert_indices(edge_index);
|
||||
if (!vertex_indices) {
|
||||
continue;
|
||||
const Span<MEdge> edges = obj_mesh_data.get_mesh()->edges();
|
||||
for (const int i : edges.index_range()) {
|
||||
const MEdge &edge = edges[i];
|
||||
if (edge.flag & ME_LOOSEEDGE) {
|
||||
fh.write_obj_edge(edge.v1 + offsets.vertex_offset + 1, edge.v2 + offsets.vertex_offset + 1);
|
||||
}
|
||||
fh.write_obj_edge((*vertex_indices)[0] + offsets.vertex_offset + 1,
|
||||
(*vertex_indices)[1] + offsets.vertex_offset + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -507,13 +507,4 @@ const char *OBJMesh::get_poly_deform_group_name(const int16_t def_group_index) c
|
|||
return vertex_group.name;
|
||||
}
|
||||
|
||||
std::optional<std::array<int, 2>> OBJMesh::calc_loose_edge_vert_indices(const int edge_index) const
|
||||
{
|
||||
const Span<MEdge> edges = export_mesh_eval_->edges();
|
||||
const MEdge &edge = edges[edge_index];
|
||||
if (edge.flag & ME_LOOSEEDGE) {
|
||||
return std::array<int, 2>{int(edge.v1), int(edge.v2)};
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
} // namespace blender::io::obj
|
||||
|
|
|
@ -215,11 +215,6 @@ class OBJMesh : NonCopyable {
|
|||
*/
|
||||
const char *get_poly_deform_group_name(int16_t def_group_index) const;
|
||||
|
||||
/**
|
||||
* Calculate vertex indices of an edge's corners if it is a loose edge.
|
||||
*/
|
||||
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).
|
||||
|
|
Loading…
Reference in New Issue