Page MenuHome

Curves: Port resample node to the new data-block
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Mar 24 2022, 4:51 AM.

Details

Summary

This commit re-implements the resample curve node to use the new curves
type instead of CurveEval. The largest changes come from the need to
keep track of offsets into the point array, and the fact that the
attributes for all curves are stored in a flat array.

Another difference is that a bit more of the logic is handled by
building on the field network inputs. The idea is to let the field
evaluator handle potential optimizations while making the rest of the
code simpler.

This also adds support for Catmull Rom curve inputs.

Diff Detail

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Mar 24 2022, 4:51 AM
Hans Goudey (HooglyBoogly) created this revision.
Hans Goudey (HooglyBoogly) retitled this revision from Curves: Port resample node to the new data-block (WIP) to Curves: Port resample node to the new data-block.
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
Hans Goudey (HooglyBoogly) set the repository for this revision to rB Blender.
Jacques Lucke (JacquesLucke) requested changes to this revision.Mar 27 2022, 2:14 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
251

Add comment saying that this is done because all curve attributes stay the same?

277

typo (both both)

279

Seems like it would be reasonable to have a ResultSamples for all the curves to avoid allocating many small vectors?
I'm fine with doing that as a separate optimization.

307

Comment should mention why this is the way it works. Maybe there is a possible optimization for some curve types so that we don't need this double-interpolation? (when downsampling a curve, that could lead to a lot of overhead)

341

Should be cleared first. Otherwise this might unnecessarily copy the old bytes into the grown vector.

400–401

I'd argue that currently there is not much value in creating separate multi-functions for great than zero and and. Performance and readability might be better if you reduce the number of multi-functions. (same in get_curve_count_field)

This revision now requires changes to proceed.Mar 27 2022, 2:14 PM
Hans Goudey (HooglyBoogly) marked 4 inline comments as done.
  • Store sample indices and factors in separate arrays
  • Use a "for each group of curves: for each attribute: for each curve" pattern
  • Refactor gathering of attribute spans
  • Use the changes to the length parameterize API
source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
400–401

My idea was to make the functions simple so that it would be simple to transition them to a separate library of easier-to-build multi-functions. Sort of like how views from C++20 are combined.
Maybe that's a bit preemptive though. For now I'll do what you suggest and make a larger function.

source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
224

typo, same below.

225–226

Generally, destructors shouldn't be able to fail. That's quite important for exception safety. While not strictly necessary here, I think it would be better to move the calls to .save() out of the destructor.

245

Add comment explaining why we have to retrieve attributes that are not interpolated.

277

typo (curves)

282

I don't understand this right now. Why "unselected"? Looks like the code is only doing something on selected curves.

311

typo (the the)

314

Maybe store selection.slice(selection_range) in a new variable?

Hans Goudey (HooglyBoogly) marked 9 inline comments as done.
  • Move saving out of destructor
  • Add comment
  • Store sliced selection in a avariable
  • Fix comments and typos
  • Merge branch 'master' into curves-resample-curves
source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc
225–226

Right, I think you mentioned that to me before, sorry I forgot. Makes sense!

Seems to look fine now, haven't tested it in great detail though. Maybe check if tests run and also so the flower shop test before committing.

This revision is now accepted and ready to land.Mar 30 2022, 4:39 PM