Curves: Port convex hull node to new data-block
This uses the evaluated positions calculations from 8538c69921
.
This commit is contained in:
parent
7bdba5f1e0
commit
d4bd9f6a27
Notes:
blender-bot
2023-02-13 16:20:51 +01:00
Referenced by issue #95443, Refactor curve nodes to use new data structure
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue