Use linearRamp and correct a small bug in lerpFill
This commit is contained in:
parent
84b58f82bd
commit
e58bf6f8cb
1 changed files with 12 additions and 6 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "Curve.h"
|
#include "Curve.h"
|
||||||
#include "Opcode.h"
|
#include "Opcode.h"
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
#include <spline/spline.h>
|
#include <spline/spline.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
@ -133,13 +134,18 @@ void Curve::fill(Interpolator itp, const bool fillStatus[NumValues])
|
||||||
|
|
||||||
void Curve::lerpFill(const bool fillStatus[NumValues])
|
void Curve::lerpFill(const bool fillStatus[NumValues])
|
||||||
{
|
{
|
||||||
for (int iCurr = 1; iCurr < NumValues - 1; ++iCurr) {
|
int left { 0 };
|
||||||
int iLeft, iRight;
|
int right { 1 };
|
||||||
iLeft = iCurr - 1;
|
auto pointSpan = absl::MakeSpan(_points);
|
||||||
for (iRight = iCurr + 1; iRight < 127 && !fillStatus[iRight]; ++iRight);
|
|
||||||
|
|
||||||
float mu = static_cast<float>(iCurr - iLeft) / (iRight - iLeft);
|
while (right < NumValues) {
|
||||||
_points[iCurr] = _points[iLeft] + mu * (_points[iRight] - _points[iLeft]);
|
for (; right < NumValues && !fillStatus[right]; ++right);
|
||||||
|
const auto length = right - left;
|
||||||
|
if (length > 1) {
|
||||||
|
const float mu = (_points[right] - _points[left]) / length;
|
||||||
|
linearRamp<float>(pointSpan.subspan(left + 1, length - 1), _points[left], mu);
|
||||||
|
}
|
||||||
|
left = right++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue