by josephg · 11y ago · 0 comments
class AnimatedVariable {
int numValues;
std::vector<float> values;
// ...
}
Then: if (!mPrecomputed) {
float idx = time * numValues;
float before = values[idx], after = values[idx+1];
return lerp(before, after, idx - (int)idx);
}
I guess there's a bit of float -> int coercion going on there, but it shouldn't be too bad.