Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc
| Show All 32 Lines | |||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_transfer_attribute_cc { | namespace blender::nodes::node_geo_transfer_attribute_cc { | ||||
| using namespace blender::bke::mesh_surface_sample; | using namespace blender::bke::mesh_surface_sample; | ||||
| using blender::fn::GArray; | using blender::fn::GArray; | ||||
| static void geo_node_transfer_attribute_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Target")) | b.add_input<decl::Geometry>(N_("Target")) | ||||
| .supported_type({GEO_COMPONENT_TYPE_MESH, | .supported_type({GEO_COMPONENT_TYPE_MESH, | ||||
| GEO_COMPONENT_TYPE_POINT_CLOUD, | GEO_COMPONENT_TYPE_POINT_CLOUD, | ||||
| GEO_COMPONENT_TYPE_CURVE, | GEO_COMPONENT_TYPE_CURVE, | ||||
| GEO_COMPONENT_TYPE_INSTANCES}); | GEO_COMPONENT_TYPE_INSTANCES}); | ||||
| b.add_input<decl::Vector>(N_("Attribute")).hide_value().supports_field(); | b.add_input<decl::Vector>(N_("Attribute")).hide_value().supports_field(); | ||||
| b.add_input<decl::Float>(N_("Attribute"), "Attribute_001").hide_value().supports_field(); | b.add_input<decl::Float>(N_("Attribute"), "Attribute_001").hide_value().supports_field(); | ||||
| b.add_input<decl::Color>(N_("Attribute"), "Attribute_002").hide_value().supports_field(); | b.add_input<decl::Color>(N_("Attribute"), "Attribute_002").hide_value().supports_field(); | ||||
| b.add_input<decl::Bool>(N_("Attribute"), "Attribute_003").hide_value().supports_field(); | b.add_input<decl::Bool>(N_("Attribute"), "Attribute_003").hide_value().supports_field(); | ||||
| b.add_input<decl::Int>(N_("Attribute"), "Attribute_004").hide_value().supports_field(); | b.add_input<decl::Int>(N_("Attribute"), "Attribute_004").hide_value().supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Source Position")).implicit_field(); | b.add_input<decl::Vector>(N_("Source Position")).implicit_field(); | ||||
| b.add_input<decl::Int>(N_("Index")).implicit_field(); | b.add_input<decl::Int>(N_("Index")).implicit_field(); | ||||
| b.add_output<decl::Vector>(N_("Attribute")).dependent_field({6, 7}); | b.add_output<decl::Vector>(N_("Attribute")).dependent_field({6, 7}); | ||||
| b.add_output<decl::Float>(N_("Attribute"), "Attribute_001").dependent_field({6, 7}); | b.add_output<decl::Float>(N_("Attribute"), "Attribute_001").dependent_field({6, 7}); | ||||
| b.add_output<decl::Color>(N_("Attribute"), "Attribute_002").dependent_field({6, 7}); | b.add_output<decl::Color>(N_("Attribute"), "Attribute_002").dependent_field({6, 7}); | ||||
| b.add_output<decl::Bool>(N_("Attribute"), "Attribute_003").dependent_field({6, 7}); | b.add_output<decl::Bool>(N_("Attribute"), "Attribute_003").dependent_field({6, 7}); | ||||
| b.add_output<decl::Int>(N_("Attribute"), "Attribute_004").dependent_field({6, 7}); | b.add_output<decl::Int>(N_("Attribute"), "Attribute_004").dependent_field({6, 7}); | ||||
| } | } | ||||
| static void geo_node_transfer_attribute_layout(uiLayout *layout, | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| bContext *UNUSED(C), | |||||
| PointerRNA *ptr) | |||||
| { | { | ||||
| const bNode &node = *static_cast<const bNode *>(ptr->data); | const bNode &node = *static_cast<const bNode *>(ptr->data); | ||||
| const NodeGeometryTransferAttribute &data = *static_cast<const NodeGeometryTransferAttribute *>( | const NodeGeometryTransferAttribute &data = *static_cast<const NodeGeometryTransferAttribute *>( | ||||
| node.storage); | node.storage); | ||||
| const GeometryNodeAttributeTransferMode mapping = (GeometryNodeAttributeTransferMode)data.mode; | const GeometryNodeAttributeTransferMode mapping = (GeometryNodeAttributeTransferMode)data.mode; | ||||
| uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); | uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); | ||||
| uiItemR(layout, ptr, "mapping", 0, "", ICON_NONE); | uiItemR(layout, ptr, "mapping", 0, "", ICON_NONE); | ||||
| if (mapping != GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED) { | if (mapping != GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED) { | ||||
| uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); | uiItemR(layout, ptr, "domain", 0, "", ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| static void geo_node_transfer_attribute_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryTransferAttribute *data = (NodeGeometryTransferAttribute *)MEM_callocN( | NodeGeometryTransferAttribute *data = (NodeGeometryTransferAttribute *)MEM_callocN( | ||||
| sizeof(NodeGeometryTransferAttribute), __func__); | sizeof(NodeGeometryTransferAttribute), __func__); | ||||
| data->data_type = CD_PROP_FLOAT; | data->data_type = CD_PROP_FLOAT; | ||||
| data->mode = GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED; | data->mode = GEO_NODE_ATTRIBUTE_TRANSFER_NEAREST_FACE_INTERPOLATED; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| static void geo_node_transfer_attribute_update(bNodeTree *ntree, bNode *node) | static void node_update(bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| const NodeGeometryTransferAttribute &data = *(const NodeGeometryTransferAttribute *) | const NodeGeometryTransferAttribute &data = *(const NodeGeometryTransferAttribute *) | ||||
| node->storage; | node->storage; | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | ||||
| const GeometryNodeAttributeTransferMode mapping = (GeometryNodeAttributeTransferMode)data.mode; | const GeometryNodeAttributeTransferMode mapping = (GeometryNodeAttributeTransferMode)data.mode; | ||||
| bNodeSocket *socket_geometry = (bNodeSocket *)node->inputs.first; | bNodeSocket *socket_geometry = (bNodeSocket *)node->inputs.first; | ||||
| bNodeSocket *socket_vector = socket_geometry->next; | bNodeSocket *socket_vector = socket_geometry->next; | ||||
| ▲ Show 20 Lines • Show All 618 Lines • ▼ Show 20 Lines | case CD_PROP_INT32: { | ||||
| params.set_output("Attribute_004", Field<int>(field)); | params.set_output("Attribute_004", Field<int>(field)); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void geo_node_transfer_attribute_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry = params.extract_input<GeometrySet>("Target"); | GeometrySet geometry = params.extract_input<GeometrySet>("Target"); | ||||
| const bNode &node = params.node(); | const bNode &node = params.node(); | ||||
| const NodeGeometryTransferAttribute &data = *(const NodeGeometryTransferAttribute *)node.storage; | const NodeGeometryTransferAttribute &data = *(const NodeGeometryTransferAttribute *)node.storage; | ||||
| const GeometryNodeAttributeTransferMode mapping = (GeometryNodeAttributeTransferMode)data.mode; | const GeometryNodeAttributeTransferMode mapping = (GeometryNodeAttributeTransferMode)data.mode; | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | ||||
| const AttributeDomain domain = static_cast<AttributeDomain>(data.domain); | const AttributeDomain domain = static_cast<AttributeDomain>(data.domain); | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| void register_node_type_geo_transfer_attribute() | void register_node_type_geo_transfer_attribute() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_transfer_attribute_cc; | namespace file_ns = blender::nodes::node_geo_transfer_attribute_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_TRANSFER_ATTRIBUTE, "Transfer Attribute", NODE_CLASS_ATTRIBUTE, 0); | &ntype, GEO_NODE_TRANSFER_ATTRIBUTE, "Transfer Attribute", NODE_CLASS_ATTRIBUTE, 0); | ||||
| node_type_init(&ntype, file_ns::geo_node_transfer_attribute_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_update(&ntype, file_ns::geo_node_transfer_attribute_update); | node_type_update(&ntype, file_ns::node_update); | ||||
| node_type_storage(&ntype, | node_type_storage(&ntype, | ||||
| "NodeGeometryTransferAttribute", | "NodeGeometryTransferAttribute", | ||||
| node_free_standard_storage, | node_free_standard_storage, | ||||
| node_copy_standard_storage); | node_copy_standard_storage); | ||||
| ntype.declare = file_ns::geo_node_transfer_attribute_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = file_ns::geo_node_transfer_attribute_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.draw_buttons = file_ns::geo_node_transfer_attribute_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||