diff options
Diffstat (limited to 'source/blender/editors/object/object_modifier.cc')
-rw-r--r-- | source/blender/editors/object/object_modifier.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index f82c0938b51..3d995c84639 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -530,6 +530,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports), Object *ob, ModifierData *md) { + using namespace blender; int cvert = 0; if (md->type != eModifierType_ParticleSystem) { @@ -599,13 +600,18 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports), MVert *mvert = verts.data(); MEdge *medge = edges.data(); + bke::MutableAttributeAccessor attributes = me->attributes_for_write(); + bke::SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_span<bool>( + ".select_vert", ATTR_DOMAIN_POINT); + /* copy coordinates */ + int vert_index = 0; cache = psys_eval->pathcache; for (int a = 0; a < part_num; a++) { ParticleCacheKey *key = cache[a]; int kmax = key->segments; - for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) { - copy_v3_v3(mvert->co, key->co); + for (int k = 0; k <= kmax; k++, key++, cvert++, vert_index++) { + copy_v3_v3(mvert[vert_index].co, key->co); if (k) { medge->v1 = cvert - 1; medge->v2 = cvert; @@ -614,7 +620,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports), } else { /* cheap trick to select the roots */ - mvert->flag |= SELECT; + select_vert.span[vert_index] = true; } } } @@ -623,8 +629,8 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports), for (int a = 0; a < child_num; a++) { ParticleCacheKey *key = cache[a]; int kmax = key->segments; - for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) { - copy_v3_v3(mvert->co, key->co); + for (int k = 0; k <= kmax; k++, key++, cvert++, vert_index++) { + copy_v3_v3(mvert[vert_index].co, key->co); if (k) { medge->v1 = cvert - 1; medge->v2 = cvert; @@ -633,11 +639,13 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports), } else { /* cheap trick to select the roots */ - mvert->flag |= SELECT; + select_vert.span[vert_index] = true; } } } + select_vert.finish(); + DEG_relations_tag_update(bmain); return true; |