[Bf-blender-cvs] [8589f60546b] master: Curves: Port bounding box node to the new curves type
Hans Goudey
noreply at git.blender.org
Sun Jun 5 21:05:28 CEST 2022
Commit: 8589f60546b34ebf39bb09bca015014256765877
Author: Hans Goudey
Date: Sun Jun 5 21:05:13 2022 +0200
Branches: master
https://developer.blender.org/rB8589f60546b34ebf39bb09bca015014256765877
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.
===================================================================
M 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<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;
}
More information about the Bf-blender-cvs
mailing list