[Bf-blender-cvs] [841df831e89] master: LineArt: More type & related chaining improvements
YimingWu
noreply at git.blender.org
Fri Jun 25 07:15:39 CEST 2021
Commit: 841df831e89dfc4011c323203c2efb8265dc1878
Author: YimingWu
Date: Fri Jun 25 13:15:25 2021 +0800
Branches: master
https://developer.blender.org/rB841df831e89dfc4011c323203c2efb8265dc1878
LineArt: More type & related chaining improvements
This patch includes: Floating edge type support,
Special chaining option for floating edge,
Chaining option for reducing jagged edges when floating
edges are involved.
Reviewed By: Sebastian Parborg (zeddb)
Differential Revision: https://developer.blender.org/D11306
===================================================================
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_chain.c
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_gpencil_modifier_types.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 f0aae7e4498..1f70ecb4595 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -305,6 +305,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);
@@ -312,7 +313,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayout *sub = uiLayoutRowWithHeading(col, false, IFACE_("Crease"));
uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE);
uiLayout *entry = uiLayoutRow(sub, false);
- uiLayoutSetActive(entry, RNA_boolean_get(ptr, "use_crease") || is_first);
+ uiLayoutSetEnabled(entry, RNA_boolean_get(ptr, "use_crease") || is_first);
if (use_cache && !is_first) {
uiItemL(entry, IFACE_("Angle Cached"), ICON_INFO);
}
@@ -368,6 +369,7 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiItemR(col, ptr, "use_edge_overlap", 0, IFACE_("Overlapping Edges As Contour"), ICON_NONE);
uiItemR(col, ptr, "use_object_instances", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "use_clip_plane_boundaries", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "allow_overlap_edge_types", 0, NULL, ICON_NONE);
}
static void style_panel_draw(const bContext *UNUSED(C), Panel *panel)
@@ -430,7 +432,7 @@ static void transparency_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropSep(layout, true);
- uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_transparency"));
+ uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_transparency"));
uiLayout *row = uiLayoutRow(layout, true);
uiLayoutSetPropDecorate(row, false);
@@ -457,6 +459,7 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
const bool use_cache = RNA_boolean_get(ptr, "use_cache");
const bool is_first = BKE_gpencil_is_first_lineart_in_stack(ob_ptr.data, ptr->data);
+ const bool is_geom = RNA_boolean_get(ptr, "chain_geometry_space");
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
@@ -469,8 +472,16 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayout *col = uiLayoutColumnWithHeading(layout, true, IFACE_("Chain"));
uiItemR(col, ptr, "use_fuzzy_intersections", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "use_fuzzy_all", 0, NULL, ICON_NONE);
-
- uiItemR(layout, ptr, "chaining_image_threshold", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "chain_floating_edges", 0, IFACE_("Floating Edges"), ICON_NONE);
+ uiItemR(col, ptr, "floating_as_contour", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "chain_geometry_space", 0, NULL, ICON_NONE);
+
+ uiItemR(layout,
+ ptr,
+ "chaining_image_threshold",
+ 0,
+ is_geom ? IFACE_("Geometry Threshold") : NULL,
+ ICON_NONE);
uiItemR(layout, ptr, "split_angle", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
}
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 72b73b4d174..a7f4231e4aa 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -189,7 +189,7 @@ typedef struct LineartEdgeChainItem {
/** 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;
@@ -267,6 +267,7 @@ typedef struct LineartRenderBuffer {
ListBase crease;
ListBase material;
ListBase edge_mark;
+ ListBase floating;
ListBase chains;
@@ -287,11 +288,16 @@ 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 allow_duplicated_types;
bool remove_doubles;
+ bool floating_as_contour;
+ bool chain_floating_edges;
+ bool chain_geometry_space;
/* Keep an copy of these data so when line art is running it's self-contained. */
bool cam_is_persp;
@@ -358,11 +364,10 @@ typedef struct LineartRenderTaskInfo {
ListBase crease;
ListBase material;
ListBase edge_mark;
+ ListBase floating;
} LineartRenderTaskInfo;
-struct BMesh;
-
typedef struct LineartObjectInfo {
struct LineartObjectInfo *next;
struct Object *original_ob;
@@ -370,7 +375,7 @@ typedef struct LineartObjectInfo {
double model_view_proj[4][4];
double model_view[4][4];
double normal[4][4];
- LineartElementLinkNode *v_reln;
+ LineartElementLinkNode *v_eln;
int usage;
int global_i_offset;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index 85a1dbb4df0..408e0081990 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -729,7 +729,8 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
}
}
- float new_len = len_v2v2(cre->eci->pos, eci->pos);
+ float new_len = rb->chain_geometry_space ? len_v3v3(cre->eci->gpos, eci->gpos) :
+ len_v2v2(cre->eci->pos, eci->pos);
if (new_len < dist) {
closest_cre = cre;
dist = new_len;
@@ -800,6 +801,10 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
}
BLI_addtail(&rb->chains, ec);
+ if (ec->type == LRT_EDGE_FLAG_FLOATING && (!rb->chain_floating_edges)) {
+ continue;
+ }
+
occlusion = ec->level;
transparency_mask = ec->transparency_mask;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index dffa6fce395..f2d1f6776ab 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -430,6 +430,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
@@ -464,6 +465,10 @@ static void lineart_occlusion_worker(TaskPool *__restrict UNUSED(pool), LineartR
for (eip = rti->edge_mark.first; eip && eip != rti->edge_mark.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
+
+ for (eip = rti->floating.first; eip && eip != rti->floating.last; eip = eip->next) {
+ lineart_occlusion_single_line(rb, eip, rti->thread_id);
+ }
}
}
@@ -486,6 +491,7 @@ static void lineart_main_occlusion_begin(LineartRenderBuffer *rb)
rb->intersection.last = rb->intersection.first;
rb->material.last = rb->material.first;
rb->edge_mark.last = rb->edge_mark.first;
+ rb->floating.last = rb->floating.first;
TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH);
@@ -720,6 +726,7 @@ static void lineart_triangle_post(LineartTriangle *tri, LineartTriangle *orig)
/* Just re-assign normal and set cull flag. */
copy_v3_v3_db(tri->gn, orig->gn);
tri->flags = LRT_CULL_GENERATED;
+ tri->transparency_mask = orig->transparency_mask;
}
static void lineart_triangle_set_cull_flag(LineartTriangle *tri, uchar flag)
@@ -735,6 +742,16 @@ static bool lineart_edge_match(LineartTriangle *tri, LineartEdge *e, int v1, int
(tri->v[v2] == e->v1 && tri->v[v1] == e->v2));
}
+static void lineart_discard_duplicated_edges(LineartEdge *old_e, int v1id, int v2id)
+{
+ LineartEdge *e = old_e;
+ e++;
+ while (e->v1_obindex == v1id && e->v2_obindex == v2id) {
+ e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
+ e++;
+ }
+}
+
/**
* Does near-plane cut on 1 triangle only. When cutting with far-plane, the camera vectors gets
* reversed by the caller so don't need to implement one in a different direction.
@@ -800,6 +817,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
old_e = ta->e[e_num]; \
new_flag = old_e->flags; \
old_e->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+ lineart_discard_duplicated_edges(old_e, old_e->v1_obindex, old_e->v2_obindex); \
INCREASE_EDGE \
e->v1 = (v1_link); \
e->v2 = (v2_link); \
@@ -820,12 +838,15 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
#define REMOVE_TRIANGLE_EDGE \
if (ta->e[0]) { \
ta->e[0]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+ lineart_discard_duplicated_edges(ta->e[0], ta->e[0]->v1_obindex, ta->e[0]->v2_obindex); \
} \
if (ta->e[1]) { \
ta->e[1]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+ lineart_discard_duplicated_edges(ta->e[1], ta->e[1]->v1_obindex, ta->e[1]->v2_obindex); \
} \
if (ta->e[2]) { \
ta->e[2]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+ lineart_discard_duplicated_edges(ta->e[2], ta->e[2]->v1_obindex, ta->e[2]->v2_obindex); \
}
switch (in0 + in1 + in2) {
@@ -1432,8 +1453,25 @@ static char lineart_identify_feature_line(LineartRenderBuffer *rb,
lr = e->l->radial_next;
}
- if (ll == lr || !lr) {
- return LRT_EDGE_FLAG_CONTOUR;
+ if (!ll && !lr) {
+ if (!rb->floating_as_contour) {
+ return LRT_EDGE_FLAG_FLOATING;
+ }
+ }
+
+ uint16_t edge_flag_result = 0;
+
+ if (count_freestyle && rb->use_edge_marks) {
+ FreestyleEdge *fe;
+ fe = CustomData_bmesh_get(&bm_if_freestyle->edata, e->head.data, CD_FREESTYLE_EDGE);
+ if (fe->flag
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list