Geometry Nodes: transfer polygon attributes to points in Point Distribute node

This commit is contained in:
Jacques Lucke 2021-03-10 12:41:50 +01:00
parent 368647bd25
commit 4fece16d45
1 changed files with 21 additions and 0 deletions

View File

@ -309,6 +309,23 @@ BLI_NOINLINE static void interpolate_attribute_corner(const Mesh &mesh,
}
}
template<typename T>
BLI_NOINLINE static void interpolate_attribute_polygon(const Mesh &mesh,
const Span<int> looptri_indices,
const Span<T> data_in,
MutableSpan<T> data_out)
{
BLI_assert(data_in.size() == mesh.totpoly);
Span<MLoopTri> looptris = get_mesh_looptris(mesh);
for (const int i : data_out.index_range()) {
const int looptri_index = looptri_indices[i];
const MLoopTri &looptri = looptris[looptri_index];
const int poly_index = looptri.poly;
data_out[i] = data_in[poly_index];
}
}
template<typename T>
BLI_NOINLINE static void interpolate_attribute(const Mesh &mesh,
Span<float3> bary_coords,
@ -327,6 +344,10 @@ BLI_NOINLINE static void interpolate_attribute(const Mesh &mesh,
mesh, bary_coords, looptri_indices, source_span, output_span);
break;
}
case ATTR_DOMAIN_POLYGON: {
interpolate_attribute_polygon<T>(mesh, looptri_indices, source_span, output_span);
break;
}
default: {
/* Not supported currently. */
return;