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.
This commit is contained in:
parent
c7e4c43072
commit
8589f60546
Notes:
blender-bot
2023-02-14 08:42:53 +01:00
Referenced by issue #100906, Regression: Lag in sculpt mode when navigating around an object with modifiers Referenced by issue #100872, Crash when creating geometry nodes in a for-loop with Python Referenced by issue #98620, Regression: Video sequencer screen corruption occurs when resizing Referenced by issue #95443, Refactor curve nodes to use new data structure
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue