24 : use_custom_normals_(use_custom_normals)
26 degenerate_tris_num_ = 0;
27 duplicate_tris_num_ = 0;
28 tris_.reserve(tris_num);
30 verts_.reserve(tris_num * 3);
31 if (use_custom_normals) {
32 loop_normals_.reserve(tris_num * 3);
38 int v1_id = verts_.index_of_or_add(data.vertices[0]);
39 int v2_id = verts_.index_of_or_add(data.vertices[1]);
40 int v3_id = verts_.index_of_or_add(data.vertices[2]);
41 if ((v1_id == v2_id) || (v1_id == v3_id) || (v2_id == v3_id)) {
42 degenerate_tris_num_++;
45 if (!tris_.add({v1_id, v2_id, v3_id})) {
46 duplicate_tris_num_++;
50 if (use_custom_normals_) {
51 loop_normals_.append_n_times(data.normal, 3);
58 if (degenerate_tris_num_ > 0) {
59 std::cout <<
"STL Importer: " << degenerate_tris_num_ <<
" degenerate triangles were removed"
62 if (duplicate_tris_num_ > 0) {
63 std::cout <<
"STL Importer: " << duplicate_tris_num_ <<
" duplicate triangles were removed"
68 mesh->vert_positions_for_write().copy_from(verts_);
77 if (use_custom_normals_ && loop_normals_.size() == mesh->corners_num) {
void BKE_mesh_set_custom_normals(Mesh *mesh, float(*r_custom_loop_normals)[3])
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
bool add_triangle(const PackedTriangle &data)
STLMeshHelper(int tris_num, bool use_custom_normals)
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
void fill_constant_group_size(int size, int start_offset, MutableSpan< int > offsets)