Refactor: Sculpt: Replace sculpt attribute system for dynamic topology data
Part of #118145. Use the BMesh functions instead of the sculpt attribute API which we intend to remove.
This commit is contained in:
@@ -390,10 +390,6 @@ struct SculptAttributePointers {
|
||||
SculptAttribute *automasking_occlusion = nullptr; /* CD_PROP_INT8. */
|
||||
SculptAttribute *automasking_stroke_id = nullptr;
|
||||
SculptAttribute *automasking_cavity = nullptr;
|
||||
|
||||
/* BMesh */
|
||||
SculptAttribute *dyntopo_node_id_vertex = nullptr;
|
||||
SculptAttribute *dyntopo_node_id_face = nullptr;
|
||||
};
|
||||
|
||||
struct SculptTopologyIslandCache {
|
||||
|
||||
@@ -94,7 +94,6 @@ static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob,
|
||||
const SculptAttributeParams *params,
|
||||
blender::bke::pbvh::Type pbvhtype,
|
||||
bool flat_array_for_bmesh);
|
||||
static void sculptsession_bmesh_add_layers(Object *ob);
|
||||
|
||||
static void palette_init_data(ID *id)
|
||||
{
|
||||
@@ -2354,9 +2353,11 @@ namespace blender::bke {
|
||||
|
||||
static std::unique_ptr<pbvh::Tree> build_pbvh_for_dynamic_topology(Object *ob)
|
||||
{
|
||||
sculptsession_bmesh_add_layers(ob);
|
||||
BMesh &bm = *ob->sculpt->bm;
|
||||
BM_data_layer_ensure_named(&bm, &bm.vdata, CD_PROP_INT32, ".sculpt_dyntopo_node_id_vertex");
|
||||
BM_data_layer_ensure_named(&bm, &bm.pdata, CD_PROP_INT32, ".sculpt_dyntopo_node_id_face");
|
||||
|
||||
return pbvh::build_bmesh(ob->sculpt->bm);
|
||||
return pbvh::build_bmesh(&bm);
|
||||
}
|
||||
|
||||
static std::unique_ptr<pbvh::Tree> build_pbvh_from_regular_mesh(Object *ob,
|
||||
@@ -2870,30 +2871,6 @@ SculptAttribute *BKE_sculpt_attribute_ensure(Object *ob,
|
||||
ob, domain, proptype, name, &temp_params, ob->sculpt->pbvh->type(), true);
|
||||
}
|
||||
|
||||
static void sculptsession_bmesh_add_layers(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptAttributeParams params = {0};
|
||||
|
||||
ss->attrs.dyntopo_node_id_vertex = sculpt_attribute_ensure_ex(
|
||||
ob,
|
||||
AttrDomain::Point,
|
||||
CD_PROP_INT32,
|
||||
SCULPT_ATTRIBUTE_NAME(dyntopo_node_id_vertex),
|
||||
¶ms,
|
||||
blender::bke::pbvh::Type::BMesh,
|
||||
false);
|
||||
|
||||
ss->attrs.dyntopo_node_id_face = sculpt_attribute_ensure_ex(
|
||||
ob,
|
||||
AttrDomain::Face,
|
||||
CD_PROP_INT32,
|
||||
SCULPT_ATTRIBUTE_NAME(dyntopo_node_id_face),
|
||||
¶ms,
|
||||
blender::bke::pbvh::Type::BMesh,
|
||||
false);
|
||||
}
|
||||
|
||||
void BKE_sculpt_attributes_destroy_temporary_stroke(Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
@@ -2920,10 +2897,6 @@ static void sculpt_attribute_update_refs(Object *ob, blender::bke::pbvh::Type pb
|
||||
sculpt_attr_update(ob, attr, pbvhtype);
|
||||
}
|
||||
}
|
||||
|
||||
if (ss->bm) {
|
||||
sculptsession_bmesh_add_layers(ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,12 +126,9 @@ static void disable(
|
||||
SculptSession &ss = *ob.sculpt;
|
||||
Mesh *mesh = static_cast<Mesh *>(ob.data);
|
||||
|
||||
if (ss.attrs.dyntopo_node_id_vertex) {
|
||||
BKE_sculpt_attribute_destroy(&ob, ss.attrs.dyntopo_node_id_vertex);
|
||||
}
|
||||
|
||||
if (ss.attrs.dyntopo_node_id_face) {
|
||||
BKE_sculpt_attribute_destroy(&ob, ss.attrs.dyntopo_node_id_face);
|
||||
if (BMesh *bm = ss.bm) {
|
||||
BM_data_layer_free_named(bm, &bm->vdata, ".sculpt_dyntopo_node_id_vertex");
|
||||
BM_data_layer_free_named(bm, &bm->pdata, ".sculpt_dyntopo_node_id_face");
|
||||
}
|
||||
|
||||
SCULPT_pbvh_clear(ob);
|
||||
|
||||
Reference in New Issue
Block a user