25 if (
node !=
nullptr) {
31 b.add_input<
decl::Vector>(
"Max"_ustr).default_value({1.0f, 1.0f, 1.0f});
35 b.add_input<
decl::Float>(
"Max"_ustr).default_value(1.0f);
39 b.add_input<
decl::Int>(
"Max"_ustr).default_value(100);
54 const bool is_compositor =
b.tree_or_null() &&
b.tree_or_null()->type ==
NTREE_COMPOSIT;
64 b.add_output(data_type,
"Value"_ustr);
82 switch (socket.
type) {
108 node_storage(
node).data_type = *type;
113 node_storage(
node).data_type = *type;
128 node_storage(
node).data_type = *type;
141 static auto fn = mf::build::SI4_SO<float3, float3, int, int, float3>(
147 return float3(
x,
y,
z) * (max_value - min_value) + min_value;
149 mf::build::exec_presets::SomeSpanOrSingle<2>());
154 static auto fn = mf::build::SI4_SO<float, float, int, int, float>(
156 [](
float min_value,
float max_value,
int id,
int seed) ->
float {
158 return value * (max_value - min_value) + min_value;
160 mf::build::exec_presets::SomeSpanOrSingle<2>());
165 static auto fn = mf::build::SI4_SO<int, int, int, int, int>(
167 [](
int min_value,
int max_value,
int id,
int seed) ->
int {
168 if (min_value > max_value) {
169 std::swap(min_value, max_value);
180 return int(
uint32_t(min_value) + modulo_result);
182 mf::build::exec_presets::SomeSpanOrSingle<2>());
187 static auto fn = mf::build::SI3_SO<float, int, int, bool>(
189 [](
float probability,
int id,
int seed) ->
bool {
192 mf::build::exec_presets::SomeSpanOrSingle<1>());
207 return "random_value_vector";
209 return "random_value_float";
211 return "random_value_int";
213 return "random_value_bool";
231 if (name ==
nullptr) {
243 ntype.
ui_name =
"Random Value";
#define NODE_CLASS_CONVERTER
#define NODE_STORAGE_FUNCS(StorageT)
#define FN_NODE_RANDOM_VALUE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define BLI_assert_unreachable()
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeSocket & other_socket() const
eNodeSocketInOut in_out() const
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
bNode & add_node(UString idname)
void set_matching_fn(const mf::MultiFunction *fn)
StructureType structure_type
#define storage(slot, qualifiers)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
static void node_register()
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static const char * gpu_shader_get_name(const eCustomDataType data_type)
static void node_declare(NodeDeclarationBuilder &b)
static void node_gather_link_search_ops(GatherLinkSearchOpParams ¶ms)
static void fn_node_random_value_init(bNodeTree *, bNode *node)
static std::optional< eCustomDataType > node_type_from_other_socket(const bNodeSocket &socket)
static int node_gpu_material(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
uint32_t hash(uint32_t kx)
float hash_to_float(uint32_t kx)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
void fn_cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
BMesh const char void * data
@ NODE_DEFAULT_INPUT_ID_INDEX_FIELD
@ NODE_DEFAULT_INPUT_VALUE
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
VecBase< float, 3 > float3
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)