Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_cycles.c
| Show First 20 Lines • Show All 767 Lines • ▼ Show 20 Lines | static void update_noise_node_dimensions(bNodeTree *ntree) | ||||
| for (bNode *node = ntree->nodes.first; node; node = node->next) { | for (bNode *node = ntree->nodes.first; node; node = node->next) { | ||||
| if (node->type == SH_NODE_TEX_NOISE && node->storage) { | if (node->type == SH_NODE_TEX_NOISE && node->storage) { | ||||
| NodeTexNoise *tex = (NodeTexNoise *)node->storage; | NodeTexNoise *tex = (NodeTexNoise *)node->storage; | ||||
| tex->dimensions = 3; | tex->dimensions = 3; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* This utility function is used by update_mapping_node_inputs_and_properties. | |||||
| * It takes an fcurve from an action or a driver and updates its RNA path. The | |||||
| * path needs to be updated because the node properties became inputs. | |||||
| * | |||||
| * nodes["Mapping"].translation --> nodes["Mapping"].inputs[1].default_value | |||||
| * nodes["Mapping"].rotation --> nodes["Mapping"].inputs[2].default_value | |||||
| * nodes["Mapping"].scale --> nodes["Mapping"].inputs[3].default_value | |||||
| * nodes["Mapping"].max --> nodes["Maximum"].inputs[1].default_value | |||||
| * nodes["Mapping"].min --> nodes["Minimum"].inputs[1].default_value | |||||
| * | |||||
| * The input fcurve can be that of any node or property in the nodetree, so we | |||||
| * only update if the rna path starts with the rna path of the mapping node | |||||
| * and doesn't end with "default_value", that is, not the Vector input. | |||||
| */ | |||||
| static void update_mapping_node_fcurve_rna_path(FCurve *fcurve, | |||||
| char *nodePath, | |||||
| bNode *minimumNode, | |||||
| bNode *maximumNode) | |||||
| { | |||||
| if (!STRPREFIX(fcurve->rna_path, nodePath) || | |||||
| BLI_str_endswith(fcurve->rna_path, "default_value")) { | |||||
| return; | |||||
| } | |||||
| char *old_fcurve_rna_path = fcurve->rna_path; | |||||
| if (BLI_str_endswith(old_fcurve_rna_path, "translation")) { | |||||
| fcurve->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[1].default_value"); | |||||
| } | |||||
| else if (BLI_str_endswith(old_fcurve_rna_path, "rotation")) { | |||||
| fcurve->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[2].default_value"); | |||||
| } | |||||
| else if (BLI_str_endswith(old_fcurve_rna_path, "scale")) { | |||||
| fcurve->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[3].default_value"); | |||||
| } | |||||
| else if (minimumNode && BLI_str_endswith(old_fcurve_rna_path, "max")) { | |||||
| fcurve->rna_path = BLI_sprintfN( | |||||
| "nodes[\"%s\"].%s", minimumNode->name, "inputs[1].default_value"); | |||||
| } | |||||
| else if (maximumNode && BLI_str_endswith(old_fcurve_rna_path, "min")) { | |||||
| fcurve->rna_path = BLI_sprintfN( | |||||
| "nodes[\"%s\"].%s", maximumNode->name, "inputs[1].default_value"); | |||||
| } | |||||
| if (fcurve->rna_path != old_fcurve_rna_path) { | |||||
| MEM_freeN(old_fcurve_rna_path); | |||||
| } | |||||
| } | |||||
| /* The Mapping node has been rewritten to support dynamic inputs. Previously, | /* The Mapping node has been rewritten to support dynamic inputs. Previously, | ||||
| * the transformation information was stored in a TexMapping struct in the | * the transformation information was stored in a TexMapping struct in the | ||||
| * node->storage member of bNode. Currently, the transformation information | * node->storage member of bNode. Currently, the transformation information | ||||
| * is stored in input sockets. To correct this, we transfer the information | * is stored in input sockets. To correct this, we transfer the information | ||||
| * from the TexMapping struct to the input sockets. | * from the TexMapping struct to the input sockets. | ||||
| * | * | ||||
| * Additionally, the Minimum and Maximum properties are no longer available | * Additionally, the Minimum and Maximum properties are no longer available | ||||
| * in the node. To correct this, a Vector Minimum and/or a Vector Maximum | * in the node. To correct this, a Vector Minimum and/or a Vector Maximum | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | if (node->type == SH_NODE_MAPPING && node->storage) { | ||||
| } | } | ||||
| MEM_freeN(node->storage); | MEM_freeN(node->storage); | ||||
| node->storage = NULL; | node->storage = NULL; | ||||
| AnimData *animData = BKE_animdata_from_id(&ntree->id); | AnimData *animData = BKE_animdata_from_id(&ntree->id); | ||||
| if (animData && animData->action) { | if (animData && animData->action) { | ||||
| char *nodePath = BLI_sprintfN("nodes[\"%s\"]", node->name); | char *nodePath = BLI_sprintfN("nodes[\"%s\"]", node->name); | ||||
| for (FCurve *fcu = animData->action->curves.first; fcu; fcu = fcu->next) { | for (FCurve *fcurve = animData->action->curves.first; fcurve; fcurve = fcurve->next) { | ||||
| if (STRPREFIX(fcu->rna_path, nodePath) && | update_mapping_node_fcurve_rna_path(fcurve, nodePath, minimumNode, maximumNode); | ||||
sergey: Wouldn't it be more reliable and less verbose to use `BKE_fcurves_id_cb`? | |||||
| !BLI_str_endswith(fcu->rna_path, "default_value")) { | |||||
| char *old_fcu_rna_path = fcu->rna_path; | |||||
| if (BLI_str_endswith(old_fcu_rna_path, "translation")) { | |||||
| fcu->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[1].default_value"); | |||||
| } | |||||
| else if (BLI_str_endswith(old_fcu_rna_path, "rotation")) { | |||||
| fcu->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[2].default_value"); | |||||
| } | |||||
| else if (BLI_str_endswith(old_fcu_rna_path, "scale")) { | |||||
| fcu->rna_path = BLI_sprintfN("%s.%s", nodePath, "inputs[3].default_value"); | |||||
| } | |||||
| else if (minimumNode && BLI_str_endswith(old_fcu_rna_path, "max")) { | |||||
| fcu->rna_path = BLI_sprintfN( | |||||
| "nodes[\"%s\"].%s", minimumNode->name, "inputs[1].default_value"); | |||||
| } | |||||
| else if (maximumNode && BLI_str_endswith(old_fcu_rna_path, "min")) { | |||||
| fcu->rna_path = BLI_sprintfN( | |||||
| "nodes[\"%s\"].%s", maximumNode->name, "inputs[1].default_value"); | |||||
| } | } | ||||
| if (fcu->rna_path != old_fcu_rna_path) { | for (FCurve *fcurve = animData->drivers.first; fcurve; fcurve = fcurve->next) { | ||||
| MEM_freeN(old_fcu_rna_path); | update_mapping_node_fcurve_rna_path(fcurve, nodePath, minimumNode, maximumNode); | ||||
| } | |||||
| } | |||||
| } | } | ||||
| MEM_freeN(nodePath); | MEM_freeN(nodePath); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (need_update) { | if (need_update) { | ||||
| ▲ Show 20 Lines • Show All 496 Lines • Show Last 20 Lines | |||||
Wouldn't it be more reliable and less verbose to use BKE_fcurves_id_cb?