Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
| Show All 28 Lines | static bNodeSocketTemplate geo_node_point_translate_out[] = { | ||||
| {SOCK_GEOMETRY, N_("Geometry")}, | {SOCK_GEOMETRY, N_("Geometry")}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) | static void execute_on_component(GeoNodeExecParams params, GeometryComponent &component) | ||||
| { | { | ||||
| Float3WriteAttribute position_attribute = component.attribute_try_ensure_for_write( | OutputAttributePtr position_attribute = component.attribute_try_get_for_output( | ||||
| "position", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); | "position", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); | ||||
| ReadAttributePtr attribute = params.get_input_attribute( | ReadAttributePtr attribute = params.get_input_attribute( | ||||
| "Translation", component, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, nullptr); | "Translation", component, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, nullptr); | ||||
| if (!attribute) { | if (!attribute) { | ||||
| return; | return; | ||||
| } | } | ||||
| Span<float3> data = attribute->get_span<float3>(); | Span<float3> data = attribute->get_span<float3>(); | ||||
| MutableSpan<float3> scale_span = position_attribute.get_span(); | MutableSpan<float3> scale_span = position_attribute->get_span<float3>(); | ||||
| for (const int i : scale_span.index_range()) { | for (const int i : scale_span.index_range()) { | ||||
| scale_span[i] = scale_span[i] + data[i]; | scale_span[i] = scale_span[i] + data[i]; | ||||
| } | } | ||||
| position_attribute.apply_span(); | position_attribute.apply_span_and_save(); | ||||
| } | } | ||||
| static void geo_node_point_translate_exec(GeoNodeExecParams params) | static void geo_node_point_translate_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| if (geometry_set.has<MeshComponent>()) { | if (geometry_set.has<MeshComponent>()) { | ||||
| execute_on_component(params, geometry_set.get_component_for_write<MeshComponent>()); | execute_on_component(params, geometry_set.get_component_for_write<MeshComponent>()); | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||