Fix #117515: Geometry Nodes: Count of unique face neighbors #118848

Merged
Hans Goudey merged 4 commits from mod_moder/blender:tmp_change_face_neighboards_num into main 2024-04-14 01:08:23 +02:00
1 changed files with 12 additions and 22 deletions
Showing only changes of commit 26a6bea73d - Show all commits

View File

@ -7,8 +7,6 @@
#include "BLI_task.hh"
#include "BLI_timeit.hh"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_input_mesh_face_neighbors_cc {
@ -23,14 +21,14 @@ static void node_declare(NodeDeclarationBuilder &b)
.description("Number of faces which share an edge with the face");
}
static bool enught_large_total(const GroupedSpan<int> values,
const Span<int> indices,
const int total)
static bool large_enough_total_size(const GroupedSpan<int> values,
const Span<int> indices,
const int max)
mod_moder marked this conversation as resolved Outdated

Grammar: large_enough_total_size

Grammar: `large_enough_total_size`
{
int num = 0;
for (const int i : indices) {
num += values[i].size();
if (total <= num) {
if (max <= num) {
return true;
}
}
@ -39,7 +37,7 @@ static bool enught_large_total(const GroupedSpan<int> values,
static int unique_num(const GroupedSpan<int> values, const Span<int> indices)
{
if (enught_large_total(values, indices, 100)) {
if (large_enough_total_size(values, indices, 100)) {
Set<int, 16> unique_values;
for (const int i : indices) {
unique_values.add_multiple(values[i]);
@ -61,23 +59,15 @@ static VArray<int> construct_neighbor_count_varray(const Mesh &mesh, const AttrD
Array<int> offsets;
Array<int> indices;
GroupedSpan<int> edge_to_faces_map;
{
SCOPED_TIMER_AVERAGED("build_edge_to_face_map");
edge_to_faces_map = bke::mesh::build_edge_to_face_map(
face_edges.offsets, face_edges.data, mesh.edges_num, offsets, indices);
}
GroupedSpan<int> edge_to_faces_map = bke::mesh::build_edge_to_face_map(
face_edges.offsets, face_edges.data, mesh.edges_num, offsets, indices);
Array<int> face_count(face_edges.size());
{
SCOPED_TIMER_AVERAGED("face_count: Set");
threading::parallel_for(face_edges.index_range(), 2048, [&](const IndexRange range) {
for (const int64_t face_i : range) {
face_count[face_i] = unique_num(edge_to_faces_map, face_edges[face_i]) - 1;
}
});
}
threading::parallel_for(face_edges.index_range(), 2048, [&](const IndexRange range) {
for (const int64_t face_i : range) {
mod_moder marked this conversation as resolved Outdated

I guess these timers can be removed now

I guess these timers can be removed now
face_count[face_i] = unique_num(edge_to_faces_map, face_edges[face_i]) - 1;
}
});
return mesh.attributes().adapt_domain<int>(
VArray<int>::ForContainer(std::move(face_count)), AttrDomain::Face, domain);
}