Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_proximity.cc
| Show All 21 Lines | |||||
| #include "BKE_bvhutils.h" | #include "BKE_bvhutils.h" | ||||
| #include "BKE_geometry_set.hh" | #include "BKE_geometry_set.hh" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes { | namespace blender::nodes::node_geo_proximity_cc { | ||||
| static void geo_node_proximity_declare(NodeDeclarationBuilder &b) | static void geo_node_proximity_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Target")) | b.add_input<decl::Geometry>(N_("Target")) | ||||
| .only_realized_data() | .only_realized_data() | ||||
| .supported_type({GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD}); | .supported_type({GEO_COMPONENT_TYPE_MESH, GEO_COMPONENT_TYPE_POINT_CLOUD}); | ||||
| b.add_input<decl::Vector>(N_("Source Position")).implicit_field(); | b.add_input<decl::Vector>(N_("Source Position")).implicit_field(); | ||||
| b.add_output<decl::Vector>(N_("Position")).dependent_field(); | b.add_output<decl::Vector>(N_("Position")).dependent_field(); | ||||
| ▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | auto proximity_fn = std::make_unique<ProximityFunction>( | ||||
| static_cast<GeometryNodeProximityTargetType>(storage.target_element)); | static_cast<GeometryNodeProximityTargetType>(storage.target_element)); | ||||
| auto proximity_op = std::make_shared<FieldOperation>( | auto proximity_op = std::make_shared<FieldOperation>( | ||||
| FieldOperation(std::move(proximity_fn), {std::move(position_field)})); | FieldOperation(std::move(proximity_fn), {std::move(position_field)})); | ||||
| params.set_output("Position", Field<float3>(proximity_op, 0)); | params.set_output("Position", Field<float3>(proximity_op, 0)); | ||||
| params.set_output("Distance", Field<float>(proximity_op, 1)); | params.set_output("Distance", Field<float>(proximity_op, 1)); | ||||
| } | } | ||||
| } // namespace blender::nodes | } // namespace blender::nodes::node_geo_proximity_cc | ||||
| void register_node_type_geo_proximity() | void register_node_type_geo_proximity() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_proximity_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_PROXIMITY, "Geometry Proximity", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_PROXIMITY, "Geometry Proximity", NODE_CLASS_GEOMETRY, 0); | ||||
| node_type_init(&ntype, blender::nodes::geo_proximity_init); | node_type_init(&ntype, file_ns::geo_proximity_init); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeGeometryProximity", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeGeometryProximity", node_free_standard_storage, node_copy_standard_storage); | ||||
| ntype.declare = blender::nodes::geo_node_proximity_declare; | ntype.declare = file_ns::geo_node_proximity_declare; | ||||
| ntype.geometry_node_execute = blender::nodes::geo_node_proximity_exec; | ntype.geometry_node_execute = file_ns::geo_node_proximity_exec; | ||||
| ntype.draw_buttons = blender::nodes::geo_node_proximity_layout; | ntype.draw_buttons = file_ns::geo_node_proximity_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||