Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pbvh.c
| Show First 20 Lines • Show All 1,101 Lines • ▼ Show 20 Lines | PBVHUpdateData data = { | ||||
| .pbvh = pbvh, | .pbvh = pbvh, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| .vnors = pbvh->vert_normals, | .vnors = pbvh->vert_normals, | ||||
| }; | }; | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, totnode); | BKE_pbvh_parallel_range_settings(&settings, true, totnode); | ||||
| /* Zero normals before accumulation. | |||||
| * NOTE: This could be made parallel but has minimal gains as the task is not expensive. */ | |||||
| for (int n = 0; n < totnode; n++) { | |||||
| PBVHNode *node = nodes[n]; | |||||
| if ((node->flag & PBVH_UpdateNormals) == 0) { | |||||
| continue; | |||||
| } | |||||
| const int *faces = node->prim_indices; | |||||
| const int totface = node->totprim; | |||||
| for (int i = 0; i < totface; i++) { | |||||
| const MLoopTri *lt = &pbvh->looptri[faces[i]]; | |||||
| for (int j = 0; j < 3; j++) { | |||||
| const int v = pbvh->mloop[lt->tri[j]].v; | |||||
| if (pbvh->verts[v].flag & ME_VERT_PBVH_UPDATE) { | |||||
| zero_v3(data.vnors[v]); | |||||
| } | |||||
HooglyBoogly: I think this part would be simpler (and require loading less memory) if written like this (like… | |||||
campbellbartonAuthorUnsubmitted Done Inline ActionsThanks, I hadn't touched sculpt code in a while and missed the possibility of looping over verts directly. In this case though, there are no problems accessing from multiple threads. campbellbarton: Thanks, I hadn't touched sculpt code in a while and missed the possibility of looping over… | |||||
HooglyBooglyUnsubmitted Not Done Inline ActionsGreat, even better! HooglyBoogly: Great, even better! | |||||
| } | |||||
| } | |||||
| } | |||||
| BLI_task_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); | ||||
| BLI_task_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); | ||||
| } | } | ||||
| 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 20 Lines • Show All 1,940 Lines • Show Last 20 Lines | |||||
I think this part would be simpler (and require loading less memory) if written like this (like in pbvh_update_normals_store_task_cb):
const int *verts = node->vert_indices; const int totvert = node->uniq_verts; for (int i = 0; i < totvert; i++) { const int v = verts[i]; MVert *mvert = &pbvh->verts[v]; if (mvert->flag & ME_VERT_PBVH_UPDATE) { zero_v3(data.vnors[v]); } }