Blender  V3.3
Classes | Macros | Typedefs | Functions
lineart_shadow.c File Reference
#include "MOD_gpencil_lineart.h"
#include "MOD_lineart.h"
#include "lineart_intern.h"
#include "BKE_global.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_lib_id.h"
#include "BKE_material.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "DEG_depsgraph_query.h"
#include "DNA_collection_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_light_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_task.h"
#include "PIL_time.h"

Go to the source code of this file.

Classes

struct  LineartShadowFinalizeData
 

Macros

#define DISCARD_NONSENSE_SEGMENTS
 
#define GET_RATIO(n)
 

Typedefs

typedef struct LineartShadowFinalizeData LineartShadowFinalizeData
 

Functions

LineartElementLinkNodelineart_find_matching_eln (ListBase *shadow_elns, int obindex)
 
LineartEdgelineart_find_matching_edge (LineartElementLinkNode *shadow_eln, uint64_t edge_identifier)
 
static bool lineart_contour_viewed_from_dark_side (LineartData *ld, LineartEdge *e)
 
void lineart_register_shadow_cuts (LineartData *ld, LineartEdge *e, LineartEdge *shadow_edge)
 
void lineart_register_intersection_shadow_cuts (LineartData *ld, ListBase *shadow_elns)
 
static LineartShadowSegmentlineart_give_shadow_segment (LineartData *ld)
 
static void lineart_shadow_segment_slice_get (double *fb_co_1, double *fb_co_2, double *gloc_1, double *gloc_2, double ratio, double at_1, double at_2, double *r_fb_co, double *r_gloc)
 
static bool lineart_do_closest_segment (bool is_persp, double *s1_fb_co_1, double *s1_fb_co_2, double *s2_fb_co_1, double *s2_fb_co_2, double *s1_gloc_1, double *s1_gloc_2, double *s2_gloc_1, double *s2_gloc_2, double *r_fb_co_1, double *r_fb_co_2, double *r_gloc_1, double *r_gloc_2, double *r_new_in_the_middle, double *r_new_in_the_middle_global, double *r_new_at, bool *is_side_2r, bool *use_new_ref)
 
static void lineart_shadow_create_shadow_edge_array (LineartData *ld, bool transform_edge_cuts, bool do_light_contour)
 
static void lineart_shadow_edge_cut (LineartData *ld, LineartShadowEdge *e, double start, double end, double *start_gloc, double *end_gloc, double *start_fb_co, double *end_fb_co, bool facing_light, uint32_t target_reference)
 
static bool lineart_shadow_cast_onto_triangle (LineartData *ld, LineartTriangle *tri, LineartShadowEdge *sedge, double *r_at_1, double *r_at_2, double *r_fb_co_1, double *r_fb_co_2, double *r_gloc_1, double *r_gloc_2, bool *r_facing_light)
 
static void lineart_shadow_cast (LineartData *ld, bool transform_edge_cuts, bool do_light_contour)
 
static bool lineart_shadow_cast_generate_edges (LineartData *ld, bool do_original_edges, LineartElementLinkNode **r_veln, LineartElementLinkNode **r_eeln)
 
static void lineart_shadow_register_silhouette (LineartData *ld)
 
static void lineart_shadow_register_enclosed_shapes (LineartData *ld, LineartData *shadow_ld)
 
bool lineart_main_try_generate_shadow (Depsgraph *depsgraph, Scene *scene, LineartData *original_ld, LineartGpencilModifierData *lmd, LineartStaticMemPool *shadow_data_pool, LineartElementLinkNode **r_veln, LineartElementLinkNode **r_eeln, ListBase *r_calculated_edges_eln_list, LineartData **r_shadow_ld_if_reproject)
 
static void lineart_shadow_transform_task (void *__restrict userdata, const int element_index, const TaskParallelTLS *__restrict UNUSED(tls))
 
static void lineart_shadow_finalize_shadow_edges_task (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict UNUSED(tls))
 
void lineart_main_transform_and_add_shadow (LineartData *ld, LineartElementLinkNode *veln, LineartElementLinkNode *eeln)
 
void lineart_main_make_enclosed_shapes (LineartData *ld, LineartData *shadow_ld)
 

Macro Definition Documentation

◆ DISCARD_NONSENSE_SEGMENTS

#define DISCARD_NONSENSE_SEGMENTS
Value:
if (es->occlusion != 0 || \
(es->next && \
LRT_DOUBLE_CLOSE_ENOUGH(es->ratio, ((LineartEdgeSegment *)es->next)->ratio))) { \
LRT_ITER_ALL_LINES_NEXT; \
continue; \
}
#define LRT_DOUBLE_CLOSE_ENOUGH(a, b)
Definition: MOD_lineart.h:588

◆ GET_RATIO

#define GET_RATIO (   n)
Value:
(fabs(orig_e->v2->fbcoord[0] - orig_e->v1->fbcoord[0]) > \
fabs(orig_e->v2->fbcoord[1] - orig_e->v1->fbcoord[1])) ? \
((g##n##v[0] - orig_e->v1->fbcoord[0]) / \
(orig_e->v2->fbcoord[0] - orig_e->v1->fbcoord[0])) : \
((g##n##v[1] - orig_e->v1->fbcoord[1]) / (orig_e->v2->fbcoord[1] - orig_e->v1->fbcoord[1]))
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_inline float2 fabs(const float2 &a)
Definition: math_float2.h:222
static const pxr::TfToken g("g", pxr::TfToken::Immortal)

Typedef Documentation

◆ LineartShadowFinalizeData

Function Documentation

◆ lineart_contour_viewed_from_dark_side()

static bool lineart_contour_viewed_from_dark_side ( LineartData ld,
LineartEdge e 
)
static

◆ lineart_do_closest_segment()

static bool lineart_do_closest_segment ( bool  is_persp,
double s1_fb_co_1,
double s1_fb_co_2,
double s2_fb_co_1,
double s2_fb_co_2,
double s1_gloc_1,
double s1_gloc_2,
double s2_gloc_1,
double s2_gloc_2,
double r_fb_co_1,
double r_fb_co_2,
double r_gloc_1,
double r_gloc_2,
double r_new_in_the_middle,
double r_new_in_the_middle_global,
double r_new_at,
bool is_side_2r,
bool use_new_ref 
)
static

This function tries to get the closest projected segments along two end points. The x,y of s1, s2 are aligned in frame-buffer coordinates, only z,w are different. We will get the closest z/w as well as the corresponding global coordinates.

(far side)
l-------r [s1] ^
_-r [s2] | In this situation it will essentially return the coordinates of s2.
_-` |
l-` |
(far side)
_-r [s2] ^
_-` | In this case the return coordinates would be `s2l` and `s1r`,
l-----_c`-----r [s1] | and `r_new` will be assigned coordinates of `c`.
_-` |
l-` |

Returns true when a new cut (c) is needed in the middle, otherwise returns false, and *r_new_xxx are not touched.

Definition at line 220 of file lineart_shadow.c.

References copy_v3_v3_db(), copy_v4_v4_db(), interp_v3_v3v3_db(), interpd(), and ratiod().

Referenced by lineart_shadow_edge_cut().

◆ lineart_find_matching_edge()

LineartEdge* lineart_find_matching_edge ( LineartElementLinkNode shadow_eln,
uint64_t  edge_identifier 
)

◆ lineart_find_matching_eln()

LineartElementLinkNode* lineart_find_matching_eln ( ListBase shadow_elns,
int  obindex 
)

◆ lineart_give_shadow_segment()

static LineartShadowSegment* lineart_give_shadow_segment ( LineartData ld)
static

◆ lineart_main_make_enclosed_shapes()

void lineart_main_make_enclosed_shapes ( LineartData ld,
LineartData shadow_ld 
)

◆ lineart_main_transform_and_add_shadow()

void lineart_main_transform_and_add_shadow ( LineartData ld,
LineartElementLinkNode veln,
LineartElementLinkNode eeln 
)

◆ lineart_main_try_generate_shadow()

bool lineart_main_try_generate_shadow ( Depsgraph depsgraph,
Scene scene,
LineartData original_ld,
LineartGpencilModifierData lmd,
LineartStaticMemPool shadow_data_pool,
LineartElementLinkNode **  r_veln,
LineartElementLinkNode **  r_eeln,
ListBase r_calculated_edges_eln_list,
LineartData **  r_shadow_ld_if_reproject 
)

Definition at line 1119 of file lineart_shadow.c.

References LineartData::_conf::allow_duplicated_types, BLI_spin_init(), LineartData::_conf::cam_is_persp, LineartData::_conf::cam_is_persp_secondary, LineartData::_conf::cam_obmat, LineartData::_conf::cam_obmat_secondary, LineartData::_conf::camera_pos, LineartData::_conf::camera_pos_secondary, LineartData::conf, copy_m4_m4(), copy_m4_m4_db(), copy_v3_v3_db(), copy_v3db_v3fl(), Object::data, DEG2RAD, depsgraph, LineartData::_conf::do_shadow_cast, LineartData::edge_data_pool, LineartData::_conf::far_clip, ListBase::first, LineartGpencilModifierData::flags, G, LineartData::geom, LineartData::h, if(), invert_m4_m4(), LA_SUN, LineartGpencilModifierData::light_contour_object, LineartData::_geom::line_buffer_pointers, lineart_destroy_render_data_keep_init(), lineart_main_add_triangles(), lineart_main_bounding_area_make_initial(), lineart_main_bounding_areas_connect_post(), lineart_main_cull_triangles(), lineart_main_discard_out_of_frame_edges(), lineart_main_free_adjacent_data(), lineart_main_get_view_vector(), lineart_main_link_lines(), lineart_main_load_geometries(), lineart_main_occlusion_begin(), lineart_main_perspective_division(), lineart_matrix_ortho_44d(), lineart_matrix_perspective_44d(), lineart_shadow_cast(), lineart_shadow_cast_generate_edges(), LineartData::lock_cuts, LineartStaticMemPool::lock_mem, LineartData::lock_task, LRT_ALLOW_DUPLI_OBJECTS, LRT_TILE_RECURSIVE_ORTHO, LRT_TILE_RECURSIVE_PERSPECTIVE, LineartData::_conf::max_occlusion_level, MEM_callocN, MEM_freeN, mul_m4db_m4db_m4fl_uniq(), LineartData::_conf::near_clip, NULL, OB_LAMP, Object::obmat, PIL_check_seconds_timer(), LineartData::qtree, LineartData::_qtree::recursive_level, LineartData::render_data_pool, result, scene, LineartGpencilModifierData::shadow_camera_far, LineartGpencilModifierData::shadow_camera_near, LineartGpencilModifierData::shadow_camera_size, LineartData::shadow_data_pool, LineartData::_conf::shadow_enclose_shapes, LineartData::_conf::shadow_selection, Light::type, Object::type, unit_m4_db(), LineartData::_conf::use_back_face_culling, LineartData::_conf::use_contour, LineartData::_conf::use_contour_secondary, LineartData::_conf::use_crease, LineartData::_conf::use_edge_marks, LineartData::_conf::use_intersections, LineartData::_conf::use_light_contour, LineartData::_conf::use_loose, LineartData::_conf::use_material, LineartData::_conf::use_shadow, LineartData::_geom::vertex_buffer_pointers, view, LineartData::_conf::view, LineartData::_conf::view_projection, and LineartData::w.

Referenced by MOD_lineart_compute_feature_lines().

◆ lineart_register_intersection_shadow_cuts()

void lineart_register_intersection_shadow_cuts ( LineartData ld,
ListBase shadow_elns 
)

◆ lineart_register_shadow_cuts()

void lineart_register_shadow_cuts ( LineartData ld,
LineartEdge e,
LineartEdge shadow_edge 
)

◆ lineart_shadow_cast()

static void lineart_shadow_cast ( LineartData ld,
bool  transform_edge_cuts,
bool  do_light_contour 
)
static

◆ lineart_shadow_cast_generate_edges()

static bool lineart_shadow_cast_generate_edges ( LineartData ld,
bool  do_original_edges,
LineartElementLinkNode **  r_veln,
LineartElementLinkNode **  r_eeln 
)
static

◆ lineart_shadow_cast_onto_triangle()

static bool lineart_shadow_cast_onto_triangle ( LineartData ld,
LineartTriangle tri,
LineartShadowEdge sedge,
double r_at_1,
double r_at_2,
double r_fb_co_1,
double r_fb_co_2,
double r_gloc_1,
double r_gloc_2,
bool r_facing_light 
)
static

◆ lineart_shadow_create_shadow_edge_array()

static void lineart_shadow_create_shadow_edge_array ( LineartData ld,
bool  transform_edge_cuts,
bool  do_light_contour 
)
static

◆ lineart_shadow_edge_cut()

static void lineart_shadow_edge_cut ( LineartData ld,
LineartShadowEdge e,
double  start,
double  end,
double start_gloc,
double end_gloc,
double start_fb_co,
double end_fb_co,
bool  facing_light,
uint32_t  target_reference 
)
static

◆ lineart_shadow_finalize_shadow_edges_task()

static void lineart_shadow_finalize_shadow_edges_task ( void *__restrict  userdata,
const int  i,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

◆ lineart_shadow_register_enclosed_shapes()

static void lineart_shadow_register_enclosed_shapes ( LineartData ld,
LineartData shadow_ld 
)
static

◆ lineart_shadow_register_silhouette()

static void lineart_shadow_register_silhouette ( LineartData ld)
static

◆ lineart_shadow_segment_slice_get()

static void lineart_shadow_segment_slice_get ( double fb_co_1,
double fb_co_2,
double gloc_1,
double gloc_2,
double  ratio,
double  at_1,
double  at_2,
double r_fb_co,
double r_gloc 
)
static

Definition at line 180 of file lineart_shadow.c.

References interp_v3_v3v3_db(), and interpd().

Referenced by lineart_shadow_edge_cut().

◆ lineart_shadow_transform_task()

static void lineart_shadow_transform_task ( void *__restrict  userdata,
const int  element_index,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static