Prevent the indices from overflowing
This commit is contained in:
parent
e3b0260d9c
commit
9e15fa5e7c
1 changed files with 4 additions and 2 deletions
|
|
@ -641,8 +641,10 @@ namespace _internals {
|
||||||
template <class T>
|
template <class T>
|
||||||
void snippetSFZInterpolationCast(const T*& floatJump, int*& jump, T*& coeff)
|
void snippetSFZInterpolationCast(const T*& floatJump, int*& jump, T*& coeff)
|
||||||
{
|
{
|
||||||
*jump = static_cast<int>(*floatJump);
|
constexpr float maxJump { 1 << 24 };
|
||||||
*coeff = *floatJump - static_cast<float>(*jump);
|
const float limitedJump = min(maxJump, *floatJump);
|
||||||
|
*jump = static_cast<int>(limitedJump);
|
||||||
|
*coeff = limitedJump - static_cast<float>(*jump);
|
||||||
incrementAll(floatJump, coeff, jump);
|
incrementAll(floatJump, coeff, jump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue