42 CLOG_WARN(&
LOG,
"PLY mesh too large to import, exceeds max int size");
47 data.vertices.size(),
data.edges.size(),
data.face_sizes.size(),
data.face_vertices.size());
56 mesh->vert_positions_for_write().copy_from(
data.vertices);
60 if (!
data.edges.is_empty()) {
62 for (
const int i :
data.edges.index_range()) {
66 CLOG_WARN(&
LOG,
"Invalid PLY vertex index in edge %i/1: %d", i, v1);
70 CLOG_WARN(&
LOG,
"Invalid PLY vertex index in edge %i/2: %d", i,
v2);
78 if (!
data.face_sizes.is_empty()) {
84 for (
const int64_t i :
data.face_sizes.index_range()) {
86 face_offsets[i] = offset;
87 for (
int64_t j = 0; j < size; j++) {
91 &
LOG,
"Invalid PLY vertex index in face %" PRId64 " loop %" PRId64 ": %u", i, j,
v);
94 corner_verts[offset + j] =
v;
107 for (
const int i :
data.vertex_colors.index_range()) {
112 for (
const int i :
data.vertex_colors.index_range()) {
122 if (!
data.uv_coordinates.is_empty()) {
125 for (
const int i :
data.face_vertices.index_range()) {
128 data.uv_coordinates[
v] :
132 mesh->uv_maps_active_set(
"UVMap");
133 mesh->uv_maps_default_set(
"UVMap");
138 bool set_custom_normals_for_verts =
false;
139 if (!
data.vertex_normals.is_empty()) {
140 if (!
data.face_sizes.is_empty()) {
143 set_custom_normals_for_verts =
true;
161 attributes.
add<
float>(attr.
name,
169 const bool allow_missing_edges =
true;
171 const bool verbose_validate =
true;
173 const bool verbose_validate =
false;
178 if (set_custom_normals_for_verts) {
Generic geometry attributes built on CustomData.
#define BLI_SCOPED_DEFER(function_to_defer)
#define CLOG_WARN(clg_ref,...)
static VArray from_span(Span< T > values)
bool add(const StringRef name, const AttrDomain domain, const AttrType data_type, const AttributeInit &initializer)
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void mesh_set_custom_normals_from_verts(Mesh &mesh, MutableSpan< float3 > vert_normals)
bool mesh_validate(Mesh &mesh, bool verbose=false, bool allow_missing_edges=false)
std::optional< Mesh * > mesh_merge_by_distance_all(const Mesh &mesh, const IndexMask &selection, float merge_distance, const bke::AttributeFilter &attribute_filter=bke::AttributeFilter::default_filter())
Mesh * convert_ply_to_mesh(PlyData &data, const PLYImportParams ¶ms)
bool size_fits_in_int(const int64_t size)
bool index_in_range(const int64_t index, const int64_t size)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
VecBase< float, 2 > float2
BMesh const char void * data
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
void BKE_id_free(Main *bmain, void *idv)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
MINLINE void copy_v4_v4(float r[4], const float a[4])
VecBase< float, 3 > float3
ePLYVertexColorMode vertex_colors
MutableVArraySpan< T > span