Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_set_position.cc
| Show All 28 Lines | static void set_computed_position_and_offset(GeometryComponent &component, | ||||
| const IndexMask selection) | const IndexMask selection) | ||||
| { | { | ||||
| MutableAttributeAccessor attributes = *component.attributes_for_write(); | MutableAttributeAccessor attributes = *component.attributes_for_write(); | ||||
| AttributeWriter<float3> positions = attributes.lookup_for_write<float3>("position"); | AttributeWriter<float3> positions = attributes.lookup_for_write<float3>("position"); | ||||
| const int grain_size = 10000; | const int grain_size = 10000; | ||||
| switch (component.type()) { | switch (component.type()) { | ||||
| case GEO_COMPONENT_TYPE_MESH: { | |||||
| Mesh *mesh = static_cast<MeshComponent &>(component).get_for_write(); | |||||
| MutableSpan<MVert> verts = mesh->verts_for_write(); | |||||
| if (in_positions.is_same(positions.varray)) { | |||||
| devirtualize_varray(in_offsets, [&](const auto in_offsets) { | |||||
| threading::parallel_for( | |||||
| selection.index_range(), grain_size, [&](const IndexRange range) { | |||||
| for (const int i : selection.slice(range)) { | |||||
| const float3 offset = in_offsets[i]; | |||||
| add_v3_v3(verts[i].co, offset); | |||||
| } | |||||
| }); | |||||
| }); | |||||
| } | |||||
| else { | |||||
| devirtualize_varray2( | |||||
| in_positions, in_offsets, [&](const auto in_positions, const auto in_offsets) { | |||||
| threading::parallel_for( | |||||
| selection.index_range(), grain_size, [&](const IndexRange range) { | |||||
| for (const int i : selection.slice(range)) { | |||||
| const float3 new_position = in_positions[i] + in_offsets[i]; | |||||
| copy_v3_v3(verts[i].co, new_position); | |||||
| } | |||||
| }); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case GEO_COMPONENT_TYPE_CURVE: { | case GEO_COMPONENT_TYPE_CURVE: { | ||||
| CurveComponent &curve_component = static_cast<CurveComponent &>(component); | CurveComponent &curve_component = static_cast<CurveComponent &>(component); | ||||
| Curves &curves_id = *curve_component.get_for_write(); | Curves &curves_id = *curve_component.get_for_write(); | ||||
| bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); | bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry); | ||||
| if (attributes.contains("handle_right") && attributes.contains("handle_left")) { | if (attributes.contains("handle_right") && attributes.contains("handle_left")) { | ||||
| SpanAttributeWriter<float3> handle_right_attribute = | SpanAttributeWriter<float3> handle_right_attribute = | ||||
| attributes.lookup_or_add_for_write_span<float3>("handle_right", ATTR_DOMAIN_POINT); | attributes.lookup_or_add_for_write_span<float3>("handle_right", ATTR_DOMAIN_POINT); | ||||
| SpanAttributeWriter<float3> handle_left_attribute = | SpanAttributeWriter<float3> handle_left_attribute = | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||