forked from blender/blender
me-main #1
@ -28,12 +28,14 @@ static void copy_data_based_on_map(const Span<T> src,
|
|||||||
const Span<int> index_map,
|
const Span<int> index_map,
|
||||||
MutableSpan<T> dst)
|
MutableSpan<T> dst)
|
||||||
{
|
{
|
||||||
for (const int i_src : index_map.index_range()) {
|
threading::parallel_for(index_map.index_range(), 1024, [&](const IndexRange range) {
|
||||||
|
for (const int i_src : range) {
|
||||||
const int i_dst = index_map[i_src];
|
const int i_dst = index_map[i_src];
|
||||||
if (i_dst != -1) {
|
if (i_dst != -1) {
|
||||||
dst[i_dst] = src[i_src];
|
dst[i_dst] = src[i_src];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,13 +161,15 @@ static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh,
|
|||||||
const Span<MEdge> src_edges = src_mesh.edges();
|
const Span<MEdge> src_edges = src_mesh.edges();
|
||||||
MutableSpan<MEdge> dst_edges = dst_mesh.edges_for_write();
|
MutableSpan<MEdge> dst_edges = dst_mesh.edges_for_write();
|
||||||
|
|
||||||
for (const int i_src : IndexRange(src_mesh.totedge)) {
|
threading::parallel_for(src_edges.index_range(), 1024, [&](const IndexRange range) {
|
||||||
|
for (const int i_src : range) {
|
||||||
const int i_dst = edge_map[i_src];
|
const int i_dst = edge_map[i_src];
|
||||||
if (ELEM(i_dst, -1, -2)) {
|
if (ELEM(i_dst, -1, -2)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dst_edges[i_dst] = src_edges[i_src];
|
dst_edges[i_dst] = src_edges[i_src];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh,
|
static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh,
|
||||||
@ -178,7 +182,8 @@ static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh,
|
|||||||
const Span<MEdge> src_edges = src_mesh.edges();
|
const Span<MEdge> src_edges = src_mesh.edges();
|
||||||
MutableSpan<MEdge> dst_edges = dst_mesh.edges_for_write();
|
MutableSpan<MEdge> dst_edges = dst_mesh.edges_for_write();
|
||||||
|
|
||||||
for (const int i_src : IndexRange(src_mesh.totedge)) {
|
threading::parallel_for(src_edges.index_range(), 1024, [&](const IndexRange range) {
|
||||||
|
for (const int i_src : range) {
|
||||||
const int i_dst = edge_map[i_src];
|
const int i_dst = edge_map[i_src];
|
||||||
if (i_dst == -1) {
|
if (i_dst == -1) {
|
||||||
continue;
|
continue;
|
||||||
@ -190,6 +195,7 @@ static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh,
|
|||||||
e_dst.v1 = vertex_map[e_src.v1];
|
e_dst.v1 = vertex_map[e_src.v1];
|
||||||
e_dst.v2 = vertex_map[e_src.v2];
|
e_dst.v2 = vertex_map[e_src.v2];
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Faces and edges changed but vertices are the same. */
|
/* Faces and edges changed but vertices are the same. */
|
||||||
@ -204,7 +210,8 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
|||||||
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
|
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
|
||||||
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
|
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
|
||||||
|
|
||||||
for (const int i_dst : masked_poly_indices.index_range()) {
|
threading::parallel_for(masked_poly_indices.index_range(), 512, [&](const IndexRange range) {
|
||||||
|
for (const int i_dst : range) {
|
||||||
const int i_src = masked_poly_indices[i_dst];
|
const int i_src = masked_poly_indices[i_dst];
|
||||||
|
|
||||||
const MPoly &mp_src = src_polys[i_src];
|
const MPoly &mp_src = src_polys[i_src];
|
||||||
@ -222,6 +229,7 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
|||||||
ml_dst[i].e = edge_map[ml_src[i].e];
|
ml_dst[i].e = edge_map[ml_src[i].e];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only faces changed. */
|
/* Only faces changed. */
|
||||||
@ -235,7 +243,8 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
|||||||
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
|
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
|
||||||
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
|
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
|
||||||
|
|
||||||
for (const int i_dst : masked_poly_indices.index_range()) {
|
threading::parallel_for(masked_poly_indices.index_range(), 512, [&](const IndexRange range) {
|
||||||
|
for (const int i_dst : range) {
|
||||||
const int i_src = masked_poly_indices[i_dst];
|
const int i_src = masked_poly_indices[i_dst];
|
||||||
|
|
||||||
const MPoly &mp_src = src_polys[i_src];
|
const MPoly &mp_src = src_polys[i_src];
|
||||||
@ -253,6 +262,7 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
|||||||
ml_dst[i].e = ml_src[i].e;
|
ml_dst[i].e = ml_src[i].e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
||||||
@ -267,7 +277,8 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
|||||||
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
|
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
|
||||||
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
|
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
|
||||||
|
|
||||||
for (const int i_dst : masked_poly_indices.index_range()) {
|
threading::parallel_for(masked_poly_indices.index_range(), 512, [&](const IndexRange range) {
|
||||||
|
for (const int i_dst : range) {
|
||||||
const int i_src = masked_poly_indices[i_dst];
|
const int i_src = masked_poly_indices[i_dst];
|
||||||
|
|
||||||
const MPoly &mp_src = src_polys[i_src];
|
const MPoly &mp_src = src_polys[i_src];
|
||||||
@ -285,6 +296,7 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
|
|||||||
ml_dst[i].e = edge_map[ml_src[i].e];
|
ml_dst[i].e = edge_map[ml_src[i].e];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_curves_selection(GeometrySet &geometry_set,
|
static void delete_curves_selection(GeometrySet &geometry_set,
|
||||||
@ -574,16 +586,20 @@ static void compute_selected_mesh_data_from_vertex_selection_edge_face(
|
|||||||
int *r_selected_polys_num,
|
int *r_selected_polys_num,
|
||||||
int *r_selected_loops_num)
|
int *r_selected_loops_num)
|
||||||
{
|
{
|
||||||
|
threading::parallel_invoke(
|
||||||
|
mesh.totedge > 1000,
|
||||||
|
[&]() {
|
||||||
compute_selected_edges_from_vertex_selection(
|
compute_selected_edges_from_vertex_selection(
|
||||||
mesh, vertex_selection, r_edge_map, r_selected_edges_num);
|
mesh, vertex_selection, r_edge_map, r_selected_edges_num);
|
||||||
|
},
|
||||||
|
[&]() {
|
||||||
compute_selected_polys_from_vertex_selection(mesh,
|
compute_selected_polys_from_vertex_selection(mesh,
|
||||||
vertex_selection,
|
vertex_selection,
|
||||||
r_selected_poly_indices,
|
r_selected_poly_indices,
|
||||||
r_loop_starts,
|
r_loop_starts,
|
||||||
r_selected_polys_num,
|
r_selected_polys_num,
|
||||||
r_selected_loops_num);
|
r_selected_loops_num);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -601,18 +617,24 @@ static void compute_selected_mesh_data_from_vertex_selection(const Mesh &mesh,
|
|||||||
int *r_selected_polys_num,
|
int *r_selected_polys_num,
|
||||||
int *r_selected_loops_num)
|
int *r_selected_loops_num)
|
||||||
{
|
{
|
||||||
|
threading::parallel_invoke(
|
||||||
|
mesh.totedge > 1000,
|
||||||
|
[&]() {
|
||||||
compute_selected_verts_from_vertex_selection(
|
compute_selected_verts_from_vertex_selection(
|
||||||
vertex_selection, r_vertex_map, r_selected_verts_num);
|
vertex_selection, r_vertex_map, r_selected_verts_num);
|
||||||
|
},
|
||||||
|
[&]() {
|
||||||
compute_selected_edges_from_vertex_selection(
|
compute_selected_edges_from_vertex_selection(
|
||||||
mesh, vertex_selection, r_edge_map, r_selected_edges_num);
|
mesh, vertex_selection, r_edge_map, r_selected_edges_num);
|
||||||
|
},
|
||||||
|
[&]() {
|
||||||
compute_selected_polys_from_vertex_selection(mesh,
|
compute_selected_polys_from_vertex_selection(mesh,
|
||||||
vertex_selection,
|
vertex_selection,
|
||||||
r_selected_poly_indices,
|
r_selected_poly_indices,
|
||||||
r_loop_starts,
|
r_loop_starts,
|
||||||
r_selected_polys_num,
|
r_selected_polys_num,
|
||||||
r_selected_loops_num);
|
r_selected_loops_num);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -629,14 +651,20 @@ static void compute_selected_mesh_data_from_edge_selection_edge_face(
|
|||||||
int *r_selected_polys_num,
|
int *r_selected_polys_num,
|
||||||
int *r_selected_loops_num)
|
int *r_selected_loops_num)
|
||||||
{
|
{
|
||||||
|
threading::parallel_invoke(
|
||||||
|
mesh.totedge > 1000,
|
||||||
|
[&]() {
|
||||||
compute_selected_edges_from_edge_selection(
|
compute_selected_edges_from_edge_selection(
|
||||||
mesh, edge_selection, r_edge_map, r_selected_edges_num);
|
mesh, edge_selection, r_edge_map, r_selected_edges_num);
|
||||||
|
},
|
||||||
|
[&]() {
|
||||||
compute_selected_polys_from_edge_selection(mesh,
|
compute_selected_polys_from_edge_selection(mesh,
|
||||||
edge_selection,
|
edge_selection,
|
||||||
r_selected_poly_indices,
|
r_selected_poly_indices,
|
||||||
r_loop_starts,
|
r_loop_starts,
|
||||||
r_selected_polys_num,
|
r_selected_polys_num,
|
||||||
r_selected_loops_num);
|
r_selected_loops_num);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -654,15 +682,25 @@ static void compute_selected_mesh_data_from_edge_selection(const Mesh &mesh,
|
|||||||
int *r_selected_polys_num,
|
int *r_selected_polys_num,
|
||||||
int *r_selected_loops_num)
|
int *r_selected_loops_num)
|
||||||
{
|
{
|
||||||
|
threading::parallel_invoke(
|
||||||
|
mesh.totedge > 1000,
|
||||||
|
[&]() {
|
||||||
r_vertex_map.fill(-1);
|
r_vertex_map.fill(-1);
|
||||||
compute_selected_verts_and_edges_from_edge_selection(
|
compute_selected_verts_and_edges_from_edge_selection(mesh,
|
||||||
mesh, edge_selection, r_vertex_map, r_edge_map, r_selected_verts_num, r_selected_edges_num);
|
edge_selection,
|
||||||
|
r_vertex_map,
|
||||||
|
r_edge_map,
|
||||||
|
r_selected_verts_num,
|
||||||
|
r_selected_edges_num);
|
||||||
|
},
|
||||||
|
[&]() {
|
||||||
compute_selected_polys_from_edge_selection(mesh,
|
compute_selected_polys_from_edge_selection(mesh,
|
||||||
edge_selection,
|
edge_selection,
|
||||||
r_selected_poly_indices,
|
r_selected_poly_indices,
|
||||||
r_loop_starts,
|
r_loop_starts,
|
||||||
r_selected_polys_num,
|
r_selected_polys_num,
|
||||||
r_selected_loops_num);
|
r_selected_loops_num);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user