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>2022-04-28 16:39:30 +0300
committerHans Goudey <h.goudey@me.com>2022-04-28 16:39:30 +0300
commit0ad73bb9655f04afb5ad56174d8fb416cded3e4c (patch)
treee427b3514ee5165843f9a5dc2724d85c92fd215a /source/blender/modifiers/intern/MOD_nodes.cc
parentb0e47ffdcf13cd00c42e6cab4c3556679ad9fea4 (diff)
Geometry Nodes: Add default attribute name to field inputs/outputs
Geometry node group inputs and outputs get a new property that controls the attribute name used for that field input/output when assigning the node group to a modifier for the first time. If the default name is assigned to an input, the default "Use attribute name" is true . In order to properly detect when a node group is first assigned, the modifier now clears its properties when clearing the node group. Ref T96707 Differential Revision: https://developer.blender.org/D14761
Diffstat (limited to 'source/blender/modifiers/intern/MOD_nodes.cc')
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 3867abbd29c..1c890190678 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -628,6 +628,10 @@ static void init_socket_cpp_value_from_property(const IDProperty &property,
void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd)
{
if (nmd->node_group == nullptr) {
+ if (nmd->settings.properties) {
+ IDP_FreeProperty(nmd->settings.properties);
+ nmd->settings.properties = nullptr;
+ }
return;
}
@@ -680,7 +684,13 @@ void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd)
IDProperty *attribute_prop = IDP_New(IDP_STRING, &idprop, attribute_name_id.c_str());
IDP_AddToGroup(nmd->settings.properties, attribute_prop);
- if (old_properties != nullptr) {
+ if (old_properties == nullptr) {
+ if (socket->default_attribute_name && socket->default_attribute_name[0] != '\0') {
+ IDP_AssignString(attribute_prop, socket->default_attribute_name, MAX_NAME);
+ IDP_Int(use_attribute_prop) = 1;
+ }
+ }
+ else {
IDProperty *old_prop_use_attribute = IDP_GetPropertyFromGroup(old_properties,
use_attribute_id.c_str());
if (old_prop_use_attribute != nullptr) {
@@ -709,7 +719,12 @@ void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd)
}
IDP_AddToGroup(nmd->settings.properties, new_prop);
- if (old_properties != nullptr) {
+ if (old_properties == nullptr) {
+ if (socket->default_attribute_name && socket->default_attribute_name[0] != '\0') {
+ IDP_AssignString(new_prop, socket->default_attribute_name, MAX_NAME);
+ }
+ }
+ else {
IDProperty *old_prop = IDP_GetPropertyFromGroup(old_properties, idprop_name.c_str());
if (old_prop != nullptr) {
/* #IDP_CopyPropertyContent replaces the UI data as well, which we don't (we only
@@ -1728,8 +1743,13 @@ static void blendWrite(BlendWriter *writer, const ModifierData *md)
static void blendRead(BlendDataReader *reader, ModifierData *md)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
- BLO_read_data_address(reader, &nmd->settings.properties);
- IDP_BlendDataRead(reader, &nmd->settings.properties);
+ if (nmd->node_group == nullptr) {
+ nmd->settings.properties = nullptr;
+ }
+ else {
+ BLO_read_data_address(reader, &nmd->settings.properties);
+ IDP_BlendDataRead(reader, &nmd->settings.properties);
+ }
nmd->runtime_eval_log = nullptr;
}