diff options
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index e9f398093a7..477b99d85d0 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -875,7 +875,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb, * (!in0) means "when point 0 is visible". * conditions for point 1, 2 are the same idea. * - * \code{.txt} + * \code{.txt}identify * 1-----|-------0 * | | --- * | |--- @@ -1807,6 +1807,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu mat->lineart.mat_occlusion : 1); + tri->intersection_mask = obi->override_intersection_mask; + double gn[3]; copy_v3db_v3fl(gn, f->no); mul_v3_mat3_m4v3_db(tri->gn, normal, gn); @@ -1945,13 +1947,30 @@ static bool _lineart_object_not_in_source_collection(Collection *source, Object return true; } +static uchar lineart_intersection_mask_check(Collection *c, Object *ob) +{ + LISTBASE_FOREACH (CollectionChild *, cc, &c->children) { + uchar result = lineart_intersection_mask_check(cc->collection, ob); + if (result) { + return result; + } + } + + if (c->children.first == NULL) { + if (BKE_collection_has_object(c, (Object *)(ob->id.orig_id))) { + if (c->lineart_flags & COLLECTION_LRT_USE_INTERSECTION_MASK) { + return c->lineart_intersection_mask; + } + } + } + return 0; +} + /** * See if this object in such collection is used for generating line art, * Disabling a collection for line art will doable all objects inside. - * `_rb` is used to provide source selection info. - * See the definition of `rb->_source_type` for details. */ -static int lineart_usage_check(Collection *c, Object *ob, LineartRenderBuffer *_rb) +static int lineart_usage_check(Collection *c, Object *ob) { if (!c) { @@ -1981,29 +2000,15 @@ static int lineart_usage_check(Collection *c, Object *ob, LineartRenderBuffer *_ } return ob->lineart.usage; } - return OBJECT_LRT_INHERIT; } LISTBASE_FOREACH (CollectionChild *, cc, &c->children) { - int result = lineart_usage_check(cc->collection, ob, _rb); + int result = lineart_usage_check(cc->collection, ob); if (result > OBJECT_LRT_INHERIT) { return result; } } - /* Temp solution to speed up calculation in the modifier without cache. See the definition of - * rb->_source_type for details. */ - if (_rb->_source_type == LRT_SOURCE_OBJECT) { - if (ob != _rb->_source_object && ob->id.orig_id != (ID *)_rb->_source_object) { - return OBJECT_LRT_OCCLUSION_ONLY; - } - } - else if (_rb->_source_type == LRT_SOURCE_COLLECTION) { - if (_lineart_object_not_in_source_collection(_rb->_source_collection, ob)) { - return OBJECT_LRT_OCCLUSION_ONLY; - } - } - return OBJECT_LRT_INHERIT; } @@ -2123,7 +2128,9 @@ static void lineart_main_load_geometries( DEG_OBJECT_ITER_BEGIN (depsgraph, ob, flags) { LineartObjectInfo *obi = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartObjectInfo)); - obi->usage = lineart_usage_check(scene->master_collection, ob, rb); + obi->usage = lineart_usage_check(scene->master_collection, ob); + obi->override_intersection_mask = lineart_intersection_mask_check(scene->master_collection, + ob); Mesh *use_mesh; if (obi->usage == OBJECT_LRT_EXCLUDE) { @@ -2841,6 +2848,7 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb, BLI_addtail(&result->segments, es); /* Don't need to OR flags right now, just a type mark. */ result->flags = LRT_EDGE_FLAG_INTERSECTION; + result->intersection_mask = (tri->intersection_mask | testing->intersection_mask); lineart_prepend_edge_direct(&rb->intersection.first, result); int r1, r2, c1, c2, row, col; @@ -4191,8 +4199,9 @@ static void lineart_gpencil_generate(LineartCache *cache, Object *source_object, Collection *source_collection, int types, - uchar material_mask_flags, + uchar mask_switches, uchar material_mask_bits, + uchar intersection_mask, short thickness, float opacity, const char *source_vgname, @@ -4248,8 +4257,8 @@ static void lineart_gpencil_generate(LineartCache *cache, continue; } } - if (material_mask_flags & LRT_GPENCIL_MATERIAL_MASK_ENABLE) { - if (material_mask_flags & LRT_GPENCIL_MATERIAL_MASK_MATCH) { + if (mask_switches & LRT_GPENCIL_MATERIAL_MASK_ENABLE) { + if (mask_switches & LRT_GPENCIL_MATERIAL_MASK_MATCH) { if (ec->material_mask_bits != material_mask_bits) { continue; } @@ -4260,6 +4269,18 @@ static void lineart_gpencil_generate(LineartCache *cache, } } } + if (types & LRT_EDGE_FLAG_INTERSECTION) { + if (mask_switches & LRT_GPENCIL_INTERSECTION_MATCH) { + if (ec->intersection_mask != intersection_mask) { + continue; + } + } + else { + if ((intersection_mask) && !(ec->intersection_mask & intersection_mask)) { + continue; + } + } + } /* Preserved: If we ever do asynchronous generation, this picked flag should be set here. */ // ec->picked = 1; @@ -4354,8 +4375,9 @@ void MOD_lineart_gpencil_generate(LineartCache *cache, int level_end, int mat_nr, short edge_types, - uchar material_mask_flags, + uchar mask_switches, uchar material_mask_bits, + uchar intersection_mask, short thickness, float opacity, const char *source_vgname, @@ -4403,8 +4425,9 @@ void MOD_lineart_gpencil_generate(LineartCache *cache, source_object, source_collection, use_types, - material_mask_flags, + mask_switches, material_mask_bits, + intersection_mask, thickness, opacity, source_vgname, |