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:
authorHans Goudey <h.goudey@me.com>2021-09-09 17:43:00 +0300
committerHans Goudey <h.goudey@me.com>2021-09-09 17:43:00 +0300
commitb4fd8750f96d42a53bbccf4952bab1b6f018d78f (patch)
treeccee31468907c566f1c66650358f98549251321b
parent62ec88eb846a8c342e046bc5c798022cbe694026 (diff)
Geometry Nodes: Allow exposing color sockets to the modifier
This commit allows connecting color sockets to the group input and changing the input values in the modifier. Before there was an error since this was more complicated to support with the previous IDProperty UI data storage method. Differential Revision: https://developer.blender.org/D12437
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index ba557c3976c..f6d145bfdd7 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -88,6 +88,7 @@
#include "FN_field.hh"
#include "FN_multi_function.hh"
+using blender::ColorGeometry4f;
using blender::destruct_ptr;
using blender::float3;
using blender::FunctionRef;
@@ -335,6 +336,22 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket)
}
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;
+ }
case SOCK_BOOLEAN: {
bNodeSocketValueBoolean *value = (bNodeSocketValueBoolean *)socket.default_value;
IDPropertyTemplate idprop = {0};
@@ -391,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:
@@ -432,6 +451,12 @@ static void init_socket_cpp_value_from_property(const IDProperty &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 value = IDP_Int(&property) != 0;
new (r_value) blender::fn::Field<bool>(blender::fn::make_constant_field(value));