Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_300.c
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| static void add_realize_instances_and_point_conversion_before_socket(bNodeTree *ntree, | |||||
| bNode *group_output, | |||||
| bNodeSocket *geometry_socket) | |||||
| { | |||||
| /* Move the original output node to the right to make space for the new nodes. */ | |||||
| group_output->locx += 750.0f; | |||||
| bNodeLink *link_orig = find_connected_link(ntree, geometry_socket); | |||||
| if (link_orig == NULL) { | |||||
| return; | |||||
| } | |||||
| bNode *join = nodeAddStaticNode(NULL, ntree, GEO_NODE_JOIN_GEOMETRY); | |||||
| join->parent = group_output->parent; | |||||
| join->locx = group_output->locx - 175.0f; | |||||
| join->locy = group_output->locy; | |||||
| bNode *conv = nodeAddStaticNode(NULL, ntree, GEO_NODE_POINTS_TO_VERTICES); | |||||
| conv->parent = group_output->parent; | |||||
| conv->locx = join->locx - 175.0f; | |||||
| conv->locy = join->locy - 70.0; | |||||
| bNode *separate = nodeAddStaticNode(NULL, ntree, GEO_NODE_SEPARATE_COMPONENTS); | |||||
| separate->parent = group_output->parent; | |||||
| separate->locx = join->locx - 350.0f; | |||||
| separate->locy = join->locy + 50.0f; | |||||
| bNode *realize = nodeAddStaticNode(NULL, ntree, GEO_NODE_REALIZE_INSTANCES); | |||||
| realize->parent = group_output->parent; | |||||
| realize->locx = separate->locx - 200.0f; | |||||
| realize->locy = join->locy; | |||||
| nodeAddLink(ntree, realize, realize->outputs.first, separate, separate->inputs.first); | |||||
| nodeAddLink(ntree, separate, BLI_findlink(&separate->outputs, 2), join, join->inputs.first); | |||||
| nodeAddLink(ntree, conv, conv->outputs.first, join, join->inputs.first); | |||||
| nodeAddLink(ntree, separate, BLI_findlink(&separate->outputs, 1), conv, conv->inputs.first); | |||||
| nodeAddLink(ntree, separate, BLI_findlink(&separate->outputs, 3), join, join->inputs.first); | |||||
| nodeAddLink(ntree, separate, separate->outputs.first, join, join->inputs.first); | |||||
| nodeAddLink(ntree, join, join->outputs.first, group_output, geometry_socket); | |||||
| link_orig->tonode = realize; | |||||
| link_orig->tosock = realize->inputs.first; | |||||
| } | |||||
| /** | |||||
| * 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 void version_geometry_nodes_add_modifier_realize_instance_nodes(bNodeTree *ntree) | |||||
| { | |||||
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. | |||||
| LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) { | |||||
| if (node->type == NODE_GROUP_OUTPUT) { | |||||
| LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) { | |||||
| if (socket->type == SOCK_GEOMETRY) { | |||||
| add_realize_instances_and_point_conversion_before_socket(ntree, node, socket); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) | void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports)) | ||||
| { | { | ||||
| 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)) { | ||||
| Context not available. | |||||
| do_versions_idproperty_ui_data(bmain); | do_versions_idproperty_ui_data(bmain); | ||||
| } | } | ||||
| if (!MAIN_VERSION_ATLEAST(bmain, 300, 32)) { | |||||
| LISTBASE_FOREACH (Object *, ob, &bmain->objects) { | |||||
| LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) { | |||||
| if (md->type == eModifierType_Nodes) { | |||||
| NodesModifierData *nmd = (NodesModifierData *)md; | |||||
| if (nmd->node_group != NULL) { | |||||
| version_geometry_nodes_add_modifier_realize_instance_nodes(nmd->node_group); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Versioning code until next subversion bump goes here. | * Versioning code until next subversion bump goes here. | ||||
| * | * | ||||
| Context not available. | |||||
I think the flag is unnecessary.