[Bf-blender-cvs] [da4349c1476] sculpt-dev: Sculpt-dev: fix shapekey undo bug with PBVH_FACES
Joseph Eagar
noreply at git.blender.org
Sat May 14 01:53:59 CEST 2022
Commit: da4349c147646b30cbfe0a78a5095e400cf4b5d7
Author: Joseph Eagar
Date: Fri May 13 16:53:47 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rBda4349c147646b30cbfe0a78a5095e400cf4b5d7
Sculpt-dev: fix shapekey undo bug with PBVH_FACES
* Also fixed bug in bmesh conversion code.
===================================================================
M source/blender/bmesh/intern/bmesh_mesh_convert.cc
M source/blender/editors/mesh/editmesh_utils.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
index 91126913e59..c7ce47a7eed 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
@@ -308,8 +308,21 @@ void BM_mesh_bm_from_me(Object *ob,
const Mesh *me,
const struct BMeshFromMeshParams *params)
{
- const bool is_new = !(bm->totvert || (bm->vdata.totlayer || bm->edata.totlayer ||
- bm->pdata.totlayer || bm->ldata.totlayer));
+ static int totlayers = 0;
+
+ for (int i = 0; i < 4; i++) {
+ CustomData *cdata = (&bm->vdata) + i;
+
+ for (int j = 0; j < cdata->totlayer; j++) {
+ if (cdata->layers[j].type == CD_TOOLFLAGS || cdata->layers[j].type == CD_MESH_ID) {
+ continue;
+ }
+
+ totlayers++;
+ }
+ }
+
+ const bool is_new = !(bm->totvert || totlayers);
KeyBlock *actkey;
float(*keyco)[3] = nullptr;
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index a1ea3230ba9..62cf51b0928 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -27,6 +27,7 @@
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_report.h"
+#include "BKE_pbvh.h"
#include "DEG_depsgraph.h"
@@ -304,6 +305,8 @@ void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data)
bm->shapenr = 1;
}
+ BKE_pbvh_invalidate_cache(ob);
+
BM_mesh_bm_to_me(bmain,
ob,
bm,
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 34717fa6bfc..8fc965e32ce 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -19,6 +19,7 @@
#include "BLI_threads.h"
#include "BLI_utildefines.h"
+#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -1716,6 +1717,8 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
unode->orig_co = MEM_malloc_arrayN(allvert, sizeof(float) * 3, "sculpt unode undo coords");
}
+ bool have_grids = BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS;
+
BKE_pbvh_vertex_iter_begin (ss->pbvh, unode->node, vd, PBVH_ITER_ALL) {
copy_v3_v3(unode->co[vd.i], vd.co);
if (vd.no) {
@@ -1726,9 +1729,15 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
}
if (ss->deform_modifiers_active) {
- SCULPT_orig_vert_data_update(&orig_data, vd.vertex);
+ if (!have_grids && ss->shapekey_active) {
+ float(*cos)[3] = ss->shapekey_active->data;
- copy_v3_v3(unode->orig_co[vd.i], orig_data.co);
+ copy_v3_v3(unode->orig_co[vd.i], cos[vd.index]);
+ }
+ else {
+ MSculptVert *mv = SCULPT_vertex_get_sculptvert(ss, vd.vertex);
+ copy_v3_v3(unode->orig_co[vd.i], mv->origco);
+ }
}
}
BKE_pbvh_vertex_iter_end;
More information about the Bf-blender-cvs
mailing list