diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-25 21:39:51 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-25 21:40:07 +0300 |
commit | f431be224fa58374386a32dba2542ee20d2a2d61 (patch) | |
tree | 7470402341cd9e9b8f5dbb50dc101249bf15c4bb /source/blender/blenkernel/intern/geometry_component_curves.cc | |
parent | 845e2ed3a282913cd9d37207a313627275acc158 (diff) |
Curves: Cache the number of curves of each type
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.
Differential Revision: https://developer.blender.org/D14732
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_curves.cc')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_curves.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 4796135b32f..bc9bba3ee2f 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -291,6 +291,15 @@ static void tag_component_topology_changed(GeometryComponent &component) } } +static void tag_component_curve_types_changed(GeometryComponent &component) +{ + Curves *curves = get_curves_from_component_for_write(component); + if (curves) { + blender::bke::CurvesGeometry::wrap(curves->geometry).update_curve_types(); + blender::bke::CurvesGeometry::wrap(curves->geometry).tag_topology_changed(); + } +} + static void tag_component_positions_changed(GeometryComponent &component) { Curves *curves = get_curves_from_component_for_write(component); @@ -506,7 +515,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() curve_access, make_array_read_attribute<int8_t>, make_array_write_attribute<int8_t>, - tag_component_topology_changed); + tag_component_curve_types_changed); static BuiltinCustomDataLayerProvider resolution("resolution", ATTR_DOMAIN_CURVE, |