[Bf-blender-cvs] [4775d79df5b] lanpr-under-gp: LineArt: Intersection vert data now allocated in extended way.
YimingWu
noreply at git.blender.org
Thu Oct 22 10:45:59 CEST 2020
Commit: 4775d79df5b11bf94b9423b69de2c08a3922577a
Author: YimingWu
Date: Thu Oct 22 16:45:49 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB4775d79df5b11bf94b9423b69de2c08a3922577a
LineArt: Intersection vert data now allocated in extended way.
===================================================================
M source/blender/editors/include/ED_lineart.h
M source/blender/editors/lineart/lineart_cpu.c
===================================================================
diff --git a/source/blender/editors/include/ED_lineart.h b/source/blender/editors/include/ED_lineart.h
index 78f6a23353a..1e885c0a13a 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -52,7 +52,7 @@ typedef struct LineartStaticMemPool {
typedef struct LineartRenderTriangle {
struct LineartRenderVert *v[3];
- //struct LineartRenderLine *rl[3];
+ // struct LineartRenderLine *rl[3];
/* first culled in line list to use adjacent triangle info, then go through triangle list. */
double gn[3];
@@ -62,7 +62,7 @@ typedef struct LineartRenderTriangle {
/* These two should only be allocated when intersection is enabled, using a pointer. */
ListBase intersecting_verts;
- struct Object* object_ref;
+ struct Object *object_ref;
} LineartRenderTriangle;
typedef struct LineartRenderTriangleThread {
@@ -113,21 +113,28 @@ typedef struct LineartRenderVert {
int index;
- /** This will used in future acceleration for intersection processing.
- * Add intersection data flag here, when intersecting vert flag is set,
+ /** Intersection data flag is here, when LRT_VERT_HAS_INTERSECTION_DATA is set,
* size of the struct is extended to include intersection data.
+ * See eLineArtVertFlags.
*/
- char edge_used;
+ char flag;
- /** Used as "r" when intersecting */
- struct BMVert *v;
- struct LineartRenderVert *isec1,*isec2;
- struct LineartRenderTriangle *intersecting_with;
} LineartRenderVert;
+typedef struct LineartRenderVertIntersection {
+ struct LineartRenderVert base;
+ struct LineartRenderVert *isec1, *isec2;
+ struct LineartRenderTriangle *intersecting_with;
+} LineartRenderVertIntersection;
+
+typedef enum eLineArtVertFlags {
+ LRT_VERT_HAS_INTERSECTION_DATA = (1 << 0),
+ LRT_VERT_EDGE_USED = (1 << 1),
+} eLineArtVertFlags;
+
typedef struct LineartRenderLine {
/* We only need link node kind of list here. */
- struct LineartRenderLine* next;
+ struct LineartRenderLine *next;
struct LineartRenderVert *l, *r;
struct LineartRenderTriangle *tl, *tr;
ListBase segments;
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index 68c892af42a..7086f644002 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -333,6 +333,15 @@ static int lineart_occlusion_make_task_info(LineartRenderBuffer *rb, LineartRend
return res;
}
+BLI_INLINE bool lineart_occlusion_is_adjacent_intersection(LineartRenderLine *rl,
+ LineartRenderTriangle *rt)
+{
+ LineartRenderVertIntersection *l = (void *)rl->l;
+ LineartRenderVertIntersection *r = (void *)rl->r;
+ return ((l->base.flag && l->intersecting_with == (void *)rt) ||
+ (r->base.flag && r->intersecting_with == (void *)rt));
+}
+
static void lineart_occlusion_single_line(LineartRenderBuffer *rb,
LineartRenderLine *rl,
int thread_id)
@@ -356,9 +365,8 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb,
LISTBASE_FOREACH (LinkData *, lip, &nba->linked_triangles) {
rt = lip->data;
- if (rt->testing[thread_id] == rl || rl->l->intersecting_with == (void *)rt ||
- rl->r->intersecting_with == (void *)rt ||
- (rt->base.flags & LRT_TRIANGLE_INTERSECTION_ONLY)) {
+ if (rt->testing[thread_id] == rl || (rt->base.flags & LRT_TRIANGLE_INTERSECTION_ONLY) ||
+ lineart_occlusion_is_adjacent_intersection(rl, rt)) {
continue;
}
rt->testing[thread_id] = rl;
@@ -2198,19 +2206,21 @@ static LineartRenderVert *lineart_triangle_share_point(const LineartRenderTriang
return NULL;
}
-static bool lineart_vert_already_intersected_2v(LineartRenderVert *rv,
- LineartRenderVert *v1,
- LineartRenderVert *v2)
+static bool lineart_vert_already_intersected_2v(LineartRenderVertIntersection *rv,
+ LineartRenderVertIntersection *v1,
+ LineartRenderVertIntersection *v2)
{
- return ((rv->isec1 == v1 && rv->isec2 == v2) || (rv->isec2 == v2 && rv->isec1 == v1));
+ return ((rv->isec1 == (void *)v1 && rv->isec2 == (void *)v2) ||
+ (rv->isec2 == (void *)v2 && rv->isec1 == (void *)v1));
}
static void lineart_vert_set_intersection_2v(LineartRenderVert *rv,
LineartRenderVert *v1,
LineartRenderVert *v2)
{
- rv->isec1 = v1;
- rv->isec2 = v2;
+ LineartRenderVertIntersection *irv = (LineartRenderVertIntersection *)rv;
+ irv->isec1 = v1;
+ irv->isec2 = v2;
}
static LineartRenderVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *rb,
@@ -2228,8 +2238,10 @@ static LineartRenderVert *lineart_triangle_2v_intersection_test(LineartRenderBuf
LineartRenderVert *l = v1, *r = v2;
LISTBASE_FOREACH (LinkData *, ld, &testing->intersecting_verts) {
- LineartRenderVert *rv = (LineartRenderVert *)ld->data;
- if (rv->intersecting_with == rt && lineart_vert_already_intersected_2v(rv, l, r)) {
+ LineartRenderVertIntersection *rv = (LineartRenderVert *)ld->data;
+ if (rv->intersecting_with == rt &&
+ lineart_vert_already_intersected_2v(
+ rv, (LineartRenderVertIntersection *)l, (LineartRenderVertIntersection *)r)) {
return rv;
}
}
@@ -2260,14 +2272,9 @@ static LineartRenderVert *lineart_triangle_2v_intersection_test(LineartRenderBuf
return NULL;
}
- result = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartRenderVert));
+ result = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartRenderVertIntersection));
- result->edge_used = 1;
-
- /** Caution! BMVert* result->v is reused to save a intersecting render vert.
- * this saves memory when the scene is very large.
- */
- result->v = (void *)r;
+ result->flag = LRT_VERT_HAS_INTERSECTION_DATA;
copy_v3_v3_db(result->gloc, gloc);
@@ -2301,11 +2308,11 @@ static LineartRenderLine *lineart_triangle_generate_intersection_line_only(
LineartRenderVert *new_share;
lineart_another_edge_2v(rt, share, &sv1, &sv2);
- l = new_share = lineart_mem_aquire(&rb->render_data_pool, (sizeof(LineartRenderVert)));
+ l = new_share = lineart_mem_aquire(&rb->render_data_pool,
+ (sizeof(LineartRenderVertIntersection)));
+
+ new_share->flag = LRT_VERT_HAS_INTERSECTION_DATA;
- new_share->edge_used = 1;
- new_share->v = (void *)
- r; /* Caution! BMVert* result->v is reused to save a intersecting render vert. */
copy_v3_v3_db(new_share->gloc, share->gloc);
r = lineart_triangle_2v_intersection_test(rb, sv1, sv2, rt, testing, 0);
@@ -2395,8 +2402,8 @@ static LineartRenderLine *lineart_triangle_generate_intersection_line_only(
l->fbcoord[2] = ZMin * ZMax / (ZMax - fabs(l->fbcoord[2]) * (ZMax - ZMin));
r->fbcoord[2] = ZMin * ZMax / (ZMax - fabs(r->fbcoord[2]) * (ZMax - ZMin));
- l->intersecting_with = rt;
- r->intersecting_with = testing;
+ ((LineartRenderVertIntersection *)l)->intersecting_with = rt;
+ ((LineartRenderVertIntersection *)r)->intersecting_with = testing;
result = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartRenderLine));
result->l = l;
More information about the Bf-blender-cvs
mailing list