Blender  V3.3
MOD_lineart.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "BLI_linklist.h"
11 #include "BLI_listbase.h"
12 #include "BLI_math.h" /* Needed here for inline functions. */
13 #include "BLI_threads.h"
14 
15 #include <math.h>
16 
17 typedef struct LineartStaticMemPoolNode {
19  size_t size;
20  size_t used_byte;
21  /* User memory starts here */
23 
24 typedef struct LineartStaticMemPool {
28 
29 typedef struct LineartTriangleAdjacent {
30  struct LineartEdge *e[3];
32 
33 typedef struct LineartTriangle {
34  struct LineartVert *v[3];
35 
36  /* first culled in line list to use adjacent triangle info, then go through triangle list. */
37  double gn[3];
38 
42  uint8_t flags; /* #eLineartTriangleFlags */
43 
44  /* target_reference = (obi->obindex | triangle_index) */
45  /* higher 12 bits-------^ ^-----index in object, lower 20 bits */
47 
49 
57 
58 typedef struct LineartTriangleThread {
59  struct LineartTriangle base;
68  struct LineartEdge *testing_e[1];
70 
77 
78 typedef struct LineartElementLinkNode {
80  void *pointer;
82  void *object_ref;
84 
85  /* For edge element link nodes, used for shadow edge matching. */
86  int obindex;
88 
92 
93 typedef struct LineartEdgeSegment {
97  double ratio;
100 
101  /* Used to filter line art occlusion edges */
103 
104  /* Lit/shaded flag for shadow is stored here.
105  * TODO(Yiming): Transfer material masks from shadow results
106  * onto here so then we can even filter transparent shadows. */
109 
110 typedef struct LineartShadowEdge {
112  /* Two end points in frame-buffer coordinates viewed from the light source. */
113  double fbc1[4], fbc2[4];
114  double g1[3], g2[3];
115  bool orig1, orig2;
118  struct LineartEdgeSegment *es_ref; /* Only for 3rd stage casting. */
121 
125 };
126 
127 /* Represents a cutting point on a #LineartShadowEdge */
128 typedef struct LineartShadowSegment {
130  /* eLineartShadowSegmentFlag */
131  int flag;
132  /* The point after which a property of the segment is changed. e.g. shadow mask/target_ref etc.
133  * Coordinates in NDC during shadow calculation but transformed to global linear before cutting
134  * onto edges during the loading stage of the "actual" rendering. */
135  double ratio;
136  /* Left and right pos, because when casting shadows at some point there will be
137  * non-continuous cuts, see #lineart_shadow_edge_cut for detailed explanation. */
138  double fbc1[4], fbc2[4];
139  /* Global position. */
140  double g1[4], g2[4];
144 
145 typedef struct LineartVert {
146  double gloc[3];
147  double fbcoord[4];
148 
149  /* Scene global index. */
150  int index;
152 
153 typedef struct LineartEdge {
154  struct LineartVert *v1, *v2;
155 
158  struct LineartTriangle *t1, *t2;
159 
162 
166 
175 
179 
189 
190 typedef struct LineartEdgeChain {
193 
195  float length;
196 
200 
202  int type;
204  int loop_id;
208 
209  /* We need local index for correct weight transfer, line art index is global, thus
210  * local_index=lineart_index-index_offset. */
212 
216 
217 typedef struct LineartEdgeChainItem {
220  float pos[4];
222  float gpos[3];
223  float normal[3];
229  size_t index;
231 
237 
238  /* left/right mark.
239  * Because we revert list in chaining so we need the flag. */
242 
243 typedef struct LineartAdjacentEdge {
248 
250  /* If tile gets this small, it's already much smaller than a pixel. No need to continue
251  * splitting. */
253  /* This is a tried-and-true safe value for high poly models that also needed ortho rendering. */
255 };
256 
257 #define LRT_TILE_SPLITTING_TRIANGLE_LIMIT 100
258 #define LRT_TILE_EDGE_COUNT_INITIAL 32
259 
263 };
264 
265 typedef struct LineartPendingEdges {
267  int max;
268  int next;
270 
271 typedef struct LineartData {
272 
273  int w, h;
276 
278  /* A pointer to LineartCache::chain_data_pool, which acts as a cache for edge chains. */
280  /* Reference to LineartCache::shadow_data_pool, stay available until the final round of line art
281  * calculation is finished. */
283 
284  /* Storing shadow edge eln, array, and cuts for shadow information, so it's available when line
285  * art runs the second time for occlusion. Either a reference to LineartCache::shadow_data_pool
286  * (shadow stage) or a reference to LineartData::render_data_pool (final stage). */
288 
289  struct _qtree {
290 
293 
294  /* When splitting bounding areas, if there's an ortho camera placed at a straight angle, there
295  * will be a lot of triangles aligned in line which can not be separated by continue
296  * subdividing the tile. So we set a strict limit when using ortho camera. See
297  * eLineArtTileRecursiveLimit. */
299 
301 
303 
304  } qtree;
305 
306  struct _geom {
307 
311 
314 
316 
317  } geom;
318 
319  struct _conf {
320 
321  double view_projection[4][4];
322  double view[4][4];
323 
324  float overscan;
325 
327  double crease_angle;
328  double crease_cos;
329 
332 
338  bool use_loose;
341  bool use_contour_secondary; /* From viewing camera, during shadow calculation. */
342 
343  int shadow_selection; /* Needs to be numeric because it's not just on/off. */
346 
358 
363 
366 
368 
371 
372  /* Keep an copy of these data so when line art is running it's self-contained. */
374  bool cam_is_persp_secondary; /* "Secondary" ones are from viewing camera (as opposed to shadow
375  camera), during shadow calculation. */
376  float cam_obmat[4][4];
377  float cam_obmat_secondary[4][4];
378  double camera_pos[3];
380  double active_camera_pos[3]; /* Stroke offset calculation may use active or selected camera. */
382  float shift_x, shift_y;
383 
387 
389 
390  double view_vector[3];
391  double view_vector_secondary[3]; /* For shadow. */
392  } conf;
393 
396 
397  /* NOTE: Data inside #pending_edges are allocated with MEM_xxx call instead of in pool. */
400 
401  /* Intermediate shadow results, list of LineartShadowEdge */
404 
406 
411 
413 
414 typedef struct LineartCache {
419 
422 
426 
430 
431 #define DBL_TRIANGLE_LIM 1e-8
432 #define DBL_EDGE_LIM 1e-9
433 
434 #define LRT_MEMORY_POOL_1MB (1 << 20)
435 
436 typedef enum eLineartTriangleFlags {
438  LRT_CULL_USED = (1 << 0),
439  LRT_CULL_DISCARD = (1 << 1),
440  LRT_CULL_GENERATED = (1 << 2),
446 
447 #define LRT_SHADOW_MASK_UNDEFINED 0
448 #define LRT_SHADOW_MASK_ILLUMINATED (1 << 0)
449 #define LRT_SHADOW_MASK_SHADED (1 << 1)
450 #define LRT_SHADOW_MASK_ENCLOSED_SHAPE (1 << 2)
451 #define LRT_SHADOW_MASK_INHIBITED (1 << 3)
452 #define LRT_SHADOW_SILHOUETTE_ERASED_GROUP (1 << 4)
453 #define LRT_SHADOW_SILHOUETTE_ERASED_OBJECT (1 << 5)
454 #define LRT_SHADOW_MASK_ILLUMINATED_SHAPE (1 << 6)
455 
456 #define LRT_SHADOW_TEST_SHAPE_BITS \
457  (LRT_SHADOW_MASK_ILLUMINATED | LRT_SHADOW_MASK_SHADED | LRT_SHADOW_MASK_INHIBITED | \
458  LRT_SHADOW_MASK_ILLUMINATED_SHAPE)
459 
465 #define LRT_THREAD_EDGE_COUNT 1000
466 
467 typedef struct LineartRenderTaskInfo {
468  struct LineartData *ld;
469 
471 
477 
479 
480 #define LRT_OBINDEX_SHIFT 20
481 #define LRT_OBINDEX_LOWER 0x0FFFFF /* Lower 20 bits. */
482 #define LRT_OBINDEX_HIGHER 0xFFF00000 /* Higher 12 bits. */
483 #define LRT_EDGE_IDENTIFIER(obi, e) \
484  (((uint64_t)(obi->obindex | (e->v1->index & LRT_OBINDEX_LOWER)) << 32) | \
485  (obi->obindex | (e->v2->index & LRT_OBINDEX_LOWER)))
486 #define LRT_LIGHT_CONTOUR_TARGET 0xFFFFFFFF
487 
488 typedef struct LineartObjectInfo {
491  struct Object *original_ob_eval; /* For evaluated materials */
492  struct Mesh *original_me;
493  double model_view_proj[4][4];
494  double model_view[4][4];
495  double normal[4][4];
497  int usage;
501 
502  /* Shifted LRT_OBINDEX_SHIFT bits to be combined with object triangle index. */
503  int obindex;
504 
506 
509 
511 
513  struct LineartData *ld;
515  /* LinkNode styled list */
517  /* Used to spread the load across several threads. This can not overflow. */
521 
546 typedef struct LineartBoundingArea {
547  double l, r, u, b;
548  double cx, cy;
549 
552 
554 
559 
565 
566  /* Use array for speeding up multiple accesses. */
569 
573 
574 #define LRT_TILE(tile, r, c, CCount) tile[r * CCount + c]
575 
576 #define LRT_CLAMP(a, Min, Max) a = a < Min ? Min : (a > Max ? Max : a)
577 
578 #define LRT_MAX3_INDEX(a, b, c) (a > b ? (a > c ? 0 : (b > c ? 1 : 2)) : (b > c ? 1 : 2))
579 
580 #define LRT_MIN3_INDEX(a, b, c) (a < b ? (a < c ? 0 : (b < c ? 1 : 2)) : (b < c ? 1 : 2))
581 
582 #define LRT_MAX3_INDEX_ABC(x, y, z) (x > y ? (x > z ? a : (y > z ? b : c)) : (y > z ? b : c))
583 
584 #define LRT_MIN3_INDEX_ABC(x, y, z) (x < y ? (x < z ? a : (y < z ? b : c)) : (y < z ? b : c))
585 
586 #define DBL_LOOSER 1e-5
587 #define LRT_DOUBLE_CLOSE_LOOSER(a, b) (((a) + DBL_LOOSER) >= (b) && ((a)-DBL_LOOSER) <= (b))
588 #define LRT_DOUBLE_CLOSE_ENOUGH(a, b) (((a) + DBL_EDGE_LIM) >= (b) && ((a)-DBL_EDGE_LIM) <= (b))
589 #define LRT_DOUBLE_CLOSE_ENOUGH_TRI(a, b) \
590  (((a) + DBL_TRIANGLE_LIM) >= (b) && ((a)-DBL_TRIANGLE_LIM) <= (b))
591 
592 #define LRT_CLOSE_LOOSER_v3(a, b) \
593  (LRT_DOUBLE_CLOSE_LOOSER(a[0], b[0]) && LRT_DOUBLE_CLOSE_LOOSER(a[1], b[1]) && \
594  LRT_DOUBLE_CLOSE_LOOSER(a[2], b[2]))
595 
596 /* Notes on this function:
597  *
598  * r_ratio: The ratio on segment a1-a2. When r_ratio is very close to zero or one, it
599  * fixes the value to zero or one, this makes it easier to identify "on the tip" situations.
600  *
601  * r_aligned: True when 1) a and b is exactly on the same straight line and 2) a and b share a
602  * common end-point.
603  *
604  * IMPORTANT: if r_aligned is true, r_ratio will be either 0 or 1 depending on which point from
605  * segment a is shared with segment b. If it's a1 then r_ratio is 0, else then r_ratio is 1. This
606  * extra information is needed for line art occlusion stage to work correctly in such cases.
607  */
608 BLI_INLINE int lineart_intersect_seg_seg(const double a1[2],
609  const double a2[2],
610  const double b1[2],
611  const double b2[2],
612  double *r_ratio,
613  bool *r_aligned)
614 {
615 /* Legacy intersection math aligns better with occlusion function quirks. */
616 /* #define USE_VECTOR_LINE_INTERSECTION */
617 #ifdef USE_VECTOR_LINE_INTERSECTION
618 
619  /* from isect_line_line_v2_point() */
620 
621  double s10[2], s32[2];
622  double div;
623 
624  sub_v2_v2v2_db(s10, a2, a1);
625  sub_v2_v2v2_db(s32, b2, b1);
626 
627  div = cross_v2v2_db(s10, s32);
628  if (div != 0.0f) {
629  const double u = cross_v2v2_db(a2, a1);
630  const double v = cross_v2v2_db(b2, b1);
631 
632  const double rx = ((s32[0] * u) - (s10[0] * v)) / div;
633  const double ry = ((s32[1] * u) - (s10[1] * v)) / div;
634  double rr;
635 
636  if (fabs(a2[0] - a1[0]) > fabs(a2[1] - a1[1])) {
637  *r_ratio = ratiod(a1[0], a2[0], rx);
638  if (fabs(b2[0] - b1[0]) > fabs(b2[1] - b1[1])) {
639  rr = ratiod(b1[0], b2[0], rx);
640  }
641  else {
642  rr = ratiod(b1[1], b2[1], ry);
643  }
644  if ((*r_ratio) > 0 && (*r_ratio) < 1 && rr > 0 && rr < 1) {
645  return 1;
646  }
647  return 0;
648  }
649 
650  *r_ratio = ratiod(a1[1], a2[1], ry);
651  if (fabs(b2[0] - b1[0]) > fabs(b2[1] - b1[1])) {
652  rr = ratiod(b1[0], b2[0], rx);
653  }
654  else {
655  rr = ratiod(b1[1], b2[1], ry);
656  }
657  if ((*r_ratio) > 0 && (*r_ratio) < 1 && rr > 0 && rr < 1) {
658  return 1;
659  }
660  return 0;
661  }
662  return 0;
663 
664 #else
665  double k1, k2;
666  double x;
667  double y;
668  double ratio;
669  double x_diff = (a2[0] - a1[0]);
670  double x_diff2 = (b2[0] - b1[0]);
671 
672  *r_aligned = false;
673 
674  if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff, 0)) {
675  if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff2, 0)) {
676  /* This means two segments are both vertical. */
677  if ((LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b1[1])) ||
678  (LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b2[1]))) {
679  *r_aligned = true;
680  *r_ratio = 1;
681  }
682  else if ((LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b1[1])) ||
683  (LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b2[1]))) {
684  *r_aligned = true;
685  *r_ratio = 0;
686  }
687  return 0;
688  }
689  double r2 = ratiod(b1[0], b2[0], a1[0]);
690  x = interpd(b2[0], b1[0], r2);
691  y = interpd(b2[1], b1[1], r2);
692  *r_ratio = ratio = ratiod(a1[1], a2[1], y);
693  }
694  else {
695  if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff2, 0)) {
696  ratio = ratiod(a1[0], a2[0], b1[0]);
697  x = interpd(a2[0], a1[0], ratio);
698  *r_ratio = ratio;
699  }
700  else {
701  double y_diff = a2[1] - a1[1], y_diff2 = b2[1] - b1[1];
702  k1 = y_diff / x_diff;
703  k2 = y_diff2 / x_diff2;
704 
705  if (LRT_DOUBLE_CLOSE_ENOUGH_TRI(k2, k1)) {
706  /* This means two segments are parallel. This also handles k==0 (both completely
707  * horizontal) cases. */
708  if ((LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b1[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b1[1])) ||
709  (LRT_DOUBLE_CLOSE_ENOUGH(a2[0], b2[0]) && LRT_DOUBLE_CLOSE_ENOUGH(a2[1], b2[1]))) {
710  *r_aligned = true;
711  *r_ratio = 1;
712  }
713  else if ((LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b1[0]) &&
714  LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b1[1])) ||
715  (LRT_DOUBLE_CLOSE_ENOUGH(a1[0], b2[0]) &&
716  LRT_DOUBLE_CLOSE_ENOUGH(a1[1], b2[1]))) {
717  *r_aligned = true;
718  *r_ratio = 0;
719  }
720  return 0;
721  }
722 
723  x = (a1[1] - b1[1] - k1 * a1[0] + k2 * b1[0]) / (k2 - k1);
724 
725  ratio = (x - a1[0]) / x_diff;
726 
727  *r_ratio = ratio;
728  }
729  }
730 
731  if (LRT_DOUBLE_CLOSE_ENOUGH(b1[0], b2[0])) {
732  y = interpd(a2[1], a1[1], ratio);
733  if (y > MAX2(b1[1], b2[1]) || y < MIN2(b1[1], b2[1]))
734  return 0;
735  }
736  else if (ratio <= 0 || ratio > 1 || (b1[0] > b2[0] && x > b1[0]) ||
737  (b1[0] < b2[0] && x < b1[0]) || (b2[0] > b1[0] && x > b2[0]) ||
738  (b2[0] < b1[0] && x < b2[0]))
739  return 0;
740 
741  if (LRT_DOUBLE_CLOSE_ENOUGH_TRI(*r_ratio, 1)) {
742  *r_ratio = 1;
743  }
744  else if (LRT_DOUBLE_CLOSE_ENOUGH_TRI(*r_ratio, 0)) {
745  *r_ratio = 0;
746  }
747 
748  return 1;
749 #endif
750 }
751 
752 /* This is a special convenience function to lineart_intersect_seg_seg which will return true when
753  * the intersection point falls in the range of a1-a2 but not necessarily in the range of b1-b2. */
755  const double a2[2],
756  const double b1[2],
757  const double b2[2],
758  double *r_a_ratio)
759 {
760  /* The define here is used to check how vector or slope method handles boundary cases. The result
761  * of `lim(div->0)` and `lim(k->0)` could both produce some unwanted flickers in line art, the
762  * influence of which is still not fully understood, so keep the switch there for further
763  * investigations. */
764 #define USE_VECTOR_LINE_INTERSECTION_IGN
765 #ifdef USE_VECTOR_LINE_INTERSECTION_IGN
766 
767  /* from isect_line_line_v2_point() */
768 
769  double s10[2], s32[2];
770  double div;
771 
772  sub_v2_v2v2_db(s10, a2, a1);
773  sub_v2_v2v2_db(s32, b2, b1);
774 
775  div = cross_v2v2_db(s10, s32);
776  if (div != 0.0f) {
777  const double u = cross_v2v2_db(a2, a1);
778  const double v = cross_v2v2_db(b2, b1);
779 
780  const double rx = ((s32[0] * u) - (s10[0] * v)) / div;
781  const double ry = ((s32[1] * u) - (s10[1] * v)) / div;
782 
783  if (fabs(a2[0] - a1[0]) > fabs(a2[1] - a1[1])) {
784  *r_a_ratio = ratiod(a1[0], a2[0], rx);
785  if ((*r_a_ratio) >= -DBL_EDGE_LIM && (*r_a_ratio) <= 1 + DBL_EDGE_LIM) {
786  return 1;
787  }
788  return 0;
789  }
790 
791  *r_a_ratio = ratiod(a1[1], a2[1], ry);
792  if ((*r_a_ratio) >= -DBL_EDGE_LIM && (*r_a_ratio) <= 1 + DBL_EDGE_LIM) {
793  return 1;
794  }
795  return 0;
796  }
797  return 0;
798 
799 #else
800  double k1, k2;
801  double x;
802  double y;
803  double ratio;
804  double x_diff = (a2[0] - a1[0]);
805  double x_diff2 = (b2[0] - b1[0]);
806 
807  if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff, 0)) {
808  if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff2, 0)) {
809  *r_a_ratio = 0;
810  return 0;
811  }
812  double r2 = ratiod(b1[0], b2[0], a1[0]);
813  x = interpd(b2[0], b1[0], r2);
814  y = interpd(b2[1], b1[1], r2);
815  *r_a_ratio = ratio = ratiod(a1[1], a2[1], y);
816  }
817  else {
818  if (LRT_DOUBLE_CLOSE_ENOUGH(x_diff2, 0)) {
819  ratio = ratiod(a1[0], a2[0], b1[0]);
820  x = interpd(a2[0], a1[0], ratio);
821  *r_a_ratio = ratio;
822  }
823  else {
824  k1 = (a2[1] - a1[1]) / x_diff;
825  k2 = (b2[1] - b1[1]) / x_diff2;
826 
827  if ((k1 == k2))
828  return 0;
829 
830  x = (a1[1] - b1[1] - k1 * a1[0] + k2 * b1[0]) / (k2 - k1);
831 
832  ratio = (x - a1[0]) / x_diff;
833 
834  *r_a_ratio = ratio;
835  }
836  }
837 
838  if (ratio <= 0 || ratio >= 1)
839  return 0;
840 
841  return 1;
842 #endif
843 }
844 
845 struct Depsgraph;
847 struct LineartData;
848 struct Scene;
849 
851 
860 void MOD_lineart_chain_discard_unused(LineartData *ld, float threshold, uint8_t max_occlusion);
866 void MOD_lineart_chain_split_angle(LineartData *ld, float angle_threshold_rad);
867 void MOD_lineart_smooth_chains(LineartData *ld, float tolerance);
868 void MOD_lineart_chain_offset_towards_camera(LineartData *ld, float dist, bool use_custom_camera);
870 
874 
881  struct LineartGpencilModifierData *lmd,
882  struct LineartCache **cached_result,
883  bool enable_stroke_offset);
884 
885 struct Scene;
886 
891 
896 
897 struct bGPDframe;
898 struct bGPDlayer;
899 
904  struct Depsgraph *depsgraph,
905  struct Object *ob,
906  struct bGPDlayer *gpl,
907  struct bGPDframe *gpf,
908  int8_t source_type,
909  void *source_reference,
910  int level_start,
911  int level_end,
912  int mat_nr,
913  int16_t edge_types,
914  uint8_t mask_switches,
915  uint8_t material_mask_bits,
916  uint8_t intersection_mask,
918  float opacity,
919  uint8_t shadow_selection,
920  uint8_t silhouette_mode,
921  const char *source_vgname,
922  const char *vgname,
923  int modifier_flags,
924  int modifier_calculation_flags);
925 
930 
#define BLI_INLINE
MINLINE double interpd(double a, double b, double t)
MINLINE double ratiod(double min, double max, double pos)
MINLINE double cross_v2v2_db(const double a[2], const double b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2_db(double r[2], const double a[2], const double b[2])
pthread_spinlock_t SpinLock
Definition: BLI_threads.h:110
#define MAX2(a, b)
#define MIN2(a, b)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
struct LineartStaticMemPool LineartStaticMemPool
struct LineartBoundingArea LineartBoundingArea
#define LRT_DOUBLE_CLOSE_ENOUGH(a, b)
Definition: MOD_lineart.h:588
#define LRT_DOUBLE_CLOSE_ENOUGH_TRI(a, b)
Definition: MOD_lineart.h:589
void MOD_lineart_chain_connect(LineartData *ld)
void MOD_lineart_gpencil_generate(LineartCache *cache, struct Depsgraph *depsgraph, struct Object *ob, struct bGPDlayer *gpl, struct bGPDframe *gpf, int8_t source_type, void *source_reference, int level_start, int level_end, int mat_nr, int16_t edge_types, uint8_t mask_switches, uint8_t material_mask_bits, uint8_t intersection_mask, int16_t thickness, float opacity, uint8_t shadow_selection, uint8_t silhouette_mode, const char *source_vgname, const char *vgname, int modifier_flags, int modifier_calculation_flags)
Definition: lineart_cpu.c:5368
void MOD_lineart_chain_discard_unused(LineartData *ld, float threshold, uint8_t max_occlusion)
struct LineartCache LineartCache
struct LineartEdge LineartEdge
#define DBL_EDGE_LIM
Definition: MOD_lineart.h:432
float MOD_lineart_chain_compute_length(LineartEdgeChain *ec)
struct LineartRenderTaskInfo LineartRenderTaskInfo
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)
Definition: MOD_lineart.h:608
void MOD_lineart_chain_split_for_fixed_occlusion(LineartData *ld)
struct LineartEdgeChainItem LineartEdgeChainItem
struct LineartChainRegisterEntry LineartChainRegisterEntry
struct LineartObjectInfo LineartObjectInfo
LineartBoundingArea * MOD_lineart_get_bounding_area(LineartData *ld, double x, double y)
Definition: lineart_cpu.c:4511
void MOD_lineart_chain_clip_at_border(LineartData *ld)
struct LineartAdjacentEdge LineartAdjacentEdge
int MOD_lineart_chain_count(const LineartEdgeChain *ec)
struct LineartData LineartData
struct LineartPendingEdges LineartPendingEdges
void MOD_lineart_finalize_chains(LineartData *ld)
struct LineartEdgeChain LineartEdgeChain
struct LineartTriangleAdjacent LineartTriangleAdjacent
void MOD_lineart_destroy_render_data(struct LineartGpencilModifierData *lmd)
Definition: lineart_cpu.c:3517
void ED_operatortypes_lineart(void)
struct LineartStaticMemPoolNode LineartStaticMemPoolNode
eLineArtTileRecursiveLimit
Definition: MOD_lineart.h:249
@ LRT_TILE_RECURSIVE_PERSPECTIVE
Definition: MOD_lineart.h:252
@ LRT_TILE_RECURSIVE_ORTHO
Definition: MOD_lineart.h:254
void MOD_lineart_chain_find_silhouette_backdrop_objects(LineartData *ld)
struct LineartEdgeSegment LineartEdgeSegment
struct LineartObjectLoadTaskInfo LineartObjectLoadTaskInfo
void MOD_lineart_chain_feature_lines(LineartData *ld)
LineartBoundingArea * MOD_lineart_get_parent_bounding_area(LineartData *ld, double x, double y)
Definition: lineart_cpu.c:4442
struct LineartTriangleThread LineartTriangleThread
eLineartTriangleFlags
Definition: MOD_lineart.h:436
@ LRT_TRIANGLE_NO_INTERSECTION
Definition: MOD_lineart.h:442
@ LRT_CULL_GENERATED
Definition: MOD_lineart.h:440
@ LRT_CULL_DISCARD
Definition: MOD_lineart.h:439
@ LRT_TRIANGLE_MAT_BACK_FACE_CULLING
Definition: MOD_lineart.h:443
@ LRT_CULL_DONT_CARE
Definition: MOD_lineart.h:437
@ LRT_TRIANGLE_INTERSECTION_ONLY
Definition: MOD_lineart.h:441
@ LRT_TRIANGLE_FORCE_INTERSECTION
Definition: MOD_lineart.h:444
@ LRT_CULL_USED
Definition: MOD_lineart.h:438
struct LineartShadowEdge LineartShadowEdge
eLineArtElementNodeFlag
Definition: MOD_lineart.h:71
@ LRT_ELEMENT_NO_INTERSECTION
Definition: MOD_lineart.h:74
@ LRT_ELEMENT_BORDER_ONLY
Definition: MOD_lineart.h:73
@ LRT_ELEMENT_INTERSECTION_DATA
Definition: MOD_lineart.h:75
@ LRT_ELEMENT_IS_ADDITIONAL
Definition: MOD_lineart.h:72
void MOD_lineart_chain_clear_picked_flag(LineartCache *lc)
eLineartShadowCameraType
Definition: MOD_lineart.h:260
@ LRT_SHADOW_CAMERA_POINT
Definition: MOD_lineart.h:262
@ LRT_SHADOW_CAMERA_DIRECTIONAL
Definition: MOD_lineart.h:261
struct LineartElementLinkNode LineartElementLinkNode
void MOD_lineart_smooth_chains(LineartData *ld, float tolerance)
BLI_INLINE int lineart_line_isec_2d_ignore_line2pos(const double a1[2], const double a2[2], const double b1[2], const double b2[2], double *r_a_ratio)
Definition: MOD_lineart.h:754
void MOD_lineart_chain_split_angle(LineartData *ld, float angle_threshold_rad)
eLineartShadowSegmentFlag
Definition: MOD_lineart.h:122
@ LRT_SHADOW_CASTED
Definition: MOD_lineart.h:123
@ LRT_SHADOW_FACING_LIGHT
Definition: MOD_lineart.h:124
void MOD_lineart_chain_offset_towards_camera(LineartData *ld, float dist, bool use_custom_camera)
bool MOD_lineart_compute_feature_lines(struct Depsgraph *depsgraph, struct LineartGpencilModifierData *lmd, struct LineartCache **cached_result, bool enable_stroke_offset)
Definition: lineart_cpu.c:4957
struct LineartShadowSegment LineartShadowSegment
struct LineartTriangle LineartTriangle
struct LineartVert LineartVert
ATTR_WARN_UNUSED_RESULT const BMVert * v
const Depsgraph * depsgraph
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
ccl_device_inline float2 fabs(const float2 &a)
Definition: math_float2.h:222
static const pxr::TfToken opacity("opacity", pxr::TfToken::Immortal)
signed short int16_t
Definition: stdint.h:76
unsigned short uint16_t
Definition: stdint.h:79
unsigned int uint32_t
Definition: stdint.h:80
unsigned char uint8_t
Definition: stdint.h:78
unsigned __int64 uint64_t
Definition: stdint.h:90
signed char int8_t
Definition: stdint.h:75
struct LineartBoundingArea * child
Definition: MOD_lineart.h:551
struct LineartEdge ** linked_lines
Definition: MOD_lineart.h:568
uint32_t triangle_count
Definition: MOD_lineart.h:560
uint32_t insider_triangle_count
Definition: MOD_lineart.h:564
uint32_t max_line_count
Definition: MOD_lineart.h:563
ListBase linked_chains
Definition: MOD_lineart.h:571
struct LineartTriangle ** linked_triangles
Definition: MOD_lineart.h:567
uint32_t max_triangle_count
Definition: MOD_lineart.h:561
ListBase shadow_elns
Definition: MOD_lineart.h:425
ListBase chains
Definition: MOD_lineart.h:421
LineartStaticMemPool chain_data_pool
Definition: MOD_lineart.h:417
uint16_t all_enabled_edge_types
Definition: MOD_lineart.h:428
LineartStaticMemPool shadow_data_pool
Definition: MOD_lineart.h:418
struct LineartChainRegisterEntry * next
Definition: MOD_lineart.h:233
LineartEdgeChainItem * eci
Definition: MOD_lineart.h:235
struct LineartChainRegisterEntry * prev
Definition: MOD_lineart.h:233
LineartEdgeChain * ec
Definition: MOD_lineart.h:234
float cam_obmat_secondary[4][4]
Definition: MOD_lineart.h:377
bool filter_face_mark_invert
Definition: MOD_lineart.h:360
double view_projection[4][4]
Definition: MOD_lineart.h:321
double view_vector[3]
Definition: MOD_lineart.h:390
double view_vector_secondary[3]
Definition: MOD_lineart.h:391
double camera_pos_secondary[3]
Definition: MOD_lineart.h:379
float chaining_image_threshold
Definition: MOD_lineart.h:385
bool filter_face_mark_keep_contour
Definition: MOD_lineart.h:362
double active_camera_pos[3]
Definition: MOD_lineart.h:380
double camera_pos[3]
Definition: MOD_lineart.h:378
float chain_smooth_tolerance
Definition: MOD_lineart.h:388
double material_transparency
Definition: MOD_lineart.h:331
bool use_image_boundary_trimming
Definition: MOD_lineart.h:356
double view[4][4]
Definition: MOD_lineart.h:322
bool filter_face_mark_boundaries
Definition: MOD_lineart.h:361
bool allow_overlapping_edges
Definition: MOD_lineart.h:350
float angle_splitting_threshold
Definition: MOD_lineart.h:386
bool use_geometry_space_chain
Definition: MOD_lineart.h:355
float cam_obmat[4][4]
Definition: MOD_lineart.h:376
bool light_reference_available
Definition: MOD_lineart.h:370
ListBase vertex_buffer_pointers
Definition: MOD_lineart.h:308
ListBase line_buffer_pointers
Definition: MOD_lineart.h:309
ListBase triangle_adjacent_pointers
Definition: MOD_lineart.h:313
ListBase intersecting_vertex_buffer
Definition: MOD_lineart.h:315
ListBase triangle_buffer_pointers
Definition: MOD_lineart.h:310
uint32_t initial_tile_count
Definition: MOD_lineart.h:302
struct LineartBoundingArea * initials
Definition: MOD_lineart.h:300
int thread_count
Definition: MOD_lineart.h:274
LineartShadowEdge * shadow_edges
Definition: MOD_lineart.h:402
ListBase wasted_shadow_cuts
Definition: MOD_lineart.h:408
LineartStaticMemPool render_data_pool
Definition: MOD_lineart.h:277
struct LineartData::_conf conf
struct LineartData::_geom geom
struct LineartData::_qtree qtree
int isect_scheduled_up_to_index
Definition: MOD_lineart.h:395
ListBase chains
Definition: MOD_lineart.h:405
int sizeof_triangle
Definition: MOD_lineart.h:275
LineartElementLinkNode * isect_scheduled_up_to
Definition: MOD_lineart.h:394
ListBase wasted_cuts
Definition: MOD_lineart.h:407
SpinLock lock_task
Definition: MOD_lineart.h:410
LineartStaticMemPool * edge_data_pool
Definition: MOD_lineart.h:287
int scheduled_count
Definition: MOD_lineart.h:399
SpinLock lock_cuts
Definition: MOD_lineart.h:409
struct LineartPendingEdges pending_edges
Definition: MOD_lineart.h:398
int shadow_edges_count
Definition: MOD_lineart.h:403
LineartStaticMemPool * shadow_data_pool
Definition: MOD_lineart.h:282
LineartStaticMemPool * chain_data_pool
Definition: MOD_lineart.h:279
uint8_t material_mask_bits
Definition: MOD_lineart.h:226
struct LineartEdgeChainItem * next
Definition: MOD_lineart.h:218
uint32_t shadow_mask_bits
Definition: MOD_lineart.h:228
struct LineartEdgeChainItem * prev
Definition: MOD_lineart.h:218
uint8_t material_mask_bits
Definition: MOD_lineart.h:205
uint32_t index_offset
Definition: MOD_lineart.h:211
struct Object * silhouette_backdrop
Definition: MOD_lineart.h:214
struct LineartEdgeChain * next
Definition: MOD_lineart.h:191
struct LineartEdgeChain * prev
Definition: MOD_lineart.h:191
uint32_t shadow_mask_bits
Definition: MOD_lineart.h:207
uint8_t intersection_mask
Definition: MOD_lineart.h:206
struct Object * object_ref
Definition: MOD_lineart.h:213
struct LineartEdgeSegment * prev
Definition: MOD_lineart.h:94
struct LineartEdgeSegment * next
Definition: MOD_lineart.h:94
uint32_t shadow_mask_bits
Definition: MOD_lineart.h:107
uint8_t material_mask_bits
Definition: MOD_lineart.h:102
int8_t min_occ
Definition: MOD_lineart.h:161
uint16_t flags
Definition: MOD_lineart.h:164
struct LineartVert * v2
Definition: MOD_lineart.h:154
ListBase segments
Definition: MOD_lineart.h:160
struct LineartTriangle * t2
Definition: MOD_lineart.h:158
uint64_t edge_identifier
Definition: MOD_lineart.h:174
uint8_t intersection_mask
Definition: MOD_lineart.h:165
struct LineartTriangle * t1
Definition: MOD_lineart.h:158
uint64_t target_reference
Definition: MOD_lineart.h:178
struct Object * object_ref
Definition: MOD_lineart.h:187
struct LineartVert * v1
Definition: MOD_lineart.h:154
eLineArtElementNodeFlag flags
Definition: MOD_lineart.h:83
struct LineartElementLinkNode * prev
Definition: MOD_lineart.h:79
struct LineartElementLinkNode * next
Definition: MOD_lineart.h:79
LineartElementLinkNode * v_eln
Definition: MOD_lineart.h:496
struct Mesh * original_me
Definition: MOD_lineart.h:492
double model_view[4][4]
Definition: MOD_lineart.h:494
double normal[4][4]
Definition: MOD_lineart.h:495
struct LineartPendingEdges pending_edges
Definition: MOD_lineart.h:508
double model_view_proj[4][4]
Definition: MOD_lineart.h:493
struct Object * original_ob_eval
Definition: MOD_lineart.h:491
uint8_t override_intersection_mask
Definition: MOD_lineart.h:498
struct LineartObjectInfo * next
Definition: MOD_lineart.h:489
uint8_t intersection_priority
Definition: MOD_lineart.h:499
struct Object * original_ob
Definition: MOD_lineart.h:490
struct LineartData * ld
Definition: MOD_lineart.h:513
LineartObjectInfo * pending
Definition: MOD_lineart.h:516
LineartEdge ** array
Definition: MOD_lineart.h:266
struct LineartData * ld
Definition: MOD_lineart.h:468
struct LineartPendingEdges pending_edges
Definition: MOD_lineart.h:476
ListBase shadow_segments
Definition: MOD_lineart.h:119
struct LineartShadowEdge * prev
Definition: MOD_lineart.h:111
struct LineartEdgeSegment * es_ref
Definition: MOD_lineart.h:118
struct LineartShadowEdge * next
Definition: MOD_lineart.h:111
struct LineartEdge * e_ref_light_contour
Definition: MOD_lineart.h:117
struct LineartEdge * e_ref
Definition: MOD_lineart.h:116
struct LineartShadowSegment * next
Definition: MOD_lineart.h:129
struct LineartShadowSegment * prev
Definition: MOD_lineart.h:129
uint32_t target_reference
Definition: MOD_lineart.h:141
uint32_t shadow_mask_bits
Definition: MOD_lineart.h:142
struct LineartEdge * e[3]
Definition: MOD_lineart.h:30
struct LineartEdge * testing_e[1]
Definition: MOD_lineart.h:68
struct LineartTriangle base
Definition: MOD_lineart.h:59
uint8_t material_mask_bits
Definition: MOD_lineart.h:39
uint8_t intersection_priority
Definition: MOD_lineart.h:48
uint8_t intersection_mask
Definition: MOD_lineart.h:40
uint32_t target_reference
Definition: MOD_lineart.h:46
struct LinkNode * intersecting_verts
Definition: MOD_lineart.h:55
double gn[3]
Definition: MOD_lineart.h:37
uint8_t mat_occlusion
Definition: MOD_lineart.h:41
struct LineartVert * v[3]
Definition: MOD_lineart.h:34
double fbcoord[4]
Definition: MOD_lineart.h:147
double gloc[3]
Definition: MOD_lineart.h:146