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-21 20:42:47 +0300
committerHans Goudey <h.goudey@me.com>2021-09-21 20:42:47 +0300
commitb37d36a60f9f60d8beb34142b4768f7bcd7bf987 (patch)
tree586dce13f1f0e1397eeb8f07f2b6af49d513dcbc /source/blender/blenloader
parent3642e17428448e4e9760ca5a8900d02e0abe2df7 (diff)
Fix: Add versioning for geometry nodes attribute input toggle
rB8e21d528cab98 neglected to add versioning to add the new "use_attribute" and "attribute_name" properties to the modifier input list. Though they are added if the modifier's interface is updated, that doesn't happen when the file is loaded, so patch adds them manually. Another solution would be calling `MOD_nodes_update_interface`, but that would require including the modifiers module. Differential Revision: https://developer.blender.org/D12535
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/versioning_300.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 791b5d52d97..58265bca238 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -808,6 +808,47 @@ static void do_version_subsurface_methods(bNode *node)
}
}
+static void version_geometry_nodes_add_attribute_input_settings(NodesModifierData *nmd)
+{
+ /* Before versioning the properties, make sure it hasn't been done already. */
+ LISTBASE_FOREACH (const IDProperty *, property, &nmd->settings.properties->data.group) {
+ if (strstr(property->name, "_use_attribute") || strstr(property->name, "_attribute_name")) {
+ return;
+ }
+ }
+
+ LISTBASE_FOREACH_MUTABLE (IDProperty *, property, &nmd->settings.properties->data.group) {
+ if (!ELEM(property->type, IDP_FLOAT, IDP_INT, IDP_ARRAY)) {
+ continue;
+ }
+
+ if (strstr(property->name, "_use_attribute") || strstr(property->name, "_attribute_name")) {
+ continue;
+ }
+
+ char use_attribute_prop_name[MAX_IDPROP_NAME];
+ BLI_snprintf(use_attribute_prop_name,
+ sizeof(use_attribute_prop_name),
+ "%s%s",
+ property->name,
+ "_use_attribute");
+
+ IDPropertyTemplate idprop = {0};
+ IDProperty *use_attribute_prop = IDP_New(IDP_INT, &idprop, use_attribute_prop_name);
+ IDP_AddToGroup(nmd->settings.properties, use_attribute_prop);
+
+ char attribute_name_prop_name[MAX_IDPROP_NAME];
+ BLI_snprintf(attribute_name_prop_name,
+ sizeof(attribute_name_prop_name),
+ "%s%s",
+ property->name,
+ "_attribute_name");
+
+ IDProperty *attribute_prop = IDP_New(IDP_STRING, &idprop, attribute_name_prop_name);
+ IDP_AddToGroup(nmd->settings.properties, attribute_prop);
+ }
+}
+
/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
@@ -1390,5 +1431,12 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
+ if (md->type == eModifierType_Nodes) {
+ version_geometry_nodes_add_attribute_input_settings((NodesModifierData *)md);
+ }
+ }
+ }
}
}