Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| use_olti->total_faces += this_face_count; | use_olti->total_faces += this_face_count; | ||||
| obi->next = use_olti->pending; | obi->next = use_olti->pending; | ||||
| use_olti->pending = obi; | use_olti->pending = obi; | ||||
| } | } | ||||
| static bool lineart_geometry_check_visible(double (*model_view_proj)[4], | static bool lineart_geometry_check_visible(double (*model_view_proj)[4], | ||||
| double shift_x, | double shift_x, | ||||
| double shift_y, | double shift_y, | ||||
| Object *use_ob) | Mesh *use_mesh) | ||||
| { | { | ||||
| const BoundBox *bb = BKE_object_boundbox_get(use_ob); | if (!use_mesh) { | ||||
| if (!bb) { | |||||
| /* For lights and empty stuff there will be no bbox. */ | |||||
| return false; | return false; | ||||
| } | } | ||||
| float mesh_min[3], mesh_max[3]; | |||||
| INIT_MINMAX(mesh_min, mesh_max); | |||||
| BKE_mesh_minmax(use_mesh, mesh_min, mesh_max); | |||||
| BoundBox bb = {0}; | |||||
| BKE_boundbox_init_from_minmax(&bb, mesh_min, mesh_max); | |||||
| double co[8][4]; | double co[8][4]; | ||||
| double tmp[3]; | double tmp[3]; | ||||
| for (int i = 0; i < 8; i++) { | for (int i = 0; i < 8; i++) { | ||||
| copy_v3db_v3fl(co[i], bb->vec[i]); | copy_v3db_v3fl(co[i], bb.vec[i]); | ||||
| copy_v3_v3_db(tmp, co[i]); | copy_v3_v3_db(tmp, co[i]); | ||||
| mul_v4_m4v3_db(co[i], model_view_proj, tmp); | mul_v4_m4v3_db(co[i], model_view_proj, tmp); | ||||
| co[i][0] -= shift_x * 2 * co[i][3]; | co[i][0] -= shift_x * 2 * co[i][3]; | ||||
| co[i][1] -= shift_y * 2 * co[i][3]; | co[i][1] -= shift_y * 2 * co[i][3]; | ||||
| } | } | ||||
| bool cond[6] = {true, true, true, true, true, true}; | bool cond[6] = {true, true, true, true, true, true}; | ||||
| /* Because for a point to be inside clip space, it must satisfy `-Wc <= XYCc <= Wc`, here if | /* Because for a point to be inside clip space, it must satisfy `-Wc <= XYCc <= Wc`, here if | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
| * done before mesh boundbox check because the function needs that. */ | * done before mesh boundbox check because the function needs that. */ | ||||
| mul_m4db_m4db_m4fl_uniq(obi->model_view_proj, rb->view_projection, ob->obmat); | mul_m4db_m4db_m4fl_uniq(obi->model_view_proj, rb->view_projection, ob->obmat); | ||||
| mul_m4db_m4db_m4fl_uniq(obi->model_view, rb->view, ob->obmat); | mul_m4db_m4db_m4fl_uniq(obi->model_view, rb->view, ob->obmat); | ||||
| if (!ELEM(use_ob->type, OB_MESH, OB_MBALL, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) { | if (!ELEM(use_ob->type, OB_MESH, OB_MBALL, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!lineart_geometry_check_visible(obi->model_view_proj, rb->shift_x, rb->shift_y, use_ob)) { | |||||
| if (G.debug_value == 4000) { | |||||
| bound_box_discard_count++; | |||||
| } | |||||
| continue; | |||||
| } | |||||
| if (use_ob->type == OB_MESH) { | if (use_ob->type == OB_MESH) { | ||||
| use_mesh = BKE_object_get_evaluated_mesh(use_ob); | use_mesh = BKE_object_get_evaluated_mesh(use_ob); | ||||
| } | } | ||||
| else { | else { | ||||
| /* If DEG_ITER_OBJECT_FLAG_DUPLI is set, some curve objects may also have an evaluated mesh | /* If DEG_ITER_OBJECT_FLAG_DUPLI is set, some curve objects may also have an evaluated mesh | ||||
| * object in the list. To avoid adding duplicate geometry, ignore evaluated curve objects | * object in the list. To avoid adding duplicate geometry, ignore evaluated curve objects | ||||
| * in those cases. */ | * in those cases. */ | ||||
| if (allow_duplicates && BKE_object_get_evaluated_mesh(ob) != NULL) { | if (allow_duplicates && BKE_object_get_evaluated_mesh(ob) != NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| use_mesh = BKE_mesh_new_from_object(depsgraph, use_ob, true, true); | use_mesh = BKE_mesh_new_from_object(depsgraph, use_ob, true, true); | ||||
| } | } | ||||
| /* In case we still can not get any mesh geometry data from the object */ | /* In case we still can not get any mesh geometry data from the object */ | ||||
| if (!use_mesh) { | if (!use_mesh) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!lineart_geometry_check_visible( | |||||
| obi->model_view_proj, rb->shift_x, rb->shift_y, use_mesh)) { | |||||
| if (ob->type != OB_MESH) { | |||||
| BKE_id_free(NULL, use_mesh); | |||||
| } | |||||
| if (G.debug_value == 4000) { | |||||
| bound_box_discard_count++; | |||||
| } | |||||
| continue; | |||||
| } | |||||
| if (ob->type != OB_MESH) { | if (ob->type != OB_MESH) { | ||||
| obi->free_use_mesh = true; | obi->free_use_mesh = true; | ||||
| } | } | ||||
| /* Make normal matrix. */ | /* Make normal matrix. */ | ||||
| float imat[4][4]; | float imat[4][4]; | ||||
| invert_m4_m4(imat, ob->obmat); | invert_m4_m4(imat, ob->obmat); | ||||
| transpose_m4(imat); | transpose_m4(imat); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||