Page MenuHome

BLI: Refactor length parameterization.
ClosedPublic

Authored by Jacques Lucke (JacquesLucke) on Jul 2 2022, 7:03 PM.

Details

Summary

Goals:

  • Simplify the sampling code by using an algorithm with less special cases.
  • Generalize the sampling to support non-sorted samples.

Diff Detail

Repository
rB Blender

Event Timeline

Jacques Lucke (JacquesLucke) requested review of this revision.Jul 2 2022, 7:03 PM
Jacques Lucke (JacquesLucke) created this revision.

This is great. It will make the sample node much simpler! If you want, the commit message could mention that it's inspired by (or at least similar to) OpenVDB's ValueAccessor.

This will probably be more beneficial when up-sampling, since the hint will be useful more often is the segments are long compared to the samples.
We could probably improve it for the down-sampling case by looking 5 or 10 segments ahead. But it's fine to leave that for later, since this is a nice simplification either way.

Unfortunately the two tests I added in D15340 still fail. That doesn't need to block this patch, it should be easier to look into after anyway.

source/blender/blenlib/BLI_length_parameterize.hh
135
139
This revision is now accepted and ready to land.Jul 2 2022, 8:35 PM

Unfortunately the two tests I added in D15340 still fail. That doesn't need to block this patch, it should be easier to look into after anyway.

I was looking at the tests now. I might be wrong but it feels like the test cases are just wrong. They are mixing up point values with segment lengths.

  • It doesn't work even with a much simpler example like lengths = {0, 1}.
  • If I create actual point values that result in the given lengths (like below), it works fine.
Vector<float> point_values;
point_values.append(4.0f);
for (float &length : lengths) {
  point_values.append(point_values.first() + length);
}
Jacques Lucke (JacquesLucke) marked 2 inline comments as done.Jul 2 2022, 9:47 PM
This revision was automatically updated to reflect the committed changes.

I was looking at the tests now. I might be wrong but it feels like the test cases are just wrong. They are mixing up point values with segment lengths.

  • It doesn't work even with a much simpler example like lengths = {0, 1}.
  • If I create actual point values that result in the given lengths (like below), it works fine.

I was suspicious about that but not sure. Makes sense in retrospect. And good news! Thanks for looking into it.