18 #define LRT_OTHER_VERT(e, vt) ((vt) == (e)->v1 ? (e)->v2 : ((vt) == (e)->v2 ? (e)->v1 : NULL))
29 struct Object *match_isec_object)
176 float use_fbcoord[4];
179 #define VERT_COORD_TO_FLOAT(a) \
180 copy_v4fl_v4db(use_fbcoord, (a)->fbcoord); \
181 copy_v3fl_v3db(use_gpos, (a)->gloc);
183 #define POS_TO_FLOAT(lpos, gpos) \
184 copy_v3fl_v3db(use_fbcoord, lpos); \
185 copy_v3fl_v3db(use_gpos, gpos);
208 N[0] +=
e->t1->gn[0];
209 N[1] +=
e->t1->gn[1];
210 N[2] +=
e->t1->gn[2];
213 N[0] +=
e->t2->gn[0];
214 N[1] +=
e->t2->gn[1];
215 N[2] +=
e->t2->gn[2];
217 if (
e->t1 ||
e->t2) {
224 es =
e->segments.first;
240 if (new_e->
t1 || new_e->
t2) {
243 N[0] += new_e->
t1->
gn[0];
244 N[1] += new_e->
t1->
gn[1];
245 N[2] += new_e->
t1->
gn[2];
248 N[0] += new_e->
t2->
gn[0];
249 N[1] += new_e->
t2->
gn[1];
250 N[2] += new_e->
t2->
gn[2];
255 if (new_vt == new_e->
v1) {
257 double gpos[3], lpos[3];
259 double global_at = lfb[3] * es->
ratio / (es->
ratio * lfb[3] + (1 - es->
ratio) * rfb[3]);
279 else if (new_vt == new_e->
v2) {
285 for (; es; es = es->
next) {
286 double gpos[3], lpos[3];
288 double global_at = lfb[3] * es->
ratio / (es->
ratio * lfb[3] + (1 - es->
ratio) * rfb[3]);
323 if (
e->t1 ||
e->t2) {
326 N[0] +=
e->t1->gn[0];
327 N[1] +=
e->t1->gn[1];
328 N[2] +=
e->t1->gn[2];
331 N[0] +=
e->t2->gn[0];
332 N[1] +=
e->t2->gn[1];
333 N[2] +=
e->t2->gn[2];
339 es =
e->segments.first;
343 for (es = es->
next; es; es = es->
next) {
344 double gpos[3], lpos[3];
345 double *lfb =
e->v1->fbcoord, *rfb =
e->v2->fbcoord;
346 double global_at = lfb[3] * es->
ratio / (es->
ratio * lfb[3] + (1 - es->
ratio) * rfb[3]);
349 use_fbcoord[3] =
interpf(
e->v2->fbcoord[3],
e->v1->fbcoord[3], global_at);
384 if (new_e->
t1 || new_e->
t2) {
387 N[0] += new_e->
t1->
gn[0];
388 N[1] += new_e->
t1->
gn[1];
389 N[2] += new_e->
t1->
gn[2];
392 N[0] += new_e->
t2->
gn[0];
393 N[1] += new_e->
t2->
gn[1];
394 N[2] += new_e->
t2->
gn[2];
403 if (new_vt == new_e->
v1) {
413 double gpos[3], lpos[3];
415 double global_at = lfb[3] * es->
ratio / (es->
ratio * lfb[3] + (1 - es->
ratio) * rfb[3]);
435 else if (new_vt == new_e->
v2) {
444 for (; es; es = es->
next) {
445 double gpos[3], lpos[3];
447 double global_at = lfb[3] * es->
ratio / (es->
ratio * lfb[3] + (1 - es->
ratio) * rfb[3]);
499 #define IN_BOUND(ba, eci) \
500 ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1]
555 #define IN_BOUND(ba, eci) \
556 ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1]
592 float distance_threshold,
593 bool preserve_details,
596 float dist_accum = 0;
598 int fixed_occ = last_matching_eci->
occlusion;
606 if (dist_accum > distance_threshold) {
612 if (eci->occlusion < fixed_occ) {
615 if (eci->material_mask_bits == fixed_mask && eci->occlusion == fixed_occ &&
616 eci->shadow_mask_bits == fixed_shadow) {
625 next_eci = eci->
next;
626 if (eci->material_mask_bits == fixed_mask && eci->occlusion == fixed_occ &&
627 eci->shadow_mask_bits == fixed_shadow) {
630 if (preserve_details) {
632 eci->occlusion = fixed_occ;
633 eci->shadow_mask_bits = fixed_shadow;
639 *r_next_eci = can_skip_to;
668 ec->
level = fixed_occ;
671 for (eci = first_eci->
next; eci; eci = next_eci) {
672 next_eci = eci->
next;
722 ec->
level = fixed_occ;
799 float *result_new_len,
822 if (cre->ec->picked || cre->picked) {
825 if (cre->ec == ec || (!cre->ec->chain.first) || (cre->ec->level !=
occlusion) ||
826 (cre->ec->material_mask_bits != material_mask_bits) ||
827 (cre->ec->intersection_mask != isec_mask) || (cre->ec->shadow_mask_bits != shadow_mask)) {
831 if (cre->ec->type != ec->
type) {
849 if (((cre->ec->loop_id == loop_id) && (new_len < dist)) ||
850 ((cre->ec->loop_id != loop_id) && (new_len < dist / 10))) {
853 if (result_new_len) {
854 (*result_new_len) = new_len;
860 float adjacent_new_len = dist;
863 #define LRT_TEST_ADJACENT_AREAS(dist_to, list) \
864 if (dist_to < dist && dist_to > 0) { \
865 LISTBASE_FOREACH (LinkData *, link, list) { \
866 LineartBoundingArea *sba = (LineartBoundingArea *)link->data; \
867 adjacent_closest = lineart_chain_get_closest_cre(ld, \
872 material_mask_bits, \
879 if (adjacent_new_len < dist) { \
880 dist = adjacent_new_len; \
881 closest_cre = adjacent_closest; \
891 if (result_new_len) {
892 (*result_new_len) = dist;
904 float dist_l, dist_r;
905 int reverse_main, loop_id;
964 if (closest_cre_l && closest_cre_r) {
965 if (dist_l < dist_r) {
966 closest_cre = closest_cre_l;
970 closest_cre = closest_cre_r;
974 else if (closest_cre_l) {
975 closest_cre = closest_cre_l;
978 else if (closest_cre_r) {
979 closest_cre = closest_cre_r;
1005 float offset_accum = 0;
1007 float last_point[2];
1016 offset_accum += dist;
1019 return offset_accum;
1057 if (eln->object_ref == obj) {
1090 for (
int times = 0; times < 2; times++) {
1095 if ((!(eci2 = eci->
next)) || (!(eci3 = eci2->
next))) {
1097 next_eci = eci->
next;
1113 float vec2[2], vec3[2], v2n[2], ratio, len2;
1127 if (ratio < len2 && ratio > -len2 * 10) {
1129 if ((eci4 = eci3->
next) &&
1147 next_eci = eci->next;
1160 float ref_lu[2] = {-1.0f, 1.0f}, ref_lb[2] = {-1.0f, -1.0f}, ref_ru[2] = {1.0f, 1.0f},
1161 ref_rb[2] = {1.0f, -1.0f};
1164 if (eci2->
pos[0] < -1.0f) {
1167 if (!found && eci2->
pos[0] > 1.0f) {
1170 if (!found && eci2->
pos[1] < -1.0f) {
1173 if (!found && eci2->
pos[1] > 1.0f) {
1181 float ratio = (
fabs(eci2->
pos[0] - eci1->pos[0]) >
fabs(eci2->
pos[1] - eci1->pos[1])) ?
1182 ratiof(eci1->pos[0], eci2->
pos[0], isec[0]) :
1183 ratiof(eci1->pos[1], eci2->
pos[1], isec[1]);
1184 float gratio = eci1->pos[3] * ratio / (ratio * eci1->pos[3] + (1 - ratio) * eci2->
pos[3]);
1196 #define LRT_ECI_INSIDE(eci) \
1197 ((eci)->pos[0] >= -1.0f && (eci)->pos[0] <= 1.0f && (eci)->pos[1] >= -1.0f && \
1198 (eci)->pos[1] <= 1.0f)
1211 bool ec_added =
false;
1217 for (eci = first_eci->
next; eci; eci = next_eci) {
1218 next_eci = eci->
next;
1219 prev_eci = eci->
prev;
1224 if (new_inside ==
false) {
1240 next_eci = eci->
next;
1254 next_eci = eci->
next;
1281 for (eci = first_eci->
next; eci; eci = next_eci) {
1282 next_eci = eci->
next;
1283 prev_eci = eci->
prev;
1285 if (next_eci && prev_eci) {
1291 if (
angle < angle_threshold_rad) {
1328 float view_clamp[3];
1330 if (use_custom_camera) {
1341 float orig_len =
len_v3(dir);
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void void void void void BLI_listbase_reverse(struct ListBase *lb) ATTR_NONNULL(1)
MINLINE float interpf(float a, float b, float t)
MINLINE float ratiof(float min, float max, float pos)
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float vi[2])
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2])
float angle_v2v2v2(const float a[2], const float b[2], const float c[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v4_v4(float r[4], const float a[4])
void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], double t)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void copy_v3fl_v3db(float r[3], const double a[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v2_v2(float r[2], const float a[2])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
@ LRT_EDGE_FLAG_PROJECTED_SHADOW
@ LRT_EDGE_FLAG_INTERSECTION
@ LRT_EDGE_FLAG_LIGHT_CONTOUR
@ LRT_EDGE_FLAG_CHAIN_PICKED
#define LRT_EDGE_FLAG_ALL_TYPE
_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
_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 type
#define LRT_OBINDEX_HIGHER
#define LRT_SHADOW_SILHOUETTE_ERASED_GROUP
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
static bool is_inside(int x, int y, int cols, int rows)
IconTextureDrawCall normal
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
static LineartEdgeChain * lineart_chain_create(LineartData *ld)
#define POS_TO_FLOAT(lpos, gpos)
static bool lineart_chain_fix_ambiguous_segments(LineartEdgeChain *ec, LineartEdgeChainItem *last_matching_eci, float distance_threshold, bool preserve_details, LineartEdgeChainItem **r_next_eci)
#define LRT_ECI_INSIDE(eci)
void MOD_lineart_chain_connect(LineartData *ld)
void MOD_lineart_chain_discard_unused(LineartData *ld, const float threshold, uint8_t max_occlusion)
static LineartEdge * lineart_line_get_connected(LineartBoundingArea *ba, LineartVert *vt, LineartVert **new_vt, int match_flag, uint8_t match_isec_mask, struct Object *match_isec_object)
float MOD_lineart_chain_compute_length(LineartEdgeChain *ec)
void MOD_lineart_chain_split_for_fixed_occlusion(LineartData *ld)
static LineartEdgeChainItem * lineart_chain_prepend_point(LineartData *ld, LineartEdgeChain *ec, float fbcoord[4], float gpos[3], float normal[3], uint8_t type, int level, uint8_t material_mask_bits, uint32_t shadow_mask_bits, size_t index)
void MOD_lineart_chain_clip_at_border(LineartData *ld)
int MOD_lineart_chain_count(const LineartEdgeChain *ec)
static void lineart_chain_connect(LineartData *UNUSED(ld), LineartEdgeChain *onto, LineartEdgeChain *sub, int reverse_1, int reverse_2)
static LineartEdgeChainItem * lineart_chain_create_crossing_point(LineartData *ld, LineartEdgeChainItem *eci_inside, LineartEdgeChainItem *eci_outside)
static LineartEdgeChainItem * lineart_chain_append_point(LineartData *ld, LineartEdgeChain *ec, float fbcoord[4], float gpos[3], float normal[3], uint8_t type, int level, uint8_t material_mask_bits, uint32_t shadow_mask_bits, size_t index)
#define VERT_COORD_TO_FLOAT(a)
void MOD_lineart_finalize_chains(LineartData *ld)
static LineartBoundingArea * lineart_bounding_area_get_end_point(LineartData *ld, LineartEdgeChainItem *eci)
static void lineart_bounding_area_link_chain(LineartData *ld, LineartEdgeChain *ec)
#define LRT_OTHER_VERT(e, vt)
void MOD_lineart_chain_find_silhouette_backdrop_objects(LineartData *ld)
LineartElementLinkNode * lineart_find_matching_eln_obj(ListBase *elns, struct Object *obj)
static bool lineart_point_overlapping(LineartEdgeChainItem *eci, float x, float y, double threshold)
void MOD_lineart_chain_feature_lines(LineartData *ld)
static LineartChainRegisterEntry * lineart_chain_get_closest_cre(LineartData *ld, LineartBoundingArea *ba, LineartEdgeChain *ec, LineartEdgeChainItem *eci, int occlusion, uint8_t material_mask_bits, uint8_t isec_mask, uint32_t shadow_mask, int loop_id, float dist, float *result_new_len, LineartBoundingArea *caller_ba)
#define LRT_TEST_ADJACENT_AREAS(dist_to, list)
static LineartBoundingArea * lineart_bounding_area_get_eci_recursive(LineartData *ld, LineartBoundingArea *root, LineartEdgeChainItem *eci)
void MOD_lineart_chain_clear_picked_flag(LineartCache *lc)
static void lineart_bounding_area_link_point_recursive(LineartData *ld, LineartBoundingArea *root, LineartEdgeChain *ec, LineartEdgeChainItem *eci)
void MOD_lineart_smooth_chains(LineartData *ld, float tolerance)
void MOD_lineart_chain_split_angle(LineartData *ld, float angle_threshold_rad)
void MOD_lineart_chain_offset_towards_camera(LineartData *ld, float dist, bool use_custom_camera)
#define IN_BOUND(ba, eci)
LineartBoundingArea * MOD_lineart_get_bounding_area(LineartData *ld, double x, double y)
LineartBoundingArea * MOD_lineart_get_parent_bounding_area(LineartData *ld, double x, double y)
void * lineart_list_append_pointer_pool_sized(ListBase *h, struct LineartStaticMemPool *smp, void *data, int size)
#define LRT_ITER_ALL_LINES_END
#define LRT_ITER_ALL_LINES_NEXT
#define LRT_ITER_ALL_LINES_BEGIN
LineartElementLinkNode * lineart_find_matching_eln(struct ListBase *shadow_elns, int obindex)
void * lineart_mem_acquire(struct LineartStaticMemPool *smp, size_t size)
ccl_device_inline float2 fabs(const float2 &a)
static const pxr::TfToken occlusion("occlusion", pxr::TfToken::Immortal)
struct LineartBoundingArea * child
struct LineartEdge ** linked_lines
LineartEdgeChainItem * eci
bool use_loose_edge_chain
bool chain_preserve_details
float chaining_image_threshold
double active_camera_pos[3]
bool use_geometry_space_chain
ListBase vertex_buffer_pointers
ListBase line_buffer_pointers
struct LineartData::_conf conf
struct LineartData::_geom geom
LineartStaticMemPool * chain_data_pool
uint8_t material_mask_bits
struct LineartEdgeChainItem * next
uint32_t shadow_mask_bits
struct LineartEdgeChainItem * prev
uint8_t material_mask_bits
struct LineartEdgeChain * next
struct LineartEdgeChain * prev
uint32_t shadow_mask_bits
uint8_t intersection_mask
struct Object * object_ref
struct LineartEdgeSegment * prev
struct LineartEdgeSegment * next
uint32_t shadow_mask_bits
uint8_t material_mask_bits
struct LineartTriangle * t2
uint8_t intersection_mask
struct LineartTriangle * t1
struct Object * object_ref