45 std::optional<StringRef>
name,
51 auto item = std::make_unique<GeometryBakeItem>(std::move(
geometry));
52 r_geometry_bake_items.
append(item.get());
56 return std::make_unique<StringBakeItem>(socket_value.
extract<std::string>());
71 bke::GVolumeGrid grid = socket_value.
get<bke::GVolumeGrid>();
73 grid.get_for_write().set_name(*
name);
75 return std::make_unique<VolumeGridBakeItem>(
76 std::make_unique<bke::GVolumeGrid>(std::move(grid)));
84 return std::make_unique<PrimitiveBakeItem>(*value.
type(), value.
get());
88 auto bundle_bake_item = std::make_unique<BundleBakeItem>();
92 if (
const auto *item_socket_value = std::get_if<nodes::BundleItemSocketValue>(
93 &bundle_item.value.value))
97 *item_socket_value->type, value_variant, std::nullopt, r_geometry_bake_items))
99 bundle_bake_item->items.append(
102 std::move(bake_item)}});
105 else if (
const auto *internal_value = std::get_if<nodes::BundleItemInternalValue>(
106 &bundle_item.value.value))
118 return bundle_bake_item;
144 auto geometry_item = std::make_unique<GeometryBakeItem>(std::move(
geometry));
145 geometry_bake_items.
append(geometry_item.get());
146 bake_items[
i] = std::move(geometry_item);
153 switch (socket_type) {
160 stype, socket_value, config.
names[
i], geometry_bake_items);
173 const std::string attribute_name =
".bake_" + std::to_string(
i);
175 for (
const int geometry_i : geometry_indices) {
181 bake_items[
i] = std::make_unique<AttributeBakeItem>(attribute_name);
185 stype, socket_value, config.
names[
i], geometry_bake_items);
191 stype, socket_value, config.
names[
i], geometry_bake_items);
205 if (std::unique_ptr<BakeItem> &item = bake_items[
i]) {
206 item->name = config.
names[
i];
220 make_attribute_field,
224 switch (socket_type) {
226 if (
const auto *item =
dynamic_cast<const GeometryBakeItem *
>(&bake_item)) {
242 if (item->type() == base_type) {
245 return value_variant;
250 if (!make_attribute_field) {
253 std::shared_ptr<AttributeFieldInput> attribute_field = make_attribute_field(base_type);
254 r_attribute_map.
add(item->name(), attribute_field->attribute_name());
259 if (
const auto *item =
dynamic_cast<const VolumeGridBakeItem *
>(&bake_item)) {
260 const GVolumeGrid &grid = *item->grid;
264 if (!grid_socket_type) {
267 if (grid_socket_type == socket_type) {
276 if (
const auto *item =
dynamic_cast<const StringBakeItem *
>(&bake_item)) {
282 if (
const auto *item =
dynamic_cast<const BundleBakeItem *
>(&bake_item)) {
286 if (
const auto *socket_value = std::get_if<BundleBakeItem::SocketValue>(&item.
value)) {
294 if (std::optional<SocketValueVariant> child_value_variant =
296 *socket_value->value, stype->
type, {}, data_block_map, r_attribute_map))
304 if (
const auto *internal_value = std::get_if<BundleBakeItem::InternalValue>(&item.
value))
307 internal_value->value.get());
308 if (!internal_data) {
341 if (std::none_of(attribute_map.
keys().
begin(),
343 [&](
const StringRef name) { return attributes_read_only.contains(name); }))
351 attributes.
rename(attribute_item.key, attribute_item.value);
367 FunctionRef<std::shared_ptr<AttributeFieldInput>(
int,
const CPPType &)> make_attribute_field)
376 if (bake_item ==
nullptr) {
383 [&](
const CPPType &attr_type) {
return make_attribute_field(
i, attr_type); },
387 socket_values.
append(std::move(*socket_value));
406 return socket_values;
413 FunctionRef<std::shared_ptr<AttributeFieldInput>(
int,
const CPPType &)> make_attribute_field)
421 const BakeItem *bake_item = bake_items[
i];
422 if (bake_item ==
nullptr) {
430 [&](
const CPPType &attr_type) {
return make_attribute_field(
i, attr_type); },
434 socket_values.
append(std::move(*socket_value));
448 return socket_values;
SubIterator begin() const
IndexRange index_range() const
const CPPType * type() const
bool add(const Key &key, const Value &value)
KeyIterator keys() const &
ItemIterator items() const &
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void append(const T &value)
void reserve(const int64_t min_capacity)
virtual std::optional< MutableAttributeAccessor > attributes_for_write()
bool rename(StringRef old_attribute_id, StringRef new_attribute_id)
bool is_context_dependent_field() const
bool is_volume_grid() const
static SocketValueVariant From(T &&value)
void store_single(eNodeSocketDatatype socket_type, const void *value)
GPointer get_single_ptr() const
static void prepare_geometry_for_bake(GeometrySet &geometry, BakeDataBlockMap *data_block_map)
static void try_restore_data_blocks(GeometrySet &geometry, BakeDataBlockMap *data_block_map)
Span< StoredItem > items() const
static BundlePtr create()
bool add(StringRef key, const BundleItemValue &value)
Array< std::unique_ptr< BakeItem > > move_socket_values_to_bake_items(MutableSpan< SocketValueVariant > socket_values, const BakeSocketConfig &config, BakeDataBlockMap *data_block_map)
static std::optional< SocketValueVariant > 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, BakeDataBlockMap *data_block_map, Map< std::string, std::string > &r_attribute_map)
static std::unique_ptr< BakeItem > move_common_socket_value_to_bake_item(const bNodeSocketType &stype, SocketValueVariant &socket_value, std::optional< StringRef > name, Vector< GeometryBakeItem * > &r_geometry_bake_items)
Vector< SocketValueVariant > 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)
static void rename_attributes(const Span< GeometrySet * > geometries, const Map< std::string, std::string > &attribute_map)
static SocketValueVariant default_initialize_socket_value(const eNodeSocketDatatype socket_type)
Vector< SocketValueVariant > 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)
static void capture_field_on_geometry_components(GeometrySet &geometry, const fn::GField &field, const AttrDomain domain, const StringRef attribute_name)
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
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 CPPType * socket_type_to_geo_nodes_base_cpp_type(eNodeSocketDatatype type)
bNodeSocketType * node_socket_type_find(StringRef idname)
bNodeSocketType * node_socket_type_find_static(int type, int subtype=0)
ImplicitSharingPtr< Bundle > BundlePtr
const SocketValueVariant * geometry_nodes_default_value
Vector< Vector< int, 1 > > geometries_by_attribute
Vector< StringRef > names
Vector< eNodeSocketDatatype > types
Vector< AttrDomain > domains
std::variant< SocketValue, InternalValue > value