Mesh: Multithreaded transformation apply #115021

Closed
glitchy-virophage wants to merge 1 commits from (deleted):multithreaded into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 10 additions and 2 deletions

View File

@ -1717,7 +1717,11 @@ float (*BKE_mesh_vert_coords_alloc(const Mesh *mesh, int *r_vert_len))[3]
void BKE_mesh_vert_coords_apply(Mesh *mesh, const float (*vert_coords)[3])
{
MutableSpan<float3> positions = mesh->vert_positions_for_write();
for (const int i : positions.index_range()) {
const int size = mesh->totvert;
#ifdef WITH_OMP
#pragma omp parallel for
#endif
for (int i = 0; i < size; ++i) {

Please, check threading::parallel_for() (from BLI_task.hh) use case instead of WITH_OMP.

Please, check `threading::parallel_for()` (from `BLI_task.hh`) use case instead of `WITH_OMP`.

the function being run is a lambda expression which is not compatible with it

the function being run is a lambda expression which is not compatible with it

Why?

Why?

i have no idea

i have no idea
Just as example https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/intern/mesh.cc#L1534

oh, i see where i went wrong, i was trying to replace the for loop with threading::parallel_for()

oh, i see where i went wrong, i was trying to replace the for loop with threading::parallel_for()
copy_v3_v3(positions[i], vert_coords[i]);
}
BKE_mesh_tag_positions_changed(mesh);
@ -1728,7 +1732,11 @@ void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh,
const float mat[4][4])
{
MutableSpan<float3> positions = mesh->vert_positions_for_write();
for (const int i : positions.index_range()) {
const int size = mesh->totvert;
#ifdef WITH_OMP
#pragma omp parallel for
#endif
for (int i = 0; i < size; ++i) {
mul_v3_m4v3(positions[i], mat, vert_coords[i]);
}
BKE_mesh_tag_positions_changed(mesh);