Differential D13361 Diff 45286 source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_clamp.cc
- This file was moved from source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_clamp.cc.
| Show All 14 Lines | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| #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_attribute_clamp_cc { | ||||
| static void geo_node_attribute_clamp_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_("Attribute")); | b.add_input<decl::String>(N_("Attribute")); | ||||
| b.add_input<decl::String>(N_("Result")); | b.add_input<decl::String>(N_("Result")); | ||||
| b.add_input<decl::Vector>(N_("Min")); | b.add_input<decl::Vector>(N_("Min")); | ||||
| b.add_input<decl::Vector>(N_("Max")).default_value({1.0f, 1.0f, 1.0f}); | b.add_input<decl::Vector>(N_("Max")).default_value({1.0f, 1.0f, 1.0f}); | ||||
| b.add_input<decl::Float>(N_("Min"), "Min_001"); | b.add_input<decl::Float>(N_("Min"), "Min_001"); | ||||
| b.add_input<decl::Float>(N_("Max"), "Max_001").default_value(1.0f); | b.add_input<decl::Float>(N_("Max"), "Max_001").default_value(1.0f); | ||||
| b.add_input<decl::Int>(N_("Min"), "Min_002").min(-100000).max(100000); | b.add_input<decl::Int>(N_("Min"), "Min_002").min(-100000).max(100000); | ||||
| b.add_input<decl::Int>(N_("Max"), "Max_002").default_value(100).min(-100000).max(100000); | b.add_input<decl::Int>(N_("Max"), "Max_002").default_value(100).min(-100000).max(100000); | ||||
| b.add_input<decl::Color>(N_("Min"), "Min_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); | b.add_input<decl::Color>(N_("Min"), "Min_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); | ||||
| b.add_input<decl::Color>(N_("Max"), "Max_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); | b.add_input<decl::Color>(N_("Max"), "Max_003").default_value({0.5f, 0.5f, 0.5f, 1.0f}); | ||||
| b.add_output<decl::Geometry>(N_("Geometry")); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| static void geo_node_attribute_clamp_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, "operation", 0, "", ICON_NONE); | uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); | ||||
| } | } | ||||
| static void geo_node_attribute_clamp_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| { | { | ||||
| NodeAttributeClamp *data = (NodeAttributeClamp *)MEM_callocN(sizeof(NodeAttributeClamp), | NodeAttributeClamp *data = (NodeAttributeClamp *)MEM_callocN(sizeof(NodeAttributeClamp), | ||||
| __func__); | __func__); | ||||
| data->data_type = CD_PROP_FLOAT; | data->data_type = CD_PROP_FLOAT; | ||||
| data->operation = NODE_CLAMP_MINMAX; | data->operation = NODE_CLAMP_MINMAX; | ||||
| node->storage = data; | node->storage = data; | ||||
| } | } | ||||
| static void geo_node_attribute_clamp_update(bNodeTree *ntree, bNode *node) | static void node_update(bNodeTree *ntree, bNode *node) | ||||
| { | { | ||||
| bNodeSocket *sock_min_vector = (bNodeSocket *)BLI_findlink(&node->inputs, 3); | bNodeSocket *sock_min_vector = (bNodeSocket *)BLI_findlink(&node->inputs, 3); | ||||
| bNodeSocket *sock_max_vector = sock_min_vector->next; | bNodeSocket *sock_max_vector = sock_min_vector->next; | ||||
| bNodeSocket *sock_min_float = sock_max_vector->next; | bNodeSocket *sock_min_float = sock_max_vector->next; | ||||
| bNodeSocket *sock_max_float = sock_min_float->next; | bNodeSocket *sock_max_float = sock_min_float->next; | ||||
| bNodeSocket *sock_min_int = sock_max_float->next; | bNodeSocket *sock_min_int = sock_max_float->next; | ||||
| bNodeSocket *sock_max_int = sock_min_int->next; | bNodeSocket *sock_max_int = sock_min_int->next; | ||||
| bNodeSocket *sock_min_color = sock_max_int->next; | bNodeSocket *sock_min_color = sock_max_int->next; | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | default: { | ||||
| BLI_assert(false); | BLI_assert(false); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| attribute_result.save(); | attribute_result.save(); | ||||
| } | } | ||||
| static void geo_node_attribute_clamp_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>()) { | ||||
| clamp_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); | clamp_attribute(geometry_set.get_component_for_write<MeshComponent>(), params); | ||||
| } | } | ||||
| if (geometry_set.has<PointCloudComponent>()) { | if (geometry_set.has<PointCloudComponent>()) { | ||||
| clamp_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); | clamp_attribute(geometry_set.get_component_for_write<PointCloudComponent>(), params); | ||||
| } | } | ||||
| if (geometry_set.has<CurveComponent>()) { | if (geometry_set.has<CurveComponent>()) { | ||||
| clamp_attribute(geometry_set.get_component_for_write<CurveComponent>(), params); | clamp_attribute(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_attribute_clamp_cc | ||||
| void register_node_type_geo_attribute_clamp() | void register_node_type_geo_attribute_clamp() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_legacy_attribute_clamp_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base( | geo_node_type_base( | ||||
| &ntype, GEO_NODE_LEGACY_ATTRIBUTE_CLAMP, "Attribute Clamp", NODE_CLASS_ATTRIBUTE, 0); | &ntype, GEO_NODE_LEGACY_ATTRIBUTE_CLAMP, "Attribute Clamp", NODE_CLASS_ATTRIBUTE, 0); | ||||
| node_type_init(&ntype, blender::nodes::geo_node_attribute_clamp_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_update(&ntype, blender::nodes::geo_node_attribute_clamp_update); | node_type_update(&ntype, file_ns::node_update); | ||||
| ntype.declare = blender::nodes::geo_node_attribute_clamp_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = blender::nodes::geo_node_attribute_clamp_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.draw_buttons = blender::nodes::geo_node_attribute_clamp_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeAttributeClamp", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeAttributeClamp", node_free_standard_storage, node_copy_standard_storage); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||