From 5f7ca5462d31ff56f16016d5f9e6a5489b30a05e Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 2 Nov 2022 12:29:01 +0100 Subject: Geometry Nodes: Add index and value inputs to sample curve node As described in T92474 and T91650, this patch adds two features to the sample curve node. First is an index input, to allow choosing the curve to sample for each point. Second is a custom field input, which is evaluated on the control points of the curve and then sampled like the other outputs. There is an "All Curves" option for the old behavior which takes the length of all curves into account. For invalid curve indices, the node outputs zeros (default values). Invalid lengths and factors are clamped. There have been various discussions about splitting the node up more, but this is an intuitive combination of options and will work well enough for current use cases. The node could still be generalized more in the future. Keep in mind that the source field is evaluated on curve control points, not the evaluated points used for sampling. This is necessary so that fields like "Index" work as expected. Differential Revision: https://developer.blender.org/D16147 --- source/blender/blenloader/intern/versioning_300.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index a2bd7fd2fd1..65094655cfe 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3653,6 +3653,25 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 304, 6)) { + LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { + if (ntree->type != NTREE_GEOMETRY) { + continue; + } + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type != GEO_NODE_SAMPLE_CURVE) { + continue; + } + static_cast(node->storage)->use_all_curves = true; + static_cast(node->storage)->data_type = CD_PROP_FLOAT; + bNodeSocket *curve_socket = nodeFindSocket(node, SOCK_IN, "Curve"); + BLI_assert(curve_socket != nullptr); + STRNCPY(curve_socket->name, "Curves"); + STRNCPY(curve_socket->identifier, "Curves"); + } + } + } + /** * Versioning code until next subversion bump goes here. * -- cgit v1.2.3