[Bf-blender-cvs] [4079136bf4f] sculpt-dev: sculpt-dev: Fix new BMLog for new id system

2023-02-06 Thread Joseph Eagar
Commit: 4079136bf4fe207fa37de73382bf6cbc6428761c
Author: Joseph Eagar
Date:   Mon Feb 6 02:52:36 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB4079136bf4fe207fa37de73382bf6cbc6428761c

sculpt-dev: Fix new BMLog for new id system

Everything seems to be working, I can now
start reverting the old ID system (which
was not suitable for master).

===

M   source/blender/bmesh/intern/bmesh_log.cc

===

diff --git a/source/blender/bmesh/intern/bmesh_log.cc 
b/source/blender/bmesh/intern/bmesh_log.cc
index adc22c599a4..e98aea0080e 100644
--- a/source/blender/bmesh/intern/bmesh_log.cc
+++ b/source/blender/bmesh/intern/bmesh_log.cc
@@ -418,10 +418,9 @@ struct BMLogEntry {
   template T *get_elem_from_id(BMesh *bm, BMID id)
   {
 #ifdef USE_NEW_IDMAP
-BMIdMap *idmap = idmap;
+return reinterpret_cast(BM_idmap_lookup(idmap, id.id));
 #else
 auto *idmap = >idmap;
-#endif
 
 if (idmap->flag & BM_NO_REUSE_IDS) {
   return reinterpret_cast(BLI_ghash_lookup(bm->idmap.ghash, 
POINTER_FROM_INT(id.id)));
@@ -433,18 +432,19 @@ struct BMLogEntry {
 }
 
 return reinterpret_cast(idmap->map[id.id]);
+#endif
   }
 
   template void assign_elem_id(BMesh *bm, T *elem, BMID _id, 
bool check_unique)
   {
-BMElem *bmelem = reinterpret_cast(elem);
 int id = _id.id;
 
 #ifdef USE_NEW_IDMAP
 if (check_unique) {
   BMElem *old;
+  old = BM_idmap_lookup(idmap, id);
 
-  if ((old = BM_idmap_lookup(idmap, id))) {
+  if (old && old != (BMElem *)elem) {
 printf("id conflict in bm_assign_id; elem %p (a %s) is being 
reassinged to id %d.\n",
elem,
get_elem_htype_str((int)elem->head.htype),
@@ -452,13 +452,14 @@ struct BMLogEntry {
 printf(
 "  elem %p (a %s) will get a new id\n", old, 
get_elem_htype_str((int)old->head.htype));
 
-BM_idmap_assign(idmap, elem, id);
+BM_idmap_assign(idmap, reinterpret_cast(elem), id);
 return;
   }
 }
 
-BM_idmap_assign(idmap, elem, id);
+BM_idmap_assign(idmap, reinterpret_cast(elem), id);
 #else
+BMElem *bmelem = reinterpret_cast(elem);
 bm_assign_id(bm, bmelem, (uint)id, check_unique);
 #endif
   }
@@ -533,7 +534,7 @@ struct BMLogEntry {
   printf("%s: error: wrong length for face, was %d, should be %d\n",
  __func__,
  f->len,
- lf->verts.size());
+ (int)lf->verts.size());
   return;
 }
 
@@ -711,7 +712,7 @@ struct BMLogEntry {
   ATTR_NO_OPT void undo(BMesh *bm, BMLogCallbacks *callbacks)
   {
 for (int i = sets.size() - 1; i >= 0; i--) {
-  printf("  - %d of %d\n", i, (int)(sets.size() - 1));
+  //printf("  - %d of %d\n", i, (int)(sets.size() - 1));
   sets[i]->undo(bm, callbacks);
 }
   }
@@ -1014,7 +1015,7 @@ void BMLogSetDiff::modify_edge(BMesh *bm, BMEdge *e)
 void BMLogSetDiff::add_face(BMesh *bm, BMFace *f)
 {
 #ifdef USE_NEW_IDMAP
-  BM_idmap_check_assign(log->idmap, (BMElem *)f);
+  BM_idmap_check_assign(entry->idmap, (BMElem *)f);
 #endif
 
   BMID id = entry->get_elem_id(bm, f);
@@ -1153,7 +1154,7 @@ ATTR_NO_OPT void BMLogSetDiff::remove_verts(BMesh *bm,
 }
 
 #ifdef USE_NEW_IDMAP
-BM_idmap_release(log->idmap, (BMElem *)v, false);
+BM_idmap_release(entry->idmap, (BMElem *)v, false);
 #endif
 BM_vert_kill(bm, v);
   }
@@ -1208,7 +1209,7 @@ void BMLogSetDiff::remove_edges(BMesh *bm,
 }
 
 #ifdef USE_NEW_IDMAP
-BM_idmap_release(entry->idmap, reinterpret_cast(e));
+BM_idmap_release(entry->idmap, reinterpret_cast(e), true);
 #endif
 BM_edge_kill(bm, e);
   }
@@ -1314,7 +1315,7 @@ ATTR_NO_OPT void BMLogSetDiff::remove_faces(BMesh *bm,
 }
 
 #ifdef USE_NEW_IDMAP
-BM_idmap_release(entry->idmap, reinterpret_cast(f));
+BM_idmap_release(entry->idmap, reinterpret_cast(f), true);
 #endif
 BM_face_kill(bm, f);
   }
@@ -1546,7 +1547,7 @@ void BM_log_full_mesh(BMesh *bm, BMLog *log)
 BMVert *BM_log_id_vert_get(BMesh *bm, BMLog *log, uint id)
 {
 #ifdef USE_NEW_IDMAP
-  return BM_idmap_lookup(log->idmap, id);
+  return reinterpret_cast(BM_idmap_lookup(log->idmap, id));
 #else
   return reinterpret_cast(BM_ELEM_FROM_ID(bm, id));
 #endif
@@ -1564,7 +1565,7 @@ uint BM_log_vert_id_get(BMesh *bm, BMLog *log, BMVert *v)
 BMFace *BM_log_id_face_get(BMesh *bm, BMLog *log, uint id)
 {
 #ifdef USE_NEW_IDMAP
-  return BM_idmap_lookup(log->idmap, id);
+  return reinterpret_cast(BM_idmap_lookup(log->idmap, id));
 #else
   return reinterpret_cast(BM_ELEM_FROM_ID(bm, id));
 #endif

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [155fa374eb3] sculpt-dev: sculpt-dev: Add face corner color attribute support to dyntopo undo

2023-02-06 Thread Joseph Eagar
Commit: 155fa374eb3bac338835c7e23e89a2fe8b2c2589
Author: Joseph Eagar
Date:   Mon Feb 6 02:40:12 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB155fa374eb3bac338835c7e23e89a2fe8b2c2589

sculpt-dev: Add face corner color attribute support to dyntopo undo

===

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

===

diff --git a/source/blender/bmesh/intern/bmesh_log.cc 
b/source/blender/bmesh/intern/bmesh_log.cc
index 51ac12ec526..adc22c599a4 100644
--- a/source/blender/bmesh/intern/bmesh_log.cc
+++ b/source/blender/bmesh/intern/bmesh_log.cc
@@ -221,7 +221,7 @@ struct BMLogSetDiff : public BMLogSetBase {
   void remove_edge(BMesh *bm, BMEdge *e);
   void modify_edge(BMesh *bm, BMEdge *e);
   void add_face(BMesh *bm, BMFace *f);
-  void remove_face(BMesh *bm, BMFace *f);
+  void remove_face(BMesh *bm, BMFace *f, bool no_check = false);
   void modify_face(BMesh *bm, BMFace *f);
 
   void undo(BMesh *bm, BMLogCallbacks *callbacks) override;
@@ -529,6 +529,23 @@ struct BMLogEntry {
   CustomData_bmesh_swap_data(, >pdata, lf->customdata, 
>head.data);
 }
 
+if (f->len != lf->verts.size()) {
+  printf("%s: error: wrong length for face, was %d, should be %d\n",
+ __func__,
+ f->len,
+ lf->verts.size());
+  return;
+}
+
+if (lf->loop_customdata[0]) {
+  BMLoop *l = f->l_first;
+
+  int i = 0;
+  do {
+CustomData_bmesh_swap_data(, >ldata, lf->loop_customdata[i], 
>head.data);
+i++;
+  } while ((l = l->next) != f->l_first);
+}
 std::swap(f->head.hflag, lf->flag);
   }
 
@@ -682,9 +699,9 @@ struct BMLogEntry {
   {
 current_diff_set(bm)->add_face(bm, f);
   }
-  void remove_face(BMesh *bm, BMFace *f)
+  void remove_face(BMesh *bm, BMFace *f, bool no_check = false)
   {
-current_diff_set(bm)->remove_face(bm, f);
+current_diff_set(bm)->remove_face(bm, f, no_check);
   }
   void modify_face(BMesh *bm, BMFace *f)
   {
@@ -856,10 +873,10 @@ struct BMLog {
 current_entry->add_face(bm, f);
   }
 
-  void remove_face(BMesh *bm, BMFace *f)
+  void remove_face(BMesh *bm, BMFace *f, bool no_check = false)
   {
 ensure_entry(bm);
-current_entry->remove_face(bm, f);
+current_entry->remove_face(bm, f, no_check);
   }
 
   void modify_face(BMesh *bm, BMFace *f)
@@ -1020,11 +1037,11 @@ void BMLogSetDiff::add_face(BMesh *bm, BMFace *f)
   added_faces.add(id, lf);
 }
 
-ATTR_NO_OPT void BMLogSetDiff::remove_face(BMesh *bm, BMFace *f)
+ATTR_NO_OPT void BMLogSetDiff::remove_face(BMesh *bm, BMFace *f, bool no_check)
 {
   BMID id = entry->get_elem_id(bm, f);
 
-  if (added_faces.remove(id) || removed_faces.contains(id)) {
+  if (!no_check && (added_faces.remove(id) || removed_faces.contains(id))) {
 return;
   }
 
@@ -1508,7 +1525,7 @@ ATTR_NO_OPT void BM_log_face_added(BMesh *bm, BMLog *log, 
BMFace *f)
 {
   log->add_face(bm, f);
 }
-void BM_log_face_modified(BMesh *bm, BMLog *log, BMFace *f)
+ATTR_NO_OPT void BM_log_face_modified(BMesh *bm, BMLog *log, BMFace *f)
 {
   log->modify_face(bm, f);
 }
@@ -1518,7 +1535,7 @@ void BM_log_face_removed(BMesh *bm, BMLog *log, BMFace *f)
 }
 void BM_log_face_removed_no_check(BMesh *bm, BMLog *log, BMFace *f)
 {
-  // XXX
+  log->remove_face(bm, f, true);
 }
 
 void BM_log_full_mesh(BMesh *bm, BMLog *log)
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c 
b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 10f85104d82..4cf4cfb9eb1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -2028,7 +2028,9 @@ void SCULPT_undo_ensure_bmlog(Object *ob)
   }
 }
 
-static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, 
SculptUndoType type)
+ATTR_NO_OPT static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob,
+  PBVHNode *node,
+  SculptUndoType type)
 {
   UndoSculpt *usculpt = sculpt_undo_get_nodes();
   SculptSession *ss = ob->sculpt;
@@ -2116,12 +2118,35 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object 
*ob, PBVHNode *node, Sculpt
   }
 
   case SCULPT_UNDO_COLOR: {
-BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
-  bm_logstack_push();
-  BM_log_vert_before_modified(ss->bm, ss->bm_log, vd.bm_vert);
-  bm_logstack_pop();
+Mesh *mesh = BKE_object_get_original_mesh(ob);
+CustomDataLayer *color_layer = 
BKE_id_attributes_active_color_get(>id);
+if (!color_layer) {
+  break;
+}
+eAttrDomain domain = BKE_id_attribute_domain(>id, color_lay

[Bf-blender-cvs] [e4851c22b07] sculpt-dev: sculpt-dev: Rewrite BMLog

2023-02-06 Thread Joseph Eagar
Commit: e4851c22b07717ceb353788d690c54caa8b749f5
Author: Joseph Eagar
Date:   Sat Feb 4 04:29:35 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBe4851c22b07717ceb353788d690c54caa8b749f5

sculpt-dev: Rewrite BMLog

Part one of BMLog C++ rewrite.

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/dyntopo_collapse.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/bmesh/CMakeLists.txt
M   source/blender/bmesh/intern/bmesh_construct.c
M   source/blender/bmesh/intern/bmesh_core.c
D   source/blender/bmesh/intern/bmesh_log.c
A   source/blender/bmesh/intern/bmesh_log.cc
M   source/blender/bmesh/intern/bmesh_log.h
M   source/blender/bmesh/intern/bmesh_log_intern.h
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M   source/blender/editors/sculpt_paint/sculpt_face_set.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_ops.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 3cee0640af7..31f466e5223 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -22,6 +22,8 @@
 #include "BKE_attribute.h"
 #include "BKE_pbvh.h"
 
+#include "bmesh_log.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -847,7 +849,7 @@ typedef struct SculptSession {
   bool ignore_uvs;
 
   /* Undo/redo log for dynamic topology sculpting */
-  struct BMLog *bm_log;
+  BMLog *bm_log;
 
   /* Limit surface/grids. */
   struct SubdivCCG *subdiv_ccg;
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 6dd175c47a6..c3aafb88da5 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -12,6 +12,7 @@
 #include "BLI_ghash.h"
 
 #include "bmesh.h"
+#include "bmesh_log.h"
 
 /* For embedding CCGKey in iterator. */
 #include "BKE_attribute.h"
@@ -93,7 +94,6 @@ typedef struct PBVHTriBuf {
 
 //#define WITH_PBVH_CACHE
 
-struct BMLog;
 struct BMesh;
 struct BMVert;
 struct BMEdge;
@@ -434,7 +434,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
   struct Mesh *me,
   struct BMesh *bm,
   bool smooth_shading,
-  struct BMLog *log,
+  BMLog *log,
   struct BMIdMap *idmap,
   const int cd_vert_node_offset,
   const int cd_face_node_offset,
@@ -462,8 +462,8 @@ void BKE_pbvh_build_pixels(PBVH *pbvh,
struct ImageUser *image_user);
 void BKE_pbvh_free(PBVH *pbvh);
 
-void BKE_pbvh_set_bm_log(PBVH *pbvh, struct BMLog *log);
-struct BMLog *BKE_pbvh_get_bm_log(PBVH *pbvh);
+void BKE_pbvh_set_bm_log(PBVH *pbvh, BMLog *log);
+BMLog *BKE_pbvh_get_bm_log(PBVH *pbvh);
 
 /* update MSculptVerts, doesn't take pbvh argument to allow usage if pbvh 
doesn't currently exist
  */
diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index 5cef8751343..18351f48c79 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -44,7 +44,7 @@
 #include "dyntopo_intern.hh"
 #include "pbvh_intern.h"
 
-#include 
+#include 
 
 namespace blender::dyntopo {
 
@@ -205,13 +205,13 @@ static void pbvh_kill_vert(PBVH *pbvh, BMVert *v, bool 
log_vert, bool log_edges)
   if (log_edges) {
 if (e) {
   do {
-BM_log_edge_removed(pbvh->bm_log, e);
+BM_log_edge_removed(pbvh->header.bm, pbvh->bm_log, e);
   } while ((e = BM_DISK_EDGE_NEXT(e, v)) != v->e);
 }
   }
 
   if (log_vert) {
-BM_log_vert_removed(pbvh->bm_log, v, -1);
+BM_log_vert_removed(pbvh->header.bm, pbvh->bm_log, v);
   }
 
 #ifdef USE_NEW_IDMAP
@@ -300,7 +300,7 @@ static BMVert *pbvh_bmesh_vert_create(PBVH *pbvh,
   node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB | PBVH_UpdateTris | 
PBVH_UpdateOtherVerts;
 
   /* Log the new vertex */
-  BM_log_vert_added(pbvh->bm_log, v, cd_vert_mask_offset);
+  BM_log_vert_added(pbvh->header.bm, pbvh->bm_log, v);
   v->head.index = pbvh->header.bm->totvert;  // set provisional index
 
   return v;
@@ -324,7 +324,7 @@ static BMFace *bmesh_face_create_edge_log(PBVH *pbv

[Bf-blender-cvs] [bd5f5597c89] sculpt-dev: sculpt-dev: BMLog rewrite part 2

2023-02-06 Thread Joseph Eagar
Commit: bd5f5597c895d9d920ddbee552631a44798dd54f
Author: Joseph Eagar
Date:   Mon Feb 6 02:20:06 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBbd5f5597c895d9d920ddbee552631a44798dd54f

sculpt-dev: BMLog rewrite part 2

Finished implementing old behavior.  I still
need to do more testing, but the code is now
much (much) cleaner and less confusing.

===

M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/bmesh/intern/bmesh_log.cc

===

diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index 18351f48c79..6b84f27ec73 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -759,7 +759,7 @@ static void edge_queue_insert_val34_vert(EdgeQueueContext 
*eq_ctx, BMVert *v)
   // BLI_table_gset_add(eq_ctx->used_verts, v);
   eq_ctx->tot_used_verts++;
 
-  if (!eq_ctx->used_verts || eq_ctx->tot_used_verts > eq_ctx->used_verts_size) 
{
+  if (!eq_ctx->used_verts || eq_ctx->tot_used_verts >= 
eq_ctx->used_verts_size) {
 int newlen = (eq_ctx->tot_used_verts + 1);
 newlen += newlen >> 1;
 
@@ -2718,6 +2718,8 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
   }
 
   EdgeQueueContext eq_ctx;
+  memset(static_cast(_ctx), 0, sizeof(eq_ctx));
+
   eq_ctx.pool = nullptr;
   eq_ctx.bm = pbvh->header.bm;
   eq_ctx.mask_cb = mask_cb;
diff --git a/source/blender/bmesh/intern/bmesh_log.cc 
b/source/blender/bmesh/intern/bmesh_log.cc
index 7a3497dbde9..51ac12ec526 100644
--- a/source/blender/bmesh/intern/bmesh_log.cc
+++ b/source/blender/bmesh/intern/bmesh_log.cc
@@ -98,7 +98,7 @@ template struct BMID {
 };
 
 template struct BMLogElem {
-  BMID id;
+  BMID id = BMID(-1);
   void *customdata = nullptr;
   char flag = 0;
 };
@@ -108,7 +108,8 @@ template struct LogElemAlloc {
 
   LogElemAlloc()
   {
-pool = BLI_mempool_create(sizeof(T), 0, 256, 0);
+/* We need an iterable pool to call individual destructors in 
~LogElemAlloc(). */
+pool = BLI_mempool_create(sizeof(T), 0, 256, BLI_MEMPOOL_ALLOW_ITER);
   }
 
   LogElemAlloc(const LogElemAlloc ) = delete;
@@ -133,15 +134,21 @@ template struct LogElemAlloc {
   ~LogElemAlloc()
   {
 if (pool) {
+  BLI_mempool_iter iter;
+  BLI_mempool_iternew(pool, );
+  while (void *entry = BLI_mempool_iterstep()) {
+T *ptr = static_cast(entry);
+ptr->~T();
+  }
+
   BLI_mempool_destroy(pool);
 }
   }
 
   T *alloc()
   {
-void *ret = BLI_mempool_alloc(pool);
-memset(ret, 0, sizeof(T));
-return static_cast(ret);
+void *mem = BLI_mempool_alloc(pool);
+return new (mem) T();
   }
 
   void free(T *elem)
@@ -158,8 +165,8 @@ struct BMLogVert : public BMLogElem {
 };
 
 struct BMLogEdge : public BMLogElem {
-  BMID v1;
-  BMID v2;
+  BMID v1 = BMID(-1);
+  BMID v2 = BMID(-1);
 };
 
 struct BMLogFace : public BMLogElem {
@@ -210,9 +217,12 @@ struct BMLogSetDiff : public BMLogSetBase {
   void add_vert(BMesh *bm, BMVert *v);
   void remove_vert(BMesh *bm, BMVert *v);
   void modify_vert(BMesh *bm, BMVert *v);
-  void add_face(BMesh *bm, BMFace *v);
-  void remove_face(BMesh *bm, BMFace *v);
-  void modify_face(BMesh *bm, BMFace *v);
+  void add_edge(BMesh *bm, BMEdge *e);
+  void remove_edge(BMesh *bm, BMEdge *e);
+  void modify_edge(BMesh *bm, BMEdge *e);
+  void add_face(BMesh *bm, BMFace *f);
+  void remove_face(BMesh *bm, BMFace *f);
+  void modify_face(BMesh *bm, BMFace *f);
 
   void undo(BMesh *bm, BMLogCallbacks *callbacks) override;
   void redo(BMesh *bm, BMLogCallbacks *callbacks) override;
@@ -226,15 +236,24 @@ struct BMLogSetDiff : public BMLogSetBase {
   void swap_verts(BMesh *bm,
   blender::Map, BMLogVert *> verts,
   BMLogCallbacks *callbacks);
+  void restore_edges(BMesh *bm,
+ blender::Map, BMLogEdge *> edges,
+ BMLogCallbacks *callbacks);
+  void remove_edges(BMesh *bm,
+blender::Map, BMLogEdge *> edges,
+BMLogCallbacks *callbacks);
+  void swap_edges(BMesh *bm,
+  blender::Map, BMLogEdge *> edges,
+  BMLogCallbacks *callbacks);
 
   void restore_faces(BMesh *bm,
- blender::Map, BMLogVert *> verts,
+ blender::Map, BMLogFace *> faces,
  BMLogCallbacks *callbacks);
   void remove_faces(BMesh *bm,
-blender::Map, BMLogVert *> verts,
+blender::Map, BMLogFace *> faces,
 BMLogCallbacks *callbacks);
   void swap_faces(BMesh *bm,
-  blender::Map, BMLogVert *> verts,
+  blender::Map, BMLogFace *> faces,
   BMLogCallbacks 

[Bf-blender-cvs] [9fc73526a05] sculpt-dev: sculpt-dev: remove optimization flags

2023-02-06 Thread Joseph Eagar
Commit: 9fc73526a0577662ebe86ed794e228a2a0b0e476
Author: Joseph Eagar
Date:   Thu Feb 2 12:14:55 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB9fc73526a0577662ebe86ed794e228a2a0b0e476

sculpt-dev: remove optimization flags

===

M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/dyntopo_collapse.cc
M   source/blender/blenkernel/intern/dyntopo_intern.hh
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenlib/intern/smallhash.c
M   source/blender/bmesh/intern/bmesh_core.c
M   source/blender/bmesh/intern/bmesh_idmap.cc
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/bmesh/intern/bmesh_mods.c
M   source/blender/draw/intern/draw_manager_data.cc
M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/editors/sculpt_paint/sculpt_face_set.cc
M   source/blender/editors/sculpt_paint/sculpt_smooth.c

===

diff --git a/source/blender/blenkernel/intern/customdata.cc 
b/source/blender/blenkernel/intern/customdata.cc
index f04a78eaa11..45bb3874ede 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4265,7 +4265,7 @@ void 
CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data,
 }
 
 #ifndef USE_BMESH_PAGE_CUSTOMDATA
-ATTR_NO_OPT static void CustomData_bmesh_set_default_n(CustomData *data, void 
**block, const int n)
+static void CustomData_bmesh_set_default_n(CustomData *data, void **block, 
const int n)
 {
   if (ELEM(data->layers[n].type, CD_TOOLFLAGS, CD_MESH_ID)) {
 /* do not do toolflags or mesh ids */
@@ -4414,11 +4414,11 @@ void CustomData_bmesh_swap_data(CustomData *source,
   }
 }
 
-ATTR_NO_OPT void CustomData_bmesh_copy_data_exclude_by_type(const CustomData 
*source,
-CustomData *dest,
-void *src_block,
-void **dest_block,
-const 
eCustomDataMask mask_exclude)
+void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
+CustomData *dest,
+void *src_block,
+void **dest_block,
+const eCustomDataMask 
mask_exclude)
 {
   /* Note that having a version of this function without a 'mask_exclude'
* would cause too much duplicate code, so add a check instead. */
@@ -4819,11 +4819,11 @@ void CustomData_bmesh_interp(CustomData *data,
   }
 }
 
-ATTR_NO_OPT void CustomData_to_bmesh_block(const CustomData *source,
-   CustomData *dest,
-   int src_index,
-   void **dest_block,
-   bool use_default_init)
+void CustomData_to_bmesh_block(const CustomData *source,
+   CustomData *dest,
+   int src_index,
+   void **dest_block,
+   bool use_default_init)
 {
   if (*dest_block == nullptr) {
 CustomData_bmesh_alloc_block(dest, dest_block);
diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index 987bcb1879f..5cef8751343 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -1393,7 +1393,7 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
   return false;
 }
 
-ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
+bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
 {
 #if !(DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_FIN_REMOVAL)
   bm_logstack_push();
@@ -3163,12 +3163,12 @@ static const int splitmap[43][16] = {
 {6, -1, 3, -1, 5, -1, 1},  // 42 0 1 0 1 0 1
 };
 
-ATTR_NO_OPT static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
- PBVH *pbvh,
- BMesh *bm,
- BMEdge **edges1,
- int totedge,
- bool ignore_isolated_edges)
+static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
+ PBVH *pbvh,
+ BMesh *bm,
+ BMEdge **edges1,
+ int totedge,
+  

[Bf-blender-cvs] [0a9520ce846] master: Sculpt: Un-invert expand normal falloff

2023-01-31 Thread Joseph Eagar
Commit: 0a9520ce846d29742dbb1afa79a97a56cab0abeb
Author: Joseph Eagar
Date:   Tue Jan 31 10:01:18 2023 -0800
Branches: master
https://developer.blender.org/rB0a9520ce846d29742dbb1afa79a97a56cab0abeb

Sculpt: Un-invert expand normal falloff

Normals falloff mask is created inverted compared
to how other falloffs work.  It's now un-inverted
in a final step at the end.

Also exposed the normals falloff smooth steps as
an RNA property.

===

M   source/blender/editors/sculpt_paint/sculpt_expand.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc 
b/source/blender/editors/sculpt_paint/sculpt_expand.cc
index b6a71a69287..64b71ba26f1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc
@@ -517,11 +517,12 @@ static bool mask_expand_normal_floodfill_cb(
 static float *sculpt_expand_normal_falloff_create(Sculpt *sd,
   Object *ob,
   const PBVHVertRef v,
-  const float edge_sensitivity)
+  const float edge_sensitivity,
+  const int blur_steps)
 {
   SculptSession *ss = ob->sculpt;
   const int totvert = SCULPT_vertex_count_get(ss);
-  float *dists = static_cast(MEM_malloc_arrayN(totvert, 
sizeof(float), __func__));
+  float *dists = static_cast(MEM_calloc_arrayN(totvert, 
sizeof(float), __func__));
   float *edge_factor = static_cast(MEM_callocN(sizeof(float) * 
totvert, __func__));
   for (int i = 0; i < totvert; i++) {
 edge_factor[i] = 1.0f;
@@ -540,7 +541,7 @@ static float *sculpt_expand_normal_falloff_create(Sculpt 
*sd,
   SCULPT_floodfill_execute(ss, , mask_expand_normal_floodfill_cb, 
);
   SCULPT_floodfill_free();
 
-  for (int repeat = 0; repeat < 2; repeat++) {
+  for (int repeat = 0; repeat < blur_steps; repeat++) {
 for (int i = 0; i < totvert; i++) {
   PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
 
@@ -550,10 +551,17 @@ static float *sculpt_expand_normal_falloff_create(Sculpt 
*sd,
 avg += dists[ni.index];
   }
   SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
-  dists[i] = avg / ni.size;
+
+  if (ni.size > 0.0f) {
+dists[i] = avg / ni.size;
+  }
 }
   }
 
+  for (int i = 0; i < totvert; i++) {
+dists[i] = 1.0 - dists[i];
+  }
+
   MEM_SAFE_FREE(edge_factor);
 
   return dists;
@@ -1049,7 +1057,11 @@ static void 
sculpt_expand_falloff_factors_from_vertex_and_symm_create(
   break;
 case SCULPT_EXPAND_FALLOFF_NORMALS:
   expand_cache->vert_falloff = sculpt_expand_normal_falloff_create(
-  sd, ob, v, SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY);
+  sd,
+  ob,
+  v,
+  SCULPT_EXPAND_NORMALS_FALLOFF_EDGE_SENSITIVITY,
+  expand_cache->normal_falloff_blur_steps);
   break;
 case SCULPT_EXPAND_FALLOFF_SPHERICAL:
   expand_cache->vert_falloff = sculpt_expand_spherical_falloff_create(ob, 
v);
@@ -2066,6 +2078,7 @@ static void 
sculpt_expand_cache_initial_config_set(bContext *C,
ExpandCache *expand_cache)
 {
   /* RNA properties. */
+  expand_cache->normal_falloff_blur_steps = RNA_int_get(op->ptr, 
"normal_falloff_smooth");
   expand_cache->invert = RNA_boolean_get(op->ptr, "invert");
   expand_cache->preserve = RNA_boolean_get(op->ptr, "use_mask_preserve");
   expand_cache->auto_mask = RNA_boolean_get(op->ptr, "use_auto_mask");
@@ -2415,4 +2428,13 @@ void SCULPT_OT_expand(wmOperatorType *ot)
  false,
  "Auto Create",
  "Fill in mask if nothing is already masked");
+  ot->prop = RNA_def_int(ot->srna,
+ "normal_falloff_smooth",
+ 2,
+ 0,
+ 10,
+ "Normal Smooth",
+ "Blurring steps for normal falloff",
+ 0,
+ 10);
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 64529525099..154e9a7decc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -822,6 +822,7 @@ typedef struct ExpandCache {
   float (*original_colors)[4];
 
   bool check_islands;
+  int normal_falloff_blur_steps;
 } ExpandCache;
 /** \} */

__

[Bf-blender-cvs] [3750e7ef0b9] master: Sculpt: Don't invert in geodesic mask expand keymap

2023-01-31 Thread Joseph Eagar
Commit: 3750e7ef0b922e73567ce80881850f767333005e
Author: Joseph Eagar
Date:   Tue Jan 31 10:18:08 2023 -0800
Branches: master
https://developer.blender.org/rB3750e7ef0b922e73567ce80881850f767333005e

Sculpt: Don't invert in geodesic mask expand keymap

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index e1b34e4cc55..01e6ac0f0c0 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5048,7 +5048,7 @@ def km_sculpt(params):
  {"properties": [
  ("target", "MASK"),
  ("falloff_type", "GEODESIC"),
- ("invert", True),
+ ("invert", False),
  ("use_auto_mask", False),
  ("use_mask_preserve", True),
  ]}),

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [91263a8b8ba] master: Sculpt: Fix T104040: Always update eevee shadows in sculpt modes

2023-01-30 Thread Joseph Eagar
Commit: 91263a8b8baa5e107da717eb4b56ee51c2269636
Author: Joseph Eagar
Date:   Mon Jan 30 21:28:30 2023 -0800
Branches: master
https://developer.blender.org/rB91263a8b8baa5e107da717eb4b56ee51c2269636

Sculpt: Fix T104040: Always update eevee shadows in sculpt modes

===

M   source/blender/draw/engines/eevee/eevee_materials.c
M   source/blender/draw/engines/eevee/eevee_shadows.c

===

diff --git a/source/blender/draw/engines/eevee/eevee_materials.c 
b/source/blender/draw/engines/eevee/eevee_materials.c
index e5645ac4a96..81ec8981c9c 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -848,6 +848,8 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
 
 MATCACHE_AS_ARRAY(matcache, shadow_grp, materials_len, shgrps_array);
 DRW_shgroup_call_sculpt_with_materials(shgrps_array, gpumat_array, 
materials_len, ob);
+
+*cast_shadow = true;
   }
   else {
 struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, 
materials_len);
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c 
b/source/blender/draw/engines/eevee/eevee_shadows.c
index 1cf3c7c6da1..ac039e22f38 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -139,6 +139,10 @@ void EEVEE_shadows_caster_register(EEVEE_ViewLayerData 
*sldata, Object *ob)
   BLI_BITMAP_SET(backbuffer->update, past_id, oedata->need_update);
 }
 update = oedata->need_update;
+
+/* Always update shadow buffers in sculpt modes. */
+update |= ob->sculpt != NULL;
+
 oedata->need_update = false;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a391a01509a] sculpt-dev: sculpt-dev: Cleanup and fix bugs in dyntopo subdivide

2023-01-30 Thread Joseph Eagar
Commit: a391a01509a3984df37b634b3a11c14ede556ab4
Author: Joseph Eagar
Date:   Mon Jan 30 15:53:19 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBa391a01509a3984df37b634b3a11c14ede556ab4

sculpt-dev: Cleanup and fix bugs in dyntopo subdivide

* Removed unused code.
* Fixed nasty double increment bug.
* Fixed subdivision patterns.

===

M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/dyntopo_intern.hh
M   source/blender/bmesh/intern/bmesh_idmap.cc
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/source/blender/blenkernel/intern/customdata.cc 
b/source/blender/blenkernel/intern/customdata.cc
index 7b912cb7285..f04a78eaa11 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4265,7 +4265,7 @@ void 
CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data,
 }
 
 #ifndef USE_BMESH_PAGE_CUSTOMDATA
-static void CustomData_bmesh_set_default_n(CustomData *data, void **block, 
const int n)
+ATTR_NO_OPT static void CustomData_bmesh_set_default_n(CustomData *data, void 
**block, const int n)
 {
   if (ELEM(data->layers[n].type, CD_TOOLFLAGS, CD_MESH_ID)) {
 /* do not do toolflags or mesh ids */
@@ -4414,11 +4414,11 @@ void CustomData_bmesh_swap_data(CustomData *source,
   }
 }
 
-void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
-CustomData *dest,
-void *src_block,
-void **dest_block,
-const eCustomDataMask 
mask_exclude)
+ATTR_NO_OPT void CustomData_bmesh_copy_data_exclude_by_type(const CustomData 
*source,
+CustomData *dest,
+void *src_block,
+void **dest_block,
+const 
eCustomDataMask mask_exclude)
 {
   /* Note that having a version of this function without a 'mask_exclude'
* would cause too much duplicate code, so add a check instead. */
@@ -,7 +,6 @@ 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 */
diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index 28e456c76a3..987bcb1879f 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -1257,6 +1257,10 @@ static void unified_edge_queue_task_cb(void *__restrict 
userdata,
 
 bool check_face_is_tri(PBVH *pbvh, BMFace *f)
 {
+#if DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_TRIANGULATOR
+  return true;
+#endif
+
   if (f->len == 3) {
 return true;
   }
@@ -1391,7 +1395,7 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
 
 ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
 {
-#if 0
+#if !(DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_FIN_REMOVAL)
   bm_logstack_push();
 
   static int max_faces = 64;
@@ -2756,6 +2760,13 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH 
*pbvh,
 mode |= PBVH_Collapse;
   }
 
+#if DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_COLLAPSE
+  mode &= ~PBVH_Collapse;
+#endif
+#if DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_SPLIT_EDGES
+  mode &= ~PBVH_Subdivide;
+#endif
+
   if (mode & (PBVH_Subdivide | PBVH_Collapse)) {
 unified_edge_queue_create(_ctx,
   pbvh,
@@ -2907,7 +2918,11 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH 
*pbvh,
 
 if (bm_elem_is_free((BMElem *)e->v1, BM_VERT) ||
 bm_elem_is_free((BMElem *)e->v2, BM_VERT)) {
-  printf("%s: error!\n");
+  printf("%s: error! operated on freed bmesh elements! e: %p, e->v1: 
%p, e->v2: %p\n",
+ __func__,
+ e,
+ e->v1,
+ e->v2);
   break;
 }
 
@@ -3012,15 +3027,16 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH 
*pbvh,
   return modified;
 }
 
-#define SPLIT_TAG BM_ELEM_TAG_ALT
+#define SPLIT_TAG BM_ELEM_TAG
 
 /*
-#generate shifted and mirrored patterns
 
+#generate shifted and mirrored patterns
+# [number of verts, vert_connections... ]
 table = [
-  [4, 3, -1, -1, -1],
-  [5, -1, 3, -1, 4, -1],
-  [6, -1, 3, -1, 5, -1, 1, -1]
+  [4, -1,  3, -1,

[Bf-blender-cvs] [042775ad482] master: Sculpt: Fix T104068, depth calculation error in trim tools

2023-01-28 Thread Joseph Eagar
Commit: 042775ad482977a930528bf11eb26da5ce2810f0
Author: Joseph Eagar
Date:   Sat Jan 28 16:04:50 2023 -0800
Branches: master
https://developer.blender.org/rB042775ad482977a930528bf11eb26da5ce2810f0

Sculpt: Fix T104068, depth calculation error in trim tools

Also made the coplanar padding factor relative.

===

M   source/blender/editors/sculpt_paint/paint_mask.cc

===

diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc 
b/source/blender/editors/sculpt_paint/paint_mask.cc
index c0f4ddf4218..177bc33bed5 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.cc
+++ b/source/blender/editors/sculpt_paint/paint_mask.cc
@@ -1148,13 +1148,16 @@ static void 
sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
 
   float depth_front = trim_operation->depth_front;
   float depth_back = trim_operation->depth_back;
+  float pad_factor = 0.0f;
 
   if (!trim_operation->use_cursor_depth) {
+pad_factor = (depth_back - depth_front) * 0.01f + 0.001f;
+
 /* When using cursor depth, don't modify the depth set by the cursor 
radius. If full depth is
  * used, adding a little padding to the trimming shape can help avoiding 
booleans with coplanar
  * faces. */
-depth_front -= 0.1f;
-depth_back += 0.1f;
+depth_front -= pad_factor;
+depth_back += pad_factor;
   }
 
   float shape_origin[3];
@@ -1198,7 +1201,9 @@ static void 
sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
 }
 else {
   copy_v3_v3(new_point, positions[i]);
-  madd_v3_v3fl(new_point, shape_normal, depth_back);
+  float dist = dist_signed_to_plane_v3(new_point, shape_plane);
+
+  madd_v3_v3fl(new_point, shape_normal, depth_back - dist);
 }
 
 copy_v3_v3(positions[i + tot_screen_points], new_point);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f68b5cd7e1c] sculpt-dev: sculpt-dev: Cleanup collapse code

2023-01-28 Thread Joseph Eagar
Commit: f68b5cd7e1c831dcf6518107d485443d2cf5d6d1
Author: Joseph Eagar
Date:   Fri Jan 27 23:35:48 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBf68b5cd7e1c831dcf6518107d485443d2cf5d6d1

sculpt-dev: Cleanup collapse code

===

M   source/blender/blenkernel/intern/dyntopo_collapse.cc
M   source/blender/bmesh/intern/bmesh_idmap.h

===

diff --git a/source/blender/blenkernel/intern/dyntopo_collapse.cc 
b/source/blender/blenkernel/intern/dyntopo_collapse.cc
index dc7173f66ad..33ab9617891 100644
--- a/source/blender/blenkernel/intern/dyntopo_collapse.cc
+++ b/source/blender/blenkernel/intern/dyntopo_collapse.cc
@@ -34,6 +34,7 @@
 #include "dyntopo_intern.hh"
 #include "pbvh_intern.h"
 
+#include 
 #include 
 
 using blender::float2;
@@ -131,8 +132,7 @@ inline bool bm_edge_collapse_is_degenerate_topology(BMEdge 
*e_first)
 
 typedef struct TraceData {
   PBVH *pbvh;
-  SmallHash visit;
-  blender::Set visit2;
+  blender::Set visit;
   BMEdge *e;
 } TraceData;
 
@@ -146,10 +146,9 @@ ATTR_NO_OPT void col_on_vert_kill(BMesh *bm, BMVert *v, 
void *userdata)
 blender::dyntopo::pbvh_bmesh_vert_remove(pbvh, v);
   }
 
-  if (!BLI_smallhash_haskey(>visit, (uintptr_t)v)) {
+  if (!data->visit.add(static_cast(v))) {
 // printf("vert kill!\n");
 BM_log_vert_pre(pbvh->bm_log, v);
-BLI_smallhash_insert(>visit, (uintptr_t)v, nullptr);
 #ifdef USE_NEW_IDMAP
 BM_idmap_release(pbvh->bm_idmap, reinterpret_cast(v), true);
 #endif
@@ -161,10 +160,9 @@ ATTR_NO_OPT void col_on_edge_kill(BMesh *bm, BMEdge *e, 
void *userdata)
   TraceData *data = (TraceData *)userdata;
   PBVH *pbvh = data->pbvh;
 
-  if (!BLI_smallhash_haskey(>visit, (uintptr_t)e)) {
+  if (!data->visit.add(static_cast(e))) {
 // printf("edge kill!\n");
 BM_log_edge_pre(pbvh->bm_log, e);
-BLI_smallhash_insert(>visit, (uintptr_t)e, nullptr);
 #ifdef USE_NEW_IDMAP
 BM_idmap_release(pbvh->bm_idmap, reinterpret_cast(e), true);
 #endif
@@ -180,9 +178,8 @@ ATTR_NO_OPT void col_on_face_kill(BMesh *bm, BMFace *f, 
void *userdata)
 pbvh_bmesh_face_remove(pbvh, f, false, false, false);
   }
 
-  if (!BLI_smallhash_haskey(>visit, (uintptr_t)f)) {
+  if (!data->visit.add(static_cast(f))) {
 BM_log_face_pre(pbvh->bm_log, f);
-BLI_smallhash_insert(>visit, (uintptr_t)f, nullptr);
 #ifdef USE_NEW_IDMAP
 BM_idmap_release(pbvh->bm_idmap, reinterpret_cast(f), true);
 #endif
@@ -206,8 +203,8 @@ ATTR_NO_OPT void col_on_vert_add(BMesh *bm, BMVert *v, void 
*userdata)
   TraceData *data = (TraceData *)userdata;
   PBVH *pbvh = data->pbvh;
 
-  if (!data->visit2.add(static_cast(v))) {
-// return;
+  if (!data->visit.add(static_cast(v))) {
+//  return;
   }
 
   pbvh_boundary_update_bmesh(pbvh, v);
@@ -224,7 +221,7 @@ ATTR_NO_OPT void col_on_edge_add(BMesh *bm, BMEdge *e, void 
*userdata)
   TraceData *data = (TraceData *)userdata;
   PBVH *pbvh = data->pbvh;
 
-  if (!data->visit2.add(static_cast(e))) {
+  if (!data->visit.add(static_cast(e))) {
 // return;
   }
 
@@ -237,7 +234,7 @@ ATTR_NO_OPT void col_on_face_add(BMesh *bm, BMFace *f, void 
*userdata)
   TraceData *data = (TraceData *)userdata;
   PBVH *pbvh = data->pbvh;
 
-  if (!data->visit2.add(static_cast(f))) {
+  if (!data->visit.add(static_cast(f))) {
 // return;
   }
 
@@ -326,7 +323,7 @@ ATTR_NO_OPT static void vert_ring_untag_inner_faces(BMVert 
*v, int tag, int face
 }
 
 ATTR_NO_OPT void vert_ring_do_apply(BMVert *v,
-void (*callback)(BMElem *elem, void 
*userdata),
+std::function callback,
 void *userdata,
 int tag,
 int facetag,
@@ -385,12 +382,12 @@ ATTR_NO_OPT void vert_ring_do_apply(BMVert *v,
 const int COLLAPSE_TAG = BM_ELEM_INTERNAL_TAG;
 const int COLLAPSE_FACE_TAG = BM_ELEM_TAG_ALT;
 
-ATTR_NO_OPT static void vert_ring_do(BMVert *v,
- void (*callback)(BMElem *elem, void 
*userdata),
- void *userdata,
- int tag,
- int facetag,
- int depth)
+ATTR_NO_OPT static void vert_ring_do_old(BMVert *v,
+ void (*callback)(BMElem *elem, void 
*userdata),
+ void *userdata,
+ int tag,
+ int facetag,
+ int depth)
 {
   if (!v->e) {
 v->head.hflag &= ~tag;
@@ -403,12 +400,71 @@ ATTR_NO_OPT static void vert_ring_do(BMVert *v,
   vert_ring_d

[Bf-blender-cvs] [b4cc9b67fc7] sculpt-dev: sculpt-dev: Dyntopo collapse now works with new id system

2023-01-28 Thread Joseph Eagar
Commit: b4cc9b67fc7d4e0546d5606b94db8f4dccee7fea
Author: Joseph Eagar
Date:   Sat Jan 28 00:34:05 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBb4cc9b67fc7d4e0546d5606b94db8f4dccee7fea

sculpt-dev: Dyntopo collapse now works with new id system

. . .but subdivide is now broken.

===

M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/dyntopo_collapse.cc
M   source/blender/bmesh/intern/bmesh_idmap.cc
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/editors/sculpt_paint/sculpt_face_set.cc

===

diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index 09c8acc393d..28e456c76a3 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -80,7 +80,6 @@ static void edge_queue_create_local(struct EdgeQueueContext 
*eq_ctx,
 const bool use_projected,
 PBVHTopologyUpdateMode local_mode);
 
-
 BLI_INLINE void surface_smooth_v_safe(PBVH *pbvh, BMVert *v, float fac)
 {
   float co[3];
@@ -714,7 +713,7 @@ static float maskcb_get(EdgeQueueContext *eq_ctx, BMVert 
*v1, BMVert *v2)
 return min_ff(w1, w2);
 //}
 
-return (w1 + w2) * 0.5f;
+// return (w1 + w2) * 0.5f;
   }
 
   return 1.0f;
@@ -1392,8 +1391,7 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
 
 ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
 {
-  return false;
-
+#if 0
   bm_logstack_push();
 
   static int max_faces = 64;
@@ -1436,7 +1434,6 @@ ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, 
BMEdge *e_root)
   continue;
 }
 
-void **val = nullptr;
 BMFace *f2 = l->radial_next->f;
 
 if (visit.add(f2)) {
@@ -1469,7 +1466,7 @@ ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, 
BMEdge *e_root)
 return false;
   }
 
-  printf("manifold fin size: %d\n", minfs.size());
+  printf("manifold fin size: %d\n", (int)minfs.size());
   const int tag = BM_ELEM_TAG_ALT;
 
   for (int i = 0; i < minfs.size(); i++) {
@@ -1534,9 +1531,9 @@ ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, 
BMEdge *e_root)
 }
 
 pbvh_bmesh_face_remove(pbvh, f, true, false, false);
-#ifdef USE_NEW_IDMAP
+#  ifdef USE_NEW_IDMAP
 BM_idmap_release(pbvh->bm_idmap, (BMElem *)f, true);
-#endif
+#  endif
 BM_face_kill(pbvh->header.bm, f);
   }
 
@@ -1547,9 +1544,9 @@ ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, 
BMEdge *e_root)
 
 if (!e->l) {
   BM_log_edge_removed(pbvh->bm_log, e);
-#ifdef USE_NEW_IDMAP
+#  ifdef USE_NEW_IDMAP
   BM_idmap_release(pbvh->bm_idmap, (BMElem *)e, true);
-#endif
+#  endif
   BM_edge_kill(pbvh->header.bm, e);
 }
   }
@@ -1561,9 +1558,9 @@ ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, 
BMEdge *e_root)
   pbvh_bmesh_vert_remove(pbvh, v);
 
   BM_log_vert_removed(pbvh->bm_log, v, pbvh->cd_vert_mask_offset);
-#ifdef USE_NEW_IDMAP
+#  ifdef USE_NEW_IDMAP
   BM_idmap_release(pbvh->bm_idmap, (BMElem *)v, true);
-#endif
+#  endif
   BM_vert_kill(pbvh->header.bm, v);
 }
 else {
@@ -1576,6 +1573,9 @@ ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, 
BMEdge *e_root)
 
   bm_logstack_pop();
   return true;
+#else
+  return false;
+#endif
 }
 
 bool check_for_fins(PBVH *pbvh, BMVert *v)
@@ -3192,16 +3192,6 @@ static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
   for (int i = 0; i < totedge; i++) {
 BMEdge *e = edges[i];
 
-#if 0
-BMLoop *l = e->l;
-while (e->l) {
-  BMFace *f = e->l->f;
-  BM_log_face_removed(pbvh->bm_log, f);
-  BKE_pbvh_bmesh_remove_face(pbvh, f, false);
-  BM_idmap_release(pbvh->bm_idmap, (BMElem *)f, true);
-  BM_face_kill(pbvh->header.bm, f);
-}
-#endif
 check_vert_fan_are_tris(pbvh, e->v1);
 check_vert_fan_are_tris(pbvh, e->v2);
   }
@@ -3287,7 +3277,6 @@ static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
 BMFace *f = faces[i];
 BMLoop *l = f->l_first;
 
-// pbvh_bmesh_face_remove(pbvh, f, true, false, false);
 if (!ignore_isolated_edges) {
   f->head.hflag |= SPLIT_TAG;
   BM_log_face_pre(pbvh->bm_log, f);
diff --git a/source/blender/blenkernel/intern/dyntopo_collapse.cc 
b/source/blender/blenkernel/intern/dyntopo_collapse.cc
index 33ab9617891..029c8a873aa 100644
--- a/source/blender/blenkernel/intern/dyntopo_collapse.cc
+++ b/source/blender/blenkernel/intern/dyntopo_collapse.cc
@@ -47,6 +47,11 @@ using blender::Vector;
 
 namespace blender::dyntopo {
 
+typedef struct TraceData {
+  PBVH *pbvh;
+  BMEdge *e;
+} TraceData;
+
 // copied from decimate modifier code
 inline bool bm_edge_collapse_is_degenerate_topology(BMEdge *e_fi

[Bf-blender-cvs] [4e76cc86b07] sculpt-dev: sculpt-dev: Cleanup dyntopo.cc

2023-01-28 Thread Joseph Eagar
Commit: 4e76cc86b073ae9f06fb291a3ec2eff00839c6f8
Author: Joseph Eagar
Date:   Fri Jan 27 17:27:44 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB4e76cc86b073ae9f06fb291a3ec2eff00839c6f8

sculpt-dev: Cleanup dyntopo.cc

* Split into dyntopo.cc, dyntopo_collapse.cc and dyntopo_intern.hh
* Removed various unused functions.

===

M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/dyntopo.cc
A   source/blender/blenkernel/intern/dyntopo_collapse.cc
A   source/blender/blenkernel/intern/dyntopo_intern.hh
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/bmesh/intern/bmesh_idmap.h

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 3196b89fb56..b70bedc471a 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -132,6 +132,7 @@ set(SRC
   intern/displist.cc
   intern/dynamicpaint.c
   intern/dyntopo.cc
+  intern/dyntopo_collapse.cc
   intern/editlattice.c
   intern/editmesh.cc
   intern/editmesh_bvh.c
@@ -514,6 +515,7 @@ set(SRC
   intern/CCGSubSurf.h
   intern/CCGSubSurf_inline.h
   intern/CCGSubSurf_intern.h
+  intern/dyntopo_intern.hh
   intern/attribute_access_intern.hh
   intern/data_transfer_intern.h
   intern/lib_intern.h
diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index 307fe476010..09c8acc393d 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -41,10 +41,13 @@
 #include "bmesh.h"
 #include "bmesh_log.h"
 
+#include "dyntopo_intern.hh"
 #include "pbvh_intern.h"
 
 #include 
 
+namespace blender::dyntopo {
+
 using blender::float2;
 using blender::float3;
 using blender::float4;
@@ -53,178 +56,21 @@ using blender::Map;
 using blender::Set;
 using blender::Vector;
 
-//#define DYNTOPO_VALIDATE_LOG
-
-#ifdef DYNTOPO_VALIDATE_LOG
-#  define VALIDATE_LOG(log) BM_log_validate_cur(log)
-#else
-#  define VALIDATE_LOG(log)
-#endif
-
-//#define DYNTOPO_REPORT
-//#define WITH_ADAPTIVE_CURVATURE
-//#define DYNTOPO_NO_THREADING
-
-#define SCULPTVERT_VALENCE_TEMP SCULPTVERT_SPLIT_TEMP
-
-#define SCULPTVERT_SMOOTH_BOUNDARY \
-  (SCULPT_BOUNDARY_MESH | SCULPT_BOUNDARY_FACE_SET | SCULPT_BOUNDARY_SHARP | \
-   SCULPT_BOUNDARY_SEAM | SCULPT_BOUNDARY_UV)
-#define SCULPTVERT_ALL_BOUNDARY \
-  (SCULPT_BOUNDARY_MESH | SCULPT_BOUNDARY_FACE_SET | SCULPT_BOUNDARY_SHARP | \
-   SCULPT_BOUNDARY_SEAM | SCULPT_BOUNDARY_UV)
-#define SCULPTVERT_SMOOTH_CORNER \
-  (SCULPT_CORNER_MESH | SCULPT_CORNER_FACE_SET | SCULPT_CORNER_SHARP | 
SCULPT_CORNER_SEAM | \
-   SCULPT_CORNER_UV)
-#define SCULPTVERT_ALL_CORNER \
-  (SCULPT_CORNER_MESH | SCULPT_CORNER_FACE_SET | SCULPT_CORNER_SHARP | 
SCULPT_CORNER_SEAM | \
-   SCULPT_CORNER_UV)
-
-#define DYNTOPO_MAX_ITER 4096
-
-#define DYNTOPO_USE_HEAP
-#define DYNTOPO_USE_MINMAX_HEAP
-
-#ifndef DYNTOPO_USE_HEAP
-/* don't add edges into the queue multiple times */
-#  define USE_EDGEQUEUE_TAG
-#endif
-
-/* Avoid skinny faces */
-#define USE_EDGEQUEUE_EVEN_SUBDIV
-
-/* How much longer we need to be to consider for subdividing
- * (avoids subdividing faces which are only *slightly* skinny) */
-#define EVEN_EDGELEN_THRESHOLD 1.2f
-/* How much the limit increases per recursion
- * (avoids performing subdivisions too far away). */
-#define EVEN_GENERATION_SCALE 1.1f
-
-/* recursion depth to start applying front face test */
-#define DEPTH_START_LIMIT 5
-
-//#define FANCY_EDGE_WEIGHTS <= too slow
-//#define SKINNY_EDGE_FIX
-
-/* slightly relax geometry by this factor along surface tangents
-   to improve convergence of remesher */
-#define DYNTOPO_SAFE_SMOOTH_FAC 0.05f
-
-#define DYNTOPO_SAFE_SMOOTH_SUBD_ONLY_FAC 0.075f
-
-#ifdef USE_EDGEQUEUE_EVEN_SUBDIV
-#  include "BKE_global.h"
-#endif
-
-/* Support for only operating on front-faces */
-#define USE_EDGEQUEUE_FRONTFACE
-
-/**
- * Ensure we don't have dirty tags for the edge queue, and that they are left 
cleared.
- * (slow, even for debug mode, so leave disabled for now).
- */
-#if defined(USE_EDGEQUEUE_TAG) && 0
-#  if !defined(NDEBUG)
-#define USE_EDGEQUEUE_TAG_VERIFY
-#  endif
-#endif
-
-// #define USE_VERIFY
-
-#define DYNTOPO_MASK(cd_mask_offset, v) BM_ELEM_CD_GET_FLOAT(v, cd_mask_offset)
-
-#ifdef USE_VERIFY
-static void pbvh_bmesh_verify(PBVH *pbvh);
-#endif
-
-/*  */
-/** \name BMesh Utility API
- *
- * Use some local functions which assume triangles.
- * \{ */
-
-/**
- * Typically using BM_LOOPS_OF_VERT and BM_FACES_OF_VERT iterators are fine,
- * however this is an area where performance matters so do it in-line.
- *
- * Take care since 'break' won't works as expected wi

[Bf-blender-cvs] [390b6492e73] sculpt-dev: sculpt-dev: Fix bugs from merge:

2023-01-28 Thread Joseph Eagar
Commit: 390b6492e7306d4536b982e62575902a00cd8d40
Author: Joseph Eagar
Date:   Thu Jan 26 21:22:45 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB390b6492e7306d4536b982e62575902a00cd8d40

sculpt-dev: Fix bugs from merge:

* MSculptVert->valence was not initialized for PBVH_FACES
* PBVH_BMESH did not draw color attributes.
* Crashes related to active mesh attributes.

===

M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/editors/sculpt_paint/sculpt_smooth.c

===

diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index ba859605c6f..8dff338f2e7 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2786,21 +2786,14 @@ extern "C" bool 
BKE_sculptsession_check_sculptverts(Object *ob, struct PBVH *pbv
 
   sculpt_boundary_flags_ensure(ob, pbvh, totvert);
 
-  if (!ss->attrs.sculpt_vert) {
+  if (!ss->attrs.sculpt_vert || !ss->attrs.sculpt_vert->data) {
 SculptAttributeParams params = {0};
 
 ss->attrs.sculpt_vert = sculpt_attribute_ensure_ex(
 ob, ATTR_DOMAIN_POINT, CD_DYNTOPO_VERT, "", , 
BKE_pbvh_type(pbvh));
   }
 
-  if (!ss->bm && (!ss->msculptverts || totvert != 
ss->last_msculptverts_count)) {
-ss->last_msculptverts_count = totvert;
-ss->msculptverts = static_cast(ss->attrs.sculpt_vert->data);
-
-init_sculptvert_layer(ss, pbvh, totvert);
-return true;
-  }
-
+  ss->msculptverts = static_cast(ss->attrs.sculpt_vert->data);
   BKE_pbvh_set_sculpt_verts(pbvh, ss->msculptverts);
 
   return false;
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index b94e0c18caf..4fd2792b947 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -830,6 +830,10 @@ static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args 
*args, PBVHNode *node)
   break;
 case PBVH_BMESH:
   args->bm = pbvh->header.bm;
+
+  args->active_color = pbvh->mesh->active_color_attribute;
+  args->render_color = pbvh->mesh->default_color_attribute;
+
   args->me = pbvh->mesh;
   args->vdata = >bm->vdata;
   args->ldata = >bm->ldata;
@@ -980,6 +984,11 @@ void BKE_pbvh_build_mesh(PBVH *pbvh,
   /* For each face, store the AABB and the AABB centroid */
   prim_bbc = MEM_mallocN(sizeof(BBC) * looptri_num, "prim_bbc");
 
+  for (int i = 0; i < mesh->totvert; i++) {
+msculptverts[i].flag &= ~SCULPTVERT_NEED_VALENCE;
+msculptverts[i].valence = pmap->pmap[i].count;
+  }
+
   for (int i = 0; i < looptri_num; i++) {
 const MLoopTri *lt = [i];
 const int sides = 3;
@@ -1794,6 +1803,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict 
userdata,
 
   Mesh me_query;
   BKE_id_attribute_copy_domains_temp(ID_ME, vdata, NULL, ldata, NULL, NULL, 
_query.id);
+  me_query.active_color_attribute = me->active_color_attribute;
 
   if (!pbvh->header.bm) {
 vdata = pbvh->vdata;
@@ -5374,6 +5384,8 @@ void BKE_pbvh_update_active_vcol(PBVH *pbvh, const Mesh 
*mesh)
   }
 
   BKE_id_attribute_copy_domains_temp(ID_ME, vdata, NULL, ldata, NULL, NULL, 
_query.id);
+  me_query.active_color_attribute = mesh->active_color_attribute;
+
   BKE_pbvh_get_color_layer(_query, >color_layer, >color_domain);
 
   if (pbvh->color_layer && pbvh->header.bm) {
diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 583bfefea7d..df00ebfa0ce 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -760,7 +760,7 @@ struct PBVHBatches {
 }
   }
 
-  void fill_vbo_bmesh(PBVHVbo , PBVH_GPU_Args *args)
+  ATTR_NO_OPT void fill_vbo_bmesh(PBVHVbo , PBVH_GPU_Args *args)
   {
 auto foreach_bmesh_normal = [&](std::function callback) {
   for (int i : IndexRange(args->tribuf->tottri)) {
@@ -931,6 +931,7 @@ struct PBVHBatches {
 const bool do_loop = vbo.domain == ATTR_DOMAIN_CORNER;
 
 const int cd_color = CustomData_get_offset_named(cdata, CD_PROP_COLOR, 
vbo.name.c_str());
+
 foreach_bmesh([&](BMLoop *l) {
   MPropCol *col;
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c 
b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index e770cc053e0..0c51ba4ddbb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -1991,14 +1991,14 @@ void SCULPT_bound_smooth_ensure(SculptSession *ss, 
Object *ob)
   }
 }
 
-void SCULPT_smooth(Sculpt *sd,
-   

[Bf-blender-cvs] [6c0c339da97] sculpt-dev: sculpt-dev: fix error from merge

2023-01-26 Thread Joseph Eagar
Commit: 6c0c339da972ba067819ffeac08c93d9be9ee20d
Author: Joseph Eagar
Date:   Thu Jan 26 20:31:25 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB6c0c339da972ba067819ffeac08c93d9be9ee20d

sculpt-dev: fix error from merge

===

M   source/blender/bmesh/intern/bmesh_mesh_convert.cc

===

diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc 
b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
index fde4fc430d9..41a1363b060 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
@@ -437,9 +437,9 @@ void BM_mesh_bm_from_me(Object *ob,
  * At the moment it's simplest to assume all original meshes use the 
key-block and meshes
  * that are evaluated (through the modifier stack for example) use 
custom-data layers.
  */
-BLI_assert(!CustomData_has_layer(>vdata, CD_SHAPEKEY));
+BLI_assert(!CustomData_has_layer(_vdata, CD_SHAPEKEY));
   }
-  if (is_new == false && CustomData_has_layer(>vdata, CD_SHAPEKEY)) {
+  if (is_new == false && CustomData_has_layer(>vdata, CD_SHAPEKEY)) {
 tot_shape_keys = min_ii(tot_shape_keys, 
CustomData_number_of_layers(>vdata, CD_SHAPEKEY));
   }
   const float(**shape_key_table)[3] = tot_shape_keys ? (const 
float(**)[3])BLI_array_alloca(
@@ -1580,8 +1580,10 @@ void BM_mesh_bm_to_me(
 CustomData_copy(>pdata, >pdata, mask.pmask, CD_SET_DEFAULT, 
me->totpoly);
   }
 
-  CustomData_add_layer_named(
-  >vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, me->totvert, 
"position");
+  if (CustomData_get_named_layer_index(>vdata, CD_PROP_FLOAT3, "position") 
== -1) {
+CustomData_add_layer_named(
+>vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, me->totvert, 
"position");
+  }
   CustomData_add_layer(>edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, 
me->totedge);
   CustomData_add_layer(>ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, 
me->totloop);
   CustomData_add_layer(>pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, 
me->totpoly);
@@ -1601,8 +1603,6 @@ void BM_mesh_bm_to_me(
 
   i = 0;
   BM_ITER_MESH (v, , bm, BM_VERTS_OF_MESH) {
-copy_v3_v3(positions[i], v->co);
-
 if (BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
   need_hide_vert = true;
 }
@@ -1615,6 +1615,8 @@ void BM_mesh_bm_to_me(
 /* Copy over custom-data. */
 CustomData_from_bmesh_block(>vdata, >vdata, v->head.data, i);
 
+copy_v3_v3(positions[i], v->co);
+
 i++;
 
 BM_CHECK_ELEMENT(v);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [71bce6d8e87] sculpt-dev: Merge branch 'master' into sculpt-dev

2023-01-26 Thread Joseph Eagar
Commit: 71bce6d8e87df59febac3bae37369573b711a3a4
Author: Joseph Eagar
Date:   Thu Jan 26 20:13:46 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB71bce6d8e87df59febac3bae37369573b711a3a4

Merge branch 'master' into sculpt-dev

===



===

diff --cc CMakeLists.txt
index abe0b08ccf5,9dfb962a57e..fe4b245b381
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -753,13 -751,6 +758,8 @@@ if("${CMAKE_GENERATOR}" MATCHES "Ninja"
mark_as_advanced(WITH_NINJA_POOL_JOBS)
  endif()
  
- if(UNIX AND NOT APPLE)
-   option(WITH_CXX11_ABI "Use native C++11 ABI of compiler" ON)
-   mark_as_advanced(WITH_CXX11_ABI)
- endif()
- 
 +option(WITH_INSTANT_MESHES, "Instant Meshes Quadrangulator" ON)
 +
  # Installation process.
  set(POSTINSTALL_SCRIPT "" CACHE FILEPATH "Run given CMake script after 
installation process")
  mark_as_advanced(POSTINSTALL_SCRIPT)
diff --cc intern/guardedalloc/intern/mallocn_lockfree_impl.c
index 2338012246b,2c4761c74f0..84f9f8dfa74
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@@ -111,12 -87,9 +109,11 @@@ void MEM_lockfree_freeN(void *vmemh
}
  
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
 +  MEM_UNPOISON_MEMHEAD(vmemh);
 +
size_t len = MEMHEAD_LEN(memh);
  
-   atomic_sub_and_fetch_u(, 1);
-   atomic_sub_and_fetch_z(_in_use, len);
+   memory_usage_block_free(len);
  
if (UNLIKELY(malloc_debug_memset && len)) {
  memset(memh + 1, 255, len);
@@@ -271,11 -209,8 +268,9 @@@ void *MEM_lockfree_callocN(size_t len, 
  
if (LIKELY(memh)) {
  memh->len = len;
- atomic_add_and_fetch_u(, 1);
- atomic_add_and_fetch_z(_in_use, len);
- update_maximum(_mem, mem_in_use);
+ memory_usage_block_alloc(len);
  
 +MEM_POISON_MEMHEAD(PTR_FROM_MEMHEAD(memh));
  return PTR_FROM_MEMHEAD(memh);
}
print_error("Calloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
@@@ -317,12 -252,8 +312,10 @@@ void *MEM_lockfree_mallocN(size_t len, 
  }
  
  memh->len = len;
- atomic_add_and_fetch_u(, 1);
- atomic_add_and_fetch_z(_in_use, len);
- update_maximum(_mem, mem_in_use);
+ memory_usage_block_alloc(len);
  
 +MEM_POISON_MEMHEAD(PTR_FROM_MEMHEAD(memh));
 +
  return PTR_FROM_MEMHEAD(memh);
}
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
@@@ -390,12 -321,8 +383,10 @@@ void *MEM_lockfree_mallocN_aligned(size
  
  memh->len = len | (size_t)MEMHEAD_ALIGN_FLAG;
  memh->alignment = (short)alignment;
- atomic_add_and_fetch_u(, 1);
- atomic_add_and_fetch_z(_in_use, len);
- update_maximum(_mem, mem_in_use);
+ memory_usage_block_alloc(len);
  
 +MEM_POISON_MEMHEAD(PTR_FROM_MEMHEAD(memh));
 +
  return PTR_FROM_MEMHEAD(memh);
}
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
diff --cc release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 6da898dc306,19a93e0882a..6b24452131d
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@@ -5098,14 -5047,22 +5095,25 @@@ def km_sculpt(params)
   {"properties": [("mode", 'INVERT')]}),
  ("sculpt.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', 
"shift": True},
   {"properties": [("mode", 'SMOOTH')]}),
 +# Face Set by Topology
 +("sculpt.face_set_by_topology", {"type": 'W', "value": 'PRESS', 
"ctrl": True},
 + {"properties": [("mode", "POLY_LOOP"), ("repeat_previous", True)]}),
  # Expand
  ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True},
-  {"properties": [("target", "MASK"), ("falloff_type", "GEODESIC"), 
("invert", True)]}),
+  {"properties": [
+  ("target", "MASK"),
+  ("falloff_type", "GEODESIC"),
+  ("invert", True),
+  ("use_auto_mask", False),
+  ("use_mask_preserve", True),
+  ]}),
  ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True, 
"alt": True},
-  {"properties": [("target", "MASK"), ("falloff_type", "NORMALS"), 
("invert", False)]}),
+  {"properties": [
+  ("target", "

[Bf-blender-cvs] [a5bddb43645] sculpt-dev: Sculpt-dev: Cleanup of edge collapse

2023-01-26 Thread Joseph Eagar
Commit: a5bddb436455d8dc84b5e853d5eec1f3236bb947
Author: Joseph Eagar
Date:   Tue Dec 20 02:54:34 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBa5bddb436455d8dc84b5e853d5eec1f3236bb947

Sculpt-dev: Cleanup of edge collapse

Still a work in progress.

===

M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/bmesh/intern/bmesh_construct.c
M   source/blender/bmesh/intern/bmesh_core.c
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/editors/sculpt_paint/sculpt_dyntopo.c

===

diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index baab7497ec9..36d3ec26657 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -2263,6 +2263,8 @@ static bool check_face_is_tri(PBVH *pbvh, BMFace *f)
 
 ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
 {
+  return false;
+
   bm_logstack_push();
 
   static int max_faces = 64;
@@ -2270,8 +2272,7 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 
   BMLoop *l = e_root->l;
   Vector ls;
-  Vector fs;
-  int minfs = INT_MAX;
+  Vector minfs;
 
   if (!l) {
 bm_logstack_pop();
@@ -2309,7 +2310,7 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 void **val = nullptr;
 BMFace *f2 = l->radial_next->f;
 
-if (!visit.lookup_key_or_add(f2)) {
+if (visit.add(f2)) {
   if (fs2.size() > max_faces) {
 bad = true;
 break;
@@ -2325,17 +2326,8 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
   }
 }
 
-if (!bad && fs2.size() < minfs) {
-#if 0
-  if (fs2.size() > 0) {
-fs.resize(fs2.size());
-memcpy((void *)[0], (void *)[0], sizeof(void *) * fs2.size());
-  } else {
-fs.clear();
-  }
-#endif
-  fs = fs2;
-  minfs = fs.size();
+if (!bad && fs2.size() && (minfs.size() == 0 || fs2.size() < 
minfs.size())) {
+  minfs = fs2;
 }
   }
 
@@ -2343,19 +2335,28 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 PBVH_UpdateTriAreas;
   nupdateflag = nupdateflag | PBVH_UpdateNormals | PBVH_UpdateTris | 
PBVH_RebuildDrawBuffers;
 
-  if (!fs.size()) {
+  if (!minfs.size()) {
 bm_logstack_pop();
 return false;
   }
 
-  printf("manifold fin size: %d\n", fs.size());
+  printf("manifold fin size: %d\n", minfs.size());
   const int tag = BM_ELEM_TAG_ALT;
 
-  for (int i = 0; i < fs.size(); i++) {
-BMFace *f = fs[i];
+  for (int i = 0; i < minfs.size(); i++) {
+BMFace *f = minfs[i];
 
 BMLoop *l = f->l_first;
 do {
+  BMLoop *l2 = l;
+  do {
+BMLoop *l3 = l2;
+do {
+  l3->v->head.hflag &= ~tag;
+  l3->e->head.hflag &= ~tag;
+} while ((l3 = l3->next) != l2);
+  } while ((l2 = l2->radial_next) != l);
+
   l->v->head.hflag &= ~tag;
   l->e->head.hflag &= ~tag;
 } while ((l = l->next) != f->l_first);
@@ -2364,8 +2365,8 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
   Vector vs;
   Vector es;
 
-  for (int i = 0; i < fs.size(); i++) {
-BMFace *f = fs[i];
+  for (int i = 0; i < minfs.size(); i++) {
+BMFace *f = minfs[i];
 
 BMLoop *l = f->l_first;
 do {
@@ -2381,17 +2382,17 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 } while ((l = l->next) != f->l_first);
   }
 
-  for (int i = 0; i < minfs; i++) {
-for (int j = 0; j < minfs; j++) {
-  if (i != j && fs[i] == fs[j]) {
+  for (int i = 0; i < minfs.size(); i++) {
+for (int j = 0; j < minfs.size(); j++) {
+  if (i != j && minfs[i] == minfs[j]) {
 printf("%s: duplicate faces\n", __func__);
 continue;
   }
 }
   }
 
-  for (int i = 0; i < minfs; i++) {
-BMFace *f = fs[i];
+  for (int i = 0; i < minfs.size(); i++) {
+BMFace *f = minfs[i];
 
 if (f->head.htype != BM_FACE) {
   printf("%s: corruption!\n", __func__);
@@ -3167,6 +3168,7 @@ static bool 
bm_edge_collapse_is_degenerate_topology(BMEdge *e_first)
 typedef struct TraceData {
   PBVH *pbvh;
   SmallHash visit;
+  blender::Set visit2;
   BMEdge *e;
 } TraceData;
 
@@ -3240,6 +3242,10 @@ ATTR_NO_OPT void col_on_vert_add(BMesh *bm, BMVert *v, 
void *userdata)
   TraceData *data = (TraceData *)userdata;
   PBVH *pbvh = data->pbvh;
 
+  if (!data->visit2.add(static_cast(v))) {
+// return;
+  }
+
   pbvh_boundary_update_bmesh(pbvh, v);
 

[Bf-blender-cvs] [abc1b0ce41b] sculpt-dev: sculpt-dev: Update submodule refs ahead of merge

2023-01-26 Thread Joseph Eagar
Commit: abc1b0ce41bd60715e110867f1d9fe081de5c7b5
Author: Joseph Eagar
Date:   Fri Jan 13 20:37:39 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBabc1b0ce41bd60715e110867f1d9fe081de5c7b5

sculpt-dev: Update submodule refs ahead of merge

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index fe221a8bc93..7084c4ecd97 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit fe221a8bc934385d9f302c46a5c7cbeacddafe3b
+Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
diff --git a/release/scripts/addons b/release/scripts/addons
index fdfd24de034..a9d4443c244 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit fdfd24de034d4bba4fb67731d0aae81dc4940239
+Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index c43c0b2bcf0..bdcfdd47ec3 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit c43c0b2bcf08c34d933c3b56f096c9a23c8eff68
+Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
diff --git a/source/tools b/source/tools
index dfa16042bf7..e1744b9bd82 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit dfa16042bf7149475ad318d29a8202d969982abb
+Subproject commit e1744b9bd82527cf7e8af63362b61bd309b5711b

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d76004f48f4] master: Sculpt: Fix sculpt expand not switching falloff types properly

2023-01-26 Thread Joseph Eagar
Commit: d76004f48f46164a73b107a11f115d3c45e312ad
Author: Joseph Eagar
Date:   Thu Jan 26 17:53:32 2023 -0800
Branches: master
https://developer.blender.org/rBd76004f48f46164a73b107a11f115d3c45e312ad

Sculpt: Fix sculpt expand not switching falloff types properly

===

M   source/blender/editors/sculpt_paint/sculpt_expand.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc 
b/source/blender/editors/sculpt_paint/sculpt_expand.cc
index a125545c010..b6a71a69287 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc
@@ -388,11 +388,11 @@ static BLI_bitmap 
*sculpt_expand_boundary_from_enabled(SculptSession *ss,
   return boundary_verts;
 }
 
-static void sculpt_expand_check_topology_islands(Object *ob)
+static void sculpt_expand_check_topology_islands(Object *ob, 
eSculptExpandFalloffType falloff_type)
 {
   SculptSession *ss = ob->sculpt;
 
-  ss->expand_cache->check_islands = ELEM(ss->expand_cache->falloff_type,
+  ss->expand_cache->check_islands = ELEM(falloff_type,
  SCULPT_EXPAND_FALLOFF_GEODESIC,
  SCULPT_EXPAND_FALLOFF_TOPOLOGY,
  
SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS,
@@ -1865,8 +1865,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 return OPERATOR_FINISHED;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC: {
-expand_cache->falloff_gradient = true;
-sculpt_expand_check_topology_islands(ob);
+sculpt_expand_check_topology_islands(ob, 
SCULPT_EXPAND_FALLOFF_GEODESIC);
 
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
@@ -1877,8 +1876,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY: {
-expand_cache->falloff_gradient = SCULPT_EXPAND_FALLOFF_TOPOLOGY;
-sculpt_expand_check_topology_islands(ob);
+sculpt_expand_check_topology_islands(ob, 
SCULPT_EXPAND_FALLOFF_TOPOLOGY);
 
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
@@ -1889,8 +1887,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS: {
-expand_cache->falloff_gradient = true;
-sculpt_expand_check_topology_islands(ob);
+sculpt_expand_check_topology_islands(ob, 
SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS);
 
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
@@ -2247,7 +2244,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator 
*op, const wmEvent *even
   sculpt_expand_falloff_factors_from_vertex_and_symm_create(
   ss->expand_cache, sd, ob, ss->expand_cache->initial_active_vertex, 
falloff_type);
 
-  sculpt_expand_check_topology_islands(ob);
+  sculpt_expand_check_topology_islands(ob, falloff_type);
 
   /* Initial mesh data update, resets all target data in the sculpt mesh. */
   sculpt_expand_update_for_vertex(C, ob, 
ss->expand_cache->initial_active_vertex);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [647cffc0016] master: Sculpt: Add numpad aliases for number keymap entries in expand modal map

2023-01-26 Thread Joseph Eagar
Commit: 647cffc0016374088dcd8decbc065d7799028939
Author: Joseph Eagar
Date:   Thu Jan 26 16:57:28 2023 -0800
Branches: master
https://developer.blender.org/rB647cffc0016374088dcd8decbc065d7799028939

Sculpt: Add numpad aliases for number keymap entries in expand modal map

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index ec89b61d47c..9f25d421c9d 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -6281,6 +6281,8 @@ def km_sculpt_expand_modal(_params):
 ("MOVE_TOGGLE", {"type": 'SPACE', "value": 'ANY', "any": True}, None),
 *((e, {"type": NUMBERS_1[i], "value": 'PRESS', "any": True}, None) for 
i, e in enumerate(
 ("FALLOFF_GEODESICS", "FALLOFF_TOPOLOGY", 
"FALLOFF_TOPOLOGY_DIAGONALS", "FALLOFF_SPHERICAL"))),
+*((e, {"type": "NUMPAD_%i" % (i+1), "value": 'PRESS', "any": True}, 
None) for i, e in enumerate(
+("FALLOFF_GEODESICS", "FALLOFF_TOPOLOGY", 
"FALLOFF_TOPOLOGY_DIAGONALS", "FALLOFF_SPHERICAL"))),
 ("SNAP_TOGGLE", {"type": 'LEFT_CTRL', "value": 'ANY'}, None),
 ("SNAP_TOGGLE", {"type": 'RIGHT_CTRL', "value": 'ANY'}, None),
 ("LOOP_COUNT_INCREASE", {"type": 'W', "value": 'PRESS', "any": True, 
"repeat": True}, None),

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [789ab9b92af] master: Sculpt: Fix T104090: Automask topology not constrained by brush radius

2023-01-24 Thread Joseph Eagar
Commit: 789ab9b92aff9a576a3d926583b1446827937fa9
Author: Joseph Eagar
Date:   Tue Jan 24 11:03:21 2023 -0800
Branches: master
https://developer.blender.org/rB789ab9b92aff9a576a3d926583b1446827937fa9

Sculpt: Fix T104090: Automask topology not constrained by brush radius

===

M   release/datafiles/locale
M   release/scripts/addons
M   source/blender/editors/sculpt_paint/sculpt_automasking.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index f1425d8a7fc..08b372721b9 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit f1425d8a7fc38e8111c2a9e125f0e7877dcd0fdf
+Subproject commit 08b372721b9b33a16f380cab23b2e5ded738ea96
diff --git a/release/scripts/addons b/release/scripts/addons
index c0a678d3686..d887a4ea6b2 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit c0a678d3686a591eb3041cc72b60aec2857d389a
+Subproject commit d887a4ea6b2a9d64b926034d4e78ecf7a48ca979
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 62c27a5ffeb..6b030d8a5b7 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -177,11 +177,29 @@ static float sculpt_automasking_normal_calc(SculptSession 
*ss,
   return 1.0f;
 }
 
+static bool sculpt_automasking_is_constrained_by_radius(const Brush *br)
+{
+  /* 2D falloff is not constrained by radius. */
+  if (br->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
+return false;
+  }
+
+  if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, 
SCULPT_TOOL_ROTATE)) {
+return true;
+  }
+  return false;
+}
+
 static bool SCULPT_automasking_needs_factors_cache(const Sculpt *sd, const 
Brush *brush)
 {
 
   const int automasking_flags = sculpt_automasking_mode_effective_bits(sd, 
brush);
 
+  if (automasking_flags & BRUSH_AUTOMASKING_TOPOLOGY &&
+  sculpt_automasking_is_constrained_by_radius(brush)) {
+return true;
+  }
+
   if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES |
BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | 
BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 return brush && brush->automasking_boundary_edges_propagation_steps != 1;
@@ -537,7 +555,8 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 return automasking_factor_end(ss, automasking, vert, 0.0f);
   }
 
-  if (automasking->settings.flags & BRUSH_AUTOMASKING_TOPOLOGY &&
+  if (!automasking->settings.topology_use_brush_limit &&
+  automasking->settings.flags & BRUSH_AUTOMASKING_TOPOLOGY &&
   SCULPT_vertex_island_get(ss, vert) != 
automasking->settings.initial_island_nr) {
 return 0.0f;
   }
@@ -592,6 +611,53 @@ struct AutomaskFloodFillData {
   char symm;
 };
 
+static bool automask_floodfill_cb(
+SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool 
/*is_duplicate*/, void *userdata)
+{
+  AutomaskFloodFillData *data = (AutomaskFloodFillData *)userdata;
+
+  *(float *)SCULPT_vertex_attr_get(to_v, ss->attrs.automasking_factor) = 1.0f;
+  *(float *)SCULPT_vertex_attr_get(from_v, ss->attrs.automasking_factor) = 
1.0f;
+  return (!data->use_radius ||
+  SCULPT_is_vertex_inside_brush_radius_symm(
+  SCULPT_vertex_co_get(ss, to_v), data->location, data->radius, 
data->symm));
+}
+
+static void SCULPT_topology_automasking_init(Sculpt *sd, Object *ob)
+{
+  SculptSession *ss = ob->sculpt;
+  Brush *brush = BKE_paint_brush(>paint);
+
+  if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES && !ss->pmap) {
+BLI_assert_unreachable();
+return;
+  }
+
+  const int totvert = SCULPT_vertex_count_get(ss);
+  for (int i : IndexRange(totvert)) {
+PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
+
+(*(float *)SCULPT_vertex_attr_get(vertex, ss->attrs.automasking_factor)) = 
0.0f;
+  }
+
+  /* Flood fill automask to connected vertices. Limited to vertices inside
+   * the brush radius if the tool requires it. */
+  SculptFloodFill flood;
+  SCULPT_floodfill_init(ss, );
+  const float radius = ss->cache ? ss->cache->radius : FLT_MAX;
+  SCULPT_floodfill_add_active(sd, ob, ss, , radius);
+
+  AutomaskFloodFillData fdata = {0};
+
+  fdata.radius = radius;
+  fdata.use_radius = ss->cache && 
sculpt_automasking_is_constrained_by_radius(brush);
+  fdata.symm = SCULPT_mesh_symmetry_xyz_get(ob);
+
+  copy_v3_v3(fdata.location, SCULPT_active_vertex_co_get(ss));
+  SCULPT_floodfill_execute(ss, , automask_floodfill_cb, );
+  SCULPT_floodfill_free();
+}
+
 static void sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob)

[Bf-blender-cvs] [62af8ae57bd] temp-sculpt-roll-mapping: Merge branch 'master' into temp-sculpt-roll-mapping

2023-01-24 Thread Joseph Eagar
Commit: 62af8ae57bda2a3554f384eabc784f137d69b97b
Author: Joseph Eagar
Date:   Thu Jan 12 19:34:16 2023 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB62af8ae57bda2a3554f384eabc784f137d69b97b

Merge branch 'master' into temp-sculpt-roll-mapping

===



===

diff --cc release/datafiles/locale
index 4a581c54af9,4f6dbb69893..7084c4ecd97
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e
 -Subproject commit 4f6dbb69893bd6bdf73467effe77ae46c8e4ee37
++Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
diff --cc release/scripts/addons
index 0b0052bd53a,bf49eeaa14c..a9d4443c244
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde
 -Subproject commit bf49eeaa14c445d3c53068203fdf91bff568fe64
++Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
diff --cc release/scripts/addons_contrib
index 96143b1a8b0,0f72f6c85c3..bdcfdd47ec3
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3
 -Subproject commit 0f72f6c85c3743a9072273acb6a8a34b1cf1064b
++Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
diff --cc source/blender/editors/sculpt_paint/sculpt.cc
index c9bde27572d,e1586e00788..5916b3d2745
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@@ -75,12 -73,9 +75,13 @@@
  
  #include "bmesh.h"
  
- #include 
+ using blender::float3;
+ using blender::MutableSpan;
  
 +using blender::float2;
 +using blender::float3;
 +using blender::IndexRange;
 +using blender::MutableSpan;
  /*  */
  /** \name Sculpt PBVH Abstraction API
   *
diff --cc source/tools
index fdfa2fcb949,3582f5326d0..e1744b9bd82
--- a/source/tools
+++ b/source/tools
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit fdfa2fcb9495d87571f2dfe2ae9fa0e032536600
 -Subproject commit 3582f5326d08ca05c2a19056597e49ec5511d854
++Subproject commit e1744b9bd82527cf7e8af63362b61bd309b5711b

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3dd3a0f02e4] temp-sculpt-roll-mapping: temp-sculpt-roll-mapping: Fix deadlock

2023-01-24 Thread Joseph Eagar
Commit: 3dd3a0f02e4db155d6fe6ca6e349abea39b524f7
Author: Joseph Eagar
Date:   Tue Jan 24 08:54:12 2023 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB3dd3a0f02e4db155d6fe6ca6e349abea39b524f7

temp-sculpt-roll-mapping: Fix deadlock

===

M   source/blender/editors/sculpt_paint/sculpt.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index 3394bb2a895..548484bd32c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -2697,7 +2697,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
 }
 else {
   const float point_3d[3] = {point_2d[0], point_2d[1], 0.0f};
-  avg = BKE_brush_sample_tex_3d(scene, br, mtex, point_3d, rgba, 0, 
ss->tex_pool);
+  avg = BKE_brush_sample_tex_3d(scene, br, mtex, point_3d, rgba, 
thread_id, ss->tex_pool);
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3ca4ec3857c] temp-sculpt-roll-mapping: Merge branch 'master' into temp-sculpt-roll-mapping

2023-01-24 Thread Joseph Eagar
Commit: 3ca4ec3857c11b3ce700ad2013bbfe52ac2cb792
Author: Joseph Eagar
Date:   Tue Jan 24 08:30:06 2023 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB3ca4ec3857c11b3ce700ad2013bbfe52ac2cb792

Merge branch 'master' into temp-sculpt-roll-mapping

===



===

diff --cc release/datafiles/locale
index 7084c4ecd97,f1425d8a7fc..08b372721b9
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
 -Subproject commit f1425d8a7fc38e8111c2a9e125f0e7877dcd0fdf
++Subproject commit 08b372721b9b33a16f380cab23b2e5ded738ea96
diff --cc release/scripts/addons
index a9d4443c244,c0a678d3686..d887a4ea6b2
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
 -Subproject commit c0a678d3686a591eb3041cc72b60aec2857d389a
++Subproject commit d887a4ea6b2a9d64b926034d4e78ecf7a48ca979
diff --cc source/blender/blenlib/BLI_even_spline.hh
index dea44756ca4,000..ae019808afe
mode 100644,00..100644
--- a/source/blender/blenlib/BLI_even_spline.hh
+++ b/source/blender/blenlib/BLI_even_spline.hh
@@@ -1,777 -1,0 +1,777 @@@
 +#pragma once
 +
 +#include "BLI_compiler_attrs.h"
 +#include "BLI_compiler_compat.h"
 +
 +#include "BLI_math.h"
- #include "BLI_math_vec_types.hh"
++#include "BLI_math_vector_types.hh"
 +#include "BLI_vector.hh"
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +//#define FINITE_DIFF
 +
 +/*
 + * Arc length parameterized spline library.
 + */
 +namespace blender {
 +/*
 + Abstract curve interface. Curves must be
 + arc length parameterized (evenly spaced,
 + length of first derivative vector is 1).
 +
 + We get a nice set of properties by using
 + arc length parameterizion.
 +
 + * Even spacing.
 + * Second derivative is the curve normal multiplied by the curvature
 + * Easy to calculate torsion for space curves (though this hasn't been
 +   implemented yet).
 +
 + Look up the Frenet-Serret formulas for more info.
 +
 + Abstract class interface:
 +
 +template class Curve {
-   using Vector = vec_base;
++  using Vector = VecBase;
 +
 + public:
 +  Float length;
 +
 +  Vector evaluate(Float s);
 +  Vector derivative(Float s);
 +  Vector derivative2(Float s);
 +
 +  Float curvature(float s);
 +  Float dcurvature(float s); // Derivative of curvature.
 +
 +  void update();
 +};
 +
 +*/
 +
 +/** Cubic curves */
 +
 +template class 
CubicBezier {
-   using Vector = vec_base;
++  using Vector = VecBase;
 +
 + public:
 +  Vector ps[4];
 +
 +  static const int TableSize = table_size;
 +
 +  CubicBezier(Vector a, Vector b, Vector c, Vector d)
 +  {
 +ps[0] = a;
 +ps[1] = b;
 +ps[2] = c;
 +ps[3] = d;
 +
 +deleted = false;
 +_arc_to_t = new Float[table_size];
 +  }
 +
 +  ~CubicBezier()
 +  {
 +deleted = true;
 +
 +if (_arc_to_t) {
 +  delete[] _arc_to_t;
 +  _arc_to_t = nullptr;
 +}
 +  }
 +
 +  CubicBezier()
 +  {
 +deleted = false;
 +_arc_to_t = new Float[table_size];
 +  }
 +
 +  CubicBezier(const CubicBezier )
 +  {
 +_arc_to_t = new Float[table_size];
 +*this = b;
 +deleted = false;
 +  }
 +
 +  CubicBezier =(const CubicBezier )
 +  {
 +ps[0] = b.ps[0];
 +ps[1] = b.ps[1];
 +ps[2] = b.ps[2];
 +ps[3] = b.ps[3];
 +
 +length = b.length;
 +
 +if (!_arc_to_t) {
 +  _arc_to_t = new Float[table_size];
 +}
 +
 +if (b._arc_to_t) {
 +  for (int i = 0; i < table_size; i++) {
 +_arc_to_t[i] = b._arc_to_t[i];
 +  }
 +}
 +
 +return *this;
 +  }
 +
 +  CubicBezier(CubicBezier &)
 +  {
 +*this = b;
 +  }
 +
 +  CubicBezier =(CubicBezier &)
 +  {
 +ps[0] = b.ps[0];
 +ps[1] = b.ps[1];
 +ps[2] = b.ps[2];
 +ps[3] = b.ps[3];
 +
 +length = b.length;
 +
 +if (b._arc_to_t) {
 +  _arc_to_t = std::move(b._arc_to_t);
 +  b._arc_to_t = nullptr;
 +}
 +else {
 +  _arc_to_t = new Float[table_size];
 +}
 +
 +return *this;
 +  }
 +
 +  Float length;
 +
 +  /* Update arc length -> parameterization table. */
 +  void update()
 +  {
 +Float t = 0.0, dt = 1.0 / (Float)table_size;
 +Float s = 0.0;
 +
 +if (!_arc_to_t) {
 +  _arc_to_t = new Float[table_size];
 +}
 +
 +for (int i = 0; i < table_size; i++) {
 +  _arc_to_t[i] = -1.0;
 +}
 +
 +length = 0.0;
 +
 +for (int i = 0; i < table_size; i++, t += dt) {
 +  Float dlen = 0.0;
 +  for (int j = 0; j < axes; j++) {
 +float dv = dcubic(ps[0][j], ps[1][j], ps[2][j], ps[3][j], t);
 +
 +dlen += dv * dv;
 +  }
 +
 +  dlen = sqrt(dlen) * dt;
 +
 +  length += dlen;
 +}
 +
 +const int sam

[Bf-blender-cvs] [b6b6e47e1db] master: Sculpt: PBVH node splitting for texture paint

2023-01-23 Thread Joseph Eagar
Commit: b6b6e47e1dbc2e4a175fb1a257e50dc0f51b2fc6
Author: Joseph Eagar
Date:   Mon Jan 23 10:29:40 2023 -0800
Branches: master
https://developer.blender.org/rBb6b6e47e1dbc2e4a175fb1a257e50dc0f51b2fc6

Sculpt: PBVH node splitting for texture paint

`PBVH_Leaf` nodes are now split into a new `PBVH_TexLeaf`
node type when using the paint brush.  These nodes are
split by image pixels, not triangles.  This greatly
increases performance when working with large
textures on low-poly meshes.

Reviewed By: Jeroen Bakker
Differential Revision: https://developer.blender.org/D14900
Ref: D14900

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/BKE_pbvh_pixels.hh
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenkernel/intern/pbvh_pixels.cc
M   source/blender/draw/engines/basic/basic_engine.c
M   source/blender/draw/engines/eevee/eevee_materials.c
M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager_data.cc
M   source/blender/draw/intern/draw_shader_shared.h
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_paint_color.c
M   source/blender/editors/sculpt_paint/sculpt_paint_image.cc
M   source/blender/editors/sculpt_paint/sculpt_undo.cc

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 5a63b9bb126..7153f05c0c3 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -163,7 +163,8 @@ typedef enum {
   PBVH_UpdateTopology = 1 << 13,
   PBVH_UpdateColor = 1 << 14,
   PBVH_RebuildPixels = 1 << 15,
-  PBVH_TopologyUpdated = 1 << 16, /* Used internally by pbvh_bmesh.c */
+  PBVH_TexLeaf = 1 << 16,
+  PBVH_TopologyUpdated = 1 << 17, /* Used internally by pbvh_bmesh.c */
 
 } PBVHNodeFlags;
 
@@ -337,7 +338,12 @@ void BKE_pbvh_search_callback(PBVH *pbvh,
 
 void BKE_pbvh_search_gather(
 PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode 
***array, int *tot);
-
+void BKE_pbvh_search_gather_ex(PBVH *pbvh,
+   BKE_pbvh_SearchCallback scb,
+   void *search_data,
+   PBVHNode ***r_array,
+   int *r_tot,
+   PBVHNodeFlags leaf_flag);
 /* Ray-cast
  * the hit callback is called for all leaf nodes intersecting the ray;
  * it's up to the callback to find the primitive within the leaves that is
diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh 
b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index b6e006805ec..31dbad0abe1 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -200,6 +200,10 @@ struct NodeData {
   {
 undo_regions.clear();
 for (UDIMTilePixels  : tiles) {
+  if (tile.pixel_rows.size() == 0) {
+continue;
+  }
+
   rcti region;
   BLI_rcti_init_minmax();
   for (PackedPixelRow _row : tile.pixel_rows) {
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index d18ef62c20c..e9461350448 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1020,7 +1020,9 @@ void BKE_pbvh_free(PBVH *pbvh)
   if (node->bm_other_verts) {
 BLI_gset_free(node->bm_other_verts, NULL);
   }
+}
 
+if (node->flag & (PBVH_Leaf | PBVH_TexLeaf)) {
   pbvh_node_pixels_free(node);
 }
   }
@@ -1094,7 +1096,7 @@ static void pbvh_stack_push(PBVHIter *iter, PBVHNode 
*node, bool revisiting)
   iter->stacksize++;
 }
 
-static PBVHNode *pbvh_iter_next(PBVHIter *iter)
+static PBVHNode *pbvh_iter_next(PBVHIter *iter, PBVHNodeFlags leaf_flag)
 {
   /* purpose here is to traverse tree, visiting child nodes before their
* parents, this order is necessary for e.g. computing bounding boxes */
@@ -1121,7 +1123,7 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter)
   continue; /* don't traverse, outside of search zone */
 }
 
-if (node->flag & PBVH_Leaf) {
+if (node->flag & leaf_flag) {
   /* immediately hit leaf node */
   return node;
 }
@@ -1166,8 +1168,12 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter)
   return NULL;
 }
 
-void BKE_pbvh_search_gather(
-PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode 
***r_array, int *r_tot)
+void BKE_pbvh_search_gather_ex(PBVH *pbvh,
+   BKE_pbvh_SearchCallback scb,
+   void *search_data,
+   PBVHNode ***r_array,
+  

[Bf-blender-cvs] [8ea7063a718] temp-pbvh-split: Merge remote-tracking branch 'origin' into temp-pbvh-split

2023-01-23 Thread Joseph Eagar
Commit: 8ea7063a7182c24fea3b70d9322fb1c8651a3e32
Author: Joseph Eagar
Date:   Mon Jan 23 09:14:43 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB8ea7063a7182c24fea3b70d9322fb1c8651a3e32

Merge remote-tracking branch 'origin' into temp-pbvh-split

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [495094d65be] temp-pbvh-split: temp-pbvh-split: fix compile error

2023-01-23 Thread Joseph Eagar
Commit: 495094d65befe4fb6feb608e908abee279a1bb87
Author: Joseph Eagar
Date:   Mon Jan 23 09:11:57 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB495094d65befe4fb6feb608e908abee279a1bb87

temp-pbvh-split: fix compile error

===

M   source/blender/blenkernel/intern/pbvh_pixels.cc

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 4315cde4b8c..ed87631ffe9 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -174,7 +174,7 @@ static void split_pixel_node(PBVH *pbvh,
   continue;
 }
 
-const MVert *mvert = BKE_pbvh_get_verts(pbvh);
+const float(*vert_cos)[3] = BKE_pbvh_get_vert_positions(pbvh);
 PBVHData _data = BKE_pbvh_pixels_data_get(*pbvh);
 
 for (const PackedPixelRow  : tile.pixel_rows) {
@@ -186,9 +186,9 @@ static void split_pixel_node(PBVH *pbvh,
 
   float verts[3][3];
 
-  copy_v3_v3(verts[0], mvert[tri[0]].co);
-  copy_v3_v3(verts[1], mvert[tri[1]].co);
-  copy_v3_v3(verts[2], mvert[tri[2]].co);
+  copy_v3_v3(verts[0], vert_cos[tri[0]]);
+  copy_v3_v3(verts[1], vert_cos[tri[1]]);
+  copy_v3_v3(verts[2], vert_cos[tri[2]]);
 
   float2 delta = uv_prim.delta_barycentric_coord_u;
   float2 uv1 = row.start_barycentric_coord;
@@ -667,7 +667,7 @@ static bool update_pixels(PBVH *pbvh, Mesh *mesh, Image 
*image, ImageUser *image
 
   const StringRef active_uv_name = 
CustomData_get_active_layer_name(>ldata, CD_PROP_FLOAT2);
   if (active_uv_name.is_empty()) {
-return;
+return false;
   }
 
   const AttributeAccessor attributes = mesh->attributes();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [365bd78cba2] temp-pbvh-split: Merge branch 'master' into temp-pbvh-split

2023-01-23 Thread Joseph Eagar
Commit: 365bd78cba2f2c01997c2a18423556053c8e3107
Author: Joseph Eagar
Date:   Mon Jan 23 08:45:43 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB365bd78cba2f2c01997c2a18423556053c8e3107

Merge branch 'master' into temp-pbvh-split

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3f923b0d7ed] temp-pbvh-split: temp-pbvh-split: Attempt to fix submodules

2023-01-23 Thread Joseph Eagar
Commit: 3f923b0d7ed22ab3f6d7bb9fb52f8083a3fa6f11
Author: Joseph Eagar
Date:   Mon Jan 23 08:47:46 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB3f923b0d7ed22ab3f6d7bb9fb52f8083a3fa6f11

temp-pbvh-split: Attempt to fix submodules

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 7084c4ecd97..08b372721b9 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
+Subproject commit 08b372721b9b33a16f380cab23b2e5ded738ea96
diff --git a/release/scripts/addons b/release/scripts/addons
index a9d4443c244..d887a4ea6b2 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
+Subproject commit d887a4ea6b2a9d64b926034d4e78ecf7a48ca979
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index bdcfdd47ec3..9d538629bb8 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
+Subproject commit 9d538629bb8a425991c7d10a49bab1ba0788c18f
diff --git a/source/tools b/source/tools
index e1744b9bd82..3582f5326d0 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit e1744b9bd82527cf7e8af63362b61bd309b5711b
+Subproject commit 3582f5326d08ca05c2a19056597e49ec5511d854

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5f302c9d101] temp-pbvh-texpaint-automasking: temp-pbvh-texpaint-automasking: Use PBVHVertRef directly for Set

2023-01-23 Thread Joseph Eagar
Commit: 5f302c9d1019218e75c8732e9fd9ad2e3e4aa031
Author: Joseph Eagar
Date:   Mon Jan 23 08:38:17 2023 -0800
Branches: temp-pbvh-texpaint-automasking
https://developer.blender.org/rB5f302c9d1019218e75c8732e9fd9ad2e3e4aa031

temp-pbvh-texpaint-automasking: Use PBVHVertRef directly for Set

===

M   source/blender/editors/sculpt_paint/sculpt_automasking.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index ad0153bfbda..7f3c6ec4a3c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -986,7 +986,7 @@ void SCULPT_automasking_cache_check(
 }
   });
 
-  Set done_set;
+  Set done_set;
 
   for (int i : IndexRange(totnode)) {
 PBVHNode *node = nodes[i];
@@ -1013,8 +1013,8 @@ void SCULPT_automasking_cache_check(
 
   SCULPT_automasking_node_update(ss, _data, );
 
-  if (!done_set.contains(vertex.i)) {
-done_set.add(vertex.i);
+  if (!done_set.contains(vertex)) {
+done_set.add(vertex);
 
 float value = SCULPT_automasking_factor_get(automasking, ss, 
vd.vertex, _data);
 *(float *)SCULPT_vertex_attr_get(vd.vertex, 
ss->attrs.automasking_factor) = value;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1184501d5ce] master: Sculpt: Fix T103948: Automasking stroke id not being updated

2023-01-19 Thread Joseph Eagar
Commit: 1184501d5ce147024faa93dca1e79b64140f8723
Author: Joseph Eagar
Date:   Thu Jan 19 18:32:40 2023 -0800
Branches: master
https://developer.blender.org/rB1184501d5ce147024faa93dca1e79b64140f8723

Sculpt: Fix T103948: Automasking stroke id not being updated

===

M   source/blender/editors/sculpt_paint/sculpt_automasking.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 3edc99d32c1..62c27a5ffeb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -522,7 +522,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
   factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
 }
 
-return factor * mask;
+return automasking_factor_end(ss, automasking, vert, factor * mask);
   }
 
   uchar stroke_id = ss->attrs.automasking_stroke_id ?

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fcb0425f64c] master: Sculpt: Remove old connected component API in favor of new island API

2023-01-19 Thread Joseph Eagar
Commit: fcb0425f64c4b3652e513420fd7b1a59951e39a3
Author: Joseph Eagar
Date:   Thu Jan 19 18:22:59 2023 -0800
Branches: master
https://developer.blender.org/rBfcb0425f64c4b3652e513420fd7b1a59951e39a3

Sculpt: Remove old connected component API in favor of new island API

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/sculpt_paint/sculpt_expand.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_mask_init.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index aefb33357a2..1a380addfbb 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -392,9 +392,6 @@ typedef struct SculptPersistentBase {
 } SculptPersistentBase;
 
 typedef struct SculptVertexInfo {
-  /* Indexed by vertex, stores and ID of its topologically connected 
component. */
-  int *connected_component;
-
   /* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
   BLI_bitmap *boundary;
 } SculptVertexInfo;
diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 1d416eec1e8..0ee517311d2 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -1454,7 +1454,6 @@ static void sculptsession_free_pbvh(Object *object)
   MEM_SAFE_FREE(ss->preview_vert_list);
   ss->preview_vert_count = 0;
 
-  MEM_SAFE_FREE(ss->vertex_info.connected_component);
   MEM_SAFE_FREE(ss->vertex_info.boundary);
 
   MEM_SAFE_FREE(ss->fake_neighbors.fake_neighbor_index);
diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index a26cf16b78a..676f2de49ef 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -3351,7 +3351,6 @@ static void sculpt_topology_update(Sculpt *sd,
   /* Free index based vertex info as it will become invalid after modifying 
the topology during the
* stroke. */
   MEM_SAFE_FREE(ss->vertex_info.boundary);
-  MEM_SAFE_FREE(ss->vertex_info.connected_component);
 
   PBVHTopologyUpdateMode mode = PBVHTopologyUpdateMode(0);
   float location[3];
@@ -5928,14 +5927,6 @@ enum {
   SCULPT_TOPOLOGY_ID_DEFAULT,
 };
 
-static int SCULPT_vertex_get_connected_component(SculptSession *ss, 
PBVHVertRef vertex)
-{
-  if (ss->vertex_info.connected_component) {
-return ss->vertex_info.connected_component[vertex.i];
-  }
-  return SCULPT_TOPOLOGY_ID_DEFAULT;
-}
-
 static void SCULPT_fake_neighbor_init(SculptSession *ss, const float max_dist)
 {
   const int totvert = SCULPT_vertex_count_get(ss);
@@ -5981,7 +5972,7 @@ static void do_fake_neighbor_search_task_cb(void 
*__restrict userdata,
   PBVHVertexIter vd;
 
   BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
-int vd_topology_id = SCULPT_vertex_get_connected_component(ss, vd.vertex);
+int vd_topology_id = SCULPT_vertex_island_get(ss, vd.vertex);
 if (vd_topology_id != nvtd->current_topology_id &&
 ss->fake_neighbors.fake_neighbor_index[vd.index] == 
FAKE_NEIGHBOR_NONE) {
   float distance_squared = len_squared_v3v3(vd.co, 
data->nearest_vertex_search_co);
@@ -6044,7 +6035,7 @@ static PBVHVertRef SCULPT_fake_neighbor_search(Sculpt *sd,
   NearestVertexFakeNeighborTLSData nvtd;
   nvtd.nearest_vertex.i = -1;
   nvtd.nearest_vertex_distance_squared = FLT_MAX;
-  nvtd.current_topology_id = SCULPT_vertex_get_connected_component(ss, vertex);
+  nvtd.current_topology_id = SCULPT_vertex_island_get(ss, vertex);
 
   TaskParallelSettings settings;
   BKE_pbvh_parallel_range_settings(, true, totnode);
@@ -6062,55 +6053,6 @@ struct SculptTopologyIDFloodFillData {
   int next_id;
 };
 
-static bool SCULPT_connected_components_floodfill_cb(
-SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool 
/*is_duplicate*/, void *userdata)
-{
-  SculptTopologyIDFloodFillData *data = 
static_cast(userdata);
-
-  int from_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, from_v);
-  int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
-
-  ss->vertex_info.connected_component[from_v_i] = data->next_id;
-  ss->vertex_info.connected_component[to_v_i] = data->next_id;
-  return true;
-}
-
-void SCULPT_connected_components_ensure(Object *ob)
-{
-  SculptSession *ss = ob->sculpt;
-
-  /* Topology IDs already initialized. They only need to be recalculated when 
the PBVH is
-   * rebuild.
-   */
-  if (ss->vertex_info.connected_component) {
-return;
-  }
-
-  const int totvert = SCULPT_vertex_count_get(ss);
-  ss->vertex_info.connected_component = static_cast(
- 

[Bf-blender-cvs] [da21e035d33] master: Sculpt: Fix T103923: Expand face sets now taking visibility into account

2023-01-19 Thread Joseph Eagar
Commit: da21e035d33535ce8740f8b563deb73f9e52245e
Author: Joseph Eagar
Date:   Thu Jan 19 18:04:34 2023 -0800
Branches: master
https://developer.blender.org/rBda21e035d33535ce8740f8b563deb73f9e52245e

Sculpt: Fix T103923: Expand face sets now taking visibility into account

The code was never ported from the old system of encoding visibility
as negative face set values.

===

M   source/blender/editors/sculpt_paint/sculpt_expand.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index e1980f0ff6b..683eeed5111 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -256,7 +256,7 @@ static bool sculpt_expand_state_get(SculptSession *ss,
  */
 static bool sculpt_expand_face_state_get(SculptSession *ss, ExpandCache 
*expand_cache, const int f)
 {
-  if (expand_cache->original_face_sets[f] <= 0) {
+  if (ss->hide_poly && ss->hide_poly[f]) {
 return false;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4fa6ce09734] master: Sculpt: Expand NORMALS and TOPOLOGY_DIAGNAL falloff now check islands

2023-01-19 Thread Joseph Eagar
Commit: 4fa6ce09734d113b4fe0d2745b07a0cd9331f6d2
Author: Joseph Eagar
Date:   Thu Jan 19 17:55:25 2023 -0800
Branches: master
https://developer.blender.org/rB4fa6ce09734d113b4fe0d2745b07a0cd9331f6d2

Sculpt: Expand NORMALS and TOPOLOGY_DIAGNAL falloff now check islands

Prevents disconnect parts of the mesh from having their masks
filled.

===

M   source/blender/editors/sculpt_paint/sculpt_expand.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index 069f943dc41..e1980f0ff6b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -397,7 +397,9 @@ static void sculpt_expand_check_topology_islands(Object *ob)
   ss->expand_cache->check_islands = ELEM(ss->expand_cache->falloff_type,
  SCULPT_EXPAND_FALLOFF_GEODESIC,
  SCULPT_EXPAND_FALLOFF_TOPOLOGY,
- 
SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY);
+ 
SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS,
+ 
SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY,
+ SCULPT_EXPAND_FALLOFF_NORMALS);
 
   if (ss->expand_cache->check_islands) {
 SCULPT_topology_islands_ensure(ob);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0e35d5c0957] master: Sculpt: Expand now waits for click before invoking when called from menu

2023-01-19 Thread Joseph Eagar
Commit: 0e35d5c0957e962792beb103bb3f59ceacdf0f0b
Author: Joseph Eagar
Date:   Thu Jan 19 17:49:53 2023 -0800
Branches: master
https://developer.blender.org/rB0e35d5c0957e962792beb103bb3f59ceacdf0f0b

Sculpt: Expand now waits for click before invoking when called from menu

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   source/blender/editors/sculpt_paint/sculpt_expand.c

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 19a93e0882a..19093e51ec5 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -6269,6 +6269,7 @@ def km_sculpt_expand_modal(_params):
 ("CANCEL", {"type": 'ESC', "value": 'PRESS', "any": True}, None),
 ("CANCEL", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}, 
None),
 ("CONFIRM", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, 
None),
+("CONFIRM", {"type": 'LEFTMOUSE', "value": 'RELEASE', "any": True}, 
None),
 ("INVERT", {"type": 'F', "value": 'PRESS', "any": True}, None),
 ("PRESERVE", {"type": 'E', "value": 'PRESS', "any": True}, None),
 ("GRADIENT", {"type": 'G', "value": 'PRESS', "any": True}, None),
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index b71f52acbdb..069f943dc41 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -2334,7 +2334,7 @@ void SCULPT_OT_expand(wmOperatorType *ot)
   ot->cancel = sculpt_expand_cancel;
   ot->poll = SCULPT_mode_poll;
 
-  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_DEPENDS_ON_CURSOR;
 
   static EnumPropertyItem prop_sculpt_expand_falloff_type_items[] = {
   {SCULPT_EXPAND_FALLOFF_GEODESIC, "GEODESIC", 0, "Geodesic", ""},

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8a6c6a5dc51] master: Cleanup: Remove unused functions in sculpt automasking code

2023-01-19 Thread Joseph Eagar
Commit: 8a6c6a5dc5189e41348943749eef5aa30434d046
Author: Joseph Eagar
Date:   Thu Jan 19 17:30:17 2023 -0800
Branches: master
https://developer.blender.org/rB8a6c6a5dc5189e41348943749eef5aa30434d046

Cleanup: Remove unused functions in sculpt automasking code

===

M   source/blender/editors/sculpt_paint/sculpt_automasking.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index dcd8a72eb51..3edc99d32c1 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -585,19 +585,6 @@ void SCULPT_automasking_cache_free(AutomaskingCache 
*automasking)
   MEM_SAFE_FREE(automasking);
 }
 
-static bool sculpt_automasking_is_constrained_by_radius(Brush *br)
-{
-  /* 2D falloff is not constrained by radius. */
-  if (br->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) {
-return false;
-  }
-
-  if (ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, 
SCULPT_TOOL_ROTATE)) {
-return true;
-  }
-  return false;
-}
-
 struct AutomaskFloodFillData {
   float radius;
   bool use_radius;
@@ -605,18 +592,6 @@ struct AutomaskFloodFillData {
   char symm;
 };
 
-static bool automask_floodfill_cb(
-SculptSession *ss, PBVHVertRef from_v, PBVHVertRef to_v, bool 
/*is_duplicate*/, void *userdata)
-{
-  AutomaskFloodFillData *data = (AutomaskFloodFillData *)userdata;
-
-  *(float *)SCULPT_vertex_attr_get(to_v, ss->attrs.automasking_factor) = 1.0f;
-  *(float *)SCULPT_vertex_attr_get(from_v, ss->attrs.automasking_factor) = 
1.0f;
-  return (!data->use_radius ||
-  SCULPT_is_vertex_inside_brush_radius_symm(
-  SCULPT_vertex_co_get(ss, to_v), data->location, data->radius, 
data->symm));
-}
-
 static void sculpt_face_sets_automasking_init(Sculpt *sd, Object *ob)
 {
   SculptSession *ss = ob->sculpt;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8b5c2d9ef10] master: Sculpt: Restrict expand to active mesh islands for geodesic and topology

2023-01-19 Thread Joseph Eagar
Commit: 8b5c2d9ef109014ef64d8c170fd3e0554e8fef79
Author: Joseph Eagar
Date:   Thu Jan 19 17:27:40 2023 -0800
Branches: master
https://developer.blender.org/rB8b5c2d9ef109014ef64d8c170fd3e0554e8fef79

Sculpt: Restrict expand to active mesh islands for geodesic and topology

Fixes bug where other islands sometimes get their masks cleared (or
filled) in strange circumstances.  Still need to figure out the
correct behavior for spherical falloff.

===

M   source/blender/editors/sculpt_paint/sculpt_expand.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index a05dc8c7c66..b71f52acbdb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -390,6 +390,22 @@ static BLI_bitmap 
*sculpt_expand_boundary_from_enabled(SculptSession *ss,
   return boundary_verts;
 }
 
+static void sculpt_expand_check_topology_islands(Object *ob)
+{
+  SculptSession *ss = ob->sculpt;
+
+  ss->expand_cache->check_islands = ELEM(ss->expand_cache->falloff_type,
+ SCULPT_EXPAND_FALLOFF_GEODESIC,
+ SCULPT_EXPAND_FALLOFF_TOPOLOGY,
+ 
SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY);
+
+  if (ss->expand_cache->check_islands) {
+SCULPT_topology_islands_ensure(ob);
+ss->expand_cache->initial_island_key = SCULPT_vertex_island_get(
+ss, ss->expand_cache->initial_active_vertex);
+  }
+}
+
 /* Functions implementing different algorithms for initializing falloff 
values. */
 
 /**
@@ -1250,6 +1266,11 @@ static void sculpt_expand_mask_update_task_cb(void 
*__restrict userdata,
 const float initial_mask = *vd.mask;
 const bool enabled = sculpt_expand_state_get(ss, expand_cache, vd.vertex);
 
+if (expand_cache->check_islands &&
+SCULPT_vertex_island_get(ss, vd.vertex) != 
expand_cache->initial_island_key) {
+  continue;
+}
+
 float new_mask;
 
 if (enabled) {
@@ -1842,6 +1863,9 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 return OPERATOR_FINISHED;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC: {
+expand_cache->falloff_gradient = SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC;
+sculpt_expand_check_topology_islands(ob);
+
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
 sd,
@@ -1851,6 +1875,9 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY: {
+expand_cache->falloff_gradient = SCULPT_EXPAND_FALLOFF_TOPOLOGY;
+sculpt_expand_check_topology_islands(ob);
+
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
 sd,
@@ -1860,6 +1887,9 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS: {
+expand_cache->falloff_gradient = 
SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS;
+sculpt_expand_check_topology_islands(ob);
+
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
 sd,
@@ -1869,6 +1899,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_SPHERICAL: {
+expand_cache->check_islands = false;
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
 sd,
@@ -2213,6 +2244,8 @@ static int sculpt_expand_invoke(bContext *C, wmOperator 
*op, const wmEvent *even
   sculpt_expand_falloff_factors_from_vertex_and_symm_create(
   ss->expand_cache, sd, ob, ss->expand_cache->initial_active_vertex, 
falloff_type);
 
+  sculpt_expand_check_topology_islands(ob);
+
   /* Initial mesh data update, resets all target data in the sculpt mesh. */
   sculpt_expand_update_for_vertex(C, ob, 
ss->expand_cache->initial_active_vertex);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 760f05ac105..b053b2764ca 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -818,6 +818,9 @@ typedef struct ExpandCache {
   float *original_mask;
   int *original_face_sets;
   float (*original_colors)[4];
+
+  int initial_island_key;
+  bool check_islands;
 } ExpandCache;
 /** \} */

___
Bf-blender-cvs 

[Bf-blender-cvs] [9889918fd4d] master: Sculpt: New API for keeping track of topology islands

2023-01-19 Thread Joseph Eagar
Commit: 9889918fd4de7a8db9702628de787c840673d85b
Author: Joseph Eagar
Date:   Thu Jan 19 16:53:43 2023 -0800
Branches: master
https://developer.blender.org/rB9889918fd4de7a8db9702628de787c840673d85b

Sculpt: New API for keeping track of topology islands

Mesh islands (shells) are now calculated on an as-needed
basis and cached inside of a temp attribute,
`sculpt_topology_island_key`.  This attribute is updated
as needed when geometry changes (e.g. the trim brush)
or when mesh visibility changes.

This replaces the old behavior where the "topology" automasking
mode would walk the entire mesh on every stroke.

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/editors/sculpt_paint/paint_hide.c
M   source/blender/editors/sculpt_paint/paint_mask.c
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/sculpt_paint/sculpt_automasking.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_ops.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 55c89e2d6b1..aefb33357a2 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -559,6 +559,8 @@ typedef struct SculptAttributePointers {
   SculptAttribute *automasking_stroke_id;
   SculptAttribute *automasking_cavity;
 
+  SculptAttribute *topology_island_key; /* CD_PROP_INT8 */
+
   /* BMesh */
   SculptAttribute *dyntopo_node_id_vertex;
   SculptAttribute *dyntopo_node_id_face;
@@ -756,6 +758,7 @@ typedef struct SculptSession {
 
   int last_automasking_settings_hash;
   uchar last_automask_stroke_id;
+  bool islands_valid; /* Is attrs.topology_island_key valid? */
 } SculptSession;
 
 void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 0e7eb957fd9..5a63b9bb126 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -74,18 +74,40 @@ struct PBVHPublic {
  * to be vertices.  This is not true of edges or faces which are pulled from
  * the base mesh.
  */
+
+#ifdef __cplusplus
+/* A few C++ methods to play nice with sets and maps. */
+#  define PBVH_REF_CXX_METHODS(Class) \
+bool operator==(const Class b) const \
+{ \
+  return i == b.i; \
+} \
+uint64_t hash() const \
+{ \
+  return i; \
+}
+#else
+#  define PBVH_REF_CXX_METHODS(cls)
+#endif
+
 typedef struct PBVHVertRef {
   intptr_t i;
+
+  PBVH_REF_CXX_METHODS(PBVHVertRef)
 } PBVHVertRef;
 
 /* NOTE: edges in PBVH_GRIDS are always pulled from the base mesh. */
 typedef struct PBVHEdgeRef {
   intptr_t i;
+
+  PBVH_REF_CXX_METHODS(PBVHVertRef)
 } PBVHEdgeRef;
 
 /* NOTE: faces in PBVH_GRIDS are always puled from the base mesh. */
 typedef struct PBVHFaceRef {
   intptr_t i;
+
+  PBVH_REF_CXX_METHODS(PBVHVertRef)
 } PBVHFaceRef;
 
 #define PBVH_REF_NONE -1LL
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c 
b/source/blender/editors/sculpt_paint/paint_hide.c
index 1ec93d3a713..2c6d3357894 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -378,6 +378,8 @@ static int hide_show_exec(bContext *C, wmOperator *op)
   /* End undo. */
   SCULPT_undo_push_end(ob);
 
+  SCULPT_topology_islands_invalidate(ob->sculpt);
+
   /* Ensure that edges and faces get hidden as well (not used by
* sculpt but it looks wrong when entering editmode otherwise). */
   if (pbvh_type == PBVH_FACES) {
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c 
b/source/blender/editors/sculpt_paint/paint_mask.c
index c6ffee8ba46..26d3b4fead9 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -1385,6 +1385,7 @@ static void sculpt_gesture_trim_begin(bContext *C, 
SculptGestureContext *sgconte
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
   sculpt_gesture_trim_calculate_depth(sgcontext);
   sculpt_gesture_trim_geometry_generate(sgcontext);
+  SCULPT_topology_islands_invalidate(ss);
   BKE_sculpt_update_object_for_edit(depsgraph, sgcontext->vc.obact, true, 
false, false);
   SCULPT_undo_push_node(sgcontext->vc.obact, NULL, SCULPT_UNDO_GEOMETRY);
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index af03fe06092..a26cf16b78a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -17,10 +17,12 @@
 #include "BLI_ghash.h"
 #include "BLI_gsqueue.h"
 #include "BLI_math.h"
+#include "BLI_set.hh"
 #include "BLI_task.h"
 #include "BLI_task.hh"
 

[Bf-blender-cvs] [92773761d33] master: Sculpt: Change expand hotkey to not auto-create mask

2023-01-13 Thread Joseph Eagar
Commit: 92773761d33058ec4e0eeb3819e23fb06726b5ea
Author: Joseph Eagar
Date:   Fri Jan 13 20:17:03 2023 -0800
Branches: master
https://developer.blender.org/rB92773761d33058ec4e0eeb3819e23fb06726b5ea

Sculpt: Change expand hotkey to not auto-create mask

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index c861236c468..19a93e0882a 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5053,7 +5053,7 @@ def km_sculpt(params):
  ("target", "MASK"),
  ("falloff_type", "GEODESIC"),
  ("invert", True),
- ("use_auto_mask", True),
+ ("use_auto_mask", False),
  ("use_mask_preserve", True),
  ]}),
 ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True, 
"alt": True},

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [325105ee6f6] master: Sculpt: add support for curves sculpt to paint_init_pivot

2023-01-13 Thread Joseph Eagar
Commit: 325105ee6f68ed21cfa85e89922f9ec669d74efa
Author: Joseph Eagar
Date:   Fri Jan 13 19:58:42 2023 -0800
Branches: master
https://developer.blender.org/rB325105ee6f68ed21cfa85e89922f9ec669d74efa

Sculpt: add support for curves sculpt to paint_init_pivot

Uses BKE_object_boundbox_get.

===

M   source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M   source/blender/editors/sculpt_paint/paint_image.cc

===

diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
index 797b57dd0ca..f12b94aea8f 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -286,6 +286,7 @@ static void curves_sculptmode_enter(bContext *C)
   ob->mode = OB_MODE_SCULPT_CURVES;
 
   ED_paint_cursor_start(_sculpt->paint, CURVES_SCULPT_mode_poll_view3d);
+  paint_init_pivot(ob, scene);
 
   /* Necessary to change the object mode on the evaluated object. */
   DEG_id_tag_update(>id, ID_RECALC_COPY_ON_WRITE);
diff --git a/source/blender/editors/sculpt_paint/paint_image.cc 
b/source/blender/editors/sculpt_paint/paint_image.cc
index a57287b924b..d5efb4fe9c6 100644
--- a/source/blender/editors/sculpt_paint/paint_image.cc
+++ b/source/blender/editors/sculpt_paint/paint_image.cc
@@ -759,23 +759,47 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
 
 / texture paint toggle operator /
 
-void paint_init_pivot(Object *ob, Scene *scene)
+static void paint_init_pivot_mesh(Object *ob, Scene *scene, float location[3])
 {
-  UnifiedPaintSettings *ups = >toolsettings->unified_paint_settings;
-
   const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
   if (!me_eval) {
 me_eval = (const Mesh *)ob->data;
   }
 
-  float location[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, 
-FLT_MAX, -FLT_MAX};
+  float min[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, -FLT_MAX, 
-FLT_MAX};
 
-  if (!BKE_mesh_minmax(me_eval, location, max)) {
+  if (!BKE_mesh_minmax(me_eval, min, max)) {
 zero_v3(location);
 zero_v3(max);
   }
 
-  interp_v3_v3v3(location, location, max, 0.5f);
+  interp_v3_v3v3(location, min, max, 0.5f);
+}
+
+static void paint_init_pivot_curves(Object *ob, Scene *scene, float 
location[3])
+{
+  const BoundBox *bbox = BKE_object_boundbox_get(ob);
+  interp_v3_v3v3(location, bbox->vec[0], bbox->vec[6], 0.5f);
+}
+
+void paint_init_pivot(Object *ob, Scene *scene)
+{
+  UnifiedPaintSettings *ups = >toolsettings->unified_paint_settings;
+  float location[3];
+
+  switch (ob->type) {
+case OB_MESH:
+  paint_init_pivot_mesh(ob, scene, location);
+  break;
+case OB_CURVES:
+  paint_init_pivot_curves(ob, scene, location);
+  break;
+default:
+  BLI_assert_unreachable();
+  ups->last_stroke_valid = false;
+  return;
+  }
+
   mul_m4_v3(ob->object_to_world, location);
 
   ups->last_stroke_valid = true;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bc3da3ad41a] master: Sculpt: fix T103454: SCULPT_vertex_is_occluded is not compatible with filters

2023-01-13 Thread Joseph Eagar
Commit: bc3da3ad41a906414c589625bb3cd92384ddbcc3
Author: Joseph Eagar
Date:   Fri Jan 13 00:10:46 2023 -0800
Branches: master
https://developer.blender.org/rBbc3da3ad41a906414c589625bb3cd92384ddbcc3

Sculpt: fix T103454: SCULPT_vertex_is_occluded is not compatible with
filters

===

M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index dd3e38258dc..af03fe06092 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -6225,9 +6225,12 @@ bool SCULPT_vertex_is_occluded(SculptSession *ss, 
PBVHVertRef vertex, bool origi
   copy_v3_v3(co, SCULPT_vertex_co_get(ss, vertex));
   float mouse[2];
 
-  ED_view3d_project_float_v2_m4(ss->cache->vc->region, co, mouse, 
ss->cache->projection_mat);
+  ViewContext *vc = ss->cache ? ss->cache->vc : >filter_cache->vc;
 
-  int depth = SCULPT_raycast_init(ss->cache->vc, mouse, ray_end, ray_start, 
ray_normal, original);
+  ED_view3d_project_float_v2_m4(
+  vc->region, co, mouse, ss->cache ? ss->cache->projection_mat : 
ss->filter_cache->viewmat);
+
+  int depth = SCULPT_raycast_init(vc, mouse, ray_end, ray_start, ray_normal, 
original);
 
   negate_v3(ray_normal);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c 
b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index f6bf9c0c488..9ffe10360af 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -152,6 +152,8 @@ void SCULPT_filter_cache_init(bContext *C,
   Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
   ViewContext vc;
   ED_view3d_viewcontext_init(C, , depsgraph);
+
+  ss->filter_cache->vc = vc;
   copy_m4_m4(ss->filter_cache->viewmat, vc.rv3d->viewmat);
   copy_m4_m4(ss->filter_cache->viewmat_inv, vc.rv3d->viewinv);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 6a6fce851e7..700fba4cd40 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -22,6 +22,8 @@
 #include "BLI_gsqueue.h"
 #include "BLI_threads.h"
 
+#include "ED_view3d.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -486,6 +488,8 @@ typedef struct FilterCache {
 
   /* Pre-smoothed colors used by sharpening. Colors are HSL. */
   float (*pre_smoothed_color)[4];
+
+  ViewContext vc;
 } FilterCache;
 
 /**

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [daedf193155] master: Sculpt: Fix T103724: missing mask attr existance check for PBVH_GRIDS

2023-01-12 Thread Joseph Eagar
Commit: daedf19315519d7279b762b72f7cb50bdaf26606
Author: Joseph Eagar
Date:   Thu Jan 12 23:57:01 2023 -0800
Branches: master
https://developer.blender.org/rBdaedf19315519d7279b762b72f7cb50bdaf26606

Sculpt: Fix T103724: missing mask attr existance check for PBVH_GRIDS

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 4f6dbb69893..7084c4ecd97 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 4f6dbb69893bd6bdf73467effe77ae46c8e4ee37
+Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
diff --git a/release/scripts/addons b/release/scripts/addons
index bf49eeaa14c..a9d4443c244 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit bf49eeaa14c445d3c53068203fdf91bff568fe64
+Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 0f72f6c85c3..bdcfdd47ec3 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 0f72f6c85c3743a9072273acb6a8a34b1cf1064b
+Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index e1586e00788..dd3e38258dc 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -259,6 +259,11 @@ float SCULPT_vertex_mask_get(SculptSession *ss, 
PBVHVertRef vertex)
 }
 case PBVH_GRIDS: {
   const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
+
+  if (key->mask_offset == -1) {
+return 0.0f;
+  }
+
   const int grid_index = vertex.i / key->grid_area;
   const int vertex_index = vertex.i - grid_index * key->grid_area;
   CCGElem *elem = BKE_pbvh_get_grids(ss->pbvh)[grid_index];
diff --git a/source/tools b/source/tools
index 3582f5326d0..e1744b9bd82 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 3582f5326d08ca05c2a19056597e49ec5511d854
+Subproject commit e1744b9bd82527cf7e8af63362b61bd309b5711b

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f25377ceb7f] temp-pbvh-texpaint-automasking: Merge branch 'master' into temp-pbvh-texpaint-automasking

2023-01-12 Thread Joseph Eagar
Commit: f25377ceb7f589072d861bfca6c6006d321ee009
Author: Joseph Eagar
Date:   Thu Jan 12 19:28:57 2023 -0800
Branches: temp-pbvh-texpaint-automasking
https://developer.blender.org/rBf25377ceb7f589072d861bfca6c6006d321ee009

Merge branch 'master' into temp-pbvh-texpaint-automasking

===



===

diff --cc source/blender/blenkernel/BKE_pbvh.h
index af6442530de,0e7eb957fd9..03a9eb2c7b1
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -587,14 -583,13 +583,15 @@@ typedef struct PBVHVertexIter 
int gridsize;
  
/* mesh */
-   struct MVert *mverts;
+   float (*vert_positions)[3];
float (*vert_normals)[3];
 +
const bool *hide_vert;
int totvert;
 +  int unique_vert_len;
const int *vert_indices;
float *vmask;
+   bool is_mesh;
  
/* bmesh */
struct GSetIterator bm_unique_verts;
diff --cc source/blender/blenkernel/intern/pbvh.c
index 03463ca9a5c,2a8683ecaaa..d88db32e60d
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -3366,11 -3348,9 +3348,12 @@@ void pbvh_vertex_iter_init(PBVH *pbvh, 
else {
  vi->totvert = uniq_verts;
}
 +
 +  vi->unique_vert_len = uniq_verts;
 +
vi->vert_indices = vert_indices;
-   vi->mverts = verts;
+   vi->vert_positions = pbvh->vert_positions;
+   vi->is_mesh = pbvh->vert_positions != NULL;
  
if (pbvh->header.type == PBVH_BMESH) {
  BLI_gsetIterator_init(>bm_unique_verts, node->bm_unique_verts);
diff --cc source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 79c5a8b5f27,67c3e4bfd74..1982cdc9727
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@@ -12,10 -12,9 +12,10 @@@
  #include "BLI_hash.h"
  #include "BLI_index_range.hh"
  #include "BLI_math.h"
- #include "BLI_math_vec_types.hh"
+ #include "BLI_math_vector_types.hh"
  #include "BLI_set.hh"
  #include "BLI_task.h"
 +#include "BLI_task.hh"
  #include "BLI_vector.hh"
  
  #include "DNA_brush_types.h"
diff --cc source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index 16cb2ed3e0f,75c84c48f77..29be026c300
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@@ -367,16 -328,16 +370,16 @@@ static void do_paint_pixels(void *__res
PBVHData _data = BKE_pbvh_pixels_data_get(*pbvh);
NodeData _data = BKE_pbvh_pixels_node_data_get(*node);
const int thread_id = BLI_task_parallel_thread_id(tls);
-   MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
+   const float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
  
std::vector brush_test = init_uv_primitives_brush_test(
-   ss, pbvh_data.geom_primitives, node_data.uv_primitives, mvert);
+   ss, pbvh_data.geom_primitives, node_data.uv_primitives, positions);
  
-   PaintingKernel kernel_float4(ss, brush, thread_id, 
mvert);
-   PaintingKernel kernel_byte4(ss, brush, thread_id, mvert);
+   PaintingKernel kernel_float4(ss, brush, thread_id, 
positions);
+   PaintingKernel kernel_byte4(ss, brush, thread_id, 
positions);
  
 -  AutomaskingNodeData automask_data;
 -  SCULPT_automasking_node_begin(ob, ss, ss->cache->automasking, 
_data, data->nodes[n]);
 +  AutomaskingNodeData automask_data = {0};
 +  automask_data.have_orig_data = false;
  
ImageUser image_user = *data->image_data.image_user;
bool pixels_updated = false;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [14fa20d7979] temp-pbvh-split: Merge branch 'master' into temp-pbvh-split

2023-01-12 Thread Joseph Eagar
Commit: 14fa20d7979a98827ce5eaf6bbb578f678130592
Author: Joseph Eagar
Date:   Thu Jan 12 19:33:03 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB14fa20d7979a98827ce5eaf6bbb578f678130592

Merge branch 'master' into temp-pbvh-split

===



===

diff --cc release/datafiles/locale
index 4a581c54af9,4f6dbb69893..7084c4ecd97
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e
 -Subproject commit 4f6dbb69893bd6bdf73467effe77ae46c8e4ee37
++Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
diff --cc release/scripts/addons
index 0b0052bd53a,bf49eeaa14c..a9d4443c244
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde
 -Subproject commit bf49eeaa14c445d3c53068203fdf91bff568fe64
++Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
diff --cc release/scripts/addons_contrib
index 96143b1a8b0,0f72f6c85c3..bdcfdd47ec3
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3
 -Subproject commit 0f72f6c85c3743a9072273acb6a8a34b1cf1064b
++Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
diff --cc source/blender/blenkernel/intern/pbvh_pixels.cc
index 8af7cdf3eb4,39651349ae9..99d2103461e
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@@ -536,10 -233,7 +538,10 @@@ static void do_encode_pixels(void *__re
  
  static bool should_pixels_be_updated(PBVHNode *node)
  {
-   if ((node->flag & (PBVH_Leaf|PBVH_TexLeaf)) == 0) {
 -  if ((node->flag & PBVH_Leaf) == 0) {
++  if ((node->flag & (PBVH_Leaf | PBVH_TexLeaf)) == 0) {
 +return false;
 +  }
 +  if (node->children_offset != 0) {
  return false;
}
if ((node->flag & PBVH_RebuildPixels) != 0) {
@@@ -660,19 -354,19 +662,19 @@@ static bool update_pixels(PBVH *pbvh, M
Vector nodes_to_update;
  
if (!find_nodes_to_update(pbvh, nodes_to_update)) {
 -return;
 +return false;
}
  
-   const MLoopUV *ldata_uv = static_cast(
-   CustomData_get_layer(>ldata, CD_MLOOPUV));
-   if (ldata_uv == nullptr) {
- return false;
+   const StringRef active_uv_name = 
CustomData_get_active_layer_name(>ldata, CD_PROP_FLOAT2);
+   if (active_uv_name.is_empty()) {
+ return;
}
  
-   uv_islands::MeshData mesh_data({pbvh->looptri, pbvh->totprim},
-  {pbvh->mloop, mesh->totloop},
-  pbvh->totvert,
-  {ldata_uv, mesh->totloop});
+   const AttributeAccessor attributes = mesh->attributes();
+   const VArraySpan uv_map = attributes.lookup(active_uv_name, 
ATTR_DOMAIN_CORNER);
+ 
+   uv_islands::MeshData mesh_data(
+   {pbvh->looptri, pbvh->totprim}, {pbvh->mloop, mesh->totloop}, 
pbvh->totvert, uv_map);
uv_islands::UVIslands islands(mesh_data);
  
uv_islands::UVIslandsMask uv_masks;
diff --cc source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index b376ab2c480,75c84c48f77..ebe4bcd4916
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@@ -338,30 -328,14 +341,30 @@@ static void do_paint_pixels(void *__res
PBVHData _data = BKE_pbvh_pixels_data_get(*pbvh);
NodeData _data = BKE_pbvh_pixels_node_data_get(*node);
const int thread_id = BLI_task_parallel_thread_id(tls);
-   MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
+   const float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
  
std::vector brush_test = init_uv_primitives_brush_test(
-   ss, pbvh_data.geom_primitives, node_data.uv_primitives, mvert);
+   ss, pbvh_data.geom_primitives, node_data.uv_primitives, positions);
  
-   PaintingKernel kernel_float4(ss, brush, thread_id, 
mvert);
-   PaintingKernel kernel_byte4(ss, brush, thread_id, mvert);
+   PaintingKernel kernel_float4(ss, brush, thread_id, 
positions);
+   PaintingKernel kernel_byte4(ss, brush, thread_id, 
positions);
  
 +  float brush_color[4];
 +
 +#ifdef DEBUG_PIXEL_NODES
 +  uint hash = BLI_hash_int(POINTER_AS_UINT(node));
 +
 +  brush_color[0] = (float)(hash & 255) / 255.0f;
 +  brush_color[1] = (float)((hash >> 8) & 255) / 255.0f;
 +  brush_color[2] = (float)((hash >> 16) & 255) / 255.0f;
 +#else
 +  copy_v3_v3(brush_color,
 + ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, 
brush) :
 + BKE_brush_color_get(ss->scene, brush));
 +#endif
 +
 +  brush_color[3] = 1.0f;
 +
AutomaskingNodeData automask_data;
SCULPT_automasking_node_begin(ob,

[Bf-blender-cvs] [6fbb4d70516] blender-v3.3-release: Fix T103261: Undo after mask extract doesn't restore active object

2023-01-12 Thread Joseph Eagar
Commit: 6fbb4d70516ef2cf84ae3b07297a749c502abd16
Author: Joseph Eagar
Date:   Sun Dec 18 07:50:35 2022 -0800
Branches: blender-v3.3-release
https://developer.blender.org/rB6fbb4d70516ef2cf84ae3b07297a749c502abd16

Fix T103261: Undo after mask extract doesn't restore active object

===

M   source/blender/editors/mesh/editmesh_mask_extract.c

===

diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c 
b/source/blender/editors/mesh/editmesh_mask_extract.c
index 7634ce6af9e..7ee92d4a5f7 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -37,6 +37,7 @@
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_sculpt.h"
+#include "ED_undo.h"
 #include "ED_view3d.h"
 
 #include "bmesh_tools.h"
@@ -286,6 +287,16 @@ static int paint_mask_extract_exec(bContext *C, wmOperator 
*op)
   params.add_boundary_loop = RNA_boolean_get(op->ptr, "add_boundary_loop");
   params.apply_shrinkwrap = RNA_boolean_get(op->ptr, "apply_shrinkwrap");
   params.add_solidify = RNA_boolean_get(op->ptr, "add_solidify");
+
+  /* Push an undo step prior to extraction.
+   * Note: A second push happens after the operator due to
+   * the OPTYPE_UNDO flag; having an initial undo step here
+   * is just needed to preserve the active object pointer.
+   * 
+   * Fixes T103261.
+   */
+  ED_undo_push_op(C, op);
+
   return geometry_extract_apply(C, op, geometry_extract_tag_masked_faces, 
);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [88e9826529d] master: Sculpt: Fix T102889: Sculpt trim tool extrudes in perspective

2023-01-11 Thread Joseph Eagar
Commit: 88e9826529d1cce750181d6355a42a2bbcdb1ff3
Author: Joseph Eagar
Date:   Wed Jan 11 09:57:58 2023 -0800
Branches: master
https://developer.blender.org/rB88e9826529d1cce750181d6355a42a2bbcdb1ff3

Sculpt: Fix T102889: Sculpt trim tool extrudes in perspective

Added an extrude mode enum to the trim operators to
control extrusion: "project" and "fixed."  "Fixed" just
extrudes along a fixed normal and is the new default.

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/editors/sculpt_paint/paint_mask.c
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 7be7aff5a18..7084c4ecd97 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 7be7aff5a18c550465b3f7634539ed4168af7c51
+Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
diff --git a/release/scripts/addons b/release/scripts/addons
index c226f867aff..a9d4443c244 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit c226f867affd12881533a54c8c90ac6eebfaca6c
+Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index fb6136154c8..37cb01503d3 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1408,6 +1408,7 @@ class _defs_sculpt:
 def draw_settings(_context, layout, tool):
 props = tool.operator_properties("sculpt.trim_box_gesture")
 layout.prop(props, "trim_mode", expand=False)
+layout.prop(props, "trim_extrude_mode", expand=False)
 layout.prop(props, "use_cursor_depth", expand=False)
 return dict(
 idname="builtin.box_trim",
@@ -1424,6 +1425,7 @@ class _defs_sculpt:
 props = tool.operator_properties("sculpt.trim_lasso_gesture")
 layout.prop(props, "trim_mode", expand=False)
 layout.prop(props, "trim_orientation", expand=False)
+layout.prop(props, "trim_extrude_mode", expand=False)
 layout.prop(props, "use_cursor_depth", expand=False)
 return dict(
 idname="builtin.lasso_trim",
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c 
b/source/blender/editors/sculpt_paint/paint_mask.c
index eff24ceb0b3..3ebd5fe799d 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -954,6 +954,21 @@ static EnumPropertyItem prop_trim_orientation_types[] = {
 {0, NULL, 0, NULL, NULL},
 };
 
+typedef enum eSculptTrimExtrudeMode {
+  SCULPT_GESTURE_TRIM_EXTRUDE_PROJECT,
+  SCULPT_GESTURE_TRIM_EXTRUDE_FIXED
+} eSculptTrimExtrudeMode;
+
+static EnumPropertyItem prop_trim_extrude_modes[] = {
+{SCULPT_GESTURE_TRIM_EXTRUDE_PROJECT,
+ "PROJECT",
+ 0,
+ "Project",
+ "Project back faces when extruding"},
+{SCULPT_GESTURE_TRIM_EXTRUDE_FIXED, "FIXED", 0, "Fixed", "Extrude back 
faces by fixed amount"},
+{0, NULL, 0, NULL, NULL},
+};
+
 typedef struct SculptGestureTrimOperation {
   SculptGestureOperation op;
 
@@ -967,6 +982,7 @@ typedef struct SculptGestureTrimOperation {
 
   eSculptTrimOperationType mode;
   eSculptTrimOrientationType orientation;
+  eSculptTrimExtrudeMode extrude_mode;
 } SculptGestureTrimOperation;
 
 static void sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
@@ -1160,23 +1176,39 @@ static void 
sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
   ED_view3d_win_to_3d_on_plane(region, shape_plane, screen_points[i], 
false, new_point);
   madd_v3_v3fl(new_point, shape_normal, depth_front);
 }
-mul_v3_m4v3(positions[i], ob_imat, new_point);
-mul_v3_m4v3(trim_operation->true_mesh_co[i], ob_imat, new_point);
+
+copy_v3_v3(positions[i], new_point);
   }
 
   /* Write vertices coordinates for the back face. */
   madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_back);
   for (int i = 0; i < tot_screen_points; i++) {
 float new_point[3];
-if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) {
-  ED_view3d_win_to_3d(vc->v3d, region, depth_point, screen_points[i], 
new_point);
+
+if (trim_operation->extrude_mode == SCULPT_GESTURE_TRIM_EXTRUDE_PROJECT) {
+  if (trim_operation->orientation == SCULPT_GESTURE_TRIM_ORIENTATION_VIEW) 
{
+ED_view3d_win_to_3d(vc->v3d, region, 

[Bf-blender-cvs] [08fc4eae2e1] temp-pbvh-texpaint-automasking: Merge branch 'master' into temp-pbvh-texpaint-automasking

2023-01-05 Thread Joseph Eagar
Commit: 08fc4eae2e1386ff22ca873cd7e3b6bbbd90693a
Author: Joseph Eagar
Date:   Thu Jan 5 22:24:46 2023 -0800
Branches: temp-pbvh-texpaint-automasking
https://developer.blender.org/rB08fc4eae2e1386ff22ca873cd7e3b6bbbd90693a

Merge branch 'master' into temp-pbvh-texpaint-automasking

===



===

diff --cc source/blender/editors/sculpt_paint/sculpt.cc
index 000,899044145d3..1753ad301f3
mode 00,100644..100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@@ -1,0 -1,6300 +1,6308 @@@
+ /* SPDX-License-Identifier: GPL-2.0-or-later
+  * Copyright 2006 by Nicholas Bishop. All rights reserved. */
+ 
+ /** \file
+  * \ingroup edsculpt
+  * Implements the Sculpt Mode tools.
+  */
+ 
+ #include 
+ #include 
+ #include 
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ #include "BLI_blenlib.h"
+ #include "BLI_dial_2d.h"
+ #include "BLI_ghash.h"
+ #include "BLI_gsqueue.h"
+ #include "BLI_math.h"
+ #include "BLI_task.h"
+ #include "BLI_task.hh"
+ #include "BLI_timeit.hh"
+ #include "BLI_utildefines.h"
+ 
+ #include "DNA_brush_types.h"
+ #include "DNA_customdata_types.h"
+ #include "DNA_mesh_types.h"
+ #include "DNA_meshdata_types.h"
+ #include "DNA_node_types.h"
+ #include "DNA_object_types.h"
+ #include "DNA_scene_types.h"
+ 
+ #include "BKE_attribute.h"
+ #include "BKE_attribute.hh"
+ #include "BKE_brush.h"
+ #include "BKE_ccg.h"
+ #include "BKE_colortools.h"
+ #include "BKE_context.h"
+ #include "BKE_image.h"
+ #include "BKE_key.h"
+ #include "BKE_lib_id.h"
+ #include "BKE_main.h"
+ #include "BKE_mesh.h"
+ #include "BKE_mesh_mapping.h"
+ #include "BKE_modifier.h"
+ #include "BKE_multires.h"
+ #include "BKE_node_runtime.hh"
+ #include "BKE_object.h"
+ #include "BKE_paint.h"
+ #include "BKE_pbvh.h"
+ #include "BKE_report.h"
+ #include "BKE_scene.h"
+ #include "BKE_subdiv_ccg.h"
+ #include "BKE_subsurf.h"
+ 
+ #include "NOD_texture.h"
+ 
+ #include "DEG_depsgraph.h"
+ 
+ #include "WM_api.h"
+ #include "WM_types.h"
+ 
+ #include "ED_paint.h"
+ #include "ED_screen.h"
+ #include "ED_sculpt.h"
+ #include "ED_view3d.h"
+ 
+ #include "paint_intern.h"
+ #include "sculpt_intern.h"
+ 
+ #include "RNA_access.h"
+ #include "RNA_define.h"
+ 
+ #include "bmesh.h"
+ 
+ using blender::MutableSpan;
+ 
+ /*  */
+ /** \name Sculpt PBVH Abstraction API
+  *
+  * This is read-only, for writing use PBVH vertex iterators. There vd.index 
matches
+  * the indices used here.
+  *
+  * For multi-resolution, the same vertex in multiple grids is counted 
multiple times, with
+  * different index for each grid.
+  * \{ */
+ 
+ void SCULPT_vertex_random_access_ensure(SculptSession *ss)
+ {
+   if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
+ BM_mesh_elem_index_ensure(ss->bm, BM_VERT);
+ BM_mesh_elem_table_ensure(ss->bm, BM_VERT);
+   }
+ }
+ 
+ int SCULPT_vertex_count_get(SculptSession *ss)
+ {
+   switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES:
+   return ss->totvert;
+ case PBVH_BMESH:
+   return BM_mesh_elem_count(BKE_pbvh_get_bmesh(ss->pbvh), BM_VERT);
+ case PBVH_GRIDS:
+   return BKE_pbvh_get_grid_num_verts(ss->pbvh);
+   }
+ 
+   return 0;
+ }
+ 
+ const float *SCULPT_vertex_co_get(SculptSession *ss, PBVHVertRef vertex)
+ {
+   switch (BKE_pbvh_type(ss->pbvh)) {
+ case PBVH_FACES: {
+   if (ss->shapekey_active || ss->deform_modifiers_active) {
+ const MVert *mverts = BKE_pbvh_get_verts(ss->pbvh);
+ return mverts[vertex.i].co;
+   }
+   return ss->mvert[vertex.i].co;
+ }
+ case PBVH_BMESH:
+   return ((BMVert *)vertex.i)->co;
+ case PBVH_GRIDS: {
+   const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
+   const int grid_index = vertex.i / key->grid_area;
+   const int vertex_index = vertex.i - grid_index * key->grid_area;
+   CCGElem *elem = BKE_pbvh_get_grids(ss->pbvh)[grid_index];
+   return CCG_elem_co(key, CCG_elem_offset(key, elem, vertex_index));
+ }
+   }
+   return nullptr;
+ }
+ 
+ bool SCULPT_has_loop_colors(const Object *ob)
+ {
+   using namespace blender;
+   Mesh *me = BKE_object_get_original_mesh(ob);
+   const std::optional meta_data = 
me->attributes().lookup_meta_data(
+   me->active_color_attribut

[Bf-blender-cvs] [f1998fe28c1] temp-pbvh-texpaint-automasking: Merge remote-tracking branch 'origin' into temp-pbvh-texpaint-automasking

2023-01-05 Thread Joseph Eagar
Commit: f1998fe28c1e0b2e99e2c8b3616c87f57a5c093d
Author: Joseph Eagar
Date:   Thu Jan 5 22:25:10 2023 -0800
Branches: temp-pbvh-texpaint-automasking
https://developer.blender.org/rBf1998fe28c1e0b2e99e2c8b3616c87f57a5c093d

Merge remote-tracking branch 'origin' into temp-pbvh-texpaint-automasking

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [afbfa1352b7] temp-pbvh-split: temp-pbvh-split: make requested patch changes

2023-01-03 Thread Joseph Eagar
Commit: afbfa1352b778245cc2056e27598b905759f5709
Author: Joseph Eagar
Date:   Tue Jan 3 10:57:29 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rBafbfa1352b778245cc2056e27598b905759f5709

temp-pbvh-split: make requested patch changes

===

M   source/blender/blenkernel/intern/pbvh_pixels.cc
M   source/blender/editors/sculpt_paint/sculpt_paint_image.cc

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 084d30b271f..8af7cdf3eb4 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -24,8 +24,6 @@
 #include "pbvh_intern.h"
 #include "pbvh_uv_islands.hh"
 
-#include 
-
 namespace blender::bke::pbvh::pixels {
 
 /**
@@ -54,7 +52,7 @@ static float2 calc_barycentric_delta_x(const ImBuf 
*image_buffer,
   return calc_barycentric_delta(uvs, start_uv, end_uv);
 }
 
-int count_node_pixels(PBVHNode )
+static int count_node_pixels(PBVHNode )
 {
   if (!node.pixels.node_data) {
 return 0;
@@ -806,13 +804,7 @@ using namespace blender::bke::pbvh::pixels;
 void BKE_pbvh_build_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser 
*image_user)
 {
   if (update_pixels(pbvh, mesh, image, image_user)) {
-double time_ms = PIL_check_seconds_timer();
-
 split_pixel_nodes(pbvh, mesh, image, image_user);
-
-time_ms = PIL_check_seconds_timer() - time_ms;
-
-printf("Nodes split time: %.2fms\n", time_ms * 1000.0);
   }
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc 
b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index 4b76ff7f0c8..b376ab2c480 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -13,7 +13,7 @@
 #include "BLI_math_color_blend.h"
 #include "BLI_task.h"
 #ifdef DEBUG_PIXEL_NODES
-#  include "BLI_rand.h"
+#  include "BLI_hash.h"
 #endif
 
 #include "IMB_colormanagement.h"
@@ -349,11 +349,11 @@ static void do_paint_pixels(void *__restrict userdata,
   float brush_color[4];
 
 #ifdef DEBUG_PIXEL_NODES
-  RNG *rng = BLI_rng_new(POINTER_AS_UINT(node));
+  uint hash = BLI_hash_int(POINTER_AS_UINT(node));
 
-  brush_color[0] = BLI_rng_get_float(rng);
-  brush_color[1] = BLI_rng_get_float(rng);
-  brush_color[2] = BLI_rng_get_float(rng);
+  brush_color[0] = (float)(hash & 255) / 255.0f;
+  brush_color[1] = (float)((hash >> 8) & 255) / 255.0f;
+  brush_color[2] = (float)((hash >> 16) & 255) / 255.0f;
 #else
   copy_v3_v3(brush_color,
  ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, 
brush) :

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7cb31b649fe] temp-pbvh-split: Merge branch 'master' into temp-pbvh-split

2023-01-03 Thread Joseph Eagar
Commit: 7cb31b649fe8412c4991700e24d55baec896e8ae
Author: Joseph Eagar
Date:   Tue Jan 3 10:37:06 2023 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB7cb31b649fe8412c4991700e24d55baec896e8ae

Merge branch 'master' into temp-pbvh-split

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bddb691dfc8] temp-sculpt-roll-mapping: temp-sculpt-roll-mapping: Fix texture rotation bugs

2023-01-03 Thread Joseph Eagar
Commit: bddb691dfc8f968efd215b8fd4ee499de37d19c7
Author: Joseph Eagar
Date:   Tue Jan 3 10:34:20 2023 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rBbddb691dfc8f968efd215b8fd4ee499de37d19c7

temp-sculpt-roll-mapping: Fix texture rotation bugs

===

M   source/blender/editors/sculpt_paint/sculpt.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index a8de6aceadf..c9bde27572d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -2656,9 +2656,15 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
 }
   }
 
+  mul_v3_fl(point_3d, 1.0f / ss->cache->initial_radius);
+  float angle = mtex->rot;
+
+  float3 final;
+  rotate_v2_v2fl(final, point_3d, angle);
+
 #if 0 /* Write texture UVs to color attribute*/
   if (SCULPT_has_colors(ss)) {
-float color[4] = {point_3d[0], point_3d[1], 0.0f, 1.0f};
+float color[4] = {final[0], final[1], 0.0f, 1.0f};
 
 mul_v3_fl(color, 0.25f / ss->cache->initial_radius);
 color[0] -= floorf(color[0]);
@@ -2669,12 +2675,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
   }
 #endif
 
-  mul_v3_fl(point_3d, 1.0f / ss->cache->initial_radius);
-  float angle = mtex->rot - cache->special_rotation;
-  rotate_v2_v2fl(point_3d, point_3d, angle);
-
-
-  avg = paint_get_tex_pixel(mtex, point_3d[0], point_3d[1], ss->tex_pool, 
thread_id);
+  avg = paint_get_tex_pixel(mtex, final[0], final[1], ss->tex_pool, 
thread_id);
   avg += br->texture_sample_bias;
 }
 else {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a489b73a382] temp-sculpt-roll-mapping: Merge branch 'master' into temp-sculpt-roll-mapping

2023-01-03 Thread Joseph Eagar
Commit: a489b73a38254d7eed08ae0d352c273a19b7cc83
Author: Joseph Eagar
Date:   Tue Jan 3 09:18:36 2023 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rBa489b73a38254d7eed08ae0d352c273a19b7cc83

Merge branch 'master' into temp-sculpt-roll-mapping

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [98bdd08507b] temp-pbvh-split: Merge branch 'master' into temp-pbvh-split

2022-12-30 Thread Joseph Eagar
Commit: 98bdd08507b95e2e0cb4b9bac4fd0d3b28cbd207
Author: Joseph Eagar
Date:   Fri Dec 30 21:38:01 2022 -0800
Branches: temp-pbvh-split
https://developer.blender.org/rB98bdd08507b95e2e0cb4b9bac4fd0d3b28cbd207

Merge branch 'master' into temp-pbvh-split

===



===

diff --cc source/blender/blenkernel/intern/pbvh.c
index b012cb7c098,a6a362b1daf..1239a29b353
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -941,10 -1018,8 +1018,10 @@@ void BKE_pbvh_free(PBVH *pbvh
if (node->bm_other_verts) {
  BLI_gset_free(node->bm_other_verts, NULL);
}
 +}
  
 +if (node->flag & (PBVH_Leaf | PBVH_TexLeaf)) {
-   pbvh_pixels_free(node);
+   pbvh_node_pixels_free(node);
  }
}
  
diff --cc source/blender/blenkernel/intern/pbvh_intern.h
index 34eb969adac,ee728a698dd..444a28d077c
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@@ -148,10 -148,9 +148,11 @@@ struct PBVH 
int *prim_indices;
int totprim;
int totvert;
+   int faces_num; /* Do not use directly, use BKE_pbvh_num_faces. */
  
int leaf_limit;
 +  int pixel_leaf_limit;
 +  int depth_limit;
  
/* Mesh data */
struct Mesh *mesh;
diff --cc source/blender/blenkernel/intern/pbvh_pixels.cc
index a0c796168ed,e21103c9f19..084d30b271f
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@@ -22,10 -20,15 +22,11 @@@
  #include "bmesh.h"
  
  #include "pbvh_intern.h"
+ #include "pbvh_uv_islands.hh"
  
 -namespace blender::bke::pbvh::pixels {
 +#include 
  
 -/**
 - * During debugging this check could be enabled.
 - * It will write to each image pixel that is covered by the PBVH.
 - */
 -constexpr bool USE_WATERTIGHT_CHECK = false;
 +namespace blender::bke::pbvh::pixels {
  
  /**
   * Calculate the delta of two neighbor UV coordinates in the given image 
buffer.
@@@ -53,317 -56,13 +54,322 @@@ static float2 calc_barycentric_delta_x(
return calc_barycentric_delta(uvs, start_uv, end_uv);
  }
  
 +int count_node_pixels(PBVHNode )
 +{
 +  if (!node.pixels.node_data) {
 +return 0;
 +  }
 +
 +  NodeData  = BKE_pbvh_pixels_node_data_get(node);
 +
 +  int totpixel = 0;
 +
 +  for (UDIMTilePixels  : data.tiles) {
 +for (PackedPixelRow  : tile.pixel_rows) {
 +  totpixel += row.num_pixels;
 +}
 +  }
 +
 +  return totpixel;
 +}
 +
 +struct SplitQueueData {
 +  ThreadQueue *new_nodes;
 +  TaskPool *pool;
 +
 +  PBVH *pbvh;
 +  Mesh *mesh;
 +  Image *image;
 +  ImageUser *image_user;
 +};
 +
 +struct SplitNodePair {
 +  SplitNodePair *parent;
 +  PBVHNode node;
 +  int children_offset = 0;
 +  int depth = 0;
 +  int source_index = -1;
 +  bool is_old = false;
 +  SplitQueueData *tdata;
 +
 +  SplitNodePair(SplitNodePair *node_parent = nullptr) : parent(node_parent)
 +  {
 +memset(static_cast(), 0, sizeof(PBVHNode));
 +  }
 +};
 +
 +static void split_thread_job(TaskPool *__restrict pool, void *taskdata);
 +
 +static void split_pixel_node(PBVH *pbvh,
 + SplitNodePair *split,
 + Mesh *mesh,
 + Image *image,
 + ImageUser *image_user,
 + SplitQueueData *tdata)
 +{
 +  BB cb;
 +  PBVHNode *node = >node;
 +
 +  cb = node->vb;
 +
 +  if (count_node_pixels(*node) <= pbvh->pixel_leaf_limit || split->depth >= 
pbvh->depth_limit) {
 +BKE_pbvh_pixels_node_data_get(split->node).rebuild_undo_regions();
 +return;
 +  }
 +
 +  /* Find widest axis and its midpoint */
 +  const int axis = BB_widest_axis();
 +  const float mid = (cb.bmax[axis] + cb.bmin[axis]) * 0.5f;
 +
 +  node->flag = (PBVHNodeFlags)((int)node->flag & (int)~PBVH_TexLeaf);
 +
 +  SplitNodePair *split1 = MEM_new("split_pixel_node split1", 
split);
 +  SplitNodePair *split2 = MEM_new("split_pixel_node split1", 
split);
 +
 +  split1->depth = split->depth + 1;
 +  split2->depth = split->depth + 1;
 +
 +  PBVHNode *child1 = >node;
 +  PBVHNode *child2 = >node;
 +
 +  child1->flag = PBVH_TexLeaf;
 +  child2->flag = PBVH_TexLeaf;
 +
 +  child1->vb = cb;
 +  child1->vb.bmax[axis] = mid;
 +
 +  child2->vb = cb;
 +  child2->vb.bmin[axis] = mid;
 +
 +  NodeData  = BKE_pbvh_pixels_node_data_get(split->node);
 +
 +  NodeData *data1 = MEM_new(__func__);
 +  NodeData *data2 = MEM_new(__func__);
 +  child1->pixels.node_data = static_cast(data1);
 +  child2->pixels.node_data = static_cast(data2);
 +
-   data1->triangles = data.triangles;
-   data2->triangles = data.triangles;
++  data1->uv_primitives = data.uv_primitives;
++  data2->uv_primitives = data.uv_primitives;
 +
 +  dat

[Bf-blender-cvs] [2157115fa60] temp-sculpt-roll-mapping: temp-sculpt-roll-mapping: Fix merge errors

2022-12-30 Thread Joseph Eagar
Commit: 2157115fa606a864055dd40b572810ba0aed473a
Author: Joseph Eagar
Date:   Fri Dec 30 14:21:26 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB2157115fa606a864055dd40b572810ba0aed473a

temp-sculpt-roll-mapping: Fix merge errors

===

M   source/blender/editors/sculpt_paint/paint_stroke.cc
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/tools

===

diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc 
b/source/blender/editors/sculpt_paint/paint_stroke.cc
index 832a968d9f4..fdf8343c48b 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.cc
+++ b/source/blender/editors/sculpt_paint/paint_stroke.cc
@@ -552,7 +552,7 @@ static bool paint_stroke_use_scene_spacing(Brush *brush, 
ePaintMode mode)
   return false;
 }
 
-static bool paint_tool_raycast_original(Brush *brush, ePaintMode UNUSED(mode))
+static bool paint_tool_raycast_original(Brush *brush, ePaintMode /*mode*/)
 {
   return brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT);
 }
@@ -1329,7 +1329,7 @@ PaintStroke *paint_stroke_new(bContext *C,
   return stroke;
 }
 
-void paint_stroke_free(bContext *C, wmOperator *UNUSED(op), PaintStroke 
*stroke)
+void paint_stroke_free(bContext *C, wmOperator * /*op*/, PaintStroke *stroke)
 {
   RegionView3D *rv3d = CTX_wm_region_view3d(C);
   if (rv3d) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index 3c1cf4dbf7b..1e083c8a4a6 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -2660,7 +2660,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
   if (SCULPT_has_colors(ss)) {
 float color[4] = {point_3d[0], point_3d[1], 0.0f, 1.0f};
 
-#  if 1
+#  if 0
 for (int i = 0; i < 3; i++) {
   color[i] = tile_point[i] - std::floor(tile_point[i]);
 }
diff --git a/source/tools b/source/tools
index 9e33a8678a3..fdfa2fcb949 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 9e33a8678a3b97d2fdb833349657c3cc1c04811f
+Subproject commit fdfa2fcb9495d87571f2dfe2ae9fa0e032536600

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4faa5e30a55] temp-sculpt-roll-mapping: Merge remote-tracking branch 'origin' into temp-sculpt-roll-mapping

2022-12-30 Thread Joseph Eagar
Commit: 4faa5e30a5530d965228a7d6e32298f81c3c25ad
Author: Joseph Eagar
Date:   Fri Dec 30 14:22:01 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB4faa5e30a5530d965228a7d6e32298f81c3c25ad

Merge remote-tracking branch 'origin' into temp-sculpt-roll-mapping

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a2385335501] temp-sculpt-roll-mapping: temp-sculpt-roll-mapping: Visualization improvements

2022-12-30 Thread Joseph Eagar
Commit: a238533550195a4260d5a10d1228a27a632dee6c
Author: Joseph Eagar
Date:   Fri Dec 30 15:12:22 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rBa238533550195a4260d5a10d1228a27a632dee6c

temp-sculpt-roll-mapping: Visualization improvements

* Only draw curve line at start of stroke
* Fixed dash

===

M   source/blender/editors/sculpt_paint/paint_stroke.cc
M   source/blender/editors/sculpt_paint/sculpt.cc

===

diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc 
b/source/blender/editors/sculpt_paint/paint_stroke.cc
index fdf8343c48b..c45230118ae 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.cc
+++ b/source/blender/editors/sculpt_paint/paint_stroke.cc
@@ -49,7 +49,7 @@
 #include 
 
 //#define DEBUG_TIME
-#define DRAW_DEBUG_VIS
+//#define DRAW_DEBUG_VIS
 
 using blender::float2;
 using blender::float3;
@@ -271,34 +271,20 @@ static void paint_brush_make_spline(bContext *C, 
PaintStroke *stroke)
 
   float tmp1[2];
   float tmp2[2];
-#if 1
+
   sub_v2_v2v2(tmp1, d, a);
   sub_v2_v2v2(tmp2, a, b);
   interp_v2_v2v2(b, tmp1, tmp2, 0.5f);
   mul_v2_fl(b, scale);
-#else
-  zero_v2(b);
-#endif
 
   add_v2_v2(b, a);
 
-#if 1
   sub_v2_v2v2(tmp1, a, d);
   sub_v2_v2v2(tmp2, d, c);
   interp_v2_v2v2(c, tmp1, tmp2, 0.5f);
   mul_v2_fl(c, scale);
-#else
-  zero_v2(c);
-#endif
 
   add_v2_v2(c, d);
-#if 0
-printf("\n");
-printf("a: %.2f: %.2f\n", a[0], a[1]);
-printf("b: %.2f: %.2f\n", b[0], b[1]);
-printf("c: %.2f: %.2f\n", c[0], c[1]);
-printf("d: %.2f: %.2f\n", d[0], d[1]);
-#endif
 
   blender::CubicBezier bez(a, b, c, d);
   bez.update();
@@ -320,7 +306,6 @@ static void paint_brush_make_spline(bContext *C, 
PaintStroke *stroke)
   }
 }
 
-#ifdef DRAW_DEBUG_VIS
 static void paint_brush_cubic_vis(const bContext *C, ARegion *region, void 
*userdata)
 {
   PaintStroke *stroke = (PaintStroke *)userdata;
@@ -336,6 +321,12 @@ static void paint_brush_cubic_vis(const bContext *C, 
ARegion *region, void *user
 return;
   }
 
+#ifndef DRAW_DEBUG_VIS
+  if (spline->segments.size() == paint_stroke_max_points(nullptr, stroke)) {
+return;
+  }
+#endif
+
   GPU_line_smooth(false);
   GPU_depth_test(GPU_DEPTH_NONE);
   GPU_depth_mask(false);
@@ -352,7 +343,7 @@ static void paint_brush_cubic_vis(const bContext *C, 
ARegion *region, void *user
   immBegin(GPU_PRIM_LINE_STRIP, steps);
 
   float s = 0.0f;
-  float ds = 0.999 * spline->length / (steps - 1);
+  float ds = 0.9f * spline->length / (steps - 1);
 
   for (int i = 0; i < steps; i++, s += ds) {
 float3 co = spline->evaluate(s);
@@ -362,9 +353,10 @@ static void paint_brush_cubic_vis(const bContext *C, 
ARegion *region, void *user
   }
   immEnd();
 
-#  if 0  // control points
+/* Control points. */
+#if defined(DRAW_DEBUG_VIS) && 0
   immUniformColor4ub(255, 0, 0, 170);
-  int components = spline->components();
+  int components = spline->order();
 
   immBegin(GPU_PRIM_POINTS, spline->segments.size() * components);
 
@@ -378,9 +370,9 @@ static void paint_brush_cubic_vis(const bContext *C, 
ARegion *region, void *user
   }
 
   immEnd();
-#  endif
+#endif
 
-#  if 1  // inflection points
+#if defined(DRAW_DEBUG_VIS) && 1 /* Inflection points. */
   immUniformColor4ub(0, 255, 0, 100);
 
   immBegin(GPU_PRIM_POINTS, spline->inflection_points.size());
@@ -392,44 +384,13 @@ static void paint_brush_cubic_vis(const bContext *C, 
ARegion *region, void *user
   }
 
   immEnd();
-#  endif
-
-#  if 0
-  s = 0.0f;
-  ds = 0.1f;
-  steps = (int)floorf(spline->length / ds + 0.5f);
-
-  immUniformColor4ub(255, 0, 0, 170);
-  immBegin(GPU_PRIM_POINTS, steps);
-  for (int i = 0; i < steps; i++, s += ds) {
-float3 co = spline->evaluate(s);
-mul_v3_m4v3(co, ob->object_to_world, co);
-
-immVertex3fv(pos, co);
-  }
-
-  immEnd();
-
-  immUniformColor4ub(0, 255, 25, 55);
-  for (int is_points = 0; is_points < 2; is_points++) {
-immBegin(is_points ? GPU_PRIM_POINTS : GPU_PRIM_LINE_STRIP, 
stroke->num_points);
-for (int i = 0; i < stroke->num_points; i++) {
-  int idx = (i + stroke->cur_point) % stroke->num_points;
-  float3 co = stroke->points[idx].location;
-  mul_v3_m4v3(co, ob->object_to_world, co);
-
-  immVertex3fv(pos, co);
-}
-immEnd();
-  }
-#  endif
+#endif
 
   immUnbindProgram();
 
   GPU_blend(GPU_BLEND_NONE);
   GPU_line_smooth(false);
 }
-#endif
 
 /*** Cursors ***/
 static void paint_draw_smooth_cursor(bContext *C, int x, int y, void 
*customdata)
@@ -919,74 +880,80 @@ static void paint_brush_stroke_add_step(
 }
   }
 
-  /* Add to stroke */
-  if (add_step) {
-PaintStrokePoint *point;
-PaintStrokePoint temp;
+  paint_stroke_add_point(paint,
+   

[Bf-blender-cvs] [8931df291ac] temp-sculpt-roll-mapping: Merge branch 'master' into temp-sculpt-roll-mapping

2022-12-30 Thread Joseph Eagar
Commit: 8931df291ac88cc25ce3863d268f5ab908d33304
Author: Joseph Eagar
Date:   Thu Dec 29 12:25:05 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB8931df291ac88cc25ce3863d268f5ab908d33304

Merge branch 'master' into temp-sculpt-roll-mapping

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dce7917717c] master: Sculpt: Invert Expand behavior for masking consistency

2022-12-26 Thread Joseph Eagar
Commit: dce7917717cd9f07466651cdb9659a247f1a19ee
Author: Joseph Eagar
Date:   Mon Dec 26 21:46:33 2022 -0800
Branches: master
https://developer.blender.org/rBdce7917717cd9f07466651cdb9659a247f1a19ee

Sculpt: Invert Expand behavior for masking consistency

This patch makes sure that each of the expand keymap entries will use 
consistent "invert" and "use_mask_preserve" properties.

Based on previous discussions we decided to flip the default Mask Expand 
behavior.
This has multiple benefited:

- The mask creation is more consistent with other masking tools (Always add to 
existing mask. Mask selected areas)
- It's easier to use expanding for masking face sets (Snapping with `Ctrl`) or 
building a mask from repeated operations
- It's less likely to mask certain areas unintentionally (Loose mesh islands)
- If the current behavior is desired for an expand operation the user can use 
`E` & `F` in the modal keymap (Which is less often the case).

If we want to revisit the original design of inverted masking again in the 
future we should do this via {T97903}.

Reviewed By: Joseph Eagar
Differential Revision https://developer.blender.org/D16434
Ref D16434

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 7712f75fc64..d9e17302177 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5049,20 +5049,31 @@ def km_sculpt(params):
  {"properties": [("mode", 'SMOOTH')]}),
 # Expand
 ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True},
- {"properties": [("target", "MASK"), ("falloff_type", "GEODESIC"), 
("invert", True)]}),
+ {"properties": [
+("target", "MASK"),
+("falloff_type", "GEODESIC"),
+("invert", True),
+("use_auto_mask", True),
+("use_mask_preserve" , True)]}),
 ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True, 
"alt": True},
- {"properties": [("target", "MASK"), ("falloff_type", "NORMALS"), 
("invert", False)]}),
+ {"properties": [
+("target", "MASK"),
+("falloff_type", "NORMALS"),
+("invert", False),
+("use_mask_preserve" , True)]}),
 ("sculpt.expand", {"type": 'W', "value": 'PRESS', "shift": True},
  {"properties": [
  ("target", "FACE_SETS"),
  ("falloff_type", "GEODESIC"),
  ("invert", False),
+ ("use_mask_preserve" , False),
  ("use_modify_active", False)]}),
 ("sculpt.expand", {"type": 'W', "value": 'PRESS', "shift": True, 
"alt": True},
  {"properties": [
  ("target", "FACE_SETS"),
  ("falloff_type", "BOUNDARY_FACE_SET"),
  ("invert", False),
+ ("use_mask_preserve" , False),
  ("use_modify_active", True),
  ]}),
 # Partial Visibility Show/hide

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a9cb66b856e] master: Sculpt: Fix expand invert mode

2022-12-26 Thread Joseph Eagar
Commit: a9cb66b856e80d0542a9ad3fec0b0fb47d28f805
Author: Joseph Eagar
Date:   Mon Dec 26 21:43:08 2022 -0800
Branches: master
https://developer.blender.org/rBa9cb66b856e80d0542a9ad3fec0b0fb47d28f805

Sculpt: Fix expand invert mode

* Invert mode now properly subtracts from mask
* Added an "auto-create" mode to automatically
  fill in the mask if everything is unmasked.

===

M   source/blender/editors/sculpt_paint/sculpt_expand.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index a8496712c41..b90488f6df4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -1260,7 +1260,12 @@ static void sculpt_expand_mask_update_task_cb(void 
*__restrict userdata,
 }
 
 if (expand_cache->preserve) {
-  new_mask = max_ff(new_mask, expand_cache->original_mask[vd.index]);
+  if (expand_cache->invert) {
+new_mask = min_ff(new_mask, expand_cache->original_mask[vd.index]);
+  }
+  else {
+new_mask = max_ff(new_mask, expand_cache->original_mask[vd.index]);
+  }
 }
 
 if (new_mask == initial_mask) {
@@ -2033,6 +2038,7 @@ static void 
sculpt_expand_cache_initial_config_set(bContext *C,
   /* RNA properties. */
   expand_cache->invert = RNA_boolean_get(op->ptr, "invert");
   expand_cache->preserve = RNA_boolean_get(op->ptr, "use_mask_preserve");
+  expand_cache->auto_mask = RNA_boolean_get(op->ptr, "use_auto_mask");
   expand_cache->falloff_gradient = RNA_boolean_get(op->ptr, 
"use_falloff_gradient");
   expand_cache->target = RNA_enum_get(op->ptr, "target");
   expand_cache->modify_active_face_set = RNA_boolean_get(op->ptr, 
"use_modify_active");
@@ -2115,6 +2121,41 @@ static int sculpt_expand_invoke(bContext *C, wmOperator 
*op, const wmEvent *even
   if (ss->expand_cache->target == SCULPT_EXPAND_TARGET_MASK) {
 MultiresModifierData *mmd = BKE_sculpt_multires_active(ss->scene, ob);
 BKE_sculpt_mask_layers_ensure(depsgraph, CTX_data_main(C), ob, mmd);
+
+if (RNA_boolean_get(op->ptr, "use_auto_mask")) {
+  int verts_num = SCULPT_vertex_count_get(ss);
+  bool ok = true;
+
+  for (int i = 0; i < verts_num; i++) {
+PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
+
+if (SCULPT_vertex_mask_get(ss, vertex) != 0.0f) {
+  ok = false;
+  break;
+}
+  }
+
+  if (ok) {
+int nodes_num;
+PBVHNode **nodes;
+
+/* TODO: implement SCULPT_vertex_mask_set and use it here. */
+
+BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, , _num);
+for (int i = 0; i < nodes_num; i++) {
+  PBVHVertexIter vd;
+  bool update = false;
+
+  BKE_pbvh_vertex_iter_begin (ss->pbvh, nodes[i], vd, 
PBVH_ITER_UNIQUE) {
+*vd.mask = 1.0f;
+update = true;
+  }
+  BKE_pbvh_vertex_iter_end;
+
+  BKE_pbvh_node_mark_update_mask(nodes[i]);
+}
+  }
+}
   }
 
   BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true, needs_colors);
@@ -2338,4 +2379,9 @@ void SCULPT_OT_expand(wmOperatorType *ot)
  "than this value, the falloff will be set to 
spherical when moving",
  0,
  100);
+  ot->prop = RNA_def_boolean(ot->srna,
+ "use_auto_mask",
+ false,
+ "Auto Create",
+ "Fill in mask if nothing is already masked.");
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index e660e8fa8ac..ae23983e6c9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -795,6 +795,9 @@ typedef struct ExpandCache {
* after finishing the operation. */
   bool reposition_pivot;
 
+  /* If nothing is masked set mask of every vertex to 0. */
+  bool auto_mask;
+
   /* Color target data type related data. */
   float fill_color[4];
   short blend_mode;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [204de8c6db6] master: Sculpt: fix T103156: Scale square brush uvs by sqrt2.

2022-12-26 Thread Joseph Eagar
Commit: 204de8c6db646fd08b393a17a3b25a5de76611e4
Author: Joseph Eagar
Date:   Mon Dec 26 21:03:26 2022 -0800
Branches: master
https://developer.blender.org/rB204de8c6db646fd08b393a17a3b25a5de76611e4

Sculpt: fix T103156: Scale square brush uvs by sqrt2.

Scale texture coordiantes for square brushes by sqrt2,
proportionally to how square they are (how close
tip_roundness is to zero).

Note: this is done in `calc_brush_local_mat()`, the
result of which appears to be used exclusively for
texture mapping.

===

M   source/blender/editors/sculpt_paint/sculpt.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index 9cb30c9f83d..899044145d3 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -2908,8 +2908,15 @@ static void calc_brush_local_mat(const MTex *mtex, 
Object *ob, float local_mat[4
   copy_v3_v3(mat[3], cache->location);
 
   /* Scale by brush radius. */
+  float radius = cache->radius;
+
+  /* Square tips should scale by square root of 2. */
+  if (sculpt_tool_has_cube_tip(cache->brush->sculpt_tool)) {
+radius += (radius * M_SQRT2 - radius) * (1.0f - 
cache->brush->tip_roundness);
+  }
+
   normalize_m4(mat);
-  scale_m4_fl(scale, cache->radius);
+  scale_m4_fl(scale, radius);
   mul_m4_m4m4(tmat, mat, scale);
 
   /* Return inverse (for converting from model-space coords to local area 
coords). */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f803a0a95b6] master: Sculpt: Fix T103341: Move sculpt overlay flags to View3DOverlay.flag

2022-12-22 Thread Joseph Eagar
Commit: f803a0a95b6769145528914d21910c10ce24c861
Author: Joseph Eagar
Date:   Thu Dec 22 16:52:44 2022 -0800
Branches: master
https://developer.blender.org/rBf803a0a95b6769145528914d21910c10ce24c861

Sculpt: Fix T103341: Move sculpt overlay flags to View3DOverlay.flag

"Show mask" and "Show face sets" were being stored in
`Sculpt`, yet their opacities are in `View3dOverlay`.
Now `View3DOverlay` has the flags too.

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenloader/intern/versioning_300.cc
M   source/blender/draw/engines/overlay/overlay_engine.cc
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesdna/DNA_view3d_defaults.h
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_sculpt_paint.c
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 263a323bb63..4feb92e71df 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6741,15 +6741,15 @@ class VIEW3D_PT_overlay_sculpt(Panel):
 overlay = view.overlay
 
 row = layout.row(align=True)
-row.prop(sculpt, "show_mask", text="")
+row.prop(overlay, "sculpt_show_mask", text="")
 sub = row.row()
-sub.active = sculpt.show_mask
+sub.active = overlay.sculpt_show_mask
 sub.prop(overlay, "sculpt_mode_mask_opacity", text="Mask")
 
 row = layout.row(align=True)
-row.prop(sculpt, "show_face_sets", text="")
+row.prop(overlay, "sculpt_show_face_sets", text="")
 sub = row.row()
-sub.active = sculpt.show_face_sets
+sub.active = overlay.sculpt_show_face_sets
 row.prop(overlay, "sculpt_mode_face_sets_opacity", text="Face Sets")
 
 
diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 7c241a4fa12..2ddda93c93b 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 5
+#define BLENDER_FILE_SUBVERSION 6
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 5c878486c68..ba631bd92a0 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -632,8 +632,6 @@ typedef struct SculptSession {
 
   /* PBVH acceleration structure */
   struct PBVH *pbvh;
-  bool show_mask;
-  bool show_face_sets;
 
   /* Painting on deformed mesh */
   bool deform_modifiers_active; /* Object is deformed with some modifiers. */
diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index ebbe3c2c4fa..acc6a32b0eb 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -1675,8 +1675,6 @@ static void sculpt_update_object(
   ss->depsgraph = depsgraph;
 
   ss->deform_modifiers_active = sculpt_modifiers_active(scene, sd, ob);
-  ss->show_mask = (sd->flags & SCULPT_HIDE_MASK) == 0;
-  ss->show_face_sets = (sd->flags & SCULPT_HIDE_FACE_SETS) == 0;
 
   ss->building_vp_handle = false;
 
@@ -1775,9 +1773,6 @@ static void sculpt_update_object(
 }
   }
 
-  pbvh_show_mask_set(ss->pbvh, ss->show_mask);
-  pbvh_show_face_sets_set(ss->pbvh, ss->show_face_sets);
-
   if (ss->deform_modifiers_active) {
 /* Painting doesn't need crazyspace, use already evaluated mesh 
coordinates if possible. */
 bool used_me_eval = false;
@@ -2173,8 +2168,6 @@ static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
ob->sculpt->bm_log,

ob->sculpt->attrs.dyntopo_node_id_vertex->bmesh_cd_offset,

ob->sculpt->attrs.dyntopo_node_id_face->bmesh_cd_offset);
-  pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
-  pbvh_show_face_sets_set(pbvh, false);
   return pbvh;
 }
 
@@ -2207,9 +2200,6 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, 
Mesh *me_eval_de

[Bf-blender-cvs] [48f0d5de544] blender-v3.4-release: Fix T103261: Undo after mask extract doesn't restore active object

2022-12-19 Thread Joseph Eagar
Commit: 48f0d5de544a0cc70ab3324f94f44dde7b7a4c21
Author: Joseph Eagar
Date:   Sun Dec 18 07:50:35 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB48f0d5de544a0cc70ab3324f94f44dde7b7a4c21

Fix T103261: Undo after mask extract doesn't restore active object

===

M   source/blender/editors/mesh/editmesh_mask_extract.c

===

diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c 
b/source/blender/editors/mesh/editmesh_mask_extract.c
index 070f748c78e..bb4d745a677 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -37,6 +37,7 @@
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_sculpt.h"
+#include "ED_undo.h"
 #include "ED_view3d.h"
 
 #include "bmesh_tools.h"
@@ -287,6 +288,16 @@ static int paint_mask_extract_exec(bContext *C, wmOperator 
*op)
   params.add_boundary_loop = RNA_boolean_get(op->ptr, "add_boundary_loop");
   params.apply_shrinkwrap = RNA_boolean_get(op->ptr, "apply_shrinkwrap");
   params.add_solidify = RNA_boolean_get(op->ptr, "add_solidify");
+
+  /* Push an undo step prior to extraction.
+   * Note: A second push happens after the operator due to
+   * the OPTYPE_UNDO flag; having an initial undo step here
+   * is just needed to preserve the active object pointer.
+   * 
+   * Fixes T103261.
+   */
+  ED_undo_push_op(C, op);
+
   return geometry_extract_apply(C, op, geometry_extract_tag_masked_faces, 
);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8666791b2e7] master: Fix T103261: Undo after mask extract doesn't restore active object

2022-12-18 Thread Joseph Eagar
Commit: 8666791b2e7542913e824a34eed2e579381377b0
Author: Joseph Eagar
Date:   Sun Dec 18 07:50:35 2022 -0800
Branches: master
https://developer.blender.org/rB8666791b2e7542913e824a34eed2e579381377b0

Fix T103261: Undo after mask extract doesn't restore active object

===

M   source/blender/editors/mesh/editmesh_mask_extract.c

===

diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c 
b/source/blender/editors/mesh/editmesh_mask_extract.c
index 070f748c78e..bb4d745a677 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -37,6 +37,7 @@
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_sculpt.h"
+#include "ED_undo.h"
 #include "ED_view3d.h"
 
 #include "bmesh_tools.h"
@@ -287,6 +288,16 @@ static int paint_mask_extract_exec(bContext *C, wmOperator 
*op)
   params.add_boundary_loop = RNA_boolean_get(op->ptr, "add_boundary_loop");
   params.apply_shrinkwrap = RNA_boolean_get(op->ptr, "apply_shrinkwrap");
   params.add_solidify = RNA_boolean_get(op->ptr, "add_solidify");
+
+  /* Push an undo step prior to extraction.
+   * Note: A second push happens after the operator due to
+   * the OPTYPE_UNDO flag; having an initial undo step here
+   * is just needed to preserve the active object pointer.
+   * 
+   * Fixes T103261.
+   */
+  ED_undo_push_op(C, op);
+
   return geometry_extract_apply(C, op, geometry_extract_tag_masked_faces, 
);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [17e266cd55e] master: Cleanup: make paint_init_pivot an api method.

2022-12-18 Thread Joseph Eagar
Commit: 17e266cd55ea58bd82094c3874254748a6d199be
Author: Joseph Eagar
Date:   Sun Dec 18 07:20:12 2022 -0800
Branches: master
https://developer.blender.org/rB17e266cd55ea58bd82094c3874254748a6d199be

Cleanup: make paint_init_pivot an api method.

I had forgotten about curves sculpt mode when I wrote
this function. It just initializes the viewport
pivot point to the evaluated object bounding box.
Should be used inside the mode entry function.

===

M   source/blender/editors/sculpt_paint/paint_image.cc
M   source/blender/editors/sculpt_paint/paint_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/paint_image.cc 
b/source/blender/editors/sculpt_paint/paint_image.cc
index 1ab364c4877..a57287b924b 100644
--- a/source/blender/editors/sculpt_paint/paint_image.cc
+++ b/source/blender/editors/sculpt_paint/paint_image.cc
@@ -759,7 +759,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
 
 / texture paint toggle operator /
 
-static void paint_init_pivot(Object *ob, Scene *scene)
+void paint_init_pivot(Object *ob, Scene *scene)
 {
   UnifiedPaintSettings *ups = >toolsettings->unified_paint_settings;
 
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h 
b/source/blender/editors/sculpt_paint/paint_intern.h
index 8a2c6955679..a3449e52225 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -517,6 +517,9 @@ enum eBlurKernelType;
 BlurKernel *paint_new_blur_kernel(struct Brush *br, bool proj);
 void paint_delete_blur_kernel(BlurKernel *);
 
+/* Initialize viewport pivot from evaulated bounding box center of ob. */
+void paint_init_pivot(struct Object *ob, struct Scene *scene);
+
 /* paint curve defines */
 #define PAINT_CURVE_NUM_SEGMENTS 40

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0beb358a69d] master: Fix T103198: Missing bounds check for material_index attr in texpaint

2022-12-18 Thread Joseph Eagar
Commit: 0beb358a69d0c9c5436995c2945eadbae95e8965
Author: Joseph Eagar
Date:   Sun Dec 18 07:08:57 2022 -0800
Branches: master
https://developer.blender.org/rB0beb358a69d0c9c5436995c2945eadbae95e8965

Fix T103198: Missing bounds check for material_index attr in texpaint

Texpaint now bounds checks material indices when looking up
materials, in case the user has corrupted the material_index
attribute somehow.  We may wish to report this to the user
somehow on entering texture paint mode.

===

M   source/blender/editors/sculpt_paint/paint_image_proj.cc

===

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc 
b/source/blender/editors/sculpt_paint/paint_image_proj.cc
index 4eeeb760b23..7c7e9fc 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.cc
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc
@@ -545,10 +545,20 @@ static int project_paint_face_paint_tile(Image *ima, 
const float *uv)
   return 1001 + 10 * ty + tx;
 }
 
+static Material *tex_get_material(const ProjPaintState *ps, int poly_i)
+{
+  int mat_nr = ps->material_indices == nullptr ? 0 : 
ps->material_indices[poly_i];
+  if (mat_nr >= 0 && mat_nr <= ps->ob->totcol) {
+return ps->mat_array[mat_nr];
+  }
+
+  return nullptr;
+}
+
 static TexPaintSlot *project_paint_face_paint_slot(const ProjPaintState *ps, 
int tri_index)
 {
   const int poly_i = ps->mlooptri_eval[tri_index].poly;
-  Material *ma = ps->mat_array[ps->material_indices == nullptr ? 0 : 
ps->material_indices[poly_i]];
+  Material *ma = tex_get_material(ps, poly_i);
   return ma ? ma->texpaintslot + ma->paint_active_slot : nullptr;
 }
 
@@ -559,7 +569,7 @@ static Image *project_paint_face_paint_image(const 
ProjPaintState *ps, int tri_i
   }
 
   const int poly_i = ps->mlooptri_eval[tri_index].poly;
-  Material *ma = ps->mat_array[ps->material_indices == nullptr ? 0 : 
ps->material_indices[poly_i]];
+  Material *ma = tex_get_material(ps, poly_i);
   TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_active_slot : nullptr;
   return slot ? slot->ima : ps->canvas_ima;
 }
@@ -567,14 +577,14 @@ static Image *project_paint_face_paint_image(const 
ProjPaintState *ps, int tri_i
 static TexPaintSlot *project_paint_face_clone_slot(const ProjPaintState *ps, 
int tri_index)
 {
   const int poly_i = ps->mlooptri_eval[tri_index].poly;
-  Material *ma = ps->mat_array[ps->material_indices == nullptr ? 0 : 
ps->material_indices[poly_i]];
+  Material *ma = tex_get_material(ps, poly_i);
   return ma ? ma->texpaintslot + ma->paint_clone_slot : nullptr;
 }
 
 static Image *project_paint_face_clone_image(const ProjPaintState *ps, int 
tri_index)
 {
   const int poly_i = ps->mlooptri_eval[tri_index].poly;
-  Material *ma = ps->mat_array[ps->material_indices == nullptr ? 0 : 
ps->material_indices[poly_i]];
+  Material *ma = tex_get_material(ps, poly_i);
   TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_clone_slot : nullptr;
   return slot ? slot->ima : ps->clone_ima;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d15324f1c38] temp-sculpt-roll-mapping: temp-sculpt-roll-mapping: update more comments

2022-12-18 Thread Joseph Eagar
Commit: d15324f1c38f10945214bdd29d3b3e167ff8a699
Author: Joseph Eagar
Date:   Sun Dec 18 05:45:37 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rBd15324f1c38f10945214bdd29d3b3e167ff8a699

temp-sculpt-roll-mapping: update more comments

===

M   source/blender/blenlib/BLI_even_spline.hh
M   source/blender/editors/sculpt_paint/paint_stroke.cc
M   source/tools

===

diff --git a/source/blender/blenlib/BLI_even_spline.hh 
b/source/blender/blenlib/BLI_even_spline.hh
index 5ac4bda019c..dea44756ca4 100644
--- a/source/blender/blenlib/BLI_even_spline.hh
+++ b/source/blender/blenlib/BLI_even_spline.hh
@@ -55,26 +55,6 @@ namespace blender {
 
 /** Cubic curves */
 
-/*
-comment: Reduce algebra script;
-
-comment: Build bernstein polynomials from linear combination;
-procedure bez(a, b);
-  a + (b - a) * t;
-
-lin := bez(k1, k2);
-quad := bez(lin, sub(k2=k3, k1=k2, lin));
-cubic := bez(quad, sub(k3=k4, k2=k3, k1=k2, quad));
-
-dcubic := df(cubic, t);
-
-comment: display final equations in fortran;
-on fort;
-cubic;
-dcubic;
-off fort;
-
-*/
 template class CubicBezier 
{
   using Vector = vec_base;
 
@@ -166,6 +146,7 @@ template class CubicBezier {
 
   Float length;
 
+  /* Update arc length -> parameterization table. */
   void update()
   {
 Float t = 0.0, dt = 1.0 / (Float)table_size;
@@ -272,6 +253,7 @@ template class CubicBezier {
 if (exact) {
   Float len = sqrt(_dot(r, r));
 
+  /* Use FLT_EPSILON here? */
   if (len > 0.1) {
 r = r / len;
   }
@@ -312,6 +294,7 @@ template class CubicBezier {
 comment: arc length second derivative;
 
 comment: build arc length from abstract derivative operators;
+
 operator x, y, z, dx, dy, dz, d2x, d2y, d2z;
 
 forall t let df(x(t), t) = dx(t);
@@ -380,6 +363,7 @@ template class CubicBezier {
 return sqrt(_dot(dv2, dv2));
   }
 
+  /* First derivative of curvature. */
   Float dcurvature(Float s)
   {
 const Float ds = 0.0001;
@@ -404,23 +388,27 @@ template class CubicBezier {
   Float *_arc_to_t;
   bool deleted = false;
 
+  /* Bernstein/bezier polynomial.*/
   Float cubic(Float k1, Float k2, Float k3, Float k4, Float t)
   {
 return -(((3.0 * (t - 1.0) * k3 - k4 * t) * t - 3.0 * (t - 1.0) * (t - 
1.0) * k2) * t +
  (t - 1) * (t - 1) * (t - 1) * k1);
   }
 
+  /* First derivative. */
   Float dcubic(Float k1, Float k2, Float k3, Float k4, Float t)
   {
 return -3.0 * ((t - 1.0) * (t - 1.0) * k1 - k4 * t * t + (3.0 * t - 2.0) * 
k3 * t -
(3.0 * t - 1.0) * (t - 1.0) * k2);
   }
 
+  /* Second derivative. */
   Float d2cubic(Float k1, Float k2, Float k3, Float k4, Float t)
   {
 return -6.0 * (k1 * t - k1 - 3.0 * k2 * t + 2.0 * k2 + 3.0 * k3 * t - k3 - 
k4 * t);
   }
 
+  /* Inlinable dot product. */
   Float _dot(Vector a, Vector b)
   {
 Float sum = 0.0;
@@ -440,6 +428,9 @@ template class CubicBezier {
 return s;
   }
 
+  /* Convert a unit distance along the curve to parameterization t
+   * using a linearly-interpolated lookup table.
+   */
   Float arc_to_t(Float s)
   {
 if (length == 0.0) {
@@ -537,6 +528,9 @@ class EvenSpline {
 update_inflection_points();
   }
 
+  /* Find inflection points, these are used to speed
+   * up closest point test.
+   */
   void update_inflection_points()
   {
 inflection_points.clear();
@@ -562,7 +556,8 @@ class EvenSpline {
 inflection_points.append(1.0);
   }
 
-  int components() noexcept
+  /* Number of control points inside a curve segment. */
+  int order() noexcept
   {
 return sizeof(segments[0].bezier.ps) / sizeof(*segments[0].bezier.ps);
   }
@@ -574,7 +569,7 @@ class EvenSpline {
 }
 
 if (s >= length) {
-  return segments[segments.size() - 1].bezier.ps[components() - 1];
+  return segments[segments.size() - 1].bezier.ps[order() - 1];
 }
 
 Segment *seg = get_segment(s);
@@ -594,6 +589,7 @@ class EvenSpline {
 return seg->bezier.derivative(s - seg->start, exact);
   }
 
+  /* Second derivative. */
   Vector derivative2(Float s)
   {
 if (segments.size() == 0) {
@@ -618,6 +614,7 @@ class EvenSpline {
 return seg->bezier.curvature(s - seg->start);
   }
 
+  /* First derivative of curvature. */
   Float dcurvature(Float s)
   {
 if (segments.size() == 0) {
@@ -630,7 +627,8 @@ class EvenSpline {
 return seg->bezier.dcurvature(s - seg->start);
   }
 
-  /* Find the closest point on the spline.  Uses a bisecting root finding 
approach..
+  /* Find the closest point on the spline.  Uses a bisecting root
+   * finding approach.
*/
   Vector closest_point(const Vector p, Float _s, Vector _tan, Float _dis)
   {
@@ -652,10 +650,10 @@ class EvenSpline {
 
   b = evaluate(s);
 
-  /* The extra false parameter means we don't
-   * need 

[Bf-blender-cvs] [e9b573e11db] temp-sculpt-roll-mapping: temp-sculpt-roll-mapping: Cleanup some comments

2022-12-18 Thread Joseph Eagar
Commit: e9b573e11dbc349bd3b58bd6b800f8b6adaca866
Author: Joseph Eagar
Date:   Sat Dec 17 20:58:10 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rBe9b573e11dbc349bd3b58bd6b800f8b6adaca866

temp-sculpt-roll-mapping: Cleanup some comments

===

M   source/blender/blenlib/BLI_even_spline.hh

===

diff --git a/source/blender/blenlib/BLI_even_spline.hh 
b/source/blender/blenlib/BLI_even_spline.hh
index 4b98d51db37..5ac4bda019c 100644
--- a/source/blender/blenlib/BLI_even_spline.hh
+++ b/source/blender/blenlib/BLI_even_spline.hh
@@ -58,9 +58,7 @@ namespace blender {
 /*
 comment: Reduce algebra script;
 
-on factor;
-off period;
-
+comment: Build bernstein polynomials from linear combination;
 procedure bez(a, b);
   a + (b - a) * t;
 
@@ -70,6 +68,7 @@ cubic := bez(quad, sub(k3=k4, k2=k3, k1=k2, quad));
 
 dcubic := df(cubic, t);
 
+comment: display final equations in fortran;
 on fort;
 cubic;
 dcubic;
@@ -140,7 +139,6 @@ template class CubicBezier {
 return *this;
   }
 
-#if 1
   CubicBezier(CubicBezier &)
   {
 *this = b;
@@ -165,7 +163,6 @@ template class CubicBezier {
 
 return *this;
   }
-#endif
 
   Float length;
 
@@ -311,11 +308,12 @@ template class CubicBezier {
 Float dy = dcubic(ps[0][1], ps[1][1], ps[2][1], ps[3][1], t);
 Float d2y = d2cubic(ps[0][1], ps[1][1], ps[2][1], ps[3][1], t);
 
-/*
+/* reduce algebra script
 comment: arc length second derivative;
 
-comment: build arc length version from abstract derivative operators;
+comment: build arc length from abstract derivative operators;
 operator x, y, z, dx, dy, dz, d2x, d2y, d2z;
+
 forall t let df(x(t), t) = dx(t);
 forall t let df(y(t), t) = dy(t);
 forall t let df(z(t), t) = dz(t);
@@ -328,6 +326,7 @@ template class CubicBezier {
 comment: 2d case;
 dlen := sqrt(df(x(t), t)**2 + df(y(t), t)**2);
 
+comment: final derivatives;
 df(df(x(t), t) / dlen, t);
 df(df(y(t), t) / dlen, t);
 
@@ -335,15 +334,13 @@ template class CubicBezier {
 dlen := sqrt(df(x(t), t)**2 + df(y(t), t)**2 + df(z(t), t)**2);
 
 comment: final derivatives;
-
 df(df(x(t), t) / dlen, t);
 df(df(y(t), t) / dlen, t);
 df(df(z(t), t) / dlen, t);
-
 */
+
 if constexpr (axes == 2) {
   /* Basically the 2d perpidicular normalized tangent multiplied by the 
curvature. */
-
   Float div = sqrt(dx * dx + dy * dy) * (dx * dx + dy * dy);
 
   r[0] = ((d2x * dy - d2y * dx) * dy) / div;
@@ -633,9 +630,7 @@ class EvenSpline {
 return seg->bezier.dcurvature(s - seg->start);
   }
 
-  /* Find the closest point on the spline.  Uses a bisecting root finding 
approach.
-   * Note: in thoery we could split the spline into quadratic segments and 
solve
-   * for the closest point directy.
+  /* Find the closest point on the spline.  Uses a bisecting root finding 
approach..
*/
   Vector closest_point(const Vector p, Float _s, Vector _tan, Float _dis)
   {
@@ -656,7 +651,11 @@ class EvenSpline {
   Float ds = s - inflection_points[i - 1];
 
   b = evaluate(s);
-  dvb = derivative(s, false); /* False means we don't need fully 
normalized derivative. */
+
+  /* The extra false parameter means we don't
+   * need fully normalized derivative.
+   */
+  dvb = derivative(s, false); 
 
   if (i == 0) {
 continue;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [90b633967b7] temp-sculpt-roll-mapping: Merge remote-tracking branch 'origin' into temp-sculpt-roll-mapping

2022-12-18 Thread Joseph Eagar
Commit: 90b633967b726d940935ea9577299daf1a4882d9
Author: Joseph Eagar
Date:   Sat Dec 17 20:58:31 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rB90b633967b726d940935ea9577299daf1a4882d9

Merge remote-tracking branch 'origin' into temp-sculpt-roll-mapping

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ce56101897d] temp-sculpt-roll-mapping: Merge branch 'master' into temp-sculpt-roll-mapping

2022-12-15 Thread Joseph Eagar
Commit: ce56101897d55d453096ed545e14e29ce4c74506
Author: Joseph Eagar
Date:   Thu Dec 15 17:56:57 2022 -0800
Branches: temp-sculpt-roll-mapping
https://developer.blender.org/rBce56101897d55d453096ed545e14e29ce4c74506

Merge branch 'master' into temp-sculpt-roll-mapping

===



===

diff --cc source/blender/editors/sculpt_paint/CMakeLists.txt
index 94a067845d9,d1a80e3e068..633abe8f5c2
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@@ -50,10 -50,10 +50,10 @@@ set(SR
paint_image_2d.c
paint_image_2d_curve_mask.cc
paint_image_ops_paint.cc
-   paint_image_proj.c
+   paint_image_proj.cc
paint_mask.c
paint_ops.c
 -  paint_stroke.c
 +  paint_stroke.cc
paint_utils.c
paint_vertex.cc
paint_vertex_color_ops.cc

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9f1d7d930d0] master: Cleanup: fix comile error from last commit

2022-12-13 Thread Joseph Eagar
Commit: 9f1d7d930d0e12ab23ed620abcc617bb9d9ec307
Author: Joseph Eagar
Date:   Tue Dec 13 13:58:27 2022 -0800
Branches: master
https://developer.blender.org/rB9f1d7d930d0e12ab23ed620abcc617bb9d9ec307

Cleanup: fix comile error from last commit

===

M   source/blender/blenkernel/intern/paint.cc

===

diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 718ec5318ac..e6d61ddcdd3 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -75,7 +75,7 @@ static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob,
const SculptAttributeParams 
*params,
PBVHType pbvhtype,
bool flat_array_for_bmesh);
-void sculptsession_bmesh_add_layers(Object *ob);
+static void sculptsession_bmesh_add_layers(Object *ob);
 
 using blender::MutableSpan;
 using blender::Span;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6f9cfb037a8] master: Sculpt: Fix T102991: Multires fast navigate not implemented

2022-12-13 Thread Joseph Eagar
Commit: 6f9cfb037a8e5dbd8707877d0a9539ae8d358656
Author: Joseph Eagar
Date:   Tue Dec 13 12:24:24 2022 -0800
Branches: master
https://developer.blender.org/rB6f9cfb037a8e5dbd8707877d0a9539ae8d358656

Sculpt: Fix T102991: Multires fast navigate not implemented

PBVH draw code now builds coarse triangle index buffers
for multires. Note that the coarse grids can be at any
multires depth but is currently hardcoded to 1.

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/draw/DRW_pbvh.h
M   source/blender/draw/intern/draw_manager_data.cc
M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/gpu/intern/gpu_shader_builder_stubs.cc

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 139b6ff6bbe..8f66d552387 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -414,7 +414,8 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, struct 
Mesh *me);
 int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
   const int *grid_indices,
   int totgrid,
-  int gridsize);
+  int gridsize,
+  int display_gridsize);
 
 /**
  * Multi-res level, only valid for type == #PBVH_GRIDS.
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 98e21c685a2..35c2c660fd2 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -383,7 +383,8 @@ static void update_vb(PBVH *pbvh, PBVHNode *node, BBC 
*prim_bbc, int offset, int
 int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
   const int *grid_indices,
   int totgrid,
-  int gridsize)
+  int gridsize,
+  int display_gridsize)
 {
   const int gridarea = (gridsize - 1) * (gridsize - 1);
   int totquad = 0;
@@ -391,13 +392,18 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
   /* grid hidden layer is present, so have to check each grid for
* visibility */
 
+  int depth1 = (int)(log2((double)gridsize - 1.0) + DBL_EPSILON);
+  int depth2 = (int)(log2((double)display_gridsize - 1.0) + DBL_EPSILON);
+
+  int skip = depth2 < depth1 ? 1 << (depth1 - depth2 - 1) : 1;
+
   for (int i = 0; i < totgrid; i++) {
 const BLI_bitmap *gh = grid_hidden[grid_indices[i]];
 
 if (gh) {
   /* grid hidden are present, have to check each element */
-  for (int y = 0; y < gridsize - 1; y++) {
-for (int x = 0; x < gridsize - 1; x++) {
+  for (int y = 0; y < gridsize - skip; y += skip) {
+for (int x = 0; x < gridsize - skip; x += skip) {
   if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) {
 totquad++;
   }
@@ -414,8 +420,11 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
 
 static void build_grid_leaf_node(PBVH *pbvh, PBVHNode *node)
 {
-  int totquads = BKE_pbvh_count_grid_quads(
-  pbvh->grid_hidden, node->prim_indices, node->totprim, 
pbvh->gridkey.grid_size);
+  int totquads = BKE_pbvh_count_grid_quads(pbvh->grid_hidden,
+   node->prim_indices,
+   node->totprim,
+   pbvh->gridkey.grid_size,
+   pbvh->gridkey.grid_size);
   BKE_pbvh_node_fully_hidden_set(node, (totquads == 0));
   BKE_pbvh_node_mark_rebuild_draw(node);
 }
diff --git a/source/blender/draw/DRW_pbvh.h b/source/blender/draw/DRW_pbvh.h
index ffd4b92d87b..6f9daac0a35 100644
--- a/source/blender/draw/DRW_pbvh.h
+++ b/source/blender/draw/DRW_pbvh.h
@@ -86,12 +86,14 @@ struct GPUBatch *DRW_pbvh_tris_get(PBVHBatches *batches,
struct PBVHAttrReq *attrs,
int attrs_num,
PBVH_GPU_Args *args,
-   int *r_prim_count);
+   int *r_prim_count,
+   bool do_coarse_grids);
 struct GPUBatch *DRW_pbvh_lines_get(struct PBVHBatches *batches,
 struct PBVHAttrReq *attrs,
 int attrs_num,
 PBVH_GPU_Args *args,
-int *r_prim_count);
+int *r_prim_count,
+bool do_coarse_grids);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/draw/intern/draw_manager_data.cc 
b/source/blender

[Bf-blender-cvs] [939b63bcd6c] master: Sculpt: Fix more attribute bugs when switching PBVH modes

2022-12-13 Thread Joseph Eagar
Commit: 939b63bcd6c2e2bb92c7d5feb466bb44f4427fc8
Author: Joseph Eagar
Date:   Tue Dec 13 13:42:25 2022 -0800
Branches: master
https://developer.blender.org/rB939b63bcd6c2e2bb92c7d5feb466bb44f4427fc8

Sculpt: Fix more attribute bugs when switching PBVH modes

Fixed more cases where attributes weren't being reinitialized
on switching PBVH mode:

* When PBVH_GRIDS and PBVH_BMESH force attributes into simple
  array mode they no longer override simple_array in the
  SculptAttributeParams parameters, instead they set a field
  in SculptAttribute itself.  Thus if the attribute is
  reinitialized in another mode it won't retain the simple_array
  parameter.
* sculpt_attribute_ensure_ex now calls sculpt_attr_update if
  the attribute already exists.
* Fixed a bug from a couple commits ago that set
  SculptAttribute.data_for_bmesh wrong.

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/multires.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 434255b2d9c..4acaa7b05e1 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -516,6 +516,11 @@ typedef struct SculptAttribute {
   int elem_size, elem_num;
   bool data_for_bmesh; /* Temporary data store as array outside of bmesh. */
 
+  /* Data is a flat array outside the CustomData system.
+   * This will be true if simple_array is requested in
+   * SculptAttributeParams, or the PBVH type is PBVH_GRIDS or PBVH_BMESH.
+   */
+  bool simple_array; 
   /* Data stored per BMesh element. */
   int bmesh_cd_offset;
 
diff --git a/source/blender/blenkernel/intern/multires.cc 
b/source/blender/blenkernel/intern/multires.cc
index 7f9a0d64e4b..3700432696a 100644
--- a/source/blender/blenkernel/intern/multires.cc
+++ b/source/blender/blenkernel/intern/multires.cc
@@ -426,6 +426,28 @@ void multires_flush_sculpt_updates(Object *object)
   }
 
   Mesh *mesh = static_cast(object->data);
+
+  /* Check that the multires modifier still exists.
+   * Fixes crash when deleting multires modifier
+   * from within sculpt mode.
+   */
+  ModifierData *md;
+  MultiresModifierData *mmd = nullptr;
+  VirtualModifierData virtualModifierData;
+
+  for (md = BKE_modifiers_get_virtual_modifierlist(object, 
); md;
+   md = md->next) {
+if (md->type == eModifierType_Multires) {
+  if (BKE_modifier_is_enabled(nullptr, md, eModifierMode_Realtime)) {
+mmd = (MultiresModifierData *)md;
+  }
+}
+  }
+
+  if (!mmd) {
+return;
+  }
+
   multiresModifier_reshapeFromCCG(
   sculpt_session->multires.modifier->totlvl, mesh, 
sculpt_session->subdiv_ccg);
 
diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 3100b4cc20c..718ec5318ac 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2454,7 +2454,7 @@ static bool sculpt_attribute_create(SculptSession *ss,
   permanent = (out->params.permanent = false);
 }
 
-simple_array = (out->params.simple_array = true);
+simple_array = true;
   }
 
   BLI_assert(!(simple_array && permanent));
@@ -2466,8 +2466,8 @@ static bool sculpt_attribute_create(SculptSession *ss,
 
 out->data = MEM_calloc_arrayN(totelem, elemsize, __func__);
 
-out->data_for_bmesh = false;
-out->params.simple_array = true;
+out->data_for_bmesh = ss->bm != nullptr;
+out->simple_array = true;
 out->bmesh_cd_offset = -1;
 out->layer = nullptr;
 out->elem_size = elemsize;
@@ -2477,6 +2477,8 @@ static bool sculpt_attribute_create(SculptSession *ss,
 return true;
   }
 
+  out->simple_array = false;
+
   switch (BKE_pbvh_type(ss->pbvh)) {
 case PBVH_BMESH: {
   CustomData *cdata = nullptr;
@@ -2512,8 +2514,6 @@ static bool sculpt_attribute_create(SculptSession *ss,
 case PBVH_FACES: {
   CustomData *cdata = nullptr;
 
-  out->data_for_bmesh = false;
-
   switch (domain) {
 case ATTR_DOMAIN_POINT:
   cdata = >vdata;
@@ -2535,10 +2535,10 @@ static bool sculpt_attribute_create(SculptSession *ss,
 cdata->layers[index].flag |= CD_FLAG_TEMPORARY | CD_FLAG_NOCOPY;
   }
 
-  out->data = nullptr;
   out->layer = cdata->layers + index;
-  out->bmesh_cd_offset = -1;
   out->data = out->layer->data;
+  out->data_for_bmesh = false;
+  out->bmesh_cd_offset = -1;
   out->elem_size = CustomData_get_elem_size(out->layer);
 
   break;
@@ -2566,31 +2566,36 @@ static bool sculpt_attr_update(Object *ob, 
SculptAttribute *attr)
 
   bool bad = false;
 
-  if (attr->params.simple_ar

[Bf-blender-cvs] [0a5e8a63420] master: Sculpt: Fix crash in dyntopo

2022-12-13 Thread Joseph Eagar
Commit: 0a5e8a63420de7efcf874370009831da8f19e215
Author: Joseph Eagar
Date:   Tue Dec 13 08:46:05 2022 -0800
Branches: master
https://developer.blender.org/rB0a5e8a63420de7efcf874370009831da8f19e215

Sculpt: Fix crash in dyntopo

Attribute wrangler in PBVH_BMESH mode was
converting real attributes (e.g. vertex node index)
into simple arrays when validating the attribute list.

===

M   source/blender/blenkernel/intern/paint.cc

===

diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 200eb3e8732..3100b4cc20c 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2466,7 +2466,8 @@ static bool sculpt_attribute_create(SculptSession *ss,
 
 out->data = MEM_calloc_arrayN(totelem, elemsize, __func__);
 
-out->data_for_bmesh = ss->bm != nullptr;
+out->data_for_bmesh = false;
+out->params.simple_array = true;
 out->bmesh_cd_offset = -1;
 out->layer = nullptr;
 out->elem_size = elemsize;
@@ -2598,7 +2599,7 @@ static bool sculpt_attr_update(Object *ob, 
SculptAttribute *attr)
 attr,
 >params,
 BKE_pbvh_type(ss->pbvh),
-true);
+attr->data_for_bmesh);
   }
 
   return bad;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [246df680958] master: Sculpt: Fix crash with unsupported attr types in pbvh draw

2022-12-13 Thread Joseph Eagar
Commit: 246df68095835110a3e11eb3c7a9d2acb048332c
Author: Joseph Eagar
Date:   Tue Dec 13 08:37:04 2022 -0800
Branches: master
https://developer.blender.org/rB246df68095835110a3e11eb3c7a9d2acb048332c

Sculpt: Fix crash with unsupported attr types in pbvh draw

===

M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index cac3e3339fc..d56a86ab44c 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -66,6 +66,22 @@ using blender::Vector;
 
 using string = std::string;
 
+static bool valid_pbvh_attr(int type)
+{
+  switch (type) {
+case CD_PBVH_CO_TYPE:
+case CD_PBVH_NO_TYPE:
+case CD_PBVH_FSET_TYPE:
+case CD_PBVH_MASK_TYPE:
+case CD_PROP_COLOR:
+case CD_PROP_BYTE_COLOR:
+case CD_MLOOPUV:
+  return true;
+  }
+
+  return false;
+}
+
 struct PBVHVbo {
   uint64_t type;
   eAttrDomain domain;
@@ -228,6 +244,10 @@ struct PBVHBatches {
 for (int i : IndexRange(attrs_num)) {
   PBVHAttrReq *attr = attrs + i;
 
+  if (!valid_pbvh_attr(attr->type)) {
+continue;
+  }
+
   PBVHVbo vbo(attr->domain, attr->type, string(attr->name));
   vbo.build_key();
 
@@ -858,10 +878,10 @@ struct PBVHBatches {
 break;
   }
   default:
-BLI_assert(0);
-printf("%s: error\n", __func__);
+printf("%s: Unsupported attribute type %d\n", __func__, type);
+BLI_assert_unreachable();
 
-break;
+return;
 }
 
 if (need_aliases) {
@@ -1227,6 +1247,10 @@ struct PBVHBatches {
 for (int i : IndexRange(attrs_num)) {
   PBVHAttrReq *attr = attrs + i;
 
+  if (!valid_pbvh_attr(attr->type)) {
+continue;
+  }
+
   if (!has_vbo(attr->domain, int(attr->type), attr->name)) {
 create_vbo(attr->domain, uint32_t(attr->type), attr->name, args);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bb764e418aa] sculpt-dev: sculpt-dev: DynTopo cleanup

2022-12-11 Thread Joseph Eagar
Commit: bb764e418aa2d92661812885e4b4343558005244
Author: Joseph Eagar
Date:   Sun Dec 11 00:38:14 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBbb764e418aa2d92661812885e4b4343558005244

sculpt-dev: DynTopo cleanup

* Moved dyntopo.c to c++.
* The new element id system now mostly
  works. Doesn't yet work with collapse
  though, which is a tricky case.  Element
  IDs have to be manually freed now, doing that
  with something as convoluted as a non-manifold
  BREP's edge collapse is not easy.

===

M   release/scripts/startup/bl_ui/properties_data_mesh.py
M   release/scripts/startup/bl_ui/properties_paint_common.py
M   release/scripts/startup/bl_ui/space_view3d_toolbar.py
M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/CMakeLists.txt
R090source/blender/blenkernel/intern/dyntopo.c  
source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/blenlib/BLI_ghash.h
M   source/blender/blenlib/intern/smallhash.c
M   source/blender/bmesh/intern/bmesh_core.c
M   source/blender/bmesh/intern/bmesh_idmap.cc
M   source/blender/bmesh/intern/bmesh_idmap.h
M   source/blender/bmesh/intern/bmesh_interp.h
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/bmesh/intern/bmesh_log.h
M   source/blender/bmesh/intern/bmesh_log_intern.h
M   source/blender/bmesh/intern/bmesh_mods.c
M   source/blender/draw/intern/draw_manager_data.cc
M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/editors/sculpt_paint/paint_mask.c
M   source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M   source/blender/editors/sculpt_paint/sculpt_ops.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py 
b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 56252ff113a..9452e72b684 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -540,7 +540,7 @@ class MESH_UL_attributes(UIList):
 show_all = _context.tool_settings.save_temp_layers if 
hasattr(_context, "tool_settings") else False
 
 for item in attributes:
-flags.append(0 if item.is_internal else self.bitflag_filter_item)
+flags.append(0 if (not show_all and item.is_internal) else 
self.bitflag_filter_item)
 
 return flags, indices
 
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index ca7bbdf38c4..5c045df9148 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -2158,10 +2158,10 @@ def brush_settings_advanced(layout, context, brush, 
popover=False):
 is_cavity_active = "CAVITY" in flags or "CAVITY_INVERTED" in flags
 
 if is_cavity_active:
-props = row.operator("sculpt.mask_from_cavity", text="Create Mask")
+props = layout.operator("sculpt.mask_from_cavity", text="Create 
Mask")
 props.settings_source = "BRUSH"
 
-col.prop(brush, "use_automasking_cavity_inverted", text="Cavity 
(inverted)")
+layout.prop(brush, "use_automasking_cavity_inverted", text="Cavity 
(inverted)")
 
 if is_cavity_active:
 col = layout.column(align=True)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 9328a08f98d..0b99bc81d95 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1148,6 +1148,8 @@ class SCULPT_OT_set_dyntopo_mode(Operator):
 elif self.mode == "C":
 finalch.flags_value = oldf.union({"COLLAPSE"})
 
+print("NEWF", finalch.flags_value)
+
 return {'FINISHED'}
 
 
@@ -2891,7 +2893,8 @@ class VIEW3D_PT_gpencil_brush_presets(Panel, PresetPanel):
 preset_add_operator = "scene.gpencil_brush_preset_add"
 
 
-classes = (VIEW3D_MT_brush_context_menu,
+classes = (SCULPT_OT_set_dyntopo_mode,
+VIEW3D_MT_brush_context_menu,
 VIEW3D_MT_brush_gpencil_context_menu,
 VIEW3D_PT_tools_object_options,
 VIEW3D_PT_tools_object_options_transform,
@@ -2990,8 +2993,7 @@ classes = (VIEW3D_MT_brush_context_menu,
 VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff,
 VIEW3D_PT_tools_brush_swatches_channels,
 VIEW3D_PT_tools_persis

[Bf-blender-cvs] [8e46ef2fa5e] master: Sculpt: Fix crash when sculpting after disabling dyntopo

2022-12-08 Thread Joseph Eagar
Commit: 8e46ef2fa5e63b145e1f448a77a1878d5f265d54
Author: Joseph Eagar
Date:   Thu Dec 8 04:40:42 2022 -0800
Branches: master
https://developer.blender.org/rB8e46ef2fa5e63b145e1f448a77a1878d5f265d54

Sculpt: Fix crash when sculpting after disabling dyntopo

Attributes weren't being reinitialized properly.

===

M   release/scripts/addons
M   source/blender/blenkernel/intern/paint.cc

===

diff --git a/release/scripts/addons b/release/scripts/addons
index fdfd24de034..0b0052bd53a 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit fdfd24de034d4bba4fb67731d0aae81dc4940239
+Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde
diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index a39e53662aa..200eb3e8732 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2571,15 +2571,19 @@ static bool sculpt_attr_update(Object *ob, 
SculptAttribute *attr)
 if (bad) {
   MEM_SAFE_FREE(attr->data);
 }
+else {
+  attr->data_for_bmesh = false;
+}
   }
   else {
 CustomData *cdata = sculpt_get_cdata(ob, attr->domain);
 
 if (cdata) {
   int layer_index = CustomData_get_named_layer_index(cdata, 
attr->proptype, attr->name);
-  bad = layer_index == -1;
 
-  if (ss->bm) {
+  bad |= (ss->bm != nullptr) != attr->data_for_bmesh;
+
+  if (attr->data_for_bmesh) {
 attr->bmesh_cd_offset = cdata->layers[layer_index].offset;
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [31ccf79011b] blender-v3.4-release: Fix T102336: dynamic topology crash

2022-12-06 Thread Joseph Eagar
Commit: 31ccf79011bd537c2dfbe041a76267c7fe46d4c1
Author: Joseph Eagar
Date:   Tue Dec 6 18:02:56 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB31ccf79011bd537c2dfbe041a76267c7fe46d4c1

Fix T102336: dynamic topology crash

Ensure there is always an active vertex when a face is hit.

Differential Revision: https://developer.blender.org/D16705

===

M   source/blender/blenkernel/intern/pbvh_bmesh.c

===

diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c 
b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 3b0f35263d3..d03f12b98bd 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1527,8 +1527,8 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
   float location[3] = {0.0f};
   madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
   for (int j = 0; j < 3; j++) {
-if (len_squared_v3v3(location, cos[j]) <
-len_squared_v3v3(location, nearest_vertex_co)) {
+if (j == 0 || len_squared_v3v3(location, cos[j]) <
+  len_squared_v3v3(location, nearest_vertex_co)) {
   copy_v3_v3(nearest_vertex_co, cos[j]);
   r_active_vertex->i = 
(intptr_t)node->bm_orvert[node->bm_ortri[i][j]];
 }
@@ -1559,8 +1559,8 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
 float location[3] = {0.0f};
 madd_v3_v3v3fl(location, ray_start, ray_normal, *depth);
 for (int j = 0; j < 3; j++) {
-  if (len_squared_v3v3(location, v_tri[j]->co) <
-  len_squared_v3v3(location, nearest_vertex_co)) {
+  if (j == 0 || len_squared_v3v3(location, v_tri[j]->co) <
+len_squared_v3v3(location, nearest_vertex_co)) 
{
 copy_v3_v3(nearest_vertex_co, v_tri[j]->co);
 r_active_vertex->i = (intptr_t)v_tri[j];
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e53a8f9c51d] sculpt-dev: Merge branch 'master' into sculpt-dev

2022-12-03 Thread Joseph Eagar
Commit: e53a8f9c51d4b4d6e92652bdf371a6215ff1fe83
Author: Joseph Eagar
Date:   Sat Dec 3 03:26:49 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBe53a8f9c51d4b4d6e92652bdf371a6215ff1fe83

Merge branch 'master' into sculpt-dev

===



===

diff --cc release/scripts/addons
index 5a818af9508,0b0052bd53a..fdfd24de034
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 5a818af95080cccf04dfa8317f0e966bff515c64
 -Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde
++Subproject commit fdfd24de034d4bba4fb67731d0aae81dc4940239
diff --cc release/scripts/startup/bl_ui/properties_data_mesh.py
index 6d676a4ee18,5d7e7cd77b1..56252ff113a
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@@ -535,13 -536,8 +537,10 @@@ class MESH_UL_attributes(UIList)
  flags = []
  indices = [i for i in range(len(attributes))]
  
 +show_all = _context.tool_settings.save_temp_layers if 
hasattr(_context, "tool_settings") else False
 +
  for item in attributes:
- if show_all:
- flags.append(self.bitflag_filter_item)
- else:
- flags.append(0)
+ flags.append(0 if item.is_internal else self.bitflag_filter_item)
  
  return flags, indices
  
diff --cc release/scripts/startup/bl_ui/properties_paint_common.py
index 2fd34c78722,3cd5df4df7d..ca7bbdf38c4
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@@ -2151,14 -954,17 +2151,17 @@@ def brush_settings_advanced(layout, con
  
  layout.separator()
  
 -col = layout.column(align=True)
 -row = col.row()
 -row.prop(brush, "use_automasking_cavity", text="Cavity")
 +#col = layout.column(align=True)
 +#row = col.row()
 +#row.prop(brush, "use_automasking_cavity", text="Cavity")
  
 -is_cavity_active = brush.use_automasking_cavity or 
brush.use_automasking_cavity_inverted
 +is_cavity_active = "CAVITY" in flags or "CAVITY_INVERTED" in flags
  
  if is_cavity_active:
- layout.operator("sculpt.mask_from_cavity", text="Create Mask")
+ props = row.operator("sculpt.mask_from_cavity", text="Create 
Mask")
+ props.settings_source = "BRUSH"
+ 
+ col.prop(brush, "use_automasking_cavity_inverted", text="Cavity 
(inverted)")
  
  if is_cavity_active:
  col = layout.column(align=True)
diff --cc release/scripts/startup/bl_ui/space_view3d.py
index a48441d6cff,63aff89aa7d..9ee1f2bb118
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@@ -18,8 -18,13 +18,12 @@@ from bl_ui.properties_grease_pencil_com
  from bl_ui.space_toolsystem_common import (
  ToolActivePanelHelper,
  )
- from bpy.app.translations import contexts as i18n_contexts
+ from bpy.app.translations import (
+ pgettext_iface as iface_,
+ pgettext_tip as tip_,
+ contexts as i18n_contexts,
+ )
  
 -
  class VIEW3D_HT_tool_header(Header):
  bl_space_type = 'VIEW_3D'
  bl_region_type = 'TOOL_HEADER'
diff --cc source/blender/blenkernel/BKE_bassrelief.h
index e3dbc21df65,000..81392f6c88c
mode 100644,00..100644
--- a/source/blender/blenkernel/BKE_bassrelief.h
+++ b/source/blender/blenkernel/BKE_bassrelief.h
@@@ -1,90 -1,0 +1,91 @@@
 +/*
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) Blender Foundation.
 + * All rights reserved.
 + */
 +#pragma once
 +
 +/** \file
 + * \ingroup bke
 + */
 +
 +#include "BKE_bvhutils.h"
 +#include "BLI_bitmap.h"
 +#include "BLI_math_matrix.h"
 +
 +struct Scene;
 +struct Mesh;
 +struct BassReliefModifierData;
 +struct Object;
 +struct MDeformVert;
 +struct ModifierEvalContext;
 +struct MPropCol;
 +
 +#define MAX_BASSRELIEF_DEBUG_COLORS 7
 +
 +#ifdef __cplusplus
 

[Bf-blender-cvs] [e19d6d2f188] sculpt-dev: sculpt-dev: part one of new id system for dyntopo

2022-12-03 Thread Joseph Eagar
Commit: e19d6d2f188858e7e323bde624dc093fa71213d3
Author: Joseph Eagar
Date:   Tue Nov 22 12:39:49 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBe19d6d2f188858e7e323bde624dc093fa71213d3

sculpt-dev: part one of new id system for dyntopo

===

M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/bmesh/CMakeLists.txt
A   source/blender/bmesh/intern/bmesh_idmap.cc
A   source/blender/bmesh/intern/bmesh_idmap.h
M   source/blender/makesdna/DNA_customdata_types.h

===

diff --git a/source/blender/blenkernel/intern/customdata.cc 
b/source/blender/blenkernel/intern/customdata.cc
index 5a6b2f4abc3..504b705bde8 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -220,6 +220,7 @@ struct LayerTypeInfo {
   /** a function to determine max allowed number of layers,
* should be null or return -1 if no limit */
   int (*layers_max)();
+  bool use_default_data;
 };
 
 /** \} */
@@ -1848,7 +1849,21 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
  nullptr,
  nullptr,
  layerInterp_propInt,
- nullptr},
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ true},
 /* 12: CD_PROP_STRING */
 {sizeof(MStringProperty),
  "MStringProperty",
@@ -2624,6 +2639,10 @@ bool CustomData_merge(const CustomData *source,
 }
 
 if (newlayer) {
+  if (layer->default_data) {
+newlayer->default_data = MEM_dupallocN(layer->default_data);
+  }
+
   newlayer->uid = layer->uid;
 
   newlayer->active = lastactive;
@@ -2759,6 +2778,10 @@ static void 
customData_free_layer__internal(CustomDataLayer *layer, const int to
 if (layer->data) {
   MEM_freeN(layer->data);
 }
+
+if (layer->default_data) {
+  MEM_freeN(layer->default_data);
+}
   }
 }
 
@@ -4295,7 +4318,7 @@ static void CustomData_bmesh_alloc_block(CustomData 
*data, void **block)
   ptr += cd_tflags;
 
   MToolFlags *flags = (MToolFlags *)ptr;
-  flags->flag = NULL;
+  flags->flag = nullptr;
 }
   }
   else {
@@ -4345,7 +4368,12 @@ static void CustomData_bmesh_set_default_n(CustomData 
*data, void **block, const
 typeInfo->set_default_value(POINTER_OFFSET(*block, offset), 1);
   }
   else {
-memset(POINTER_OFFSET(*block, offset), 0, typeInfo->size);
+if (typeInfo->use_default_data && data->layers[n].default_data) {
+  memcpy(POINTER_OFFSET(*block, offset), data->layers[n].default_data, 
typeInfo->size);
+}
+else {
+  memset(POINTER_OFFSET(*block, offset), 0, typeInfo->size);
+}
   }
 }
 
@@ -4850,9 +4878,16 @@ void CustomData_bmesh_interp(CustomData *data,
  1);
 }
 else {
-  memcpy(POINTER_OFFSET(dst_block, layer->offset),
- POINTER_OFFSET(src_blocks[0], layer->offset),
- typeInfo->size);
+  if (layer->default_data && typeInfo->use_default_data) {
+memcpy(POINTER_OFFSET(dst_block, layer->offset),
+   layer->default_data,
+   typeInfo->size);
+  }
+  else {
+memcpy(POINTER_OFFSET(dst_block, layer->offset),
+   POINTER_OFFSET(src_blocks[0], layer->offset),
+   typeInfo->size);
+  }
 }
   }
 
@@ -5846,6 +5881,12 @@ void CustomData_blend_write(BlendWriter *writer,
   writer, CustomDataLayer, data->totlayer, data->layers, 
layers_to_write.data());
 
   for (const CustomDataLayer  : layers_to_write) {
+const LayerTypeInfo *typeInfo = layerType_getInfo(layer.type);
+
+if (typeInfo->use_default_data && layer.default_data) {
+  BLO_write_struct_by_name(writer, typeInfo->structname, 
layer.default_data);
+}
+
 switch (layer.type) {
   case CD_MDEFORMVERT:
 BKE_defvert_blend_write(writer, count, static_cast(layer.data));
@@ -5956,6 +5997,14 @@ void CustomData_blend_read(BlendDataReader *reader, 
CustomData *data, const int
   int i = 0;
   while (i < data->totlayer) {
 CustomDataLayer *layer = >layers[i];
+const LayerTypeInfo *typeInfo = layerType_getInfo(layer->type);
+
+if (layer->default_data && typeInfo->use_default_data) {
+  BLO_read_data_address(reader, >default_data);
+}
+else {
+  layer->default_data = nullptr;
+}
 
 if (layer->flag & CD_FLAG_EXTERNAL) {
   layer->flag &= ~CD_FLAG_IN_MEMORY;
diff --git a/source/blender/bmesh/CMakeLists.txt 
b/source/blender/bmesh/CMakeLists.txt

[Bf-blender-cvs] [aeefe651716] sculpt-dev: sculpt-dev: fix compile errors

2022-12-03 Thread Joseph Eagar
Commit: aeefe651716f0fec059f8ff1b228ece76ead018b
Author: Joseph Eagar
Date:   Fri Dec 2 12:35:34 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBaeefe651716f0fec059f8ff1b228ece76ead018b

sculpt-dev: fix compile errors

===

M   release/scripts/addons
M   source/blender/blenlib/intern/BLI_table_gset.c
M   source/blender/blenlib/intern/smallhash.c

===

diff --git a/release/scripts/addons b/release/scripts/addons
index c226f867aff..5a818af9508 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit c226f867affd12881533a54c8c90ac6eebfaca6c
+Subproject commit 5a818af95080cccf04dfa8317f0e966bff515c64
diff --git a/source/blender/blenlib/intern/BLI_table_gset.c 
b/source/blender/blenlib/intern/BLI_table_gset.c
index 90c1235072e..88e3cc133b1 100644
--- a/source/blender/blenlib/intern/BLI_table_gset.c
+++ b/source/blender/blenlib/intern/BLI_table_gset.c
@@ -100,7 +100,7 @@ bool BLI_table_gset_add(TableGSet *ts, void *elem)
   bool ret = BLI_smallhash_ensure_p(PTR_TO_IDX(ts), (uintptr_t)elem, );
 
   if (!ret) {
-*val = ts->cur;
+*val = POINTER_FROM_INT(ts->cur);
 
 ts->elems[ts->cur++] = elem;
 ts->length++;
@@ -113,7 +113,7 @@ void BLI_table_gset_insert(TableGSet *ts, void *elem)
 {
   table_gset_resize(ts);
 
-  BLI_smallhash_insert(PTR_TO_IDX(ts), elem, (void *)ts->cur);
+  BLI_smallhash_insert(PTR_TO_IDX(ts), (uintptr_t)elem, (void *)ts->cur);
 
   ts->elems[ts->cur++] = elem;
   ts->length++;
@@ -125,14 +125,14 @@ void BLI_table_gset_remove(TableGSet *ts, void *elem, 
GHashKeyFreeFP freefp)
 return;
   }
 
-  int *idx = (int *)BLI_smallhash_lookup_p(PTR_TO_IDX(ts), elem);
+  int *idx = (int *)BLI_smallhash_lookup_p(PTR_TO_IDX(ts), (uintptr_t)elem);
   if (!idx) {
 return;
   }
 
   int idx2 = *idx;
 
-  BLI_smallhash_remove(PTR_TO_IDX(ts), elem);
+  BLI_smallhash_remove(PTR_TO_IDX(ts), (uintptr_t)elem);
 
   if (!ts->elems || ts->elems[idx2] != elem) {
 return;
@@ -144,7 +144,7 @@ void BLI_table_gset_remove(TableGSet *ts, void *elem, 
GHashKeyFreeFP freefp)
 
 bool BLI_table_gset_haskey(TableGSet *ts, void *elem)
 {
-  return BLI_smallhash_haskey(PTR_TO_IDX(ts), elem);
+  return BLI_smallhash_haskey(PTR_TO_IDX(ts), (uintptr_t)elem);
 }
 
 int BLI_table_gset_len(TableGSet *ts)
diff --git a/source/blender/blenlib/intern/smallhash.c 
b/source/blender/blenlib/intern/smallhash.c
index d3c7c7f8958..c266743346d 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -68,8 +68,8 @@
 #endif
 
 #define SMHASH_KEY_UNUSED (uintptr_t)(MAKE_ID_8('s', 'm', 'h', 'k', 'u', 'n', 
'u', 's'))
-#define SMHASH_CELL_FREE (uintptr_t)(MAKE_ID_8('s', 'm', 'h', 'c', 'f', 'r', 
'e', 'e'))
-#define SMHASH_CELL_UNUSED (uintptr_t)(MAKE_ID_8('s', 'm', 'h', 'c', 'u', 'n', 
'u', 's'))
+#define SMHASH_CELL_FREE (void *)(MAKE_ID_8('s', 'm', 'h', 'c', 'f', 'r', 'e', 
'e'))
+#define SMHASH_CELL_UNUSED (void *)(MAKE_ID_8('s', 'm', 'h', 'c', 'u', 'n', 
'u', 's'))
 
 #define USE_REMOVE

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [46f991dbae9] master: Sculpt: Fix broken pivots when entering paint modes

2022-12-02 Thread Joseph Eagar
Commit: 46f991dbae96b95870bf3db4564082fc6e2e0ee5
Author: Joseph Eagar
Date:   Fri Dec 2 00:37:50 2022 -0800
Branches: master
https://developer.blender.org/rB46f991dbae96b95870bf3db4564082fc6e2e0ee5

Sculpt: Fix broken pivots when entering paint modes

When entering paint modes the paint pivot was cleared,
which broken rotate around pivot.  Fixed for all paint modes.
PBVH modes set the pivot to the PBVH bounding box
while texture paint uses the evaluated mesh bounding box.

===

M   release/scripts/addons

===

diff --git a/release/scripts/addons b/release/scripts/addons
index fdfd24de034..0b0052bd53a 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit fdfd24de034d4bba4fb67731d0aae81dc4940239
+Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4aac5b92c1b] master: Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes

2022-11-30 Thread Joseph Eagar
Commit: 4aac5b92c1bbef77edaa50f460cba8350c56eaea
Author: Joseph Eagar
Date:   Wed Nov 30 13:16:17 2022 -0800
Branches: master
https://developer.blender.org/rB4aac5b92c1bbef77edaa50f460cba8350c56eaea

Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes

The code I wrote to group triangles or multires quads that
belonging to single faces into single PBVH nodes had edge
cases that failed.  The code is now much simpler and simply
assigns groups of primitives to nodes.

===

M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/editors/sculpt_paint/sculpt_ops.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 145ceb143ea..0322b7135cb 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -39,6 +39,11 @@
 
 #define LEAF_LIMIT 1
 
+/* Uncomment to test if triangles of the same face are
+ * properly clustered into single nodes.
+ */
+//#define TEST_PBVH_FACE_SPLIT
+
 /* Uncomment to test that faces are only assigned to one PBVHNode */
 //#define VALIDATE_UNIQUE_NODE_FACES
 
@@ -164,24 +169,65 @@ static bool grid_materials_match(const DMFlagMat *f1, 
const DMFlagMat *f2)
 
 /* Adapted from BLI_kdopbvh.c */
 /* Returns the index of the first element on the right of the partition */
-static int partition_indices(int *prim_indices, int lo, int hi, int axis, 
float mid, BBC *prim_bbc)
+static int partition_indices_faces(int *prim_indices,
+   int *prim_scratch,
+   int lo,
+   int hi,
+   int axis,
+   float mid,
+   BBC *prim_bbc,
+   const MLoopTri *looptri,
+   const MPoly *mpoly)
 {
-  int i = lo, j = hi;
-  for (;;) {
-for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) {
-  /* pass */
-}
-for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) {
-  /* pass */
-}
+  for (int i = lo; i < hi; i++) {
+prim_scratch[i - lo] = prim_indices[i];
+  }
 
-if (!(i < j)) {
-  return i;
+  int lo2 = lo, hi2 = hi - 1;
+  int i1 = lo, i2 = 0;
+
+  while (i1 < hi) {
+int poly = looptri[prim_scratch[i2]].poly;
+bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
+
+while (i1 < hi && looptri[prim_scratch[i2]].poly == poly) {
+  prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
+  i1++;
+  i2++;
 }
+  }
 
-SWAP(int, prim_indices[i], prim_indices[j]);
-i++;
+  return lo2;
+}
+
+static int partition_indices_grids(int *prim_indices,
+   int *prim_scratch,
+   int lo,
+   int hi,
+   int axis,
+   float mid,
+   BBC *prim_bbc,
+   SubdivCCG *subdiv_ccg)
+{
+  for (int i = lo; i < hi; i++) {
+prim_scratch[i - lo] = prim_indices[i];
+  }
+
+  int lo2 = lo, hi2 = hi - 1;
+  int i1 = lo, i2 = 0;
+
+  while (i1 < hi) {
+int poly = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]);
+bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
+
+while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, 
prim_scratch[i2]) == poly) {
+  prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
+  i1++;
+  i2++;
+}
   }
+
+  return lo2;
 }
 
 /* Returns the index of the first element on the right of the partition */
@@ -424,55 +470,53 @@ static bool leaf_needs_material_split(PBVH *pbvh, int 
offset, int count)
   return false;
 }
 
-static int adjust_partition_faces(PBVH *pbvh, int offset, int mid, int count)
+#ifdef TEST_PBVH_FACE_SPLIT
+static void test_face_boundaries(PBVH *pbvh)
 {
-  int poly = pbvh->looptri[pbvh->prim_indices[mid]].poly;
-
-  /* Scan backwards. */
-  while (mid > offset + 2) { /* First node should have at least 1 primitive */
-if (pbvh->looptri[pbvh->prim_indices[mid - 1]].poly != poly) {
-  return mid;
-}
-
-mid--;
+  int faces_num = BKE_pbvh_num_faces(pbvh);
+  int *node_map = MEM_calloc_arrayN(faces_num, sizeof(int), __func__);
+  for (int i = 0; i < faces_num; i++) {
+node_map[i] = -1;
   }
 
-  /* If that didn't work try scanning forward. */
-  while (mid < pbvh->totprim + count) {
-if (pbvh->looptri[pbvh->prim_indices[mid]].poly != poly) {
-  break;
-}
-
-mid++;
-  }
-
-  return mid;
-}
-
-static int adjust_partition_grids(PBVH *pbvh, int offset, int mid, int count)
-{
-  int poly = BKE_subdiv_ccg_grid_to_face

[Bf-blender-cvs] [65393add526] master: Sculpt: Fix broken pivots when entering paint modes

2022-11-30 Thread Joseph Eagar
Commit: 65393add5269f9b803691b2df67fcdf0152d0b40
Author: Joseph Eagar
Date:   Wed Nov 30 13:54:56 2022 -0800
Branches: master
https://developer.blender.org/rB65393add5269f9b803691b2df67fcdf0152d0b40

Sculpt: Fix broken pivots when entering paint modes

When entering paint modes the paint pivot was cleared,
which broken rotate around pivot.  Fixed for all paint modes.
PBVH modes set the pivot to the PBVH bounding box
while texture paint uses the evaluated mesh bounding box.

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/sculpt_paint/paint_cursor.cc
M   source/blender/editors/sculpt_paint/paint_image.cc
M   source/blender/editors/sculpt_paint/paint_vertex.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_ops.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index acb0e53aa55..9e8d9636a29 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -293,7 +293,10 @@ void ED_object_vpaintmode_exit(struct bContext *C);
 void ED_object_wpaintmode_exit_ex(struct Object *ob);
 void ED_object_wpaintmode_exit(struct bContext *C);
 
-void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, struct Scene 
*scene, Object *ob);
+void ED_object_texture_paint_mode_enter_ex(struct Main *bmain,
+   struct Scene *scene,
+   struct Depsgraph *depsgraph,
+   Object *ob);
 void ED_object_texture_paint_mode_enter(struct bContext *C);
 
 void ED_object_texture_paint_mode_exit_ex(struct Main *bmain, struct Scene 
*scene, Object *ob);
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc 
b/source/blender/editors/sculpt_paint/paint_cursor.cc
index 29d86e22814..c27cd8eb2ef 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.cc
+++ b/source/blender/editors/sculpt_paint/paint_cursor.cc
@@ -15,6 +15,7 @@
 #include "DNA_brush_types.h"
 #include "DNA_color_types.h"
 #include "DNA_customdata_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
diff --git a/source/blender/editors/sculpt_paint/paint_image.cc 
b/source/blender/editors/sculpt_paint/paint_image.cc
index 2fff4fe9dc5..1ab364c4877 100644
--- a/source/blender/editors/sculpt_paint/paint_image.cc
+++ b/source/blender/editors/sculpt_paint/paint_image.cc
@@ -35,11 +35,14 @@
 #include "BKE_material.h"
 #include "BKE_mesh.h"
 #include "BKE_node_runtime.hh"
+#include "BKE_object.h"
 #include "BKE_paint.h"
+#include "BKE_scene.h"
 
 #include "NOD_texture.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "UI_interface.h"
 #include "UI_view2d.h"
@@ -756,7 +759,34 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
 
 / texture paint toggle operator /
 
-void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object 
*ob)
+static void paint_init_pivot(Object *ob, Scene *scene)
+{
+  UnifiedPaintSettings *ups = >toolsettings->unified_paint_settings;
+
+  const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
+  if (!me_eval) {
+me_eval = (const Mesh *)ob->data;
+  }
+
+  float location[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, 
-FLT_MAX, -FLT_MAX};
+
+  if (!BKE_mesh_minmax(me_eval, location, max)) {
+zero_v3(location);
+zero_v3(max);
+  }
+
+  interp_v3_v3v3(location, location, max, 0.5f);
+  mul_m4_v3(ob->object_to_world, location);
+
+  ups->last_stroke_valid = true;
+  ups->average_stroke_counter = 1;
+  copy_v3_v3(ups->average_stroke_accum, location);
+}
+
+void ED_object_texture_paint_mode_enter_ex(Main *bmain,
+   Scene *scene,
+   Depsgraph *depsgraph,
+   Object *ob)
 {
   Image *ima = nullptr;
   ImagePaintSettings *imapaint = >toolsettings->imapaint;
@@ -800,6 +830,14 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain, 
Scene *scene, Object *ob
   Mesh *me = BKE_mesh_from_object(ob);
   BLI_assert(me != nullptr);
   DEG_id_tag_update(>id, ID_RECALC_COPY_ON_WRITE);
+
+  /* Ensure we have evaluated data for bounding box. */
+  BKE_scene_graph_evaluated_ensure(depsgraph, bmain);
+
+  /* Set pivot to bounding box center. */
+  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
+  paint_init_pivot(ob_eval ? ob_eval : ob, scene);
+
   WM_main_add_notifier(NC_SCENE

[Bf-blender-cvs] [918282d391a] master: Sculpt: fix crash when no brush

2022-11-30 Thread Joseph Eagar
Commit: 918282d391a4068102bbc4e25ab9c829bd1b41f3
Author: Joseph Eagar
Date:   Tue Nov 29 14:29:45 2022 -0800
Branches: master
https://developer.blender.org/rB918282d391a4068102bbc4e25ab9c829bd1b41f3

Sculpt: fix crash when no brush

If no brush exists the stroke operator
falls through to the grab transform
op in the global view3d keymap.

This now works.  It would be nice if
we could get rid of that keymap entry
though and add it manually to the edit/paint
modes that need it.

===

M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/sculpt_paint/sculpt_filter_mesh.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index e1dac167a32..9d30aa512c8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -4839,6 +4839,10 @@ static bool sculpt_needs_connectivity_info(const Sculpt 
*sd,
SculptSession *ss,
int stroke_mode)
 {
+  if (!brush) {
+return true;
+  }
+
   if (ss && ss->pbvh && SCULPT_is_automasking_enabled(sd, ss, brush)) {
 return true;
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c 
b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index c158cf33f6d..e677b565a10 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -191,7 +191,8 @@ void SCULPT_filter_cache_init(bContext *C,
 
 BKE_pbvh_search_gather(pbvh, SCULPT_search_sphere_cb, _data2, 
, );
 
-if (SCULPT_pbvh_calc_area_normal(
+if (BKE_paint_brush(>paint) &&
+SCULPT_pbvh_calc_area_normal(
 brush, ob, nodes, totnode, true, 
ss->filter_cache->initial_normal)) {
   copy_v3_v3(ss->last_normal, ss->filter_cache->initial_normal);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1017b493edb] blender-v3.4-release: Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes

2022-11-30 Thread Joseph Eagar
Commit: 1017b493edb9bc0a14bdfe642dbdc09eebf10d77
Author: Joseph Eagar
Date:   Wed Nov 30 13:16:17 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB1017b493edb9bc0a14bdfe642dbdc09eebf10d77

Sculpt: Fix T102824: broken face primitive partitioning in pbvh nodes

The code I wrote to group triangles or multires quads that
belonging to single faces into single PBVH nodes had edge
cases that failed.  The code is now much simpler and simply
assigns groups of primitives to nodes.

===

M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/editors/sculpt_paint/sculpt_ops.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 7d7641a7a54..4b24f851fca 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -39,6 +39,11 @@
 
 #define LEAF_LIMIT 1
 
+/* Uncomment to test if triangles of the same face are
+ * properly clustered into single nodes.
+ */
+//#define TEST_PBVH_FACE_SPLIT
+
 /* Uncomment to test that faces are only assigned to one PBVHNode */
 //#define VALIDATE_UNIQUE_NODE_FACES
 
@@ -164,24 +169,65 @@ static bool grid_materials_match(const DMFlagMat *f1, 
const DMFlagMat *f2)
 
 /* Adapted from BLI_kdopbvh.c */
 /* Returns the index of the first element on the right of the partition */
-static int partition_indices(int *prim_indices, int lo, int hi, int axis, 
float mid, BBC *prim_bbc)
+static int partition_indices_faces(int *prim_indices,
+   int *prim_scratch,
+   int lo,
+   int hi,
+   int axis,
+   float mid,
+   BBC *prim_bbc,
+   const MLoopTri *looptri,
+   const MPoly *mpoly)
 {
-  int i = lo, j = hi;
-  for (;;) {
-for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) {
-  /* pass */
-}
-for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) {
-  /* pass */
-}
+  for (int i = lo; i < hi; i++) {
+prim_scratch[i - lo] = prim_indices[i];
+  }
 
-if (!(i < j)) {
-  return i;
+  int lo2 = lo, hi2 = hi - 1;
+  int i1 = lo, i2 = 0;
+
+  while (i1 < hi) {
+int poly = looptri[prim_scratch[i2]].poly;
+bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
+
+while (i1 < hi && looptri[prim_scratch[i2]].poly == poly) {
+  prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
+  i1++;
+  i2++;
 }
+  }
 
-SWAP(int, prim_indices[i], prim_indices[j]);
-i++;
+  return lo2;
+}
+
+static int partition_indices_grids(int *prim_indices,
+   int *prim_scratch,
+   int lo,
+   int hi,
+   int axis,
+   float mid,
+   BBC *prim_bbc,
+   SubdivCCG *subdiv_ccg)
+{
+  for (int i = lo; i < hi; i++) {
+prim_scratch[i - lo] = prim_indices[i];
+  }
+
+  int lo2 = lo, hi2 = hi - 1;
+  int i1 = lo, i2 = 0;
+
+  while (i1 < hi) {
+int poly = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, prim_scratch[i2]);
+bool side = prim_bbc[prim_scratch[i2]].bcentroid[axis] >= mid;
+
+while (i1 < hi && BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, 
prim_scratch[i2]) == poly) {
+  prim_indices[side ? hi2-- : lo2++] = prim_scratch[i2];
+  i1++;
+  i2++;
+}
   }
+
+  return lo2;
 }
 
 /* Returns the index of the first element on the right of the partition */
@@ -424,55 +470,53 @@ static bool leaf_needs_material_split(PBVH *pbvh, int 
offset, int count)
   return false;
 }
 
-static int adjust_partition_faces(PBVH *pbvh, int offset, int mid, int count)
+#ifdef TEST_PBVH_FACE_SPLIT
+static void test_face_boundaries(PBVH *pbvh)
 {
-  int poly = pbvh->looptri[pbvh->prim_indices[mid]].poly;
-
-  /* Scan backwards. */
-  while (mid > offset + 2) { /* First node should have at least 1 primitive */
-if (pbvh->looptri[pbvh->prim_indices[mid - 1]].poly != poly) {
-  return mid;
-}
-
-mid--;
+  int faces_num = BKE_pbvh_num_faces(pbvh);
+  int *node_map = MEM_calloc_arrayN(faces_num, sizeof(int), __func__);
+  for (int i = 0; i < faces_num; i++) {
+node_map[i] = -1;
   }
 
-  /* If that didn't work try scanning forward. */
-  while (mid < pbvh->totprim + count) {
-if (pbvh->looptri[pbvh->prim_indices[mid]].poly != poly) {
-  break;
-}
-
-mid++;
-  }
-
-  return mid;
-}
-
-static int adjust_partition_grids(PBVH *pbvh, int offset, int mid, int count)
-{
-  int poly = BKE_subdiv_ccg_gr

[Bf-blender-cvs] [8fa5206ab04] blender-v3.4-release: Sculpt: fix crash when no brush

2022-11-30 Thread Joseph Eagar
Commit: 8fa5206ab04d901320484351657bbcea8dc037f0
Author: Joseph Eagar
Date:   Tue Nov 29 14:29:45 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB8fa5206ab04d901320484351657bbcea8dc037f0

Sculpt: fix crash when no brush

If no brush exists the stroke operator
falls through to the grab transform
op in the global view3d keymap.

This now works.  It would be nice if
we could get rid of that keymap entry
though and add it manually to the edit/paint
modes that need it.

===

M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_filter_mesh.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index aad86ffc2b1..212d39464b7 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4861,6 +4861,10 @@ static bool sculpt_needs_connectivity_info(const Sculpt 
*sd,
SculptSession *ss,
int stroke_mode)
 {
+  if (!brush) {
+return true;
+  }
+
   if (ss && ss->pbvh && SCULPT_is_automasking_enabled(sd, ss, brush)) {
 return true;
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c 
b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index c158cf33f6d..e677b565a10 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -191,7 +191,8 @@ void SCULPT_filter_cache_init(bContext *C,
 
 BKE_pbvh_search_gather(pbvh, SCULPT_search_sphere_cb, _data2, 
, );
 
-if (SCULPT_pbvh_calc_area_normal(
+if (BKE_paint_brush(>paint) &&
+SCULPT_pbvh_calc_area_normal(
 brush, ob, nodes, totnode, true, 
ss->filter_cache->initial_normal)) {
   copy_v3_v3(ss->last_normal, ss->filter_cache->initial_normal);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fde628ddb32] blender-v3.4-release: Sculpt: Fix broken pivots when entering paint modes

2022-11-30 Thread Joseph Eagar
Commit: fde628ddb324660c715c0b8fd345f002eb993beb
Author: Joseph Eagar
Date:   Wed Nov 30 12:36:29 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rBfde628ddb324660c715c0b8fd345f002eb993beb

Sculpt: Fix broken pivots when entering paint modes

When entering paint modes the paint pivot was cleared,
which broken rotate around pivot.  Fixed for all paint modes.
PBVH modes set the pivot to the PBVH bounding box
while texture paint uses the evaluated mesh bounding box.

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/sculpt_paint/paint_cursor.c
M   source/blender/editors/sculpt_paint/paint_image.cc
M   source/blender/editors/sculpt_paint/paint_vertex.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_ops.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index acb0e53aa55..9e8d9636a29 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -293,7 +293,10 @@ void ED_object_vpaintmode_exit(struct bContext *C);
 void ED_object_wpaintmode_exit_ex(struct Object *ob);
 void ED_object_wpaintmode_exit(struct bContext *C);
 
-void ED_object_texture_paint_mode_enter_ex(struct Main *bmain, struct Scene 
*scene, Object *ob);
+void ED_object_texture_paint_mode_enter_ex(struct Main *bmain,
+   struct Scene *scene,
+   struct Depsgraph *depsgraph,
+   Object *ob);
 void ED_object_texture_paint_mode_enter(struct bContext *C);
 
 void ED_object_texture_paint_mode_exit_ex(struct Main *bmain, struct Scene 
*scene, Object *ob);
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c 
b/source/blender/editors/sculpt_paint/paint_cursor.c
index b6e83187c86..c2fde7c2117 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -15,6 +15,7 @@
 #include "DNA_brush_types.h"
 #include "DNA_color_types.h"
 #include "DNA_customdata_types.h"
+#include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -27,6 +28,7 @@
 #include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_image.h"
+#include "BKE_mesh.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
 
diff --git a/source/blender/editors/sculpt_paint/paint_image.cc 
b/source/blender/editors/sculpt_paint/paint_image.cc
index 8c6358520ca..eebc1bdb4b9 100644
--- a/source/blender/editors/sculpt_paint/paint_image.cc
+++ b/source/blender/editors/sculpt_paint/paint_image.cc
@@ -34,11 +34,14 @@
 #include "BKE_main.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
+#include "BKE_object.h"
 #include "BKE_paint.h"
+#include "BKE_scene.h"
 
 #include "NOD_texture.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "UI_interface.h"
 #include "UI_view2d.h"
@@ -755,7 +758,34 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
 
 / texture paint toggle operator /
 
-void ED_object_texture_paint_mode_enter_ex(Main *bmain, Scene *scene, Object 
*ob)
+static void paint_init_pivot(Object *ob, Scene *scene)
+{
+  UnifiedPaintSettings *ups = >toolsettings->unified_paint_settings;
+
+  const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
+  if (!me_eval) {
+me_eval = (const Mesh *)ob->data;
+  }
+
+  float location[3] = {FLT_MAX, FLT_MAX, FLT_MAX}, max[3] = {-FLT_MAX, 
-FLT_MAX, -FLT_MAX};
+
+  if (!BKE_mesh_minmax(me_eval, location, max)) {
+zero_v3(location);
+zero_v3(max);
+  }
+
+  interp_v3_v3v3(location, location, max, 0.5f);
+  mul_m4_v3(ob->object_to_world, location);
+
+  ups->last_stroke_valid = true;
+  ups->average_stroke_counter = 1;
+  copy_v3_v3(ups->average_stroke_accum, location);
+}
+
+void ED_object_texture_paint_mode_enter_ex(Main *bmain,
+   Scene *scene,
+   Depsgraph *depsgraph,
+   Object *ob)
 {
   Image *ima = nullptr;
   ImagePaintSettings *imapaint = >toolsettings->imapaint;
@@ -812,6 +842,14 @@ void ED_object_texture_paint_mode_enter_ex(Main *bmain, 
Scene *scene, Object *ob
   Mesh *me = BKE_mesh_from_object(ob);
   BLI_assert(me != nullptr);
   DEG_id_tag_update(>id, ID_RECALC_COPY_ON_WRITE);
+
+  /* Ensure we have evaluated data for bounding box. */
+  BKE_scene_graph_evaluate

[Bf-blender-cvs] [48143ab0015] blender-v3.4-release: Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

2022-11-28 Thread Joseph Eagar
Commit: 48143ab00156f94687dc74701e13a07ebd8a
Author: Joseph Eagar
Date:   Mon Nov 28 13:07:50 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB48143ab00156f94687dc74701e13a07ebd8a

Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

===

M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 6a38ef8bc8c..aad86ffc2b1 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1824,14 +1824,27 @@ SculptBrushTestFn 
SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss,
 SculptBrushTest 
*test,
 char falloff_shape)
 {
+  if (!ss->cache && !ss->filter_cache) {
+falloff_shape = PAINT_FALLOFF_SHAPE_SPHERE;
+  }
+
   SCULPT_brush_test_init(ss, test);
   SculptBrushTestFn sculpt_brush_test_sq_fn;
   if (falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
 sculpt_brush_test_sq_fn = SCULPT_brush_test_sphere_sq;
   }
   else {
+float view_normal[3];
+
+if (ss->cache) {
+  copy_v3_v3(view_normal, ss->cache->view_normal);
+}
+else {
+  copy_v3_v3(view_normal, ss->filter_cache->view_normal);
+}
+
 /* PAINT_FALLOFF_SHAPE_TUBE */
-plane_from_point_normal_v3(test->plane_view, test->location, 
ss->cache->view_normal);
+plane_from_point_normal_v3(test->plane_view, test->location, view_normal);
 sculpt_brush_test_sq_fn = SCULPT_brush_test_circle_sq;
   }
   return sculpt_brush_test_sq_fn;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2e1a479e290] blender-v3.4-release: Sculpt: fix T102664: Broken multires solid shading

2022-11-28 Thread Joseph Eagar
Commit: 2e1a479e290aa703b31bbc59439af63299fec82c
Author: Joseph Eagar
Date:   Mon Nov 28 12:35:20 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB2e1a479e290aa703b31bbc59439af63299fec82c

Sculpt: fix T102664: Broken multires solid shading

Calculate quad normal directly instead of averaging
the vertex normals.

===

M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 6c504e63511..2a13072ce83 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -374,12 +374,13 @@ struct PBVHBatches {
 no = CCG_elem_no(>ccg_key, elems[0]);
   }
   else {
-for (int j = 0; j < 4; j++) {
-  no += CCG_elem_no(>ccg_key, elems[j]);
-}
+normal_quad_v3(no,
+   CCG_elem_co(>ccg_key, elems[3]),
+   CCG_elem_co(>ccg_key, elems[2]),
+   CCG_elem_co(>ccg_key, elems[1]),
+   CCG_elem_co(>ccg_key, elems[0]));
   }
 
-  normalize_v3(no);
   short sno[3];
 
   normal_float_to_short_v3(sno, no);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b1cc2a48f2a] blender-v3.4-release: Sculpt: fix T102348: Don't fold area normal automasking into cache

2022-11-28 Thread Joseph Eagar
Commit: b1cc2a48f2a57d4020b562f7d428ca8ed553b451
Author: Joseph Eagar
Date:   Mon Nov 28 12:59:53 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rBb1cc2a48f2a57d4020b562f7d428ca8ed553b451

Sculpt: fix T102348: Don't fold area normal automasking into cache

Certain automasking modes build a factor cache.  Modes
that rely on the mirror symmetry pass should not fold into
this pass.

===

M   source/blender/editors/sculpt_paint/sculpt_automasking.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 211ff14c906..e490cb762fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -185,9 +185,8 @@ static bool SCULPT_automasking_needs_factors_cache(const 
Sculpt *sd, const Brush
 return true;
   }
 
-  if (automasking_flags &
-  (BRUSH_AUTOMASKING_BOUNDARY_EDGES | BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS 
|
-   BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL)) {
+  if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES |
+   BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | 
BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 return brush && brush->automasking_boundary_edges_propagation_steps != 1;
   }
   return false;
@@ -507,6 +506,16 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 return 1.0f;
   }
 
+  float mask = 1.0f;
+
+  /* Since brush normal mode depends on the current mirror symmery pass
+   * it is not folded into the factor cache (when it exists).
+   */
+  if ((ss->cache || ss->filter_cache) &&
+  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
+mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
+  }
+
   /* If the cache is initialized with valid info, use the cache. This is used 
when the
* automasking information can't be computed in real time per vertex and 
needs to be
* initialized for the whole mesh when the stroke starts. */
@@ -517,7 +526,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
   factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
 }
 
-return factor;
+return factor * mask;
   }
 
   uchar stroke_id = ss->attrs.automasking_stroke_id ?
@@ -554,13 +563,6 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 }
   }
 
-  float mask = 1.0f;
-
-  if ((ss->cache || ss->filter_cache) &&
-  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
-mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
-  }
-
   if ((ss->cache || ss->filter_cache) &&
   (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 mask *= automasking_view_normal_factor(automasking, ss, vert, 
automask_data);
@@ -782,9 +784,6 @@ static void 
sculpt_normal_occlusion_automasking_fill(AutomaskingCache *automaski
 
 float f = *(float *)SCULPT_vertex_attr_get(vertex, 
ss->attrs.automasking_factor);
 
-if (int(mode) & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
-  f *= automasking_brush_normal_factor(automasking, ss, vertex, );
-}
 if (int(mode) & BRUSH_AUTOMASKING_VIEW_NORMAL) {
   if (int(mode) & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
 f *= automasking_view_occlusion_factor(automasking, ss, vertex, -1, 
);
@@ -940,8 +939,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, 
Brush *brush, Object
 
   /* Subtractive modes. */
   int normal_bits = sculpt_automasking_mode_effective_bits(sd, brush) &
-(BRUSH_AUTOMASKING_BRUSH_NORMAL | 
BRUSH_AUTOMASKING_VIEW_NORMAL |
- BRUSH_AUTOMASKING_VIEW_OCCLUSION);
+(BRUSH_AUTOMASKING_VIEW_NORMAL | 
BRUSH_AUTOMASKING_VIEW_OCCLUSION);
 
   if (normal_bits) {
 sculpt_normal_occlusion_automasking_fill(automasking, ob, 
(eAutomasking_flag)normal_bits);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0ed4865fd03] master: Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

2022-11-28 Thread Joseph Eagar
Commit: 0ed4865fd030ea169ab700843b06b747b06382be
Author: Joseph Eagar
Date:   Mon Nov 28 13:07:50 2022 -0800
Branches: master
https://developer.blender.org/rB0ed4865fd030ea169ab700843b06b747b06382be

Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

===

M   source/blender/editors/sculpt_paint/sculpt.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index e7dd7a92d3f..e1dac167a32 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -1832,14 +1832,27 @@ SculptBrushTestFn 
SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss,
 SculptBrushTest 
*test,
 char falloff_shape)
 {
+  if (!ss->cache && !ss->filter_cache) {
+falloff_shape = PAINT_FALLOFF_SHAPE_SPHERE;
+  }
+
   SCULPT_brush_test_init(ss, test);
   SculptBrushTestFn sculpt_brush_test_sq_fn;
   if (falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
 sculpt_brush_test_sq_fn = SCULPT_brush_test_sphere_sq;
   }
   else {
+float view_normal[3];
+
+if (ss->cache) {
+  copy_v3_v3(view_normal, ss->cache->view_normal);
+}
+else {
+  copy_v3_v3(view_normal, ss->filter_cache->view_normal);
+}
+
 /* PAINT_FALLOFF_SHAPE_TUBE */
-plane_from_point_normal_v3(test->plane_view, test->location, 
ss->cache->view_normal);
+plane_from_point_normal_v3(test->plane_view, test->location, view_normal);
 sculpt_brush_test_sq_fn = SCULPT_brush_test_circle_sq;
   }
   return sculpt_brush_test_sq_fn;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1fc5dc3bf38] master: Sculpt: fix T102664: Broken multires solid shading

2022-11-28 Thread Joseph Eagar
Commit: 1fc5dc3bf3827e0bec2fe70d557280497730dc5a
Author: Joseph Eagar
Date:   Mon Nov 28 12:35:20 2022 -0800
Branches: master
https://developer.blender.org/rB1fc5dc3bf3827e0bec2fe70d557280497730dc5a

Sculpt: fix T102664: Broken multires solid shading

Calculate quad normal directly instead of averaging
the vertex normals.

===

M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 39d493003c2..cac3e3339fc 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -375,12 +375,13 @@ struct PBVHBatches {
 no = CCG_elem_no(>ccg_key, elems[0]);
   }
   else {
-for (int j = 0; j < 4; j++) {
-  no += CCG_elem_no(>ccg_key, elems[j]);
-}
+normal_quad_v3(no,
+   CCG_elem_co(>ccg_key, elems[3]),
+   CCG_elem_co(>ccg_key, elems[2]),
+   CCG_elem_co(>ccg_key, elems[1]),
+   CCG_elem_co(>ccg_key, elems[0]));
   }
 
-  normalize_v3(no);
   short sno[3];
 
   normal_float_to_short_v3(sno, no);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0ad8f3ff585] master: Sculpt: fix T102348: Don't fold area normal automasking into cache

2022-11-28 Thread Joseph Eagar
Commit: 0ad8f3ff585c9693bb0cc84108ced00e8e0e1771
Author: Joseph Eagar
Date:   Mon Nov 28 12:59:53 2022 -0800
Branches: master
https://developer.blender.org/rB0ad8f3ff585c9693bb0cc84108ced00e8e0e1771

Sculpt: fix T102348: Don't fold area normal automasking into cache

Certain automasking modes build a factor cache.  Modes
that rely on the mirror symmetry pass should not fold into
this pass.

===

M   source/blender/editors/sculpt_paint/sculpt_automasking.cc

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 211ff14c906..e490cb762fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -185,9 +185,8 @@ static bool SCULPT_automasking_needs_factors_cache(const 
Sculpt *sd, const Brush
 return true;
   }
 
-  if (automasking_flags &
-  (BRUSH_AUTOMASKING_BOUNDARY_EDGES | BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS 
|
-   BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL)) {
+  if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES |
+   BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | 
BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 return brush && brush->automasking_boundary_edges_propagation_steps != 1;
   }
   return false;
@@ -507,6 +506,16 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 return 1.0f;
   }
 
+  float mask = 1.0f;
+
+  /* Since brush normal mode depends on the current mirror symmery pass
+   * it is not folded into the factor cache (when it exists).
+   */
+  if ((ss->cache || ss->filter_cache) &&
+  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
+mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
+  }
+
   /* If the cache is initialized with valid info, use the cache. This is used 
when the
* automasking information can't be computed in real time per vertex and 
needs to be
* initialized for the whole mesh when the stroke starts. */
@@ -517,7 +526,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
   factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
 }
 
-return factor;
+return factor * mask;
   }
 
   uchar stroke_id = ss->attrs.automasking_stroke_id ?
@@ -554,13 +563,6 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 }
   }
 
-  float mask = 1.0f;
-
-  if ((ss->cache || ss->filter_cache) &&
-  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
-mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
-  }
-
   if ((ss->cache || ss->filter_cache) &&
   (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 mask *= automasking_view_normal_factor(automasking, ss, vert, 
automask_data);
@@ -782,9 +784,6 @@ static void 
sculpt_normal_occlusion_automasking_fill(AutomaskingCache *automaski
 
 float f = *(float *)SCULPT_vertex_attr_get(vertex, 
ss->attrs.automasking_factor);
 
-if (int(mode) & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
-  f *= automasking_brush_normal_factor(automasking, ss, vertex, );
-}
 if (int(mode) & BRUSH_AUTOMASKING_VIEW_NORMAL) {
   if (int(mode) & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
 f *= automasking_view_occlusion_factor(automasking, ss, vertex, -1, 
);
@@ -940,8 +939,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, 
Brush *brush, Object
 
   /* Subtractive modes. */
   int normal_bits = sculpt_automasking_mode_effective_bits(sd, brush) &
-(BRUSH_AUTOMASKING_BRUSH_NORMAL | 
BRUSH_AUTOMASKING_VIEW_NORMAL |
- BRUSH_AUTOMASKING_VIEW_OCCLUSION);
+(BRUSH_AUTOMASKING_VIEW_NORMAL | 
BRUSH_AUTOMASKING_VIEW_OCCLUSION);
 
   if (normal_bits) {
 sculpt_normal_occlusion_automasking_fill(automasking, ob, 
(eAutomasking_flag)normal_bits);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [81754a0fc52] master: Cleanup: remove else after return.

2022-11-24 Thread Joseph Eagar
Commit: 81754a0fc528a0934f37344bdfbe52933c780c0f
Author: Joseph Eagar
Date:   Thu Nov 24 09:56:05 2022 -0800
Branches: master
https://developer.blender.org/rB81754a0fc528a0934f37344bdfbe52933c780c0f

Cleanup: remove else after return.

===

M   source/blender/blenkernel/intern/pbvh.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 6b1bdeef4af..3e49382371f 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3563,9 +3563,8 @@ BLI_INLINE int face_iter_prim_to_face(PBVHFaceIter *fd, 
int prim_index)
   if (fd->subdiv_ccg_) {
 return BKE_subdiv_ccg_grid_to_face_index(fd->subdiv_ccg_, prim_index);
   }
-  else {
-return fd->looptri_[prim_index].poly;
-  }
+
+  return fd->looptri_[prim_index].poly;
 }
 
 static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [14a0fb0cc65] master: Merge branch 'blender-v3.4-release'

2022-11-24 Thread Joseph Eagar
Commit: 14a0fb0cc65daca0efaa8ef04d892e1c8a929b3a
Author: Joseph Eagar
Date:   Thu Nov 24 09:02:23 2022 -0800
Branches: master
https://developer.blender.org/rB14a0fb0cc65daca0efaa8ef04d892e1c8a929b3a

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [959f3cd6450] blender-v3.4-release: Sculpt: fix T102436: missing null pointer check in automasking code

2022-11-24 Thread Joseph Eagar
Commit: 959f3cd6450225a255839396029240f42817e61a
Author: Joseph Eagar
Date:   Thu Nov 24 08:53:15 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB959f3cd6450225a255839396029240f42817e61a

Sculpt: fix T102436: missing null pointer check in automasking code

===

M   source/blender/editors/sculpt_paint/sculpt_automasking.cc
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index f0b803ecfa1..211ff14c906 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -847,7 +847,10 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt 
*sd, Brush *brush, Object
 use_stroke_id = true;
 
 if (SCULPT_is_automasking_mode_enabled(sd, brush, 
BRUSH_AUTOMASKING_CAVITY_USE_CURVE)) {
-  BKE_curvemapping_init(brush->automasking_cavity_curve);
+  if (brush) {
+BKE_curvemapping_init(brush->automasking_cavity_curve);
+  }
+
   BKE_curvemapping_init(sd->automasking_cavity_curve);
 }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 7bc947fe215..46414cf6a0d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1356,6 +1356,7 @@ float SCULPT_automasking_factor_get(struct 
AutomaskingCache *automasking,
  * brushes and filter. */
 struct AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession 
*ss);
 
+/* Brush can be null. */
 struct AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush 
*brush, Object *ob);
 void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e3567aad0a6] master: Merge branch 'blender-v3.4-release'

2022-11-22 Thread Joseph Eagar
Commit: e3567aad0a6e63613b60dac6f233507d38321470
Author: Joseph Eagar
Date:   Tue Nov 22 12:49:48 2022 -0800
Branches: master
https://developer.blender.org/rBe3567aad0a6e63613b60dac6f233507d38321470

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0f3b3ee679a] master: Merge branch 'blender-v3.4-release'

2022-11-22 Thread Joseph Eagar
Commit: 0f3b3ee679a1b215ad979aa2a432419617ea42ea
Author: Joseph Eagar
Date:   Tue Nov 22 12:48:29 2022 -0800
Branches: master
https://developer.blender.org/rB0f3b3ee679a1b215ad979aa2a432419617ea42ea

Merge branch 'blender-v3.4-release'

===



===

diff --cc source/blender/blenkernel/intern/pbvh.c
index 796ffa8a62e,8fba781835f..6b1bdeef4af
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -3656,7 -3660,7 +3656,6 @@@ static void pbvh_face_iter_step(PBVHFac
fd->verts[i].i = ml->v;
  }
}
-   
 -
break;
  }
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [af8a449ca55] blender-v3.4-release: blender-v3.4-release: fix more merge discrepencies in pbvh.c

2022-11-22 Thread Joseph Eagar
Commit: af8a449ca55358bbf84611da2ec9b82b5b5d6664
Author: Joseph Eagar
Date:   Tue Nov 22 12:48:39 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rBaf8a449ca55358bbf84611da2ec9b82b5b5d6664

blender-v3.4-release: fix more merge discrepencies in pbvh.c

===

M   source/blender/blenkernel/intern/pbvh.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 8fba781835f..7d7641a7a54 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3572,7 +3572,7 @@ BLI_INLINE int face_iter_prim_to_face(PBVHFaceIter *fd, 
int prim_index)
   }
 }
 
-void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
+static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
 {
   if (do_step) {
 fd->i++;
@@ -3677,7 +3677,6 @@ void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, 
PBVHFaceIter *fd)
 
   fd->node_ = node;
   fd->pbvh_type_ = BKE_pbvh_type(pbvh);
-
   fd->verts = fd->verts_reserved_;
   fd->verts_size_ = PBVH_FACE_ITER_VERTS_RESERVED;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f5e99abb60b] blender-v3.4-release: blender-v3.4-release: Rearrange function order to fix merging

2022-11-22 Thread Joseph Eagar
Commit: f5e99abb60b4470e5a4d6c7659085d608699d805
Author: Joseph Eagar
Date:   Tue Nov 22 12:45:09 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rBf5e99abb60b4470e5a4d6c7659085d608699d805

blender-v3.4-release: Rearrange function order to fix merging

BKE_pbvh_sync_visibility_from_verts was in the wrong spot
relative to master, was leading to very nasty merge errors.

===

M   source/blender/blenkernel/intern/pbvh.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index f948749f7bb..8fba781835f 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3547,95 +3547,6 @@ int BKE_pbvh_debug_draw_gen_get(PBVHNode *node)
   return node->debug_draw_gen;
 }
 
-void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
-{
-  switch (pbvh->header.type) {
-case PBVH_FACES: {
-  BKE_mesh_flush_hidden_from_verts(mesh);
-  BKE_pbvh_update_hide_attributes_from_mesh(pbvh);
-  break;
-}
-case PBVH_BMESH: {
-  BMIter iter;
-  BMVert *v;
-  BMEdge *e;
-  BMFace *f;
-
-  BM_ITER_MESH (f, , pbvh->header.bm, BM_FACES_OF_MESH) {
-BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
-  }
-
-  BM_ITER_MESH (e, , pbvh->header.bm, BM_EDGES_OF_MESH) {
-BM_elem_flag_disable(e, BM_ELEM_HIDDEN);
-  }
-
-  BM_ITER_MESH (v, , pbvh->header.bm, BM_VERTS_OF_MESH) {
-if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
-  continue;
-}
-BMIter iter_l;
-BMLoop *l;
-
-BM_ITER_ELEM (l, _l, v, BM_LOOPS_OF_VERT) {
-  BM_elem_flag_enable(l->e, BM_ELEM_HIDDEN);
-  BM_elem_flag_enable(l->f, BM_ELEM_HIDDEN);
-}
-  }
-  break;
-}
-case PBVH_GRIDS: {
-  const MPoly *mp = BKE_mesh_polys(mesh);
-  const MLoop *mloop = BKE_mesh_loops(mesh);
-  CCGKey key = pbvh->gridkey;
-
-  bool *hide_poly = (bool *)CustomData_get_layer_named(
-  >pdata, CD_PROP_BOOL, ".hide_poly");
-
-  bool delete_hide_poly = true;
-  for (int face_index = 0; face_index < mesh->totpoly; face_index++, mp++) 
{
-const MLoop *ml = mloop + mp->loopstart;
-bool hidden = false;
-
-for (int loop_index = 0; !hidden && loop_index < mp->totloop; 
loop_index++, ml++) {
-  int grid_index = mp->loopstart + loop_index;
-
-  if (pbvh->grid_hidden[grid_index] &&
-  BLI_BITMAP_TEST(pbvh->grid_hidden[grid_index], key.grid_area - 
1)) {
-hidden = true;
-
-break;
-  }
-}
-
-if (hidden && !hide_poly) {
-  hide_poly = (bool *)CustomData_get_layer_named(>pdata, 
CD_PROP_BOOL, ".hide_poly");
-
-  if (!hide_poly) {
-CustomData_add_layer_named(
->pdata, CD_PROP_BOOL, CD_CONSTRUCT, NULL, mesh->totpoly, 
".hide_poly");
-
-hide_poly = (bool *)CustomData_get_layer_named(
->pdata, CD_PROP_BOOL, ".hide_poly");
-  }
-}
-
-if (hide_poly) {
-  delete_hide_poly = delete_hide_poly && !hidden;
-  hide_poly[face_index] = hidden;
-}
-  }
-
-  if (delete_hide_poly) {
-CustomData_free_layer_named(>pdata, ".hide_poly", mesh->totpoly);
-  }
-
-  BKE_mesh_flush_hidden_from_polys(mesh);
-  BKE_pbvh_update_hide_attributes_from_mesh(pbvh);
-  break;
-}
-  }
-}
-
 static void pbvh_face_iter_verts_reserve(PBVHFaceIter *fd, int verts_num)
 {
   if (verts_num >= fd->verts_size_) {
@@ -3820,3 +3731,92 @@ bool BKE_pbvh_face_iter_done(PBVHFaceIter *fd)
   return true;
   }
 }
+
+void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh *mesh)
+{
+  switch (pbvh->header.type) {
+case PBVH_FACES: {
+  BKE_mesh_flush_hidden_from_verts(mesh);
+  BKE_pbvh_update_hide_attributes_from_mesh(pbvh);
+  break;
+}
+case PBVH_BMESH: {
+  BMIter iter;
+  BMVert *v;
+  BMEdge *e;
+  BMFace *f;
+
+  BM_ITER_MESH (f, , pbvh->header.bm, BM_FACES_OF_MESH) {
+BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
+  }
+
+  BM_ITER_MESH (e, , pbvh->header.bm, BM_EDGES_OF_MESH) {
+BM_elem_flag_disable(e, BM_ELEM_HIDDEN);
+  }
+
+  BM_ITER_MESH (v, , pbvh->header.bm, BM_VERTS_OF_MESH) {
+if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
+  continue;
+}
+BMIter iter_l;
+BMLoop *l;
+
+BM_ITER_ELEM (l, _l, v, BM_LOOPS_OF_VERT) {
+  BM_elem_flag_enable(l->e, BM_ELEM_HIDDEN);
+  BM_elem_flag_enable(l->f, BM_ELEM_HIDDEN);
+}
+  }
+  break;
+}
+case PBV

  1   2   3   4   5   6   7   8   9   10   >