Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2022-10-07 00:03:17 +0300
committerJoseph Eagar <joeedh@gmail.com>2022-10-07 00:04:12 +0300
commitdfa0eb298ed3fa08cc70a472eb9427b515040457 (patch)
tree1db5978f7febd6a656c3d97be80bc5b8304dec27
parenteae3fa8730dfa820a81c0f1fb95d4df601408639 (diff)
Sculpt: Fix T101502: GPU tris miscounted for dyntopo
Dyntopo PBVH draw was miscounting the number of triangles.
-rw-r--r--source/blender/draw/intern/draw_pbvh.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc
index 6b807222079..02e7f937987 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -707,26 +707,14 @@ struct PBVHBatches {
}
BMLoop *l = f->l_first;
- do {
- callback(l);
- } while ((l = l->next) != f->l_first);
+ callback(l->prev);
+ callback(l);
+ callback(l->next);
}
GSET_FOREACH_END();
};
- faces_count = 0;
- GSET_FOREACH_BEGIN (BMFace *, f, args->bm_faces) {
- if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
- continue;
- }
-
- BMLoop *l = f->l_first;
- do {
- faces_count++;
- } while ((l = l->next) != f->l_first);
- }
- GSET_FOREACH_END();
- tris_count = faces_count;
+ faces_count = tris_count = count_faces(args);
int existing_num = GPU_vertbuf_get_vertex_len(vbo.vert_buf);
void *existing_data = GPU_vertbuf_get_data(vbo.vert_buf);
@@ -741,7 +729,24 @@ struct PBVHBatches {
GPUVertBufRaw access;
GPU_vertbuf_attr_get_raw_data(vbo.vert_buf, 0, &access);
+#if 0 /* Enable to fuzz gpu data (to check for overallocation). */
+ existing_data = GPU_vertbuf_get_data(vbo.vert_buf);
+ uchar *c = static_cast<uchar *>(existing_data);
+ for (int i : IndexRange(vert_count * access.stride)) {
+ *c++ = i & 255;
+ }
+#endif
+
switch (vbo.type) {
+ case CD_PROP_COLOR:
+ case CD_PROP_BYTE_COLOR: {
+ ushort4 white = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
+
+ foreach_bmesh([&](BMLoop * /*l*/) {
+ *static_cast<ushort4 *>(GPU_vertbuf_raw_step(&access)) = white;
+ });
+ break;
+ }
case CD_PBVH_CO_TYPE:
foreach_bmesh(
[&](BMLoop *l) { *static_cast<float3 *>(GPU_vertbuf_raw_step(&access)) = l->v->co; });