[Bf-blender-cvs] [9afee06e4c6] temp-lineart-contained: LineArt: Remove isec unused stuff.
YimingWu
noreply at git.blender.org
Fri Jul 9 09:33:43 CEST 2021
Commit: 9afee06e4c6abd7d84e6b13be9fac36f3f595792
Author: YimingWu
Date: Fri Jul 9 11:26:41 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB9afee06e4c6abd7d84e6b13be9fac36f3f595792
LineArt: Remove isec unused stuff.
===================================================================
M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 347b3a16e1a..64a2096328a 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -2712,105 +2712,12 @@ static LineartVert *lineart_triangle_share_point(const LineartTriangle *l,
return NULL;
}
-/**
- * To save time and prevent overlapping lines when computing intersection lines.
- */
-static bool lineart_vert_already_intersected_2v(LineartVertIntersection *vt,
- LineartVertIntersection *v1,
- LineartVertIntersection *v2)
-{
- return ((vt->isec1 == v1->base.index && vt->isec2 == v2->base.index) ||
- (vt->isec2 == v2->base.index && vt->isec1 == v1->base.index));
-}
-
-static void lineart_vert_set_intersection_2v(LineartVert *vt, LineartVert *v1, LineartVert *v2)
-{
- LineartVertIntersection *irv = (LineartVertIntersection *)vt;
- irv->isec1 = v1->index;
- irv->isec2 = v2->index;
-}
-
-/**
- * This tests a triangle against a virtual line represented by `v1---v2`.
- * The vertices returned after repeated calls to this function
- * is then used to create a triangle/triangle intersection line.
- */
-static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *rb,
- LineartVert *v1,
- LineartVert *v2,
- LineartTriangle *tri,
- LineartTriangle *testing,
- LineartVert *last)
+static bool lineart_triangle_2v_intersection_math(
+ LineartVert *v1, LineartVert *v2, LineartTriangle *t2, float *last, float *rv)
{
double Lv[3];
double Rv[3];
double dot_l, dot_r;
- LineartVert *result;
- double gloc[3];
- LineartVert *l = v1, *r = v2;
-
- for (LinkNode *ln = (void *)testing->intersecting_verts; ln; ln = ln->next) {
- LineartVertIntersection *vt = ln->link;
- if (vt->intersecting_with == tri &&
- lineart_vert_already_intersected_2v(
- vt, (LineartVertIntersection *)l, (LineartVertIntersection *)r)) {
- return (LineartVert *)vt;
- }
- }
-
- sub_v3_v3v3_db(Lv, l->gloc, testing->v[0]->gloc);
- sub_v3_v3v3_db(Rv, r->gloc, testing->v[0]->gloc);
-
- dot_l = dot_v3v3_db(Lv, testing->gn);
- dot_r = dot_v3v3_db(Rv, testing->gn);
-
- if (dot_l * dot_r > 0 || (!dot_l && !dot_r)) {
- return 0;
- }
-
- dot_l = fabs(dot_l);
- dot_r = fabs(dot_r);
-
- interp_v3_v3v3_db(gloc, l->gloc, r->gloc, dot_l / (dot_l + dot_r));
-
- /* Due to precision issue, we might end up with the same point as the one we already detected.
- */
- if (last && LRT_DOUBLE_CLOSE_ENOUGH(last->gloc[0], gloc[0]) &&
- LRT_DOUBLE_CLOSE_ENOUGH(last->gloc[1], gloc[1]) &&
- LRT_DOUBLE_CLOSE_ENOUGH(last->gloc[2], gloc[2])) {
- return NULL;
- }
-
- if (!(lineart_point_inside_triangle3d(
- gloc, testing->v[0]->gloc, testing->v[1]->gloc, testing->v[2]->gloc))) {
- return NULL;
- }
-
- /* This is an intersection vert, the size is bigger than LineartVert,
- * allocated separately. */
- result = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartVertIntersection));
-
- /* Indicate the data structure difference. */
- result->flag = LRT_VERT_HAS_INTERSECTION_DATA;
-
- copy_v3_v3_db(result->gloc, gloc);
-
- lineart_prepend_pool(&testing->intersecting_verts, &rb->render_data_pool, result);
-
- return result;
-}
-
-static bool lineart_triangle_2v_intersection_math(LineartVert *v1,
- LineartVert *v2,
- LineartTriangle *tri,
- LineartTriangle *t2,
- float *last,
- float *rv)
-{
- double Lv[3];
- double Rv[3];
- double dot_l, dot_r;
- LineartVert *result;
double gloc[3];
LineartVert *l = v1, *r = v2;
@@ -2852,7 +2759,6 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri,
{
float *next = v1, *last = NULL;
LineartVert *sv1, *sv2;
- double cl[3];
LineartVert *share = lineart_triangle_share_point(t2, tri);
@@ -2860,14 +2766,13 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri,
/* If triangles have sharing points like `abc` and `acd`, then we only need to detect `bc`
* against `acd` or `cd` against `abc`. */
- LineartVert *new_share;
lineart_triangle_get_other_verts(tri, share, &sv1, &sv2);
copy_v3fl_v3db(v1, share->gloc);
- if (!lineart_triangle_2v_intersection_math(sv1, sv2, tri, t2, 0, v2)) {
+ if (!lineart_triangle_2v_intersection_math(sv1, sv2, t2, 0, v2)) {
lineart_triangle_get_other_verts(t2, share, &sv1, &sv2);
- if (lineart_triangle_2v_intersection_math(sv1, sv2, t2, tri, 0, v2)) {
+ if (lineart_triangle_2v_intersection_math(sv1, sv2, tri, 0, v2)) {
return true;
}
}
@@ -2875,19 +2780,19 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri,
else {
/* If not sharing any points, then we need to try all the possibilities. */
- if (lineart_triangle_2v_intersection_math(tri->v[0], tri->v[1], tri, t2, 0, v1)) {
+ if (lineart_triangle_2v_intersection_math(tri->v[0], tri->v[1], t2, 0, v1)) {
next = v2;
last = v1;
}
- if (lineart_triangle_2v_intersection_math(tri->v[1], tri->v[2], tri, t2, last, next)) {
+ if (lineart_triangle_2v_intersection_math(tri->v[1], tri->v[2], t2, last, next)) {
if (last) {
return true;
}
next = v2;
last = v1;
}
- if (lineart_triangle_2v_intersection_math(tri->v[2], tri->v[0], tri, t2, last, next)) {
+ if (lineart_triangle_2v_intersection_math(tri->v[2], tri->v[0], t2, last, next)) {
if (last) {
return true;
}
@@ -2895,21 +2800,21 @@ static bool lineart_triangle_intersect_math(LineartTriangle *tri,
last = v1;
}
- if (lineart_triangle_2v_intersection_math(t2->v[0], t2->v[1], t2, tri, last, next)) {
+ if (lineart_triangle_2v_intersection_math(t2->v[0], t2->v[1], tri, last, next)) {
if (last) {
return true;
}
next = v2;
last = v1;
}
- if (lineart_triangle_2v_intersection_math(t2->v[1], t2->v[2], t2, tri, last, next)) {
+ if (lineart_triangle_2v_intersection_math(t2->v[1], t2->v[2], tri, last, next)) {
if (last) {
return true;
}
next = v2;
last = v1;
}
- if (lineart_triangle_2v_intersection_math(t2->v[2], t2->v[0], t2, tri, last, next)) {
+ if (lineart_triangle_2v_intersection_math(t2->v[2], t2->v[0], tri, last, next)) {
if (last) {
return true;
}
@@ -2947,7 +2852,7 @@ static void lineart_add_eln_thread(LineartIsecThread *th, LineartElementLinkNode
{
if (th->current_pending == th->max_pending) {
- LineartElementLinkNode *new_array = MEM_mallocN(
+ LineartElementLinkNode **new_array = MEM_mallocN(
sizeof(LineartElementLinkNode *) * th->max_pending * 2, "LineartIsecSingle");
memcpy(
new_array, th->pending_triangle_nodes, sizeof(LineartElementLinkNode *) * th->max_pending);
@@ -3007,162 +2912,6 @@ static void lineart_destroy_isec_thread(LineartIsecData *d)
MEM_freeN(d->threads);
}
-/**
- * Test if two triangles intersect. Generates one intersection line if the check succeeds.
- */
-static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
- LineartTriangle *tri,
- LineartTriangle *testing)
-{
- LineartVert *v1 = 0, *v2 = 0;
- LineartVert **next = &v1;
- LineartEdge *result;
- LineartVert *E0T = 0;
- LineartVert *E1T = 0;
- LineartVert *E2T = 0;
- LineartVert *TE0 = 0;
- LineartVert *TE1 = 0;
- LineartVert *TE2 = 0;
- LineartVert *sv1, *sv2;
- double cl[3];
-
- double ZMin, ZMax;
- ZMax = rb->far_clip;
- ZMin = rb->near_clip;
- copy_v3_v3_db(cl, rb->camera_pos);
- LineartVert *share = lineart_triangle_share_point(testing, tri);
-
- if (share) {
- /* If triangles have sharing points like `abc` and `acd`, then we only need to detect `bc`
- * against `acd` or `cd` against `abc`. */
-
- LineartVert *new_share;
- lineart_triangle_get_other_verts(tri, share, &sv1, &sv2);
-
- v1 = new_share = lineart_mem_acquire(&rb->render_data_pool, (sizeof(LineartVertIntersection)));
-
- new_share->flag = LRT_VERT_HAS_INTERSECTION_DATA;
-
- copy_v3_v3_db(new_share->gloc, share->gloc);
-
- v2 = lineart_triangle_2v_intersection_test(rb, sv1, sv2, tri, testing, 0);
-
- if (v2 == NULL) {
- lineart_triangle_get_other_verts(testing, share, &sv1, &sv2);
- v2 = lineart_triangle_2v_intersection_test(rb, sv1, sv2, testing, tri, 0);
- if (v2 == NULL) {
- return 0;
- }
- lineart_prepend_pool(&testing->intersecting_verts, &rb->render_data_pool, new_share);
- }
- else {
- lineart_prepend_pool(&tri->intersecting_verts, &rb->render_data_pool, new_share);
- }
- }
- else {
- /* If not sharing any points, then we need to try all the possibilities. */
-
- E0T = lineart_triangle_2v_intersection_test(rb, tri->v[0], tri->v[1], tri, testing, 0);
- if (E0T && (!(*next))) {
- (*next) = E0T;
- lineart_vert_set_intersection_2v((*next), tri->v[0], tri->v[1]);
- next = &v2;
- }
- E1T = lineart_triangle_2v_intersection_test(rb, tri->v[1], tri->v[2], tri, testing, v1);
- if (E1T && (!(*next))) {
- (*next) = E1T;
- lineart_vert_set_intersection_2v((*next), tri->v[1], tri->v[2]);
- next = &v2;
- }
- if (!(*next)) {
- E2T = lineart_triangle_2v_intersection_test(rb, tri->v[2], tri->v[0], tri, testing, v1);
- }
- if (E2T && (!(*next))) {
- (*next) = E2T;
- lineart_vert_set_intersecti
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list