[Bf-blender-cvs] [86ee4dc571e] sculpt-dev: Sculpt: Fix customdata_regen_active_refs
Joseph Eagar
noreply at git.blender.org
Wed Oct 6 03:38:59 CEST 2021
Commit: 86ee4dc571ee838104a32cba0d41150a276d10d2
Author: Joseph Eagar
Date: Tue Oct 5 18:38:29 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB86ee4dc571ee838104a32cba0d41150a276d10d2
Sculpt: Fix customdata_regen_active_refs
===================================================================
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/dyntopo.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/bmesh/intern/bmesh_log.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index acdfe117931..b9975d3dd5b 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -953,6 +953,7 @@ void BKE_pbvh_update_vert_boundary_grids(PBVH *pbvh,
SculptVertRef vertex);
void BKE_pbvh_set_mdyntopo_verts(PBVH *pbvh, struct MDynTopoVert *mdyntopoverts);
+
#if 0
# include "DNA_meshdata_types.h"
ATTR_NO_OPT static void MV_ADD_FLAG(MDynTopoVert *mv, int flag)
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index e470251e496..2eed24b7139 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -74,7 +74,7 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(((CustomData *)NULL)->typemap) == CD_NUMTYPES, "siz
static CLG_LogRef LOG = {"bke.customdata"};
-bool CustomData_layout_is_same(const CustomData *_a, const CustomData *_b)
+ATTR_NO_OPT bool CustomData_layout_is_same(const CustomData *_a, const CustomData *_b)
{
CustomData a = *_a;
CustomData b = *_b;
@@ -2240,7 +2240,7 @@ void CustomData_update_typemap(CustomData *data)
}
}
-static void customdata_regen_active_refs(CustomData *data)
+void customdata_regen_active_refs(CustomData *data)
{
int i, j;
bool changed = false;
@@ -2251,24 +2251,34 @@ static void customdata_regen_active_refs(CustomData *data)
CustomDataLayer *base = data->layers + data->typemap[layer->type];
int n = layer - base;
+ if (layer == base) {
+ continue;
+ }
+
layer->active = n == base->active;
layer->active_clone = n == base->active_clone;
layer->active_mask = n == base->active_mask;
layer->active_rnd = n == base->active_rnd;
}
- /* regenerate active refs */
- for (i = 0; i < CD_NUMTYPES; i++) {
- if (data->typemap[i] != -1) {
- CustomDataLayer *base = data->layers + data->typemap[i];
-
- base->active = base->active_clone = base->active_mask = base->active_rnd = 0;
+ /* handle case of base layers being active */
+ for (int i = 0; i < CD_NUMTYPES; i++) {
+ if (data->typemap[i] == -1) {
+ continue;
}
+
+ CustomDataLayer *base = data->layers + data->typemap[i];
+
+ base->active = !base->active;
+ base->active_mask = !base->active_mask;
+ base->active_clone = !base->active_clone;
+ base->active_rnd = !base->active_rnd;
}
+ /* regenerate active refs */
/* set active n in base layer for all types */
for (i = 0; i < data->totlayer; i++) {
- CustomDataLayer *layer = &data->layers[i];
+ CustomDataLayer *layer = data->layers + i;
CustomDataLayer *base = data->layers + data->typemap[layer->type];
int n = layer - base;
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index 6223a748028..bf37ecb12ec 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -1598,11 +1598,15 @@ static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
#endif
/* Check if triangle intersects the sphere */
+#if 1
float dis = dist_to_tri_sphere_simple((float *)q->center,
(float *)l->v->co,
(float *)l->next->v->co,
(float *)l->prev->v->co,
(float *)f->no);
+#else
+ float dis = len_squared_v3v3(q->center, l->v->co);
+#endif
return dis <= q->radius_squared;
}
@@ -2593,14 +2597,14 @@ static void edge_queue_init(EdgeQueueContext *eq_ctx,
*
* The highest priority (lowest number) is given to the longest edge.
*/
-static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
- PBVH *pbvh,
- const float center[3],
- const float view_normal[3],
- float radius,
- const bool use_frontface,
- const bool use_projected,
- const bool local_mode)
+ATTR_NO_OPT static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
+ PBVH *pbvh,
+ const float center[3],
+ const float view_normal[3],
+ float radius,
+ const bool use_frontface,
+ const bool use_projected,
+ const bool local_mode)
{
if (local_mode) {
edge_queue_create_local(
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 160eb0f6b03..b4a4cdb6488 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -14,30 +14,30 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/** \file
- * \ingroup bli
- */
+ /** \file
+ * \ingroup bli
+ */
-/*
+ /*
-TODO:
+ TODO:
-Convergence improvements:
-1. DONE: Limit number of edges processed per run.
-2. DONE: Scale split steps by ratio of long to short edges to
- prevent runaway tesselation.
-3. DONE: Detect and dissolve three and four valence vertices that are surrounded by
- all tris.
-4. DONE: Use different (coarser) brush spacing for applying dyntopo
+ Convergence improvements:
+ 1. DONE: Limit number of edges processed per run.
+ 2. DONE: Scale split steps by ratio of long to short edges to
+ prevent runaway tesselation.
+ 3. DONE: Detect and dissolve three and four valence vertices that are surrounded by
+ all tris.
+ 4. DONE: Use different (coarser) brush spacing for applying dyntopo
-Drawing improvements:
-4. PARTIAL DONE: Build and cache vertex index buffers, to reduce GPU bandwidth
+ Drawing improvements:
+ 4. PARTIAL DONE: Build and cache vertex index buffers, to reduce GPU bandwidth
-Topology rake:
-5. DONE: Enable new curvature topology rake code and add to UI.
-6. DONE: Add code to cache curvature data per vertex in a CD layer.
+ Topology rake:
+ 5. DONE: Enable new curvature topology rake code and add to UI.
+ 6. DONE: Add code to cache curvature data per vertex in a CD layer.
-*/
+ */
#include "MEM_guardedalloc.h"
@@ -74,11 +74,11 @@ Topology rake:
#include <stdarg.h>
-static void _debugprint(const char *fmt, ...)
+static void _debugprint(const char *fmt,...)
{
va_list args;
- va_start(args, fmt);
- vprintf(fmt, args);
+ va_start(args,fmt);
+ vprintf(fmt,args);
va_end(args);
}
@@ -93,13 +93,13 @@ void pbvh_bmesh_check_nodes_simple(PBVH *pbvh)
continue;
}
- TGSET_ITER (f, node->bm_faces) {
+ TGSET_ITER (f,node->bm_faces) {
if (!f || f->head.htype != BM_FACE) {
_debugprint("Corrupted (freed?) face in node->bm_faces\n");
continue;
}
- if (BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset) != i) {
+ if (BM_ELEM_CD_GET_INT(f,pbvh->cd_face_node_offset) != i) {
_debugprint("Face in more then one node\n");
}
}
@@ -122,12 +122,12 @@ void pbvh_bmesh_check_nodes(PBVH *pbvh)
BMVert *v;
BMIter iter;
- BM_ITER_MESH (v, &iter, pbvh->bm, BM_VERTS_OF_MESH) {
- int ni = BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset);
+ BM_ITER_MESH (v,&iter,pbvh->bm,BM_VERTS_OF_MESH) {
+ int ni = BM_ELEM_CD_GET_INT(v,pbvh->cd_vert_node_offset);
if (ni >= 0 && !v->e || !v->e->l) {
_debugprint("wire vert had node reference\n");
- BM_ELEM_CD_SET_INT(v, pbvh->cd_vert_node_offset, DYNTOPO_NODE_NONE);
+ BM_ELEM_CD_SET_INT(v,pbvh->cd_vert_node_offset,DYNTOPO_NODE_NONE);
}
if (ni < -1 || ni >= pbvh->totnode) {
@@ -145,21 +145,21 @@ void pbvh_bmesh_check_nodes(PBVH *pbvh)
continue;
}
- if (!BLI_table_gset_haskey(node->bm_unique_verts, v)) {
+ if (!BLI_table_gset_haskey(node->bm_unique_verts,v)) {
_debugprint("vert not in node->bm_unique_verts\n");
}
- if (BLI_table_gset_haskey(node->bm_other_verts, v)) {
+ if (BLI_table_gset_haskey(node->bm_other_verts,v)) {
_debugprint("vert in node->bm_other_verts");
}
- MDynTopoVert *mv = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert, v);
- BKE_pbvh_bmesh_check_valence(pbvh, (SculptVertRef){.i = (intptr_t)v});
+ MDynTopoVert *mv = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert,v);
+ BKE_pbvh_bmesh_check_valence(pbvh,(SculptVertRef) { .i = (intptr_t)v });
if (BM_vert_edge_count(v) != mv->valence) {
_debugprint("cached vertex valence mismatch; old: %d, should be: %d\n",
- mv->valence,
- BM_vert_edge_count(v));
+ mv->valence,
+ BM_vert_edge_count(v));
}
}
@@ -181,48 +181,45 @@ void pbvh_bmesh_check_nodes(PBVH *pbvh)
continue;
}
- TGSET_ITER (v, node->bm_unique_verts) {
- int ni = BM_ELEM_CD_GET_INT(v, pbvh->cd_vert_node_offset);
+ TGSET_ITER (v,node->bm_unique_verts) {
+ int ni = BM_ELEM_CD_GET_INT(v,pbvh->cd_vert_node_offset);
if (ni != i) {
if (ni >= 0 && ni < pbvh->totnode) {
PBVHNode *node2 = pbvh->nodes + ni;
_debugprint("v node offset is wrong, %d\n",
- !node2->bm_unique_verts ? 0 :
- BLI_table_gset_haskey(node2->bm_unique_verts, v));
- }
- else {
+ !node2->bm_unique_verts ? 0 :
+ BLI_table_gset_haskey(node2->bm_unique_verts,v));
+ } else {
_debugprint("v node offset is wrong\n");
}
}
if (!v || v->head.htype != BM_VERT) {
_debugprint("corruption in pbvh! bm_unique_verts\n");
- }
- else if (BLI_table_gset_haskey(node->bm_other_verts, v)) {
+ } else if (BLI_table_gset_haskey(node->bm_other_verts,v)) {
_debugprint("v in both unique and other verts\n");
}
}
TGSET_ITER_END;
- TGSET_ITER (f, node
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list