diff options
Diffstat (limited to 'source/blender/editors/object/object_modifier.cc')
-rw-r--r-- | source/blender/editors/object/object_modifier.cc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 67399717c72..013bbbf7e55 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -93,6 +93,7 @@ #include "object_intern.h" +using blender::float3; using blender::Span; static void modifier_skin_customdata_delete(struct Object *ob); @@ -590,13 +591,13 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/, me->totvert = verts_num; me->totedge = edges_num; - CustomData_add_layer(&me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, verts_num); + CustomData_add_layer_named( + &me->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, verts_num, "position"); CustomData_add_layer(&me->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, edges_num); CustomData_add_layer(&me->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, 0); - blender::MutableSpan<MVert> verts = me->verts_for_write(); + blender::MutableSpan<float3> positions = me->positions_for_write(); blender::MutableSpan<MEdge> edges = me->edges_for_write(); - MVert *mvert = verts.data(); MEdge *medge = edges.data(); bke::MutableAttributeAccessor attributes = me->attributes_for_write(); @@ -610,7 +611,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/, ParticleCacheKey *key = cache[a]; int kmax = key->segments; for (int k = 0; k <= kmax; k++, key++, cvert++, vert_index++) { - copy_v3_v3(mvert[vert_index].co, key->co); + positions[vert_index] = key->co; if (k) { medge->v1 = cvert - 1; medge->v2 = cvert; @@ -629,7 +630,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/, ParticleCacheKey *key = cache[a]; int kmax = key->segments; for (int k = 0; k <= kmax; k++, key++, cvert++, vert_index++) { - copy_v3_v3(mvert[vert_index].co, key->co); + copy_v3_v3(positions[vert_index], key->co); if (k) { medge->v1 = cvert - 1; medge->v2 = cvert; @@ -2659,7 +2660,7 @@ void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot) } static void skin_armature_bone_create(Object *skin_ob, - const MVert *mvert, + const Span<float3> positions, const MEdge *medge, bArmature *arm, BLI_bitmap *edges_visited, @@ -2686,8 +2687,8 @@ static void skin_armature_bone_create(Object *skin_ob, bone->flag |= BONE_CONNECTED; } - copy_v3_v3(bone->head, mvert[parent_v].co); - copy_v3_v3(bone->tail, mvert[v].co); + copy_v3_v3(bone->head, positions[parent_v]); + copy_v3_v3(bone->tail, positions[v]); bone->rad_head = bone->rad_tail = 0.25; BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx); @@ -2698,14 +2699,14 @@ static void skin_armature_bone_create(Object *skin_ob, ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE); } - skin_armature_bone_create(skin_ob, mvert, medge, arm, edges_visited, emap, bone, v); + skin_armature_bone_create(skin_ob, positions, medge, arm, edges_visited, emap, bone, v); } } static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, Object *skin_ob) { Mesh *me = static_cast<Mesh *>(skin_ob->data); - const Span<MVert> me_verts = me->verts(); + const Span<float3> me_positions = me->positions(); const Span<MEdge> me_edges = me->edges(); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); @@ -2713,7 +2714,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, const Mesh *me_eval_deform = mesh_get_eval_deform( depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH); - const Span<MVert> verts_eval = me_eval_deform->verts(); + const Span<float3> positions_eval = me_eval_deform->positions(); /* add vertex weights to original mesh */ CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, me->totvert); @@ -2748,8 +2749,8 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, if (emap[v].count > 1) { bone = ED_armature_ebone_add(arm, "Bone"); - copy_v3_v3(bone->head, me_verts[v].co); - copy_v3_v3(bone->tail, me_verts[v].co); + copy_v3_v3(bone->head, me_positions[v]); + copy_v3_v3(bone->tail, me_positions[v]); bone->head[1] = 1.0f; bone->rad_head = bone->rad_tail = 0.25; @@ -2757,7 +2758,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, if (emap[v].count >= 1) { skin_armature_bone_create( - skin_ob, verts_eval.data(), me_edges.data(), arm, edges_visited, emap, bone, v); + skin_ob, positions_eval, me_edges.data(), arm, edges_visited, emap, bone, v); } } } |