107 const double *override_camera_loc,
108 const bool override_cam_is_persp,
109 const bool allow_overlapping_edges,
110 const double m_view_projection[4][4],
111 const double camera_dir[3],
112 const float cam_shift_x,
113 const float cam_shift_y,
123 bool do_intersection,
165 uchar material_mask_bits,
182 if (start != start) [[unlikely]] {
185 if (end != end) [[unlikely]] {
200 cut_start_before = &seg;
201 new_seg1 = cut_start_before;
204 if (seg.
next ==
nullptr) {
208 if (i_seg->
ratio > start + 1
e-09 && start > seg.
ratio) {
209 cut_start_before = i_seg;
221 cut_end_before = seg;
222 new_seg2 = cut_end_before;
228 cut_end_before = seg;
229 new_seg2 = cut_end_before;
234 if (seg->
ratio > end) {
235 cut_end_before = seg;
242 if (new_seg1 ==
nullptr) {
245 if (new_seg2 ==
nullptr) {
248 cut_end_before = new_seg2;
255 if (cut_start_before) {
256 if (cut_start_before != new_seg1) {
258 i_seg = cut_start_before->
prev ? cut_start_before->
prev :
nullptr;
271 i_seg =
e->segments.last();
277 if (cut_end_before) {
279 if (cut_end_before != new_seg2) {
280 i_seg = cut_end_before->
prev ? cut_end_before->
prev :
nullptr;
290 i_seg =
e->segments.last();
301 new_seg1->
ratio = start;
303 new_seg2->ratio = end;
307 new_seg2 = new_seg2->next;
348 min_occ = std::min<int8_t>(min_occ, seg.
occlusion);
352 e->min_occ = min_occ;
397 for (
int i = 0; i < nba->triangle_count; i++) {
483 for (i = 0; i < thread_count; i++) {
509 cl = (v0[0] -
v[0]) * (v1[1] -
v[1]) - (v0[1] -
v[1]) * (v1[0] -
v[0]);
512 cl = (v1[0] -
v[0]) * (
v2[1] -
v[1]) - (v1[1] -
v[1]) * (
v2[0] -
v[0]);
519 cl = (
v2[0] -
v[0]) * (v0[1] -
v[1]) - (
v2[1] -
v[1]) * (v0[0] -
v[0]);
536 double c1 = 1, c2 = 0;
542 if (v1[0] == v0[0] && v1[1] == v0[1]) {
547 c1 =
ratiod(v0[0], v1[0],
v[0]);
551 c2 =
ratiod(v0[1], v1[1],
v[1]);
558 c2 =
ratiod(v0[1], v1[1],
v[1]);
562 c1 =
ratiod(v0[0], v1[0],
v[0]);
598 cl = (v0[0] -
v[0]) * (v1[1] -
v[1]) - (v0[1] -
v[1]) * (v1[0] -
v[0]);
601 cl = (v1[0] -
v[0]) * (
v2[1] -
v[1]) - (v1[1] -
v[1]) * (
v2[0] -
v[0]);
602 if ((r = c * cl) < 0) {
608 cl = (
v2[0] -
v[0]) * (v0[1] -
v[1]) - (
v2[1] -
v[1]) * (v0[0] -
v[0]);
609 if ((r = c * cl) < 0) {
615 cl = (v0[0] -
v[0]) * (v1[1] -
v[1]) - (v0[1] -
v[1]) * (v1[0] -
v[0]);
616 if ((r = c * cl) < 0) {
739 tri->
flags |= intersection_only;
744 return ((tri->
v[v1] ==
e->v1 && tri->
v[
v2] ==
e->v2) ||
745 (tri->
v[
v2] ==
e->v1 && tri->
v[v1] ==
e->v2));
768 bool allow_boundaries,
769 double m_view_projection[4][4],
778 double span_v1[3], span_v2[3], dot_v1, dot_v2;
780 int v_count = *r_v_count;
781 int e_count = *r_e_count;
782 int t_count = *r_t_count;
807#define INCREASE_EDGE \
808 new_e = &((LineartEdge *)e_eln->pointer)[e_count]; \
811 es = static_cast<LineartEdgeSegment *>( \
812 lineart_mem_acquire(&ld->render_data_pool, sizeof(LineartEdgeSegment))); \
813 BLI_addtail(&e->segments, es);
815#define SELECT_EDGE(e_num, v1_link, v2_link, new_tri) \
816 if (tri_adj->e[e_num]) { \
817 old_e = tri_adj->e[e_num]; \
818 new_flag = old_e->flags; \
819 old_e->flags = MOD_LINEART_EDGE_FLAG_CHAIN_PICKED; \
820 lineart_discard_duplicated_edges(old_e); \
824 e->v1->index = (v1_link)->index; \
825 e->v2->index = (v1_link)->index; \
826 e->flags = new_flag; \
827 e->object_ref = ob; \
828 e->t1 = ((old_e->t1 == tri) ? (new_tri) : (old_e->t1)); \
829 e->t2 = ((old_e->t2 == tri) ? (new_tri) : (old_e->t2)); \
830 lineart_add_edge_to_array(&ld->pending_edges, e); \
833#define RELINK_EDGE(e_num, new_tri) \
834 if (tri_adj->e[e_num]) { \
835 old_e = tri_adj->e[e_num]; \
836 old_e->t1 = ((old_e->t1 == tri) ? (new_tri) : (old_e->t1)); \
837 old_e->t2 = ((old_e->t2 == tri) ? (new_tri) : (old_e->t2)); \
840#define REMOVE_TRIANGLE_EDGE \
841 if (tri_adj->e[0]) { \
842 tri_adj->e[0]->flags = MOD_LINEART_EDGE_FLAG_CHAIN_PICKED; \
843 lineart_discard_duplicated_edges(tri_adj->e[0]); \
845 if (tri_adj->e[1]) { \
846 tri_adj->e[1]->flags = MOD_LINEART_EDGE_FLAG_CHAIN_PICKED; \
847 lineart_discard_duplicated_edges(tri_adj->e[1]); \
849 if (tri_adj->e[2]) { \
850 tri_adj->e[2]->flags = MOD_LINEART_EDGE_FLAG_CHAIN_PICKED; \
851 lineart_discard_duplicated_edges(tri_adj->e[2]); \
854 switch (in0 + in1 + in2) {
895 a = dot_v1 / (dot_v1 + dot_v2);
906 a = dot_v1 / (dot_v1 + dot_v2);
914 if (allow_boundaries) {
934 tri1->
v[0] = tri->
v[0];
948 a = dot_v1 / (dot_v1 + dot_v2);
957 a = dot_v1 / (dot_v1 + dot_v2);
963 if (allow_boundaries) {
977 tri1->
v[2] = tri->
v[2];
989 a = dot_v1 / (dot_v1 + dot_v2);
998 a = dot_v1 / (dot_v1 + dot_v2);
1004 if (allow_boundaries) {
1016 tri1->
v[0] = &vt[0];
1017 tri1->
v[1] = tri->
v[1];
1018 tri1->
v[2] = &vt[1];
1060 a = dot_v2 / (dot_v1 + dot_v2);
1071 a = dot_v2 / (dot_v1 + dot_v2);
1079 if (allow_boundaries) {
1096 tri1->
v[0] = tri->
v[1];
1097 tri1->
v[1] = &vt[1];
1098 tri1->
v[2] = &vt[0];
1100 tri2->
v[0] = &vt[1];
1101 tri2->
v[1] = tri->
v[1];
1102 tri2->
v[2] = tri->
v[2];
1116 a = dot_v1 / (dot_v1 + dot_v2);
1125 a = dot_v1 / (dot_v1 + dot_v2);
1131 if (allow_boundaries) {
1145 tri1->
v[0] = tri->
v[2];
1146 tri1->
v[1] = &vt[1];
1147 tri1->
v[2] = &vt[0];
1149 tri2->
v[0] = &vt[1];
1150 tri2->
v[1] = tri->
v[2];
1151 tri2->
v[2] = tri->
v[0];
1165 a = dot_v1 / (dot_v1 + dot_v2);
1174 a = dot_v1 / (dot_v1 + dot_v2);
1180 if (allow_boundaries) {
1194 tri1->
v[0] = tri->
v[0];
1195 tri1->
v[1] = &vt[1];
1196 tri1->
v[2] = &vt[0];
1198 tri2->
v[0] = &vt[1];
1199 tri2->
v[1] = tri->
v[0];
1200 tri2->
v[2] = tri->
v[1];
1210 *r_v_count = v_count;
1211 *r_e_count = e_count;
1212 *r_t_count = t_count;
1217#undef REMOVE_TRIANGLE_EDGE
1226 int v_count = 0, t_count = 0, e_count = 0;
1231 double view_dir[3], clip_advance[3];
1256#define LRT_CULL_ENSURE_MEMORY \
1257 if (v_count > 60) { \
1258 v_eln->element_count = v_count; \
1259 v_eln = lineart_memory_get_vert_space(ld); \
1262 if (t_count > 60) { \
1263 t_eln->element_count = t_count; \
1264 t_eln = lineart_memory_get_triangle_space(ld); \
1267 if (e_count > 60) { \
1268 e_eln->element_count = e_count; \
1269 e_eln = lineart_memory_get_edge_space(ld); \
1273#define LRT_CULL_DECIDE_INSIDE \
1275 in0 = 0, in1 = 0, in2 = 0; \
1278 if (tri->v[0]->fbcoord[use_w] > clip_end) { \
1281 if (tri->v[1]->fbcoord[use_w] > clip_end) { \
1284 if (tri->v[2]->fbcoord[use_w] > clip_end) { \
1290 if (tri->v[0]->fbcoord[use_w] < clip_start) { \
1293 if (tri->v[1]->fbcoord[use_w] < clip_start) { \
1296 if (tri->v[2]->fbcoord[use_w] < clip_start) { \
1302 int in0 = 0, in1 = 0, in2 = 0;
1348#undef LRT_CULL_ENSURE_MEMORY
1349#undef LRT_CULL_DECIDE_INSIDE
1397 const float bounds[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, -1.0f}, {1.0f, 1.0f}};
1399#define LRT_VERT_OUT_OF_BOUND(v) \
1400 (v->fbcoord[0] < -1 || v->fbcoord[0] > 1 || v->fbcoord[1] < -1 || v->fbcoord[1] > 1)
1405 if (!
e[i].v1 || !
e[i].
v2) {
1409 const float2 vec1(
e[i].v1->fbcoord), vec2(
e[i].
v2->fbcoord);
1460#define LRT_MESH_EDGE_TYPES_COUNT 6
1515 void *__restrict chunk_join,
1516 void *__restrict chunk)
1539 if (i < edge_nabr[i].
e) {
1543 bool face_mark_filtered =
false;
1546 bool only_contour =
false;
1547 if (enable_face_mark) {
1551 if (freestyle_face[tri_faces[i / 3]]) {
1568 face_mark_filtered =
true;
1572 if (ff1 && ff2 && (ff2 != ff1)) {
1573 face_mark_filtered =
true;
1577 face_mark_filtered = !face_mark_filtered;
1579 if (!face_mark_filtered) {
1582 only_contour =
true;
1587 if (enable_face_mark && !face_mark_filtered && !only_contour) {
1592 if (edge_nabr[i].
e == -1) {
1602 int f1 = i / 3, f2 = edge_nabr[i].
e / 3;
1608 vert = &e_feat_data->
v_array[edge_nabr[i].
v1];
1610 double view_vector_persp[3];
1611 double *view_vector = view_vector_persp;
1612 double dot_v1 = 0, dot_v2 = 0;
1627 if ((
result = dot_v1 * dot_v2) <= 0 && (dot_v1 + dot_v2)) {
1639 if (material_back_face) {
1650 view_vector = view_vector_persp;
1661 if ((
result = dot_v1 * dot_v2) <= 0 && (dot_v1 + dot_v2)) {
1666 if (!only_contour) {
1668 bool do_crease =
true;
1679 int mat1 = material_indices.
is_empty() ? 0 : material_indices[tri_faces[f1]];
1680 int mat2 = material_indices.
is_empty() ? 0 : material_indices[tri_faces[f2]];
1686 ((m1->lineart.mat_occlusion == 0 && m2->lineart.mat_occlusion != 0) ||
1687 (m2->lineart.mat_occlusion == 0 && m1->lineart.mat_occlusion != 0)))
1699 if (!edge_flag_result) {
1707 corner_tris[i / 3]);
1709 if (real_edges[i % 3] >= 0) {
1723 edge_nabr[i].
flags = edge_flag_result;
1725 if (edge_flag_result) {
1748 size_t(pe->
max) * 2,
"LineartPendingEdges array");
1749 if (pe->
array) [[likely]] {
1751 MEM_delete(pe->
array);
1754 pe->
array = new_array;
1769 if (pe->
max || pe->
array || count == 0) {
1775 size_t(pe->
max),
"LineartPendingEdges array final");
1776 pe->
array = new_array;
1832 const int face_i = tri_task_data->
tri_faces[i];
1838 tri =
reinterpret_cast<LineartTriangle *
>((
reinterpret_cast<size_t>(tri)) +
1841 int v1 = corner_verts[corner_tri[0]];
1842 int v2 = corner_verts[corner_tri[1]];
1843 int v3 = corner_verts[corner_tri[2]];
1845 tri->
v[0] = &vert_arr[v1];
1846 tri->
v[1] = &vert_arr[
v2];
1847 tri->
v[2] = &vert_arr[v3];
1853 mat->lineart.material_mask_bits :
1855 tri->
mat_occlusion |= (mat ? mat->lineart.mat_occlusion : 1);
1858 mat->lineart.intersection_priority :
1886 const bool has_mark = tri_task_data->
face_marks[face_i];
1887 const bool filtered = tri_task_data->
invert_face_marks ? has_mark : (!has_mark);
1895 static_cast<void *
>(&tri_task_data->
tri_adj[i]));
1916 adj_e->
v1 = corner_verts[tri[i % 3]];
1917 adj_e->
v2 = corner_verts[tri[(i + 1) % 3]];
1918 if (adj_e->
v1 > adj_e->
v2) {
1919 std::swap(adj_e->
v1, adj_e->
v2);
1923 edge_nabr->
v1 = adj_e->
v1;
1924 edge_nabr->
v2 = adj_e->
v2;
1925 edge_nabr->
flags = 0;
1931 int a = p1.
v1 - p2.
v1;
1932 int b = p1.
v2 - p2.
v2;
1950 size_t(total_edges),
"LineartAdjacentEdge arr");
1952 size_t(total_edges),
"LineartEdgeNeighbor arr");
1960 en_data.
adj_e = adj_e;
1970 for (
int i = 0; i < total_edges - 1; i++) {
1971 if (adj_e[i].v1 == adj_e[i + 1].v1 && adj_e[i].
v2 == adj_e[i + 1].
v2) {
1972 edge_nabr[adj_e[i].
e].
e = adj_e[i + 1].
e;
1973 edge_nabr[adj_e[i + 1].
e].
e = adj_e[i].
e;
1984 ListBaseT<LineartElementLinkNode> *shadow_elns)
1987 if (!
mesh->edges_num) {
1994 const VArraySpan material_indices = *attributes.
lookup<
int>(
"material_index", AttrDomain::Face);
1995 const VArraySpan face_marks = *attributes.
lookup<
bool>(
"freestyle_face", AttrDomain::Face);
2018 ob_info->
v_eln = elem_link_node;
2020 bool use_auto_smooth =
false;
2021 float crease_angle = 0;
2043 int usage = ob_info->
usage;
2048 elem_link_node->
flags |
2053 size_t(corner_tris.
size()),
"LineartTriangleAdjacent");
2068 vert_data.
v_arr = la_v_arr;
2090 tri_data.
tri_arr = la_tri_arr;
2116 "sharp_edge", AttrDomain::Edge,
false);
2118 "sharp_face", AttrDomain::Face,
false);
2121 edge_feat_data.
ld = la_data;
2122 edge_feat_data.mesh =
mesh;
2124 edge_feat_data.material_indices = material_indices;
2125 edge_feat_data.edges =
mesh->edges();
2126 edge_feat_data.corner_verts =
mesh->corner_verts();
2127 edge_feat_data.corner_edges =
mesh->corner_edges();
2128 edge_feat_data.corner_tris = corner_tris;
2129 edge_feat_data.tri_faces =
mesh->corner_tri_faces();
2130 edge_feat_data.sharp_edges = sharp_edges;
2131 edge_feat_data.sharp_faces = sharp_faces;
2133 edge_feat_data.tri_array = la_tri_arr;
2134 edge_feat_data.v_array = la_v_arr;
2135 edge_feat_data.crease_threshold = crease_angle;
2136 edge_feat_data.use_auto_smooth = use_auto_smooth;
2137 edge_feat_data.freestyle_face = *attributes.
lookup<
bool>(
"freestyle_face", AttrDomain::Face);
2138 edge_feat_data.freestyle_edge = *attributes.
lookup<
bool>(
"freestyle_edge", AttrDomain::Edge);
2139 edge_feat_data.use_freestyle_face = bool(edge_feat_data.freestyle_face);
2140 edge_feat_data.use_freestyle_edge = bool(edge_feat_data.freestyle_edge);
2146 &edge_feat_settings);
2184 la_edge = la_edge_arr;
2185 la_seg = la_seg_arr;
2187 for (
int i = 0; i < total_edges; i++) {
2190 if (i < edge_nabr->
e) {
2195 if (edge_nabr->
flags == 0) {
2204 if (!(use_type & edge_nabr->
flags)) {
2208 la_edge->
v1 = &la_v_arr[edge_nabr->
v1];
2209 la_edge->
v2 = &la_v_arr[edge_nabr->
v2];
2215 if (edge_nabr->
e != -1) {
2216 findex = edge_nabr->
e / 3;
2222 la_edge->
flags = use_type;
2250 edge_added = la_edge;
2263 for (
int i = 0; i < loose_data.
loose_count; i++) {
2265 la_edge->
v1 = &la_v_arr[edge[0]];
2266 la_edge->
v2 = &la_v_arr[edge[1]];
2291 MEM_delete(edge_feat_data.edge_nabr);
2362 if (object_has_special_usage) {
2407 int this_face_count)
2411 for (
int i = 0; i < thread_count; i++) {
2412 if (olti_list[i].total_faces < min_face) {
2414 use_olti = &olti_list[i];
2431 const std::optional<Bounds<float3>>
bounds = use_mesh->bounds_min_max();
2432 if (!
bounds.has_value()) {
2439 for (
int i = 0; i < 8; i++) {
2443 co[i][0] -= shift_x * 2 * co[i][3];
2444 co[i][1] -= shift_y * 2 * co[i][3];
2447 bool cond[6] = {
true,
true,
true,
true,
true,
true};
2450 for (
int i = 0; i < 8; i++) {
2451 cond[0] &= (co[i][0] < -co[i][3]);
2452 cond[1] &= (co[i][0] > co[i][3]);
2453 cond[2] &= (co[i][1] < -co[i][3]);
2454 cond[3] &= (co[i][1] > co[i][3]);
2455 cond[4] &= (co[i][2] < -co[i][3]);
2456 cond[5] &= (co[i][2] > co[i][3]);
2458 for (
int i = 0; i < 6; i++) {
2467 Depsgraph *depsgraph,
2471 const float use_mat[4][4],
2542 bool allow_duplicates,
2543 bool do_shadow_casting,
2544 ListBaseT<LineartElementLinkNode> *shadow_elns,
2547 double proj[4][4], view[4][4],
result[4][4];
2550 if (!do_shadow_casting) {
2554 double asp = (double(ld->
w) / double(ld->
h));
2566 double horizontal = cam->ortho_scale / 2;
2567 double vertical = horizontal;
2575 proj, -horizontal, horizontal, -vertical, vertical, cam->clip_start, cam->clip_end);
2578 BLI_assert(!
"Unsupported camera type in lineart_main_load_geometries");
2595 if (
G.debug_value == 4000) {
2600 int bound_box_discard_count = 0;
2614 if (allow_duplicates) {
2619 deg_iter_settings.
depsgraph = depsgraph;
2620 deg_iter_settings.
flags = flags;
2645 eval_ob->object_to_world().ptr(),
2656 if (
G.debug_value == 4000) {
2657 printf(
"thread count: %d\n", thread_count);
2659 for (
int i = 0; i < thread_count; i++) {
2677 for (
int i = 0; i < thread_count; i++) {
2682 edge_count += obi->pending_edges.next;
2687 for (
int i = 0; i < thread_count; i++) {
2693 int v_count = obi->v_eln->element_count;
2694 obi->v_eln->global_index_offset = global_i;
2695 for (
int vi = 0; vi < v_count; vi++) {
2696 v[vi].index += global_i;
2702 obi->global_i_offset = global_i;
2703 global_i += v_count;
2708 if (
G.debug_value == 4000) {
2710 printf(
"Line art loading time: %lf\n", t_elapsed);
2711 printf(
"Discarded %d object from bound box check\n", bound_box_discard_count);
2724 if (tri->
v[0] == vt) {
2729 if (tri->
v[1] == vt) {
2734 if (tri->
v[2] == vt) {
2744 bool allow_overlapping_edges)
2765 if (allow_overlapping_edges) {
2766#define LRT_TRI_SAME_POINT(tri, i, pt) \
2767 ((LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[0], pt->gloc[0]) && \
2768 LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[1], pt->gloc[1]) && \
2769 LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[2], pt->gloc[2])) || \
2770 (LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[0], pt->gloc[0]) && \
2771 LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[1], pt->gloc[1]) && \
2772 LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[2], pt->gloc[2])))
2780#undef LRT_TRI_SAME_POINT
2787#define INTERSECT_SORT_MIN_TO_MAX_3(ia, ib, ic, lst) \
2789 lst[0] = LRT_MIN3_INDEX(ia, ib, ic); \
2790 lst[1] = (((ia <= ib && ib <= ic) || (ic <= ib && ib <= ia)) ? \
2792 (((ic <= ia && ia <= ib) || (ib < ia && ia <= ic)) ? 0 : 2)); \
2793 lst[2] = LRT_MAX3_INDEX(ia, ib, ic); \
2797#define INTERSECT_JUST_GREATER(is, order, num, index) \
2799 index = (num < is[order[0]] ? \
2801 (num < is[order[1]] ? order[1] : (num < is[order[2]] ? order[2] : -1))); \
2805#define INTERSECT_JUST_SMALLER(is, order, num, index) \
2807 index = (num > is[order[2]] ? \
2809 (num > is[order[1]] ? order[1] : (num > is[order[0]] ? order[0] : -1))); \
2812#define LRT_ISEC(index) (index == 0 ? isec_e1 : (index == 1 ? isec_e2 : isec_e3))
2813#define LRT_PARALLEL(index) (index == 0 ? para_e1 : (index == 1 ? para_e2 : para_e3))
2839 const double *override_camera_loc,
2840 const bool override_cam_is_persp,
2841 const bool allow_overlapping_edges,
2842 const double m_view_projection[4][4],
2843 const double camera_dir[3],
2844 const float cam_shift_x,
2845 const float cam_shift_y,
2849 double cross_ratios[3] = {0};
2851 int cross_v1 = -1, cross_v2 = -1;
2853 int isec_e1, isec_e2, isec_e3;
2855 bool para_e1, para_e2, para_e3;
2860 double view_vector[4];
2862 double dot_v1, dot_v2, dot_v1a, dot_v2a;
2864 double gloc[4], trans[4];
2867 double *LFBC =
e->v1->fbcoord, *RFBC =
e->v2->fbcoord, *FBC0 = tri->
v[0]->
fbcoord,
2871 if ((std::max({FBC0[0], FBC1[0], FBC2[0]}) < std::min(LFBC[0], RFBC[0])) ||
2872 (std::min({FBC0[0], FBC1[0], FBC2[0]}) > std::max(LFBC[0], RFBC[0])) ||
2873 (std::max({FBC0[1], FBC1[1], FBC2[1]}) < std::min(LFBC[1], RFBC[1])) ||
2874 (std::min({FBC0[1], FBC1[1], FBC2[1]}) > std::max(LFBC[1], RFBC[1])) ||
2875 (std::min({FBC0[3], FBC1[3], FBC2[3]}) > std::max(LFBC[3], RFBC[3])))
2898 if (override_cam_is_persp) {
2934 if (!isec_e1 && !isec_e2 && !isec_e3) {
2936 if ((!state_v1) && (!state_v2)) {
2943 dot_v1a =
fabs(dot_v1);
2944 if (dot_v1a < DBL_EPSILON) {
2948 dot_v2a =
fabs(dot_v2);
2949 if (dot_v2a < DBL_EPSILON) {
2953 if (dot_v1 - dot_v2 == 0) {
2956 else if (dot_v1 * dot_v2 <= 0) {
2957 cut = dot_v1a /
fabs(dot_v1 - dot_v2);
2960 cut =
fabs(dot_v2 + dot_v1) /
fabs(dot_v1 - dot_v2);
2961 cut = dot_v2a > dot_v1a ? 1 - cut : cut;
2965 if (override_cam_is_persp) {
2969 trans[0] -= cam_shift_x * 2;
2970 trans[1] -= cam_shift_y * 2;
2972 if (
fabs(
e->v1->fbcoord[0] -
e->v2->fbcoord[0]) >
fabs(
e->v1->fbcoord[1] -
e->v2->fbcoord[1]))
2974 cut =
ratiod(
e->v1->fbcoord[0],
e->v2->fbcoord[0], trans[0]);
2977 cut =
ratiod(
e->v1->fbcoord[1],
e->v2->fbcoord[1], trans[1]);
2981#define LRT_GUARD_NOT_FOUND \
2982 if (cross_v1 < 0 || cross_v2 < 0) { \
3075 if (cross_v1 >= 0 &&
LRT_ISEC(cross_v1)) {
3079 if (cross_v1 >= 0) {
3081 if (cross_v1 >= 0) {
3091 double dot_1f = dot_v1 * dot_f, dot_2f = dot_v2 * dot_f;
3094 if (dot_1f <= 0 && dot_2f <= 0 && (dot_v1 || dot_v2)) {
3095 *from = std::max(0.0, cross_ratios[cross_v1]);
3096 *to = std::min(1.0, cross_ratios[cross_v2]);
3102 if (dot_1f >= 0 && dot_2f <= 0 && (dot_v1 || dot_v2)) {
3103 *from = std::max(cut, cross_ratios[cross_v1]);
3104 *to = std::min(1.0, cross_ratios[cross_v2]);
3110 if (dot_1f <= 0 && dot_2f >= 0 && (dot_v1 || dot_v2)) {
3111 *from = std::max(0.0, cross_ratios[cross_v1]);
3112 *to = std::min(cut, cross_ratios[cross_v2]);
3123#undef INTERSECT_SORT_MIN_TO_MAX_3
3124#undef INTERSECT_JUST_GREATER
3125#undef INTERSECT_JUST_SMALLER
3135 if (
l->
v[0]->index == r->
v[0]->
index) {
3136 if (
l->
v[1]->index == r->
v[1]->
index ||
l->
v[1]->index == r->
v[2]->
index ||
3142 if (
l->
v[0]->index == r->
v[1]->
index) {
3143 if (
l->
v[1]->index == r->
v[0]->
index ||
l->
v[1]->index == r->
v[2]->
index ||
3149 if (
l->
v[0]->index == r->
v[2]->
index) {
3150 if (
l->
v[1]->index == r->
v[1]->
index ||
l->
v[1]->index == r->
v[0]->
index ||
3156 if (
l->
v[1]->index == r->
v[0]->
index) {
3157 if (
l->
v[2]->index == r->
v[1]->
index ||
l->
v[2]->index == r->
v[2]->
index ||
3163 if (
l->
v[1]->index == r->
v[1]->
index) {
3164 if (
l->
v[2]->index == r->
v[0]->
index ||
l->
v[2]->index == r->
v[2]->
index ||
3170 if (
l->
v[1]->index == r->
v[2]->
index) {
3171 if (
l->
v[2]->index == r->
v[1]->
index ||
l->
v[2]->index == r->
v[0]->
index ||
3185 if (
l->
v[0] == r->
v[0]) {
3188 if (
l->
v[0] == r->
v[1]) {
3191 if (
l->
v[0] == r->
v[2]) {
3194 if (
l->
v[1] == r->
v[0]) {
3197 if (
l->
v[1] == r->
v[1]) {
3200 if (
l->
v[1] == r->
v[2]) {
3203 if (
l->
v[2] == r->
v[0]) {
3206 if (
l->
v[2] == r->
v[1]) {
3209 if (
l->
v[2] == r->
v[2]) {
3220 double dir_v1[3], dir_v2[3];
3221 double dot_v1, dot_v2;
3230 if (dot_v1 * dot_v2 > 0 || (!dot_v1 && !dot_v2)) {
3234 dot_v1 =
fabs(dot_v1);
3235 dot_v2 =
fabs(dot_v2);
3260 double *next = v1, *last =
nullptr;
3337 size_t(th->
max) * 2,
"LineartIsecSingle");
3340 MEM_delete(th->
array);
3341 th->
array = new_array;
3346 isec_single->
tri1 = tri1;
3347 isec_single->
tri2 = tri2;
3349 std::swap(isec_single->
tri1, isec_single->
tri2);
3354#define LRT_ISECT_TRIANGLE_PER_THREAD 4096
3372 while (remaining > 0 && eln) {
3374 int added_count = std::min(remaining, remaining_this_eln);
3375 remaining -= added_count;
3376 if (remaining || added_count == remaining_this_eln) {
3411 for (
int i = 0; i < thread_count; i++) {
3425 MEM_delete(it->
array);
3441 double *G0 = tri->
v[0]->
gloc, *G1 = tri->
v[1]->
gloc, *G2 = tri->
v[2]->
gloc;
3444 for (
int i = 0; i < up_to; i++) {
3450 if (testing_triangle == tri ||
3465 double *RG0 = testing_triangle->
v[0]->
gloc, *RG1 = testing_triangle->
v[1]->
gloc,
3466 *RG2 = testing_triangle->
v[2]->
gloc;
3469 if ((std::min({G0[2], G1[2], G2[2]}) > std::max({RG0[2], RG1[2], RG2[2]})) ||
3470 (std::max({G0[2], G1[2], G2[2]}) < std::min({RG0[2], RG1[2], RG2[2]})) ||
3471 (std::min({G0[0], G1[0], G2[0]}) > std::max({RG0[0], RG1[0], RG2[0]})) ||
3472 (std::max({G0[0], G1[0], G2[0]}) < std::min({RG0[0], RG1[0], RG2[0]})) ||
3473 (std::min({G0[1], G1[1], G2[1]}) > std::max({RG0[1], RG1[1], RG2[1]})) ||
3474 (std::max({G0[1], G1[1], G2[1]}) < std::min({RG0[1], RG1[1], RG2[1]})) ||
3482 double iv1[3], iv2[3];
3491 float direction[3] = {0, 0, 1};
3494 float obmat_no_scale[4][4];
3523 for (
int i = 0; i < 4; i++) {
3531 if (ld ==
nullptr) {
3535 ld->
chains.clear_no_delete();
3556 if (ld ==
nullptr) {
3580 if (
G.debug_value == 4000) {
3581 printf(
"LRT: Destroyed render data.\n");
3612 if (!scene || !
camera || !lc) {
3616 double clipping_offset = 0;
3620 clipping_offset = 0.0001;
3624 if (active_camera) {
3647 double asp = double(ld->
w) / double(ld->
h);
3767 if (ld->
w > ld->
h) {
3768 sp_w = sp_h * ld->
w / ld->
h;
3771 sp_h = sp_w * ld->
h / ld->
w;
3776 double span_w = 1.0 / sp_w * 2.0;
3777 double span_h = 1.0 / sp_h * 2.0;
3792 for (row = 0; row < sp_h; row++) {
3793 for (col = 0; col < sp_w; col++) {
3797 ba->
l = span_w * col - 1.0;
3798 ba->
r = (col == sp_w - 1) ? 1.0 : (span_w * (col + 1) - 1.0);
3799 ba->
u = 1.0 - span_h * row;
3800 ba->
b = (row == sp_h - 1) ? -1.0 : (1.0 - span_h * (row + 1));
3802 ba->
cx = (ba->
l + ba->
r) / 2;
3803 ba->
cy = (ba->
u + ba->
b) / 2;
3809 "ba_linked_triangles");
3848 if (ba[1].u > tba->
b && ba[1].
b < tba->u) {
3852 if (ba[2].u > tba->
b && ba[2].
b < tba->u) {
3859 if (ba[0].u > tba->
b && ba[0].
b < tba->u) {
3863 if (ba[3].u > tba->
b && ba[3].
b < tba->u) {
3870 if (ba[0].r > tba->
l && ba[0].
l < tba->r) {
3874 if (ba[1].r > tba->
l && ba[1].
l < tba->r) {
3881 if (ba[2].r > tba->
l && ba[2].
l < tba->r) {
3885 if (ba[3].r > tba->
l && ba[3].
l < tba->r) {
3898 next_lip = lip2->
next;
3903 if (ba[1].u > tba->
b && ba[1].
b < tba->u) {
3906 if (ba[2].u > tba->
b && ba[2].
b < tba->u) {
3917 next_lip = lip2->
next;
3922 if (ba[0].u > tba->
b && ba[0].
b < tba->u) {
3925 if (ba[3].u > tba->
b && ba[3].
b < tba->u) {
3936 next_lip = lip2->
next;
3941 if (ba[0].r > tba->
l && ba[0].
l < tba->r) {
3944 if (ba[1].r > tba->
l && ba[1].
l < tba->r) {
3955 next_lip = lip2->
next;
3960 if (ba[2].r > tba->
l && ba[2].
l < tba->r) {
3963 if (ba[3].r > tba->
l && ba[3].
l < tba->r) {
3971 root->
lp.clear_no_delete();
3972 root->
rp.clear_no_delete();
3973 root->
up.clear_no_delete();
3974 root->
bp.clear_no_delete();
3981 for (
int i = 0; i < 4; i++) {
4014 for (
int i = 0; i < total_tile_initial; i++) {
4025 int recursive_level)
4033 ba[0].
cx = (ba[0].
l + ba[0].
r) / 2;
4034 ba[0].
cy = (ba[0].
u + ba[0].
b) / 2;
4040 ba[1].
cx = (ba[1].
l + ba[1].
r) / 2;
4041 ba[1].
cy = (ba[1].
u + ba[1].
b) / 2;
4047 ba[2].
cx = (ba[2].
l + ba[2].
r) / 2;
4048 ba[2].
cy = (ba[2].
u + ba[2].
b) / 2;
4054 ba[3].
cx = (ba[3].
l + ba[3].
r) / 2;
4055 ba[3].
cy = (ba[3].
u + ba[3].
b) / 2;
4058 for (
int i = 0; i < 4; i++) {
4062 "ba_linked_triangles");
4081 ld, &ba[0], tri,
b, 0, recursive_level + 1,
false,
nullptr);
4085 ld, &ba[1], tri,
b, 0, recursive_level + 1,
false,
nullptr);
4089 ld, &ba[2], tri,
b, 0, recursive_level + 1,
false,
nullptr);
4093 ld, &ba[3], tri,
b, 0, recursive_level + 1,
false,
nullptr);
4108 double converted[4];
4111 if (((converted[0] = ba->
l) > std::max(
l[0], r[0])) ||
4112 ((converted[1] = ba->
r) < std::min(
l[0], r[0])) ||
4113 ((converted[2] = ba->
b) > std::max(
l[1], r[1])) ||
4114 ((converted[3] = ba->
u) < std::min(
l[1], r[1])))
4122 c1 = dx * (converted[2] -
l[1]) - dy * (converted[0] -
l[0]);
4125 c1 = dx * (converted[2] -
l[1]) - dy * (converted[1] -
l[0]);
4131 c1 = dx * (converted[3] -
l[1]) - dy * (converted[0] -
l[0]);
4137 c1 = dx * (converted[3] -
l[1]) - dy * (converted[1] -
l[0]);
4149 bool *r_triangle_vert_inside)
4151 double p1[2], p2[2], p3[2], p4[2];
4154 p3[0] = p1[0] = ba->
l;
4155 p2[1] = p1[1] = ba->
b;
4156 p2[0] = p4[0] = ba->
r;
4157 p3[1] = p4[1] = ba->
u;
4159 if ((FBC1[0] >= p1[0] && FBC1[0] <= p2[0] && FBC1[1] >= p1[1] && FBC1[1] <= p3[1]) ||
4160 (FBC2[0] >= p1[0] && FBC2[0] <= p2[0] && FBC2[1] >= p1[1] && FBC2[1] <= p3[1]) ||
4161 (FBC3[0] >= p1[0] && FBC3[0] <= p2[0] && FBC3[1] >= p1[1] && FBC3[1] <= p3[1]))
4163 *r_triangle_vert_inside =
true;
4167 *r_triangle_vert_inside =
false;
4204 int recursive_level,
4205 bool do_intersection,
4208 bool triangle_vert_inside;
4215 if (old_ba->
child) {
4218 double *B1 = l_r_u_b;
4227 for (
int iba = 0; iba < 4; iba++) {
4230 ld, &old_ba->
child[iba], tri, B1, recursive, recursive_level + 1, do_intersection, th);
4248 if (triangle_vert_inside) {
4264 if (recursive_level < ld->qtree.recursive_level &&
4267 if (!old_ba->
child) {
4286 ld, root_ba, tri, l_r_u_b, recursive, recursive_level, do_intersection, th);
4299 if (recursive && ba->
child) {
4300 for (
int i = 0; i < 4; i++) {
4318 if (root_ba->
child ==
nullptr) {
4323 ld,
e->v1->fbcoord,
e->v2->fbcoord, &root_ba->
child[0]))
4328 ld,
e->v1->fbcoord,
e->v2->fbcoord, &root_ba->
child[1]))
4333 ld,
e->v1->fbcoord,
e->v2->fbcoord, &root_ba->
child[2]))
4338 ld,
e->v1->fbcoord,
e->v2->fbcoord, &root_ba->
child[3]))
4347 if (root_ba->
child) {
4348 for (
int i = 0; i < 4; i++) {
4358 "cleared lineart edges");
4374 int r1, r2, c1, c2, row, col;
4376 for (row = r1; row != r2 + 1; row++) {
4377 for (col = c1; col != c2 + 1; col++) {
4391 for (
int i = 0; i < 4; i++) {
4401 int usable_count = 0;
4404 if (
e->min_occ > max_occlusion) {
4410 if (!usable_count) {
4416 "cleaned lineart edge array");
4421 if (
e->min_occ > max_occlusion) {
4424 new_array[new_i] =
e;
4449 if (!tri->
v[0] || !tri->
v[1] || !tri->
v[2]) {
4458 if (
b[0] > 1 ||
b[1] < -1 ||
b[2] > 1 ||
b[3] < -1) {
4462 (*colbegin) = int((
b[0] + 1.0) / sp_w);
4463 (*colend) = int((
b[1] + 1.0) / sp_w);
4464 (*rowend) = ld->
qtree.
count_y - int((
b[2] + 1.0) / sp_h) - 1;
4465 (*rowbegin) = ld->
qtree.
count_y - int((
b[3] + 1.0) / sp_h) - 1;
4473 *colbegin = std::max(*colbegin, 0);
4474 *rowbegin = std::max(*rowbegin, 0);
4485 if (!
e->v1 || !
e->v2) {
4489 if (
e->v1->fbcoord[0] !=
e->v1->fbcoord[0] ||
e->v2->fbcoord[0] !=
e->v2->fbcoord[0]) {
4493 b[0] = std::min(
e->v1->fbcoord[0],
e->v2->fbcoord[0]);
4494 b[1] = std::max(
e->v1->fbcoord[0],
e->v2->fbcoord[0]);
4495 b[2] = std::min(
e->v1->fbcoord[1],
e->v2->fbcoord[1]);
4496 b[3] = std::max(
e->v1->fbcoord[1],
e->v2->fbcoord[1]);
4498 if (
b[0] > 1 ||
b[1] < -1 ||
b[2] > 1 ||
b[3] < -1) {
4502 (*colbegin) = int((
b[0] + 1.0) / sp_w);
4503 (*colend) = int((
b[1] + 1.0) / sp_w);
4504 (*rowend) = ld->
qtree.
count_y - int((
b[2] + 1.0) / sp_h) - 1;
4505 (*rowbegin) = ld->
qtree.
count_y - int((
b[3] + 1.0) / sp_h) - 1;
4508 if ((*rowend) < (*rowbegin)) {
4512 if ((*colend) < (*colbegin)) {
4533 col = int((
x + 1.0) / sp_w);
4542 col = std::max(col, 0);
4543 row = std::max(row, 0);
4552 int c = int((
x + 1.0) / sp_w);
4564 while (iba->
child) {
4567 iba = &iba->
child[0];
4570 iba = &iba->
child[3];
4575 iba = &iba->
child[1];
4578 iba = &iba->
child[2];
4606 for (
int ei = index_start; ei < index_end; ei++) {
4616 for (co = x1; co <= x2; co++) {
4617 for (r = y1; r <= y2; r++) {
4641 int total_lines = 0;
4645 if (
G.debug_value == 4000) {
4646 printf(
"Thread %d isec generated %d lines.\n", i, th->
current);
4680 for (
int j = 0; j < th->
current; j++) {
4703 v2->fbcoord[2] = ZMin * ZMax / (ZMax -
fabs(
v2->fbcoord[2]) * (ZMax - ZMin));
4709 e->edge_identifier = (
uint64_t(
e->t1->target_reference) << 32) |
e->t2->target_reference;
4723 if (
e->t1->intersection_priority >=
e->t2->intersection_priority) {
4726 e->object_ref = ob1;
4728 else if (
e->t1->intersection_priority <
e->t2->intersection_priority) {
4729 e->object_ref = ob2;
4744 if (
G.debug_value == 4000) {
4770 if (
G.debug_value == 4000) {
4772 printf(
"Line art intersection time: %f\n", t_elapsed);
4780 double data[2] = {fbcoord1[0], fbcoord1[1]};
4781 double LU[2] = {-1, 1}, RU[2] = {1, 1},
LB[2] = {-1, -1},
RB[2] = {1, -1};
4782 double r = 1, sr = 1;
4817 double rx, ry, ux, uy, lx, ly, bx, by;
4822 if (positive_x > 0) {
4824 ry =
y + k * (rx -
x);
4827 if (positive_y > 0) {
4829 ux =
x + (uy -
y) / k;
4830 r1 =
ratiod(fbcoord1[0], fbcoord2[0], rx);
4831 r2 =
ratiod(fbcoord1[0], fbcoord2[0], ux);
4832 if (std::min(r1, r2) > 1) {
4840 if (ba->
u >= ry && ba->
b < ry) {
4851 if (ba->
r >= ux && ba->
l < ux) {
4860 else if (positive_y < 0) {
4862 bx =
x + (by -
y) / k;
4863 r1 =
ratiod(fbcoord1[0], fbcoord2[0], rx);
4864 r2 =
ratiod(fbcoord1[0], fbcoord2[0], bx);
4865 if (std::min(r1, r2) > 1) {
4871 if (ba->
u >= ry && ba->
b < ry) {
4881 if (ba->
r >= bx && ba->
l < bx) {
4891 r1 =
ratiod(fbcoord1[0], fbcoord2[0], self->
r);
4897 if (ba->
u >=
y && ba->
b <
y) {
4907 else if (positive_x < 0) {
4909 ly =
y + k * (lx -
x);
4912 if (positive_y > 0) {
4914 ux =
x + (uy -
y) / k;
4915 r1 =
ratiod(fbcoord1[0], fbcoord2[0], lx);
4916 r2 =
ratiod(fbcoord1[0], fbcoord2[0], ux);
4917 if (std::min(r1, r2) > 1) {
4923 if (ba->
u >= ly && ba->
b < ly) {
4933 if (ba->
r >= ux && ba->
l < ux) {
4943 else if (positive_y < 0) {
4945 bx =
x + (by -
y) / k;
4946 r1 =
ratiod(fbcoord1[0], fbcoord2[0], lx);
4947 r2 =
ratiod(fbcoord1[0], fbcoord2[0], bx);
4948 if (std::min(r1, r2) > 1) {
4954 if (ba->
u >= ly && ba->
b < ly) {
4964 if (ba->
r >= bx && ba->
l < bx) {
4974 r1 =
ratiod(fbcoord1[0], fbcoord2[0], self->
l);
4980 if (ba->
u >=
y && ba->
b <
y) {
4990 if (positive_y > 0) {
4991 r1 =
ratiod(fbcoord1[1], fbcoord2[1], self->
u);
4997 if (ba->
r >
x && ba->
l <=
x) {
5004 else if (positive_y < 0) {
5005 r1 =
ratiod(fbcoord1[1], fbcoord2[1], self->
b);
5011 if (ba->
r >
x && ba->
l <=
x) {
5029 bool enable_stroke_depth_offset)
5033 int intersections_only = 0;
5034 Object *lineart_camera =
nullptr;
5037 if (
G.debug_value == 4000) {
5041 bool use_render_camera_override =
false;
5053 use_render_camera_override =
true;
5055 if (!lineart_camera) {
5060 lineart_camera = scene->
camera;
5071 *cached_result = lc;
5077 use_render_camera_override ? lineart_camera : scene->
camera,
5113 if (shadow_generated) {
5161 if (!intersections_only) {
5220 MEM_delete(shadow_rb);
5223 if (
G.debug_value == 4000) {
5227 printf(
"Line art total time: %lf\n", t_elapsed);
5240 Depsgraph *depsgraph,
5242 const int8_t source_type,
5245 const int level_start,
5246 const int level_end,
5249 const uchar mask_switches,
5250 const uchar material_mask_bits,
5251 const uchar intersection_mask,
5252 const float thickness,
5253 const float opacity,
5254 const bool fill_strokes,
5255 const uchar shadow_selection,
5256 const uchar silhouette_mode,
5257 const char *source_vgname,
5259 const int modifier_flags,
5260 const int modifier_calculation_flags)
5262 if (
G.debug_value == 4000) {
5263 printf(
"Line Art v3: Generating...\n");
5266 if (cache ==
nullptr) {
5267 if (
G.debug_value == 4000) {
5268 printf(
"nullptr Lineart cache!\n");
5273 Object *orig_ob =
nullptr;
5277 if (!source_object) {
5285 if (!source_collection) {
5288 orig_col = source_collection->
id.
orig_id ?
5289 id_cast<Collection *>(source_collection->
id.
orig_id) :
5303 int total_point_count = 0;
5304 int stroke_count = 0;
5310 if (!(ec.
type & (edge_types & enabled_types))) {
5313 if (ec.
level > level_end || ec.
level < level_start) {
5355 if (shadow_selection) {
5379 bool is_silhouette =
false;
5382 is_silhouette =
true;
5386 is_silhouette =
true;
5391 is_silhouette =
true;
5398 is_silhouette =
true;
5401 if (inverse_silhouette) {
5402 is_silhouette = !is_silhouette;
5404 if (!is_silhouette) {
5417 total_point_count += count;
5418 writer.
append({&ec, count});
5423 if (!total_point_count || !stroke_count) {
5437 "radius", AttrDomain::Point);
5440 "opacity", AttrDomain::Point);
5443 "material_index", AttrDomain::Curve);
5447 const bool weight_transfer_match_output = modifier_calculation_flags &
5450 auto find_target_defgroup = [&](
StringRef group_name) {
5451 if (group_name.is_empty()) {
5455 int group_index = 0;
5468 int up_to_point = 0;
5475 Mesh *src_mesh =
nullptr;
5477 int target_defgroup = find_target_defgroup(vgname);
5478 if (source_vgname) {
5482 src_dvert = src_mesh->deform_verts();
5486 if ((!skip_weight_transfer) && (!src_dvert.
is_empty())) {
5489 for (
const auto [group_index, defgroup] : (deflist)->enumerate()) {
5490 if (
StringRef(defgroup.name).startswith(source_vgname)) {
5491 const int target_group_index = weight_transfer_match_output ?
5492 find_target_defgroup(defgroup.name) :
5494 src_to_dst_defgroup.
append(target_group_index);
5497 src_to_dst_defgroup.
append(-1);
5502 auto transfer_to_matching_groups = [&](
const int64_t source_index,
const int target_index) {
5503 for (
const int from_group : src_to_dst_defgroup.
index_range()) {
5504 if (from_group < 0 || src_to_dst_defgroup[from_group] < 0 ||
5512 src_to_dst_defgroup[from_group]);
5513 const float source_weight = mdw_from ? mdw_from->
weight : 0.0f;
5514 mdw_to->
weight = invert_input ? (1 - source_weight) : source_weight;
5518 auto transfer_to_singular_group = [&](
const int64_t source_index,
const int target_index) {
5519 if (target_defgroup < 0) {
5522 float highest_weight = 0.0f;
5523 for (
const int from_group : src_to_dst_defgroup.
index_range()) {
5524 if (from_group < 0 ||
UNLIKELY(source_index >= src_dvert.
size())) {
5529 const float source_weight = mdw_from ? mdw_from->
weight : 0.0f;
5530 highest_weight = std::max(highest_weight, source_weight);
5533 mdw_to->
weight = invert_input ? (1 - highest_weight) : highest_weight;
5536 for (
const auto [i, eci] : cwi.
chain->
chain.enumerate()) {
5537 int point_i = i + up_to_point;
5539 point_radii.
span[point_i] = thickness / 2.0f;
5540 if (point_opacities) {
5541 point_opacities.span[point_i] = opacity;
5546 if (!src_to_dst_defgroup.
is_empty()) {
5547 if (weight_transfer_match_output) {
5548 transfer_to_matching_groups(vindex, point_i);
5551 transfer_to_singular_group(vindex, point_i);
5556 offsets[chain_i] = up_to_point;
5557 stroke_materials.span[chain_i] =
max_ii(mat_nr, 0);
5564 "cyclic", AttrDomain::Curve);
5565 stroke_cyclic.
span.fill(
false);
5569 point_opacities.finish();
5570 stroke_materials.finish();
5574 "fill_id", AttrDomain::Curve);
5588 if (
G.debug_value == 4000) {
5589 printf(
"LRT: Generated %d strokes.\n", stroke_count);
Camera data-block and utility functions.
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define ISECT_LINE_LINE_NONE
Platform independent time functions.
#define DEG_OBJECT_ITER_BEGIN(settings_, instance_)
#define DEG_OBJECT_ITER_END
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define LRT_TILE_EDGE_COUNT_INITIAL
#define LRT_DOUBLE_CLOSE_ENOUGH(a, b)
#define LRT_SHADOW_MASK_INHIBITED
#define LRT_SHADOW_MASK_UNDEFINED
#define LRT_OBINDEX_LOWER
#define LRT_OBINDEX_SHIFT
#define LRT_SHADOW_MASK_ILLUMINATED_SHAPE
#define LRT_LIGHT_CONTOUR_TARGET
#define LRT_SHADOW_MASK_ENCLOSED_SHAPE
#define LRT_SHADOW_TEST_SHAPE_BITS
#define LRT_OBINDEX_HIGHER
#define LRT_SHADOW_MASK_ILLUMINATED
#define LRT_TILE_SPLITTING_TRIANGLE_LIMIT
#define LRT_THREAD_EDGE_COUNT
#define LRT_SHADOW_MASK_SHADED
#define LRT_EDGE_IDENTIFIER(obi, e)
#define MEM_realloc_zeroed(vmemh, len)
constexpr MutableSpan()=default
constexpr int64_t size() const
constexpr bool is_empty() const
void append(const T &value)
IndexRange index_range() const
void reserve(const int64_t min_capacity)
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef name) const
MutableSpan< MDeformVert > deform_verts_for_write()
MutableSpan< float3 > positions_for_write()
MutableSpan< int > offsets_for_write()
void fill_curve_types(CurveType type)
MutableAttributeAccessor attributes_for_write()
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_or_add_for_write_only_span(StringRef name, AttrDomain domain, AttrType data_type)
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
void tag_topology_changed()
constexpr int64_t last(const int64_t n=0) const
constexpr bool is_empty() const
void to_indices(MutableSpan< T > r_indices) const
float length(VecOp< float, D >) RET
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
#define INTERSECT_JUST_SMALLER(is, order, num, index)
#define LRT_MESH_EDGE_TYPES_COUNT
#define RELINK_EDGE(e_num, new_tri)
#define LRT_VERT_OUT_OF_BOUND(v)
#define LRT_CULL_DECIDE_INSIDE
#define LRT_ISECT_TRIANGLE_PER_THREAD
#define REMOVE_TRIANGLE_EDGE
#define LRT_PARALLEL(index)
#define INTERSECT_JUST_GREATER(is, order, num, index)
#define LRT_TRI_SAME_POINT(tri, i, pt)
#define INTERSECT_SORT_MIN_TO_MAX_3(ia, ib, ic, lst)
#define SELECT_EDGE(e_num, v1_link, v2_link, new_tri)
#define LRT_CULL_ENSURE_MEMORY
#define LRT_GUARD_NOT_FOUND
#define LRT_BOUND_AREA_CROSSES(b1, b2)
#define LRT_EDGE_BA_MARCHING_BEGIN(fb1, fb2)
#define LRT_EDGE_BA_MARCHING_NEXT(fb1, fb2)
#define LRT_EDGE_BA_MARCHING_END
#define LRT_ITER_ALL_LINES_END
#define LRT_ITER_ALL_LINES_BEGIN
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
void gather_next_available_fill_ids(const VArray< int > &fill_ids, MutableSpan< int > r_new_fill_ids)
int3 corner_tri_get_real_edges(Span< int2 > edges, Span< int > corner_verts, Span< int > corner_edges, const int3 &corner_tri)
Curves * curves_new_nomain(int points_num, int curves_num)
std::array< VecBase< T, 3 >, 8 > corners(const Bounds< VecBase< T, 3 > > &bounds)
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt, bool allow_merging_instance_references=true)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void lineart_main_discard_out_of_frame_edges(LineartData *ld)
static void lineart_occlusion_single_line(LineartData *ld, LineartEdge *e, int thread_id)
bool lineart_edge_from_triangle(const LineartTriangle *tri, const LineartEdge *e, bool allow_overlapping_edges)
static LineartBoundingArea * lineart_get_bounding_area(LineartData *ld, double x, double y)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static uchar lineart_intersection_mask_check(Collection *c, Object *ob)
static void lineart_object_load_worker(TaskPool *__restrict, LineartObjectLoadTaskInfo *olti)
void MOD_lineart_smooth_chains(LineartData *ld, float tolerance)
unsigned __int64 uint64_t
LineartBoundingArea * MOD_lineart_get_parent_bounding_area(LineartData *ld, double x, double y)
@ COLLECTION_LRT_NO_INTERSECTION
@ COLLECTION_LRT_OCCLUSION_ONLY
@ COLLECTION_LRT_INTERSECTION_ONLY
@ COLLECTION_LRT_FORCE_INTERSECTION
static void lineart_bounding_areas_connect_new(LineartData *ld, LineartBoundingArea *root)
static LineartTriangle * lineart_triangle_from_index(LineartData *ld, LineartTriangle *rt_array, int index)
MINLINE void sub_v2_v2v2_db(double r[2], const double a[2], const double b[2])
static void lineart_discard_segment(LineartData *ld, LineartEdgeSegment *es)
void lineart_list_remove_pointer_item_no_free(ListBase *h, LinkData *lip)
LineartEdge * lineart_find_matching_edge(struct LineartElementLinkNode *shadow_eln, uint64_t edge_identifier)
bool BKE_collection_has_object_recursive_instanced(Collection *collection, Object *ob)
static void lineart_geometry_object_load(LineartObjectInfo *ob_info, LineartData *la_data, ListBaseT< LineartElementLinkNode > *shadow_elns)
@ LRT_ELEMENT_BORDER_ONLY
@ LRT_ELEMENT_IS_ADDITIONAL
@ LRT_ELEMENT_INTERSECTION_DATA
@ LRT_ELEMENT_NO_INTERSECTION
MINLINE double dot_v3v3_db(const double a[3], const double b[3]) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
@ LRT_TRIANGLE_MAT_BACK_FACE_CULLING
@ LRT_TRIANGLE_FORCE_INTERSECTION
@ LRT_TRIANGLE_INTERSECTION_ONLY
@ LRT_TRIANGLE_NO_INTERSECTION
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static void lineart_end_bounding_area_recursive(LineartBoundingArea *ba)
MINLINE void copy_v3db_v3fl(double r[3], const float a[3])
static void lineart_identify_corner_tri_feature_edges(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict tls)
void lineart_main_bounding_areas_connect_post(LineartData *ld)
static void lineart_add_edge_to_array_thread(LineartObjectInfo *obi, LineartEdge *e)
@ LRT_TILE_RECURSIVE_PERSPECTIVE
@ LRT_TILE_RECURSIVE_ORTHO
void lineart_main_load_geometries(Depsgraph *depsgraph, Scene *scene, Object *camera, LineartData *ld, bool allow_duplicates, bool do_shadow_casting, ListBaseT< LineartElementLinkNode > *shadow_elns, Set< const Object * > *included_objects)
BLI_INLINE bool lineart_occlusion_is_adjacent_intersection(LineartEdge *e, LineartTriangle *tri)
static void lineart_init_isec_thread(LineartIsecData *d, LineartData *ld, int thread_count)
static int lineart_triangle_size_get(LineartData *ld)
BLI_INLINE float fb(float length, float L)
static int lineart_usage_check(Collection *c, Object *ob, bool is_render)
static void lineart_triangle_cull_single(LineartData *ld, LineartTriangle *tri, int in0, int in1, int in2, double cam_pos[3], double view_dir[3], bool allow_boundaries, double m_view_projection[4][4], Object *ob, int *r_v_count, int *r_e_count, int *r_t_count, LineartElementLinkNode *v_eln, LineartElementLinkNode *e_eln, LineartElementLinkNode *t_eln)
static bool lineart_bounding_area_triangle_intersect(LineartData *fb, LineartTriangle *tri, LineartBoundingArea *ba, bool *r_triangle_vert_inside)
static void lineart_destroy_isec_thread(LineartIsecData *d)
Material * BKE_object_material_get(Object *ob, short act)
void lineart_count_and_print_render_buffer_memory(struct LineartData *ld)
static bool lineart_get_edge_bounding_areas(LineartData *ld, LineartEdge *e, int *rowbegin, int *rowend, int *colbegin, int *colend)
@ COLLECTION_LRT_USE_INTERSECTION_PRIORITY
@ COLLECTION_LRT_USE_INTERSECTION_MASK
LineartBoundingArea * lineart_edge_first_bounding_area(LineartData *ld, double *fbcoord1, double *fbcoord2)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void MOD_lineart_clear_cache(LineartCache **lc)
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void MOD_lineart_chain_feature_lines(LineartData *ld)
void * lineart_list_append_pointer_pool_sized(ListBase *h, struct LineartStaticMemPool *smp, void *data, int size)
static void lineart_edge_neighbor_init_task(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static bool lineart_schedule_new_triangle_task(LineartIsecThread *th)
void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], double t)
void lineart_matrix_perspective_44d(double(*mProjection)[4], double fFov_rad, double fAspect, double zMin, double zMax)
MINLINE int max_ii(int a, int b)
int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
@ OBJECT_LRT_OWN_INTERSECTION_PRIORITY
ATTR_WARN_UNUSED_RESULT const BMVert * v
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void MOD_lineart_chain_offset_towards_camera(LineartData *ld, float dist, bool use_custom_camera)
static void lineart_mvert_transform_task(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
static LineartVert * lineart_triangle_share_point(const LineartTriangle *l, const LineartTriangle *r)
MatBase< float, 4, 4 > float4x4
void lineart_destroy_render_data_keep_init(LineartData *ld)
MINLINE void copy_v3_v3_db(double r[3], const double a[3])
void MOD_lineart_finalize_chains(LineartData *ld)
static void lineart_destroy_render_data(LineartData *ld)
void MEM_delete_void(void *vmemh)
void * lineart_list_append_pointer_pool_sized_thread(ListBase *h, LineartStaticMemPool *smp, void *data, int size)
void MOD_lineart_chain_clip_at_border(LineartData *ld)
static void lineart_triangle_adjacent_assign(LineartTriangle *tri, LineartTriangleAdjacent *tri_adj, LineartEdge *e)
static void lineart_occlusion_worker(TaskPool *__restrict, LineartRenderTaskInfo *rti)
MINLINE double ratiod(double min, double max, double pos)
LineartBoundingArea * lineart_bounding_area_next(LineartBoundingArea *self, double *fbcoord1, double *fbcoord2, double x, double y, double k, int positive_x, int positive_y, double *next_x, double *next_y)
static LineartEdgeNeighbor * lineart_build_edge_neighbor(Mesh *mesh, int total_edges)
bool MOD_lineart_compute_feature_lines_v3(Depsgraph *depsgraph, GreasePencilLineartModifierData &lmd, LineartCache **cached_result, bool enable_stroke_depth_offset)
int MOD_lineart_chain_count(const LineartEdgeChain *ec)
bool BKE_collection_has_object(Collection *collection, const Object *ob)
void BLI_task_pool_work_and_wait(TaskPool *pool)
static void lineart_add_isec_thread(LineartIsecThread *th, const double *v1, const double *v2, LineartTriangle *tri1, LineartTriangle *tri2)
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
void MOD_lineart_chain_clear_picked_flag(LineartCache *lc)
@ LINEART_SILHOUETTE_FILTER_INDIVIDUAL
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
static void lineart_main_remove_unused_lines_from_tiles(LineartData *ld)
@ OBJECT_LRT_OCCLUSION_ONLY
@ OBJECT_LRT_INTERSECTION_ONLY
@ OBJECT_LRT_FORCE_INTERSECTION
@ OBJECT_LRT_NO_INTERSECTION
float focallength_to_fov(float focal_length, float sensor)
int BKE_render_num_threads(const RenderData *r)
void BLI_spin_end(SpinLock *spin)
Render * RE_GetSceneRender(const Scene *scene)
static void lineart_load_tri_task(void *__restrict userdata, const int i, const TaskParallelTLS *__restrict)
void lineart_add_edge_to_array(LineartPendingEdges *pe, LineartEdge *e)
static bool lineart_edge_match(LineartTriangle *tri, LineartEdge *e, int v1, int v2)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
void lineart_main_clear_linked_edges(LineartData *ld)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void MOD_lineart_chain_split_for_fixed_occlusion(LineartData *ld)
void mul_v4_m4v3_db(double r[4], const double mat[4][4], const double vec[3])
void copy_m4_m4_db(double m1[4][4], const double m2[4][4])
void * lineart_list_append_pointer_pool_thread(ListBase *h, struct LineartStaticMemPool *smp, void *data)
static const int LRT_MESH_EDGE_TYPES[]
static uchar lineart_intersection_priority_check(Collection *c, Object *ob)
void lineart_register_intersection_shadow_cuts(struct LineartData *ld, ListBaseT< LineartElementLinkNode > *shadow_elns)
void lineart_main_add_triangles(LineartData *ld)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
static void lineart_finalize_object_edge_array(LineartPendingEdges *pe, LineartObjectInfo *obi)
static bool lineart_get_triangle_bounding_areas(LineartData *ld, LineartTriangle *tri, int *rowbegin, int *rowend, int *colbegin, int *colend)
void lineart_matrix_ortho_44d(double(*mProjection)[4], double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
BMesh const char void * data
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void lineart_main_occlusion_begin(LineartData *ld)
static void lineart_clear_linked_edges_recursive(LineartData *ld, LineartBoundingArea *root_ba)
static int lineart_edge_type_duplication_count(int eflag)
void MOD_lineart_gpencil_generate_v3(const LineartCache *cache, const float4x4 &inverse_mat, Depsgraph *depsgraph, bke::greasepencil::Drawing &drawing, const int8_t source_type, Object *source_object, Collection *source_collection, const int level_start, const int level_end, const int mat_nr, const int16_t edge_types, const uchar mask_switches, const uchar material_mask_bits, const uchar intersection_mask, const float thickness, const float opacity, const bool fill_strokes, const uchar shadow_selection, const uchar silhouette_mode, const char *source_vgname, const char *vgname, const int modifier_flags, const int modifier_calculation_flags)
static int lineart_point_on_line_segment(double v[2], double v0[2], double v1[2])
int BKE_object_visibility(const Object *ob, int dag_eval_mode)
static void lineart_bounding_area_split(LineartData *ld, LineartBoundingArea *root, int recursive_level)
static bool lineart_triangle_share_edge(const LineartTriangle *l, const LineartTriangle *r)
int3 corner_tri_get_real_edges(Span< int2 > edges, Span< int > corner_verts, Span< int > corner_edges, const int3 &corner_tri)
void MOD_lineart_chain_split_angle(LineartData *ld, float angle_threshold_rad)
static LineartElementLinkNode * lineart_memory_get_vert_space(LineartData *ld)
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_DUPLI
MINLINE void cross_v3_v3v3_db(double r[3], const double a[3], const double b[3])
void MOD_lineart_chain_connect(LineartData *ld)
static void lineart_sort_adjacent_items(LineartAdjacentEdge *ai, int length)
MDeformWeight * BKE_defvert_ensure_index(MDeformVert *dv, int defgroup)
void(*) TaskRunFunction(TaskPool *__restrict pool, void *taskdata)
void MOD_lineart_destroy_render_data_v3(GreasePencilLineartModifierData *lmd)
static bool lineart_geometry_check_visible(double model_view_proj[4][4], double shift_x, double shift_y, Mesh *use_mesh)
static bool lineart_triangle_2v_intersection_math(LineartVert *v1, LineartVert *v2, LineartTriangle *tri, const double *last, double *rv)
void mul_v3_m4v3_db(double r[3], const double mat[4][4], const double vec[3])
@ LINEART_SHADOW_FILTER_SHADED
@ LINEART_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES
@ LINEART_SHADOW_FILTER_ILLUMINATED
static void lineart_triangle_post(LineartTriangle *tri, LineartTriangle *orig)
void lineart_register_shadow_cuts(struct LineartData *ld, struct LineartEdge *e, struct LineartEdge *shadow_edge)
static void lineart_bounding_area_triangle_reallocate(LineartBoundingArea *ba)
void lineart_main_get_view_vector(LineartData *ld)
static bool lineart_triangle_get_other_verts(const LineartTriangle *tri, const LineartVert *vt, LineartVert **l, LineartVert **r)
void BKE_id_free(Main *bmain, void *idv)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
void BLI_task_pool_free(TaskPool *pool)
void unit_m4_db(double m[4][4])
LineartBoundingArea * MOD_lineart_get_bounding_area(LineartData *ld, double x, double y)
void copy_m4d_m4(double m1[4][4], const float m2[4][4])
TaskPool * BLI_task_pool_create(void *userdata, eTaskPriority priority)
static void lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_list, LineartObjectInfo *obi, int thread_count, int this_face_count)
@ MOD_LINEART_EDGE_FLAG_PROJECTED_SHADOW
@ MOD_LINEART_EDGE_FLAG_NEXT_IS_DUPLICATION
@ MOD_LINEART_EDGE_FLAG_INHIBIT
@ MOD_LINEART_EDGE_FLAG_EDGE_MARK
@ MOD_LINEART_EDGE_FLAG_LOOSE
@ MOD_LINEART_EDGE_FLAG_CONTOUR_SECONDARY
@ MOD_LINEART_EDGE_FLAG_CREASE
@ MOD_LINEART_EDGE_FLAG_SHADOW_FACING_LIGHT
@ MOD_LINEART_EDGE_FLAG_CHAIN_PICKED
@ MOD_LINEART_EDGE_FLAG_INTERSECTION
@ MOD_LINEART_EDGE_FLAG_LIGHT_CONTOUR
@ MOD_LINEART_EDGE_FLAG_CONTOUR
@ MOD_LINEART_EDGE_FLAG_MATERIAL
void BLI_spin_unlock(SpinLock *spin)
MINLINE float normalize_v3(float n[3])
void lineart_main_cull_triangles(LineartData *ld, bool clip_far)
MINLINE void mul_v3db_db(double r[3], double f)
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, LineartBoundingArea *ba, LineartIsecThread *th, int up_to)
void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], double t)
static void lineart_discard_duplicated_edges(LineartEdge *old_e)
void BLI_spin_init(SpinLock *spin)
void * lineart_mem_acquire(struct LineartStaticMemPool *smp, size_t size)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
static LineartData * lineart_create_render_buffer_v3(Scene *scene, GreasePencilLineartModifierData *lmd, Object *camera, Object *active_camera, LineartCache *lc)
void transpose_m4(float R[4][4])
@ COLLECTION_HIDE_VIEWPORT
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static bool lineart_bounding_area_edge_intersect(LineartData *, const double l[2], const double r[2], LineartBoundingArea *ba)
void lineart_mem_destroy(struct LineartStaticMemPool *smp)
bool BKE_scene_camera_switch_update(Scene *scene)
void lineart_main_link_lines(LineartData *ld)
static bool lineart_point_inside_triangle3d(double v[3], double v0[3], double v1[3], double v2[3])
static void lineart_bounding_area_line_add(LineartBoundingArea *ba, LineartEdge *e)
MINLINE void sub_v3_v3v3_db(double r[3], const double a[3], const double b[3])
void lineart_edge_cut(LineartData *ld, LineartEdge *e, double start, double end, uchar material_mask_bits, uchar mat_occlusion, uint32_t shadow_bits)
static void lineart_add_triangles_worker(TaskPool *__restrict, LineartIsecThread *th)
void lineart_main_transform_and_add_shadow(struct LineartData *ld, struct LineartElementLinkNode *veln, struct LineartElementLinkNode *eeln)
Material * BKE_object_material_get_eval(Object *ob, short act)
static void lineart_free_bounding_area_memory(LineartBoundingArea *ba, bool recursive)
void lineart_main_make_enclosed_shapes(struct LineartData *ld, struct LineartData *shadow_ld)
static void lineart_bounding_areas_connect_recursive(LineartData *ld, LineartBoundingArea *root)
static LineartPointTri lineart_point_triangle_relation(double v[2], double v0[2], double v1[2], double v2[2])
void lineart_finalize_object_edge_array_reserve(LineartPendingEdges *pe, int count)
static void lineart_triangle_set_cull_flag(LineartTriangle *tri, uchar flag)
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
static bool lineart_triangle_intersect_math(LineartTriangle *tri, LineartTriangle *t2, double *v1, double *v2)
static void lineart_main_remove_unused_lines_recursive(LineartBoundingArea *ba, uint8_t max_occlusion)
double BLI_time_now_seconds()
BLI_INLINE int lineart_intersect_seg_seg(const double a1[2], const double a2[2], const double b1[2], const double b2[2], double *r_ratio, bool *r_aligned)
static int lineart_occlusion_make_task_info(LineartData *ld, LineartRenderTaskInfo *rti)
void MOD_lineart_chain_find_silhouette_backdrop_objects(LineartData *ld)
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers, bool preserve_origindex, bool ensure_subdivision)
void * lineart_mem_acquire_thread(struct LineartStaticMemPool *smp, size_t size)
static void lineart_bounding_area_link_edge(LineartData *ld, LineartBoundingArea *root_ba, LineartEdge *e)
@ LINEART_GPENCIL_OFFSET_TOWARDS_CUSTOM_CAMERA
@ LINEART_GPENCIL_INVERT_COLLECTION
@ LINEART_GPENCIL_INVERT_SILHOUETTE_FILTER
static LineartElementLinkNode * lineart_memory_get_edge_space(LineartData *ld)
void mul_m4db_m4db_m4fl(double R[4][4], const double A[4][4], const float B[4][4])
MINLINE void add_v3_v3_db(double r[3], const double a[3])
static void lineart_create_edges_from_isec_data(LineartIsecData *d)
static void lineart_object_load_single_instance(LineartData *ld, Depsgraph *depsgraph, Scene *scene, Object *ob, Object *ref_ob, const float use_mat[4][4], bool is_render, LineartObjectLoadTaskInfo *olti, int thread_count, int obindex)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
VecBase< float, 3 > float3
static void lineart_free_bounding_area_memories(LineartData *ld)
static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *tri, const LineartEdge *e, const double *override_camera_loc, const bool override_cam_is_persp, const bool allow_overlapping_edges, const double m_view_projection[4][4], const double camera_dir[3], const float cam_shift_x, const float cam_shift_y, double *from, double *to)
@ MOD_LINEART_USE_IMAGE_BOUNDARY_TRIMMING
@ MOD_LINEART_CHAIN_PRESERVE_DETAILS
@ MOD_LINEART_USE_BACK_FACE_CULLING
@ MOD_LINEART_FILTER_FACE_MARK
@ MOD_LINEART_ALLOW_CLIPPING_BOUNDARIES
@ MOD_LINEART_USE_CREASE_ON_SHARP_EDGES
@ MOD_LINEART_USE_CUSTOM_CAMERA
@ MOD_LINEART_ALLOW_DUPLI_OBJECTS
@ MOD_LINEART_CHAIN_GEOMETRY_SPACE
@ MOD_LINEART_FILTER_FACE_MARK_INVERT
@ MOD_LINEART_INVERT_SOURCE_VGROUP
@ MOD_LINEART_FILTER_FACE_MARK_BOUNDARIES
@ MOD_LINEART_MATCH_OUTPUT_VGROUP
@ MOD_LINEART_FILTER_FACE_MARK_KEEP_CONTOUR
@ MOD_LINEART_ALLOW_OVERLAP_EDGE_TYPES
@ MOD_LINEART_ALLOW_OVERLAPPING_EDGES
@ MOD_LINEART_CHAIN_LOOSE_EDGES
@ MOD_LINEART_INTERSECTION_AS_CONTOUR
@ MOD_LINEART_USE_CREASE_ON_SMOOTH_SURFACES
@ MOD_LINEART_LOOSE_AS_CONTOUR
@ MOD_LINEART_EVERYTHING_AS_CONTOUR
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
void * lineart_list_append_pointer_pool(ListBase *h, struct LineartStaticMemPool *smp, void *data)
MINLINE double normalize_v3_db(double n[3])
void BLI_spin_lock(SpinLock *spin)
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
static LineartEdgeSegment * lineart_give_segment(LineartData *ld)
static bool lineart_point_inside_triangle(const double v[2], const double v0[2], const double v1[2], const double v2[2])
void mul_v3_mat3_m4v3_db(double r[3], const double mat[4][4], const double vec[3])
void lineart_main_perspective_division(LineartData *ld)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void lineart_main_free_adjacent_data(LineartData *ld)
static LineartElementLinkNode * lineart_memory_get_triangle_space(LineartData *ld)
static void feat_data_sum_reduce(const void *__restrict, void *__restrict chunk_join, void *__restrict chunk)
bool lineart_main_try_generate_shadow_v3(struct Depsgraph *depsgraph, struct Scene *scene, struct LineartData *original_ld, struct GreasePencilLineartModifierData *lmd, struct LineartStaticMemPool *shadow_data_pool, struct LineartElementLinkNode **r_veln, struct LineartElementLinkNode **r_eeln, ListBaseT< LineartElementLinkNode > *r_calculated_edges_eln_list, struct LineartData **r_shadow_ld_if_reproject)
MDeformWeight * BKE_defvert_find_index(const MDeformVert *dv, int defgroup)
@ LINEART_SOURCE_COLLECTION
@ MOD_LINEART_MATERIAL_MASK_MATCH
@ MOD_LINEART_INTERSECTION_MATCH
@ MOD_LINEART_MATERIAL_MASK_ENABLE
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
@ LRT_MATERIAL_CUSTOM_INTERSECTION_PRIORITY
@ LRT_MATERIAL_MASK_ENABLED
static void lineart_bounding_area_link_triangle(LineartData *ld, LineartBoundingArea *root_ba, LineartTriangle *tri, double l_r_u_b[4], int recursive, int recursive_level, bool do_intersection, LineartIsecThread *th)
void lineart_main_bounding_area_make_initial(LineartData *ld)
LineartElementLinkNode * lineart_find_matching_eln(ListBaseT< LineartElementLinkNode > *shadow_elns, int obindex)
LineartCache * MOD_lineart_init_cache()
struct Collection * collection
eCollectionLineArt_Flags lineart_flags
uint8_t lineart_intersection_mask
eCollectionLineArt_Usage lineart_usage
ListBaseT< CollectionChild > children
ListBaseT< CollectionObject > gobject
uint8_t lineart_intersection_priority
ListBaseT< struct bDeformGroup > vertex_group_names
Set< const Object * > * included_objects
LineartTriangle * tri_array
VArray< bool > sharp_faces
VArray< bool > sharp_edges
LineartEdgeNeighbor * edge_nabr
VArray< bool > freestyle_edge
VArray< bool > freestyle_face
Span< int > material_indices
LineartEdgeNeighbor * edge_nabr
LineartAdjacentEdge * adj_e
float chain_smooth_tolerance
float angle_splitting_threshold
char shadow_use_silhouette_override
struct LineartModifierRuntime * runtime
struct LineartData * la_data_ptr
eGreasePencilLineartFlags flags
char shadow_selection_override
struct LineartCache * cache
float stroke_depth_offset
struct Object * source_camera
short edge_types_override
float chaining_image_threshold
struct Object * light_contour_object
uint32_t max_triangle_count
LineartBoundingArea * child
LineartTriangle ** linked_triangles
uint32_t insider_triangle_count
LineartEdge ** linked_lines
LineartStaticMemPool chain_data_pool
ListBaseT< LineartElementLinkNode > shadow_elns
ListBaseT< LineartEdgeChain > chains
uint16_t all_enabled_edge_types
LineartStaticMemPool shadow_data_pool
double view_projection[4][4]
bool chain_preserve_details
bool use_loose_edge_chain
bool shadow_use_silhouette
double active_camera_pos[3]
bool use_image_boundary_trimming
float cam_obmat_secondary[4][4]
float chain_smooth_tolerance
double camera_pos_secondary[3]
bool use_geometry_space_chain
bool cam_is_persp_secondary
bool filter_face_mark_boundaries
bool filter_face_mark_invert
double view_vector_secondary[3]
bool use_back_face_culling
bool use_contour_secondary
float angle_splitting_threshold
float chaining_image_threshold
bool allow_duplicated_types
bool light_reference_available
bool shadow_enclose_shapes
bool filter_face_mark_keep_contour
bool use_loose_as_contour
bool allow_overlapping_edges
ListBaseT< LineartElementLinkNode > vertex_buffer_pointers
ListBaseT< LineartElementLinkNode > triangle_adjacent_pointers
ListBaseT< LineartElementLinkNode > line_buffer_pointers
ListBaseT< LineartElementLinkNode > triangle_buffer_pointers
uint32_t initial_tile_count
LineartBoundingArea * initials
LineartStaticMemPool * chain_data_pool
struct blender::LineartData::_geom geom
LineartStaticMemPool * edge_data_pool
struct blender::LineartData::_qtree qtree
struct blender::LineartData::_conf conf
ListBaseT< LineartEdgeChain > chains
int isect_scheduled_up_to_index
struct LineartPendingEdges pending_edges
LineartStaticMemPool render_data_pool
ListBaseT< LineartEdgeSegment > wasted_cuts
LineartElementLinkNode * isect_scheduled_up_to
ListBaseT< LineartEdgeChainItem > chain
uint8_t intersection_mask
uint32_t shadow_mask_bits
Object * silhouette_backdrop
uint8_t material_mask_bits
LineartEdgeSegment * next
uint32_t shadow_mask_bits
uint8_t material_mask_bits
LineartEdgeSegment * prev
ListBaseT< LineartEdgeSegment > segments
eLineArtElementNodeFlag flags
LineartElementLinkNode * next
LineartIsecThread * threads
LineartElementLinkNode * pending_from
LineartIsecSingle * array
LineartElementLinkNode * pending_to
Set< const Object * > object_dependencies
uint8_t intersection_priority
LineartPendingEdges pending_edges
Object * original_ob_eval
LineartElementLinkNode * v_eln
double model_view_proj[4][4]
uint8_t override_intersection_mask
ListBaseT< LineartElementLinkNode > * shadow_elns
LineartObjectInfo * pending
struct LineartPendingEdges pending_edges
LineartEdge * testing_e[1]
uint32_t target_reference
LinkNode * intersecting_verts
uint8_t material_mask_bits
uint8_t intersection_mask
uint8_t intersection_priority
ListBaseT< bDeformGroup > vertex_group_names
bke::MeshRuntime * runtime
eObjectLineArt_Usage usage
eObjectLineArt_Flags flags
unsigned char intersection_priority
struct Collection * master_collection
TaskParallelReduceFunc func_reduce
size_t userdata_chunk_size
LineartTriangle * tri_arr
LineartObjectInfo * ob_info
LineartTriangleAdjacent * tri_adj
Span< int > material_indices
int lineart_triangle_size
double(* model_view_proj)[4]
static GeometrySet from_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Curves * get_curves_for_write()
std::shared_ptr< BMEditMesh > edit_mesh
MutableVArraySpan< T > span