Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/versioning_common.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup blenloader | * \ingroup blenloader | ||||
| */ | */ | ||||
| /* allow readfile to use deprecated functionality */ | /* allow readfile to use deprecated functionality */ | ||||
| #define DNA_DEPRECATED_ALLOW | #define DNA_DEPRECATED_ALLOW | ||||
| #include <cstring> | #include <cstring> | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "BLI_array.hh" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_index_range.hh" | |||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_string_ref.hh" | #include "BLI_string_ref.hh" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_attribute_math.hh" | |||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "versioning_common.h" | #include "versioning_common.h" | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| ARegion *do_versions_add_region(int regiontype, const char *name) | ARegion *do_versions_add_region(int regiontype, const char *name) | ||||
| { | { | ||||
| ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), name); | ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), name); | ||||
| region->regiontype = regiontype; | region->regiontype = regiontype; | ||||
| return region; | return region; | ||||
| } | } | ||||
| /* In_Out : true - input, false - output. */ | |||||
| void socket_naming_attribute_defualt(bNodeSocket *socket, int node_type, bool in_out) | |||||
| { | |||||
| switch (node_type) { | |||||
| case (GEO_NODE_CAPTURE_ATTRIBUTE): { | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::float3>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<float>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>().copy(socket->identifier, | |||||
| 64); | |||||
| socket = socket->next; | |||||
HooglyBoogly: I think this is a prefix rather than a suffix | |||||
| blender::attribute_math::default_name<bool>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<int>().copy(socket->identifier, 64); | |||||
| break; | |||||
| } | |||||
| case (GEO_NODE_INPUT_NAMED_ATTRIBUTE): { | |||||
| if (!in_out) { | |||||
| blender::attribute_math::default_name<blender::float3>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<float>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>().copy(socket->identifier, | |||||
| 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<bool>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<int>().copy(socket->identifier, 64); | |||||
| } | |||||
| break; | |||||
| } | |||||
| case (GEO_NODE_FIELD_ON_DOMAIN): { | |||||
| blender::attribute_math::default_name<float>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<int>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::float3>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>().copy(socket->identifier, | |||||
| 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<bool>().copy(socket->identifier, 64); | |||||
| break; | |||||
| } | |||||
| case (GEO_NODE_FIELD_AT_INDEX): { | |||||
| if (in_out) { | |||||
| socket = socket->next; | |||||
| } | |||||
| blender::attribute_math::default_name<float>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<int>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::float3>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>().copy(socket->identifier, | |||||
| 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<bool>().copy(socket->identifier, 64); | |||||
| break; | |||||
| } | |||||
| case (GEO_NODE_TRANSFER_ATTRIBUTE): { | |||||
| if (in_out) { | |||||
| socket = socket->next; | |||||
| } | |||||
| blender::attribute_math::default_name<blender::float3>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<float>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>().copy(socket->identifier, | |||||
| 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<bool>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<int>().copy(socket->identifier, 64); | |||||
| break; | |||||
| } | |||||
| case (GEO_NODE_RAYCAST): { | |||||
| socket = socket->next; | |||||
| if (!in_out) { | |||||
| socket = socket->next->next->next; | |||||
| } | |||||
| blender::attribute_math::default_name<blender::float3>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<float>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>().copy(socket->identifier, | |||||
| 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<bool>().copy(socket->identifier, 64); | |||||
| socket = socket->next; | |||||
| blender::attribute_math::default_name<int>().copy(socket->identifier, 64); | |||||
| break; | |||||
| } | |||||
| default: { | |||||
| } | |||||
| } | |||||
| } | |||||
| template<bNodeSocket *(next)(bNodeSocket *)> | |||||
| void version_node_switch_sockets_naming_attribute_defualt(bNodeSocket *socket, std::string prefix) | |||||
| { | |||||
| blender::Array<std::string> names({ | |||||
| blender::attribute_math::default_name<float>(), | |||||
| blender::attribute_math::default_name<int>(), | |||||
| blender::attribute_math::default_name<bool>(), | |||||
| blender::attribute_math::default_name<blender::float3>(), | |||||
| blender::attribute_math::default_name<blender::ColorGeometry4f>(), | |||||
| blender::attribute_math::default_name<std::string>(), | |||||
| "Geometry", | |||||
| "Object", | |||||
| "Collection", | |||||
| "Texture", | |||||
| "Material", | |||||
| "Image", | |||||
| }); | |||||
| for (const int index : blender::IndexRange(names.size() - 1)) { | |||||
| std::string new_socket_name = prefix + names[index]; | |||||
| STRNCPY(socket->identifier, new_socket_name.c_str()); | |||||
| socket = next(socket); | |||||
| } | |||||
| std::string new_socket_name = prefix + names[names.size() - 1]; | |||||
| STRNCPY(socket->identifier, new_socket_name.c_str()); | |||||
| } | |||||
| void version_node_socket_naming_attribute_defualt_input(bNodeSocket *socket, int node_type) | |||||
| { | |||||
| if (node_type == GEO_NODE_SWITCH) { | |||||
| STRNCPY(socket->identifier, "Switch_Field"); | |||||
| socket = socket->next; | |||||
| STRNCPY(socket->identifier, "Switch_Single"); | |||||
| socket = socket->next; | |||||
| version_node_switch_sockets_naming_attribute_defualt<[](bNodeSocket *in) { | |||||
| return in->next->next; | |||||
| }>(socket, "False_"); | |||||
| version_node_switch_sockets_naming_attribute_defualt<[](bNodeSocket *in) { | |||||
| return in->next->next; | |||||
| }>(socket->next, "True_"); | |||||
| } | |||||
| else { | |||||
| socket_naming_attribute_defualt(socket, node_type, true); | |||||
| } | |||||
| } | |||||
| void version_node_socket_naming_attribute_defualt_output(bNodeSocket *socket, int node_type) | |||||
| { | |||||
| if (node_type == GEO_NODE_SWITCH) { | |||||
| version_node_switch_sockets_naming_attribute_defualt<[](bNodeSocket *in) { return in->next; }>( | |||||
| socket, ""); | |||||
| } | |||||
| else { | |||||
| socket_naming_attribute_defualt(socket, node_type, false); | |||||
| } | |||||
| } | |||||
I think this is a prefix rather than a suffix