3 ms·
Why scan the table of precomputed values? It seems like the code would be both cleaner and faster like this: class AnimatedVariable { int numValues;
by josephg 11y ago
Why scan the table of precomputed values? It seems like the code would be both cleaner and faster like this:
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.
- RiotTony 11y agoBecause we are interpolating between keys which aren't evenly distributed in time. What you have there is pretty much what we do when looking up the precomputed values from the table.
- deleted 11y ago[deleted]