[Bf-blender-cvs] [e18be332b38] sculpt-dev: sculpt-dev: Experimental: Flush sculpt data to mesh on autosave
Joseph Eagar
noreply at git.blender.org
Fri Oct 7 10:40:16 CEST 2022
Commit: e18be332b38b44ad074d573dbfb4dea6a356caa6
Author: Joseph Eagar
Date: Fri Oct 7 01:39:11 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rBe18be332b38b44ad074d573dbfb4dea6a356caa6
sculpt-dev: Experimental: Flush sculpt data to mesh on autosave
===================================================================
M source/blender/blenkernel/intern/paint.cc
M source/blender/bmesh/CMakeLists.txt
M source/blender/bmesh/intern/bmesh_log.c
D source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
M source/blender/editors/undo/memfile_undo.c
M source/blender/makesrna/intern/rna_wm_api.c
M source/blender/windowmanager/intern/wm_files.c
===================================================================
diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc
index c807d600280..b7d9010c842 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -1427,7 +1427,7 @@ void BKE_sculptsession_free_vwpaint_data(SculptSession *ss)
/**
* Write out the sculpt dynamic-topology #BMesh to the #Mesh.
*/
-static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
+ATTR_NO_OPT static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
{
SculptSession *ss = ob->sculpt;
diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index 865a44774a0..a972c240396 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -85,7 +85,7 @@ set(SRC
intern/bmesh_marking.h
intern/bmesh_mesh.cc
intern/bmesh_mesh.h
- intern/bmesh_mesh_convert_threaded.c
+ intern/bmesh_mesh_convert_threaded.cc
intern/bmesh_mesh_convert.cc
intern/bmesh_mesh_convert.h
intern/bmesh_mesh_debug.c
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index b170137d0ac..665009ca494 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -4032,3 +4032,40 @@ bool BM_log_has_face_post(BMLog *log, BMFace *f)
return BLI_ghash_haskey(log->current_entry->topo_modified_faces_post,
POINTER_FROM_UINT(BM_ELEM_GET_ID(log->bm, f)));
}
+
+void BM_log_get_changed(BMesh *bm, BMLogEntry *_entry, SmallHash *sh)
+{
+ BMLogEntry *entry = _entry;
+
+ while (entry->combined_prev) {
+ entry = entry->combined_prev;
+ }
+
+ while (entry) {
+ GHashIterator gh_iter;
+
+ GHash **ghashes = &entry->topo_modified_verts_pre;
+
+ for (int i = 0; i < 9; i++) {
+ GHASH_ITER (gh_iter, ghashes[i]) {
+ void *key = BLI_ghashIterator_getKey(&gh_iter);
+ uint id = POINTER_AS_UINT(key);
+
+ /* Note: elements are not guaranteed to exist */
+ if (id >= bm->idmap.map_size) {
+ continue;
+ }
+
+ BMElem *elem = BM_ELEM_FROM_ID(bm, id);
+
+ if (!elem) {
+ continue;
+ }
+
+ BLI_smallhash_reinsert(sh, (uintptr_t)elem, (void *)elem);
+ }
+ }
+
+ entry = entry->combined_next;
+ }
+}
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c b/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
deleted file mode 100644
index 9f3f062cb9f..00000000000
--- a/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
+++ /dev/null
@@ -1,1198 +0,0 @@
-#if 0
-# include "DNA_key_types.h"
-# include "DNA_mesh_types.h"
-# include "DNA_meshdata_types.h"
-# include "DNA_modifier_types.h"
-# include "DNA_object_types.h"
-
-# include "MEM_guardedalloc.h"
-
-# include "BLI_alloca.h"
-# include "BLI_compiler_attrs.h"
-# include "BLI_listbase.h"
-# include "BLI_math_vector.h"
-# include "BLI_task.h"
-# include "BLI_threads.h"
-
-# include "BKE_customdata.h"
-# include "BKE_mesh.h"
-# include "BKE_mesh_runtime.h"
-# include "BKE_multires.h"
-
-# include "BKE_key.h"
-# include "BKE_main.h"
-
-# include "DEG_depsgraph_query.h"
-
-# include "bmesh.h"
-# include "intern/bmesh_private.h" /* For element checking. */
-
-# include "BLI_task.h"
-
-# include "atomic_ops.h"
-
-# define ECHUNK 512
-# define VCHUNK 512
-# define FCHUNK 512
-# define LCHUNK 1024
-
-typedef struct BMThreadData {
- BMesh *bm;
- Object *ob;
- const Mesh *me;
-
- struct BMeshFromMeshParams *params;
-
- void **vdata, **edata, **ldata, **fdata;
- int totdv, totde, totdl, totdf;
- int vsize, esize, lsize, fsize;
-
- int vchunk, echunk, lchunk, fchunk;
-
- BMVert **verts;
- BMEdge **edges;
- BMLoop **loops;
- BMFace **faces;
-
- float (**shape_key_table)[3];
- int tot_shape_keys;
-
- int cd_vert_bweight;
- int cd_edge_bweight;
- int cd_crease;
-
- int cdvsize, cdesize, cdlsize, cdfsize;
-
- // chunk sizes
- int totcv, totce, totcl, totcf;
-} BMThreadData;
-
-# define ELEM_NEXT(type, ptr, size) ((type *)(((char *)ptr) + size))
-
-static void bm_vert_task(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- BMThreadData *data = userdata;
- BMesh *bm = data->bm;
- const Mesh *me = data->me;
-
- int starti = n * VCHUNK;
-
- int ilen = starti + VCHUNK > bm->totvert ? bm->totvert - starti : VCHUNK;
- MVert *mv = me->mvert + starti;
- BMVert *v = data->verts[n];
- char *cdblock = data->vdata ? (char *)data->vdata[n] : NULL;
-
- for (int i = 0; i < ilen; i++, mv++) {
- if (cdblock) {
- v->head.data = (void *)cdblock;
- cdblock += data->cdvsize;
- }
- else {
- v->head.data = NULL;
- }
-
- v->head.htype = BM_VERT;
- v->head.hflag = BM_vert_flag_from_mflag(mv->flag);
- v->head.api_flag = 0;
-
- copy_v3_v3(v->co, mv->co);
- // XXX normal_short_to_float_v3(v->no, mv->no);
-
- v->e = NULL;
- v->head.index = i + starti;
- v = ELEM_NEXT(BMVert, v, data->vsize);
- }
-
- if (data->vdata) {
- v = data->verts[n];
- for (int i = 0; i < ilen; i++) {
- CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i + starti, &v->head.data, true);
- v = ELEM_NEXT(BMVert, v, data->vsize);
- }
- }
-}
-
-static void bm_edge_task(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- BMThreadData *data = userdata;
- BMesh *bm = data->bm;
- const Mesh *me = data->me;
-
- int starti = n * ECHUNK;
-
- int ilen = starti + ECHUNK > bm->totedge ? bm->totedge - starti : ECHUNK;
- MEdge *med = me->medge + starti;
- BMEdge *e = data->edges[n];
- char *cdblock = data->edata ? (char *)data->edata[n] : NULL;
-
- for (int i = 0; i < ilen; i++, med++) {
- if (cdblock) {
- e->head.data = (void *)cdblock;
- cdblock += data->cdesize;
- }
- else {
- e->head.data = NULL;
- }
-
- e->head.htype = BM_EDGE;
- e->head.hflag = BM_edge_flag_from_mflag(med->flag);
- e->head.api_flag = 0;
-
- e->v1 = &data->verts[med->v1 / VCHUNK][med->v1 % VCHUNK];
- e->v2 = &data->verts[med->v2 / VCHUNK][med->v2 % VCHUNK];
-
- e->l = NULL;
- e->v1_disk_link.next = e->v1_disk_link.prev = NULL;
- e->v2_disk_link.next = e->v2_disk_link.prev = NULL;
-
- e = ELEM_NEXT(BMEdge, e, data->esize);
- }
-
- if (data->edata) {
- e = data->edges[n];
- for (int i = 0; i < ilen; i++) {
- CustomData_to_bmesh_block(&me->edata, &bm->edata, i + starti, &e->head.data, true);
- e = ELEM_NEXT(BMEdge, e, data->esize);
- }
- }
-}
-
-static void bm_loop_task(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- BMThreadData *data = userdata;
- BMesh *bm = data->bm;
- const Mesh *me = data->me;
-
- int starti = n * LCHUNK;
-
- int ilen = starti + LCHUNK > bm->totloop ? bm->totloop - starti : LCHUNK;
- MLoop *ml = me->mloop + starti;
- BMLoop *l = data->loops[n];
- char *cdblock = data->ldata ? (char *)data->ldata[n] : NULL;
-
- for (int i = 0; i < ilen; i++, ml++) {
- if (cdblock) {
- l->head.data = (void *)cdblock;
- cdblock += data->cdlsize;
- }
- else {
- l->head.data = NULL;
- }
-
- l->head.htype = BM_LOOP;
- l->head.hflag = 0;
- l->head.api_flag = 0;
-
- l->v = data->verts[ml->v / VCHUNK] + (ml->v % VCHUNK);
- l->e = data->edges[ml->e / ECHUNK] + (ml->e % ECHUNK);
- l->radial_next = l->radial_prev = l->next = l->prev = NULL;
- l->f = NULL;
-
- l = ELEM_NEXT(BMLoop, l, data->lsize);
- }
-
- if (data->ldata) {
- l = data->loops[n];
- for (int i = 0; i < ilen; i++) {
- CustomData_to_bmesh_block(&me->ldata, &bm->ldata, i + starti, &l->head.data, true);
- l = ELEM_NEXT(BMLoop, l, data->lsize);
- }
- }
-}
-
-static void bm_face_task(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
-{
- BMThreadData *data = userdata;
- BMesh *bm = data->bm;
- const Mesh *me = data->me;
-
- int starti = n * FCHUNK;
-
- int ilen = starti + FCHUNK > bm->totface ? bm->totface - starti : FCHUNK;
- MPoly *mp = me->mpoly + starti;
- BMFace *f = data->faces[n];
- char *cdblock = data->fdata ? (char *)data->fdata[n] : NULL;
-
- for (int i = 0; i < ilen; i++, mp++) {
- if (cdblock) {
- f->head.data = (void *)cdblock;
- cdblock += data->cdfsize;
- }
- else {
- f->head.data = NULL;
- }
-
- f->head.htype = BM_FACE;
- f->head.hflag = BM_face_flag_from_mflag(mp->flag);
- f->head.api_flag = 0;
-
- f->len = mp->totloop;
- f->mat_nr = mp->mat_nr;
- zero_v3(f->no);
-
- int li = mp->loopstart;
- BMLoop *lastl = NULL;
-
- for (int j = 0; j < mp->totloop; j++, li++) {
- BMLoop *l = data->loops[li / LCHUNK] + (li % LCHUNK);
-
- l->f = f;
-
- if (j == 0) {
- f->l_first = l;
- }
- else {
- lastl->next = l;
- l->prev = lastl;
- }
-
- lastl = l;
- }
-
- lastl->next = f->l_first;
- f->l_first->prev = lastl;
-
- f = ELEM_NEXT(BMFace, f, data->fsize);
- }
-
- if (data->fdata) {
- f = data->faces[n];
- for (int i = 0; i < ilen; i++) {
- CustomData_to_bmesh_block(&me->pdata, &bm->pdata, i + starti, &f->head.data, true);
- f = ELEM_NEXT(BMFace, f, data->fsize);
- }
- }
-}
-
-static void bm_mesh_cd_flag_apply(BMesh *bm, const char cd_flag)
-{
- /* CustomData_bmesh_init_pool() must run first */
- BLI_assert(bm->vdata.totlayer == 0 || bm->vdata.pool != NULL);
- BLI_assert(bm->edata.totlayer == 0 || bm->edata.pool != NULL);
- BLI_assert(bm->pdata.totlayer == 0 || bm->pdata.pool != NULL);
-
- if (cd_flag & ME_CDFLAG_VERT_BWEIGHT) {
- if (!CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
- CustomData_add_layer(&bm->vdata, CD_BWEIGHT, CD_ASSIGN, NULL, 0);
- }
- }
- else {
- if (CustomData_has_layer(&bm->vdata, CD_BWEIGHT)) {
- CustomData_free_layer_active(&bm->vdata, CD_BWEIGHT, 0);
- }
- }
-
- if (cd_flag & ME_CDFLA
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list