CurvesGeometry: Add initial vertex group support #106944
|
@ -50,10 +50,6 @@ void BKE_object_defgroup_active_index_set(struct Object *ob, int new_index);
|
|||
const struct ListBase *BKE_id_defgroup_list_get(const struct ID *id);
|
||||
struct ListBase *BKE_id_defgroup_list_get_mutable(struct ID *id);
|
||||
int BKE_id_defgroup_name_index(const struct ID *id, const char *name);
|
||||
bool BKE_defgroup_listbase_name_find(const ListBase *defbase,
|
||||
const char *name,
|
||||
int *r_index,
|
||||
struct bDeformGroup **r_group);
|
||||
bool BKE_id_defgroup_name_find(const struct ID *id,
|
||||
const char *name,
|
||||
int *r_index,
|
||||
|
|
|
@ -489,9 +489,6 @@ static const int *object_defgroup_active_index_get_p(const Object *ob)
|
|||
const bGPdata *gpd = (const bGPdata *)ob->data;
|
||||
return &gpd->vertex_group_active_index;
|
||||
}
|
||||
default: {
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -520,15 +517,16 @@ int BKE_id_defgroup_name_index(const ID *id, const char *name)
|
|||
return index;
|
||||
}
|
||||
|
||||
bool BKE_defgroup_listbase_name_find(const ListBase *defbase,
|
||||
const char *name,
|
||||
int *r_index,
|
||||
bDeformGroup **r_group)
|
||||
bool BKE_id_defgroup_name_find(const ID *id,
|
||||
const char *name,
|
||||
int *r_index,
|
||||
bDeformGroup **r_group)
|
||||
{
|
||||
if (name == nullptr || name[0] == '\0') {
|
||||
return false;
|
||||
}
|
||||
int index;
|
||||
const ListBase *defbase = BKE_id_defgroup_list_get(id);
|
||||
LISTBASE_FOREACH_INDEX (bDeformGroup *, group, defbase, index) {
|
||||
if (STREQ(name, group->name)) {
|
||||
if (r_index != nullptr) {
|
||||
|
@ -543,14 +541,6 @@ bool BKE_defgroup_listbase_name_find(const ListBase *defbase,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BKE_id_defgroup_name_find(const ID *id,
|
||||
const char *name,
|
||||
int *r_index,
|
||||
bDeformGroup **r_group)
|
||||
{
|
||||
return BKE_defgroup_listbase_name_find(BKE_id_defgroup_list_get(id), name, r_index, r_group);
|
||||
}
|
||||
|
||||
const ListBase *BKE_object_defgroup_list(const Object *ob)
|
||||
{
|
||||
BLI_assert(BKE_object_supports_vertex_groups(ob));
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_curves.hh"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_gpencil_legacy.h"
|
||||
|
@ -112,18 +111,14 @@ bDeformGroup *BKE_object_defgroup_add(Object *ob)
|
|||
|
||||
MDeformVert *BKE_object_defgroup_data_create(ID *id)
|
||||
{
|
||||
switch (GS(id->name)) {
|
||||
case ID_ME: {
|
||||
return BKE_mesh_deform_verts_for_write((Mesh *)id);
|
||||
}
|
||||
case ID_LT: {
|
||||
Lattice *lt = (Lattice *)id;
|
||||
lt->dvert = static_cast<MDeformVert *>(MEM_callocN(
|
||||
sizeof(MDeformVert) * lt->pntsu * lt->pntsv * lt->pntsw, "lattice deformVert"));
|
||||
return lt->dvert;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
if (GS(id->name) == ID_ME) {
|
||||
return BKE_mesh_deform_verts_for_write((Mesh *)id);
|
||||
}
|
||||
if (GS(id->name) == ID_LT) {
|
||||
Lattice *lt = (Lattice *)id;
|
||||
lt->dvert = static_cast<MDeformVert *>(MEM_callocN(
|
||||
sizeof(MDeformVert) * lt->pntsu * lt->pntsv * lt->pntsw, "lattice deformVert"));
|
||||
return lt->dvert;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_curves.hh"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_editmesh.h"
|
||||
|
@ -61,7 +60,6 @@
|
|||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "ED_curves.hh"
|
||||
#include "ED_mesh.hh"
|
||||
#include "ED_object.hh"
|
||||
#include "ED_screen.hh"
|
||||
|
@ -256,34 +254,7 @@ bool ED_vgroup_parray_alloc(ID *id,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
case ID_CV: {
|
||||
Curves *curves_id = reinterpret_cast<Curves *>(id);
|
||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
if (!curves.deform_verts().is_empty()) {
|
||||
MutableSpan<MDeformVert> dverts = curves.deform_verts_for_write();
|
||||
|
||||
*dvert_tot = curves.points_num();
|
||||
*dvert_arr = static_cast<MDeformVert **>(
|
||||
MEM_mallocN(sizeof(void *) * curves.points_num(), __func__));
|
||||
|
||||
if (use_vert_sel) {
|
||||
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
|
||||
".selection", ATTR_DOMAIN_POINT, true);
|
||||
|
||||
for (int64_t i = 0; i < curves.points_num(); i++) {
|
||||
(*dvert_arr)[i] = selection[i] ? &dverts[i] : nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int64_t i = 0; i < curves.points_num(); i++) {
|
||||
(*dvert_arr)[i] = &dverts[i];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1135,24 +1106,6 @@ static void vgroup_select_verts(Object *ob, int select)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (ob->type == OB_CURVES) {
|
||||
Curves *curves_id = static_cast<Curves *>(ob->data);
|
||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
const Span<MDeformVert> dverts = curves.deform_verts();
|
||||
if (!dverts.is_empty()) {
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
curves, ATTR_DOMAIN_POINT, CD_PROP_BOOL);
|
||||
MutableSpan<bool> selection_typed = selection.span.typed<bool>();
|
||||
threading::parallel_for(curves.points_range(), 4096, [&](const IndexRange range) {
|
||||
for (const int64_t index : range) {
|
||||
if (BKE_defvert_find_index(&dverts[index], def_nr)) {
|
||||
selection_typed[index] = bool(select);
|
||||
}
|
||||
}
|
||||
});
|
||||
selection.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void vgroup_duplicate(Object *ob)
|
||||
|
@ -2355,23 +2308,6 @@ static void vgroup_assign_verts(Object *ob, const float weight)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (ob->type == OB_CURVES) {
|
||||
Curves *curves_id = static_cast<Curves *>(ob->data);
|
||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
|
||||
".selection", ATTR_DOMAIN_POINT, true);
|
||||
|
||||
MutableSpan<MDeformVert> dverts = curves.deform_verts_for_write();
|
||||
threading::parallel_for(curves.points_range(), 4096, [&](const IndexRange range) {
|
||||
for (const int64_t index : range) {
|
||||
if (selection[index]) {
|
||||
if (MDeformWeight *dw = BKE_defvert_ensure_index(&dverts[index], def_nr)) {
|
||||
dw->weight = weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -599,8 +599,7 @@ typedef enum ObjectType {
|
|||
OB_POINTCLOUD, \
|
||||
OB_VOLUME, \
|
||||
OB_GREASE_PENCIL))
|
||||
#define OB_TYPE_SUPPORT_VGROUP(_type) \
|
||||
(ELEM(_type, OB_MESH, OB_LATTICE, OB_GPENCIL_LEGACY, OB_CURVES))
|
||||
#define OB_TYPE_SUPPORT_VGROUP(_type) (ELEM(_type, OB_MESH, OB_LATTICE, OB_GPENCIL_LEGACY))
|
||||
#define OB_TYPE_SUPPORT_EDITMODE(_type) \
|
||||
(ELEM(_type, \
|
||||
OB_MESH, \
|
||||
|
|
Loading…
Reference in New Issue