Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc66
1 files changed, 36 insertions, 30 deletions
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 489b618b8be..7c26ffc2099 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
@@ -140,28 +140,35 @@ static Mesh *compute_hull(const GeometrySet &geometry_set)
Span<float3> positions_span;
- if (geometry_set.has_mesh()) {
+ if (const MeshComponent *component = geometry_set.get_component_for_read<MeshComponent>()) {
count++;
- const MeshComponent *component = geometry_set.get_component_for_read<MeshComponent>();
- const Mesh *mesh = component->get_for_read();
- total_num += mesh->totvert;
+ if (const VArray<float3> positions = component->attributes()->lookup<float3>(
+ "position", ATTR_DOMAIN_POINT)) {
+ if (positions.is_span()) {
+ span_count++;
+ positions_span = positions.get_internal_span();
+ }
+ total_num += positions.size();
+ }
}
- if (geometry_set.has_pointcloud()) {
+ if (const PointCloudComponent *component =
+ geometry_set.get_component_for_read<PointCloudComponent>()) {
count++;
- span_count++;
- const PointCloudComponent *component =
- geometry_set.get_component_for_read<PointCloudComponent>();
- const PointCloud *pointcloud = component->get_for_read();
- positions_span = {reinterpret_cast<const float3 *>(pointcloud->co), pointcloud->totpoint};
- total_num += pointcloud->totpoint;
+ if (const VArray<float3> positions = component->attributes()->lookup<float3>(
+ "position", ATTR_DOMAIN_POINT)) {
+ if (positions.is_span()) {
+ span_count++;
+ positions_span = positions.get_internal_span();
+ }
+ total_num += positions.size();
+ }
}
- if (geometry_set.has_curves()) {
+ if (const Curves *curves_id = geometry_set.get_curves_for_read()) {
count++;
span_count++;
- const Curves &curves_id = *geometry_set.get_curves_for_read();
- const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
+ const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry);
positions_span = curves.evaluated_positions();
total_num += positions_span.size();
}
@@ -179,26 +186,25 @@ static Mesh *compute_hull(const GeometrySet &geometry_set)
Array<float3> positions(total_num);
int offset = 0;
- if (geometry_set.has_mesh()) {
- const MeshComponent *component = geometry_set.get_component_for_read<MeshComponent>();
- const VArray<float3> varray = component->attributes()->lookup<float3>("position",
- ATTR_DOMAIN_POINT);
- varray.materialize(positions.as_mutable_span().slice(offset, varray.size()));
- offset += varray.size();
+ if (const MeshComponent *component = geometry_set.get_component_for_read<MeshComponent>()) {
+ if (const VArray<float3> varray = component->attributes()->lookup<float3>("position",
+ ATTR_DOMAIN_POINT)) {
+ varray.materialize(positions.as_mutable_span().slice(offset, varray.size()));
+ offset += varray.size();
+ }
}
- if (geometry_set.has_pointcloud()) {
- const PointCloudComponent *component =
- geometry_set.get_component_for_read<PointCloudComponent>();
- const VArray<float3> varray = component->attributes()->lookup<float3>("position",
- ATTR_DOMAIN_POINT);
- varray.materialize(positions.as_mutable_span().slice(offset, varray.size()));
- offset += varray.size();
+ if (const PointCloudComponent *component =
+ geometry_set.get_component_for_read<PointCloudComponent>()) {
+ if (const VArray<float3> varray = component->attributes()->lookup<float3>("position",
+ ATTR_DOMAIN_POINT)) {
+ varray.materialize(positions.as_mutable_span().slice(offset, varray.size()));
+ offset += varray.size();
+ }
}
- if (geometry_set.has_curves()) {
- const Curves &curves_id = *geometry_set.get_curves_for_read();
- const bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
+ if (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();