vtkm::Lerp now casts integer types to an appropriate scalar type.
Previously types such as vtkm::Id or vtkm::U/Int32 would be cast to whatever the weight type was. This is problematic as they should actually be casted to a double type as the weight type could be a float and therefore the results
This commit is contained in:
parent
0d45c5cff2
commit
83b360f1ea
@ -41,11 +41,13 @@ namespace vtkm
|
|||||||
/// extrapolates. If w=0 => v0 is returned if w=1 => v1 is returned.
|
/// extrapolates. If w=0 => v0 is returned if w=1 => v1 is returned.
|
||||||
///
|
///
|
||||||
template <typename ValueType, typename WeightType>
|
template <typename ValueType, typename WeightType>
|
||||||
VTKM_EXEC_CONT ValueType Lerp(const ValueType& value0,
|
inline VTKM_EXEC_CONT ValueType Lerp(const ValueType& value0,
|
||||||
const ValueType& value1,
|
const ValueType& value1,
|
||||||
const WeightType& weight)
|
const WeightType& weight)
|
||||||
{
|
{
|
||||||
return static_cast<ValueType>((WeightType(1) - weight) * value0 + weight * value1);
|
using ScalarType = typename detail::FloatingPointReturnType<ValueType>::Type;
|
||||||
|
return static_cast<ValueType>((WeightType(1) - weight) * static_cast<ScalarType>(value0) +
|
||||||
|
weight * static_cast<ScalarType>(value1));
|
||||||
}
|
}
|
||||||
template <typename ValueType, vtkm::IdComponent N, typename WeightType>
|
template <typename ValueType, vtkm::IdComponent N, typename WeightType>
|
||||||
VTKM_EXEC_CONT vtkm::Vec<ValueType, N> Lerp(const vtkm::Vec<ValueType, N>& value0,
|
VTKM_EXEC_CONT vtkm::Vec<ValueType, N> Lerp(const vtkm::Vec<ValueType, N>& value0,
|
||||||
|
Loading…
Reference in New Issue
Block a user