Sculpt dyntopo: fix bug with dyntopo geometry undo push

This commit is contained in:
Joseph Eagar 2021-08-11 22:51:09 -07:00
parent a80c381ec5
commit 40aa321dc7
4 changed files with 42 additions and 23 deletions

@ -1 +1 @@
Subproject commit ca39c1459bcd99300afe3591fa5ffe40f5ba5eef
Subproject commit 35573b45adc0cc00a29538a68567621ab571a88f

@ -1 +1 @@
Subproject commit aebb668f75b57ba7cbd8f8f8ad41f0ddb4f27389
Subproject commit 78107f78694f47ee6e50a7eb7c16b506af921199

View File

@ -826,22 +826,8 @@ static BMLogEntry *bm_log_entry_create(BMLogEntryType type)
/* Free the data in a log entry
*
* NOTE: does not free the log entry itself. */
static void bm_log_entry_free(BMLogEntry *entry)
static void bm_log_entry_free_direct(BMLogEntry *entry)
{
BMLog *log = entry->log;
bool kill_log = false;
if (log) {
log->refcount--;
if (log->refcount < 0) {
fprintf(stderr, "BMLog refcount error\n");
log->refcount = 0;
}
kill_log = !log->refcount;
}
switch (entry->type) {
case LOG_ENTRY_MESH_IDS:
log_idmap_free(entry);
@ -881,6 +867,28 @@ static void bm_log_entry_free(BMLogEntry *entry)
CustomData_free(&entry->pdata, 0);
break;
}
}
/* Free the data in a log entry
* and handles bmlog ref counting
* NOTE: does not free the log entry itself. */
static void bm_log_entry_free(BMLogEntry *entry)
{
BMLog *log = entry->log;
bool kill_log = false;
if (log) {
log->refcount--;
if (log->refcount < 0) {
fprintf(stderr, "BMLog refcount error\n");
log->refcount = 0;
}
kill_log = !log->refcount;
}
bm_log_entry_free_direct(entry);
if (kill_log) {
bm_log_free_direct(log, true);
@ -2064,15 +2072,27 @@ void BM_log_full_mesh(BMesh *bm, BMLog *log)
entry = bm_log_entry_add_ex(bm, log, false, LOG_ENTRY_FULL_MESH, NULL);
}
bool add = BLI_ghash_len(entry->added_faces) > 0;
add |= BLI_ghash_len(entry->modified_verts) > 0;
add |= BLI_ghash_len(entry->modified_faces) > 0;
add |= BLI_ghash_len(entry->deleted_verts) > 0;
add |= BLI_ghash_len(entry->deleted_faces) > 0;
// add an entry if current entry isn't empty or isn't LOG_ENTRY_PARTIAL
bool add = false;
if (entry->type == LOG_ENTRY_PARTIAL) {
add = BLI_ghash_len(entry->added_faces) > 0;
add |= BLI_ghash_len(entry->modified_verts) > 0;
add |= BLI_ghash_len(entry->modified_faces) > 0;
add |= BLI_ghash_len(entry->deleted_verts) > 0;
add |= BLI_ghash_len(entry->deleted_faces) > 0;
}
else {
add = true;
}
if (add) {
entry = bm_log_entry_add_ex(bm, log, true, LOG_ENTRY_FULL_MESH, NULL);
}
else {
bm_log_entry_free_direct(entry);
entry->type = LOG_ENTRY_FULL_MESH;
}
bm_log_full_mesh_intern(bm, log, entry);

View File

@ -9535,7 +9535,6 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *op)
// symmetrize is messing up ids, regenerate them from scratch
BM_reassign_ids(ss->bm);
BM_log_full_mesh(ss->bm, ss->bm_log);
/* Finish undo. */