Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pbvh.c
| Show First 20 Lines • Show All 1,109 Lines • ▼ Show 20 Lines | static void pbvh_faces_update_normals(PBVH *bvh, PBVHNode **nodes, int totnode) | ||||
| */ | */ | ||||
| PBVHUpdateData data = { | PBVHUpdateData data = { | ||||
| .bvh = bvh, | .bvh = bvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| .vnors = vnors, | .vnors = vnors, | ||||
| }; | }; | ||||
| PBVHParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_normals_accum_task_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_normals_accum_task_cb, &settings); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_normals_store_task_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_normals_store_task_cb, &settings); | ||||
| MEM_freeN(vnors); | MEM_freeN(vnors); | ||||
| } | } | ||||
| static void pbvh_update_mask_redraw_task_cb(void *__restrict userdata, | static void pbvh_update_mask_redraw_task_cb(void *__restrict userdata, | ||||
| const int n, | const int n, | ||||
| const TaskParallelTLS *__restrict UNUSED(tls)) | const TaskParallelTLS *__restrict UNUSED(tls)) | ||||
| { | { | ||||
| Show All 33 Lines | |||||
| static void pbvh_update_mask_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) | static void pbvh_update_mask_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) | ||||
| { | { | ||||
| PBVHUpdateData data = { | PBVHUpdateData data = { | ||||
| .bvh = bvh, | .bvh = bvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| .flag = flag, | .flag = flag, | ||||
| }; | }; | ||||
| PBVHParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_mask_redraw_task_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_mask_redraw_task_cb, &settings); | ||||
| } | } | ||||
| static void pbvh_update_visibility_redraw_task_cb(void *__restrict userdata, | static void pbvh_update_visibility_redraw_task_cb(void *__restrict userdata, | ||||
| const int n, | const int n, | ||||
| const TaskParallelTLS *__restrict UNUSED(tls)) | const TaskParallelTLS *__restrict UNUSED(tls)) | ||||
| { | { | ||||
| PBVHUpdateData *data = userdata; | PBVHUpdateData *data = userdata; | ||||
| Show All 19 Lines | |||||
| static void pbvh_update_visibility_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) | static void pbvh_update_visibility_redraw(PBVH *bvh, PBVHNode **nodes, int totnode, int flag) | ||||
| { | { | ||||
| PBVHUpdateData data = { | PBVHUpdateData data = { | ||||
| .bvh = bvh, | .bvh = bvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| .flag = flag, | .flag = flag, | ||||
| }; | }; | ||||
| PBVHParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_visibility_redraw_task_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_visibility_redraw_task_cb, &settings); | ||||
| } | } | ||||
| static void pbvh_update_BB_redraw_task_cb(void *__restrict userdata, | static void pbvh_update_BB_redraw_task_cb(void *__restrict userdata, | ||||
| const int n, | const int n, | ||||
| const TaskParallelTLS *__restrict UNUSED(tls)) | const TaskParallelTLS *__restrict UNUSED(tls)) | ||||
| { | { | ||||
| PBVHUpdateData *data = userdata; | PBVHUpdateData *data = userdata; | ||||
| PBVH *bvh = data->bvh; | PBVH *bvh = data->bvh; | ||||
| Show All 19 Lines | |||||
| { | { | ||||
| /* update BB, redraw flag */ | /* update BB, redraw flag */ | ||||
| PBVHUpdateData data = { | PBVHUpdateData data = { | ||||
| .bvh = bvh, | .bvh = bvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| .flag = flag, | .flag = flag, | ||||
| }; | }; | ||||
| PBVHParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_BB_redraw_task_cb, &settings); | ||||
| } | } | ||||
| static int pbvh_get_buffers_update_flags(PBVH *bvh, bool show_vcol) | static int pbvh_get_buffers_update_flags(PBVH *bvh, bool show_vcol) | ||||
| { | { | ||||
| int update_flags = 0; | int update_flags = 0; | ||||
| update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0; | update_flags |= bvh->show_mask ? GPU_PBVH_BUFFERS_SHOW_MASK : 0; | ||||
| update_flags |= show_vcol ? GPU_PBVH_BUFFERS_SHOW_VCOL : 0; | update_flags |= show_vcol ? GPU_PBVH_BUFFERS_SHOW_VCOL : 0; | ||||
| update_flags |= bvh->show_face_sets ? GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS : 0; | update_flags |= bvh->show_face_sets ? GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS : 0; | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static void pbvh_update_draw_buffers( | ||||
| /* Parallel creation and update of draw buffers. */ | /* Parallel creation and update of draw buffers. */ | ||||
| PBVHUpdateData data = { | PBVHUpdateData data = { | ||||
| .bvh = bvh, | .bvh = bvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| .show_vcol = show_vcol, | .show_vcol = show_vcol, | ||||
| }; | }; | ||||
| PBVHParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_draw_buffer_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_draw_buffer_cb, &settings); | ||||
| } | } | ||||
| static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag) | static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag) | ||||
| { | { | ||||
| int update = 0; | int update = 0; | ||||
| /* difficult to multithread well, we just do single threaded recursive */ | /* difficult to multithread well, we just do single threaded recursive */ | ||||
| if (node->flag & PBVH_Leaf) { | if (node->flag & PBVH_Leaf) { | ||||
| ▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
| static void pbvh_update_visibility(PBVH *bvh, PBVHNode **nodes, int totnode) | static void pbvh_update_visibility(PBVH *bvh, PBVHNode **nodes, int totnode) | ||||
| { | { | ||||
| PBVHUpdateData data = { | PBVHUpdateData data = { | ||||
| .bvh = bvh, | .bvh = bvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| }; | }; | ||||
| PBVHParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pbvh_update_visibility_task_cb, &settings); | BLI_task_parallel_range(0, totnode, &data, pbvh_update_visibility_task_cb, &settings); | ||||
| } | } | ||||
| void BKE_pbvh_update_visibility(PBVH *bvh) | void BKE_pbvh_update_visibility(PBVH *bvh) | ||||
| { | { | ||||
| if (!bvh->nodes) { | if (!bvh->nodes) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,417 Lines • ▼ Show 20 Lines | |||||
| void BKE_pbvh_get_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes) | void BKE_pbvh_get_frustum_planes(PBVH *bvh, PBVHFrustumPlanes *planes) | ||||
| { | { | ||||
| planes->num_planes = bvh->num_planes; | planes->num_planes = bvh->num_planes; | ||||
| for (int i = 0; i < planes->num_planes; i++) { | for (int i = 0; i < planes->num_planes; i++) { | ||||
| copy_v4_v4(planes->planes[i], bvh->planes[i]); | copy_v4_v4(planes->planes[i], bvh->planes[i]); | ||||
| } | } | ||||
| } | } | ||||
| void BKE_pbvh_parallel_range_settings(PBVHParallelSettings *settings, | void BKE_pbvh_parallel_range_settings(TaskParallelSettings *settings, | ||||
| bool use_threading, | bool use_threading, | ||||
| int totnode) | int totnode) | ||||
| { | { | ||||
| memset(settings, 0, sizeof(*settings)); | memset(settings, 0, sizeof(*settings)); | ||||
| settings->use_threading = use_threading && totnode > 1; | settings->use_threading = use_threading && totnode > 1; | ||||
| } | } | ||||
| MVert *BKE_pbvh_get_verts(const PBVH *bvh) | MVert *BKE_pbvh_get_verts(const PBVH *bvh) | ||||
| Show All 14 Lines | |||||