[Bf-blender-cvs] [1e9a7383efa] temp_bmesh_multires: * Don't rely on BMLog's stored normals, instead flag pbvh nodes to update normals on undo/redo.

Joseph Eagar noreply at git.blender.org
Sun Aug 8 04:26:47 CEST 2021


Commit: 1e9a7383efa5b40eaef79b4bb82643f28b83b288
Author: Joseph Eagar
Date:   Sat Aug 7 19:25:36 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB1e9a7383efa5b40eaef79b4bb82643f28b83b288

* Don't rely on BMLog's stored normals, instead flag pbvh nodes to
  update normals on undo/redo.

===================================================================

M	source/blender/bmesh/intern/bmesh_log.c
M	source/blender/bmesh/intern/bmesh_log.h
M	source/blender/editors/sculpt_paint/sculpt_undo.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c
index acba919e817..9cab7fb02af 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -147,7 +147,7 @@ struct BMLog {
 
 typedef struct {
   float co[3];
-  short no[3];
+  float no[3];
   char hflag;
   float mask;
   void *customdata;
@@ -399,7 +399,8 @@ static void bm_log_vert_bmvert_copy(BMLog *log,
                                     bool copy_customdata)
 {
   copy_v3_v3(lv->co, v->co);
-  normal_float_to_short_v3(lv->no, v->no);
+  copy_v3_v3(lv->no, v->no);
+
   lv->mask = vert_mask_get(v, cd_vert_mask_offset);
   lv->hflag = v->head.hflag;
 
@@ -583,10 +584,13 @@ static void bm_log_verts_restore(
   GHASH_ITER (gh_iter, verts) {
     void *key = BLI_ghashIterator_getKey(&gh_iter);
     BMLogVert *lv = BLI_ghashIterator_getValue(&gh_iter);
+
     BMVert *v = BM_vert_create(bm, lv->co, NULL, BM_CREATE_SKIP_ID);
+
     vert_mask_set(v, lv->mask, cd_vert_mask_offset);
+
     v->head.hflag = lv->hflag;
-    normal_short_to_float_v3(v->no, lv->no);
+    copy_v3_v3(v->no, lv->no);
 
 #ifdef CUSTOMDATA
     if (lv->customdata) {
@@ -698,13 +702,13 @@ static void bm_log_vert_values_swap(
     uint id = POINTER_AS_UINT(key);
     BMVert *v = bm_log_vert_from_id(log, id);
     float mask;
-    short normal[3];
 
     swap_v3_v3(v->co, lv->co);
-    copy_v3_v3_short(normal, lv->no);
-    normal_float_to_short_v3(lv->no, v->no);
-    normal_short_to_float_v3(v->no, normal);
+    swap_v3_v3(v->no, lv->no);
+
     SWAP(char, v->head.hflag, lv->hflag);
+
+    // TODO: probably don't need to deal with mask explicitly anymore
     mask = lv->mask;
     lv->mask = vert_mask_get(v, cd_vert_mask_offset);
     vert_mask_set(v, mask, cd_vert_mask_offset);
@@ -2120,7 +2124,7 @@ const float *BM_log_original_vert_co(BMLog *log, BMVert *v)
 /* Get the logged normal of a vertex
  *
  * Does not modify the log or the vertex */
-const short *BM_log_original_vert_no(BMLog *log, BMVert *v)
+const float *BM_log_original_vert_no(BMLog *log, BMVert *v)
 {
   BMLogEntry *entry = log->current_entry;
   const BMLogVert *lv;
@@ -2153,7 +2157,7 @@ float BM_log_original_mask(BMLog *log, BMVert *v)
   return lv->mask;
 }
 
-void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const short **r_no)
+void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const float **r_no)
 {
   BMLogEntry *entry = log->current_entry;
   const BMLogVert *lv;
diff --git a/source/blender/bmesh/intern/bmesh_log.h b/source/blender/bmesh/intern/bmesh_log.h
index c7a1629a496..f83c5741e10 100644
--- a/source/blender/bmesh/intern/bmesh_log.h
+++ b/source/blender/bmesh/intern/bmesh_log.h
@@ -115,13 +115,13 @@ void BM_log_before_all_removed(BMesh *bm, BMLog *log);
 const float *BM_log_original_vert_co(BMLog *log, BMVert *v);
 
 /* Get the logged normal of a vertex */
-const short *BM_log_original_vert_no(BMLog *log, BMVert *v);
+const float *BM_log_original_vert_no(BMLog *log, BMVert *v);
 
 /* Get the logged mask of a vertex */
 float BM_log_original_mask(BMLog *log, BMVert *v);
 
 /* Get the logged data of a vertex (avoid multiple lookups) */
-void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const short **r_no);
+void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const float **r_no);
 
 /* For internal use only (unit testing) */
 BMLogEntry *BM_log_current_entry(BMLog *log);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 769598ebab3..a2a60936fbb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -423,6 +423,7 @@ static void sculpt_undo_bmesh_restore_generic_task_cb(
   PBVHNode **nodes = userdata;
 
   BKE_pbvh_node_mark_redraw(nodes[n]);
+  BKE_pbvh_node_mark_normals_update(nodes[n]);
 }
 
 extern const char dyntopop_node_idx_layer_id[];



More information about the Bf-blender-cvs mailing list