Line Art: Discard out of frame edges.

For scenes that have a lot of edges, this could potentially
save some time generating individual strokes that are outside
camera frustum.

Reviewed By: Sebastian Parborg (zeddb)

Differential Revision: https://developer.blender.org/D11525
This commit is contained in:
YimingWu 2021-06-24 13:09:25 +08:00
parent f7fbb518c8
commit de05e261ec
3 changed files with 22 additions and 2 deletions

@ -1 +1 @@
Subproject commit ab283053ab455f76f5620b59b823e73bd9f601ce
Subproject commit 4833954c0ac85cc407e1d5a153aa11b1d1823ec0

@ -1 +1 @@
Subproject commit ec07ed4c2e0495bea7fbe0b546d25e35211506a9
Subproject commit f86f25e62217264495d05f116ccb09d575fe9841

View File

@ -1372,6 +1372,24 @@ static void lineart_main_perspective_division(LineartRenderBuffer *rb)
}
}
static void lineart_main_discard_out_of_frame_edges(LineartRenderBuffer *rb)
{
LineartEdge *e;
int i;
#define LRT_VERT_OUT_OF_BOUND(v) \
(v && (v->fbcoord[0] < -1 || v->fbcoord[0] > 1 || v->fbcoord[1] < -1 || v->fbcoord[1] > 1))
LISTBASE_FOREACH (LineartElementLinkNode *, eln, &rb->line_buffer_pointers) {
e = (LineartEdge *)eln->pointer;
for (i = 0; i < eln->element_count; i++) {
if ((LRT_VERT_OUT_OF_BOUND(e[i].v1) && LRT_VERT_OUT_OF_BOUND(e[i].v2))) {
e[i].flags = LRT_EDGE_FLAG_CHAIN_PICKED;
}
}
}
}
/**
* Transform a single vert to it's viewing position.
*/
@ -3911,6 +3929,8 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph,
/* Do the perspective division after clipping is done. */
lineart_main_perspective_division(rb);
lineart_main_discard_out_of_frame_edges(rb);
/* Triangle intersections are done here during sequential adding of them. Only after this,
* triangles and lines are all linked with acceleration structure, and the 2D occlusion stage
* can do its job. */