Commit: 43f5ae0cea4ef37e92e11dfbff3db8c5ab034983 Author: YimingWu Date: Thu May 6 11:00:46 2021 +0800 Branches: temp-lineart-contained https://developer.blender.org/rB43f5ae0cea4ef37e92e11dfbff3db8c5ab034983
LineArt: Floating edge type. =================================================================== M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c M source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c M source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h M source/blender/makesdna/DNA_lineart_types.h M source/blender/makesrna/intern/rna_gpencil_modifier.c =================================================================== diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index f7d05cca77f..f3d09d9af45 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -291,6 +291,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayout *col = uiLayoutColumnWithHeading(layout, true, IFACE_("Edge Types")); uiItemR(col, ptr, "use_contour", 0, IFACE_("Contour"), ICON_NONE); + uiItemR(col, ptr, "use_floating", 0, IFACE_("Floating"), ICON_NONE); uiItemR(col, ptr, "use_material", 0, IFACE_("Material Borders"), ICON_NONE); uiItemR(col, ptr, "use_edge_mark", 0, IFACE_("Edge Marks"), ICON_NONE); uiItemR(col, ptr, "use_intersection", 0, IFACE_("Intersections"), ICON_NONE); @@ -341,6 +342,7 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(layout, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE); uiItemR(layout, ptr, "use_object_instances", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "floating_as_contour", 0, NULL, ICON_NONE); } static void style_panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 0609ce74509..7a433c68d16 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -188,7 +188,7 @@ typedef struct LineartLineChainItem { /** For restoring position to 3d space */ float gpos[3]; float normal[3]; - char line_type; + unsigned char line_type; char occlusion; unsigned char transparency_mask; size_t index; @@ -257,32 +257,25 @@ typedef struct LineartRenderBuffer { int triangle_size; - unsigned int contour_count; - unsigned int contour_processed; LineartEdge *contour_managed; /** A single linked list (cast to #LinkNode). */ LineartEdge *contours; - unsigned int intersection_count; - unsigned int intersection_processed; LineartEdge *intersection_managed; LineartEdge *intersection_lines; - unsigned int crease_count; - unsigned int crease_processed; LineartEdge *crease_managed; LineartEdge *crease_lines; - unsigned int material_line_count; - unsigned int material_processed; LineartEdge *material_managed; LineartEdge *material_lines; - unsigned int edge_mark_count; - unsigned int edge_mark_processed; LineartEdge *edge_mark_managed; LineartEdge *edge_marks; + LineartEdge *floating_managed; + LineartEdge *floating_lines; + ListBase chains; /* For managing calculation tasks for multiple threads. */ @@ -302,11 +295,13 @@ typedef struct LineartRenderBuffer { bool use_material; bool use_edge_marks; bool use_intersections; + bool use_floating; bool fuzzy_intersections; bool fuzzy_everything; bool allow_boundaries; bool allow_overlapping_edges; bool remove_doubles; + bool floating_as_contour; /* Keep an copy of these data so when line art is running it's self-contained. */ bool cam_is_persp; @@ -381,6 +376,9 @@ typedef struct LineartRenderTaskInfo { LineartEdge *edge_mark; LineartEdge *edge_mark_end; + LineartEdge *floating; + LineartEdge *floating_end; + } LineartRenderTaskInfo; struct BMesh; @@ -408,6 +406,8 @@ typedef struct LineartObjectInfo { LineartEdge *edge_mark_last; LineartEdge *intersection; LineartEdge *intersection_last; + LineartEdge *floating; + LineartEdge *floating_last; } LineartObjectInfo; typedef struct LineartObjectLoadTaskInfo { diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 094ca5332df..1083c5a070f 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -420,6 +420,7 @@ static int lineart_occlusion_make_task_info(LineartRenderBuffer *rb, LineartRend LRT_ASSIGN_OCCLUSION_TASK(crease); LRT_ASSIGN_OCCLUSION_TASK(material); LRT_ASSIGN_OCCLUSION_TASK(edge_mark); + LRT_ASSIGN_OCCLUSION_TASK(floating); #undef LRT_ASSIGN_OCCLUSION_TASK @@ -454,6 +455,10 @@ static void lineart_occlusion_worker(TaskPool *__restrict UNUSED(pool), LineartR for (eip = rti->edge_mark; eip && eip != rti->edge_mark_end; eip = eip->next) { lineart_occlusion_single_line(rb, eip, rti->thread_id); } + + for (eip = rti->floating; eip && eip != rti->floating_end; eip = eip->next) { + lineart_occlusion_single_line(rb, eip, rti->thread_id); + } } } @@ -474,6 +479,7 @@ static void lineart_main_occlusion_begin(LineartRenderBuffer *rb) rb->intersection_managed = rb->intersection_lines; rb->material_managed = rb->material_lines; rb->edge_mark_managed = rb->edge_marks; + rb->floating_managed = rb->floating_lines; TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH); @@ -1402,6 +1408,12 @@ static char lineart_identify_feature_line(LineartRenderBuffer *rb, lr = e->l->radial_next; } + if (!ll && !lr) { + if (!rb->floating_as_contour) { + return LRT_EDGE_FLAG_FLOATING; + } + } + if (ll == lr || !lr) { return LRT_EDGE_FLAG_CONTOUR; } @@ -1471,6 +1483,9 @@ static void lineart_add_edge_to_list(LineartRenderBuffer *rb, LineartEdge *e) case LRT_EDGE_FLAG_INTERSECTION: lineart_prepend_edge_direct(&rb->intersection_lines, e); break; + case LRT_EDGE_FLAG_FLOATING: + lineart_prepend_edge_direct(&rb->floating_lines, e); + break; } } @@ -1507,6 +1522,12 @@ static void lineart_add_edge_to_list_thread(LineartObjectInfo *obi, LineartEdge obi->intersection_last = e; } break; + case LRT_EDGE_FLAG_FLOATING: + lineart_prepend_edge_direct(&obi->floating, e); + if (!obi->floating_last) { + obi->floating_last = e; + } + break; } } @@ -1532,6 +1553,10 @@ static void lineart_finalize_object_edge_list(LineartRenderBuffer *rb, LineartOb obi->intersection_last->next = rb->intersection_lines; rb->intersection_lines = obi->intersection; } + if (obi->floating_last) { + obi->floating_last->next = rb->floating_lines; + rb->floating_lines = obi->floating; + } } static void lineart_triangle_adjacent_assign(LineartTriangle *rt, @@ -2717,8 +2742,6 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb, } } - rb->intersection_count++; - return result; } @@ -2805,16 +2828,12 @@ static void lineart_destroy_render_data(LineartRenderBuffer *rb) return; } - rb->contour_count = 0; rb->contour_managed = NULL; - rb->intersection_count = 0; rb->intersection_managed = NULL; - rb->material_line_count = 0; rb->material_managed = NULL; - rb->crease_count = 0; rb->crease_managed = NULL; - rb->edge_mark_count = 0; rb->edge_mark_managed = NULL; + rb->floating_managed = NULL; rb->contours = NULL; rb->intersection_lines = NULL; @@ -2916,6 +2935,7 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene, rb->fuzzy_everything = (lmd->calculation_flags & LRT_EVERYTHING_AS_CONTOUR) != 0; rb->allow_boundaries = (lmd->calculation_flags & LRT_ALLOW_CLIPPING_BOUNDARIES) != 0; rb->remove_doubles = (lmd->calculation_flags & LRT_REMOVE_DOUBLES) != 0; + rb->floating_as_contour = (lmd->calculation_flags & LRT_FLOATING_AS_CONTOUR) != 0; /* See lineart_edge_from_triangle() for how this option may impact performance. */ rb->allow_overlapping_edges = (lmd->calculation_flags & LRT_ALLOW_OVERLAPPING_EDGES) != 0; @@ -2925,6 +2945,7 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene, rb->use_material = (lmd->edge_types_override & LRT_EDGE_FLAG_MATERIAL) != 0; rb->use_edge_marks = (lmd->edge_types_override & LRT_EDGE_FLAG_EDGE_MARK) != 0; rb->use_intersections = (lmd->edge_types_override & LRT_EDGE_FLAG_INTERSECTION) != 0; + rb->use_floating = (lmd->edge_types_override & LRT_EDGE_FLAG_FLOATING) != 0; rb->chain_data_pool = &lc->chain_data_pool; @@ -4030,6 +4051,7 @@ static int lineart_rb_edge_types(LineartRenderBuffer *rb) types |= rb->use_material ? LRT_EDGE_FLAG_MATERIAL : 0; types |= rb->use_edge_marks ? LRT_EDGE_FLAG_EDGE_MARK : 0; types |= rb->use_intersections ? LRT_EDGE_FLAG_INTERSECTION : 0; + types |= rb->use_floating ? LRT_EDGE_FLAG_FLOATING : 0; return types; } diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h index 9562d52a336..ce4b3bd6726 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h @@ -102,6 +102,9 @@ void lineart_count_and_print_render_buffer_memory(struct LineartRenderBuffer *rb else if (current_list == &rb->edge_marks) { \ current_list = &rb->intersection_lines; \ } \ + else if (current_list == &rb->intersection_lines) { \ + current_list = &rb->floating_lines; \ + } \ else { \ break; \ } \ diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h index 860a6579bf7..80994c20818 100644 --- a/source/blender/makesdna/DNA_lineart_types.h +++ b/source/blender/makesdna/DNA_lineart_types.h @@ -46,6 +46,7 @@ typedef enum eLineartMainFlags { LRT_ALLOW_OVERLAPPING_EDGES = (1 << 3), LRT_ALLOW_CLIPPING_BOUNDARIES = (1 << 4), LRT_REMOVE_DOUBLES = (1 << 5), + LRT_FLOATING_AS_CONTOUR = (1 << 6), } eLineartMainFlags; typedef enum eLineartEdgeFlag { diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index ef6dfcfa4f1..59729863399 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -2749,6 +2749,11 @@ static void rna_def_modifier_gpencillineart(Ble @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs