[Bf-blender-cvs] [90e05b47cd7] lanpr-under-gp: LineArt: Own crease setting for Object.
YimingWu
noreply at git.blender.org
Thu Sep 10 15:13:22 CEST 2020
Commit: 90e05b47cd7626cbe69a70ac37788b17efedbe14
Author: YimingWu
Date: Thu Sep 10 21:12:58 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB90e05b47cd7626cbe69a70ac37788b17efedbe14
LineArt: Own crease setting for Object.
===================================================================
M release/scripts/startup/bl_ui/properties_lineart.py
M source/blender/editors/include/ED_lineart.h
M source/blender/editors/lineart/lineart_cpu.c
M source/blender/makesdna/DNA_object_types.h
M source/blender/makesrna/intern/rna_object.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_lineart.py b/release/scripts/startup/bl_ui/properties_lineart.py
index 569abc5fa16..90854b01cd8 100644
--- a/release/scripts/startup/bl_ui/properties_lineart.py
+++ b/release/scripts/startup/bl_ui/properties_lineart.py
@@ -34,6 +34,9 @@ class OBJECT_PT_lineart(LineartButtonsPanel, Panel):
lineart = context.object.lineart
if context.object.type == 'MESH':
layout.prop(lineart, 'usage')
+ layout.prop(lineart, "own_crease")
+ if lineart.own_crease:
+ layout.prop(lineart, "crease_threshold", slider=True)
classes = (
diff --git a/source/blender/editors/include/ED_lineart.h b/source/blender/editors/include/ED_lineart.h
index f9b57e8bea6..c435d09b70c 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -83,6 +83,9 @@ typedef struct LineartRenderElementLinkNode {
int element_count;
void *object_ref;
eLineArtElementNodeFlag flags;
+
+ /* Per object value, always set, if not enabled by ObjectLineArt, then it's set to global. */
+ float crease_threshold;
} LineartRenderElementLinkNode;
typedef struct LineartRenderLineSegment {
@@ -257,6 +260,7 @@ typedef struct LineartRenderBuffer {
double camera_pos[3];
double near_clip, far_clip;
float shift_x, shift_y;
+ float crease_threshold;
float chaining_image_threshold;
float chaining_geometry_threshold;
float angle_splitting_threshold;
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index 8e1eac00429..1917d08d3cf 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -1567,6 +1567,12 @@ static void lineart_geometry_object_load(Object *ob,
sizeof(LineartRenderElementLinkNode));
reln->element_count = bm->totedge;
reln->object_ref = orig_ob;
+ if (ob->lineart.flags & OBJECT_LRT_OWN_CREASE) {
+ reln->crease_threshold = ob->lineart.crease_threshold;
+ }
+ else {
+ reln->crease_threshold = rb->crease_threshold;
+ }
/* Temp solution for getting clean 2D text, future configuration will allow customizations. */
if (ob->type == OB_FONT) {
@@ -2393,7 +2399,7 @@ static void lineart_main_get_view_vector(LineartRenderBuffer *rb)
copy_v3db_v3fl(rb->view_vector, trans);
}
-static void lineart_main_compute_scene_contours(LineartRenderBuffer *rb, const float threshold)
+static void lineart_main_compute_scene_contours(LineartRenderBuffer *rb)
{
double *view_vector = rb->view_vector;
double dot_1 = 0, dot_2 = 0;
@@ -2407,87 +2413,95 @@ static void lineart_main_compute_scene_contours(LineartRenderBuffer *rb, const f
lineart_main_get_view_vector(rb);
}
- LISTBASE_FOREACH (LineartRenderLine *, rl, &rb->all_render_lines) {
-
- add = 0;
- dot_1 = 0;
- dot_2 = 0;
+ LISTBASE_FOREACH (LineartRenderElementLinkNode *, reln, &rb->line_buffer_pointers) {
+ LineartRenderLine *rl = (LineartRenderLine *)reln->pointer;
+ int amount = reln->element_count;
+ for (int i = 0; i < amount; i++) {
+ add = 0;
+ dot_1 = 0;
+ dot_2 = 0;
- if (rb->cam_is_persp) {
- sub_v3_v3v3_db(view_vector, rl->l->gloc, rb->camera_pos);
- }
-
- if (use_smooth_contour_modifier_contour) {
- if (rl->flags & LRT_EDGE_FLAG_CONTOUR) {
- add = 1;
- }
- }
- else {
- if (rl->tl) {
- dot_1 = dot_v3v3_db(view_vector, rl->tl->gn);
+ if (rb->cam_is_persp) {
+ sub_v3_v3v3_db(view_vector, rl->l->gloc, rb->camera_pos);
}
- else {
- add = 1;
- }
- if (rl->tr) {
- dot_2 = dot_v3v3_db(view_vector, rl->tr->gn);
- }
- else {
- add = 1;
- }
- }
- if (!add) {
- if ((result = dot_1 * dot_2) < 0 && (dot_1 + dot_2)) {
- add = 1;
+ if (use_smooth_contour_modifier_contour) {
+ if (rl->flags & LRT_EDGE_FLAG_CONTOUR) {
+ add = 1;
+ }
}
- else if (rb->use_crease && (dot_v3v3_db(rl->tl->gn, rl->tr->gn) < threshold)) {
- if (rl->object_ref && rl->object_ref->type == OB_FONT) {
- /* No internal lines in a text object. */
+ else {
+ if (rl->tl) {
+ dot_1 = dot_v3v3_db(view_vector, rl->tl->gn);
}
else {
- add = 2;
+ add = 1;
+ }
+ if (rl->tr) {
+ dot_2 = dot_v3v3_db(view_vector, rl->tr->gn);
+ }
+ else {
+ add = 1;
}
}
- else if (rb->use_material &&
- (rl->tl && rl->tr && rl->tl->material_id != rl->tr->material_id)) {
- add = 3;
+
+ if (!add) {
+ if ((result = dot_1 * dot_2) < 0 && (dot_1 + dot_2)) {
+ add = 1;
+ }
+ else if (rb->use_crease &&
+ (dot_v3v3_db(rl->tl->gn, rl->tr->gn) < reln->crease_threshold)) {
+ if (rl->object_ref && rl->object_ref->type == OB_FONT) {
+ /* No internal lines in a text object. */
+ }
+ else {
+ add = 2;
+ }
+ }
+ else if (rb->use_material &&
+ (rl->tl && rl->tr && rl->tl->material_id != rl->tr->material_id)) {
+ add = 3;
+ }
}
- }
- if (rb->use_contour && (add == 1)) {
- rl->flags |= LRT_EDGE_FLAG_CONTOUR;
- lineart_list_append_pointer_static(&rb->contours, &rb->render_data_pool, rl);
- contour_count++;
- }
- else if (add == 2) {
- rl->flags |= LRT_EDGE_FLAG_CREASE;
- lineart_list_append_pointer_static(&rb->crease_lines, &rb->render_data_pool, rl);
- crease_count++;
- }
- else if (rb->use_material && (add == 3)) {
- rl->flags |= LRT_EDGE_FLAG_MATERIAL;
- lineart_list_append_pointer_static(&rb->material_lines, &rb->render_data_pool, rl);
- material_count++;
- }
- else if (rb->use_edge_marks && (rl->flags & LRT_EDGE_FLAG_EDGE_MARK)) {
- /* no need to mark again */
- add = 4;
- lineart_list_append_pointer_static(&rb->edge_marks, &rb->render_data_pool, rl);
- /* continue; */
- }
- if (add) {
- int r1, r2, c1, c2, row, col;
- if (lineart_get_line_bounding_areas(rb, rl, &r1, &r2, &c1, &c2)) {
- for (row = r1; row != r2 + 1; row++) {
- for (col = c1; col != c2 + 1; col++) {
- lineart_bounding_area_link_line(rb, &rb->initial_bounding_areas[row * 4 + col], rl);
+ if (rb->use_contour && (add == 1)) {
+ rl->flags |= LRT_EDGE_FLAG_CONTOUR;
+ lineart_list_append_pointer_static(&rb->contours, &rb->render_data_pool, rl);
+ contour_count++;
+ }
+ else if (add == 2) {
+ rl->flags |= LRT_EDGE_FLAG_CREASE;
+ lineart_list_append_pointer_static(&rb->crease_lines, &rb->render_data_pool, rl);
+ crease_count++;
+ }
+ else if (rb->use_material && (add == 3)) {
+ rl->flags |= LRT_EDGE_FLAG_MATERIAL;
+ lineart_list_append_pointer_static(&rb->material_lines, &rb->render_data_pool, rl);
+ material_count++;
+ }
+ else if (rb->use_edge_marks && (rl->flags & LRT_EDGE_FLAG_EDGE_MARK)) {
+ /* no need to mark again */
+ add = 4;
+ lineart_list_append_pointer_static(&rb->edge_marks, &rb->render_data_pool, rl);
+ /* continue; */
+ }
+ if (add) {
+ int r1, r2, c1, c2, row, col;
+ if (lineart_get_line_bounding_areas(rb, rl, &r1, &r2, &c1, &c2)) {
+ for (row = r1; row != r2 + 1; row++) {
+ for (col = c1; col != c2 + 1; col++) {
+ lineart_bounding_area_link_line(rb, &rb->initial_bounding_areas[row * 4 + col], rl);
+ }
}
}
}
+
+ /* line count reserved for feature such as progress feedback */
+ rl++;
}
+ }
- /* line count reserved for feature such as progress feedback */
+ LISTBASE_FOREACH (LineartRenderLine *, rl, &rb->all_render_lines) {
}
}
@@ -2597,6 +2611,7 @@ LineartRenderBuffer *ED_lineart_create_render_buffer(Scene *scene)
rb->shift_y = (asp <= 1) ? c->shifty : c->shifty * asp;
}
+ rb->crease_threshold = scene->lineart.crease_threshold;
rb->angle_splitting_threshold = scene->lineart.angle_splitting_threshold;
rb->chaining_image_threshold = scene->lineart.chaining_image_threshold;
rb->chaining_geometry_threshold = scene->lineart.chaining_geometry_threshold;
@@ -3702,7 +3717,7 @@ int ED_lineart_compute_feature_lines_internal(Depsgraph *depsgraph, const int sh
}
if (!intersections_only) {
- lineart_main_compute_scene_contours(rb, lineart->crease_threshold);
+ lineart_main_compute_scene_contours(rb);
}
LRT_CANCEL_STAGE
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 98868c4fcba..7a1dcec7d41 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -187,8 +187,11 @@ typedef struct Object_Runtime {
} Object_Runtime;
typedef struct ObjectLineart {
- int usage;
- int _pad;
+ short usage;
+ short flags;
+
+ /** if OBJECT_LRT_OWN_CREASE is set */
+ float crease_threshold;
} ObjectLineart;
enum ObjectFeatureLine_Usage {
@@ -199,6 +202,10 @@ enum ObjectFeatureLine_Usage {
OBJECT_LRT_INTERSECTION_ONLY = (1 << 3),
};
+enum ObjectFeatureLine_Flags {
+ OBJECT_LRT_OWN_CREASE = (1 << 0),
+};
+
typedef struct Object {
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 13f708997a7..ee7d371f8af 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2621,6 +2621,15 @@ static void rna_def_object_lineart(BlenderRNA *brna)
prop = RNA_def_property(srna, "usage", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_feature_line_usage_items);
RNA_def_property_ui_text(prop, "Usage", "How to use this object");
+
+ prop = RNA_def_property(srna, "own_crease", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_prope
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list