Page MenuHome

Curves: Cache the number of curves of each type
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Apr 23 2022, 1:19 AM.

Details

Summary

Remembering the number of curves of every type makes it fast to know
whether processing specific to a single curve type has to be done.
This information was accessed in quite a few places, so this should be
an overall reduction in overhead for the new curves type.

The cache is computed eagerly, in other words every time after changing
the curve types. In order to reduce verbosity I added helper functions
for some common ways to set the types.

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Apr 23 2022, 1:19 AM
Hans Goudey (HooglyBoogly) created this revision.
source/blender/blenkernel/intern/curves_geometry.cc
256

This looks wrong, because it removes info about all other curves.

source/blender/blenkernel/intern/curves_geometry.cc
256

Oops, good catch. Yeah, copy and paste error.

Hans Goudey (HooglyBoogly) marked an inline comment as done.Apr 25 2022, 5:48 AM
source/blender/blenkernel/BKE_curves.hh
170

Short for, not sure if there is a word missing here.

181

Wonder if it would be good to return a const std::array<int, CURVE_TYPES_NUM> &. That would be more clear imo.

source/blender/blenkernel/intern/curves_geometry.cc
1427
/home/jacques/blender/blender/source/blender/blenkernel/intern/curves_geometry.cc:1425:6: error: no declaration matches ‘void blender::bke::CurvesGeometry::remove_attributes_based_on_curve_types()’
 1425 | void CurvesGeometry::remove_attributes_based_on_curve_types()
      |      ^~~~~~~~~~~~~~
/home/jacques/blender/blender/source/blender/blenkernel/intern/curves_geometry.cc:1425:6: note: no functions named ‘void blender::bke::CurvesGeometry::remove_attributes_based_on_curve_types()’
In file included from /home/jacques/blender/blender/source/blender/blenkernel/intern/curves_geometry.cc:20:
/home/jacques/blender/blender/source/blender/blenkernel/BKE_curves.hh:116:7: note: ‘class blender::bke::CurvesGeometry’ defined here
  116 | class CurvesGeometry : public ::CurvesGeometry {
      |       ^~~~~~~~~~~~~~
source/blender/blenkernel/intern/geometry_component_curves.cc
298

Might still need to tag topology as changed.

Jacques Lucke (JacquesLucke) requested changes to this revision.Apr 25 2022, 4:52 PM
This revision now requires changes to proceed.Apr 25 2022, 4:52 PM
Hans Goudey (HooglyBoogly) marked 4 inline comments as done.Apr 25 2022, 6:10 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/blenkernel/BKE_curves.hh
170

No, that's just a phrase, but I can reword it.

source/blender/blenkernel/intern/curves_geometry.cc
1427

Oops, WIP code somehow made it into this patch, sorry.

Hans Goudey (HooglyBoogly) marked 2 inline comments as done.
  • Also tag component topology changes
  • Remove accidental inclusion in patch
  • Improve comments
  • Return a std::array instead of a span
This revision is now accepted and ready to land.Apr 25 2022, 6:24 PM