diff options
author | YimingWu <xp8110@outlook.com> | 2022-05-10 09:41:35 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2022-05-10 17:01:07 +0300 |
commit | cd349dc4023aa1e6b4728ae6804ae36a5e170758 (patch) | |
tree | 28a52c3b8602088935b2675c0513dc3f80f7a002 /source | |
parent | c60b570841f0aa468014123c1b75afdd66f1b387 (diff) |
LineArt: Use thread safe bound box.
The old method is not thread safe, which will lead to minor
memory leaks. This patch fixed that.
Reviewed By: Sebastian Parborg (zeddb)
Differential Revision: https://developer.blender.org/D14904
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index dbe2ae0b890..b09bb15ce81 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2358,18 +2358,21 @@ static void lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], double shift_x, double shift_y, - Object *use_ob) + Mesh *use_mesh) { - const BoundBox *bb = BKE_object_boundbox_get(use_ob); - if (!bb) { - /* For lights and empty stuff there will be no bbox. */ + if (!use_mesh) { 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 tmp[3]; 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]); mul_v4_m4v3_db(co[i], model_view_proj, tmp); co[i][0] -= shift_x * 2 * co[i][3]; @@ -2481,13 +2484,6 @@ static void lineart_main_load_geometries( 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) { use_mesh = BKE_object_get_evaluated_mesh(use_ob); } @@ -2506,6 +2502,17 @@ static void lineart_main_load_geometries( 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) { obi->free_use_mesh = true; } |