[Bf-blender-cvs] [fdaa780e4e6] temp-lineart-contained: LineArt: Comment grammar and clarity fixes in lineart_chain.c
YimingWu
noreply at git.blender.org
Sat Mar 13 14:27:55 CET 2021
Commit: fdaa780e4e67bfbd19367488ee747e8481a53611
Author: YimingWu
Date: Sat Mar 13 21:27:40 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rBfdaa780e4e67bfbd19367488ee747e8481a53611
LineArt: Comment grammar and clarity fixes in lineart_chain.c
===================================================================
M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index ce8d3c64367..63663b2aa94 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -44,17 +44,17 @@
#include <math.h>
-#define LRT_OTHER_RV(rl, rv) ((rv) == (rl)->l ? (rl)->r : (rl)->l)
+#define LRT_OTHER_RV(rl, rv) ((rv) == (rl)->l ? (rl)->r : ((rv) == (rl)->r ? (rl)->l : NULL))
+/* Get a connected line, only for lines who has the exact given vert, or (in the case of
+ * intersection lines) who has a vert that has the exact same position. */
static LineartRenderLine *lineart_line_get_connected(LineartBoundingArea *ba,
LineartRenderVert *rv,
LineartRenderVert **new_rv,
int match_flag)
{
- LineartRenderLine *nrl;
-
LISTBASE_FOREACH (LinkData *, lip, &ba->linked_lines) {
- nrl = lip->data;
+ LineartRenderLine *nrl = lip->data;
if ((!(nrl->flags & LRT_EDGE_FLAG_ALL_TYPE)) || (nrl->flags & LRT_EDGE_FLAG_CHAIN_PICKED)) {
continue;
@@ -64,28 +64,24 @@ static LineartRenderLine *lineart_line_get_connected(LineartBoundingArea *ba,
continue;
}
- /* always chain connected lines for now. */
- /* simplification will take care of the sharp points. */
+ *new_rv = LRT_OTHER_RV(nrl, rv);
+ if (*new_rv) {
+ return nrl;
+ }
- if (rv != nrl->l && rv != nrl->r) {
- if (nrl->flags & LRT_EDGE_FLAG_INTERSECTION) {
- if (rv->fbcoord[0] == nrl->l->fbcoord[0] && rv->fbcoord[1] == nrl->l->fbcoord[1]) {
- *new_rv = LRT_OTHER_RV(nrl, nrl->l);
- return nrl;
- }
- if (rv->fbcoord[0] == nrl->r->fbcoord[0] && rv->fbcoord[1] == nrl->r->fbcoord[1]) {
- *new_rv = LRT_OTHER_RV(nrl, nrl->r);
- return nrl;
- }
+ if (nrl->flags & LRT_EDGE_FLAG_INTERSECTION) {
+ if (rv->fbcoord[0] == nrl->l->fbcoord[0] && rv->fbcoord[1] == nrl->l->fbcoord[1]) {
+ *new_rv = LRT_OTHER_RV(nrl, nrl->l);
+ return nrl;
+ }
+ if (rv->fbcoord[0] == nrl->r->fbcoord[0] && rv->fbcoord[1] == nrl->r->fbcoord[1]) {
+ *new_rv = LRT_OTHER_RV(nrl, nrl->r);
+ return nrl;
}
- continue;
}
-
- *new_rv = LRT_OTHER_RV(nrl, rv);
- return nrl;
}
- return 0;
+ return NULL;
}
static LineartRenderLineChain *lineart_chain_create(LineartRenderBuffer *rb)
@@ -126,8 +122,9 @@ static LineartRenderLineChainItem *lineart_chain_append_point(LineartRenderBuffe
LineartRenderLineChainItem *rlci;
if (lineart_point_overlapping(rlc->chain.last, fbcoord[0], fbcoord[1], 1e-5)) {
- /* 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*/
+ /* Because the new chain point is overlapping, just replace the type and occlusion level of the
+ * current point. This makes it so that the line to the point after this one has the correct
+ * type and level. */
LineartRenderLineChainItem *old_rlci = rlc->chain.last;
old_rlci->line_type = type;
old_rlci->occlusion = level;
@@ -148,15 +145,15 @@ static LineartRenderLineChainItem *lineart_chain_append_point(LineartRenderBuffe
return rlci;
}
-static LineartRenderLineChainItem *lineart_chain_push_point(LineartRenderBuffer *rb,
- LineartRenderLineChain *rlc,
- float *fbcoord,
- float *gpos,
- float *normal,
- char type,
- int level,
- unsigned char transparency_mask,
- size_t index)
+static LineartRenderLineChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb,
+ LineartRenderLineChain *rlc,
+ float *fbcoord,
+ float *gpos,
+ float *normal,
+ char type,
+ int level,
+ unsigned char transparency_mask,
+ size_t index)
{
LineartRenderLineChainItem *rlci;
@@ -186,7 +183,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
LineartRenderLineSegment *rls;
int last_occlusion;
unsigned char last_transparency;
- /* for converting from double. */
+ /* Used when converting from double. */
float use_fbcoord[2];
float use_gpos[3];
@@ -209,7 +206,9 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
rlc = lineart_chain_create(rb);
- rlc->object_ref = rl->object_ref; /* can only be the same object in a chain. */
+ /* One chain can only have one object_ref,
+ * so we assign it based on the first segment we found. */
+ rlc->object_ref = rl->object_ref;
LineartRenderLine *new_rl = rl;
LineartRenderVert *new_rv;
@@ -229,20 +228,20 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
normalize_v3(N);
}
- /* step 1: grow left. */
+ /* Step 1: grow left. */
ba = MOD_lineart_get_point_bounding_area_deep_rb(rb, rl->l->fbcoord[0], rl->l->fbcoord[1]);
new_rv = rl->l;
rls = rl->segments.first;
VERT_COORD_TO_FLOAT(new_rv);
- lineart_chain_push_point(rb,
- rlc,
- use_fbcoord,
- use_gpos,
- N,
- rl->flags,
- rls->occlusion,
- rls->transparency_mask,
- rl->l_obindex);
+ lineart_chain_prepend_point(rb,
+ rlc,
+ use_fbcoord,
+ use_gpos,
+ N,
+ rl->flags,
+ rls->occlusion,
+ rls->transparency_mask,
+ rl->l_obindex);
while (ba && (new_rl = lineart_line_get_connected(ba, new_rv, &new_rv, rl->flags))) {
new_rl->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
@@ -269,15 +268,15 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
interp_v3_v3v3_db(lpos, new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, global_at);
POS_TO_FLOAT(lpos, gpos)
- lineart_chain_push_point(rb,
- rlc,
- use_fbcoord,
- use_gpos,
- N,
- new_rl->flags,
- rls->occlusion,
- rls->transparency_mask,
- new_rl->l_obindex);
+ lineart_chain_prepend_point(rb,
+ rlc,
+ use_fbcoord,
+ use_gpos,
+ N,
+ new_rl->flags,
+ rls->occlusion,
+ rls->transparency_mask,
+ new_rl->l_obindex);
last_occlusion = rls->occlusion;
last_transparency = rls->transparency_mask;
}
@@ -294,28 +293,28 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
interp_v3_v3v3_db(lpos, new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
interp_v3_v3v3_db(gpos, new_rl->l->gloc, new_rl->r->gloc, global_at);
POS_TO_FLOAT(lpos, gpos)
- lineart_chain_push_point(rb,
- rlc,
- use_fbcoord,
- use_gpos,
- N,
- new_rl->flags,
- last_occlusion,
- last_transparency,
- new_rl->r_obindex);
+ lineart_chain_prepend_point(rb,
+ rlc,
+ use_fbcoord,
+ use_gpos,
+ N,
+ new_rl->flags,
+ last_occlusion,
+ last_transparency,
+ new_rl->r_obindex);
last_occlusion = rls->occlusion;
last_transparency = rls->transparency_mask;
}
VERT_COORD_TO_FLOAT(new_rl->r);
- lineart_chain_push_point(rb,
- rlc,
- use_fbcoord,
- use_gpos,
- N,
- new_rl->flags,
- last_occlusion,
- last_transparency,
- new_rl->r_obindex);
+ lineart_chain_prepend_point(rb,
+ rlc,
+ use_fbcoord,
+ use_gpos,
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list