diff --git a/include/ScalarField.h b/include/ScalarField.h index 8f311af..96ec877 100644 --- a/include/ScalarField.h +++ b/include/ScalarField.h @@ -116,27 +116,16 @@ namespace CCCoreLib float fillValueF = 0.0f; if (std::isfinite(fillValue)) { - if (fillValue == 0) + if (m_offsetHasBeenSet) { - // special case: filling with zeros - // (it doesn't really give an idea of what the optimal offset is) - resetOffset(); - - //fillValueF = 0.0f; // already set + fillValueF = static_cast(fillValue - m_offset); } else { - if (m_offsetHasBeenSet) - { - fillValueF = static_cast(fillValue - m_offset); - } - else - { - // if the offset has not been set yet, we use the first finite value by default - setOffset(fillValue); - - //fillValueF = 0.0f; // already set - } + // if the offset has not been set yet, we use the first finite value by default + setOffset(fillValue); + + //fillValueF = 0.0f; // already set } } else diff --git a/src/ScalarField.cpp b/src/ScalarField.cpp index 8637940..cb2a396 100644 --- a/src/ScalarField.cpp +++ b/src/ScalarField.cpp @@ -134,17 +134,8 @@ bool ScalarField::resizeSafe(std::size_t count, bool initNewElements/*=false*/, } else // if the offset has not been set yet... { - if (valueForNewElements == 0) - { - // special case: filling with zeros - // (it doesn't really give an idea of what the optimal offset is) - m_offset = 0.0; - } - else - { - // we use the first finite value as offset by default - setOffset(valueForNewElements); - } + // we use the first finite value as offset by default + setOffset(valueForNewElements); } } else