45 std::optional<StringRef> name,
51 auto item = std::make_unique<GeometryBakeItem>(std::move(
geometry));
52 r_geometry_bake_items.
append(item.get());
57 return std::make_unique<StringBakeItem>(value_variant.extract<std::string>());
67 if (value_variant.is_context_dependent_field()) {
72 if (value_variant.is_volume_grid()) {
73 bke::GVolumeGrid grid = value_variant.get<bke::GVolumeGrid>();
75 grid.get_for_write().set_name(*name);
77 return std::make_unique<VolumeGridBakeItem>(
78 std::make_unique<bke::GVolumeGrid>(std::move(grid)));
84 value_variant.convert_to_single();
85 GPointer value = value_variant.get_single_ptr();
86 return std::make_unique<PrimitiveBakeItem>(*value.
type(), value.
get());
91 auto bundle_bake_item = std::make_unique<BundleBakeItem>();
96 *bundle_item.type, bundle_item.value, std::nullopt, r_geometry_bake_items))
99 bundle_item.key, bundle_item.type->idname, std::move(bake_item)});
103 return bundle_bake_item;
127 void *socket_value = socket_values[
i];
129 auto geometry_item = std::make_unique<GeometryBakeItem>(std::move(
geometry));
130 geometry_bake_items.
append(geometry_item.get());
131 bake_items[
i] = std::move(geometry_item);
137 void *socket_value = socket_values[
i];
138 switch (socket_type) {
145 stype, socket_value, config.
names[
i], geometry_bake_items);
156 if (value_variant.is_context_dependent_field()) {
159 const std::string attribute_name =
".bake_" + std::to_string(
i);
161 for (
const int geometry_i : geometry_indices) {
167 bake_items[
i] = std::make_unique<AttributeBakeItem>(attribute_name);
171 stype, socket_value, config.
names[
i], geometry_bake_items);
177 stype, socket_value, config.
names[
i], geometry_bake_items);
191 if (std::unique_ptr<BakeItem> &item = bake_items[
i]) {
192 item->name = config.
names[
i];
206 make_attribute_field,
210 switch (socket_type) {
212 if (
const auto *item =
dynamic_cast<const GeometryBakeItem *
>(&bake_item)) {
227 if (item->type() == base_type) {
229 value_variant->
store_single(socket_type, item->value());
235 if (!make_attribute_field) {
238 std::shared_ptr<AttributeFieldInput> attribute_field = make_attribute_field(base_type);
239 r_attribute_map.
add(item->name(), attribute_field->attribute_name());
245 if (
const auto *item =
dynamic_cast<const VolumeGridBakeItem *
>(&bake_item)) {
246 const GVolumeGrid &grid = *item->grid;
250 if (!grid_socket_type) {
253 if (grid_socket_type == socket_type) {
263 if (
const auto *item =
dynamic_cast<const StringBakeItem *
>(&bake_item)) {
270 if (
const auto *item =
dynamic_cast<const BundleBakeItem *
>(&bake_item)) {
283 *item.
value, stype->
type, {}, r_attribute_map, buffer))
287 bundle.
add(item.
key, *stype, buffer);
316 if (std::none_of(attribute_map.
keys().
begin(),
318 [&](
const StringRef name) { return attributes_read_only.contains(name); }))
326 attributes.
rename(attribute_item.key, attribute_item.value);
356 FunctionRef<std::shared_ptr<AttributeFieldInput>(
int,
const CPPType &)> make_attribute_field,
366 void *r_socket_value = r_socket_values[
i];
367 if (bake_item ==
nullptr) {
374 [&](
const CPPType &attr_type) {
return make_attribute_field(
i, attr_type); },
396 FunctionRef<std::shared_ptr<AttributeFieldInput>(
int,
const CPPType &)> make_attribute_field,
404 const BakeItem *bake_item = bake_items[
i];
405 void *r_socket_value = r_socket_values[
i];
406 if (bake_item ==
nullptr) {
413 [&](
const CPPType &attr_type) {
return make_attribute_field(
i, attr_type); },
#define BUFFER_FOR_CPP_TYPE_VALUE(type, variable_name)
SubIterator begin() const
IndexRange index_range() const
void copy_construct(const void *src, void *dst) const
void destruct(void *ptr) const
void value_initialize(void *ptr) 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
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)
static BundlePtr create()
bool add(const SocketInterfaceKey &key, const bke::bNodeSocketType &type, const void *value)
Span< StoredItem > items() const
Array< std::unique_ptr< BakeItem > > move_socket_values_to_bake_items(Span< void * > socket_values, const BakeSocketConfig &config, BakeDataBlockMap *data_block_map)
static std::unique_ptr< BakeItem > move_common_socket_value_to_bake_item(const bNodeSocketType &stype, void *socket_value, std::optional< StringRef > name, Vector< GeometryBakeItem * > &r_geometry_bake_items)
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 capture_field_on_geometry_components(GeometrySet &geometry, const fn::GField &field, const AttrDomain domain, const StringRef attribute_name)
static void default_initialize_socket_value(const eNodeSocketDatatype socket_type, void *r_value)
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 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
nodes::SocketInterfaceKey key
std::string socket_idname
std::unique_ptr< BakeItem > value