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>2020-12-17 23:43:01 +0300
committerHans Goudey <h.goudey@me.com>2020-12-17 23:43:01 +0300
commit23233fcf056e42958972d129ba526c0a103cf179 (patch)
tree311032616f27854496eb4137e29a1201491ac4cf /source/blender/blenloader
parentb10d8e330e529abb1cb017312b46a33ede24a8d0 (diff)
Cleanup: Use abstraction for attribute math node input
Since creating the attribute node, a helper function has been added to automatically get the input attribute or a constant value, depending on the "input type" values for the node. This commit replaces the specific implementation of that behavior with the new helper function. The versioning is necessary since the node now has a "storage" struct.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 4df681002a0..9aded9137ec 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1428,5 +1428,26 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
+
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_GEOMETRY) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (node->type == GEO_NODE_ATTRIBUTE_MATH && node->storage == NULL) {
+ const int old_use_attibute_a = (1 << 0);
+ const int old_use_attibute_b = (1 << 1);
+ NodeAttributeMath *data = MEM_callocN(sizeof(NodeAttributeMath), "NodeAttributeMath");
+ data->operation = NODE_MATH_ADD;
+ data->input_type_a = (node->custom2 & old_use_attibute_a) ?
+ GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE :
+ GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
+ data->input_type_b = (node->custom2 & old_use_attibute_b) ?
+ GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE :
+ GEO_NODE_ATTRIBUTE_INPUT_FLOAT;
+ node->storage = data;
+ }
+ }
+ }
+ }
+ FOREACH_NODETREE_END;
}
}