Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_set_position.cc
| Show All 14 Lines | |||||
| */ | */ | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_set_position_cc { | namespace blender::nodes::node_geo_set_position_cc { | ||||
| static void geo_node_set_position_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Geometry")); | b.add_input<decl::Geometry>(N_("Geometry")); | ||||
| b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Position")).implicit_field(); | b.add_input<decl::Vector>(N_("Position")).implicit_field(); | ||||
| b.add_input<decl::Vector>(N_("Offset")).supports_field().subtype(PROP_TRANSLATION); | b.add_input<decl::Vector>(N_("Offset")).supports_field().subtype(PROP_TRANSLATION); | ||||
| b.add_output<decl::Geometry>(N_("Geometry")); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| Show All 32 Lines | static void set_position_in_component(GeometryComponent &component, | ||||
| MutableSpan<float3> position_mutable = positions.as_span(); | MutableSpan<float3> position_mutable = positions.as_span(); | ||||
| for (int i : selection) { | for (int i : selection) { | ||||
| position_mutable[i] = positions_input[i] + offsets_input[i]; | position_mutable[i] = positions_input[i] + offsets_input[i]; | ||||
| } | } | ||||
| positions.save(); | positions.save(); | ||||
| } | } | ||||
| static void geo_node_set_position_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry = params.extract_input<GeometrySet>("Geometry"); | ||||
| Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | ||||
| Field<float3> offset_field = params.extract_input<Field<float3>>("Offset"); | Field<float3> offset_field = params.extract_input<Field<float3>>("Offset"); | ||||
| Field<float3> position_field = params.extract_input<Field<float3>>("Position"); | Field<float3> position_field = params.extract_input<Field<float3>>("Position"); | ||||
| for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_MESH, | for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_MESH, | ||||
| GEO_COMPONENT_TYPE_POINT_CLOUD, | GEO_COMPONENT_TYPE_POINT_CLOUD, | ||||
| Show All 12 Lines | |||||
| void register_node_type_geo_set_position() | void register_node_type_geo_set_position() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_set_position_cc; | namespace file_ns = blender::nodes::node_geo_set_position_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_SET_POSITION, "Set Position", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_SET_POSITION, "Set Position", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_set_position_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.declare = file_ns::geo_node_set_position_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||