diff options
author | Hans Goudey <h.goudey@me.com> | 2021-10-18 20:31:01 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-10-18 20:31:01 +0300 |
commit | 9f895fbb9708eaa1d70abcd3091d44f262380a8a (patch) | |
tree | 212a94ed10cacf647feb342db2ac1951d76ed343 /source | |
parent | 9a8badc1e4175fb1765486413ba5bc86575e3ea0 (diff) |
Geometry Nodes: Optimize curve builtin attribute exists check
Calculating the number of points is overkill here, if there are many splines.
The `exists` check just needs to know if there are any points at all.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_curve.cc | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc index 73c628d3f0f..8923521d699 100644 --- a/source/blender/blenkernel/intern/geometry_component_curve.cc +++ b/source/blender/blenkernel/intern/geometry_component_curve.cc @@ -1055,7 +1055,29 @@ template<typename T> class BuiltinPointAttributeProvider : public BuiltinAttribu bool exists(const GeometryComponent &component) const final { - return component.attribute_domain_size(ATTR_DOMAIN_POINT) != 0; + const CurveEval *curve = get_curve_from_component_for_read(component); + if (curve == nullptr) { + return false; + } + + Span<SplinePtr> splines = curve->splines(); + if (splines.size() == 0) { + return false; + } + + bool has_point = false; + for (const SplinePtr &spline : curve->splines()) { + if (spline->size() != 0) { + has_point = true; + break; + } + } + + if (!has_point) { + return false; + } + + return true; } }; |