Files
test2/source/blender/nodes/NOD_geometry_nodes_execute.hh
Hans Goudey 65803f262f Node Tools: Basic support for data-block inputs
Currently support for data-block inputs is disabled because pointer
properties in operator properties aren't properly handled in Blender
(for more info, see 871c717c6e). This commit brings basic
support for them by storing strings (data-block names) in the operator
properties instead. The main downside of using strings compared other
theoretical solutions is that data-blocks from different library files
can have the same name. This solution won't work well for those cases.
However, it still brings a lot of utility to node tools for a relatively
simple code change.

I investigated two other solutions for this that didn't work out. Using
the recently added enum custom property support didn't work because
the data-block names would still have to be unique. Plus generating an
enum would require a bunch of boilerplate code. Extending the existing
button search code to handle integer session UID backed data-blocks was
much trickier than I expected. The code there is already quite spagetti-
like, and things got out of hand quickly. That's still valid future work
though. The implementation can be changed without breaking
compatibility of files.

Pull Request: https://projects.blender.org/blender/blender/pulls/121148
2024-04-29 03:47:33 +02:00

78 lines
2.8 KiB
C++

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BLI_compute_context.hh"
#include "BLI_function_ref.hh"
#include "BLI_multi_value_map.hh"
#include "BLI_set.hh"
#include "BKE_idprop.hh"
#include "BKE_node.hh"
struct bNodeTree;
struct bNodeSocket;
struct bNodeTreeInterfaceSocket;
struct Depsgraph;
namespace blender::bke {
struct GeometrySet;
}
struct IDProperty;
struct Object;
namespace blender::nodes {
struct GeoNodesCallData;
namespace geo_eval_log {
class GeoModifierLog;
} // namespace geo_eval_log
} // namespace blender::nodes
namespace blender::nodes {
void find_node_tree_dependencies(const bNodeTree &tree,
Set<ID *> &r_ids,
bool &r_needs_own_transform_relation,
bool &r_needs_scene_camera_relation);
StringRef input_use_attribute_suffix();
StringRef input_attribute_name_suffix();
std::optional<StringRef> input_attribute_name_get(const IDProperty &props,
const bNodeTreeInterfaceSocket &io_input);
/**
* \return Whether using an attribute to input values of this type is supported.
*/
bool socket_type_has_attribute_toggle(eNodeSocketDatatype type);
/**
* \return Whether using an attribute to input values of this type is supported, and the node
* group's input for this socket accepts a field rather than just single values.
*/
bool input_has_attribute_toggle(const bNodeTree &node_tree, const int socket_index);
bool id_property_type_matches_socket(const bNodeTreeInterfaceSocket &socket,
const IDProperty &property,
bool use_name_for_ids = false);
std::unique_ptr<IDProperty, bke::idprop::IDPropertyDeleter> id_property_create_from_socket(
const bNodeTreeInterfaceSocket &socket, bool use_name_for_ids);
bke::GeometrySet execute_geometry_nodes_on_geometry(const bNodeTree &btree,
const IDProperty *properties,
const ComputeContext &base_compute_context,
GeoNodesCallData &call_data,
bke::GeometrySet input_geometry);
void update_input_properties_from_node_tree(const bNodeTree &tree,
const IDProperty *old_properties,
IDProperty &properties,
bool use_name_for_ids = false);
void update_output_properties_from_node_tree(const bNodeTree &tree,
const IDProperty *old_properties,
IDProperty &properties);
} // namespace blender::nodes