Sculpt dyntopo: fix missing bit from last commit

* BM_mesh_bm_to_me now saves id layers by default.
This commit is contained in:
Joseph Eagar 2021-09-15 02:16:03 -07:00
parent 173f5f94ff
commit ecdd6a302e
7 changed files with 12 additions and 20 deletions

View File

@ -1395,19 +1395,13 @@ static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
ss->bm,
ob->data,
(&(struct BMeshToMeshParams){.calc_object_remap = false,
#ifdef WHEN_GLOBAL_UNDO_WORKS
/*
for memfile undo steps we need to
save id and temporary layers
*/
.copy_temp_cdlayers = true,
.copy_mesh_id_layers = true,
.ignore_mesh_id_layers = false,
.cd_mask_extra = CD_MASK_MESH_ID | CD_MASK_DYNTOPO_VERT
#else
.copy_temp_cdlayers = false,
.copy_mesh_id_layers = false
#endif
}));
}

View File

@ -1081,7 +1081,7 @@ static void bm_log_full_mesh_intern(BMesh *bm, BMLog *log, BMLogEntry *entry)
.calc_object_remap = false,
.cd_mask_extra = cd_mask_extra,
.copy_temp_cdlayers = true,
.copy_mesh_id_layers = true}),
.ignore_mesh_id_layers = false}),
NULL);
}

View File

@ -931,10 +931,10 @@ void BM_mesh_bm_to_me(
{
CustomData_MeshMasks mask = CD_MASK_MESH;
CustomData_MeshMasks_update(&mask, &params->cd_mask_extra);
CustomDataMask extra2 = params->copy_mesh_id_layers ? CD_MASK_MESH_ID : 0;
CustomDataMask extra2 = !params->ignore_mesh_id_layers ? CD_MASK_MESH_ID : 0;
// copy id layers? temporarily clear cd_temporary and cd_flag_elem_nocopy flags
if (params->copy_mesh_id_layers) {
if (!params->ignore_mesh_id_layers) {
for (int i = 0; i < 4; i++) {
int idx = CustomData_get_layer_index(srcdatas[i], CD_MESH_ID);
@ -1313,7 +1313,7 @@ void BM_mesh_bm_to_me(
BKE_mesh_runtime_clear_geometry(me);
// restore original cd layer flags to bmesh id layers
if (params->copy_mesh_id_layers) {
if (!params->ignore_mesh_id_layers) {
for (int i = 0; i < 4; i++) {
int idx = CustomData_get_layer_index(srcdatas[i], CD_MESH_ID);
if (idx >= 0) {

View File

@ -67,7 +67,7 @@ struct BMeshToMeshParams {
uint update_shapekey_indices : 1;
struct CustomData_MeshMasks cd_mask_extra;
uint copy_temp_cdlayers : 1;
uint copy_mesh_id_layers : 1;
uint ignore_mesh_id_layers : 1;
};
void BM_enter_multires_space(struct Object *ob, struct BMesh *bm, int space);

View File

@ -853,7 +853,7 @@ void BM_mesh_bm_to_me_threaded(
CustomData_MeshMasks mask = CD_MASK_MESH;
CustomData_MeshMasks_update(&mask, &params->cd_mask_extra);
CustomDataMask extra2 = params->copy_mesh_id_layers ? CD_MASK_MESH_ID : 0;
CustomDataMask extra2 = !params->ignore_mesh_id_layers ? CD_MASK_MESH_ID : 0;
CustomData *srcdatas[] = {&bm->vdata, &bm->edata, &bm->ldata, &bm->pdata};
int id_flags[4] = {-1, -1, -1, -1};
@ -861,7 +861,7 @@ void BM_mesh_bm_to_me_threaded(
taskdata.extra2 = extra2;
// copy id layers? temporarily clear cd_temporary and cd_flag_elem_nocopy flags
if (params->copy_mesh_id_layers) {
if (!params->ignore_mesh_id_layers) {
for (int i = 0; i < 4; i++) {
int idx = CustomData_get_layer_index(srcdatas[i], CD_MESH_ID);
@ -902,7 +902,7 @@ void BM_mesh_bm_to_me_threaded(
// BLI_threadpool_
# endif
// undo changes to source bmesh's id layers' flags
if (params->copy_mesh_id_layers) {
if (!params->ignore_mesh_id_layers) {
for (int i = 0; i < 4; i++) {
int idx = CustomData_get_layer_index(srcdatas[i], CD_MESH_ID);

View File

@ -10,10 +10,9 @@ TEST(bmesh_core, BMVertCreate)
BMVert *bv1, *bv2, *bv3;
const float co1[3] = {1.0f, 2.0f, 0.0f};
BMeshCreateParams bm_params;
BMeshCreateParams bm_params = {0};
bm_params.use_toolflags = true;
bm_params.use_unique_ids = false;
bm_params.no_reuse_ids = false;
bm = BM_mesh_create(&bm_mesh_allocsize_default, &bm_params);
EXPECT_EQ(bm->totvert, 0);

View File

@ -1270,8 +1270,7 @@ static void end_vis_object(SculptSession *ss, Object *ob, BMesh *bm)
me,
(&(struct BMeshToMeshParams){.calc_object_remap = false,
.update_shapekey_indices = false,
.copy_temp_cdlayers = false,
.copy_mesh_id_layers = false}));
.copy_temp_cdlayers = false}));
DEG_id_tag_update(&me->id, ID_RECALC_ALL);
}