From 9f895fbb9708eaa1d70abcd3091d44f262380a8a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 18 Oct 2021 12:31:01 -0500 Subject: [PATCH] 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. --- .../intern/geometry_component_curve.cc | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 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 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; } };