Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_nodes.cc')
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc57
1 files changed, 46 insertions, 11 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 9d8630b21e7..3b952e1e649 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -85,8 +85,10 @@
#include "NOD_geometry.h"
#include "NOD_geometry_nodes_eval_log.hh"
+#include "FN_field.hh"
#include "FN_multi_function.hh"
+using blender::ColorGeometry4f;
using blender::destruct_ptr;
using blender::float3;
using blender::FunctionRef;
@@ -329,8 +331,24 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket)
ui_data->max = ui_data->soft_max = (double)value->max;
ui_data->default_array = (double *)MEM_mallocN(sizeof(double[3]), "mod_prop_default");
ui_data->default_array_len = 3;
- for (int i = 3; i < 3; i++) {
- ui_data->default_array[i] = (double)value->value[i];
+ for (const int i : IndexRange(3)) {
+ ui_data->default_array[i] = double(value->value[i]);
+ }
+ return property;
+ }
+ case SOCK_RGBA: {
+ bNodeSocketValueRGBA *value = (bNodeSocketValueRGBA *)socket.default_value;
+ IDPropertyTemplate idprop = {0};
+ idprop.array.len = 4;
+ idprop.array.type = IDP_FLOAT;
+ IDProperty *property = IDP_New(IDP_ARRAY, &idprop, socket.identifier);
+ copy_v4_v4((float *)IDP_Array(property), value->value);
+ IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property);
+ ui_data->base.rna_subtype = PROP_COLOR;
+ ui_data->default_array = (double *)MEM_mallocN(sizeof(double[4]), __func__);
+ ui_data->default_array_len = 4;
+ for (const int i : IndexRange(4)) {
+ ui_data->default_array[i] = double(value->value[i]);
}
return property;
}
@@ -390,6 +408,8 @@ static bool id_property_type_matches_socket(const bNodeSocket &socket, const IDP
return property.type == IDP_INT;
case SOCK_VECTOR:
return property.type == IDP_ARRAY && property.subtype == IDP_FLOAT && property.len == 3;
+ case SOCK_RGBA:
+ return property.type == IDP_ARRAY && property.subtype == IDP_FLOAT && property.len == 4;
case SOCK_BOOLEAN:
return property.type == IDP_INT;
case SOCK_STRING:
@@ -410,28 +430,42 @@ static void init_socket_cpp_value_from_property(const IDProperty &property,
{
switch (socket_value_type) {
case SOCK_FLOAT: {
+ float value = 0.0f;
if (property.type == IDP_FLOAT) {
- *(float *)r_value = IDP_Float(&property);
+ value = IDP_Float(&property);
}
else if (property.type == IDP_DOUBLE) {
- *(float *)r_value = (float)IDP_Double(&property);
+ value = (float)IDP_Double(&property);
}
+ new (r_value) blender::fn::Field<float>(blender::fn::make_constant_field(value));
break;
}
case SOCK_INT: {
- *(int *)r_value = IDP_Int(&property);
+ int value = IDP_Int(&property);
+ new (r_value) blender::fn::Field<int>(blender::fn::make_constant_field(value));
break;
}
case SOCK_VECTOR: {
- copy_v3_v3((float *)r_value, (const float *)IDP_Array(&property));
+ float3 value;
+ copy_v3_v3(value, (const float *)IDP_Array(&property));
+ new (r_value) blender::fn::Field<float3>(blender::fn::make_constant_field(value));
+ break;
+ }
+ case SOCK_RGBA: {
+ blender::ColorGeometry4f value;
+ copy_v4_v4((float *)value, (const float *)IDP_Array(&property));
+ new (r_value) blender::fn::Field<ColorGeometry4f>(blender::fn::make_constant_field(value));
break;
}
case SOCK_BOOLEAN: {
- *(bool *)r_value = IDP_Int(&property) != 0;
+ bool value = IDP_Int(&property) != 0;
+ new (r_value) blender::fn::Field<bool>(blender::fn::make_constant_field(value));
break;
}
case SOCK_STRING: {
- new (r_value) std::string(IDP_String(&property));
+ std::string value = IDP_String(&property);
+ new (r_value)
+ blender::fn::Field<std::string>(blender::fn::make_constant_field(std::move(value)));
break;
}
case SOCK_OBJECT: {
@@ -1041,9 +1075,10 @@ ModifierTypeInfo modifierType_Nodes = {
/* srna */ &RNA_NodesModifier,
/* type */ eModifierTypeType_Constructive,
/* flags */
- static_cast<ModifierTypeFlag>(
- eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode |
- eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping),
+ static_cast<ModifierTypeFlag>(eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_AcceptsCVs |
+ eModifierTypeFlag_SupportsEditmode |
+ eModifierTypeFlag_EnableInEditmode |
+ eModifierTypeFlag_SupportsMapping),
/* icon */ ICON_NODETREE,
/* copyData */ copyData,