[Bf-blender-cvs] [d4bd9f6a278] master: Curves: Port convex hull node to new data-block
Hans Goudey
noreply at git.blender.org
Thu Mar 17 23:45:47 CET 2022
Commit: d4bd9f6a278b70347d277d46a76a9a44ffc34caa
Author: Hans Goudey
Date: Thu Mar 17 17:45:37 2022 -0500
Branches: master
https://developer.blender.org/rBd4bd9f6a278b70347d277d46a76a9a44ffc34caa
Curves: Port convex hull node to new data-block
This uses the evaluated positions calculations from 8538c69921662164677.
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
index 412f35d62fd..87fc6bcbad4 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
@@ -4,9 +4,9 @@
#include "DNA_meshdata_types.h"
#include "DNA_pointcloud_types.h"
+#include "BKE_curves.hh"
#include "BKE_material.h"
#include "BKE_mesh.h"
-#include "BKE_spline.hh"
#include "node_geometry_util.hh"
@@ -162,14 +162,12 @@ static Mesh *compute_hull(const GeometrySet &geometry_set)
}
if (geometry_set.has_curves()) {
- const std::unique_ptr<CurveEval> curve = curves_to_curve_eval(
- *geometry_set.get_curves_for_read());
- for (const SplinePtr &spline : curve->splines()) {
- positions_span = spline->evaluated_positions();
- total_size += positions_span.size();
- count++;
- span_count++;
- }
+ count++;
+ span_count++;
+ const Curves &curves_id = *geometry_set.get_curves_for_read();
+ const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
+ positions_span = curves.evaluated_positions();
+ total_size += positions_span.size();
}
if (count == 0) {
@@ -203,13 +201,11 @@ static Mesh *compute_hull(const GeometrySet &geometry_set)
}
if (geometry_set.has_curves()) {
- const std::unique_ptr<CurveEval> curve = curves_to_curve_eval(
- *geometry_set.get_curves_for_read());
- for (const SplinePtr &spline : curve->splines()) {
- Span<float3> array = spline->evaluated_positions();
- positions.as_mutable_span().slice(offset, array.size()).copy_from(array);
- offset += array.size();
- }
+ const Curves &curves_id = *geometry_set.get_curves_for_read();
+ const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
+ Span<float3> array = curves.evaluated_positions();
+ positions.as_mutable_span().slice(offset, array.size()).copy_from(array);
+ offset += array.size();
}
return hull_from_bullet(geometry_set.get_mesh_for_read(), positions);
@@ -240,20 +236,16 @@ static void read_positions(const GeometryComponent &component,
}
}
-static void read_curve_positions(const CurveEval &curve,
+static void read_curve_positions(const Curves &curves_id,
Span<float4x4> transforms,
Vector<float3> *r_coords)
{
- const Array<int> offsets = curve.evaluated_point_offsets();
- const int total_size = offsets.last();
+ const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
+ const int total_size = curves.evaluated_points_size();
r_coords->reserve(r_coords->size() + total_size * transforms.size());
- for (const SplinePtr &spline : curve.splines()) {
- Span<float3> positions = spline->evaluated_positions();
- for (const float4x4 &transform : transforms) {
- for (const float3 &position : positions) {
- r_coords->append(transform * position);
- }
- }
+ r_coords->as_mutable_span().take_back(total_size).copy_from(curves.evaluated_positions());
+ for (const float3 &position : curves.evaluated_positions()) {
+ r_coords->append(transform * postition);
}
}
@@ -275,7 +267,7 @@ static Mesh *convex_hull_from_instances(const GeometrySet &geometry_set)
read_positions(*set.get_component_for_read<MeshComponent>(), transforms, &coords);
}
if (set.has_curves()) {
- read_curve_positions(*curves_to_curve_eval(*set.get_curves_for_read()), transforms, &coords);
+ read_curve_positions(*set.get_curves_for_read(), transforms, &coords);
}
}
return hull_from_bullet(nullptr, coords);
More information about the Bf-blender-cvs
mailing list