2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2007 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2007-04-04 13:58:12 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup nodes
|
2011-02-27 20:13:22 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-12-29 12:01:32 -05:00
|
|
|
#include <cctype>
|
|
|
|
|
#include <cstring>
|
2011-02-27 20:13:22 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "DNA_node_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
2013-11-12 18:17:58 +00:00
|
|
|
#include "BLI_string.h"
|
2023-05-13 17:38:48 +10:00
|
|
|
#include "BLI_string_utf8.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2024-02-09 18:59:42 +01:00
|
|
|
#include "BLT_translation.hh"
|
2012-03-17 14:42:44 +00:00
|
|
|
|
2023-12-21 10:10:53 +01:00
|
|
|
#include "BKE_colortools.hh"
|
2023-05-15 15:14:22 +02:00
|
|
|
#include "BKE_node.hh"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_node_tree_update.hh"
|
2007-04-04 13:58:12 +00:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
|
|
|
|
#include "RNA_enum_types.hh"
|
2024-07-10 18:30:02 +02:00
|
|
|
#include "RNA_prototypes.hh"
|
2011-02-08 12:54:32 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2023-05-03 14:21:14 +02:00
|
|
|
#include "node_util.hh"
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2020-11-06 16:14:43 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Storage Data
|
|
|
|
|
* \{ */
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2007-04-05 10:49:25 +00:00
|
|
|
void node_free_curves(bNode *node)
|
2007-04-04 13:58:12 +00:00
|
|
|
{
|
2022-10-11 18:01:08 -05:00
|
|
|
BKE_curvemapping_free(static_cast<CurveMapping *>(node->storage));
|
2007-04-04 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void node_free_standard_storage(bNode *node)
|
|
|
|
|
{
|
2012-05-21 08:10:37 +00:00
|
|
|
if (node->storage) {
|
|
|
|
|
MEM_freeN(node->storage);
|
|
|
|
|
}
|
2007-04-04 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void node_copy_curves(bNodeTree * /*dest_ntree*/, bNode *dest_node, const bNode *src_node)
|
2007-04-04 13:58:12 +00:00
|
|
|
{
|
2022-10-11 18:01:08 -05:00
|
|
|
dest_node->storage = BKE_curvemapping_copy(static_cast<CurveMapping *>(src_node->storage));
|
2007-04-04 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void node_copy_standard_storage(bNodeTree * /*dest_ntree*/,
|
2019-06-03 17:08:25 +02:00
|
|
|
bNode *dest_node,
|
|
|
|
|
const bNode *src_node)
|
2007-04-04 13:58:12 +00:00
|
|
|
{
|
2013-03-18 16:34:57 +00:00
|
|
|
dest_node->storage = MEM_dupallocN(src_node->storage);
|
2007-04-04 13:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void *node_initexec_curves(bNodeExecContext * /*context*/, bNode *node, bNodeInstanceKey /*key*/)
|
2012-08-29 07:58:36 +00:00
|
|
|
{
|
2022-10-11 18:01:08 -05:00
|
|
|
BKE_curvemapping_init(static_cast<CurveMapping *>(node->storage));
|
2022-11-19 11:51:42 +01:00
|
|
|
return nullptr; /* unused return */
|
2012-08-29 07:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
2020-11-06 16:14:43 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Updates
|
|
|
|
|
* \{ */
|
2020-02-11 15:31:40 +00:00
|
|
|
|
|
|
|
|
void node_sock_label(bNodeSocket *sock, const char *name)
|
|
|
|
|
{
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(sock->label, name);
|
2020-02-11 15:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-23 09:21:56 +00:00
|
|
|
void node_sock_label_clear(bNodeSocket *sock)
|
|
|
|
|
{
|
|
|
|
|
if (sock->label[0] != '\0') {
|
|
|
|
|
sock->label[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 11:10:46 +01:00
|
|
|
void node_math_update(bNodeTree *ntree, bNode *node)
|
2020-02-11 15:31:40 +00:00
|
|
|
{
|
2022-10-11 18:01:08 -05:00
|
|
|
bNodeSocket *sock1 = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 0));
|
|
|
|
|
bNodeSocket *sock2 = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 1));
|
|
|
|
|
bNodeSocket *sock3 = static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 2));
|
2025-02-19 13:44:11 +01:00
|
|
|
blender::bke::node_set_socket_availability(*ntree,
|
|
|
|
|
*sock2,
|
2024-08-19 20:27:37 +02:00
|
|
|
!ELEM(node->custom1,
|
|
|
|
|
NODE_MATH_SQRT,
|
|
|
|
|
NODE_MATH_SIGN,
|
|
|
|
|
NODE_MATH_CEIL,
|
|
|
|
|
NODE_MATH_SINE,
|
|
|
|
|
NODE_MATH_ROUND,
|
|
|
|
|
NODE_MATH_FLOOR,
|
|
|
|
|
NODE_MATH_COSINE,
|
|
|
|
|
NODE_MATH_ARCSINE,
|
|
|
|
|
NODE_MATH_TANGENT,
|
|
|
|
|
NODE_MATH_ABSOLUTE,
|
|
|
|
|
NODE_MATH_RADIANS,
|
|
|
|
|
NODE_MATH_DEGREES,
|
|
|
|
|
NODE_MATH_FRACTION,
|
|
|
|
|
NODE_MATH_ARCCOSINE,
|
|
|
|
|
NODE_MATH_ARCTANGENT) &&
|
|
|
|
|
!ELEM(node->custom1,
|
|
|
|
|
NODE_MATH_INV_SQRT,
|
|
|
|
|
NODE_MATH_TRUNC,
|
|
|
|
|
NODE_MATH_EXPONENT,
|
|
|
|
|
NODE_MATH_COSH,
|
|
|
|
|
NODE_MATH_SINH,
|
|
|
|
|
NODE_MATH_TANH));
|
2025-02-19 13:44:11 +01:00
|
|
|
blender::bke::node_set_socket_availability(*ntree,
|
|
|
|
|
*sock3,
|
2024-08-19 20:27:37 +02:00
|
|
|
ELEM(node->custom1,
|
|
|
|
|
NODE_MATH_COMPARE,
|
|
|
|
|
NODE_MATH_MULTIPLY_ADD,
|
|
|
|
|
NODE_MATH_WRAP,
|
|
|
|
|
NODE_MATH_SMOOTH_MIN,
|
|
|
|
|
NODE_MATH_SMOOTH_MAX));
|
2020-02-11 15:31:40 +00:00
|
|
|
|
2021-03-23 09:21:56 +00:00
|
|
|
node_sock_label_clear(sock1);
|
|
|
|
|
node_sock_label_clear(sock2);
|
|
|
|
|
node_sock_label_clear(sock3);
|
2020-02-11 15:31:40 +00:00
|
|
|
|
|
|
|
|
switch (node->custom1) {
|
|
|
|
|
case NODE_MATH_WRAP:
|
2021-05-12 11:15:56 +01:00
|
|
|
node_sock_label(sock2, "Max");
|
|
|
|
|
node_sock_label(sock3, "Min");
|
2020-02-11 15:31:40 +00:00
|
|
|
break;
|
|
|
|
|
case NODE_MATH_MULTIPLY_ADD:
|
|
|
|
|
node_sock_label(sock2, "Multiplier");
|
|
|
|
|
node_sock_label(sock3, "Addend");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_LESS_THAN:
|
|
|
|
|
case NODE_MATH_GREATER_THAN:
|
|
|
|
|
node_sock_label(sock2, "Threshold");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_PINGPONG:
|
|
|
|
|
node_sock_label(sock2, "Scale");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_SNAP:
|
|
|
|
|
node_sock_label(sock2, "Increment");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_POWER:
|
|
|
|
|
node_sock_label(sock1, "Base");
|
|
|
|
|
node_sock_label(sock2, "Exponent");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_LOGARITHM:
|
|
|
|
|
node_sock_label(sock2, "Base");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_DEGREES:
|
|
|
|
|
node_sock_label(sock1, "Radians");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_RADIANS:
|
|
|
|
|
node_sock_label(sock1, "Degrees");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_COMPARE:
|
|
|
|
|
node_sock_label(sock3, "Epsilon");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_MATH_SMOOTH_MAX:
|
|
|
|
|
case NODE_MATH_SMOOTH_MIN:
|
|
|
|
|
node_sock_label(sock3, "Distance");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 16:14:43 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Labels
|
|
|
|
|
* \{ */
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void node_blend_label(const bNodeTree * /*ntree*/,
|
|
|
|
|
const bNode *node,
|
|
|
|
|
char *label,
|
|
|
|
|
int label_maxncpy)
|
2011-02-08 12:54:32 +00:00
|
|
|
{
|
|
|
|
|
const char *name;
|
2019-11-06 14:19:58 +00:00
|
|
|
bool enum_label = RNA_enum_name(rna_enum_ramp_blend_items, node->custom1, &name);
|
|
|
|
|
if (!enum_label) {
|
2023-05-18 00:11:17 +02:00
|
|
|
name = IFACE_("Unknown");
|
2019-11-06 14:19:58 +00:00
|
|
|
}
|
2023-05-13 17:38:48 +10:00
|
|
|
BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy);
|
2011-02-08 12:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void node_image_label(const bNodeTree * /*ntree*/,
|
|
|
|
|
const bNode *node,
|
|
|
|
|
char *label,
|
|
|
|
|
int label_maxncpy)
|
2018-01-07 22:29:25 +01:00
|
|
|
{
|
2025-05-04 11:37:07 +02:00
|
|
|
if (node->id == nullptr) {
|
|
|
|
|
BLI_strncpy(label, IFACE_(node->typeinfo->ui_name.c_str()), label_maxncpy);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BLI_strncpy(label, node->id->name + 2, label_maxncpy);
|
2018-01-07 22:29:25 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void node_math_label(const bNodeTree * /*ntree*/,
|
|
|
|
|
const bNode *node,
|
|
|
|
|
char *label,
|
|
|
|
|
int label_maxncpy)
|
2011-02-08 12:54:32 +00:00
|
|
|
{
|
|
|
|
|
const char *name;
|
2019-11-06 14:19:58 +00:00
|
|
|
bool enum_label = RNA_enum_name(rna_enum_node_math_items, node->custom1, &name);
|
|
|
|
|
if (!enum_label) {
|
2023-05-18 00:11:17 +02:00
|
|
|
name = IFACE_("Unknown");
|
2019-11-06 14:19:58 +00:00
|
|
|
}
|
2023-05-13 17:38:48 +10:00
|
|
|
BLI_strncpy_utf8(label, CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, name), label_maxncpy);
|
2011-02-08 12:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void node_vector_math_label(const bNodeTree * /*ntree*/,
|
2021-12-11 09:51:53 -06:00
|
|
|
const bNode *node,
|
|
|
|
|
char *label,
|
2023-05-07 15:22:58 +10:00
|
|
|
int label_maxncpy)
|
2011-02-08 12:54:32 +00:00
|
|
|
{
|
|
|
|
|
const char *name;
|
2019-11-06 14:19:58 +00:00
|
|
|
bool enum_label = RNA_enum_name(rna_enum_node_vec_math_items, node->custom1, &name);
|
|
|
|
|
if (!enum_label) {
|
2023-05-18 00:11:17 +02:00
|
|
|
name = IFACE_("Unknown");
|
2019-11-06 14:19:58 +00:00
|
|
|
}
|
2023-05-18 00:11:17 +02:00
|
|
|
BLI_strncpy_utf8(label, CTX_IFACE_(BLT_I18NCONTEXT_ID_NODETREE, name), label_maxncpy);
|
2011-02-08 12:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void node_filter_label(const bNodeTree * /*ntree*/,
|
|
|
|
|
const bNode *node,
|
|
|
|
|
char *label,
|
|
|
|
|
int label_maxncpy)
|
2011-02-08 12:54:32 +00:00
|
|
|
{
|
|
|
|
|
const char *name;
|
2019-11-06 14:19:58 +00:00
|
|
|
bool enum_label = RNA_enum_name(rna_enum_node_filter_items, node->custom1, &name);
|
|
|
|
|
if (!enum_label) {
|
2023-05-18 00:11:17 +02:00
|
|
|
name = IFACE_("Unknown");
|
2019-11-06 14:19:58 +00:00
|
|
|
}
|
2023-05-13 17:38:48 +10:00
|
|
|
BLI_strncpy_utf8(label, IFACE_(name), label_maxncpy);
|
2011-02-08 12:54:32 +00:00
|
|
|
}
|
2011-11-20 16:38:23 +00:00
|
|
|
|
Nodes: Add general Combine/Separate Color nodes
Inspired by D12936 and D12929, this patch adds general purpose
"Combine Color" and "Separate Color" nodes to Geometry, Compositor,
Shader and Texture nodes.
- Within Geometry Nodes, it replaces the existing "Combine RGB" and
"Separate RGB" nodes.
- Within Compositor Nodes, it replaces the existing
"Combine RGBA/HSVA/YCbCrA/YUVA" and "Separate RGBA/HSVA/YCbCrA/YUVA"
nodes.
- Within Texture Nodes, it replaces the existing "Combine RGBA" and
"Separate RGBA" nodes.
- Within Shader Nodes, it replaces the existing "Combine RGB/HSV" and
"Separate RGB/HSV" nodes.
Python addons have not been updated to the new nodes yet.
**New shader code**
In node_color.h, color.h and gpu_shader_material_color_util.glsl,
missing methods hsl_to_rgb and rgb_to_hsl are added by directly
converting existing C code. They always produce the same result.
**Old code**
As requested by T96219, old nodes still exist but are not displayed in
the add menu. This means Python scripts can still create them as usual.
Otherwise, versioning replaces the old nodes with the new nodes when
opening .blend files.
Differential Revision: https://developer.blender.org/D14034
2022-05-04 18:44:03 +02:00
|
|
|
void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode)
|
|
|
|
|
{
|
|
|
|
|
bNodeSocket *sock1 = (bNodeSocket *)sockets->first;
|
|
|
|
|
bNodeSocket *sock2 = sock1->next;
|
|
|
|
|
bNodeSocket *sock3 = sock2->next;
|
|
|
|
|
|
|
|
|
|
node_sock_label_clear(sock1);
|
|
|
|
|
node_sock_label_clear(sock2);
|
|
|
|
|
node_sock_label_clear(sock3);
|
|
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case NODE_COMBSEP_COLOR_RGB:
|
|
|
|
|
node_sock_label(sock1, "Red");
|
|
|
|
|
node_sock_label(sock2, "Green");
|
|
|
|
|
node_sock_label(sock3, "Blue");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_COMBSEP_COLOR_HSL:
|
|
|
|
|
node_sock_label(sock1, "Hue");
|
|
|
|
|
node_sock_label(sock2, "Saturation");
|
|
|
|
|
node_sock_label(sock3, "Lightness");
|
|
|
|
|
break;
|
|
|
|
|
case NODE_COMBSEP_COLOR_HSV:
|
|
|
|
|
node_sock_label(sock1, "Hue");
|
|
|
|
|
node_sock_label(sock2, "Saturation");
|
|
|
|
|
node_sock_label(sock3, "Value");
|
|
|
|
|
break;
|
|
|
|
|
default: {
|
|
|
|
|
BLI_assert_unreachable();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 16:14:43 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Link Insertion
|
|
|
|
|
* \{ */
|
Node callback for handling link insertion and swapping of occupied inputs.
Nodes have a feature for moving existing links to unoccupied sockets when connecting
to an already used input. This is based on the standard legacy socket types (value/float,
vector, color/rgba) and works reasonably well for shader, compositor and texture nodes.
For new pynode systems, however, the hardcoded nature of that feature has major drawbacks:
* It does not take different type systems into account, leading to meaningless connections
when sockets are swapped and making the feature useless or outright debilitating.
* Advanced socket behaviors would be possible with a registerable callback, e.g. creating
extensible input lists that move existing connections down to make room for a new link.
Now any handling of new links is done via the 'insert_links' callback, which can also be
registered through the RNA API. For the legacy shader/compo/tex nodes the behavior is the
same, using a C callback.
Note on the 'use_swap' flag: this has been removed because it was meaningless anyway:
It was disabled only for the insert-node-on-link feature, which works only for
completely unconnected nodes anyway, so there would be nothing to swap in the first place.
2015-12-03 12:51:29 +01:00
|
|
|
|
2023-01-28 10:07:29 +01:00
|
|
|
bool node_insert_link_default(bNodeTree * /*ntree*/,
|
|
|
|
|
bNode * /*node*/,
|
|
|
|
|
bNodeLink * /*inserted_link*/)
|
Node callback for handling link insertion and swapping of occupied inputs.
Nodes have a feature for moving existing links to unoccupied sockets when connecting
to an already used input. This is based on the standard legacy socket types (value/float,
vector, color/rgba) and works reasonably well for shader, compositor and texture nodes.
For new pynode systems, however, the hardcoded nature of that feature has major drawbacks:
* It does not take different type systems into account, leading to meaningless connections
when sockets are swapped and making the feature useless or outright debilitating.
* Advanced socket behaviors would be possible with a registerable callback, e.g. creating
extensible input lists that move existing connections down to make room for a new link.
Now any handling of new links is done via the 'insert_links' callback, which can also be
registered through the RNA API. For the legacy shader/compo/tex nodes the behavior is the
same, using a C callback.
Note on the 'use_swap' flag: this has been removed because it was meaningless anyway:
It was disabled only for the insert-node-on-link feature, which works only for
completely unconnected nodes anyway, so there would be nothing to swap in the first place.
2015-12-03 12:51:29 +01:00
|
|
|
{
|
2023-01-16 15:47:10 -06:00
|
|
|
return true;
|
Node callback for handling link insertion and swapping of occupied inputs.
Nodes have a feature for moving existing links to unoccupied sockets when connecting
to an already used input. This is based on the standard legacy socket types (value/float,
vector, color/rgba) and works reasonably well for shader, compositor and texture nodes.
For new pynode systems, however, the hardcoded nature of that feature has major drawbacks:
* It does not take different type systems into account, leading to meaningless connections
when sockets are swapped and making the feature useless or outright debilitating.
* Advanced socket behaviors would be possible with a registerable callback, e.g. creating
extensible input lists that move existing connections down to make room for a new link.
Now any handling of new links is done via the 'insert_links' callback, which can also be
registered through the RNA API. For the legacy shader/compo/tex nodes the behavior is the
same, using a C callback.
Note on the 'use_swap' flag: this has been removed because it was meaningless anyway:
It was disabled only for the insert-node-on-link feature, which works only for
completely unconnected nodes anyway, so there would be nothing to swap in the first place.
2015-12-03 12:51:29 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-06 16:14:43 +11:00
|
|
|
/** \} */
|
2014-03-02 16:04:25 +01:00
|
|
|
|
2020-11-06 16:14:43 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Default value RNA access
|
|
|
|
|
* \{ */
|
2014-03-02 16:04:25 +01:00
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
float node_socket_get_float(bNodeTree *ntree, bNode * /*node*/, bNodeSocket *sock)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete((ID *)ntree, &RNA_NodeSocket, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
return RNA_float_get(&ptr, "default_value");
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void node_socket_set_float(bNodeTree *ntree, bNode * /*node*/, bNodeSocket *sock, float value)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete((ID *)ntree, &RNA_NodeSocket, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_float_set(&ptr, "default_value", value);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void node_socket_get_color(bNodeTree *ntree, bNode * /*node*/, bNodeSocket *sock, float *value)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete((ID *)ntree, &RNA_NodeSocket, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_float_get_array(&ptr, "default_value", value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void node_socket_set_color(bNodeTree *ntree,
|
2022-12-20 15:51:47 -03:00
|
|
|
bNode * /*node*/,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *sock,
|
|
|
|
|
const float *value)
|
|
|
|
|
{
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete((ID *)ntree, &RNA_NodeSocket, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_float_set_array(&ptr, "default_value", value);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:51:47 -03:00
|
|
|
void node_socket_get_vector(bNodeTree *ntree, bNode * /*node*/, bNodeSocket *sock, float *value)
|
2013-03-18 16:34:57 +00:00
|
|
|
{
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete((ID *)ntree, &RNA_NodeSocket, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_float_get_array(&ptr, "default_value", value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void node_socket_set_vector(bNodeTree *ntree,
|
2022-12-20 15:51:47 -03:00
|
|
|
bNode * /*node*/,
|
2013-03-18 16:34:57 +00:00
|
|
|
bNodeSocket *sock,
|
|
|
|
|
const float *value)
|
|
|
|
|
{
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_discrete((ID *)ntree, &RNA_NodeSocket, sock);
|
2013-03-18 16:34:57 +00:00
|
|
|
RNA_float_set_array(&ptr, "default_value", value);
|
|
|
|
|
}
|
2020-11-06 16:14:43 +11:00
|
|
|
|
|
|
|
|
/** \} */
|