Differential D13361 Diff 45286 source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_align_rotation_to_vector.cc
- This file was moved from source/blender/nodes/geometry/nodes/legacy/node_geo_align_rotation_to_vector.cc.
| Show All 16 Lines | |||||
| #include "BLI_math_rotation.h" | #include "BLI_math_rotation.h" | ||||
| #include "BLI_task.hh" | #include "BLI_task.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_legacy_align_rotation_to_vector_cc { | ||||
| static void geo_node_align_rotation_to_vector_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::String>(N_("Factor")); | b.add_input<decl::String>(N_("Factor")); | ||||
| b.add_input<decl::Float>(N_("Factor"), "Factor_001") | b.add_input<decl::Float>(N_("Factor"), "Factor_001") | ||||
| .default_value(1.0f) | .default_value(1.0f) | ||||
| .min(0.0f) | .min(0.0f) | ||||
| .max(1.0f) | .max(1.0f) | ||||
| .subtype(PROP_FACTOR); | .subtype(PROP_FACTOR); | ||||
| b.add_input<decl::String>(N_("Vector")); | b.add_input<decl::String>(N_("Vector")); | ||||
| b.add_input<decl::Vector>(N_("Vector"), "Vector_001") | b.add_input<decl::Vector>(N_("Vector"), "Vector_001") | ||||
| .default_value({0.0, 0.0, 1.0}) | .default_value({0.0, 0.0, 1.0}) | ||||
| .subtype(PROP_ANGLE); | .subtype(PROP_ANGLE); | ||||
| b.add_output<decl::Geometry>(N_("Geometry")); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| static void geo_node_align_rotation_to_vector_layout(uiLayout *layout, | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| bContext *UNUSED(C), | |||||
| PointerRNA *ptr) | |||||
| { | { | ||||
| uiItemR(layout, ptr, "axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | uiItemR(layout, ptr, "axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| uiLayoutSetPropDecorate(layout, false); | uiLayoutSetPropDecorate(layout, false); | ||||
| uiItemR(layout, ptr, "pivot_axis", 0, IFACE_("Pivot"), ICON_NONE); | uiItemR(layout, ptr, "pivot_axis", 0, IFACE_("Pivot"), ICON_NONE); | ||||
| uiLayout *col = uiLayoutColumn(layout, false); | uiLayout *col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, ptr, "input_type_factor", 0, IFACE_("Factor"), ICON_NONE); | uiItemR(col, ptr, "input_type_factor", 0, IFACE_("Factor"), ICON_NONE); | ||||
| uiItemR(col, ptr, "input_type_vector", 0, IFACE_("Vector"), ICON_NONE); | uiItemR(col, ptr, "input_type_vector", 0, IFACE_("Vector"), ICON_NONE); | ||||
| } | } | ||||
| static void geo_node_align_rotation_to_vector_init(bNodeTree *UNUSED(ntree), bNode *node) | static void node_init(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *) | NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *) | ||||
| MEM_callocN(sizeof(NodeGeometryAlignRotationToVector), __func__); | MEM_callocN(sizeof(NodeGeometryAlignRotationToVector), __func__); | ||||
| node_storage->axis = GEO_NODE_ALIGN_ROTATION_TO_VECTOR_AXIS_X; | node_storage->axis = GEO_NODE_ALIGN_ROTATION_TO_VECTOR_AXIS_X; | ||||
| node_storage->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT_FLOAT; | node_storage->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT_FLOAT; | ||||
| node_storage->input_type_vector = GEO_NODE_ATTRIBUTE_INPUT_VECTOR; | node_storage->input_type_vector = GEO_NODE_ATTRIBUTE_INPUT_VECTOR; | ||||
| node->storage = node_storage; | node->storage = node_storage; | ||||
| } | } | ||||
| static void geo_node_align_rotation_to_vector_update(bNodeTree *ntree, bNode *node) | static void node_update(bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *) | NodeGeometryAlignRotationToVector *node_storage = (NodeGeometryAlignRotationToVector *) | ||||
| node->storage; | node->storage; | ||||
| update_attribute_input_socket_availabilities( | update_attribute_input_socket_availabilities( | ||||
| *ntree, *node, "Factor", (GeometryNodeAttributeInputMode)node_storage->input_type_factor); | *ntree, *node, "Factor", (GeometryNodeAttributeInputMode)node_storage->input_type_factor); | ||||
| update_attribute_input_socket_availabilities( | update_attribute_input_socket_availabilities( | ||||
| *ntree, *node, "Vector", (GeometryNodeAttributeInputMode)node_storage->input_type_vector); | *ntree, *node, "Vector", (GeometryNodeAttributeInputMode)node_storage->input_type_vector); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | else { | ||||
| local_pivot_axis[storage.pivot_axis - 1] = 1; | local_pivot_axis[storage.pivot_axis - 1] = 1; | ||||
| align_rotations_fixed_pivot( | align_rotations_fixed_pivot( | ||||
| vectors, factors, local_main_axis, local_pivot_axis, rotations.as_span()); | vectors, factors, local_main_axis, local_pivot_axis, rotations.as_span()); | ||||
| } | } | ||||
| rotations.save(); | rotations.save(); | ||||
| } | } | ||||
| static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| geometry_set = geometry_set_realize_instances(geometry_set); | geometry_set = geometry_set_realize_instances(geometry_set); | ||||
| if (geometry_set.has<MeshComponent>()) { | if (geometry_set.has<MeshComponent>()) { | ||||
| align_rotations_on_component(geometry_set.get_component_for_write<MeshComponent>(), params); | align_rotations_on_component(geometry_set.get_component_for_write<MeshComponent>(), params); | ||||
| } | } | ||||
| if (geometry_set.has<PointCloudComponent>()) { | if (geometry_set.has<PointCloudComponent>()) { | ||||
| align_rotations_on_component(geometry_set.get_component_for_write<PointCloudComponent>(), | align_rotations_on_component(geometry_set.get_component_for_write<PointCloudComponent>(), | ||||
| params); | params); | ||||
| } | } | ||||
| if (geometry_set.has<CurveComponent>()) { | if (geometry_set.has<CurveComponent>()) { | ||||
| align_rotations_on_component(geometry_set.get_component_for_write<CurveComponent>(), params); | align_rotations_on_component(geometry_set.get_component_for_write<CurveComponent>(), params); | ||||
| } | } | ||||
| params.set_output("Geometry", geometry_set); | params.set_output("Geometry", geometry_set); | ||||
| } | } | ||||
| } // namespace blender::nodes | } // namespace blender::nodes::node_geo_legacy_align_rotation_to_vector_cc | ||||
| void register_node_type_geo_align_rotation_to_vector() | void register_node_type_geo_align_rotation_to_vector() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_legacy_align_rotation_to_vector_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, | geo_node_type_base(&ntype, | ||||
| GEO_NODE_LEGACY_ALIGN_ROTATION_TO_VECTOR, | GEO_NODE_LEGACY_ALIGN_ROTATION_TO_VECTOR, | ||||
| "Align Rotation to Vector", | "Align Rotation to Vector", | ||||
| NODE_CLASS_GEOMETRY, | NODE_CLASS_GEOMETRY, | ||||
| 0); | 0); | ||||
| node_type_init(&ntype, blender::nodes::geo_node_align_rotation_to_vector_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_update(&ntype, blender::nodes::geo_node_align_rotation_to_vector_update); | node_type_update(&ntype, file_ns::node_update); | ||||
| node_type_storage(&ntype, | node_type_storage(&ntype, | ||||
| "NodeGeometryAlignRotationToVector", | "NodeGeometryAlignRotationToVector", | ||||
| node_free_standard_storage, | node_free_standard_storage, | ||||
| node_copy_standard_storage); | node_copy_standard_storage); | ||||
| ntype.declare = blender::nodes::geo_node_align_rotation_to_vector_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = blender::nodes::geo_node_align_rotation_to_vector_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.draw_buttons = blender::nodes::geo_node_align_rotation_to_vector_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||