47#include "RNA_prototypes.hh"
55#include <fmt/format.h>
79 const std::string idname_str = idname;
121 std::array<float2, NODE_LINK_RESOL + 1> coords;
156 if (path.
size() >= 256) {
168 ntree.ensure_topology_cache();
188 from_cuts.
links.add(link, *cut);
191 for (
const auto item : cuts_per_socket.
items()) {
197 item.value.from_node,
204 link->fromnode = reroute;
210 const float2 insert_point = std::accumulate(
268 const char *disabled_hint =
nullptr;
273 "Cannot add node group '%s' to '%s':\n %s",
281 "Cannot add node group '%s' to '%s'",
310 if (node_idname[0] ==
'\0') {
323 group_node->
flag &= ~NODE_OPTIONS;
327 group_node->
id = &node_group->
id;
346 C,
"Adding node groups isn't supported for custom (Python defined) node trees");
373 ot->
name =
"Add Node Group";
374 ot->
description =
"Add an existing node group to the current node editor";
388 ot->
srna,
"show_datablock_in_node",
true,
"Show the datablock selector in the node",
"");
427 group_node->
flag &= ~NODE_OPTIONS;
430 group_node->
id = &node_group->
id;
494 ot->
name =
"Add Node Group Asset";
495 ot->
description =
"Add a node group asset to the active node tree";
496 ot->
idname =
"NODE_OT_add_group_asset";
541 socket_data->
value = object;
578 ot->
name =
"Add Node Object";
579 ot->
description =
"Add an object info node to the current node editor";
615 if (!collection_node) {
627 socket_data->
value = collection;
664 ot->
name =
"Add Node Collection";
665 ot->
description =
"Add a collection info node to the current node editor";
666 ot->
idname =
"NODE_OT_add_collection";
706 const float node_stack_anim_duration = 0.25f;
707 const float duration =
float(data->anim_timer->time_duration);
708 const float prev_duration = duration -
float(data->anim_timer->time_delta);
709 const float clamped_duration =
math::min(duration, node_stack_anim_duration);
710 const float delta_factor =
716 float stack_offset = 0.0f;
718 for (
bNode *node : data->nodes) {
719 node->locy -= stack_offset;
720 stack_offset += (node->runtime->totr.ymax - node->runtime->totr.ymin) * delta_factor;
729 if (duration > node_stack_anim_duration) {
763 for (
const std::string &path : paths) {
770 images.append(image);
778 if (paths.is_empty()) {
781 images.append(image);
789 for (
Image *image : images) {
795 if (type == GEO_NODE_IMAGE_TEXTURE) {
801 node->
id = (
ID *)image;
807 position[1] -= 20.0f;
810 if (nodes.is_empty()) {
816 for (
bNode *node : nodes) {
826 if (nodes.size() == 1) {
832 data->nodes = std::move(nodes);
866 ot->
name =
"Add File Node";
867 ot->
description =
"Add a file node to the current node editor";
934 ot->
name =
"Add Mask Node";
935 ot->
description =
"Add a mask node to the current node editor";
970 if (!material_node) {
975 material_node->
id = &material->id;
1011 ot->
name =
"Add Material";
1012 ot->
description =
"Add a material node to the current node editor";
1013 ot->
idname =
"NODE_OT_add_material";
1041 const char *treename;
1061 treename = treename_buf;
1065 treename = type->ui_name;
1110 ot->
name =
"New Node Tree";
1111 ot->
idname =
"NODE_OT_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)
#define SH_NODE_TEX_IMAGE
#define GEO_NODE_IMAGE_TEXTURE
void BKE_ntree_update_tag_link_changed(bNodeTree *ntree)
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])
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ntree)
void ED_node_set_active(Main *bmain, SpaceNode *snode, bNodeTree *ntree, bNode *node, bool *r_active_texture_changed)
void ED_node_tree_update(const bContext *C)
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain)
bool ED_operator_node_editable(bContext *C)
void ED_region_tag_redraw(ARegion *region)
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
constexpr IndexRange drop_back(int64_t n) const
SubIterator begin() const
Value & lookup_or_add_default(const Key &key)
ValueIterator values() 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
AssetMetaData & get_metadata() const
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
draw_view in_light_buf[] float
ccl_device_inline float4 mask(const int4 mask, const float4 a)
void node_attach_node(bNodeTree *ntree, bNode *node, bNode *parent)
void node_set_active(bNodeTree *ntree, bNode *node)
bNode * node_add_static_node(const bContext *C, bNodeTree *ntree, int type)
bool node_group_poll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint)
bNodeLink * node_add_link(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock)
bNodeTree * node_tree_add_tree(Main *bmain, const char *name, const char *idname)
bNode * node_add_node(const bContext *C, bNodeTree *ntree, const char *idname)
bool node_set_selected(bNode *node, bool select)
void node_tag_update_id(bNode *node)
bNodeTreeType * node_tree_type_find(const char *idname)
bNodeSocket * node_find_socket(bNode *node, eNodeSocketInOut in_out, StringRef identifier)
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_object(wmOperatorType *ot)
static bool node_add_material_poll(bContext *C)
static int node_add_group_asset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_add_mask(wmOperatorType *ot)
static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool node_add_object_poll(bContext *C)
bNode * add_static_node(const bContext &C, int type, const float2 &location)
static int node_add_material_exec(bContext *C, wmOperator *op)
static bool node_add_group_poll(bContext *C)
static bool node_add_file_poll(bContext *C)
void NODE_OT_add_reroute(wmOperatorType *ot)
bool node_deselect_all(bNodeTree &node_tree)
void NODE_OT_add_collection(wmOperatorType *ot)
static int add_reroute_exec(bContext *C, wmOperator *op)
bNode * add_node(const bContext &C, const StringRef idname, const float2 &location)
static int node_add_mask_exec(bContext *C, wmOperator *op)
void NODE_OT_add_group_asset(wmOperatorType *ot)
static void position_node_based_on_mouse(bNode &node, const float2 &location)
static const EnumPropertyItem * new_node_tree_type_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
static int new_node_tree_exec(bContext *C, wmOperator *op)
static int node_add_group_exec(bContext *C, wmOperator *op)
bool node_link_is_hidden_or_dimmed(const View2D &v2d, const bNodeLink &link)
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)
const char * node_group_idname(bContext *C)
static int node_add_object_exec(bContext *C, wmOperator *op)
static int node_add_file_exec(bContext *C, wmOperator *op)
static int node_add_file_modal(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 int node_add_collection_exec(bContext *C, wmOperator *op)
static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int node_add_collection_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static std::string node_add_group_asset_get_description(bContext *C, wmOperatorType *, PointerRNA *ptr)
static int node_add_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_add_group(wmOperatorType *ot)
void NODE_OT_add_file(wmOperatorType *ot)
static bool node_add_collection_poll(bContext *C)
void NODE_OT_add_material(wmOperatorType *ot)
static int node_add_object_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_new_node_tree(wmOperatorType *ot)
static bool add_node_group_asset(const bContext &C, const asset_system::AssetRepresentation &asset, ReportList &reports)
T min(const T &a, const T &b)
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_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_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_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
bNodeRuntimeHandle * runtime
Map< bNodeLink *, float2 > links
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
std::string(* get_description)(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int 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)
int WM_gesture_lines_modal(bContext *C, wmOperator *op, const wmEvent *event)
void WM_gesture_lines_cancel(bContext *C, wmOperator *op)
int 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)
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *)
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)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
wmTimer * WM_event_timer_add(wmWindowManager *wm, wmWindow *win, const int event_type, const double time_step)