Cleanup: Add a function to sample mesh point normals
This simplifies #108014 and is consistent with the existing function for face corners, `sample_corner_normals`.
This commit is contained in:
parent
f106579a9a
commit
468295cb7c
|
@ -35,6 +35,14 @@ void sample_point_attribute(Span<int> corner_verts,
|
|||
IndexMask mask,
|
||||
GMutableSpan dst);
|
||||
|
||||
void sample_point_normals(Span<int> corner_verts,
|
||||
Span<MLoopTri> looptris,
|
||||
Span<int> looptri_indices,
|
||||
Span<float3> bary_coords,
|
||||
Span<float3> src,
|
||||
IndexMask mask,
|
||||
MutableSpan<float3> dst);
|
||||
|
||||
void sample_corner_attribute(Span<MLoopTri> looptris,
|
||||
Span<int> looptri_indices,
|
||||
Span<float3> bary_coords,
|
||||
|
|
|
@ -32,6 +32,24 @@ BLI_NOINLINE static void sample_point_attribute(const Span<int> corner_verts,
|
|||
}
|
||||
}
|
||||
|
||||
void sample_point_normals(const Span<int> corner_verts,
|
||||
const Span<MLoopTri> looptris,
|
||||
const Span<int> looptri_indices,
|
||||
const Span<float3> bary_coords,
|
||||
const Span<float3> src,
|
||||
const IndexMask mask,
|
||||
const MutableSpan<float3> dst)
|
||||
{
|
||||
for (const int i : mask) {
|
||||
const MLoopTri &tri = looptris[looptri_indices[i]];
|
||||
const float3 value = attribute_math::mix3(bary_coords[i],
|
||||
src[corner_verts[tri.tri[0]]],
|
||||
src[corner_verts[tri.tri[1]]],
|
||||
src[corner_verts[tri.tri[2]]]);
|
||||
dst[i] = math::normalize(value);
|
||||
}
|
||||
}
|
||||
|
||||
void sample_point_attribute(const Span<int> corner_verts,
|
||||
const Span<MLoopTri> looptris,
|
||||
const Span<int> looptri_indices,
|
||||
|
|
Loading…
Reference in New Issue