52#include "RNA_prototypes.hh"
60#include <fmt/format.h>
84 const std::string idname_str = idname;
126 std::array<float2, NODE_LINK_RESOL + 1> coords;
161 if (path.
size() >= 256) {
173 ntree.ensure_topology_cache();
193 from_cuts.
links.add(link, *cut);
196 for (
const auto item : cuts_per_socket.
items()) {
202 *item.value.from_node,
209 link->fromnode = reroute;
215 const float2 insert_point = std::accumulate(
237 ot->name =
"Add Reroute";
238 ot->idname =
"NODE_OT_add_reroute";
239 ot->description =
"Add a reroute node";
269 if (node_group.
type != node_tree.
type) {
273 const char *disabled_hint =
nullptr;
278 "Cannot add node group '%s' to '%s':\n %s",
286 "Cannot add node group '%s' to '%s'",
315 if (node_idname[0] ==
'\0') {
332 group_node->
id = &node_group->
id;
351 C,
"Adding node groups isn't supported for custom (Python defined) node trees");
378 ot->name =
"Add Node Group";
379 ot->description =
"Add an existing node group to the current node editor";
380 ot->idname =
"NODE_OT_add_group";
393 ot->srna,
"show_datablock_in_node",
true,
"Show the datablock selector in the node",
"");
438 group_node->
id = &node_group->
id;
504 ot->name =
"Add Node Group Asset";
505 ot->description =
"Add a node group asset to the active node tree";
506 ot->idname =
"NODE_OT_add_group_asset";
589 ot->name =
"Add Node Object";
590 ot->description =
"Add an object info node to the current node editor";
591 ot->idname =
"NODE_OT_add_object";
626 if (!collection_node) {
638 socket_data->
value = collection;
678 ot->name =
"Add Node Collection";
679 ot->description =
"Add a collection info node to the current node editor";
680 ot->idname =
"NODE_OT_add_collection";
709 "CompositorNodeTree",
728 const float node_stack_anim_duration = 0.25f;
729 const float duration = float(
data->anim_timer->time_duration);
730 const float prev_duration = duration - float(
data->anim_timer->time_delta);
731 const float clamped_duration =
math::min(duration, node_stack_anim_duration);
732 const float delta_factor =
738 float stack_offset = 0.0f;
742 stack_offset += (node->
runtime->draw_bounds.ymax - node->
runtime->draw_bounds.ymin) *
752 if (duration > node_stack_anim_duration) {
786 for (
const std::string &path : paths) {
812 for (
Image *image : images) {
821 socket_value->
value = image;
825 node->
id = (
ID *)image;
831 position[1] -= 20.0f;
834 if (
nodes.is_empty()) {
850 if (
nodes.size() == 1) {
872 "Could not add image. A node tree has not been created or assigned");
897 ot->name =
"Add Image as Node";
898 ot->description =
"Add a image/movie file as node to the current node editor";
899 ot->idname =
"NODE_OT_add_image";
965 ot->name =
"Add Mask Node";
966 ot->description =
"Add a mask node to the current node editor";
967 ot->idname =
"NODE_OT_add_mask";
1001 if (!material_node) {
1006 material_node->
id = &material->
id;
1042 ot->name =
"Add Material";
1043 ot->description =
"Add a material node to the current node editor";
1044 ot->idname =
"NODE_OT_add_material";
1073 bNode *node =
nullptr;
1074 if (path.endswith(
".csv")) {
1077 else if (path.endswith(
".obj")) {
1080 else if (path.endswith(
".ply")) {
1083 else if (path.endswith(
".stl")) {
1086 else if (path.endswith(
".txt")) {
1089 else if (path.endswith(
".vdb")) {
1094 bNodeSocket &path_socket = node->input_by_identifier(
"Path");
1097 STRNCPY(socket_data->value, path.c_str());
1109 bNode *node = new_nodes[
i];
1115 data->nodes = std::move(new_nodes);
1153 ot->name =
"Add Import Node";
1154 ot->description =
"Add an import node to the node tree";
1155 ot->idname =
"NODE_OT_add_import_node";
1167 ot->srna,
"directory",
nullptr,
FILE_MAX,
"Directory",
"Directory of the file");
1185 bool single_socket =
false;
1187 bool single_panel =
false;
1188 int panel_identifier = 0;
1190 single_socket =
true;
1194 single_panel =
true;
1197 if (single_socket && single_panel) {
1204 if (single_socket) {
1208 if (
STREQ(socket_identifier, tsocket->identifier)) {
1209 interface_socket = tsocket;
1213 if (!interface_socket) {
1217 fmt::format(
"Invalid socket_identifier: Socket \"%s\" not found", socket_identifier)
1227 if (tpanel && tpanel->
identifier == panel_identifier) {
1228 interface_panel = tpanel;
1233 if (!interface_panel) {
1243 if (single_socket) {
1246 if (!
STREQ(socket->identifier, socket_identifier)) {
1258 if (interface_panel->contains_recursive(iface_socket->item)) {
1260 *group_input_node,
SOCK_OUT, iface_socket->identifier);
1311 bool has_inputs =
false;
1313 if (panel->contains_recursive(socket->item)) {
1330 ot->name =
"Add Group Input Node";
1331 ot->description =
"Add a Group Input node with selected sockets to the current node editor";
1332 ot->idname =
"NODE_OT_add_group_input_node";
1341 "socket_identifier",
1344 "Socket Identifier",
1345 "Socket to include in the added group input/output node");
1353 "Panel from which to add sockets to the added group input/output node",
1456 ot->name =
"Add Color";
1457 ot->description =
"Add a color node to the current node editor";
1458 ot->idname =
"NODE_OT_add_color";
1469 ot->srna,
"color", 4,
nullptr, 0.0,
FLT_MAX,
"Color",
"Source color", 0.0, 1.0);
1471 ot->srna,
"gamma",
false,
"Gamma Corrected",
"The source color is gamma corrected");
1473 ot->srna,
"has_alpha",
false,
"Has Alpha",
"The source color contains an Alpha component");
1489 const char *treename;
1509 treename = treename_buf;
1513 treename = type->
ui_name.c_str();
1558 ot->name =
"New Node Tree";
1559 ot->idname =
"NODE_OT_new_node_tree";
1560 ot->description =
"Create a new node tree";
Main runtime representation of an asset.
SpaceNode * CTX_wm_space_node(const bContext *C)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
wmWindow * CTX_wm_window(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
#define IMA_SIGNAL_RELOAD
void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal)
void BKE_id_free_us(Main *bmain, void *idv) ATTR_NONNULL()
void BKE_id_move_to_same_lib(Main &bmain, ID &id, const ID &owner_id)
const char * BKE_id_name(const ID &id)
void BKE_main_ensure_invariants(Main &bmain, std::optional< blender::Span< ID * > > modified_ids=std::nullopt)
#define GEO_NODE_OBJECT_INFO
#define SH_NODE_TEX_IMAGE
#define GEO_NODE_IMAGE_TEXTURE
#define GEO_NODE_INPUT_MATERIAL
#define GEO_NODE_COLLECTION_INFO
void BKE_ntree_update_tag_link_changed(bNodeTree *ntree)
void BKE_ntree_update_tag_socket_property(bNodeTree *ntree, bNodeSocket *socket)
void BKE_ntree_update_tag_node_property(bNodeTree *ntree, bNode *node)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float duration)
#define LISTBASE_FOREACH(type, var, list)
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
MINLINE void copy_v4_v4(float r[4], const float a[4])
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
char * STRNCPY(char(&dst)[N], const char *src)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
@ NODE_INTERFACE_SOCKET_OUTPUT
void ED_node_set_active(Main *bmain, SpaceNode *snode, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed)
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
bool ED_operator_node_editable(bContext *C)
void ED_region_tag_redraw(ARegion *region)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
Read Guarded memory(de)allocation.
#define RNA_BEGIN(sptr, itemptr, propname)
const EnumPropertyItem * rna_node_tree_type_itemf(void *data, bool(*poll)(void *data, blender::bke::bNodeTreeType *), bool *r_free)
void UI_context_active_but_prop_get_templateID(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop)
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
@ OPTYPE_DEPENDS_ON_CURSOR
BMesh const char void * data
SubIterator begin() const
constexpr IndexRange drop_back(int64_t n) const
Value & lookup_or_add_default(const Key &key)
ValueIterator values() const &
KeyIterator keys() const &
ItemIterator items() const &
constexpr IndexRange index_range() const
void append(const T &value)
const T & last(const int64_t n=0) const
IndexRange index_range() const
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
T & get_item_as(bNodeTreeInterfaceItem &item)
void node_attach_node(bNodeTree &ntree, bNode &node, bNode &parent)
bNodeTreeType * node_tree_type_find(StringRef idname)
void node_tag_update_id(bNode &node)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
bNode * node_add_node(const bContext *C, bNodeTree &ntree, StringRef idname)
bool node_group_poll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint)
bool node_set_selected(bNode &node, bool select)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bNodeTree * node_tree_add_tree(Main *bmain, StringRef name, StringRef idname)
void node_set_active(bNodeTree &ntree, bNode &node)
void node_unique_name(bNodeTree &ntree, bNode &node)
ID * asset_local_id_ensure_imported(Main &bmain, const asset_system::AssetRepresentation &asset)
void operator_asset_reference_props_register(StructRNA &srna)
const asset_system::AssetRepresentation * operator_asset_reference_props_get_asset_from_all_library(const bContext &C, PointerRNA &ptr, ReportList *reports)
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
void NODE_OT_add_group_input_node(wmOperatorType *ot)
void NODE_OT_add_object(wmOperatorType *ot)
static bool node_add_material_poll(bContext *C)
static wmOperatorStatus node_add_group_exec(bContext *C, wmOperator *op)
void NODE_OT_add_mask(wmOperatorType *ot)
static bool node_add_object_poll(bContext *C)
static wmOperatorStatus add_reroute_exec(bContext *C, wmOperator *op)
bNode * add_static_node(const bContext &C, int type, const float2 &location)
static wmOperatorStatus node_add_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus node_add_mask_exec(bContext *C, wmOperator *op)
static bool node_add_image_poll(bContext *C)
static bool node_add_group_poll(bContext *C)
void NODE_OT_add_reroute(wmOperatorType *ot)
static wmOperatorStatus node_add_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool node_deselect_all(bNodeTree &node_tree)
static wmOperatorStatus node_add_import_node_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_add_collection(wmOperatorType *ot)
bNode * add_node(const bContext &C, const StringRef idname, const float2 &location)
static wmOperatorStatus node_add_group_input_node_exec(bContext *C, wmOperator *op)
void NODE_OT_add_group_asset(wmOperatorType *ot)
static wmOperatorStatus node_add_material_exec(bContext *C, wmOperator *op)
static void position_node_based_on_mouse(bNode &node, const float2 &location)
static bool node_add_color_poll(bContext *C)
static wmOperatorStatus node_add_collection_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem * new_node_tree_type_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
static bool node_add_import_node_poll(bContext *C)
void NODE_OT_add_color(wmOperatorType *ot)
static wmOperatorStatus node_add_group_asset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus node_add_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link)
void tree_update(const bContext *C)
std::optional< float2 > link_path_intersection(const bNodeLink &link, const Span< float2 > path)
static bool node_group_add_poll(const bNodeTree &node_tree, const bNodeTree &node_group, ReportList &reports)
static wmOperatorStatus node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void node_link_bezier_points_evaluated(const bNodeLink &link, std::array< float2, NODE_LINK_RESOL+1 > &coords)
static bool node_add_mask_poll(bContext *C)
static wmOperatorStatus node_add_object_exec(bContext *C, wmOperator *op)
static bool node_add_group_input_node_poll(bContext *C)
void NODE_OT_add_import_node(wmOperatorType *ot)
static std::string node_add_group_asset_get_description(bContext *C, wmOperatorType *, PointerRNA *ptr)
void NODE_OT_add_image(wmOperatorType *ot)
static wmOperatorStatus new_node_tree_exec(bContext *C, wmOperator *op)
void NODE_OT_add_group(wmOperatorType *ot)
static wmOperatorStatus node_add_nodes_modal(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus node_add_color_exec(bContext *C, wmOperator *op)
static bool node_add_collection_poll(bContext *C)
static wmOperatorStatus node_add_import_node_exec(bContext *C, wmOperator *op)
static wmOperatorStatus node_add_group_input_node_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_add_material(wmOperatorType *ot)
static wmOperatorStatus node_add_image_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus node_add_image_exec(bContext *C, wmOperator *op)
void NODE_OT_new_node_tree(wmOperatorType *ot)
StringRef node_group_idname(const bContext *C)
static bool add_node_group_asset(const bContext &C, const asset_system::AssetRepresentation &asset, ReportList &reports)
T min(const T &a, const T &b)
VecBase< float, 2 > float2
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_identifier)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_id_pointer_create(ID *id)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_color(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_collection_runtime(StructOrFunctionRNA *cont_, const char *identifier, StructRNA *type, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
PropertyRNA * RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
SpaceNode_Runtime * runtime
struct bNodeTree * edittree
struct bNodeTree * nodetree
struct Collection * value
int default_group_node_width
bNodeTypeHandle * typeinfo
bNodeRuntimeHandle * runtime
Map< bNodeLink *, float2 > links
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmOperatorStatus WM_gesture_lines_invoke(bContext *C, wmOperator *op, const wmEvent *event)
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr)
ID * WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain, PointerRNA *ptr, const ID_Type type)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)
ID * WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
wmOperatorStatus WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const wmEventType event_type, const double time_step)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)