[Bf-blender-cvs] [9f895fbb970] master: Geometry Nodes: Optimize curve builtin attribute exists check
Hans Goudey
noreply at git.blender.org
Mon Oct 18 19:31:08 CEST 2021
Commit: 9f895fbb9708eaa1d70abcd3091d44f262380a8a
Author: Hans Goudey
Date: Mon Oct 18 12:31:01 2021 -0500
Branches: master
https://developer.blender.org/rB9f895fbb9708eaa1d70abcd3091d44f262380a8a
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.
===================================================================
M source/blender/blenkernel/intern/geometry_component_curve.cc
===================================================================
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;
}
};
More information about the Bf-blender-cvs
mailing list