News for hackers. Stuff that matters.
Re:Random Acts of Optimization by josephg on Thursday October 29, 2015 @05:35PM (#10474509)
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.
Re:Random Acts of Optimization by RiotTony on Thursday October 29, 2015 @07:22PM (#10475164)
Because 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.