From 8589f60546b34ebf39bb09bca015014256765877 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Sun, 5 Jun 2022 21:05:13 +0200 Subject: Curves: Port bounding box node to the new curves type Avoid the conversion to and from the old type, which could be a substantial improvement in somce cases. --- source/blender/blenkernel/intern/geometry_set.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/geometry_set.cc') diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 10226bc6990..1a43c4d01b0 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_bounds.hh" #include "BLI_map.hh" #include "BLI_task.hh" @@ -15,7 +16,6 @@ #include "BKE_mesh_wrapper.h" #include "BKE_modifier.h" #include "BKE_pointcloud.h" -#include "BKE_spline.hh" #include "BKE_volume.h" #include "DNA_collection_types.h" @@ -175,6 +175,7 @@ Vector GeometrySet::get_components_for_read() const bool GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_max) const { + using namespace blender; bool have_minmax = false; if (const PointCloud *pointcloud = this->get_pointcloud_for_read()) { have_minmax |= BKE_pointcloud_minmax(pointcloud, *r_min, *r_max); @@ -185,10 +186,16 @@ bool GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_ma if (const Volume *volume = this->get_volume_for_read()) { have_minmax |= BKE_volume_min_max(volume, *r_min, *r_max); } - if (const Curves *curves = this->get_curves_for_read()) { - std::unique_ptr curve = curves_to_curve_eval(*curves); + if (const Curves *curves_id = this->get_curves_for_read()) { + const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry); /* Using the evaluated positions is somewhat arbitrary, but it is probably expected. */ - have_minmax |= curve->bounds_min_max(*r_min, *r_max, true); + std::optional> min_max = bounds::min_max( + curves.evaluated_positions()); + if (min_max) { + have_minmax = true; + *r_min = math::min(*r_min, min_max->min); + *r_max = math::max(*r_max, min_max->max); + } } return have_minmax; } -- cgit v1.2.3