Compare commits
9 Commits
temp-ghost
...
2d
Author | SHA1 | Date | |
---|---|---|---|
eaa666b539 | |||
fced09c6a5 | |||
2d8bf2dffd | |||
6edd8bd98f | |||
a1f044e9b9 | |||
b464bbb689 | |||
b9a5f375a0 | |||
4e78822c28 | |||
3d2314fa49 |
@@ -322,6 +322,7 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket
|
||||
}
|
||||
case SOCK_FLOAT:
|
||||
case SOCK_VECTOR:
|
||||
case SOCK_VECTOR_2D:
|
||||
case SOCK_RGBA:
|
||||
case SOCK_BOOLEAN:
|
||||
case SOCK_INT:
|
||||
@@ -457,6 +458,9 @@ static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *so
|
||||
case SOCK_VECTOR:
|
||||
BLO_write_struct(writer, bNodeSocketValueVector, sock->default_value);
|
||||
break;
|
||||
case SOCK_VECTOR_2D:
|
||||
BLO_write_struct(writer, bNodeSocketValueVector2D, sock->default_value);
|
||||
break;
|
||||
case SOCK_RGBA:
|
||||
BLO_write_struct(writer, bNodeSocketValueRGBA, sock->default_value);
|
||||
break;
|
||||
@@ -881,6 +885,7 @@ static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSock
|
||||
}
|
||||
case SOCK_FLOAT:
|
||||
case SOCK_VECTOR:
|
||||
case SOCK_VECTOR_2D:
|
||||
case SOCK_RGBA:
|
||||
case SOCK_BOOLEAN:
|
||||
case SOCK_INT:
|
||||
@@ -976,6 +981,7 @@ static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
|
||||
}
|
||||
case SOCK_FLOAT:
|
||||
case SOCK_VECTOR:
|
||||
case SOCK_VECTOR_2D:
|
||||
case SOCK_RGBA:
|
||||
case SOCK_BOOLEAN:
|
||||
case SOCK_INT:
|
||||
@@ -1578,6 +1584,7 @@ static void socket_id_user_increment(bNodeSocket *sock)
|
||||
}
|
||||
case SOCK_FLOAT:
|
||||
case SOCK_VECTOR:
|
||||
case SOCK_VECTOR_2D:
|
||||
case SOCK_RGBA:
|
||||
case SOCK_BOOLEAN:
|
||||
case SOCK_INT:
|
||||
@@ -1631,6 +1638,7 @@ static void socket_id_user_decrement(bNodeSocket *sock)
|
||||
}
|
||||
case SOCK_FLOAT:
|
||||
case SOCK_VECTOR:
|
||||
case SOCK_VECTOR_2D:
|
||||
case SOCK_RGBA:
|
||||
case SOCK_BOOLEAN:
|
||||
case SOCK_INT:
|
||||
@@ -1764,6 +1772,13 @@ const char *nodeStaticSocketType(int type, int subtype)
|
||||
default:
|
||||
return "NodeSocketVector";
|
||||
}
|
||||
case SOCK_VECTOR_2D:
|
||||
switch (subtype) {
|
||||
case PROP_XYZ:
|
||||
return "NodeSocketVectorXYZ";
|
||||
default:
|
||||
return "NodeSocketVector2D";
|
||||
}
|
||||
case SOCK_RGBA:
|
||||
return "NodeSocketColor";
|
||||
case SOCK_STRING:
|
||||
@@ -1841,6 +1856,8 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype)
|
||||
default:
|
||||
return "NodeSocketInterfaceVector";
|
||||
}
|
||||
case SOCK_VECTOR_2D:
|
||||
return "NodeSocketInterfaceVector2D";
|
||||
case SOCK_RGBA:
|
||||
return "NodeSocketInterfaceColor";
|
||||
case SOCK_STRING:
|
||||
@@ -1874,6 +1891,8 @@ const char *nodeStaticSocketLabel(int type, int UNUSED(subtype))
|
||||
return "Boolean";
|
||||
case SOCK_VECTOR:
|
||||
return "Vector";
|
||||
case SOCK_VECTOR_2D:
|
||||
return "Vector2D";
|
||||
case SOCK_RGBA:
|
||||
return "Color";
|
||||
case SOCK_STRING:
|
||||
|
@@ -82,7 +82,7 @@ namespace node_field_inferencing {
|
||||
|
||||
static bool is_field_socket_type(eNodeSocketDatatype type)
|
||||
{
|
||||
return ELEM(type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA);
|
||||
return ELEM(type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_VECTOR_2D, SOCK_RGBA);
|
||||
}
|
||||
|
||||
static bool is_field_socket_type(const SocketRef &socket)
|
||||
@@ -609,6 +609,20 @@ static int get_internal_link_type_priority(const bNodeSocketType *from, const bN
|
||||
case SOCK_VECTOR:
|
||||
switch (from->type) {
|
||||
case SOCK_VECTOR:
|
||||
return 5;
|
||||
case SOCK_VECTOR_2D:
|
||||
return 4;
|
||||
case SOCK_FLOAT:
|
||||
return 3;
|
||||
case SOCK_INT:
|
||||
return 2;
|
||||
case SOCK_BOOLEAN:
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
case SOCK_VECTOR_2D:
|
||||
switch (from->type) {
|
||||
case SOCK_VECTOR_2D:
|
||||
return 4;
|
||||
case SOCK_FLOAT:
|
||||
return 3;
|
||||
|
@@ -1166,6 +1166,7 @@ static const float std_node_socket_colors[][4] = {
|
||||
{0.96, 0.96, 0.96, 1.0}, /* SOCK_COLLECTION */
|
||||
{0.62, 0.31, 0.64, 1.0}, /* SOCK_TEXTURE */
|
||||
{0.92, 0.46, 0.51, 1.0}, /* SOCK_MATERIAL */
|
||||
{0.59, 0.59, 0.98, 1.0}, /* SOCK_VECTOR_2D */
|
||||
};
|
||||
|
||||
/* common color callbacks for standard types */
|
||||
@@ -1288,6 +1289,15 @@ static void std_node_socket_draw(
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SOCK_VECTOR_2D:
|
||||
if (sock->flag & SOCK_COMPACT) {
|
||||
uiTemplateComponentMenu(layout, ptr, "default_value", text);
|
||||
}
|
||||
else {
|
||||
uiLayout *column = uiLayoutColumn(layout, true);
|
||||
uiItemR(column, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE);
|
||||
}
|
||||
break;
|
||||
case SOCK_RGBA: {
|
||||
if (text[0] == '\0') {
|
||||
uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, "", 0);
|
||||
@@ -1412,7 +1422,8 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout
|
||||
uiItemR(sub, ptr, "max_value", DEFAULT_FLAGS, IFACE_("Max"), ICON_NONE);
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR: {
|
||||
case SOCK_VECTOR:
|
||||
case SOCK_VECTOR_2D: {
|
||||
uiItemR(col, ptr, "default_value", UI_ITEM_R_EXPAND, IFACE_("Default"), ICON_NONE);
|
||||
uiLayout *sub = uiLayoutColumn(col, true);
|
||||
uiItemR(sub, ptr, "min_value", DEFAULT_FLAGS, IFACE_("Min"), ICON_NONE);
|
||||
|
@@ -817,6 +817,9 @@ static void create_inspection_string_for_generic_value(const GPointer value, std
|
||||
else if (type.is<blender::float3>()) {
|
||||
ss << *(blender::float3 *)buffer << TIP_(" (Vector)");
|
||||
}
|
||||
else if (type.is<blender::float2>()) {
|
||||
ss << *(blender::float2 *)buffer << TIP_(" (2D Vector)");
|
||||
}
|
||||
else if (type.is<bool>()) {
|
||||
ss << ((*(bool *)buffer) ? TIP_("True") : TIP_("False")) << TIP_(" (Boolean)");
|
||||
}
|
||||
@@ -855,6 +858,9 @@ static void create_inspection_string_for_gfield(const geo_log::GFieldValueLog &v
|
||||
else if (type.is<blender::float3>()) {
|
||||
ss << TIP_("Vector field");
|
||||
}
|
||||
else if (type.is<blender::float2>()) {
|
||||
ss << TIP_("2D Vector field");
|
||||
}
|
||||
else if (type.is<bool>()) {
|
||||
ss << TIP_("Boolean field");
|
||||
}
|
||||
|
@@ -471,6 +471,7 @@ static bool socket_can_be_viewed(const OutputSocketRef &socket)
|
||||
SOCK_GEOMETRY,
|
||||
SOCK_FLOAT,
|
||||
SOCK_VECTOR,
|
||||
SOCK_VECTOR_2D,
|
||||
SOCK_INT,
|
||||
SOCK_BOOLEAN,
|
||||
SOCK_RGBA);
|
||||
@@ -485,6 +486,8 @@ static CustomDataType socket_type_to_custom_data_type(const eNodeSocketDatatype
|
||||
return CD_PROP_INT32;
|
||||
case SOCK_VECTOR:
|
||||
return CD_PROP_FLOAT3;
|
||||
case SOCK_VECTOR_2D:
|
||||
return CD_PROP_FLOAT2;
|
||||
case SOCK_BOOLEAN:
|
||||
return CD_PROP_BOOL;
|
||||
case SOCK_RGBA:
|
||||
@@ -2043,6 +2046,7 @@ static int get_main_socket_priority(const bNodeSocket *socket)
|
||||
case SOCK_COLLECTION:
|
||||
case SOCK_TEXTURE:
|
||||
case SOCK_MATERIAL:
|
||||
case SOCK_VECTOR_2D:
|
||||
return 6;
|
||||
}
|
||||
return -1;
|
||||
|
@@ -394,6 +394,9 @@ static Vector<NodeLinkItem> ui_node_link_items(NodeLinkArg *arg,
|
||||
else if (dynamic_cast<const decl::Vector *>(&socket_decl)) {
|
||||
item.socket_type = SOCK_VECTOR;
|
||||
}
|
||||
else if (dynamic_cast<const decl::Vector2D *>(&socket_decl)) {
|
||||
item.socket_type = SOCK_VECTOR_2D;
|
||||
}
|
||||
else if (dynamic_cast<const decl::Color *>(&socket_decl)) {
|
||||
item.socket_type = SOCK_RGBA;
|
||||
}
|
||||
@@ -877,7 +880,8 @@ static void ui_node_draw_input(
|
||||
|
||||
switch (input->type) {
|
||||
case SOCK_VECTOR:
|
||||
if (input->type == SOCK_VECTOR) {
|
||||
case SOCK_VECTOR_2D:
|
||||
if (ELEM(input->type, SOCK_VECTOR_2D, SOCK_VECTOR)) {
|
||||
uiItemS(row);
|
||||
sub = uiLayoutColumn(row, true);
|
||||
}
|
||||
|
@@ -205,6 +205,7 @@ typedef enum eNodeSocketDatatype {
|
||||
SOCK_COLLECTION = 11,
|
||||
SOCK_TEXTURE = 12,
|
||||
SOCK_MATERIAL = 13,
|
||||
SOCK_VECTOR_2D = 14,
|
||||
} eNodeSocketDatatype;
|
||||
|
||||
/** Socket shape. */
|
||||
@@ -648,6 +649,13 @@ typedef struct bNodeSocketValueVector {
|
||||
float min, max;
|
||||
} bNodeSocketValueVector;
|
||||
|
||||
typedef struct bNodeSocketValueVector2D {
|
||||
/** RNA subtype. */
|
||||
int subtype;
|
||||
float value[2];
|
||||
float min, max;
|
||||
} bNodeSocketValueVector2D;
|
||||
|
||||
typedef struct bNodeSocketValueRGBA {
|
||||
float value[4];
|
||||
} bNodeSocketValueRGBA;
|
||||
@@ -1343,6 +1351,10 @@ typedef struct NodeInputVector {
|
||||
float vector[3];
|
||||
} NodeInputVector;
|
||||
|
||||
typedef struct NodeInputVector2D {
|
||||
float vector[2];
|
||||
} NodeInputVector2D;
|
||||
|
||||
typedef struct NodeInputColor {
|
||||
float color[4];
|
||||
} NodeInputColor;
|
||||
@@ -2150,7 +2162,7 @@ typedef enum GeometryNodeAttributeInputMode {
|
||||
GEO_NODE_ATTRIBUTE_INPUT_VECTOR = 2,
|
||||
GEO_NODE_ATTRIBUTE_INPUT_COLOR = 3,
|
||||
GEO_NODE_ATTRIBUTE_INPUT_BOOLEAN = 4,
|
||||
GEO_NODE_ATTRIBUTE_INPUT_INTEGER = 5,
|
||||
GEO_NODE_ATTRIBUTE_INPUT_INTEGER = 5
|
||||
} GeometryNodeAttributeInputMode;
|
||||
|
||||
typedef enum GeometryNodePointDistributeMode {
|
||||
|
@@ -41,11 +41,11 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = {
|
||||
{CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
|
||||
{CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
|
||||
{CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
|
||||
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
|
||||
{CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with floating-point values"},
|
||||
{CD_MLOOPCOL, "BYTE_COLOR", 0, "Byte Color", "RGBA color with 8-bit values"},
|
||||
{CD_PROP_STRING, "STRING", 0, "String", "Text string"},
|
||||
{CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
|
||||
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
@@ -54,11 +54,11 @@ const EnumPropertyItem rna_enum_attribute_type_with_auto_items[] = {
|
||||
{CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"},
|
||||
{CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"},
|
||||
{CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"},
|
||||
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
|
||||
{CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with floating-point values"},
|
||||
{CD_MLOOPCOL, "BYTE_COLOR", 0, "Byte Color", "RGBA color with 8-bit values"},
|
||||
{CD_PROP_STRING, "STRING", 0, "String", "Text string"},
|
||||
{CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"},
|
||||
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
@@ -123,6 +123,8 @@ static StructRNA *srna_by_custom_data_layer_type(const CustomDataType type)
|
||||
return &RNA_IntAttribute;
|
||||
case CD_PROP_FLOAT3:
|
||||
return &RNA_FloatVectorAttribute;
|
||||
case CD_PROP_FLOAT2:
|
||||
return &RNA_Float2Attribute;
|
||||
case CD_PROP_COLOR:
|
||||
return &RNA_FloatColorAttribute;
|
||||
case CD_MLOOPCOL:
|
||||
@@ -131,8 +133,6 @@ static StructRNA *srna_by_custom_data_layer_type(const CustomDataType type)
|
||||
return &RNA_StringAttribute;
|
||||
case CD_PROP_BOOL:
|
||||
return &RNA_BoolAttribute;
|
||||
case CD_PROP_FLOAT2:
|
||||
return &RNA_Float2Attribute;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
@@ -238,6 +238,9 @@ static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRN
|
||||
case CD_PROP_FLOAT3:
|
||||
struct_size = sizeof(float[3]);
|
||||
break;
|
||||
case CD_PROP_FLOAT2:
|
||||
struct_size = sizeof(float[2]);
|
||||
break;
|
||||
case CD_PROP_COLOR:
|
||||
struct_size = sizeof(MPropCol);
|
||||
break;
|
||||
@@ -250,9 +253,6 @@ static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRN
|
||||
case CD_PROP_BOOL:
|
||||
struct_size = sizeof(MBoolProperty);
|
||||
break;
|
||||
case CD_PROP_FLOAT2:
|
||||
struct_size = sizeof(float[2]);
|
||||
break;
|
||||
default:
|
||||
struct_size = 0;
|
||||
length = 0;
|
||||
|
@@ -73,6 +73,7 @@ static const EnumPropertyItem node_socket_data_type_items[] = {
|
||||
{SOCK_INT, "INT", 0, "Integer", ""},
|
||||
{SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
|
||||
{SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
|
||||
{SOCK_VECTOR_2D, "VECTOR_2D", 0, "2D Vector", ""},
|
||||
{SOCK_STRING, "STRING", 0, "String", ""},
|
||||
{SOCK_RGBA, "RGBA", 0, "Color", ""},
|
||||
{SOCK_OBJECT, "OBJECT", 0, "Object", ""},
|
||||
@@ -100,6 +101,7 @@ static const EnumPropertyItem node_socket_type_items[] = {
|
||||
{SOCK_INT, "INT", 0, "Integer", ""},
|
||||
{SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
|
||||
{SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
|
||||
{SOCK_VECTOR_2D, "VECTOR2D", 0, "Vector2d", ""},
|
||||
{SOCK_STRING, "STRING", 0, "String", ""},
|
||||
{SOCK_RGBA, "RGBA", 0, "RGBA", ""},
|
||||
{SOCK_SHADER, "SHADER", 0, "Shader", ""},
|
||||
@@ -572,6 +574,10 @@ static EnumPropertyItem rna_node_geometry_mesh_circle_fill_type_items[] = {
|
||||
{ \
|
||||
GEO_NODE_ATTRIBUTE_INPUT_VECTOR, "VECTOR", 0, "Vector", "" \
|
||||
}
|
||||
#define ITEM_VECTOR_2D \
|
||||
{ \
|
||||
GEO_NODE_ATTRIBUTE_INPUT_VECTOR2D, "VECTOR_2D", 0, "2D Vector", "" \
|
||||
}
|
||||
#define ITEM_COLOR \
|
||||
{ \
|
||||
GEO_NODE_ATTRIBUTE_INPUT_COLOR, "COLOR", 0, "Color", "" \
|
||||
@@ -2099,6 +2105,7 @@ static bool switch_type_supported(const EnumPropertyItem *item)
|
||||
SOCK_INT,
|
||||
SOCK_BOOLEAN,
|
||||
SOCK_VECTOR,
|
||||
SOCK_VECTOR_2D,
|
||||
SOCK_STRING,
|
||||
SOCK_RGBA,
|
||||
SOCK_GEOMETRY,
|
||||
@@ -12120,6 +12127,69 @@ static void rna_def_node_socket_vector(BlenderRNA *brna,
|
||||
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
|
||||
}
|
||||
|
||||
static void rna_def_node_socket_vector_2d(BlenderRNA *brna,
|
||||
const char *identifier,
|
||||
const char *interface_idname,
|
||||
PropertySubType subtype)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
const float *value_default;
|
||||
|
||||
/* choose sensible common default based on subtype */
|
||||
switch (subtype) {
|
||||
default: {
|
||||
static const float default_vector[2] = {0.0f, 0.0f};
|
||||
value_default = default_vector;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
|
||||
RNA_def_struct_ui_text(srna, "Vector Node Socket", "2D vector socket of a node");
|
||||
RNA_def_struct_sdna(srna, "bNodeSocket");
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "bNodeSocketValueVector2D", "default_value");
|
||||
|
||||
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype);
|
||||
RNA_def_property_float_sdna(prop, NULL, "value");
|
||||
RNA_def_property_float_array_default(prop, value_default);
|
||||
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_vector_range");
|
||||
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
|
||||
|
||||
/* socket interface */
|
||||
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
|
||||
RNA_def_struct_ui_text(srna, "Vector2d Node Socket Interface", "2D vector socket of a node");
|
||||
RNA_def_struct_sdna(srna, "bNodeSocket");
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "bNodeSocketValueVector2D", "default_value");
|
||||
|
||||
prop = RNA_def_property(srna, "default_value", PROP_FLOAT, subtype);
|
||||
RNA_def_property_float_sdna(prop, NULL, "value");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_float_funcs(prop, NULL, NULL, "rna_NodeSocketStandard_vector_range");
|
||||
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
|
||||
|
||||
prop = RNA_def_property(srna, "min_value", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "min");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Minimum Value", "Minimum value");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
|
||||
|
||||
prop = RNA_def_property(srna, "max_value", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "max");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Maximum Value", "Maximum value");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
|
||||
|
||||
RNA_def_struct_sdna_from(srna, "bNodeSocket", NULL);
|
||||
}
|
||||
|
||||
static void rna_def_node_socket_color(BlenderRNA *brna,
|
||||
const char *identifier,
|
||||
const char *interface_idname)
|
||||
@@ -12548,9 +12618,16 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
|
||||
PROP_ACCELERATION);
|
||||
rna_def_node_socket_vector(
|
||||
brna, "NodeSocketVectorEuler", "NodeSocketInterfaceVectorEuler", PROP_EULER);
|
||||
|
||||
rna_def_node_socket_vector(
|
||||
brna, "NodeSocketVectorXYZ", "NodeSocketInterfaceVectorXYZ", PROP_XYZ);
|
||||
|
||||
rna_def_node_socket_vector_2d(
|
||||
brna, "NodeSocketVector2D", "NodeSocketInterfaceVector2D", PROP_NONE);
|
||||
|
||||
rna_def_node_socket_vector_2d(
|
||||
brna, "NodeSocketVector2DXYZ", "NodeSocketInterfaceVector2DXYZ", PROP_XYZ);
|
||||
|
||||
rna_def_node_socket_color(brna, "NodeSocketColor", "NodeSocketInterfaceColor");
|
||||
|
||||
rna_def_node_socket_string(brna, "NodeSocketString", "NodeSocketInterfaceString");
|
||||
|
@@ -105,6 +105,7 @@
|
||||
using blender::Array;
|
||||
using blender::ColorGeometry4f;
|
||||
using blender::destruct_ptr;
|
||||
using blender::float2;
|
||||
using blender::float3;
|
||||
using blender::FunctionRef;
|
||||
using blender::IndexRange;
|
||||
@@ -400,7 +401,8 @@ static const std::string attribute_name_suffix = "_attribute_name";
|
||||
*/
|
||||
static bool socket_type_has_attribute_toggle(const bNodeSocket &socket)
|
||||
{
|
||||
return ELEM(socket.type, SOCK_FLOAT, SOCK_VECTOR, SOCK_BOOLEAN, SOCK_RGBA, SOCK_INT);
|
||||
return ELEM(
|
||||
socket.type, SOCK_FLOAT, SOCK_VECTOR, SOCK_VECTOR_2D, SOCK_BOOLEAN, SOCK_RGBA, SOCK_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,6 +461,24 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket)
|
||||
}
|
||||
return property;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
bNodeSocketValueVector2D *value = (bNodeSocketValueVector2D *)socket.default_value;
|
||||
IDPropertyTemplate idprop = {0};
|
||||
idprop.array.len = 2;
|
||||
idprop.array.type = IDP_FLOAT;
|
||||
IDProperty *property = IDP_New(IDP_ARRAY, &idprop, socket.identifier);
|
||||
copy_v2_v2((float *)IDP_Array(property), value->value);
|
||||
IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property);
|
||||
ui_data->base.rna_subtype = value->subtype;
|
||||
ui_data->min = ui_data->soft_min = (double)value->min;
|
||||
ui_data->max = ui_data->soft_max = (double)value->max;
|
||||
ui_data->default_array = (double *)MEM_mallocN(sizeof(double[2]), "mod_prop_default");
|
||||
ui_data->default_array_len = 2;
|
||||
for (const int i : IndexRange(2)) {
|
||||
ui_data->default_array[i] = double(value->value[i]);
|
||||
}
|
||||
return property;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
bNodeSocketValueRGBA *value = (bNodeSocketValueRGBA *)socket.default_value;
|
||||
IDPropertyTemplate idprop = {0};
|
||||
@@ -535,6 +555,8 @@ static bool id_property_type_matches_socket(const bNodeSocket &socket, const IDP
|
||||
return ELEM(property.type, IDP_FLOAT, IDP_DOUBLE);
|
||||
case SOCK_INT:
|
||||
return property.type == IDP_INT;
|
||||
case SOCK_VECTOR_2D:
|
||||
return property.type == IDP_ARRAY && property.subtype == IDP_FLOAT && property.len == 2;
|
||||
case SOCK_VECTOR:
|
||||
return property.type == IDP_ARRAY && property.subtype == IDP_FLOAT && property.len == 3;
|
||||
case SOCK_RGBA:
|
||||
@@ -581,6 +603,12 @@ static void init_socket_cpp_value_from_property(const IDProperty &property,
|
||||
new (r_value) ValueOrField<float3>(value);
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
float2 value;
|
||||
copy_v2_v2(value, (const float *)IDP_Array(&property));
|
||||
new (r_value) ValueOrField<float2>(value);
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
blender::ColorGeometry4f value;
|
||||
copy_v4_v4((float *)value, (const float *)IDP_Array(&property));
|
||||
|
@@ -110,6 +110,35 @@ class VectorBuilder : public SocketDeclarationBuilder<Vector> {
|
||||
VectorBuilder &compact();
|
||||
};
|
||||
|
||||
class Vector2DBuilder;
|
||||
|
||||
class Vector2D : public SocketDeclaration {
|
||||
private:
|
||||
float2 default_value_ = {0, 0};
|
||||
float soft_min_value_ = -FLT_MAX;
|
||||
float soft_max_value_ = FLT_MAX;
|
||||
PropertySubType subtype_ = PROP_NONE;
|
||||
|
||||
friend Vector2DBuilder;
|
||||
|
||||
public:
|
||||
using Builder = Vector2DBuilder;
|
||||
|
||||
bNodeSocket &build(bNodeTree &ntree, bNode &node) const override;
|
||||
bool matches(const bNodeSocket &socket) const override;
|
||||
bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
|
||||
bool can_connect(const bNodeSocket &socket) const override;
|
||||
};
|
||||
|
||||
class Vector2DBuilder : public SocketDeclarationBuilder<Vector2D> {
|
||||
public:
|
||||
Vector2DBuilder &default_value(const float2 value);
|
||||
Vector2DBuilder &subtype(PropertySubType subtype);
|
||||
Vector2DBuilder &min(float min);
|
||||
Vector2DBuilder &max(float max);
|
||||
Vector2DBuilder &compact();
|
||||
};
|
||||
|
||||
class BoolBuilder;
|
||||
|
||||
class Bool : public SocketDeclaration {
|
||||
@@ -333,6 +362,42 @@ inline VectorBuilder &VectorBuilder::compact()
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name #Vector2DBuilder Inline Methods
|
||||
* \{ */
|
||||
|
||||
inline Vector2DBuilder &Vector2DBuilder::default_value(const float2 value)
|
||||
{
|
||||
decl_->default_value_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2DBuilder &Vector2DBuilder::subtype(PropertySubType subtype)
|
||||
{
|
||||
decl_->subtype_ = subtype;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2DBuilder &Vector2DBuilder::min(const float min)
|
||||
{
|
||||
decl_->soft_min_value_ = min;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2DBuilder &Vector2DBuilder::max(const float max)
|
||||
{
|
||||
decl_->soft_max_value_ = max;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Vector2DBuilder &Vector2DBuilder::compact()
|
||||
{
|
||||
decl_->compact_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name #BoolBuilder Inline Methods
|
||||
* \{ */
|
||||
|
@@ -91,8 +91,8 @@ static bool geometry_node_tree_validate_link(eNodeSocketDatatype type_a,
|
||||
{
|
||||
/* Geometry, string, object, material, texture and collection sockets can only be connected to
|
||||
* themselves. The other types can be converted between each other. */
|
||||
if (ELEM(type_a, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT) &&
|
||||
ELEM(type_b, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT)) {
|
||||
if (ELEM(type_a, SOCK_FLOAT, SOCK_VECTOR, SOCK_VECTOR_2D, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT) &&
|
||||
ELEM(type_b, SOCK_FLOAT, SOCK_VECTOR, SOCK_VECTOR_2D, SOCK_RGBA, SOCK_BOOLEAN, SOCK_INT)) {
|
||||
return true;
|
||||
}
|
||||
return type_a == type_b;
|
||||
@@ -104,6 +104,7 @@ static bool geometry_node_tree_socket_type_valid(bNodeTreeType *UNUSED(ntreetype
|
||||
return nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type,
|
||||
SOCK_FLOAT,
|
||||
SOCK_VECTOR,
|
||||
SOCK_VECTOR_2D,
|
||||
SOCK_RGBA,
|
||||
SOCK_BOOLEAN,
|
||||
SOCK_INT,
|
||||
|
@@ -58,6 +58,8 @@ std::optional<CustomDataType> node_data_type_to_custom_data_type(const eNodeSock
|
||||
return CD_PROP_FLOAT;
|
||||
case SOCK_VECTOR:
|
||||
return CD_PROP_FLOAT3;
|
||||
case SOCK_VECTOR_2D:
|
||||
return CD_PROP_FLOAT2;
|
||||
case SOCK_RGBA:
|
||||
return CD_PROP_COLOR;
|
||||
case SOCK_BOOLEAN:
|
||||
|
@@ -72,6 +72,8 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::Material>(N_("True"), "True_010");
|
||||
b.add_input<decl::Image>(N_("False"), "False_011");
|
||||
b.add_input<decl::Image>(N_("True"), "True_011");
|
||||
b.add_input<decl::Vector2D>(N_("False"), "False_012").supports_field();
|
||||
b.add_input<decl::Vector2D>(N_("True"), "True_012").supports_field();
|
||||
|
||||
b.add_output<decl::Float>(N_("Output")).dependent_field();
|
||||
b.add_output<decl::Int>(N_("Output"), "Output_001").dependent_field();
|
||||
@@ -85,6 +87,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_output<decl::Texture>(N_("Output"), "Output_009");
|
||||
b.add_output<decl::Material>(N_("Output"), "Output_010");
|
||||
b.add_output<decl::Image>(N_("Output"), "Output_011");
|
||||
b.add_output<decl::Vector2D>(N_("Output"), "Output_012").dependent_field();
|
||||
}
|
||||
|
||||
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
@@ -106,8 +109,14 @@ static void node_update(bNodeTree *ntree, bNode *node)
|
||||
bNodeSocket *field_switch = (bNodeSocket *)node->inputs.first;
|
||||
bNodeSocket *non_field_switch = (bNodeSocket *)field_switch->next;
|
||||
|
||||
const bool fields_type = ELEM(
|
||||
storage.input_type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA, SOCK_STRING);
|
||||
const bool fields_type = ELEM(storage.input_type,
|
||||
SOCK_FLOAT,
|
||||
SOCK_INT,
|
||||
SOCK_BOOLEAN,
|
||||
SOCK_VECTOR,
|
||||
SOCK_VECTOR_2D,
|
||||
SOCK_RGBA,
|
||||
SOCK_STRING);
|
||||
|
||||
nodeSetSocketAvailability(ntree, field_switch, fields_type);
|
||||
nodeSetSocketAvailability(ntree, non_field_switch, !fields_type);
|
||||
@@ -313,6 +322,10 @@ static void node_geo_exec(GeoNodeExecParams params)
|
||||
switch_no_fields<Image *>(params, "_011");
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
switch_fields<float2>(params, "_012");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
|
@@ -38,6 +38,7 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_input<decl::Color>(N_("Value"), "Value_002").supports_field().hide_value();
|
||||
b.add_input<decl::Int>(N_("Value"), "Value_003").supports_field().hide_value();
|
||||
b.add_input<decl::Bool>(N_("Value"), "Value_004").supports_field().hide_value();
|
||||
b.add_input<decl::Vector2D>(N_("Value"), "Value_005").supports_field().hide_value();
|
||||
}
|
||||
|
||||
static void node_init(bNodeTree *UNUSED(tree), bNode *node)
|
||||
@@ -60,6 +61,8 @@ static eNodeSocketDatatype custom_data_type_to_socket_type(const CustomDataType
|
||||
return SOCK_FLOAT;
|
||||
case CD_PROP_INT32:
|
||||
return SOCK_INT;
|
||||
case CD_PROP_FLOAT2:
|
||||
return SOCK_VECTOR_2D;
|
||||
case CD_PROP_FLOAT3:
|
||||
return SOCK_VECTOR;
|
||||
case CD_PROP_BOOL:
|
||||
@@ -109,8 +112,13 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
|
||||
set_active_fn(params, node);
|
||||
});
|
||||
}
|
||||
if (type &&
|
||||
ELEM(type, CD_PROP_FLOAT, CD_PROP_BOOL, CD_PROP_INT32, CD_PROP_FLOAT3, CD_PROP_COLOR)) {
|
||||
if (type && ELEM(type,
|
||||
CD_PROP_FLOAT,
|
||||
CD_PROP_BOOL,
|
||||
CD_PROP_INT32,
|
||||
CD_PROP_FLOAT3,
|
||||
CD_PROP_FLOAT2,
|
||||
CD_PROP_COLOR)) {
|
||||
params.add_item(IFACE_("Value"), [type, set_active_fn](LinkSearchOpParams ¶ms) {
|
||||
bNode &node = params.add_node("GeometryNodeViewer");
|
||||
node_storage(node).data_type = *type;
|
||||
|
@@ -169,6 +169,12 @@ GVArray GeoNodeExecParams::get_input_attribute(const StringRef name,
|
||||
conversions.convert_to_uninitialized(CPPType::get<float3>(), *cpp_type, &value, buffer);
|
||||
return GVArray::ForSingle(*cpp_type, domain_size, buffer);
|
||||
}
|
||||
if (found_socket->type == SOCK_VECTOR_2D) {
|
||||
const float2 value = this->get_input<float2>(found_socket->identifier);
|
||||
BUFFER_FOR_CPP_TYPE_VALUE(*cpp_type, buffer);
|
||||
conversions.convert_to_uninitialized(CPPType::get<float2>(), *cpp_type, &value, buffer);
|
||||
return GVArray::ForSingle(*cpp_type, domain_size, buffer);
|
||||
}
|
||||
if (found_socket->type == SOCK_RGBA) {
|
||||
const ColorGeometry4f value = this->get_input<ColorGeometry4f>(found_socket->identifier);
|
||||
BUFFER_FOR_CPP_TYPE_VALUE(*cpp_type, buffer);
|
||||
@@ -205,6 +211,9 @@ CustomDataType GeoNodeExecParams::get_input_attribute_data_type(
|
||||
if (found_socket->type == SOCK_VECTOR) {
|
||||
return CD_PROP_FLOAT3;
|
||||
}
|
||||
if (found_socket->type == SOCK_VECTOR_2D) {
|
||||
return CD_PROP_FLOAT2;
|
||||
}
|
||||
if (found_socket->type == SOCK_RGBA) {
|
||||
return CD_PROP_COLOR;
|
||||
}
|
||||
|
@@ -93,6 +93,14 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree,
|
||||
dval->max = stemp->max;
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
bNodeSocketValueVector2D *dval = (bNodeSocketValueVector2D *)sock->default_value;
|
||||
dval->value[0] = stemp->val1;
|
||||
dval->value[1] = stemp->val2;
|
||||
dval->min = stemp->min;
|
||||
dval->max = stemp->max;
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)sock->default_value;
|
||||
dval->value[0] = stemp->val1;
|
||||
@@ -346,6 +354,18 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
static float default_value[] = {0.0f, 0.0f};
|
||||
bNodeSocketValueVector2D *dval = MEM_cnew<bNodeSocketValueVector2D>(
|
||||
"node socket value Vector2D");
|
||||
dval->subtype = subtype;
|
||||
copy_v2_v2(dval->value, default_value);
|
||||
dval->min = -FLT_MAX;
|
||||
dval->max = FLT_MAX;
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
static float default_value[] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
bNodeSocketValueRGBA *dval = MEM_cnew<bNodeSocketValueRGBA>("node socket value color");
|
||||
@@ -446,6 +466,12 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
|
||||
*toval = *fromval;
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
bNodeSocketValueVector2D *toval = (bNodeSocketValueVector2D *)to->default_value;
|
||||
bNodeSocketValueVector2D *fromval = (bNodeSocketValueVector2D *)from->default_value;
|
||||
*toval = *fromval;
|
||||
break;
|
||||
}
|
||||
case SOCK_RGBA: {
|
||||
bNodeSocketValueRGBA *toval = (bNodeSocketValueRGBA *)to->default_value;
|
||||
bNodeSocketValueRGBA *fromval = (bNodeSocketValueRGBA *)from->default_value;
|
||||
@@ -606,6 +632,14 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree
|
||||
toval->max = fromval->max;
|
||||
break;
|
||||
}
|
||||
case SOCK_VECTOR_2D: {
|
||||
bNodeSocketValueVector2D *toval = (bNodeSocketValueVector2D *)sock->default_value;
|
||||
const bNodeSocketValueVector2D *fromval = (const bNodeSocketValueVector2D *)
|
||||
interface_socket->default_value;
|
||||
toval->min = fromval->min;
|
||||
toval->max = fromval->max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,6 +794,22 @@ static bNodeSocketType *make_socket_type_vector(PropertySubType subtype)
|
||||
return socktype;
|
||||
}
|
||||
|
||||
static bNodeSocketType *make_socket_type_vector_2d(PropertySubType subtype)
|
||||
{
|
||||
bNodeSocketType *socktype = make_standard_socket_type(SOCK_VECTOR_2D, subtype);
|
||||
socktype->base_cpp_type = &blender::fn::CPPType::get<blender::float2>();
|
||||
socktype->get_base_cpp_value = [](const bNodeSocket &socket, void *r_value) {
|
||||
*(blender::float2 *)r_value = ((bNodeSocketValueVector2D *)socket.default_value)->value;
|
||||
};
|
||||
socktype->geometry_nodes_cpp_type = &blender::fn::CPPType::get<ValueOrField<blender::float2>>();
|
||||
socktype->get_geometry_nodes_cpp_value = [](const bNodeSocket &socket, void *r_value) {
|
||||
blender::float2 value;
|
||||
socket.typeinfo->get_base_cpp_value(socket, &value);
|
||||
new (r_value) ValueOrField<blender::float2>(value);
|
||||
};
|
||||
return socktype;
|
||||
}
|
||||
|
||||
static bNodeSocketType *make_socket_type_rgba()
|
||||
{
|
||||
bNodeSocketType *socktype = make_standard_socket_type(SOCK_RGBA, PROP_NONE);
|
||||
@@ -900,6 +950,8 @@ void register_standard_node_socket_types()
|
||||
nodeRegisterSocketType(make_socket_type_vector(PROP_EULER));
|
||||
nodeRegisterSocketType(make_socket_type_vector(PROP_XYZ));
|
||||
|
||||
nodeRegisterSocketType(make_socket_type_vector_2d(PROP_NONE));
|
||||
|
||||
nodeRegisterSocketType(make_socket_type_rgba());
|
||||
|
||||
nodeRegisterSocketType(make_socket_type_string());
|
||||
|
@@ -66,7 +66,13 @@ static bool sockets_can_connect(const SocketDeclaration &socket_decl,
|
||||
static bool basic_types_can_connect(const SocketDeclaration &UNUSED(socket_decl),
|
||||
const bNodeSocket &other_socket)
|
||||
{
|
||||
return ELEM(other_socket.type, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_VECTOR, SOCK_RGBA);
|
||||
return ELEM(other_socket.type,
|
||||
SOCK_FLOAT,
|
||||
SOCK_INT,
|
||||
SOCK_BOOLEAN,
|
||||
SOCK_VECTOR,
|
||||
SOCK_VECTOR_2D,
|
||||
SOCK_RGBA);
|
||||
}
|
||||
|
||||
static void modify_subtype_except_for_storage(bNodeSocket &socket, int new_subtype)
|
||||
@@ -261,6 +267,62 @@ bNodeSocket &Vector::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name #Vector2D
|
||||
* \{ */
|
||||
|
||||
bNodeSocket &Vector2D::build(bNodeTree &ntree, bNode &node) const
|
||||
{
|
||||
bNodeSocket &socket = *nodeAddStaticSocket(
|
||||
&ntree, &node, in_out_, SOCK_VECTOR_2D, subtype_, identifier_.c_str(), name_.c_str());
|
||||
this->set_common_flags(socket);
|
||||
bNodeSocketValueVector2D &value = *(bNodeSocketValueVector2D *)socket.default_value;
|
||||
copy_v2_v2(value.value, default_value_);
|
||||
value.min = soft_min_value_;
|
||||
value.max = soft_max_value_;
|
||||
return socket;
|
||||
}
|
||||
|
||||
bool Vector2D::matches(const bNodeSocket &socket) const
|
||||
{
|
||||
if (!this->matches_common_data(socket)) {
|
||||
return false;
|
||||
}
|
||||
if (socket.type != SOCK_VECTOR_2D) {
|
||||
return false;
|
||||
}
|
||||
if (socket.typeinfo->subtype != subtype_) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Vector2D::can_connect(const bNodeSocket &socket) const
|
||||
{
|
||||
if (!sockets_can_connect(*this, socket)) {
|
||||
return false;
|
||||
}
|
||||
return basic_types_can_connect(*this, socket);
|
||||
}
|
||||
|
||||
bNodeSocket &Vector2D::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
|
||||
{
|
||||
if (socket.type != SOCK_VECTOR_2D) {
|
||||
BLI_assert(socket.in_out == in_out_);
|
||||
return this->build(ntree, node);
|
||||
}
|
||||
if (socket.typeinfo->subtype != subtype_) {
|
||||
modify_subtype_except_for_storage(socket, subtype_);
|
||||
}
|
||||
this->set_common_flags(socket);
|
||||
bNodeSocketValueVector2D &value = *(bNodeSocketValueVector2D *)socket.default_value;
|
||||
value.subtype = subtype_;
|
||||
STRNCPY(socket.name, name_.c_str());
|
||||
return socket;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name #Bool
|
||||
* \{ */
|
||||
|
@@ -392,4 +392,23 @@ void node_socket_set_vector(bNodeTree *ntree,
|
||||
RNA_float_set_array(&ptr, "default_value", value);
|
||||
}
|
||||
|
||||
void node_socket_get_vector_2d(bNodeTree *ntree,
|
||||
bNode *UNUSED(node),
|
||||
bNodeSocket *sock,
|
||||
float *value)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
|
||||
RNA_float_get_array(&ptr, "default_value", value);
|
||||
}
|
||||
|
||||
void node_socket_set_vector_2d(bNodeTree *ntree,
|
||||
bNode *UNUSED(node),
|
||||
bNodeSocket *sock,
|
||||
const float *value)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr);
|
||||
RNA_float_set_array(&ptr, "default_value", value);
|
||||
}
|
||||
/** \} */
|
||||
|
@@ -112,7 +112,14 @@ void node_socket_set_vector(struct bNodeTree *ntree,
|
||||
struct bNode *node,
|
||||
struct bNodeSocket *sock,
|
||||
const float *value);
|
||||
|
||||
void node_socket_get_vector_2d(struct bNodeTree *ntree,
|
||||
struct bNode *node,
|
||||
struct bNodeSocket *sock,
|
||||
float *value);
|
||||
void node_socket_set_vector_2d(struct bNodeTree *ntree,
|
||||
struct bNode *node,
|
||||
struct bNodeSocket *sock,
|
||||
const float *value);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user