diff options
author | YimingWu <xp8110@outlook.com> | 2021-06-24 08:09:25 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2021-06-24 08:09:25 +0300 |
commit | de05e261ec1fe5687859c797b98d7fb65260f954 (patch) | |
tree | 1101d902f2409c28f9077e58c7939b5f6d93aab9 /source/blender/gpencil_modifiers | |
parent | f7fbb518c8194e0a416321f5856e947d5592e131 (diff) |
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
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 3796e374db7..c00bd7c1cb5 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -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. */ |