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(
a);
40 int v2_id = verts_.index_of_or_add(
b);
41 int v3_id = verts_.index_of_or_add(
c);
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_++;
56 const float3 &custom_normal)
59 loop_normals_.append_n_times(custom_normal, 3);
65 if (degenerate_tris_num_ > 0) {
66 std::cout <<
"STL Importer: " << degenerate_tris_num_ <<
" degenerate triangles were removed"
69 if (duplicate_tris_num_ > 0) {
70 std::cout <<
"STL Importer: " << duplicate_tris_num_ <<
" duplicate triangles were removed"
93 for (const int i : tris_range) {
94 mesh->mpoly[i].loopstart = 3 * i;
95 mesh->mpoly[i].totloop = 3;
97 mesh->mloop[3 * i].v = tris_[i].v1;
98 mesh->mloop[3 * i + 1].v = tris_[i].v2;
99 mesh->mloop[3 * i + 2].v = tris_[i].v3;
106 if (use_custom_normals_ && loop_normals_.size() ==
mesh->
totloop) {
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
void id_us_min(struct ID *id)
struct Mesh * BKE_mesh_add(struct Main *bmain, const char *name)
void BKE_mesh_set_custom_normals(struct Mesh *mesh, float(*r_custom_loopnors)[3])
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, bool select_new_edges)
MINLINE void copy_v3_v3(float r[3], const float a[3])
Mesh * to_mesh(Main *bmain, char *mesh_name)
bool add_triangle(const float3 &a, const float3 &b, const float3 &c)
STLMeshHelper(int tris_num, bool use_custom_normals)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)