Blender  V3.3
lineart_intern.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 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"
13 #include "BLI_threads.h"
14 
15 #include "DNA_lineart_types.h"
16 
17 #include <math.h>
18 #include <string.h>
19 
20 struct LineartEdge;
21 struct LineartData;
24 
27  struct LineartStaticMemPool *smp,
28  void *data,
29  int size);
31  struct LineartStaticMemPool *smp,
32  void *data);
35  void *data,
36  int size);
37 void *list_push_pointer_static(ListBase *h, struct LineartStaticMemPool *smp, void *p);
39  struct LineartStaticMemPool *smp,
40  void *p,
41  int size);
42 
45 
47  size_t size);
48 void *lineart_mem_acquire(struct LineartStaticMemPool *smp, size_t size);
49 void *lineart_mem_acquire_thread(struct LineartStaticMemPool *smp, size_t size);
51 
52 void lineart_prepend_pool(LinkNode **first, struct LineartStaticMemPool *smp, void *link);
53 
54 void lineart_matrix_ortho_44d(double (*mProjection)[4],
55  double xMin,
56  double xMax,
57  double yMin,
58  double yMax,
59  double zMin,
60  double zMax);
62  double (*mProjection)[4], double fFov_rad, double fAspect, double zMin, double zMax);
63 
65 
67 
68 #define LRT_ITER_ALL_LINES_BEGIN \
69  { \
70  LineartEdge *e; \
71  for (int __i = 0; __i < ld->pending_edges.next; __i++) { \
72  e = ld->pending_edges.array[__i];
73 
74 #define LRT_ITER_ALL_LINES_NEXT ; /* Doesn't do anything now with new array setup. */
75 
76 #define LRT_ITER_ALL_LINES_END \
77  LRT_ITER_ALL_LINES_NEXT \
78  } \
79  }
80 
81 #define LRT_BOUND_AREA_CROSSES(b1, b2) \
82  ((b1)[0] < (b2)[1] && (b1)[1] > (b2)[0] && (b1)[3] < (b2)[2] && (b1)[2] > (b2)[3])
83 
84 /* Initial bounding area row/column count, setting 10 is tested to be relatively optimal for the
85  * performance under current algorithm. */
86 #define LRT_BA_ROWS 10
87 
88 #define LRT_EDGE_BA_MARCHING_BEGIN(fb1, fb2) \
89  double x = fb1[0], y = fb1[1]; \
90  LineartBoundingArea *ba = lineart_edge_first_bounding_area(ld, fb1, fb2); \
91  LineartBoundingArea *nba = ba; \
92  double k = (fb2[1] - fb1[1]) / (fb2[0] - fb1[0] + 1e-30); \
93  int positive_x = (fb2[0] - fb1[0]) > 0 ? 1 : (fb2[0] == fb1[0] ? 0 : -1); \
94  int positive_y = (fb2[1] - fb1[1]) > 0 ? 1 : (fb2[1] == fb1[1] ? 0 : -1); \
95  while (nba)
96 
97 #define LRT_EDGE_BA_MARCHING_NEXT(fb1, fb2) \
98  /* Marching along `e->v1` to `e->v2`, searching each possible bounding areas it may touch. */ \
99  nba = lineart_bounding_area_next(nba, fb1, fb2, x, y, k, positive_x, positive_y, &x, &y);
100 
101 #define LRT_EDGE_BA_MARCHING_END
102 
104 void lineart_main_cull_triangles(struct LineartData *ld, bool clip_far);
109  struct Scene *scene,
110  struct Object *camera,
111  struct LineartData *ld,
112  bool allow_duplicates,
113  bool do_shadow_casting,
114  struct ListBase *shadow_elns);
119 void lineart_main_link_lines(struct LineartData *ld);
120 void lineart_main_add_triangles(struct LineartData *ld);
122  struct Scene *scene,
123  struct LineartData *original_ld,
124  struct LineartGpencilModifierData *lmd,
125  struct LineartStaticMemPool *shadow_data_pool,
126  struct LineartElementLinkNode **r_veln,
127  struct LineartElementLinkNode **r_eeln,
128  struct ListBase *r_calculated_edges_eln_list,
129  struct LineartData **r_shadow_ld_if_reproject);
130 void lineart_main_make_enclosed_shapes(struct LineartData *ld, struct LineartData *shadow_ld);
132  struct LineartElementLinkNode *veln,
133  struct LineartElementLinkNode *eeln);
134 
135 LineartElementLinkNode *lineart_find_matching_eln(struct ListBase *shadow_elns, int obindex);
138  uint64_t edge_identifier);
140  struct LineartEdge *e,
141  struct LineartEdge *shadow_edge);
143  struct ListBase *shadow_elns);
144 
146  const struct LineartEdge *e,
147  bool allow_overlapping_edges);
149  double *fbcoord1,
150  double *fbcoord2);
152  double *fbcoord1,
153  double *fbcoord2,
154  double x,
155  double y,
156  double k,
157  int positive_x,
158  int positive_y,
159  double *next_x,
160  double *next_y);
161 void lineart_edge_cut(struct LineartData *ld,
162  struct LineartEdge *e,
163  double start,
164  double end,
165  uchar material_mask_bits,
166  uchar mat_occlusion,
167  uint32_t shadow_bits);
171 
172 #ifdef __cplusplus
173 extern "C" {
174 #endif
175 
177 
178 #ifdef __cplusplus
179 }
180 #endif
unsigned char uchar
Definition: BLI_sys_types.h:70
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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
Scene scene
const Depsgraph * depsgraph
int count
void lineart_register_intersection_shadow_cuts(struct LineartData *ld, struct ListBase *shadow_elns)
bool lineart_main_try_generate_shadow(struct Depsgraph *depsgraph, struct Scene *scene, struct LineartData *original_ld, struct LineartGpencilModifierData *lmd, struct LineartStaticMemPool *shadow_data_pool, struct LineartElementLinkNode **r_veln, struct LineartElementLinkNode **r_eeln, struct ListBase *r_calculated_edges_eln_list, struct LineartData **r_shadow_ld_if_reproject)
void lineart_main_bounding_area_make_initial(struct LineartData *ld)
Definition: lineart_cpu.c:3696
void lineart_main_add_triangles(struct LineartData *ld)
Definition: lineart_cpu.c:4663
void * lineart_list_pop_pointer_no_free(ListBase *h)
Definition: lineart_util.c:75
void * lineart_list_append_pointer_pool_sized(ListBase *h, struct LineartStaticMemPool *smp, void *data, int size)
Definition: lineart_util.c:35
void lineart_destroy_render_data_keep_init(struct LineartData *ld)
Definition: lineart_cpu.c:3477
struct LineartStaticMemPoolNode * lineart_mem_new_static_pool(struct LineartStaticMemPool *smp, size_t size)
Definition: lineart_util.c:91
void * lineart_mem_acquire_thread(struct LineartStaticMemPool *smp, size_t size)
Definition: lineart_util.c:119
void lineart_prepend_pool(LinkNode **first, struct LineartStaticMemPool *smp, void *link)
Definition: lineart_util.c:147
void lineart_main_load_geometries(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *camera, struct LineartData *ld, bool allow_duplicates, bool do_shadow_casting, struct ListBase *shadow_elns)
Definition: lineart_cpu.c:2524
void lineart_add_edge_to_array(struct LineartPendingEdges *pe, struct LineartEdge *e)
Definition: lineart_cpu.c:1774
void lineart_finalize_object_edge_array_reserve(struct LineartPendingEdges *pe, int count)
Definition: lineart_cpu.c:1800
LineartEdge * lineart_find_matching_edge(struct LineartElementLinkNode *shadow_eln, uint64_t edge_identifier)
bool lineart_edge_from_triangle(const struct LineartTriangle *tri, const struct LineartEdge *e, bool allow_overlapping_edges)
void lineart_register_shadow_cuts(struct LineartData *ld, struct LineartEdge *e, struct LineartEdge *shadow_edge)
void lineart_main_free_adjacent_data(struct LineartData *ld)
Definition: lineart_cpu.c:1346
LineartBoundingArea * lineart_edge_first_bounding_area(struct LineartData *ld, double *fbcoord1, double *fbcoord2)
Definition: lineart_cpu.c:4698
int lineart_count_intersection_segment_count(struct LineartData *ld)
void lineart_main_cull_triangles(struct LineartData *ld, bool clip_far)
Definition: lineart_cpu.c:1211
void lineart_main_clear_linked_edges(struct LineartData *ld)
Definition: lineart_cpu.c:4271
void lineart_main_make_enclosed_shapes(struct LineartData *ld, struct LineartData *shadow_ld)
void lineart_count_and_print_render_buffer_memory(struct LineartData *ld)
Definition: lineart_util.c:208
void * lineart_list_append_pointer_pool_thread(ListBase *h, struct LineartStaticMemPool *smp, void *data)
Definition: lineart_util.c:49
void lineart_main_get_view_vector(struct LineartData *ld)
Definition: lineart_cpu.c:3437
void lineart_edge_cut(struct LineartData *ld, struct LineartEdge *e, double start, double end, uchar material_mask_bits, uchar mat_occlusion, uint32_t shadow_bits)
Definition: lineart_cpu.c:150
void lineart_main_perspective_division(struct LineartData *ld)
Definition: lineart_cpu.c:1364
void lineart_matrix_perspective_44d(double(*mProjection)[4], double fFov_rad, double fAspect, double zMin, double zMax)
Definition: lineart_util.c:157
void lineart_main_bounding_areas_connect_post(struct LineartData *ld)
Definition: lineart_cpu.c:3911
void lineart_main_discard_out_of_frame_edges(struct LineartData *ld)
Definition: lineart_cpu.c:1389
LineartBoundingArea * lineart_bounding_area_next(struct LineartBoundingArea *_this, double *fbcoord1, double *fbcoord2, double x, double y, double k, int positive_x, int positive_y, double *next_x, double *next_y)
Definition: lineart_cpu.c:4732
void lineart_list_remove_pointer_item_no_free(ListBase *h, LinkData *lip)
Definition: lineart_util.c:86
void lineart_main_occlusion_begin(struct LineartData *ld)
Definition: lineart_cpu.c:464
LineartElementLinkNode * lineart_find_matching_eln_obj(struct ListBase *elns, struct Object *ob)
void lineart_main_transform_and_add_shadow(struct LineartData *ld, struct LineartElementLinkNode *veln, struct LineartElementLinkNode *eeln)
void * lineart_list_append_pointer_pool_sized_thread(ListBase *h, LineartStaticMemPool *smp, void *data, int size)
Definition: lineart_util.c:60
void * list_push_pointer_static(ListBase *h, struct LineartStaticMemPool *smp, void *p)
LineartElementLinkNode * lineart_find_matching_eln(struct ListBase *shadow_elns, int obindex)
void lineart_mem_destroy(struct LineartStaticMemPool *smp)
Definition: lineart_util.c:139
void * list_push_pointer_static_sized(ListBase *h, struct LineartStaticMemPool *smp, void *p, int size)
void lineart_main_link_lines(struct LineartData *ld)
Definition: lineart_cpu.c:4284
void lineart_sort_adjacent_items(struct LineartAdjacentEdge *ai, int length)
void * lineart_mem_acquire(struct LineartStaticMemPool *smp, size_t size)
Definition: lineart_util.c:104
void * lineart_list_append_pointer_pool(ListBase *h, struct LineartStaticMemPool *smp, void *data)
Definition: lineart_util.c:24
void lineart_matrix_ortho_44d(double(*mProjection)[4], double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
Definition: lineart_util.c:189
T length(const vec_base< T, Size > &a)
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90