25 : use_custom_normals_(use_custom_normals)
27 degenerate_tris_num_ = 0;
28 duplicate_tris_num_ = 0;
29 tris_.reserve(tris_num);
31 verts_.reserve(tris_num * 3);
32 if (use_custom_normals) {
33 loop_normals_.reserve(tris_num * 3);
39 int v1_id = verts_.index_of_or_add(
data.vertices[0]);
40 int v2_id = verts_.index_of_or_add(
data.vertices[1]);
41 int v3_id = verts_.index_of_or_add(
data.vertices[2]);
42 if ((v1_id == v2_id) || (v1_id == v3_id) || (v2_id == v3_id)) {
43 degenerate_tris_num_++;
46 if (!tris_.add({v1_id, v2_id, v3_id})) {
47 duplicate_tris_num_++;
51 if (use_custom_normals_) {
52 loop_normals_.append_n_times(
data.normal, 3);
59 if (degenerate_tris_num_ > 0) {
60 CLOG_WARN(&
LOG,
"Removed %d degenerate triangles during import", degenerate_tris_num_);
62 if (duplicate_tris_num_ > 0) {
63 CLOG_WARN(&
LOG,
"Removed %d duplicate triangles during import", duplicate_tris_num_);
67 mesh->vert_positions_for_write().copy_from(verts_);
76 if (use_custom_normals_ && loop_normals_.size() == mesh->
corners_num) {
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
#define CLOG_WARN(clg_ref,...)
BMesh const char void * data
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 mesh_set_custom_normals(Mesh &mesh, MutableSpan< float3 > corner_normals)
void fill_constant_group_size(int size, int start_offset, MutableSpan< int > offsets)