28 void *socket_value = socket_values[i];
30 bake_items[i] = std::make_unique<GeometryBakeItem>(std::move(
geometry));
35 void *socket_value = socket_values[i];
36 switch (socket_type) {
43 bake_items[i] = std::make_unique<StringBakeItem>(value_variant.extract<std::string>());
54 if (value_variant.is_context_dependent_field()) {
57 const std::string attribute_name =
".bake_" + std::to_string(i);
59 for (
const int geometry_i : geometry_indices) {
87 bake_items[i] = std::make_unique<AttributeBakeItem>(attribute_name);
90 else if (value_variant.is_volume_grid()) {
91 bke::GVolumeGrid grid = value_variant.get<bke::GVolumeGrid>();
92 grid.get_for_write().set_name(config.
names[i]);
93 bake_items[i] = std::make_unique<VolumeGridBakeItem>(
94 std::make_unique<bke::GVolumeGrid>(std::move(grid)));
98 value_variant.convert_to_single();
99 GPointer value = value_variant.get_single_ptr();
100 bake_items[i] = std::make_unique<PrimitiveBakeItem>(*value.
type(), value.
get());
120 if (std::unique_ptr<BakeItem> &item = bake_items[i]) {
121 item->name = config.
names[i];
132 make_attribute_field,
136 switch (socket_type) {
138 if (
const auto *item =
dynamic_cast<const GeometryBakeItem *
>(&bake_item)) {
153 if (item->type() == base_type) {
155 value_variant->
store_single(socket_type, item->value());
161 std::shared_ptr<AttributeFieldInput> attribute_field = make_attribute_field(base_type);
162 r_attribute_map.
add(item->name(), attribute_field->attribute_name());
168 if (
const auto *item =
dynamic_cast<const VolumeGridBakeItem *
>(&bake_item)) {
169 const GVolumeGrid &grid = *item->grid;
173 if (!grid_socket_type) {
176 if (grid_socket_type == socket_type) {
186 if (
const auto *item =
dynamic_cast<const StringBakeItem *
>(&bake_item)) {
213 if (std::none_of(attribute_map.
keys().
begin(),
215 [&](
const StringRef name) { return attributes_read_only.contains(name); }))
223 attributes.
rename(attribute_item.key, attribute_item.value);
254 FunctionRef<std::shared_ptr<AttributeFieldInput>(
int,
const CPPType &)> make_attribute_field,
263 BakeItem *bake_item = bake_items[i];
264 void *r_socket_value = r_socket_values[i];
265 if (bake_item ==
nullptr) {
272 [&](
const CPPType &attr_type) {
return make_attribute_field(i, attr_type); },
294 FunctionRef<std::shared_ptr<AttributeFieldInput>(
int,
const CPPType &)> make_attribute_field,
302 const BakeItem *bake_item = bake_items[i];
303 void *r_socket_value = r_socket_values[i];
304 if (bake_item ==
nullptr) {
311 [&](
const CPPType &attr_type) {
return make_attribute_field(i, attr_type); },
SubIterator begin() const
IndexRange index_range() const
IndexRange index_range() const
void copy_construct(const void *src, void *dst) const
void value_initialize(void *ptr) const
const CPPType * type() const
bool add(const Key &key, const Value &value)
ItemIterator items() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void append(const T &value)
virtual std::optional< MutableAttributeAccessor > attributes_for_write()
bool rename(StringRef old_attribute_id, StringRef new_attribute_id)
void store_single(eNodeSocketDatatype socket_type, const void *value)
static void prepare_geometry_for_bake(GeometrySet &geometry, BakeDataBlockMap *data_block_map)
static void try_restore_data_blocks(GeometrySet &geometry, BakeDataBlockMap *data_block_map)
Array< std::unique_ptr< BakeItem > > move_socket_values_to_bake_items(Span< void * > socket_values, const BakeSocketConfig &config, BakeDataBlockMap *data_block_map)
static void restore_data_blocks(const Span< GeometrySet * > geometries, BakeDataBlockMap *data_block_map)
void copy_bake_items_to_socket_values(Span< const BakeItem * > bake_items, const BakeSocketConfig &config, BakeDataBlockMap *data_block_map, FunctionRef< std::shared_ptr< AttributeFieldInput >(int, const CPPType &)> make_attribute_field, Span< void * > r_socket_values)
void move_bake_items_to_socket_values(Span< BakeItem * > bake_items, const BakeSocketConfig &config, BakeDataBlockMap *data_block_map, FunctionRef< std::shared_ptr< AttributeFieldInput >(int socket_index, const CPPType &)> make_attribute_field, Span< void * > r_socket_values)
static void rename_attributes(const Span< GeometrySet * > geometries, const Map< std::string, std::string > &attribute_map)
static bool copy_bake_item_to_socket_value(const BakeItem &bake_item, const eNodeSocketDatatype socket_type, const FunctionRef< std::shared_ptr< AttributeFieldInput >(const CPPType &type)> make_attribute_field, Map< std::string, std::string > &r_attribute_map, void *r_value)
static void default_initialize_socket_value(const eNodeSocketDatatype socket_type, void *r_value)
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
bNodeSocketType * node_socket_type_find(const char *idname)
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef attribute_id, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
const char * node_static_socket_type(int type, int subtype)
const CPPType * socket_type_to_geo_nodes_base_cpp_type(eNodeSocketDatatype type)
const blender::CPPType * geometry_nodes_cpp_type
const void * geometry_nodes_default_cpp_value
Vector< Vector< int, 1 > > geometries_by_attribute
Vector< StringRef > names
Vector< eNodeSocketDatatype > types
Vector< AttrDomain > domains