CurvesGeometry: Add initial vertex group support #106944
@ -301,6 +301,7 @@ namespace blender::bke {
|
||||
VArray<float> varray_for_deform_verts(Span<MDeformVert> dverts, int defgroup_index);
|
||||
filedescriptor marked this conversation as resolved
Outdated
|
||||
VMutableArray<float> varray_for_mutable_deform_verts(MutableSpan<MDeformVert> dverts,
|
||||
int defgroup_index);
|
||||
void remove_defgroup_index(MutableSpan<MDeformVert> dverts, int defgroup_index);
|
||||
} // namespace blender::bke
|
||||
#endif
|
||||
|
||||
|
@ -1767,6 +1767,20 @@ VMutableArray<float> varray_for_mutable_deform_verts(MutableSpan<MDeformVert> dv
|
||||
{
|
||||
return VMutableArray<float>::For<VArrayImpl_For_VertexWeights>(dverts, defgroup_index);
|
||||
}
|
||||
|
||||
void remove_defgroup_index(MutableSpan<MDeformVert> dverts, const int defgroup_index)
|
||||
{
|
||||
threading::parallel_for(dverts.index_range(), 1024, [&](IndexRange range) {
|
||||
for (MDeformVert &dvert : dverts.slice(range)) {
|
||||
MDeformWeight *weight = BKE_defvert_find_index(&dvert, defgroup_index);
|
||||
BKE_defvert_remove_group(&dvert, weight);
|
||||
for (MDeformWeight &weight : MutableSpan(dvert.dw, dvert.totweight)) {
|
||||
if (weight.def_nr > defgroup_index) {
|
||||
weight.def_nr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace blender::bke
|
||||
|
@ -404,17 +404,7 @@ class CurvesVertexGroupsAttributeProvider final : public DynamicAttributesProvid
|
||||
}
|
||||
|
||||
MutableSpan<MDeformVert> dverts = curves->deform_verts_for_write();
|
||||
threading::parallel_for(dverts.index_range(), 1024, [&](IndexRange range) {
|
||||
for (MDeformVert &dvert : dverts.slice(range)) {
|
||||
MDeformWeight *weight = BKE_defvert_find_index(&dvert, index);
|
||||
BKE_defvert_remove_group(&dvert, weight);
|
||||
for (MDeformWeight &weight : MutableSpan(dvert.dw, dvert.totweight)) {
|
||||
if (weight.def_nr > index) {
|
||||
weight.def_nr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
bke::remove_defgroup_index(dverts, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -931,17 +931,7 @@ class MeshVertexGroupsAttributeProvider final : public DynamicAttributesProvider
|
||||
}
|
||||
|
||||
MutableSpan<MDeformVert> dverts = mesh->deform_verts_for_write();
|
||||
threading::parallel_for(dverts.index_range(), 1024, [&](IndexRange range) {
|
||||
for (MDeformVert &dvert : dverts.slice(range)) {
|
||||
MDeformWeight *weight = BKE_defvert_find_index(&dvert, index);
|
||||
BKE_defvert_remove_group(&dvert, weight);
|
||||
for (MDeformWeight &weight : MutableSpan(dvert.dw, dvert.totweight)) {
|
||||
if (weight.def_nr > index) {
|
||||
weight.def_nr--;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
bke::remove_defgroup_index(dverts, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
const int
->int
dvert_index
->defgroup_index
/vgroup_index