9#define DNA_DEPRECATED_ALLOW
11#include <fmt/format.h>
14#define DNA_GENFILE_VERSIONING_MACROS
25#undef DNA_GENFILE_VERSIONING_MACROS
118 auto mix_to_strength = [](
const float mix) {
return 1.0f -
math::clamp(-
mix, 0.0f, 1.0f); };
127 render_size =
int2(1920, 1080);
132 auto size_to_linear = [&](
const int size) {
136 return math::min(1.0f,
float((1 << size) + 1) /
float(max_render_size));
150 char escaped_node_name[
sizeof(
node->name) * 2 + 1];
152 const std::string node_rna_path = fmt::format(
"nodes[\"{}\"]", escaped_node_name);
157 if (!fcurve->rna_path().startswith(node_rna_path)) {
164 fcurve->rna_path_set_move(
165 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[1].default_value"));
168 fcurve->rna_path_set_move(
169 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[2].default_value"));
170 adjust_fcurve_key_frame_values(
171 fcurve, PROP_FLOAT, [&](const float value) { return mix_to_strength(value); });
174 fcurve->rna_path_set_move(
175 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[3].default_value"));
176 adjust_fcurve_key_frame_values(
177 fcurve,
PROP_FLOAT, [&](
const float value) {
return size_to_linear(value); });
180 fcurve->rna_path_set_move(
181 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[4].default_value"));
184 fcurve->rna_path_set_move(
185 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[5].default_value"));
188 fcurve->rna_path_set_move(
189 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[6].default_value"));
192 fcurve->rna_path_set_move(
193 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[7].default_value"));
195 else if (
BLI_str_endswith(fcurve->rna_path().c_str(),
"color_modulation")) {
196 fcurve->rna_path_set_move(
197 BLI_sprintfN(
"%s.%s", node_rna_path.c_str(),
"inputs[8].default_value"));
205 node_tree,
node, SOCK_OUT, SOCK_RGBA, PROP_NONE,
"Image",
"Image");
207 node_tree,
node, SOCK_OUT, SOCK_RGBA, PROP_NONE,
"Glare",
"Glare");
209 for (bNodeLink &link : node_tree->links.items_reversed_mutable()) {
210 if (link.fromsock != image_output) {
215 bke::node_add_link(*node_tree, *
node, *glare_output, *link.tonode, *link.tosock);
216 bke::node_remove_link(node_tree, link);
224 if (node_trees_already_versioned.
contains(node_tree)) {
232 else if (
node.is_group()) {
236 scene, child_tree, node_trees_already_versioned);
241 node_trees_already_versioned.
add_new(node_tree);
262 const int quality_factor = 1 <<
storage->quality;
271 render_size =
int2(1920, 1080);
274 const int2 highlights_size = render_size / quality_factor;
282 const float scaled_dimension = smaller_dimension * size_value;
283 const int chain_length = int(std::log2(
math::max(1.0f, scaled_dimension)));
285 auto scale_strength = [chain_length](
const float strength) {
return strength * chain_length; };
293 char escaped_node_name[
sizeof(
node->name) * 2 + 1];
295 const std::string strength_rna_path = fmt::format(
"nodes[\"{}\"].inputs[4].default_value",
300 if (strength_rna_path == fcurve->rna_path()) {
301 adjust_fcurve_key_frame_values(
302 fcurve, PROP_FLOAT, [&](const float value) { return scale_strength(value); });
310 if (node_trees_already_versioned.
contains(node_tree)) {
318 else if (
node.is_group()) {
322 scene, child_tree, node_trees_already_versioned);
327 node_trees_already_versioned.
add_new(node_tree);
339 for (
bNodeLink &link : node_tree->
links.items_reversed_mutable()) {
360 dot_product_node->
location[0] = link.fromnode->location[0] + link.fromnode->width + 10.0f;
361 dot_product_node->
location[1] = link.fromnode->location[1];
365 *dot_product_node,
SOCK_IN,
"Vector"_ustr);
367 *node_tree, *link.fromnode, *link.fromsock, *dot_product_node, *dot_product_a_input);
371 *dot_product_node,
SOCK_IN,
"Vector_001"_ustr);
377 *dot_product_node,
SOCK_OUT,
"Value"_ustr);
379 *node_tree, *dot_product_node, *dot_product_output, *link.tonode, *link.tosock);
382 color_to_float_links.
add_new(link.fromsock, output_link);
397 if (filter_width_input) {
412 constexpr char SCE_SNAP_TO_NODE_X = (1 << 0);
413 constexpr char SCE_SNAP_TO_NODE_Y = (1 << 1);
431 &scene, node_tree, node_trees_already_versioned);
439 if (node_trees_already_versioned.
contains(&node_tree)) {
448 node_trees_already_versioned.
add_new(&node_tree);
470 &scene, node_tree, node_trees_already_versioned);
478 if (node_trees_already_versioned.
contains(&node_tree)) {
487 node_trees_already_versioned.
add_new(&node_tree);
496 auto replace_rna_path_prefix =
499 if (!
rna_path.startswith(old_prefix)) {
504 fcurve.rna_path_set_move(new_rna_path);
508 replace_rna_path_prefix(fcurve,
"sequence_editor.sequences",
"sequence_editor.strips");
512 replace_rna_path_prefix(driver,
"sequence_editor.sequences",
"sequence_editor.strips");
575 for (
bNode *triangulate : triangulate_nodes) {
583 if (!input_links.
contains(min_verts) && old_min_verts <= 4) {
597 corners_of_face.
locx_legacy = triangulate->locx_legacy - 200;
598 corners_of_face.
locy_legacy = triangulate->locy_legacy - 50;
599 corners_of_face.
parent = triangulate->parent;
610 auto *compare_storage = MEM_new<NodeFunctionCompare>(__func__);
612 compare_storage->data_type =
SOCK_INT;
613 greater_or_equal.
storage = compare_storage;
620 greater_or_equal.
locx_legacy = triangulate->locx_legacy - 100;
621 greater_or_equal.
locy_legacy = triangulate->locy_legacy - 50;
622 greater_or_equal.
parent = triangulate->parent;
630 (*min_verts_link)->tonode = &greater_or_equal;
635 *&greater_or_equal,
SOCK_IN,
"B_INT"_ustr);
647 boolean_and.
locx_legacy = triangulate->locx_legacy - 75;
648 boolean_and.
locy_legacy = triangulate->locy_legacy - 50;
649 boolean_and.
parent = triangulate->parent;
653 (*selection_link)->tonode = &boolean_and;
687 data->lacunarity = 2.0f;
688 data->roughness = 0.5f;
689 data->legacy_noise =
true;
696 node.location[0] =
node.locx_legacy;
697 node.location[1] =
node.locy_legacy;
698 for (
const bNode *parent =
node.parent; parent; parent = parent->parent) {
699 node.location[0] += parent->locx_legacy;
700 node.location[1] += parent->locy_legacy;
703 node.location[0] +=
node.offsetx_legacy;
704 node.location[1] +=
node.offsety_legacy;
705 node.offsetx_legacy = 0.0f;
706 node.offsety_legacy = 0.0f;
718 if (!
node.is_group_input()) {
722 switch (socket.
type) {
755 if (
STREQ(
node.idname,
"GeometryNodeInputNormal")) {
867 if (prop_name.
endswith(
"_attribute_name") || prop_name.
endswith(
"_use_attribute")) {
909 if (!DNA_struct_member_exists(
910 fd->
filesdna,
"RenderData",
"RenderSettings",
"compositor_denoise_preview_quality"))
916 if (!DNA_struct_member_exists(
917 fd->
filesdna,
"RenderData",
"RenderSettings",
"compositor_denoise_final_quality"))
938 if (!DNA_struct_member_exists(fd->
filesdna,
"Curves",
"float",
"surface_collision_distance")) {
940 curves.surface_collision_distance = 0.005f;
952 const Brush default_brush;
954 if ((
brush.mask_stencil_dimension[0] == 0) && (
brush.mask_stencil_dimension[1] == 0)) {
958 if ((
brush.mask_stencil_pos[0] == 0) && (
brush.mask_stencil_pos[1] == 0)) {
995 for (
ARegion ®ion : *regionbase) {
Functions and classes to work with Actions.
Functionality to iterate an Action in various ways.
Versioning of old animation data. Most animation versioning code lives in the versioning_xxx....
#define FOREACH_MAIN_ID_END
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
#define FOREACH_NODETREE_END
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
#define GEO_NODE_TRIANGULATE
#define SH_NODE_MIX_SHADER
#define GEO_NODE_SUBDIVISION_SURFACE
#define SH_NODE_VECTOR_MATH
#define STRNCPY_UTF8(dst, src)
blenloader genfile private function prototypes
const Value * lookup_ptr(const Key &key) const
Value lookup_default(const Key &key, const Value &default_value) const
void add_new(const Key &key, const Value &value)
bool contains(const Key &key) const
bool contains(const Key &key) const
void add_new(const Key &key)
constexpr const char * data() const
constexpr bool endswith(StringRef suffix) const
#define storage(slot, qualifiers)
void convert_legacy_action_assignments(Main &bmain, ReportList *reports)
void convert_legacy_animato_actions(Main &bmain)
void tag_action_users_for_slotted_actions_conversion(Main &bmain)
void foreach_fcurve_in_action(Action &action, FunctionRef< void(FCurve &fcurve)> callback)
void node_remove_socket(bNodeTree &ntree, bNode &node, bNodeSocket &sock)
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
T pow(const T &x, const T &power)
T clamp(const T &a, const T &min, const T &max)
T reduce_max(const VecBase< T, Size > &a)
T reduce_min(const VecBase< T, Size > &a)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Editing * editing_get(const Scene *scene)
SequencerToolSettings * tool_settings_ensure(Scene *scene)
static void do_version_glare_node_bloom_strength_recursive(const Scene *scene, bNodeTree *node_tree, Set< bNodeTree * > &node_trees_already_versioned)
@ SCE_COMPOSITOR_DENOISE_BALANCED
@ SCE_COMPOSITOR_DENOISE_HIGH
static void add_subsurf_node_limit_surface_option(Main &bmain)
static void do_version_glare_node_options_to_inputs(const Scene *scene, bNodeTree *node_tree, bNode *node)
static void do_version_glare_node_options_to_inputs_recursive(const Scene *scene, bNodeTree *node_tree, Set< bNodeTree * > &node_trees_already_versioned)
static void version_geometry_normal_input_node(bNodeTree &ntree)
int bool bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1
static void do_version_color_to_float_conversion(bNodeTree *node_tree)
void BKE_fcurves_id_cb(struct ID *id, FunctionRef< void(ID *, FCurve *)> func)
@ FILE_SORT_ASSET_CATALOG
char * BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void version_cycles_property_boolean_set(IDProperty *idprop, const char *name, bool value)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
static void version_group_input_socket_data_block_reference(bNodeTree &ntree)
float * version_cycles_node_socket_float_value(bNodeSocket *socket)
static void do_version_bump_filter_width(bNodeTree *node_tree)
bNode & version_node_add_empty(bNodeTree &ntree, const char *idname)
void BKE_render_resolution(const RenderData *r, const bool use_crop, int *r_width, int *r_height)
int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
AnimData * BKE_animdata_from_id(const ID *id)
void version_node_socket_identifier_set(bNodeSocket &socket, const StringRefNull identifier)
void do_versions_after_linking_404(FileData *fd, Main *bmain)
VecBase< int32_t, 2 > int2
static bool versioning_convert_seq_text_anchor(Strip *strip, void *)
@ IDP_FLAG_OVERRIDABLE_LIBRARY
BMesh const char void * data
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
static void do_version_viewer_shortcut(bNodeTree *node_tree)
void version_cycles_property_int_set(IDProperty *idprop, const char *name, int value)
static void remove_triangulate_node_min_size_input(bNodeTree *tree)
@ NODE_COMPARE_GREATER_EQUAL
static void do_version_glare_node_bloom_strength(const Scene *scene, bNodeTree *node_tree, bNode *node)
static void version_node_locations_to_global(bNodeTree &ntree)
@ V2D_SCROLL_VERTICAL_HIDE
MINLINE void copy_v3_fl(float r[3], float f)
@ NODE_VIEWER_SHORTCUT_NONE
IDProperty * version_cycles_properties_from_ID(ID *id)
@ NODE_VECTOR_MATH_DOT_PRODUCT
void blo_do_versions_404(FileData *fd, Library *lib, Main *bmain)
static bool versioning_clear_strip_unused_flag(Strip *strip, void *)
void version_node_socket_index_animdata(Main *bmain, const int node_tree_type, const int node_type, const int socket_index_orig, const int socket_index_offset, const int total_number_of_sockets)
bNodeLink & version_node_add_link(bNodeTree &ntree, bNode &node_a, bNodeSocket &socket_a, bNode &node_b, bNodeSocket &socket_b)
bNodeSocket * version_node_add_socket_if_not_exist(bNodeTree *ntree, bNode *node, int in_out, int type, int subtype, const char *identifier, const char *name)
static void version_fcurve_noise_modifier(FCurve &fcurve)
ListBaseT< FCurve > drivers
float mask_stencil_dimension[2]
float mask_stencil_pos[2]
ListBaseT< FModifier > modifiers
FileSelectParams base_params
BlendFileReadReport * reports
std::unique_ptr< SDNA > filesdna
ListBaseT< struct IDProperty > group
ListBaseT< bNodeTree > nodetrees
ListBaseT< Curves > hair_curves
ListBaseT< Brush > brushes
ListBaseT< Object > objects
ListBaseT< WorkSpace > workspaces
ListBaseT< bAction > actions
ListBaseT< Scene > scenes
ListBaseT< bScreen > screens
struct NodesModifierSettings settings_legacy
struct IDProperty * properties
eCompositorDenoiseQaulity compositor_denoise_preview_quality
eCompositorDenoiseQaulity compositor_denoise_final_quality
DNA_DEPRECATED struct bNodeTree * nodetree
struct ToolSettings * toolsettings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
FileAssetSelectParams * asset_params
ListBaseT< ARegion > regionbase
ListBaseT< bToolRef > tools
ListBaseT< bNodeLink > links
ListBaseT< bNodeSocket > outputs
ListBaseT< bNodeSocket > inputs
ListBaseT< struct ScrArea > areabase