[Bf-blender-cvs] [9c2c3e1dd14] lineart-bvh: Merge branch 'temp-lineart-contained' into lineart-bvh
YimingWu
noreply at git.blender.org
Wed Jun 16 16:28:31 CEST 2021
Commit: 9c2c3e1dd14560c9b85e8d8c8d03f51ee3196270
Author: YimingWu
Date: Tue Jun 15 16:51:16 2021 +0800
Branches: lineart-bvh
https://developer.blender.org/rB9c2c3e1dd14560c9b85e8d8c8d03f51ee3196270
Merge branch 'temp-lineart-contained' into lineart-bvh
===================================================================
===================================================================
diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index ed54120b4d7,cee93b11d26..cf283c0f691
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@@ -1317,16 -1320,14 +1323,16 @@@ static void lineart_main_cull_triangles
}
/* Then go through all the other triangles. */
- LISTBASE_FOREACH (LineartElementLinkNode *, reln, &rb->triangle_buffer_pointers) {
- rb->bvh_face_count += reln->element_count;
+ LISTBASE_FOREACH (LineartElementLinkNode *, eln, &rb->triangle_buffer_pointers) {
++ rb->bvh_face_count += eln->element_count;
+ rb->bvh_inderxer_count++;
- if (reln->flags & LRT_ELEMENT_IS_ADDITIONAL) {
+ if (eln->flags & LRT_ELEMENT_IS_ADDITIONAL) {
continue;
}
- ob = reln->object_ref;
- for (i = 0; i < reln->element_count; i++) {
+ ob = eln->object_ref;
+ for (i = 0; i < eln->element_count; i++) {
/* Select the triangle in the array. */
- rt = (void *)(((uchar *)reln->pointer) + rb->triangle_size * i);
+ tri = (void *)(((uchar *)eln->pointer) + rb->triangle_size * i);
LRT_CULL_DECIDE_INSIDE
LRT_CULL_ENSURE_MEMORY
@@@ -3486,11 -3553,9 +3568,11 @@@ static void lineart_bounding_area_link_
recursive_level < rb->tile_recursive_level) {
lineart_bounding_area_split(rb, root_ba, recursive_level);
}
+#ifndef LINEART_WITH_BVH
if (recursive && do_intersection && rb->use_intersections) {
- lineart_triangle_intersect_in_bounding_area(rb, rt, root_ba);
+ lineart_triangle_intersect_in_bounding_area(rb, tri, root_ba);
}
+#endif
}
else {
LineartBoundingArea *ba = root_ba->child;
@@@ -3757,40 -3822,16 +3839,40 @@@ static void lineart_main_add_triangles(
int i, lim;
int x1, x2, y1, y2;
int r, co;
+ int i_indexer = 0, i_triangle = 0;
+
+#ifdef LINEART_WITH_BVH
+ if (rb->use_intersections) {
+ rb->bvh_main = BLI_bvhtree_new(rb->bvh_face_count, 0, 8, 6);
+ rb->bvh_triangle_indexer = lineart_mem_acquire(
+ &rb->render_data_pool, sizeof(LineartTriangleBufferIndexer) * rb->bvh_inderxer_count);
+ }
+#endif
- LISTBASE_FOREACH (LineartElementLinkNode *, reln, &rb->triangle_buffer_pointers) {
- rt = reln->pointer;
- lim = reln->element_count;
+ LISTBASE_FOREACH (LineartElementLinkNode *, eln, &rb->triangle_buffer_pointers) {
+ tri = eln->pointer;
+ lim = eln->element_count;
+#ifdef LINEART_WITH_BVH
+ if (rb->use_intersections) {
- rb->bvh_triangle_indexer[i_indexer].eln = reln;
++ rb->bvh_triangle_indexer[i_indexer].eln = eln;
+ rb->bvh_triangle_indexer[i_indexer].start_index = i_triangle;
+ rb->bvh_triangle_indexer[i_indexer].end_index = i_triangle + lim;
+ }
+ i_indexer++;
+#endif
for (i = 0; i < lim; i++) {
- if ((rt->flags & LRT_CULL_USED) || (rt->flags & LRT_CULL_DISCARD)) {
- rt = (void *)(((uchar *)rt) + rb->triangle_size);
+ if ((tri->flags & LRT_CULL_USED) || (tri->flags & LRT_CULL_DISCARD)) {
+ tri = (void *)(((uchar *)tri) + rb->triangle_size);
continue;
}
+
+#ifdef LINEART_WITH_BVH
+ float bounding[6];
+ lineart_triangle_bbox(rt, bounding);
+ BLI_bvhtree_insert(rb->bvh_main, i_triangle + i, bounding, 2);
+#endif
+
- if (lineart_get_triangle_bounding_areas(rb, rt, &y1, &y2, &x1, &x2)) {
+ if (lineart_get_triangle_bounding_areas(rb, tri, &y1, &y2, &x1, &x2)) {
for (co = x1; co <= x2; co++) {
for (r = y1; r <= y2; r++) {
lineart_bounding_area_link_triangle(rb,
@@@ -3803,9 -3844,8 +3885,9 @@@
}
}
} /* Else throw away. */
- rt = (void *)(((uchar *)rt) + rb->triangle_size);
+ tri = (void *)(((uchar *)tri) + rb->triangle_size);
}
+ i_triangle += lim;
}
}
More information about the Bf-blender-cvs
mailing list