28 data.vertices.size(),
data.edges.size(),
data.face_sizes.size(),
data.face_vertices.size());
30 mesh->vert_positions_for_write().copy_from(
data.vertices);
34 if (!
data.edges.is_empty()) {
36 for (
const int i :
data.edges.index_range()) {
40 CLOG_WARN(&
LOG,
"Invalid PLY vertex index in edge %i/1: %d",
i, v1);
52 if (!
data.face_sizes.is_empty()) {
58 for (
const int i :
data.face_sizes.index_range()) {
60 face_offsets[
i] = offset;
61 for (
int j = 0; j <
size; j++) {
62 uint32_t
v =
data.face_vertices[offset + j];
64 CLOG_WARN(&
LOG,
"Invalid PLY vertex index in face %i loop %i: %u",
i, j,
v);
67 corner_verts[offset + j] =
data.face_vertices[offset + j];
80 for (
const int i :
data.vertex_colors.index_range()) {
85 for (
const int i :
data.vertex_colors.index_range()) {
95 if (!
data.uv_coordinates.is_empty()) {
98 for (
const int i :
data.face_vertices.index_range()) {
106 bool set_custom_normals_for_verts =
false;
107 if (!
data.vertex_normals.is_empty()) {
108 if (!
data.face_sizes.is_empty()) {
111 set_custom_normals_for_verts =
true;
113 else if (
params.import_attributes) {
127 if (
params.import_attributes && !
data.vertex_custom_attr.is_empty()) {
129 attributes.
add<
float>(attr.
name,
140 bool verbose_validate =
false;
142 verbose_validate =
true;
147 if (set_custom_normals_for_verts) {
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< blender::StringRef > name)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
void BKE_id_free(Main *bmain, void *idv)
bool BKE_mesh_validate(Mesh *mesh, bool do_verbose, bool cddata_check_mask)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
#define CLOG_WARN(clg_ref,...)
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static VArray from_span(Span< T > values)
bool add(const StringRef attribute_id, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef attribute_id, AttrDomain domain, AttrType data_type)
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_from_verts(Mesh &mesh, MutableSpan< float3 > vert_normals)
std::optional< Mesh * > mesh_merge_by_distance_all(const Mesh &mesh, const IndexMask &selection, float merge_distance)
Mesh * convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms)
VecBase< float, 2 > float2
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
MutableVArraySpan< T > span