Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_object_info.cc
| Show All 17 Lines | |||||
| #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::node_geo_object_info_cc { | namespace blender::nodes::node_geo_object_info_cc { | ||||
| static void geo_node_object_info_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Object>(N_("Object")).hide_label(); | b.add_input<decl::Object>(N_("Object")).hide_label(); | ||||
| b.add_input<decl::Bool>(N_("As Instance")) | b.add_input<decl::Bool>(N_("As Instance")) | ||||
| .description(N_("Output the entire object as single instance. " | .description(N_("Output the entire object as single instance. " | ||||
| "This allows instancing non-geometry object types")); | "This allows instancing non-geometry object types")); | ||||
| b.add_output<decl::Vector>(N_("Location")); | b.add_output<decl::Vector>(N_("Location")); | ||||
| b.add_output<decl::Vector>(N_("Rotation")); | b.add_output<decl::Vector>(N_("Rotation")); | ||||
| b.add_output<decl::Vector>(N_("Scale")); | b.add_output<decl::Vector>(N_("Scale")); | ||||
| b.add_output<decl::Geometry>(N_("Geometry")); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| static void geo_node_object_info_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "transform_space", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | uiItemR(layout, ptr, "transform_space", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| } | } | ||||
| static void geo_node_object_info_exec(GeoNodeExecParams params) | static void node_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const bNode &bnode = params.node(); | const bNode &bnode = params.node(); | ||||
| NodeGeometryObjectInfo *node_storage = (NodeGeometryObjectInfo *)bnode.storage; | NodeGeometryObjectInfo *node_storage = (NodeGeometryObjectInfo *)bnode.storage; | ||||
| const bool transform_space_relative = (node_storage->transform_space == | const bool transform_space_relative = (node_storage->transform_space == | ||||
| GEO_NODE_TRANSFORM_SPACE_RELATIVE); | GEO_NODE_TRANSFORM_SPACE_RELATIVE); | ||||
| auto default_transform = [&]() { | auto default_transform = [&]() { | ||||
| params.set_output("Location", float3(0)); | params.set_output("Location", float3(0)); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | else { | ||||
| transform_geometry_set(geometry_set, transform, *params.depsgraph()); | transform_geometry_set(geometry_set, transform, *params.depsgraph()); | ||||
| } | } | ||||
| } | } | ||||
| params.set_output("Geometry", geometry_set); | params.set_output("Geometry", geometry_set); | ||||
| } | } | ||||
| } | } | ||||
| static void geo_node_object_info_node_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryObjectInfo *data = (NodeGeometryObjectInfo *)MEM_callocN( | NodeGeometryObjectInfo *data = (NodeGeometryObjectInfo *)MEM_callocN( | ||||
| sizeof(NodeGeometryObjectInfo), __func__); | sizeof(NodeGeometryObjectInfo), __func__); | ||||
| data->transform_space = GEO_NODE_TRANSFORM_SPACE_ORIGINAL; | data->transform_space = GEO_NODE_TRANSFORM_SPACE_ORIGINAL; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_object_info_cc | } // namespace blender::nodes::node_geo_object_info_cc | ||||
| void register_node_type_geo_object_info() | void register_node_type_geo_object_info() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_object_info_cc; | namespace file_ns = blender::nodes::node_geo_object_info_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT, 0); | geo_node_type_base(&ntype, GEO_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT, 0); | ||||
| node_type_init(&ntype, file_ns::geo_node_object_info_node_init); | node_type_init(&ntype, file_ns::node_node_init); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeGeometryObjectInfo", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeGeometryObjectInfo", node_free_standard_storage, node_copy_standard_storage); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_object_info_exec; | ntype.geometry_node_execute = file_ns::node_exec; | ||||
| ntype.draw_buttons = file_ns::geo_node_object_info_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| ntype.declare = file_ns::geo_node_object_info_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||