Differential D13361 Diff 45286 source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_attribute_color_ramp.cc
- This file was moved from source/blender/nodes/geometry/nodes/legacy/node_geo_attribute_color_ramp.cc.
| Show All 17 Lines | |||||
| #include "BKE_colorband.h" | #include "BKE_colorband.h" | ||||
| #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_attributes_color_ramp_cc { | ||||
| static void geo_node_attribute_color_ramp_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_output<decl::Geometry>(N_("Geometry")); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| static void geo_node_attribute_color_ramp_layout(uiLayout *layout, | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| bContext *UNUSED(C), | |||||
| PointerRNA *ptr) | |||||
| { | { | ||||
| uiTemplateColorRamp(layout, ptr, "color_ramp", false); | uiTemplateColorRamp(layout, ptr, "color_ramp", false); | ||||
| } | } | ||||
| static void geo_node_attribute_color_ramp_init(bNodeTree *UNUSED(ntree), bNode *node) | static void node_init(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| NodeAttributeColorRamp *node_storage = (NodeAttributeColorRamp *)MEM_callocN( | NodeAttributeColorRamp *node_storage = (NodeAttributeColorRamp *)MEM_callocN( | ||||
| sizeof(NodeAttributeColorRamp), __func__); | sizeof(NodeAttributeColorRamp), __func__); | ||||
| BKE_colorband_init(&node_storage->color_ramp, true); | BKE_colorband_init(&node_storage->color_ramp, true); | ||||
| node->storage = node_storage; | node->storage = node_storage; | ||||
| } | } | ||||
| static AttributeDomain get_result_domain(const GeometryComponent &component, | static AttributeDomain get_result_domain(const GeometryComponent &component, | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | threading::parallel_for(IndexRange(attribute_in.size()), 512, [&](IndexRange range) { | ||||
| for (const int i : range) { | for (const int i : range) { | ||||
| BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]); | BKE_colorband_evaluate(color_ramp, attribute_in[i], results[i]); | ||||
| } | } | ||||
| }); | }); | ||||
| attribute_result.save(); | attribute_result.save(); | ||||
| } | } | ||||
| static void geo_node_attribute_color_ramp_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>()) { | ||||
| execute_on_component(params, geometry_set.get_component_for_write<MeshComponent>()); | execute_on_component(params, geometry_set.get_component_for_write<MeshComponent>()); | ||||
| } | } | ||||
| if (geometry_set.has<PointCloudComponent>()) { | if (geometry_set.has<PointCloudComponent>()) { | ||||
| execute_on_component(params, geometry_set.get_component_for_write<PointCloudComponent>()); | execute_on_component(params, geometry_set.get_component_for_write<PointCloudComponent>()); | ||||
| } | } | ||||
| if (geometry_set.has<CurveComponent>()) { | if (geometry_set.has<CurveComponent>()) { | ||||
| execute_on_component(params, geometry_set.get_component_for_write<CurveComponent>()); | execute_on_component(params, geometry_set.get_component_for_write<CurveComponent>()); | ||||
| } | } | ||||
| params.set_output("Geometry", std::move(geometry_set)); | params.set_output("Geometry", std::move(geometry_set)); | ||||
| } | } | ||||
| } // namespace blender::nodes | } // namespace blender::nodes::node_geo_legacy_attributes_color_ramp_cc | ||||
| void register_node_type_geo_attribute_color_ramp() | void register_node_type_geo_attribute_color_ramp() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_legacy_attributes_color_ramp_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, | geo_node_type_base(&ntype, | ||||
| GEO_NODE_LEGACY_ATTRIBUTE_COLOR_RAMP, | GEO_NODE_LEGACY_ATTRIBUTE_COLOR_RAMP, | ||||
| "Attribute Color Ramp", | "Attribute Color Ramp", | ||||
| NODE_CLASS_ATTRIBUTE, | NODE_CLASS_ATTRIBUTE, | ||||
| 0); | 0); | ||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeAttributeColorRamp", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeAttributeColorRamp", node_free_standard_storage, node_copy_standard_storage); | ||||
| node_type_init(&ntype, blender::nodes::geo_node_attribute_color_ramp_init); | node_type_init(&ntype, file_ns::node_init); | ||||
| node_type_size_preset(&ntype, NODE_SIZE_LARGE); | node_type_size_preset(&ntype, NODE_SIZE_LARGE); | ||||
| ntype.declare = blender::nodes::geo_node_attribute_color_ramp_declare; | ntype.declare = file_ns::node_declare; | ||||
| ntype.geometry_node_execute = blender::nodes::geo_node_attribute_color_ramp_exec; | ntype.geometry_node_execute = file_ns::node_geo_exec; | ||||
| ntype.draw_buttons = blender::nodes::geo_node_attribute_color_ramp_layout; | ntype.draw_buttons = file_ns::node_layout; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||