Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_convert.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index cb72e09af16..393d54bb03e 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -140,6 +140,7 @@ static void make_edges_mdata_extend(Mesh &mesh)
static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispbase)
{
+ using namespace blender::bke;
const float *data;
int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0;
int p1, p2, p3, p4, *index;
@@ -194,6 +195,9 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
MEdge *medge = edges.data();
MPoly *mpoly = polys.data();
MLoop *mloop = loops.data();
+ MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
+ SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>(
+ "material_index", ATTR_DOMAIN_FACE);
MLoopUV *mloopuv = static_cast<MLoopUV *>(CustomData_add_layer_named(
&mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, "UVMap"));
@@ -272,7 +276,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
mloop[2].v = startvert + index[1];
mpoly->loopstart = (int)(mloop - loops.data());
mpoly->totloop = 3;
- mpoly->mat_nr = dl->col;
+ material_indices.span[mpoly - polys.data()] = dl->col;
if (mloopuv) {
for (int i = 0; i < 3; i++, mloopuv++) {
@@ -332,7 +336,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
mloop[3].v = p2;
mpoly->loopstart = (int)(mloop - loops.data());
mpoly->totloop = 4;
- mpoly->mat_nr = dl->col;
+ material_indices.span[mpoly - polys.data()] = dl->col;
if (mloopuv) {
int orco_sizeu = dl->nr - 1;
@@ -385,6 +389,8 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
make_edges_mdata_extend(*mesh);
}
+ material_indices.finish();
+
return mesh;
}