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-09-10 18:34:49 +0300
committerHans Goudey <h.goudey@me.com>2021-09-10 18:34:49 +0300
commite2f99c338bd5787658ce08984e6856b7d369a41f (patch)
tree02185bd4d123e1a52562214d836206ee10289e9a /source/blender/blenloader
parent128eb6cbe928e58dfee1c64f340fd8d663134c26 (diff)
Geometry Nodes: Add versioning to change legacy node ID names
Recently we have decided to avoid fancier versioning for nodes with string inputs for attribute names when updating the attribute workflow for 3.0. In that case we would just duplicate any node that will have an updated version to work with fields. We want to be able to use the "proper" ID names for the new versions of the nodes though, so this patch adds "Legacy" to the IDs of all nodes that will be replaced in 3.0. This commit also removes the nodes from the add menu when the fields experimental preference is enabled, in order to make it clear what has been updated and what hasn't. Nodes in the "Maybe" categories in versioning_300.c can be renamed later if necessary. For now it's probably better to be conservative, and to keep the list complete. Differential Revision: https://developer.blender.org/D12420
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c15
-rw-r--r--source/blender/blenloader/intern/versioning_300.c145
2 files changed, 152 insertions, 8 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 0e89c15ca1e..f023813555f 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1557,7 +1557,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
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) {
+ if (node->type == GEO_NODE_LEGACY_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");
@@ -1718,7 +1718,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
continue;
}
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type == GEO_NODE_POINT_INSTANCE && node->storage == NULL) {
+ if (node->type == GEO_NODE_LEGACY_POINT_INSTANCE && node->storage == NULL) {
NodeGeometryPointInstance *data = (NodeGeometryPointInstance *)MEM_callocN(
sizeof(NodeGeometryPointInstance), __func__);
data->instance_type = node->custom1;
@@ -1735,7 +1735,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_GEOMETRY) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type == GEO_NODE_ATTRIBUTE_MATH) {
+ if (node->type == GEO_NODE_LEGACY_ATTRIBUTE_MATH) {
NodeAttributeMath *data = (NodeAttributeMath *)node->storage;
data->input_type_c = GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE;
}
@@ -1794,7 +1794,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
continue;
}
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type == GEO_NODE_ATTRIBUTE_RANDOMIZE && node->storage == NULL) {
+ if (node->type == GEO_NODE_LEGACY_ATTRIBUTE_RANDOMIZE && node->storage == NULL) {
NodeAttributeRandomize *data = (NodeAttributeRandomize *)MEM_callocN(
sizeof(NodeAttributeRandomize), __func__);
data->data_type = node->custom1;
@@ -1830,7 +1830,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_GEOMETRY) {
- version_node_socket_name(ntree, GEO_NODE_ATTRIBUTE_PROXIMITY, "Result", "Distance");
+ version_node_socket_name(ntree, GEO_NODE_LEGACY_ATTRIBUTE_PROXIMITY, "Result", "Distance");
}
}
FOREACH_NODETREE_END;
@@ -1839,7 +1839,8 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 293, 10)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_GEOMETRY) {
- version_node_socket_name(ntree, GEO_NODE_ATTRIBUTE_PROXIMITY, "Location", "Position");
+ version_node_socket_name(
+ ntree, GEO_NODE_LEGACY_ATTRIBUTE_PROXIMITY, "Location", "Position");
}
}
FOREACH_NODETREE_END;
@@ -1933,7 +1934,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
if (ntree->type == NTREE_GEOMETRY) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type == GEO_NODE_ATTRIBUTE_FILL) {
+ if (node->type == GEO_NODE_LEGACY_ATTRIBUTE_FILL) {
node->custom2 = ATTR_DOMAIN_AUTO;
}
}
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index f050de6e6e9..d0b96957af5 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -446,7 +446,7 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports))
continue;
}
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (node->type != GEO_NODE_ATTRIBUTE_SAMPLE_TEXTURE) {
+ if (node->type != GEO_NODE_LEGACY_ATTRIBUTE_SAMPLE_TEXTURE) {
continue;
}
if (node->id == NULL) {
@@ -630,6 +630,141 @@ static bNodeSocket *do_version_replace_float_size_with_vector(bNodeTree *ntree,
return new_socket;
}
+static bool geometry_node_is_293_legacy(const short node_type)
+{
+ switch (node_type) {
+ /* Not legacy: No attribute inputs or outputs. */
+ case GEO_NODE_TRIANGULATE:
+ case GEO_NODE_EDGE_SPLIT:
+ case GEO_NODE_TRANSFORM:
+ case GEO_NODE_BOOLEAN:
+ case GEO_NODE_SUBDIVISION_SURFACE:
+ case GEO_NODE_IS_VIEWPORT:
+ case GEO_NODE_MESH_SUBDIVIDE:
+ case GEO_NODE_MESH_PRIMITIVE_CUBE:
+ case GEO_NODE_MESH_PRIMITIVE_CIRCLE:
+ case GEO_NODE_MESH_PRIMITIVE_UV_SPHERE:
+ case GEO_NODE_MESH_PRIMITIVE_CYLINDER:
+ case GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE:
+ case GEO_NODE_MESH_PRIMITIVE_CONE:
+ case GEO_NODE_MESH_PRIMITIVE_LINE:
+ case GEO_NODE_MESH_PRIMITIVE_GRID:
+ case GEO_NODE_BOUNDING_BOX:
+ case GEO_NODE_CURVE_RESAMPLE:
+ case GEO_NODE_INPUT_MATERIAL:
+ case GEO_NODE_MATERIAL_REPLACE:
+ case GEO_NODE_CURVE_LENGTH:
+ case GEO_NODE_CONVEX_HULL:
+ case GEO_NODE_SEPARATE_COMPONENTS:
+ case GEO_NODE_CURVE_PRIMITIVE_STAR:
+ case GEO_NODE_CURVE_PRIMITIVE_SPIRAL:
+ case GEO_NODE_CURVE_PRIMITIVE_QUADRATIC_BEZIER:
+ case GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT:
+ case GEO_NODE_CURVE_PRIMITIVE_CIRCLE:
+ case GEO_NODE_VIEWER:
+ case GEO_NODE_CURVE_PRIMITIVE_LINE:
+ case GEO_NODE_CURVE_PRIMITIVE_QUADRILATERAL:
+ case GEO_NODE_CURVE_FILL:
+ case GEO_NODE_CURVE_TRIM:
+ case GEO_NODE_CURVE_TO_MESH:
+ return false;
+
+ /* Not legacy: Newly added with fields patch. */
+ case GEO_NODE_INPUT_POSITION:
+ case GEO_NODE_SET_POSITION:
+ case GEO_NODE_INPUT_INDEX:
+ case GEO_NODE_INPUT_NORMAL:
+ case GEO_NODE_ATTRIBUTE_CAPTURE:
+ return false;
+
+ /* Maybe legacy: Might need special attribute handling, depending on design. */
+ case GEO_NODE_SWITCH:
+ case GEO_NODE_JOIN_GEOMETRY:
+ case GEO_NODE_ATTRIBUTE_REMOVE:
+ case GEO_NODE_OBJECT_INFO:
+ case GEO_NODE_COLLECTION_INFO:
+ return false;
+
+ /* Maybe legacy: Transfered *all* attributes before, will not transfer all built-ins now. */
+ case GEO_NODE_CURVE_ENDPOINTS:
+ case GEO_NODE_CURVE_TO_POINTS:
+ return false;
+
+ /* Maybe legacy: Special case for grid names? Or finish patch from level set branch to generate
+ * a mesh for all grids in the volume. */
+ case GEO_NODE_VOLUME_TO_MESH:
+ return false;
+
+ /* Legacy: Attribute operation completely replaced by field nodes. */
+ case GEO_NODE_LEGACY_ATTRIBUTE_RANDOMIZE:
+ case GEO_NODE_LEGACY_ATTRIBUTE_MATH:
+ case GEO_NODE_LEGACY_ATTRIBUTE_FILL:
+ case GEO_NODE_LEGACY_ATTRIBUTE_MIX:
+ case GEO_NODE_LEGACY_ATTRIBUTE_COLOR_RAMP:
+ case GEO_NODE_LEGACY_ATTRIBUTE_COMPARE:
+ case GEO_NODE_LEGACY_POINT_ROTATE:
+ case GEO_NODE_LEGACY_ALIGN_ROTATION_TO_VECTOR:
+ case GEO_NODE_LEGACY_POINT_SCALE:
+ case GEO_NODE_LEGACY_ATTRIBUTE_SAMPLE_TEXTURE:
+ case GEO_NODE_ATTRIBUTE_VECTOR_ROTATE:
+ case GEO_NODE_LEGACY_ATTRIBUTE_CURVE_MAP:
+ case GEO_NODE_LEGACY_ATTRIBUTE_MAP_RANGE:
+ case GEO_NODE_LECAGY_ATTRIBUTE_CLAMP:
+ case GEO_NODE_LEGACY_ATTRIBUTE_VECTOR_MATH:
+ case GEO_NODE_LEGACY_ATTRIBUTE_COMBINE_XYZ:
+ case GEO_NODE_LEGACY_ATTRIBUTE_SEPARATE_XYZ:
+ return true;
+
+ /* Legacy: Replaced by field node depending on another geometry. */
+ case GEO_NODE_LEGACY_RAYCAST:
+ case GEO_NODE_LEGACY_ATTRIBUTE_TRANSFER:
+ case GEO_NODE_LEGACY_ATTRIBUTE_PROXIMITY:
+ return true;
+
+ /* Legacy: Simple selection attribute input. */
+ case GEO_NODE_LEGACY_MESH_TO_CURVE:
+ case GEO_NODE_LEGACY_POINT_SEPARATE:
+ case GEO_NODE_LEGACY_CURVE_SELECT_HANDLES:
+ case GEO_NODE_LEGACY_CURVE_SPLINE_TYPE:
+ case GEO_NODE_LEGACY_CURVE_REVERSE:
+ case GEO_NODE_LEGACY_MATERIAL_ASSIGN:
+ case GEO_NODE_LEGACY_CURVE_SET_HANDLES:
+ return true;
+
+ /* Legacy: More complex attribute inputs or outputs. */
+ case GEO_NODE_LEGACY_DELETE_GEOMETRY: /* Needs field input, domain dropdown. */
+ case GEO_NODE_LEGACY_CURVE_SUBDIVIDE: /* Needs field count input. */
+ case GEO_NODE_LEGACY_POINTS_TO_VOLUME: /* Needs field radius input. */
+ case GEO_NODE_LEGACY_SELECT_BY_MATERIAL: /* Output anonymous attribute. */
+ case GEO_NODE_LEGACY_POINT_TRANSLATE: /* Needs field inputs. */
+ case GEO_NODE_LEGACY_POINT_INSTANCE: /* Needs field inputs. */
+ case GEO_NODE_LEGACY_POINT_DISTRIBUTE: /* Needs field input, remove max for random mode. */
+ case GEO_NODE_LEGACY_ATTRIBUTE_CONVERT: /* Attribute Capture, Store Attribute. */
+ return true;
+ }
+ return false;
+}
+
+static void version_geometry_nodes_change_legacy_names(bNodeTree *ntree)
+{
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (geometry_node_is_293_legacy(node->type)) {
+ if (strstr(node->idname, "Legacy")) {
+ /* Make sure we haven't changed this idname already, better safe than sorry. */
+ continue;
+ }
+
+ char temp_idname[sizeof(node->idname)];
+ BLI_strncpy(temp_idname, node->idname, sizeof(node->idname));
+
+ BLI_snprintf(node->idname,
+ sizeof(node->idname),
+ "GeometryNodeLegacy%s",
+ temp_idname + strlen("GeometryNode"));
+ }
+ }
+}
+
/* NOLINTNEXTLINE: readability-function-size */
void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
@@ -1084,6 +1219,14 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 300, 21)) {
+ LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
+ if (ntree->type == NTREE_GEOMETRY) {
+ version_geometry_nodes_change_legacy_names(ntree);
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*