28 : use_custom_normals_(use_custom_normals)
30 degenerate_tris_num_ = 0;
31 duplicate_tris_num_ = 0;
32 tris_.reserve(tris_num);
34 verts_.reserve(
int64_t(tris_num) * 3);
35 if (use_custom_normals) {
36 loop_normals_.reserve(
int64_t(tris_num) * 3);
42 int v1_id = verts_.index_of_or_add(
data.vertices[0]);
43 int v2_id = verts_.index_of_or_add(
data.vertices[1]);
44 int v3_id = verts_.index_of_or_add(
data.vertices[2]);
45 if ((v1_id == v2_id) || (v1_id == v3_id) || (v2_id == v3_id)) {
46 degenerate_tris_num_++;
49 if (!tris_.add({v1_id, v2_id, v3_id})) {
50 duplicate_tris_num_++;
54 if (use_custom_normals_) {
55 loop_normals_.append_n_times(
data.normal, 3);
62 if (degenerate_tris_num_ > 0) {
63 CLOG_WARN(&
LOG,
"Removed %d degenerate triangles during import", degenerate_tris_num_);
65 if (duplicate_tris_num_ > 0) {
66 CLOG_WARN(&
LOG,
"Removed %d duplicate triangles during import", duplicate_tris_num_);
70 mesh->vert_positions_for_write().copy_from(verts_);
79 if (use_custom_normals_ && loop_normals_.size() ==
mesh->corners_num) {
#define CLOG_WARN(clg_ref,...)
bool add_triangle(const PackedTriangle &data)
STLMeshHelper(int tris_num, bool use_custom_normals)
void copy(const GVArray &src, GMutableSpan dst, exec_mode::Mode mode=exec_mode::parallel)
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 mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
void fill_constant_group_size(int size, int start_offset, MutableSpan< int > offsets)
BMesh const char void * data
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)