Skip to content

Commit

Permalink
extrapolate out msd values beyond 2x rather than clamping
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 15, 2017
1 parent eae224d commit 2b155de
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,12 @@ bool Steps::IsRecalcValid() {
}

float Steps::GetMSD(float x, int i) const {
if (x > 2.f) // just extrapolate from 2x+
return stuffnthings[13][i] + stuffnthings[13][i] * ((x - 2.f) * .5f);

int idx = static_cast<int>(x * 10) - 7;
CLAMP(idx, 0, 13); // prevent crashes due to people setting rate mod below 0.7 or above 2.0 somehow - mina
float prop = fmod(x * 10.f, 1.f);
if ( prop == 0)
if (prop == 0 && x <= 2.f)
return stuffnthings[idx][i];
return lerp(prop, stuffnthings[idx][i], stuffnthings[idx + 1][i]);
}
Expand Down Expand Up @@ -693,7 +695,7 @@ class LunaSteps: public Luna<Steps>
static int GetMSD(T* p, lua_State *L) {
float rate = FArg(1);
int index = IArg(2)-1;
CLAMP(rate, 0.7f, 2.f);
CLAMP(rate, 0.7f, 3.f);
lua_pushnumber(L, p->GetMSD(rate, index));
return 1;
}
Expand Down

0 comments on commit 2b155de

Please sign in to comment.