[Bf-blender-cvs] [6f91eaad39b] temp_bmesh_multires: * Fixed an annoying number of undo bugs * Original data for bmesh pbvh is no longer handled by the undo code. This should eliminate a whole class of subtle and hard to track down bugs.
Joseph Eagar
noreply at git.blender.org
Thu Apr 8 05:40:05 CEST 2021
Commit: 6f91eaad39b021f516bca0e89638f6fd9b20aab5
Author: Joseph Eagar
Date: Wed Apr 7 20:39:16 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB6f91eaad39b021f516bca0e89638f6fd9b20aab5
* Fixed an annoying number of undo bugs
* Original data for bmesh pbvh is no longer handled by the undo code.
This should eliminate a whole class of subtle and hard to track down
bugs.
===================================================================
M source/blender/blenkernel/BKE_customdata.h
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/bmesh/intern/bmesh_log.c
M source/blender/bmesh/intern/bmesh_log.h
M source/blender/draw/engines/overlay/overlay_lattice.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
M source/blender/makesdna/DNA_meshdata_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index b31f004628d..5e8eb60f94d 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -268,6 +268,12 @@ void CustomData_copy_data_named(const struct CustomData *source,
int dest_index,
int count);
void CustomData_copy_elements(int type, void *src_data_ofs, void *dst_data_ofs, int count);
+
+void CustomData_bmesh_swap_data(struct CustomData *source,
+ struct CustomData *dest,
+ void *src_block,
+ void **dest_block);
+
void CustomData_bmesh_copy_data(const struct CustomData *source,
struct CustomData *dest,
void *src_block,
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 66ffb6541ea..930c7b6f7e5 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -23,11 +23,11 @@
* \ingroup bke
*/
+#include "BKE_pbvh.h"
#include "BLI_bitmap.h"
#include "BLI_utildefines.h"
#include "DNA_brush_enums.h"
#include "DNA_object_enums.h"
-#include "BKE_pbvh.h"
#ifdef __cplusplus
extern "C" {
@@ -344,7 +344,7 @@ typedef struct SculptClothSimulation {
struct GHash *node_state_index;
eSculptClothNodeSimState *node_state;
- //persistent base customdata layer offsets
+ // persistent base customdata layer offsets
int cd_pers_co;
int cd_pers_no;
int cd_pers_disp;
@@ -624,6 +624,10 @@ typedef struct SculptSession {
*/
char needs_flush_to_id;
char update_boundary_info_bmesh;
+
+ // id of current stroke, used to detect
+ // if vertex original data needs to be updated
+ int stroke_id;
} SculptSession;
void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 01968542ac1..c39082dbf46 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1533,6 +1533,7 @@ void layerDynTopoVert_interp(
if (i == 0) { // copy flag from first source
mv->flag = mv2->flag;
+ mv->stroke_id = mv2->stroke_id;
}
if (sub_weights) {
@@ -1949,10 +1950,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
NULL, // flag singleton layer
1,
N_("DynTopoVert"),
- layerDynTopoVert_copy,
- NULL,
- layerDynTopoVert_interp
- }};
+ layerDynTopoVert_copy,
+ NULL,
+ layerDynTopoVert_interp}};
static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
/* 0-4 */ "CDMVert",
@@ -3818,7 +3818,71 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
}
}
-void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
+__attribute__((optnone)) void CustomData_bmesh_swap_data(CustomData *source,
+ CustomData *dest,
+ void *src_block,
+ void **dest_block)
+{
+ int src_i = 0;
+ int dest_i = 0;
+ int dest_i_start = 0;
+
+ if (*dest_block == NULL) {
+ CustomData_bmesh_alloc_block(dest, dest_block);
+
+ if (*dest_block) {
+ memset(*dest_block, 0, dest->totsize);
+ CustomData_bmesh_set_default(dest, dest_block);
+ }
+ }
+
+ for (src_i = 0; src_i < source->totlayer; src_i++) {
+ /* find the first dest layer with type >= the source type
+ * (this should work because layers are ordered by type)
+ */
+ while (dest_i_start < dest->totlayer &&
+ dest->layers[dest_i_start].type < source->layers[src_i].type) {
+ dest_i_start++;
+ }
+
+ /* if there are no more dest layers, we're done */
+ if (dest_i_start >= dest->totlayer) {
+ return;
+ }
+
+ dest_i = dest_i_start;
+
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type == source->layers[src_i].type) {
+ /* if we found a matching layer, copy the data */
+ if (dest->layers[dest_i].type == source->layers[src_i].type &&
+ STREQ(dest->layers[dest_i].name, source->layers[src_i].name)) {
+ void *src_data = POINTER_OFFSET(src_block, source->layers[src_i].offset);
+ void *dest_data = POINTER_OFFSET(*dest_block, dest->layers[dest_i].offset);
+ const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
+ const uint size = typeInfo->size;
+
+ // swap data
+ char *bsrc = (char *)src_data;
+ char *bdst = (char *)dest_data;
+
+ for (int j = 0; j < size; j++) {
+ char t = *bsrc;
+ *bsrc = *bdst;
+ *bdst = t;
+
+ bsrc++;
+ bdst++;
+ }
+
+ break;
+ }
+
+ dest_i++;
+ }
+ }
+}
+
+__attribute__ ((optnone)) void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
CustomData *dest,
void *src_block,
void **dest_block,
@@ -3835,50 +3899,55 @@ void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
}
}
+ for (int dest_i=0; dest_i < dest->totlayer; dest_i++) {
+ CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
+ dest_i++;
+ }
+
/* copies a layer at a time */
- int dest_i = 0;
+ int dest_i_start = 0;
+
for (int src_i = 0; src_i < source->totlayer; src_i++) {
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
- while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
- CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
- dest_i++;
+ while (dest_i_start < dest->totlayer &&
+ dest->layers[dest_i_start].type < source->layers[src_i].type) {
+ dest_i_start++;
}
/* if there are no more dest layers, we're done */
- if (dest_i >= dest->totlayer) {
+ if (dest_i_start >= dest->totlayer) {
return;
}
- /* if we found a matching layer, copy the data */
- if (dest->layers[dest_i].type == source->layers[src_i].type &&
- STREQ(dest->layers[dest_i].name, source->layers[src_i].name)) {
- if (no_mask || ((CD_TYPE_AS_MASK(dest->layers[dest_i].type) & mask_exclude) == 0)) {
- const void *src_data = POINTER_OFFSET(src_block, source->layers[src_i].offset);
- void *dest_data = POINTER_OFFSET(*dest_block, dest->layers[dest_i].offset);
- const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
- if (typeInfo->copy) {
- typeInfo->copy(src_data, dest_data, 1);
- }
- else {
- memcpy(dest_data, src_data, typeInfo->size);
+ int dest_i = dest_i_start;
+
+ /*Previously this code was only checking one source layer against one destination.
+ Now it scans all the layers of that type. - joeedh
+ */
+ while (dest_i < dest->totlayer && dest->layers[dest_i].type == source->layers[src_i].type) {
+ /* if we found a matching layer, copy the data */
+ if (STREQ(dest->layers[dest_i].name, source->layers[src_i].name)) {
+ if (no_mask || ((CD_TYPE_AS_MASK(dest->layers[dest_i].type) & mask_exclude) == 0)) {
+ const void *src_data = POINTER_OFFSET(src_block, source->layers[src_i].offset);
+ void *dest_data = POINTER_OFFSET(*dest_block, dest->layers[dest_i].offset);
+ const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
+ if (typeInfo->copy) {
+ typeInfo->copy(src_data, dest_data, 1);
+ }
+ else {
+ memcpy(dest_data, src_data, typeInfo->size);
+ }
}
+
+ break;
}
- /* if there are multiple source & dest layers of the same type,
- * we don't want to copy all source layers to the same dest, so
- * increment dest_i
- */
dest_i++;
}
}
-
- while (dest_i < dest->totlayer) {
- CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
- dest_i++;
- }
}
void CustomData_bmesh_copy_data(const CustomData *source,
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 0d4bac4a2b9..f7581db5fd8 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -4091,6 +4091,7 @@ void BKE_pbvh_update_offsets(PBVH *pbvh,
pbvh->cd_face_node_offset = cd_face_node_offset;
pbvh->cd_vert_node_offset = cd_vert_node_offset;
pbvh->cd_vert_mask_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PAINT_MASK);
+ pbvh->cd_vcol_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PROP_COLOR);
pbvh->cd_dyn_vert = cd_dyn_vert;
}
diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index ecebc017e14..e6e1be15804 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -119,9 +119,6 @@ struct BMLog {
*/
BMLogEntry *current_entry;
- int cd_origco_offset;
- int cd_origno_offset;
- int cd_origvcol_offset;
int cd_dyn_vert;
};
@@ -260,17 +257,13 @@ static BMFace *bm_log_face_from_id(BMLog *log, uint id)
/************************ BMLogVert / BMLogFace ***********************/
-static void bm_log_vert_customdata(BMesh *bm, BMLog *log, BMVert *v, BMLogVert *lv)
+__attribute__((optnone)) static void bm_log_vert_customdata(
+ BMesh *bm, BMLog *log, BMLogEntry *entry, BMVert *v, BMLogVert *lv)
{
#ifdef CUSTOMDATA
// if (!lv) {
// return;
//}
- BMLogEntry *entry = log->current_entry;
-
- if (!entry) {
- return;
- }
if (lv->customdata) {
BLI_mempool_free(entry->vdata.pool, lv->customdata);
@@ -336,27 +329,34 @@ static void vert_mask_set(BMVert *v, const float new_mask, const int cd_vert_mas
}
/* Update a BMLogVert with data from a BMVert */
-static void bm_log_vert_bmvert_copy(BMLog *log,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list