Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_raycast.cc
| Show All 23 Lines | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_raycast_cc { | namespace blender::nodes::node_geo_raycast_cc { | ||||
| using namespace blender::bke::mesh_surface_sample; | using namespace blender::bke::mesh_surface_sample; | ||||
| static void geo_node_raycast_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Target Geometry")) | b.add_input<decl::Geometry>(N_("Target Geometry")) | ||||
| .only_realized_data() | .only_realized_data() | ||||
| .supported_type(GEO_COMPONENT_TYPE_MESH); | .supported_type(GEO_COMPONENT_TYPE_MESH); | ||||
| 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(); | ||||
| Show All 17 Lines | static void node_declare(NodeDeclarationBuilder &b) | ||||
| b.add_output<decl::Vector>(N_("Attribute")).dependent_field({1, 2, 3, 4, 5, 6}); | b.add_output<decl::Vector>(N_("Attribute")).dependent_field({1, 2, 3, 4, 5, 6}); | ||||
| b.add_output<decl::Float>(N_("Attribute"), "Attribute_001").dependent_field({1, 2, 3, 4, 5, 6}); | b.add_output<decl::Float>(N_("Attribute"), "Attribute_001").dependent_field({1, 2, 3, 4, 5, 6}); | ||||
| b.add_output<decl::Color>(N_("Attribute"), "Attribute_002").dependent_field({1, 2, 3, 4, 5, 6}); | b.add_output<decl::Color>(N_("Attribute"), "Attribute_002").dependent_field({1, 2, 3, 4, 5, 6}); | ||||
| b.add_output<decl::Bool>(N_("Attribute"), "Attribute_003").dependent_field({1, 2, 3, 4, 5, 6}); | b.add_output<decl::Bool>(N_("Attribute"), "Attribute_003").dependent_field({1, 2, 3, 4, 5, 6}); | ||||
| b.add_output<decl::Int>(N_("Attribute"), "Attribute_004").dependent_field({1, 2, 3, 4, 5, 6}); | b.add_output<decl::Int>(N_("Attribute"), "Attribute_004").dependent_field({1, 2, 3, 4, 5, 6}); | ||||
| } | } | ||||
| static void geo_node_raycast_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| 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); | ||||
| } | } | ||||
| static void geo_node_raycast_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryRaycast *data = (NodeGeometryRaycast *)MEM_callocN(sizeof(NodeGeometryRaycast), | NodeGeometryRaycast *data = (NodeGeometryRaycast *)MEM_callocN(sizeof(NodeGeometryRaycast), | ||||
| __func__); | __func__); | ||||
| data->mapping = GEO_NODE_RAYCAST_INTERPOLATED; | data->mapping = GEO_NODE_RAYCAST_INTERPOLATED; | ||||
| data->data_type = CD_PROP_FLOAT; | data->data_type = CD_PROP_FLOAT; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| static void geo_node_raycast_update(bNodeTree *ntree, bNode *node) | static void node_update(bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| const NodeGeometryRaycast &data = *(const NodeGeometryRaycast *)node->storage; | const NodeGeometryRaycast &data = *(const NodeGeometryRaycast *)node->storage; | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | ||||
| bNodeSocket *socket_vector = (bNodeSocket *)BLI_findlink(&node->inputs, 1); | bNodeSocket *socket_vector = (bNodeSocket *)BLI_findlink(&node->inputs, 1); | ||||
| bNodeSocket *socket_float = socket_vector->next; | bNodeSocket *socket_float = socket_vector->next; | ||||
| bNodeSocket *socket_color4f = socket_float->next; | bNodeSocket *socket_color4f = socket_float->next; | ||||
| bNodeSocket *socket_boolean = socket_color4f->next; | bNodeSocket *socket_boolean = socket_color4f->next; | ||||
| ▲ Show 20 Lines • Show All 280 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_raycast_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet target = params.extract_input<GeometrySet>("Target Geometry"); | GeometrySet target = params.extract_input<GeometrySet>("Target Geometry"); | ||||
| const NodeGeometryRaycast &data = *(const NodeGeometryRaycast *)params.node().storage; | const NodeGeometryRaycast &data = *(const NodeGeometryRaycast *)params.node().storage; | ||||
| const GeometryNodeRaycastMapMode mapping = static_cast<GeometryNodeRaycastMapMode>(data.mapping); | const GeometryNodeRaycastMapMode mapping = static_cast<GeometryNodeRaycastMapMode>(data.mapping); | ||||
| const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | const CustomDataType data_type = static_cast<CustomDataType>(data.data_type); | ||||
| auto return_default = [&]() { | auto return_default = [&]() { | ||||
| params.set_output("Is Hit", fn::make_constant_field<bool>(false)); | params.set_output("Is Hit", fn::make_constant_field<bool>(false)); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| void register_node_type_geo_raycast() | void register_node_type_geo_raycast() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_raycast_cc; | namespace file_ns = blender::nodes::node_geo_raycast_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_RAYCAST, "Raycast", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_RAYCAST, "Raycast", NODE_CLASS_GEOMETRY, 0); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); | ||||
| node_type_init(&ntype, file_ns::geo_node_raycast_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_update(&ntype, file_ns::geo_node_raycast_update); | node_type_update(&ntype, file_ns::node_update); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeGeometryRaycast", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeGeometryRaycast", node_free_standard_storage, node_copy_standard_storage); | ||||
| ntype.declare = file_ns::geo_node_raycast_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = file_ns::geo_node_raycast_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.draw_buttons = file_ns::geo_node_raycast_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||