[Bf-blender-cvs] [26609e2639c] lanpr-under-gp: LANPR: Fixed occlusion level detection.
YimingWu
noreply at git.blender.org
Thu Jun 25 11:20:22 CEST 2020
Commit: 26609e2639c5b0ac1aa9cd2252a40e5a17b995f9
Author: YimingWu
Date: Thu Jun 25 17:20:15 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB26609e2639c5b0ac1aa9cd2252a40e5a17b995f9
LANPR: Fixed occlusion level detection.
===================================================================
M source/blender/blenkernel/intern/collection.c
M source/blender/editors/lanpr/lanpr_chain.c
M source/blender/editors/lanpr/lanpr_cpu.c
===================================================================
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 294667f8a8c..ac792b2b393 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -432,6 +432,8 @@ static Collection *collection_duplicate_recursive(Main *bmain,
collection_child_remove(collection_new, child_collection_old);
}
+ collection_lanpr_copy(collection_old, collection_new);
+
return collection_new;
}
diff --git a/source/blender/editors/lanpr/lanpr_chain.c b/source/blender/editors/lanpr/lanpr_chain.c
index 69c31930aea..82eb096d020 100644
--- a/source/blender/editors/lanpr/lanpr_chain.c
+++ b/source/blender/editors/lanpr/lanpr_chain.c
@@ -131,7 +131,7 @@ static LANPR_RenderLineChainItem *lanpr_append_render_line_chain_point(LANPR_Ren
{
LANPR_RenderLineChainItem *rlci;
- if (lanpr_check_point_overlapping(rlc->chain.last, x, y, 1e-5)) {
+ if (lanpr_check_point_overlapping(rlc->chain.last, x, y, 1e-10)) {
/* Because segment type is determined by the leading chain point, so we need to ensure the type
* and occlusion is correct after omitting overlapping point*/
LANPR_RenderLineChainItem *old_rlci = rlc->chain.last;
@@ -170,7 +170,7 @@ static LANPR_RenderLineChainItem *lanpr_push_render_line_chain_point(LANPR_Rende
{
LANPR_RenderLineChainItem *rlci;
- if (lanpr_check_point_overlapping(rlc->chain.first, x, y, 1e-5)) {
+ if (lanpr_check_point_overlapping(rlc->chain.first, x, y, 1e-10)) {
return rlc->chain.first;
}
@@ -541,7 +541,7 @@ static void lanpr_link_chain_with_bounding_areas(LANPR_RenderBuffer *rb,
void ED_lanpr_split_chains_for_fixed_occlusion(LANPR_RenderBuffer *rb)
{
LANPR_RenderLineChain *rlc, *new_rlc;
- LANPR_RenderLineChainItem *rlci, *next_rlci;
+ LANPR_RenderLineChainItem *rlci, *next_rlci, *prev_rlci;
ListBase swap = {0};
swap.first = rb->chains.first;
@@ -557,7 +557,13 @@ void ED_lanpr_split_chains_for_fixed_occlusion(LANPR_RenderBuffer *rb)
rlc->level = fixed_occ;
for (rlci = first_rlci->next; rlci; rlci = next_rlci) {
next_rlci = rlci->next;
+ prev_rlci = rlci->prev;
if (rlci->occlusion != fixed_occ) {
+ if (lanpr_check_point_overlapping(prev_rlci, rlci->pos[0], rlci->pos[1], 1e-10)) {
+ fixed_occ = rlci->occlusion;
+ rlc->level = fixed_occ;
+ continue;
+ }
new_rlc = lanpr_create_render_line_chain(rb);
new_rlc->chain.first = rlci;
new_rlc->chain.last = rlc->chain.last;
@@ -602,7 +608,7 @@ static void lanpr_connect_two_chains(LANPR_RenderBuffer *UNUSED(rb),
BLI_listbase_reverse(&sub->chain);
}
rlci = sub->chain.first;
- if (lanpr_check_point_overlapping(onto->chain.last, rlci->pos[0], rlci->pos[1], 1e-5)) {
+ if (lanpr_check_point_overlapping(onto->chain.last, rlci->pos[0], rlci->pos[1], 1e-10)) {
BLI_pophead(&sub->chain);
if (sub->chain.first == NULL) {
return;
@@ -617,7 +623,7 @@ static void lanpr_connect_two_chains(LANPR_RenderBuffer *UNUSED(rb),
BLI_listbase_reverse(&sub->chain);
}
rlci = onto->chain.first;
- if (lanpr_check_point_overlapping(sub->chain.last, rlci->pos[0], rlci->pos[1], 1e-5)) {
+ if (lanpr_check_point_overlapping(sub->chain.last, rlci->pos[0], rlci->pos[1], 1e-10)) {
BLI_pophead(&onto->chain);
if (onto->chain.first == NULL) {
return;
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index 2ddfad09ce6..11edbcca8d0 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -2651,8 +2651,14 @@ static int lanpr_max_occlusion_in_collections(Collection *c)
CollectionChild *cc;
int max_occ = 0;
int max;
+
+ for (cc = c->children.first; cc; cc = cc->next) {
+ max = lanpr_max_occlusion_in_collections(cc->collection);
+ max_occ = MAX2(max, max_occ);
+ }
+
if (!(c->flag & COLLECTION_CONFIGURED_FOR_LANPR)) {
- return 0;
+ return max_occ;
}
if (c->lanpr->flags & LANPR_LINE_LAYER_USE_MULTIPLE_LEVELS) {
@@ -2663,11 +2669,6 @@ static int lanpr_max_occlusion_in_collections(Collection *c)
}
max_occ = MAX2(max, max_occ);
- for (cc = c->children.first; cc; cc = cc->next) {
- max = lanpr_max_occlusion_in_collections(cc->collection);
- max_occ = MAX2(max, max_occ);
- }
-
return max_occ;
}
static int lanpr_max_occlusion_in_targets(Depsgraph *depsgraph)
More information about the Bf-blender-cvs
mailing list