Skip to content

Commit

Permalink
Handle NaN in diff window for lights (#1352)
Browse files Browse the repository at this point in the history
If both values are NaN, treat them as equal as they usually are.
Closes #1351
  • Loading branch information
chreden authored Feb 16, 2025
1 parent da2083c commit 09ad282
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions trview.app/Windows/Diff/DiffWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ namespace trview
return value.has_value() ? to_string(*value) : "";
}

bool equal_float(float l, float r)
{
if (std::isnan(l) && std::isnan(r))
{
return true;
}
return l == r;
}

template <typename T>
struct Entry
{
Expand Down Expand Up @@ -562,15 +571,15 @@ namespace trview
left->intensity() == right->intensity() &&
left->fade() == right->fade() &&
left->direction() == right->direction() &&
left->in() == right->in() &&
left->out() == right->out() &&
((std::isnan(left->rad_in()) == std::isnan(right->rad_in())) || left->rad_in() == right->rad_in()) &&
((std::isnan(left->rad_out()) == std::isnan(right->rad_out())) || left->rad_out() == right->rad_out()) &&
left->range() == right->range() &&
left->length() == right->length() &&
left->cutoff() == right->cutoff() &&
left->radius() == right->radius() &&
left->density() == right->density();
equal_float(left->in(), right->in()) &&
equal_float(left->out(), right->out()) &&
equal_float(left->rad_in(), right->rad_in()) &&
equal_float(left->rad_out(), right->rad_out()) &&
equal_float(left->range(), right->range()) &&
equal_float(left->length(), right->length()) &&
equal_float(left->cutoff(), right->cutoff()) &&
equal_float(left->radius(), right->radius()) &&
equal_float(left->density(), right->density());
});

// Camera/Sinks:
Expand Down

0 comments on commit 09ad282

Please sign in to comment.