diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-05 22:05:13 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-05 22:05:13 +0300 |
commit | 8589f60546b34ebf39bb09bca015014256765877 (patch) | |
tree | a0b7a4037a4d6895f36e7f5ab44dcc00d98ab863 /source/blender/blenkernel | |
parent | c7e4c43072242951abaae36f380330b1dfbfed06 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set.cc | 15 |
1 files changed, 11 insertions, 4 deletions
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<const GeometryComponent *> 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<CurveEval> 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<bounds::MinMaxResult<float3>> 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; } |