Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/function/nodes/node_fn_random_value.cc
| Show All 18 Lines | |||||
| #include "node_function_util.hh" | #include "node_function_util.hh" | ||||
| #include "NOD_socket_search_link.hh" | #include "NOD_socket_search_link.hh" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| namespace blender::nodes { | namespace blender::nodes::node_fn_random_value_cc { | ||||
| NODE_STORAGE_FUNCS(NodeRandomValue) | NODE_STORAGE_FUNCS(NodeRandomValue) | ||||
| static void fn_node_random_value_declare(NodeDeclarationBuilder &b) | static void fn_node_random_value_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Vector>(N_("Min")).supports_field(); | b.add_input<decl::Vector>(N_("Min")).supports_field(); | ||||
| b.add_input<decl::Vector>(N_("Max")).default_value({1.0f, 1.0f, 1.0f}).supports_field(); | b.add_input<decl::Vector>(N_("Max")).default_value({1.0f, 1.0f, 1.0f}).supports_field(); | ||||
| b.add_input<decl::Float>(N_("Min"), "Min_001").supports_field(); | b.add_input<decl::Float>(N_("Min"), "Min_001").supports_field(); | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | static std::optional<CustomDataType> node_type_from_other_socket(const bNodeSocket &socket) | ||||
| switch (socket.type) { | switch (socket.type) { | ||||
| case SOCK_FLOAT: | case SOCK_FLOAT: | ||||
| return CD_PROP_FLOAT; | return CD_PROP_FLOAT; | ||||
| case SOCK_BOOLEAN: | case SOCK_BOOLEAN: | ||||
| return CD_PROP_BOOL; | return CD_PROP_BOOL; | ||||
| case SOCK_INT: | case SOCK_INT: | ||||
| return CD_PROP_INT32; | return CD_PROP_INT32; | ||||
| case SOCK_VECTOR: | case SOCK_VECTOR: | ||||
| return CD_PROP_FLOAT3; | |||||
| case SOCK_RGBA: | case SOCK_RGBA: | ||||
| return CD_PROP_COLOR; | return CD_PROP_FLOAT3; | ||||
| default: | default: | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| } | } | ||||
| static void fn_node_random_value_gather_link_search(GatherLinkSearchOpParams ¶ms) | static void fn_node_random_value_gather_link_search(GatherLinkSearchOpParams ¶ms) | ||||
| { | { | ||||
| const NodeDeclaration &declaration = *params.node_type().fixed_declaration; | const NodeDeclaration &declaration = *params.node_type().fixed_declaration; | ||||
| ▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | switch (data_type) { | ||||
| } | } | ||||
| default: { | default: { | ||||
| BLI_assert_unreachable(); | BLI_assert_unreachable(); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // namespace blender::nodes | } // namespace blender::nodes::node_fn_random_value_cc | ||||
| void register_node_type_fn_random_value() | void register_node_type_fn_random_value() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_fn_random_value_cc; | |||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| fn_node_type_base(&ntype, FN_NODE_RANDOM_VALUE, "Random Value", NODE_CLASS_CONVERTER, 0); | |||||
| node_type_init(&ntype, blender::nodes::fn_node_random_value_init); | fn_node_type_base(&ntype, FN_NODE_RANDOM_VALUE, "Random Value", NODE_CLASS_CONVERTER); | ||||
| node_type_update(&ntype, blender::nodes::fn_node_random_value_update); | node_type_init(&ntype, file_ns::fn_node_random_value_init); | ||||
| ntype.draw_buttons = blender::nodes::fn_node_random_value_layout; | node_type_update(&ntype, file_ns::fn_node_random_value_update); | ||||
| ntype.declare = blender::nodes::fn_node_random_value_declare; | ntype.draw_buttons = file_ns::fn_node_random_value_layout; | ||||
| ntype.build_multi_function = blender::nodes::fn_node_random_value_build_multi_function; | ntype.declare = file_ns::fn_node_random_value_declare; | ||||
| ntype.gather_link_search_ops = blender::nodes::fn_node_random_value_gather_link_search; | ntype.build_multi_function = file_ns::fn_node_random_value_build_multi_function; | ||||
| ntype.gather_link_search_ops = file_ns::fn_node_random_value_gather_link_search; | |||||
| node_type_storage( | node_type_storage( | ||||
| &ntype, "NodeRandomValue", node_free_standard_storage, node_copy_standard_storage); | &ntype, "NodeRandomValue", node_free_standard_storage, node_copy_standard_storage); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||