Sculpt: Assert when applying a translation that contains NaN

There have been a number of commits that have introduced regressions
in Sculpt mode where NaN begins to be propagated. While it is visually
very obvious that this is happening, this commit adds an assert so that
any automated testing with asserts on will also catch this issue.

Related to 23951e1b12

Pull Request: https://projects.blender.org/blender/blender/pulls/133992
This commit is contained in:
Sean Kim
2025-06-10 01:48:21 +02:00
committed by Sean Kim
parent 44bfeb2214
commit 12f4e17044

View File

@@ -7226,11 +7226,17 @@ void reset_translations_to_original(const MutableSpan<float3> translations,
}
}
static bool contains_nan(const Span<float> values)
{
return std::any_of(values.begin(), values.end(), [&](const float v) { return std::isnan(v); });
}
void apply_translations(const Span<float3> translations,
const Span<int> verts,
const MutableSpan<float3> positions)
{
BLI_assert(verts.size() == translations.size());
BLI_assert(!contains_nan(translations.cast<float>()));
for (const int i : verts.index_range()) {
const int vert = verts[i];
@@ -7245,6 +7251,7 @@ void apply_translations(const Span<float3> translations,
const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg);
MutableSpan<float3> positions = subdiv_ccg.positions;
BLI_assert(grids.size() * key.grid_area == translations.size());
BLI_assert(!contains_nan(translations.cast<float>()));
for (const int i : grids.index_range()) {
const Span<float3> grid_translations = translations.slice(bke::ccg::grid_range(key, i));
@@ -7258,6 +7265,7 @@ void apply_translations(const Span<float3> translations,
void apply_translations(const Span<float3> translations, const Set<BMVert *, 0> &verts)
{
BLI_assert(verts.size() == translations.size());
BLI_assert(!contains_nan(translations.cast<float>()));
int i = 0;
for (BMVert *vert : verts) {