Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_300.c
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_asset.h" | #include "BKE_asset.h" | ||||
| #include "BKE_collection.h" | #include "BKE_collection.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_fcurve_driver.h" | #include "BKE_fcurve_driver.h" | ||||
| #include "BKE_idprop.h" | #include "BKE_idprop.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_modifier.h" | |||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| #include "BLO_readfile.h" | #include "BLO_readfile.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "readfile.h" | #include "readfile.h" | ||||
| ▲ Show 20 Lines • Show All 452 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) { | ||||
| /* Also realize instances for the profile input of the curve to mesh node. */ | /* Also realize instances for the profile input of the curve to mesh node. */ | ||||
| if (node->type == GEO_NODE_CURVE_TO_MESH) { | if (node->type == GEO_NODE_CURVE_TO_MESH) { | ||||
| bNodeSocket *profile_socket = node->inputs.last; | bNodeSocket *profile_socket = node->inputs.last; | ||||
| add_realize_instances_before_socket(ntree, node, profile_socket); | add_realize_instances_before_socket(ntree, node, profile_socket); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * The geometry nodes modifier used to realize instances for the next modifier implicitly. Now it | |||||
| * is done with the realize instances node. It also used to convert meshes to point clouds | |||||
| * automatically, which is also now done with a specific node. | |||||
| */ | |||||
| static bNodeTree *add_realize_node_tree(Main *bmain) | |||||
| { | |||||
| bNodeTree *node_tree = ntreeAddTree(bmain, "Geometry nodes realize", "GeometryNodeTree"); | |||||
| ntreeAddSocketInterface(node_tree, SOCK_IN, "NodeSocketGeometry", "Geometry"); | |||||
| ntreeAddSocketInterface(node_tree, SOCK_OUT, "NodeSocketGeometry", "Geometry"); | |||||
| bNode *group_input = nodeAddStaticNode(NULL, node_tree, NODE_GROUP_INPUT); | |||||
| group_input->locx = -400.0f; | |||||
| bNode *group_output = nodeAddStaticNode(NULL, node_tree, NODE_GROUP_OUTPUT); | |||||
| group_output->locx = 500.0f; | |||||
| group_output->flag |= NODE_DO_OUTPUT; | |||||
| bNode *join = nodeAddStaticNode(NULL, node_tree, GEO_NODE_JOIN_GEOMETRY); | |||||
| join->locx = group_output->locx - 175.0f; | |||||
| join->locy = group_output->locy; | |||||
| bNode *conv = nodeAddStaticNode(NULL, node_tree, GEO_NODE_POINTS_TO_VERTICES); | |||||
| conv->locx = join->locx - 175.0f; | |||||
| conv->locy = join->locy - 70.0; | |||||
| bNode *separate = nodeAddStaticNode(NULL, node_tree, GEO_NODE_SEPARATE_COMPONENTS); | |||||
| separate->locx = join->locx - 350.0f; | |||||
| separate->locy = join->locy + 50.0f; | |||||
| bNode *realize = nodeAddStaticNode(NULL, node_tree, GEO_NODE_REALIZE_INSTANCES); | |||||
| realize->locx = separate->locx - 200.0f; | |||||
| realize->locy = join->locy; | |||||
| nodeAddLink(node_tree, group_input, group_input->outputs.first, realize, realize->inputs.first); | |||||
| nodeAddLink(node_tree, realize, realize->outputs.first, separate, separate->inputs.first); | |||||
| nodeAddLink(node_tree, separate, BLI_findlink(&separate->outputs, 2), join, join->inputs.first); | |||||
| nodeAddLink(node_tree, conv, conv->outputs.first, join, join->inputs.first); | |||||
| nodeAddLink(node_tree, separate, BLI_findlink(&separate->outputs, 1), conv, conv->inputs.first); | |||||
| nodeAddLink(node_tree, separate, BLI_findlink(&separate->outputs, 3), join, join->inputs.first); | |||||
| nodeAddLink(node_tree, separate, separate->outputs.first, join, join->inputs.first); | |||||
| nodeAddLink(node_tree, join, join->outputs.first, group_output, group_output->inputs.first); | |||||
| ntreeUpdateTree(bmain, node_tree); | |||||
| return node_tree; | |||||
| } | |||||
| void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) | void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) | ||||
| { | { | ||||
JacquesLucke: I think the flag is unnecessary. | |||||
Done Inline ActionsRight, good point, it was at one point but I forgot to remove it. HooglyBoogly: Right, good point, it was at one point but I forgot to remove it. | |||||
| if (MAIN_VERSION_ATLEAST(bmain, 300, 0) && !MAIN_VERSION_ATLEAST(bmain, 300, 1)) { | if (MAIN_VERSION_ATLEAST(bmain, 300, 0) && !MAIN_VERSION_ATLEAST(bmain, 300, 1)) { | ||||
| /* Set zero user text objects to have a fake user. */ | /* Set zero user text objects to have a fake user. */ | ||||
| LISTBASE_FOREACH (Text *, text, &bmain->texts) { | LISTBASE_FOREACH (Text *, text, &bmain->texts) { | ||||
| if (text->id.us == 0) { | if (text->id.us == 0) { | ||||
| id_fake_user_set(&text->id); | id_fake_user_set(&text->id); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { | ||||
| SOCK_MATERIAL)) { | SOCK_MATERIAL)) { | ||||
| link->tosock = link->tosock->next; | link->tosock = link->tosock->next; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 300, 33)) { | |||||
| /* Add a new modifier to realize instances from previous modifiers. | |||||
| * Previously that was done automatically by geometry nodes. */ | |||||
| LISTBASE_FOREACH (Object *, ob, &bmain->objects) { | |||||
| LISTBASE_FOREACH_MUTABLE (ModifierData *, md, &ob->modifiers) { | |||||
| if (md->type != eModifierType_Nodes) { | |||||
| continue; | |||||
| } | |||||
| if (md->next == NULL) { | |||||
| break; | |||||
| } | |||||
| if (md->next->type == eModifierType_Nodes) { | |||||
| continue; | |||||
| } | |||||
| NodesModifierData *nmd = (NodesModifierData *)md; | |||||
| if (nmd->node_group == NULL) { | |||||
| continue; | |||||
| } | |||||
| NodesModifierData *new_nmd = (NodesModifierData *)BKE_modifier_new(eModifierType_Nodes); | |||||
| BKE_modifier_unique_name(&ob->modifiers, &new_nmd->modifier); | |||||
| MOD_nodes_init(bmain, new_nmd); | |||||
| BLI_insertlinkafter(&ob->modifiers, md, new_nmd); | |||||
| new_nmd->node_group = add_realize_node_tree(bmain); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Versioning code until next subversion bump goes here. | * Versioning code until next subversion bump goes here. | ||||
| * | * | ||||
| * \note Be sure to check when bumping the version: | * \note Be sure to check when bumping the version: | ||||
| * - #blo_do_versions_300 in this file. | * - #blo_do_versions_300 in this file. | ||||
| * - "versioning_userdef.c", #blo_do_versions_userdef | * - "versioning_userdef.c", #blo_do_versions_userdef | ||||
| * - "versioning_userdef.c", #do_versions_theme | * - "versioning_userdef.c", #do_versions_theme | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 1,049 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { | ||||
| SpaceSeq *sseq = (SpaceSeq *)sl; | SpaceSeq *sseq = (SpaceSeq *)sl; | ||||
| sseq->timeline_overlay.flag |= SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG; | sseq->timeline_overlay.flag |= SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| // if (!MAIN_VERSION_ATLEAST(bmain, 300, 33)) { | |||||
| // LISTBASE_FOREACH (Object *, ob, &bmain->objects) { | |||||
| // LISTBASE_FOREACH_MUTABLE (ModifierData *, md, &ob->modifiers) { | |||||
| // if (md->type != eModifierType_Nodes) { | |||||
| // continue; | |||||
| // } | |||||
| // if (md->next == NULL) { | |||||
| // break; | |||||
| // } | |||||
| // if (md->next->type == eModifierType_Nodes) { | |||||
| // continue; | |||||
| // } | |||||
| // NodesModifierData *nmd = (NodesModifierData *)md; | |||||
| // if (nmd->node_group == NULL) { | |||||
| // continue; | |||||
| // } | |||||
| // NodesModifierData *new_nmd = (NodesModifierData *)BKE_modifier_new(eModifierType_Nodes); | |||||
| // BLI_insertlinkafter(&ob->modifiers, md, new_nmd); | |||||
| // new_nmd->node_group = add_realize_node_tree(bmain); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| /** | /** | ||||
| * Versioning code until next subversion bump goes here. | * Versioning code until next subversion bump goes here. | ||||
| * | * | ||||
| * \note Be sure to check when bumping the version: | * \note Be sure to check when bumping the version: | ||||
| * - "versioning_userdef.c", #blo_do_versions_userdef | * - "versioning_userdef.c", #blo_do_versions_userdef | ||||
| * - "versioning_userdef.c", #do_versions_theme | * - "versioning_userdef.c", #do_versions_theme | ||||
| * | * | ||||
| * \note Keep this message at the bottom of the function. | * \note Keep this message at the bottom of the function. | ||||
| */ | */ | ||||
| { | { | ||||
| /* Keep this block, even when empty. */ | /* Keep this block, even when empty. */ | ||||
| } | } | ||||
| } | } | ||||
I think the flag is unnecessary.