53#include "RNA_prototypes.hh"
61#include <fmt/format.h>
158 std::array<float2, NODE_LINK_RESOL + 1> coords;
193 if (path.
size() >= 256) {
205 ntree.ensure_topology_cache();
215 int intersection_count = 0;
228 from_cuts.
links.add(link, *cut);
229 intersection_count++;
232 for (
const auto item : cuts_per_socket.
items()) {
237 if (intersection_count == 1) {
242 *item.value.from_node,
249 link->fromnode = reroute;
255 const float2 insert_point = std::accumulate(
277 ot->name =
"Add Reroute";
278 ot->idname =
"NODE_OT_add_reroute";
279 ot->description =
"Add a reroute node";
309 if (node_group.
type != node_tree.
type) {
313 const char *disabled_hint =
nullptr;
318 "Cannot add node group '%s' to '%s':\n %s",
326 "Cannot add node group '%s' to '%s'",
355 if (node_idname[0] ==
'\0') {
372 group_node->
id = &node_group->
id;
391 C,
"Adding node groups isn't supported for custom (Python defined) node trees");
405 C,
"Adding node groups isn't supported for custom (Python defined) node trees");
411 if (selected_nodes.
size() <= 0) {
439 ot->name =
"Add Node Group";
440 ot->description =
"Add an existing node group to the current node editor";
441 ot->idname =
"NODE_OT_add_group";
454 ot->srna,
"show_datablock_in_node",
true,
"Show the data-block selector in the node",
"");
499 group_node->
id = &node_group->
id;
574 if (node_idname[0] ==
'\0') {
592 std::string setting_value =
"bpy.data.node_groups[\"" +
637 ot->name =
"Add Node Group Asset";
638 ot->description =
"Add a node group asset to the active node tree";
639 ot->idname =
"NODE_OT_add_group_asset";
652 ot->name =
"Swap Node Group Asset";
653 ot->description =
"Swap selected nodes with the specified node group asset";
654 ot->idname =
"NODE_OT_swap_group_asset";
737 ot->name =
"Add Node Object";
738 ot->description =
"Add an object info node to the current node editor";
739 ot->idname =
"NODE_OT_add_object";
774 if (!collection_node) {
786 socket_data->
value = collection;
826 ot->name =
"Add Node Collection";
827 ot->description =
"Add a collection info node to the current node editor";
828 ot->idname =
"NODE_OT_add_collection";
857 "CompositorNodeTree",
876 const float node_stack_anim_duration = 0.25f;
877 const float duration =
float(
data->anim_timer->time_duration);
878 const float prev_duration = duration -
float(
data->anim_timer->time_delta);
879 const float clamped_duration =
math::min(duration, node_stack_anim_duration);
880 const float delta_factor =
886 float stack_offset = 0.0f;
890 stack_offset += (node->
runtime->draw_bounds.ymax - node->
runtime->draw_bounds.ymin) *
900 if (duration > node_stack_anim_duration) {
934 for (
const std::string &path : paths) {
960 for (
Image *image : images) {
969 socket_value->
value = image;
973 node->
id = (
ID *)image;
979 position[1] -= 20.0f;
982 if (
nodes.is_empty()) {
998 if (
nodes.size() == 1) {
1020 "Could not add image. A node tree has not been created or assigned");
1045 ot->name =
"Add Image as Node";
1046 ot->description =
"Add a image/movie file as node to the current node editor";
1047 ot->idname =
"NODE_OT_add_image";
1113 ot->name =
"Add Mask Node";
1114 ot->description =
"Add a mask node to the current node editor";
1115 ot->idname =
"NODE_OT_add_mask";
1149 if (!material_node) {
1154 material_node->
id = &material->
id;
1190 ot->name =
"Add Material";
1191 ot->description =
"Add a material node to the current node editor";
1192 ot->idname =
"NODE_OT_add_material";
1221 bNode *node =
nullptr;
1222 if (path.endswith(
".csv")) {
1225 else if (path.endswith(
".obj")) {
1228 else if (path.endswith(
".ply")) {
1231 else if (path.endswith(
".stl")) {
1234 else if (path.endswith(
".txt")) {
1237 else if (path.endswith(
".vdb")) {
1242 bNodeSocket &path_socket = *node->input_by_identifier(
"Path");
1245 STRNCPY(socket_data->value, path.c_str());
1257 bNode *node = new_nodes[
i];
1263 data->nodes = std::move(new_nodes);
1301 ot->name =
"Add Import Node";
1302 ot->description =
"Add an import node to the node tree";
1303 ot->idname =
"NODE_OT_add_import_node";
1315 ot->srna,
"directory",
nullptr,
FILE_MAX,
"Directory",
"Directory of the file");
1333 bool single_socket =
false;
1335 bool single_panel =
false;
1336 int panel_identifier = 0;
1338 single_socket =
true;
1342 single_panel =
true;
1345 if (single_socket && single_panel) {
1352 if (single_socket) {
1356 if (
STREQ(socket_identifier, tsocket->identifier)) {
1357 interface_socket = tsocket;
1361 if (!interface_socket) {
1365 fmt::format(
"Invalid socket_identifier: Socket \"%s\" not found", socket_identifier)
1375 if (tpanel && tpanel->
identifier == panel_identifier) {
1376 interface_panel = tpanel;
1381 if (!interface_panel) {
1391 if (single_socket) {
1394 if (!
STREQ(socket->identifier, socket_identifier)) {
1406 if (interface_panel->contains_recursive(iface_socket->item)) {
1408 *group_input_node,
SOCK_OUT, iface_socket->identifier);
1459 bool has_inputs =
false;
1461 if (panel->contains_recursive(socket->item)) {
1478 ot->name =
"Add Group Input Node";
1479 ot->description =
"Add a Group Input node with selected sockets to the current node editor";
1480 ot->idname =
"NODE_OT_add_group_input_node";
1489 "socket_identifier",
1492 "Socket Identifier",
1493 "Socket to include in the added group input/output node");
1501 "Panel from which to add sockets to the added group input/output node",
1604 ot->name =
"Add Color";
1605 ot->description =
"Add a color node to the current node editor";
1606 ot->idname =
"NODE_OT_add_color";
1617 ot->srna,
"color", 4,
nullptr, 0.0,
FLT_MAX,
"Color",
"Source color", 0.0, 1.0);
1619 ot->srna,
"gamma",
false,
"Gamma Corrected",
"The source color is gamma corrected");
1621 ot->srna,
"has_alpha",
false,
"Has Alpha",
"The source color contains an Alpha component");
1645 const char *treename;
1665 treename = treename_buf;
1669 treename = type->
ui_name.c_str();
1691 ot->name =
"New Node Tree";
1692 ot->idname =
"NODE_OT_new_node_tree";
1693 ot->description =
"Create a new node tree";
1743 ot->name =
"New Compositing Node Group";
1744 ot->idname =
"NODE_OT_new_compositing_node_group";
1745 ot->description =
"Create a new compositing node group and initialize it with default nodes";
1786 ot->name =
"New Compositing Node Group";
1787 ot->idname =
"NODE_OT_duplicate_compositing_node_group";
1788 ot->description =
"Duplicate the currently assigned compositing node group.";
1867 operator_type->
name =
"New Compositor Sequencer Node Group";
1868 operator_type->
idname =
"NODE_OT_new_compositor_sequencer_node_group";
1869 operator_type->
description =
"Create a new compositor node group for sequencer";
1877 DATA_(
"Sequencer Compositor Nodes"),
Main runtime representation of an asset.
blender::Vector< PointerRNA > CTX_data_collection_get(const bContext *C, const char *member)
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)
Scene * CTX_data_scene(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_after_single_tree_change(Main &bmain, bNodeTree &modified_tree, const NodeTreeUpdateExtraParams ¶ms={})
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 BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
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)
#define STRNCPY_UTF8(dst, src)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
@ NODE_INTERFACE_SOCKET_OUTPUT
@ NODE_INTERFACE_SOCKET_INPUT
void ED_node_composit_default_init(const bContext *C, bNodeTree *ntree)
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
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
constexpr const char * data() 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)
bNodeTree * node_tree_copy_tree(Main *bmain, const bNodeTree &ntree)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
bNode * node_add_node(const bContext *C, bNodeTree &ntree, StringRef idname, std::optional< int > unique_identifier=std::nullopt)
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)
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)
ID * asset_local_id_ensure_imported(Main &bmain, const asset_system::AssetRepresentation &asset, const std::optional< eAssetImportMethod > import_method=std::nullopt)
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)
NodeLinkData data[NODELINK_GROUP_SIZE]
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)
static void initialize_compositor_sequencer_node_group(const bContext *C, bNodeTree &ntree)
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 wmOperatorStatus duplicate_compositing_node_group_exec(bContext *C, wmOperator *)
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)
void NODE_OT_new_compositing_node_group(wmOperatorType *ot)
static wmOperatorStatus node_add_import_node_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_add_collection(wmOperatorType *ot)
static void node_templateID_assign(bContext *C, bNodeTree *node_tree)
bNode * add_node(const bContext &C, const StringRef idname, const float2 &location)
static wmOperatorStatus new_compositing_node_group_exec(bContext *C, wmOperator *op)
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)
void NODE_OT_duplicate_compositing_node_group(wmOperatorType *ot)
static wmOperatorStatus node_swap_group_asset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_swap_group_asset(wmOperatorType *ot)
static const EnumPropertyItem * new_node_tree_type_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
static bool node_add_import_node_poll(bContext *C)
static wmOperatorStatus new_compositing_node_group_invoke(bContext *C, wmOperator *op, const wmEvent *)
static bNodeTree * new_node_tree_impl(bContext *C, StringRef treename, StringRef idname)
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)
static wmOperatorStatus new_compositor_sequencer_node_group_exec(bContext *C, wmOperator *op)
std::optional< float2 > link_path_intersection(const bNodeLink &link, const Span< float2 > path)
VectorSet< bNode * > get_selected_nodes(bNodeTree &node_tree)
static bool node_swap_group_poll(bContext *C)
void NODE_OT_new_compositor_sequencer_node_group(wmOperatorType *operator_type)
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)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
int RNA_int_get(PointerRNA *ptr, const char *name)
std::string RNA_string_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)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
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[]
struct bNodeTree * compositing_node_group
SpaceNode_Runtime * runtime
struct bNodeTree * edittree
struct bNodeTree * nodetree
struct Collection * value
int default_group_node_width
bNodeTreeInterface tree_interface
bNodeTypeHandle * typeinfo
bNodeRuntimeHandle * runtime
Map< bNodeLink *, float2 > links
wmOperatorStatus(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, blender::wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
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)