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-04-02 22:35:48 +0300
committerHans Goudey <h.goudey@me.com>2021-04-02 22:35:48 +0300
commit46d75052eb08cd904a42882030ca5c8718ee04ee (patch)
treef87b2f0229b563a41cc0ad86843db21372d178c9 /source/blender/blenloader/intern/versioning_290.c
parente0a07700bfbe3a4d64e65d0d51adb8c44ef105d7 (diff)
Geometry Nodes: Separate grid primitive X and Y size
Since you can already specify a separate size for X and Y with the grid node, it makes sense to be able to specify the size separately for each axis also. This also avoids some awkward math with a Transform node afterwards when you want a specific size for each direction. Versioning (except for animation and drivers) is handled in this commit. Differential Revision: https://developer.blender.org/D10834
Diffstat (limited to 'source/blender/blenloader/intern/versioning_290.c')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 0d59845e934..c9f93d35eb3 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -379,6 +379,37 @@ static void seq_update_meta_disp_range(Editing *ed)
}
}
+static void version_node_socket_duplicate(bNodeTree *ntree,
+ const int node_type,
+ const char *old_name,
+ const char *new_name)
+{
+ /* Duplicate a link going into the original socket. */
+ LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
+ if (link->tonode->type == node_type) {
+ bNode *node = link->tonode;
+ bNodeSocket *dest_socket = nodeFindSocket(node, SOCK_IN, new_name);
+ BLI_assert(dest_socket);
+ if (STREQ(link->tosock->name, old_name)) {
+ nodeAddLink(ntree, link->fromnode, link->fromsock, node, dest_socket);
+ }
+ }
+ }
+
+ /* Duplicate the default value from the old socket and assign it to the new socket. */
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (node->type == node_type) {
+ bNodeSocket *source_socket = nodeFindSocket(node, SOCK_IN, old_name);
+ bNodeSocket *dest_socket = nodeFindSocket(node, SOCK_IN, new_name);
+ BLI_assert(source_socket && dest_socket);
+ if (dest_socket->default_value) {
+ MEM_freeN(dest_socket->default_value);
+ }
+ dest_socket->default_value = MEM_dupallocN(source_socket->default_value);
+ }
+ }
+}
+
void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
{
if (!MAIN_VERSION_ATLEAST(bmain, 290, 1)) {
@@ -641,6 +672,20 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 293, 16)) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ seq_update_meta_disp_range(SEQ_editing_get(scene, false));
+ }
+
+ /* Add a separate socket for Grid node X and Y size. */
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_GEOMETRY) {
+ version_node_socket_duplicate(ntree, GEO_NODE_MESH_PRIMITIVE_GRID, "Size X", "Size Y");
+ }
+ FOREACH_NODETREE_END;
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -653,10 +698,6 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
*/
{
/* Keep this block, even when empty. */
-
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
- seq_update_meta_disp_range(SEQ_editing_get(scene, false));
- }
}
}
@@ -1939,6 +1980,15 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 293, 16)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_GEOMETRY) {
+ version_node_socket_name(ntree, GEO_NODE_MESH_PRIMITIVE_GRID, "Size", "Size X");
+ }
+ FOREACH_NODETREE_END;
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*