[Bf-blender-cvs] [384a0930d1e] temp_bmesh_multires: Commit current code state
Joseph Eagar
noreply at git.blender.org
Thu Apr 15 03:42:26 CEST 2021
Commit: 384a0930d1eb5cbb444220bbcdbeab2888b10968
Author: Joseph Eagar
Date: Wed Apr 14 15:55:09 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB384a0930d1eb5cbb444220bbcdbeab2888b10968
Commit current code state
===================================================================
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/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_boundary.c
M source/blender/gpu/GPU_buffers.h
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index ef2b091630d..f3b813b4d08 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1286,6 +1286,8 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
PBVHNode *node = data->nodes[n];
if (node->flag & PBVH_RebuildDrawBuffers) {
+ node->updategen++;
+
switch (pbvh->type) {
case PBVH_GRIDS:
node->draw_buffers = GPU_pbvh_grid_buffers_build(node->totprim, pbvh->grid_hidden);
@@ -1309,6 +1311,7 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
}
if (node->flag & PBVH_UpdateDrawBuffers) {
+ node->updategen++;
const int update_flags = pbvh_get_buffers_update_flags(pbvh);
switch (pbvh->type) {
@@ -1337,11 +1340,13 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
update_flags);
break;
case PBVH_BMESH:
+ BKE_pbvh_bmesh_check_tris(pbvh, node);
GPU_pbvh_bmesh_buffers_update(node->draw_buffers,
pbvh->bm,
node->bm_faces,
node->bm_unique_verts,
node->bm_other_verts,
+ node->tribuf,
update_flags,
pbvh->cd_vert_node_offset,
pbvh->face_sets_color_seed,
@@ -2891,7 +2896,9 @@ void BKE_pbvh_draw_debug_cb(
for (int a = 0; a < pbvh->totnode; a++) {
PBVHNode *node = &pbvh->nodes[a];
- draw_fn(user_data, node->vb.bmin, node->vb.bmax, node->flag);
+ int num = a + node->updategen;
+
+ draw_fn(&num, node->vb.bmin, node->vb.bmax, node->flag);
}
}
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index a534e0c763d..ff46cf01244 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -2702,7 +2702,7 @@ bool BKE_pbvh_bmesh_check_origdata(PBVH *pbvh, BMVert *v, int stroke_id)
MDynTopoVert *mv = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert, v);
if (mv->stroke_id != stroke_id) {
- void *dummy;
+ float *dummy;
BKE_pbvh_bmesh_update_origvert(pbvh, v, &dummy, &dummy, &dummy, false);
mv->stroke_id = stroke_id;
@@ -2825,7 +2825,7 @@ bool BKE_pbvh_bmesh_node_raycast_detail(PBVH *pbvh,
BKE_pbvh_bmesh_check_tris(pbvh, node);
for (int i = 0; i < node->tribuf->tottri; i++) {
- PBVHTri *tri = node->tribuf + i;
+ PBVHTri *tri = node->tribuf->tris + i;
BMVert *v1 = (BMVert *)node->tribuf->verts[tri->v[0]].i;
BMVert *v2 = (BMVert *)node->tribuf->verts[tri->v[1]].i;
BMVert *v3 = (BMVert *)node->tribuf->verts[tri->v[2]].i;
@@ -2869,7 +2869,7 @@ bool pbvh_bmesh_node_nearest_to_ray(PBVH *pbvh,
const int cd_dyn_vert = pbvh->cd_dyn_vert;
for (int i = 0; i < tribuf->tottri; i++) {
- PBVHTri *tri = tribuf + i;
+ PBVHTri *tri = tribuf->tris + i;
BMFace *f = (BMFace *)tri->f.i;
if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
@@ -3736,7 +3736,7 @@ static bool pbvh_bmesh_split_tris(PBVH *pbvh, PBVHNode *node)
MLoopUV *uv1 = BM_ELEM_CD_GET_VOID_P(l, cd_uv + cd_size * i);
MLoopUV *uv2 = BM_ELEM_CD_GET_VOID_P(l2, cd_uv + cd_size * i);
- if (len_v3v3(uv1, uv2) > 0.001) {
+ if (len_v3v3(uv1->uv, uv2->uv) > 0.001) {
ok = false;
break;
}
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index 92631b9c4f9..d2f3050940d 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -109,6 +109,8 @@ struct PBVHNode {
PBVHTriBuf *tribuf;
+ int updategen;
+
/* Used to store the brush color during a stroke and composite it over the original color */
PBVHColorBufferNode color_buffer;
#ifdef PROXY_ADVANCED
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c454df1362b..4ef4429013b 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4518,6 +4518,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
const float bstrength = ss->cache->bstrength;
SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS);
+ bool update = false;
proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co;
@@ -4575,11 +4576,13 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
mul_v3_fl(final_disp, SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.vertex));
- copy_v3_v3(proxy[vd.i], final_disp);
-
- if (vd.mvert) {
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ if (dot_v3v3(final_disp, final_disp) > 0.0000001) {
+ if (vd.mvert) {
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
+
+ copy_v3_v3(proxy[vd.i], final_disp);
}
BKE_pbvh_vertex_iter_end;
}
@@ -6552,6 +6555,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
else {
for (int i = 0; i < totnode; i++) {
SCULPT_ensure_dyntopo_node_undo(ob, nodes[i], SCULPT_UNDO_COORDS, -1);
+
BKE_pbvh_node_mark_update(nodes[i]);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index 408050fda1b..b200e1c3a6f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -126,7 +126,7 @@ static SculptVertRef sculpt_boundary_get_closest_boundary_vertex(
BoundaryInitialVertexFloodFillData fdata = {
.initial_vertex = initial_vertex,
.initial_vertex_index = initial_vertex_index,
- .boundary_initial_vertex = BOUNDARY_VERTEX_NONE,
+ .boundary_initial_vertex = {BOUNDARY_VERTEX_NONE},
.boundary_initial_vertex_steps = INT_MAX,
.radius_sq = radius * radius,
};
@@ -297,7 +297,7 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
BoundaryFloodFillData fdata = {
.boundary = boundary,
.included_vertices = included_vertices,
- .last_visited_vertex = BOUNDARY_VERTEX_NONE,
+ .last_visited_vertex = {BOUNDARY_VERTEX_NONE},
};
@@ -414,7 +414,8 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
boundary->edit_info[ni.index].num_propagation_steps =
boundary->edit_info[from_v_i].num_propagation_steps + 1;
- BLI_gsqueue_push(next_iteration, &ni.index);
+ BLI_gsqueue_push(next_iteration, &ni.vertex);
+
/* When copying the data to the neighbor for the next iteration, it has to be copied to
* all its duplicates too. This is because it is not possible to know if the updated
@@ -569,6 +570,8 @@ SculptBoundary *SCULPT_boundary_data_init(Object *object,
void SCULPT_boundary_data_free(SculptBoundary *boundary)
{
+ printf(" ======================= boundary free!\n\n");
+
MEM_SAFE_FREE(boundary->vertices);
MEM_SAFE_FREE(boundary->edges);
MEM_SAFE_FREE(boundary->distance);
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index c3fb989a923..de87838cb62 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -93,6 +93,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
struct TableGSet *bm_faces,
struct TableGSet *bm_unique_verts,
struct TableGSet *bm_other_verts,
+ struct PBVHTriBuf *tribuf,
const int update_flags,
const int cd_vert_node_offset,
int face_sets_color_seed,
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index c7de4a45a6f..d8fd6ababeb 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -135,10 +135,11 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len)
if (buffers->vert_buf == NULL) {
/* Initialize vertex buffer (match 'VertexBufferFormat'). */
buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&g_vbo_id.format, GPU_USAGE_DYNAMIC);
- GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
}
- else if (vert_len != buffers->vert_buf->vertex_len) {
- GPU_vertbuf_data_resize(buffers->vert_buf, vert_len);
+ if (GPU_vertbuf_get_data(buffers->vert_buf) == NULL ||
+ GPU_vertbuf_get_vertex_len(buffers->vert_buf) != vert_len) {
+ /* Allocate buffer if not allocated yet or size changed. */
+ GPU_vertbuf_data_alloc(buffers->vert_buf, vert_len);
}
#else
if (buffers->vert_buf == NULL) {
@@ -817,34 +818,14 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v,
if (show_vcol && cd_vcol_offset >= 0) {
ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
- int col[4] = {0, 0, 0, 0};
- int tot = 0;
-
- BMIter iter;
- BMLoop *l;
+
+ MPropCol *col = BM_ELEM_CD_GET_VOID_P(v, cd_vcol_offset);
- BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) {
- MLoopCol *ml = BM_ELEM_CD_GET_VOID_P(l, cd_vcol_offset);
+ vcol[0] = unit_float_to_ushort_clamp(col->color[0]);
+ vcol[1] = unit_float_to_ushort_clamp(col->color[1]);
+ vcol[2] = unit_float_to_ushort_clamp(col->color[2]);
+ vcol[3] = unit_float_to_ushort_clamp(col->color[3]);
- col[0] += ml->r;
- col[1] += ml->g;
- col[2] += ml->b;
- col[3] += ml->a;
- tot++;
- }
-
- if (tot) {
- col[0] /= tot;
- col[1] /= tot;
- col[2] /= tot;
- col[3] /= tot;
-
- vcol[0] = (ushort)(col[0] * 257);
- vcol[1] = (ushort)(col[1] * 257);
- vcol[2] = (ushort)(col[2] * 257);
- vcol[3] = (ushort)(col[3] * 257);
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list