Versioning function to replace legacy instancing panel by geometry node modifier #105494

Open
Iliya Katushenock wants to merge 44 commits from mod_moder/blender:instances into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 30 additions and 11 deletions
Showing only changes of commit 2880c19713 - Show all commits

View File

@ -247,7 +247,7 @@ void IDP_ClearProperty(struct IDProperty *prop);
void IDP_Reset(struct IDProperty *prop, const struct IDProperty *reference);
#define IDP_Int(prop) ((prop)->data.val)
#define IDP_Bool(prop) ((prop)->data.val)
#define IDP_Bool(prop) (*(bool *)&(prop)->data.val)
#define IDP_Array(prop) ((prop)->data.pointer)
/* C11 const correctness for casts */
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)

View File

@ -1,3 +1,6 @@
#if !defined(NOMINMAX)
# define NOMINMAX
#endif
/* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once

View File

@ -9,6 +9,11 @@
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"
#ifdef __cplusplus
# include "BLI_span.hh"
#endif
#include "DNA_listBase.h"
// struct ListBase;
// struct LinkData;
@ -389,4 +394,15 @@ BLI_INLINE bool operator==(const ListBase &a, const ListBase &b)
{
return BLI_listbase_equal(&a, &b);
}
namespace blender {
template<typename ItemT> void span_to_list(MutableSpan<ItemT> &src, ListBase &dst)
{
for (ItemT &item : src) {
BLI_addtail(&dst, &item);
}
}
} // namespace blender
#endif

View File

@ -164,6 +164,9 @@ loop:
}
}
#undef min
#undef swapcode
/* clang-format on */
#endif /* __GLIBC__ */

View File

@ -1244,25 +1244,25 @@ static bNodeTree *instances_on_faces(const Span<Object *> objects,
return node_tree;
}
static void copy_value_rna_to_id(PropertyRNA &src_prop, PointerRNA &src_ptr, IDProperty &dst)
static void copy_rna_to_id(PropertyRNA &src_prop, PointerRNA &src_ptr, IDProperty &dst)
{
switch (IDP_ui_data_type(&dst)) {
case IDP_UI_DATA_TYPE_INT: {
const int values = RNA_property_int_get(&src_ptr, &src_prop);
*reinterpret_cast<int *>(&IDP_Int(&dst)) = values;
IDP_Int(&dst) = values;
break;
}
case IDP_UI_DATA_TYPE_FLOAT: {
const int values = RNA_property_float_get(&src_ptr, &src_prop);
*reinterpret_cast<float *>(&IDP_Float(&dst)) = values;
IDP_Float(&dst) = values;
break;
}
case IDP_UI_DATA_TYPE_BOOLEAN: {
const bool values = RNA_property_boolean_get(&src_ptr, &src_prop);
*reinterpret_cast<bool *>(&IDP_Bool(&dst)) = values;
IDP_Bool(&dst) = values;
break;
}
case default:
default:
BLI_assert_unreachable();
break;
}
@ -1316,7 +1316,7 @@ static void object_push_instances_modifier(const StringRefNull name,
PropertyRNA *obkect_prop = RNA_struct_find_property(&object_ptr, legacy_prop_name.data());
BLI_assert(obkect_prop != nullptr);
copy_value_rna_to_id(*obkect_prop, object_ptr, *dst);
copy_rna_to_id(*obkect_prop, object_ptr, *dst);
std::string new_rna_path = "modifiers[\"" + std::string(name) + "\"][\"" +
std::string(socket->identifier) + "\"]";
@ -1328,10 +1328,7 @@ static void object_push_instances_modifier(const StringRefNull name,
}
ListBase change_list = {nullptr, nullptr};
for (AnimationBasePathChange &animation_path : animation_data_move) {
BLI_addtail(&change_list, &animation_path);
}
span_to_list(animation_data_move, change_list);
BKE_animdata_transfer_by_basepath(bmain, &object.id, &object.id, &change_list);
}