Nodes: move some files to C++
This just moves a couple of files in `space_node` to C++ and fixes related errors. The goal is to be able to use C++ data structures to simplify the code. Differential Revision: https://developer.blender.org/D11451
This commit is contained in:
parent
b8ae30e9e3
commit
4f8edc8e7f
|
@ -37,20 +37,20 @@ set(INC
|
|||
|
||||
|
||||
set(SRC
|
||||
drawnode.c
|
||||
node_add.c
|
||||
drawnode.cc
|
||||
node_add.cc
|
||||
node_buttons.c
|
||||
node_draw.cc
|
||||
node_edit.c
|
||||
node_edit.cc
|
||||
node_geometry_attribute_search.cc
|
||||
node_gizmo.c
|
||||
node_group.c
|
||||
node_group.cc
|
||||
node_ops.c
|
||||
node_relationships.c
|
||||
node_select.c
|
||||
node_templates.c
|
||||
node_toolbar.c
|
||||
node_view.c
|
||||
node_relationships.cc
|
||||
node_select.cc
|
||||
node_templates.cc
|
||||
node_toolbar.cc
|
||||
node_view.cc
|
||||
space_node.c
|
||||
|
||||
node_intern.h
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -65,13 +65,13 @@
|
|||
/**
|
||||
* XXX Does some additional initialization on top of #nodeAddNode
|
||||
* Can be used with both custom and static nodes,
|
||||
* if `idname == NULL` the static int type will be used instead.
|
||||
* if `idname == nullptr` the static int type will be used instead.
|
||||
*/
|
||||
bNode *node_add_node(const bContext *C, const char *idname, int type, float locx, float locy)
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
bNode *node = NULL;
|
||||
bNode *node = nullptr;
|
||||
|
||||
node_deselect_all(snode);
|
||||
|
||||
|
@ -90,7 +90,7 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
|
|||
nodeSetSelected(node, true);
|
||||
|
||||
ntreeUpdateTree(bmain, snode->edittree);
|
||||
ED_node_set_active(bmain, snode->edittree, node, NULL);
|
||||
ED_node_set_active(bmain, snode->edittree, node, nullptr);
|
||||
|
||||
snode_update(snode, node);
|
||||
|
||||
|
@ -114,7 +114,7 @@ static bool add_reroute_intersect_check(bNodeLink *link,
|
|||
{
|
||||
float coord_array[NODE_LINK_RESOL + 1][2];
|
||||
|
||||
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
|
||||
if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
|
||||
for (int i = 0; i < tot - 1; i++) {
|
||||
for (int b = 0; b < NODE_LINK_RESOL; b++) {
|
||||
if (isect_seg_seg_v2_point(
|
||||
|
@ -127,13 +127,13 @@ static bool add_reroute_intersect_check(bNodeLink *link,
|
|||
return false;
|
||||
}
|
||||
|
||||
typedef struct bNodeSocketLink {
|
||||
struct bNodeSocketLink {
|
||||
struct bNodeSocketLink *next, *prev;
|
||||
|
||||
struct bNodeSocket *sock;
|
||||
struct bNodeLink *link;
|
||||
float point[2];
|
||||
} bNodeSocketLink;
|
||||
};
|
||||
|
||||
static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb,
|
||||
bNodeSocket *sock,
|
||||
|
@ -142,12 +142,12 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb,
|
|||
{
|
||||
bNodeSocketLink *socklink, *prev;
|
||||
|
||||
socklink = MEM_callocN(sizeof(bNodeSocketLink), "socket link");
|
||||
socklink = (bNodeSocketLink *)MEM_callocN(sizeof(bNodeSocketLink), "socket link");
|
||||
socklink->sock = sock;
|
||||
socklink->link = link;
|
||||
copy_v2_v2(socklink->point, point);
|
||||
|
||||
for (prev = lb->last; prev; prev = prev->prev) {
|
||||
for (prev = (bNodeSocketLink *)lb->last; prev; prev = prev->prev) {
|
||||
if (prev->sock == sock) {
|
||||
break;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C,
|
|||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNodeTree *ntree = snode->edittree;
|
||||
bNode *reroute_node = NULL;
|
||||
bNode *reroute_node = nullptr;
|
||||
bNodeSocket *cursock = socklink->sock;
|
||||
float insert_point[2];
|
||||
int num_links;
|
||||
|
@ -184,12 +184,12 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C,
|
|||
socklink->link->fromnode,
|
||||
socklink->link->fromsock,
|
||||
reroute_node,
|
||||
reroute_node->inputs.first);
|
||||
(bNodeSocket *)reroute_node->inputs.first);
|
||||
}
|
||||
else {
|
||||
nodeAddLink(ntree,
|
||||
reroute_node,
|
||||
reroute_node->outputs.first,
|
||||
(bNodeSocket *)reroute_node->outputs.first,
|
||||
socklink->link->tonode,
|
||||
socklink->link->tosock);
|
||||
}
|
||||
|
@ -198,11 +198,11 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C,
|
|||
/* insert the reroute node into the link */
|
||||
if (in_out == SOCK_OUT) {
|
||||
socklink->link->fromnode = reroute_node;
|
||||
socklink->link->fromsock = reroute_node->outputs.first;
|
||||
socklink->link->fromsock = (bNodeSocket *)reroute_node->outputs.first;
|
||||
}
|
||||
else {
|
||||
socklink->link->tonode = reroute_node;
|
||||
socklink->link->tosock = reroute_node->inputs.first;
|
||||
socklink->link->tosock = (bNodeSocket *)reroute_node->inputs.first;
|
||||
}
|
||||
|
||||
add_v2_v2(insert_point, socklink->point);
|
||||
|
@ -259,7 +259,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
|
|||
BLI_listbase_clear(&output_links);
|
||||
BLI_listbase_clear(&input_links);
|
||||
|
||||
for (link = ntree->links.first; link; link = link->next) {
|
||||
for (link = (bNodeLink *)ntree->links.first; link; link = link->next) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -275,11 +275,11 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
|
|||
/* Create reroute nodes for intersected links.
|
||||
* Only one reroute if links share the same input/output socket.
|
||||
*/
|
||||
socklink = output_links.first;
|
||||
socklink = (bNodeSocketLink *)output_links.first;
|
||||
while (socklink) {
|
||||
socklink = add_reroute_do_socket_section(C, socklink, SOCK_OUT);
|
||||
}
|
||||
socklink = input_links.first;
|
||||
socklink = (bNodeSocketLink *)input_links.first;
|
||||
while (socklink) {
|
||||
socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ void NODE_OT_add_reroute(wmOperatorType *ot)
|
|||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
/* internal */
|
||||
RNA_def_int(ot->srna, "cursor", WM_CURSOR_CROSS, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
|
||||
}
|
||||
|
@ -337,10 +337,10 @@ static bNodeTree *node_add_group_get_and_poll_group_node_tree(Main *bmain,
|
|||
|
||||
bNodeTree *node_group = (bNodeTree *)BKE_libblock_find_name(bmain, ID_NT, name);
|
||||
if (!node_group) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *disabled_hint = NULL;
|
||||
const char *disabled_hint = nullptr;
|
||||
if ((node_group->type != ntree->type) || !nodeGroupPoll(ntree, node_group, &disabled_hint)) {
|
||||
if (disabled_hint) {
|
||||
BKE_reportf(op->reports,
|
||||
|
@ -358,7 +358,7 @@ static bNodeTree *node_add_group_get_and_poll_group_node_tree(Main *bmain,
|
|||
ntree->id.name + 2);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return node_group;
|
||||
|
@ -450,7 +450,7 @@ static Object *node_add_object_get_and_poll_object_node_tree(Main *bmain, wmOper
|
|||
|
||||
Object *object = (Object *)BKE_libblock_find_name(bmain, ID_OB, name);
|
||||
if (!object) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return object;
|
||||
|
@ -470,7 +470,7 @@ static int node_add_object_exec(bContext *C, wmOperator *op)
|
|||
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
||||
|
||||
bNode *object_node = node_add_node(
|
||||
C, NULL, GEO_NODE_OBJECT_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
C, nullptr, GEO_NODE_OBJECT_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
if (!object_node) {
|
||||
BKE_report(op->reports, RPT_WARNING, "Could not add node object");
|
||||
return OPERATOR_CANCELLED;
|
||||
|
@ -482,7 +482,7 @@ static int node_add_object_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
bNodeSocketValueObject *socket_data = sock->default_value;
|
||||
bNodeSocketValueObject *socket_data = (bNodeSocketValueObject *)sock->default_value;
|
||||
socket_data->value = object;
|
||||
id_us_plus(&object->id);
|
||||
|
||||
|
@ -554,7 +554,7 @@ static Tex *node_add_texture_get_and_poll_texture_node_tree(Main *bmain, wmOpera
|
|||
|
||||
Tex *texture = (Tex *)BKE_libblock_find_name(bmain, ID_TE, name);
|
||||
if (!texture) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return texture;
|
||||
|
@ -574,7 +574,7 @@ static int node_add_texture_exec(bContext *C, wmOperator *op)
|
|||
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
||||
|
||||
bNode *texture_node = node_add_node(C,
|
||||
NULL,
|
||||
nullptr,
|
||||
GEO_NODE_ATTRIBUTE_SAMPLE_TEXTURE,
|
||||
snode->runtime->cursor[0],
|
||||
snode->runtime->cursor[1]);
|
||||
|
@ -655,7 +655,7 @@ static Collection *node_add_collection_get_and_poll_collection_node_tree(Main *b
|
|||
|
||||
Collection *collection = (Collection *)BKE_libblock_find_name(bmain, ID_GR, name);
|
||||
if (!collection) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return collection;
|
||||
|
@ -675,7 +675,7 @@ static int node_add_collection_exec(bContext *C, wmOperator *op)
|
|||
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
||||
|
||||
bNode *collection_node = node_add_node(
|
||||
C, NULL, GEO_NODE_COLLECTION_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
C, nullptr, GEO_NODE_COLLECTION_INFO, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
if (!collection_node) {
|
||||
BKE_report(op->reports, RPT_WARNING, "Could not add node collection");
|
||||
return OPERATOR_CANCELLED;
|
||||
|
@ -687,7 +687,7 @@ static int node_add_collection_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
bNodeSocketValueCollection *socket_data = sock->default_value;
|
||||
bNodeSocketValueCollection *socket_data = (bNodeSocketValueCollection *)sock->default_value;
|
||||
socket_data->value = collection;
|
||||
id_us_plus(&collection->id);
|
||||
|
||||
|
@ -788,7 +788,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
|
|||
|
||||
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
||||
|
||||
node = node_add_node(C, NULL, type, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
node = node_add_node(C, nullptr, type, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
|
||||
if (!node) {
|
||||
BKE_report(op->reports, RPT_WARNING, "Could not add an image node");
|
||||
|
@ -801,7 +801,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
|
|||
* to get proper image source.
|
||||
*/
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
BKE_image_signal(bmain, ima, NULL, IMA_SIGNAL_RELOAD);
|
||||
BKE_image_signal(bmain, ima, nullptr, IMA_SIGNAL_RELOAD);
|
||||
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima);
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
|
|||
Main *bmain = CTX_data_main(C);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNode *node;
|
||||
ID *mask = NULL;
|
||||
ID *mask = nullptr;
|
||||
|
||||
/* check input variables */
|
||||
char name[MAX_ID_NAME - 2];
|
||||
|
@ -890,7 +890,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
|
|||
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
||||
|
||||
node = node_add_node(
|
||||
C, NULL, CMP_NODE_MASK, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
C, nullptr, CMP_NODE_MASK, snode->runtime->cursor[0], snode->runtime->cursor[1]);
|
||||
|
||||
if (!node) {
|
||||
BKE_report(op->reports, RPT_WARNING, "Could not add a mask node");
|
||||
|
@ -976,7 +976,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op)
|
|||
id_us_min(&ntree->id);
|
||||
|
||||
RNA_id_pointer_create(&ntree->id, &idptr);
|
||||
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
|
||||
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
|
||||
RNA_property_update(C, &ptr, prop);
|
||||
}
|
||||
else if (snode) {
|
||||
|
@ -993,7 +993,7 @@ static const EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C),
|
|||
PropertyRNA *UNUSED(prop),
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_node_tree_type_itemf(NULL, NULL, r_free);
|
||||
return rna_node_tree_type_itemf(nullptr, nullptr, r_free);
|
||||
}
|
||||
|
||||
void NODE_OT_new_node_tree(wmOperatorType *ot)
|
|
@ -83,7 +83,7 @@ enum {
|
|||
COM_RECALC_VIEWER = 2,
|
||||
};
|
||||
|
||||
typedef struct CompoJob {
|
||||
struct CompoJob {
|
||||
/* Input parameters. */
|
||||
Main *bmain;
|
||||
Scene *scene;
|
||||
|
@ -97,7 +97,7 @@ typedef struct CompoJob {
|
|||
const short *stop;
|
||||
short *do_update;
|
||||
float *progress;
|
||||
} CompoJob;
|
||||
};
|
||||
|
||||
float node_socket_calculate_height(const bNodeSocket *socket)
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ static int compo_get_recalc_flags(const bContext *C)
|
|||
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
if (area->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima = area->spacedata.first;
|
||||
SpaceImage *sima = (SpaceImage *)area->spacedata.first;
|
||||
if (sima->image) {
|
||||
if (sima->image->type == IMA_TYPE_R_RESULT) {
|
||||
recalc_flags |= COM_RECALC_COMPOSITE;
|
||||
|
@ -161,7 +161,7 @@ static int compo_get_recalc_flags(const bContext *C)
|
|||
}
|
||||
}
|
||||
else if (area->spacetype == SPACE_NODE) {
|
||||
SpaceNode *snode = area->spacedata.first;
|
||||
SpaceNode *snode = (SpaceNode *)area->spacedata.first;
|
||||
if (snode->flag & SNODE_BACKDRAW) {
|
||||
recalc_flags |= COM_RECALC_VIEWER;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ static int compo_get_recalc_flags(const bContext *C)
|
|||
/* called by compo, only to check job 'stop' value */
|
||||
static int compo_breakjob(void *cjv)
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
|
||||
/* without G.is_break 'ESC' wont quit - which annoys users */
|
||||
return (*(cj->stop)
|
||||
|
@ -188,7 +188,7 @@ static int compo_breakjob(void *cjv)
|
|||
/* called by compo, wmJob sends notifier */
|
||||
static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
|
||||
*(cj->do_update) = true;
|
||||
}
|
||||
|
@ -196,19 +196,19 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str))
|
|||
/* called by compo, wmJob sends notifier */
|
||||
static void compo_redrawjob(void *cjv)
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
|
||||
*(cj->do_update) = true;
|
||||
}
|
||||
|
||||
static void compo_freejob(void *cjv)
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
|
||||
if (cj->localtree) {
|
||||
ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree);
|
||||
}
|
||||
if (cj->compositor_depsgraph != NULL) {
|
||||
if (cj->compositor_depsgraph != nullptr) {
|
||||
DEG_graph_free(cj->compositor_depsgraph);
|
||||
}
|
||||
MEM_freeN(cj);
|
||||
|
@ -218,7 +218,7 @@ static void compo_freejob(void *cjv)
|
|||
* sliding buttons doesn't frustrate */
|
||||
static void compo_initjob(void *cjv)
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
Main *bmain = cj->bmain;
|
||||
Scene *scene = cj->scene;
|
||||
ViewLayer *view_layer = cj->view_layer;
|
||||
|
@ -243,12 +243,12 @@ static void compo_initjob(void *cjv)
|
|||
/* called before redraw notifiers, it moves finished previews over */
|
||||
static void compo_updatejob(void *UNUSED(cjv))
|
||||
{
|
||||
WM_main_add_notifier(NC_SCENE | ND_COMPO_RESULT, NULL);
|
||||
WM_main_add_notifier(NC_SCENE | ND_COMPO_RESULT, nullptr);
|
||||
}
|
||||
|
||||
static void compo_progressjob(void *cjv, float progress)
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
|
||||
*(cj->progress) = progress;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ static void compo_startjob(void *cjv,
|
|||
short *do_update,
|
||||
float *progress)
|
||||
{
|
||||
CompoJob *cj = cjv;
|
||||
CompoJob *cj = (CompoJob *)cjv;
|
||||
bNodeTree *ntree = cj->localtree;
|
||||
Scene *scene = cj->scene;
|
||||
|
||||
|
@ -311,9 +311,9 @@ static void compo_startjob(void *cjv,
|
|||
}
|
||||
}
|
||||
|
||||
ntree->test_break = NULL;
|
||||
ntree->stats_draw = NULL;
|
||||
ntree->progress = NULL;
|
||||
ntree->test_break = nullptr;
|
||||
ntree->stats_draw = nullptr;
|
||||
ntree->progress = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,7 +347,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
|
|||
"Compositing",
|
||||
WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS,
|
||||
WM_JOB_TYPE_COMPOSITE);
|
||||
CompoJob *cj = MEM_callocN(sizeof(CompoJob), "compo job");
|
||||
CompoJob *cj = (CompoJob *)MEM_callocN(sizeof(CompoJob), "compo job");
|
||||
|
||||
/* customdata for preview thread */
|
||||
cj->bmain = bmain;
|
||||
|
@ -359,7 +359,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
|
|||
/* setup job */
|
||||
WM_jobs_customdata_set(wm_job, cj, compo_freejob);
|
||||
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_COMPO_RESULT, NC_SCENE | ND_COMPO_RESULT);
|
||||
WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL);
|
||||
WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, nullptr);
|
||||
|
||||
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ void snode_notify(bContext *C, SpaceNode *snode)
|
|||
{
|
||||
ID *id = snode->id;
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_EDITED, nullptr);
|
||||
|
||||
if (ED_node_is_shader(snode)) {
|
||||
if (GS(id->name) == ID_MA) {
|
||||
|
@ -490,15 +490,15 @@ void ED_node_shader_default(const bContext *C, ID *id)
|
|||
}
|
||||
else if (ELEM(GS(id->name), ID_WO, ID_LA)) {
|
||||
/* Emission */
|
||||
bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
bNodeTree *ntree = ntreeAddTree(nullptr, "Shader Nodetree", ntreeType_Shader->idname);
|
||||
bNode *shader, *output;
|
||||
|
||||
if (GS(id->name) == ID_WO) {
|
||||
World *world = (World *)id;
|
||||
world->nodetree = ntree;
|
||||
|
||||
shader = nodeAddStaticNode(NULL, ntree, SH_NODE_BACKGROUND);
|
||||
output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_WORLD);
|
||||
shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_BACKGROUND);
|
||||
output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_WORLD);
|
||||
nodeAddLink(ntree,
|
||||
shader,
|
||||
nodeFindSocket(shader, SOCK_OUT, "Background"),
|
||||
|
@ -512,8 +512,8 @@ void ED_node_shader_default(const bContext *C, ID *id)
|
|||
Light *light = (Light *)id;
|
||||
light->nodetree = ntree;
|
||||
|
||||
shader = nodeAddStaticNode(NULL, ntree, SH_NODE_EMISSION);
|
||||
output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_LIGHT);
|
||||
shader = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION);
|
||||
output = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_LIGHT);
|
||||
nodeAddLink(ntree,
|
||||
shader,
|
||||
nodeFindSocket(shader, SOCK_OUT, "Emission"),
|
||||
|
@ -546,7 +546,7 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
|
|||
return;
|
||||
}
|
||||
|
||||
sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname);
|
||||
sce->nodetree = ntreeAddTree(nullptr, "Compositing Nodetree", ntreeType_Composite->idname);
|
||||
|
||||
sce->nodetree->chunksize = 256;
|
||||
sce->nodetree->edit_quality = NTREE_QUALITY_HIGH;
|
||||
|
@ -562,8 +562,8 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce)
|
|||
nodeSetActive(sce->nodetree, in);
|
||||
|
||||
/* links from color to color */
|
||||
bNodeSocket *fromsock = in->outputs.first;
|
||||
bNodeSocket *tosock = out->inputs.first;
|
||||
bNodeSocket *fromsock = (bNodeSocket *)in->outputs.first;
|
||||
bNodeSocket *tosock = (bNodeSocket *)out->inputs.first;
|
||||
nodeAddLink(sce->nodetree, in, fromsock, out, tosock);
|
||||
|
||||
ntreeUpdateTree(CTX_data_main(C), sce->nodetree);
|
||||
|
@ -581,7 +581,7 @@ void ED_node_texture_default(const bContext *C, Tex *tex)
|
|||
return;
|
||||
}
|
||||
|
||||
tex->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname);
|
||||
tex->nodetree = ntreeAddTree(nullptr, "Texture Nodetree", ntreeType_Texture->idname);
|
||||
|
||||
bNode *out = nodeAddStaticNode(C, tex->nodetree, TEX_NODE_OUTPUT);
|
||||
out->locx = 300.0f;
|
||||
|
@ -592,8 +592,8 @@ void ED_node_texture_default(const bContext *C, Tex *tex)
|
|||
in->locy = 300.0f;
|
||||
nodeSetActive(tex->nodetree, in);
|
||||
|
||||
bNodeSocket *fromsock = in->outputs.first;
|
||||
bNodeSocket *tosock = out->inputs.first;
|
||||
bNodeSocket *fromsock = (bNodeSocket *)in->outputs.first;
|
||||
bNodeSocket *tosock = (bNodeSocket *)out->inputs.first;
|
||||
nodeAddLink(tex->nodetree, in, fromsock, out, tosock);
|
||||
|
||||
ntreeUpdateTree(CTX_data_main(C), tex->nodetree);
|
||||
|
@ -618,24 +618,24 @@ void snode_set_context(const bContext *C)
|
|||
|
||||
if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) {
|
||||
/* current tree does not match selected type, clear tree path */
|
||||
ntree = NULL;
|
||||
id = NULL;
|
||||
from = NULL;
|
||||
ntree = nullptr;
|
||||
id = nullptr;
|
||||
from = nullptr;
|
||||
}
|
||||
|
||||
if (!(snode->flag & SNODE_PIN) || ntree == NULL) {
|
||||
if (!(snode->flag & SNODE_PIN) || ntree == nullptr) {
|
||||
if (treetype->get_from_context) {
|
||||
/* reset and update from context */
|
||||
ntree = NULL;
|
||||
id = NULL;
|
||||
from = NULL;
|
||||
ntree = nullptr;
|
||||
id = nullptr;
|
||||
from = nullptr;
|
||||
|
||||
treetype->get_from_context(C, treetype, &ntree, &id, &from);
|
||||
}
|
||||
}
|
||||
|
||||
if (snode->nodetree != ntree || snode->id != id || snode->from != from ||
|
||||
(snode->treepath.last == NULL && ntree)) {
|
||||
(snode->treepath.last == nullptr && ntree)) {
|
||||
ED_node_tree_start(snode, ntree, id, from);
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ void snode_update(SpaceNode *snode, bNode *node)
|
|||
*/
|
||||
|
||||
/* update all edited group nodes */
|
||||
bNodeTreePath *path = snode->treepath.last;
|
||||
bNodeTreePath *path = (bNodeTreePath *)snode->treepath.last;
|
||||
if (path) {
|
||||
bNodeTree *ngroup = path->nodetree;
|
||||
for (path = path->prev; path; path = path->prev) {
|
||||
|
@ -685,7 +685,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_acti
|
|||
|
||||
node->flag |= NODE_DO_OUTPUT;
|
||||
if (!was_output) {
|
||||
do_update = 1;
|
||||
do_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -734,7 +734,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node, bool *r_acti
|
|||
*r_active_texture_changed = true;
|
||||
}
|
||||
ED_node_tag_update_nodetree(bmain, ntree, node);
|
||||
WM_main_add_notifier(NC_IMAGE, NULL);
|
||||
WM_main_add_notifier(NC_IMAGE, nullptr);
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_MATERIAL | ND_NODES, node->id);
|
||||
|
@ -806,7 +806,7 @@ static bool edit_node_poll(bContext *C)
|
|||
static void edit_node_properties(wmOperatorType *ot)
|
||||
{
|
||||
/* XXX could node be a context pointer? */
|
||||
RNA_def_string(ot->srna, "node", NULL, MAX_NAME, "Node", "");
|
||||
RNA_def_string(ot->srna, "node", nullptr, MAX_NAME, "Node", "");
|
||||
RNA_def_int(ot->srna, "socket", 0, 0, MAX_SOCKET, "Socket", "", 0, MAX_SOCKET);
|
||||
RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Side", "");
|
||||
}
|
||||
|
@ -838,7 +838,7 @@ static void edit_node_properties_get(
|
|||
wmOperator *op, bNodeTree *ntree, bNode **r_node, bNodeSocket **r_sock, int *r_in_out)
|
||||
{
|
||||
bNode *node;
|
||||
bNodeSocket *sock = NULL;
|
||||
bNodeSocket *sock = nullptr;
|
||||
char nodename[MAX_NAME];
|
||||
int sockindex;
|
||||
int in_out;
|
||||
|
@ -876,29 +876,30 @@ static void edit_node_properties_get(
|
|||
static bNode *visible_node(SpaceNode *snode, const rctf *rct)
|
||||
{
|
||||
LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode->edittree->nodes) {
|
||||
if (BLI_rctf_isect(&node->totr, rct, NULL)) {
|
||||
if (BLI_rctf_isect(&node->totr, rct, nullptr)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* ********************** size widget operator ******************** */
|
||||
|
||||
typedef struct NodeSizeWidget {
|
||||
struct NodeSizeWidget {
|
||||
float mxstart, mystart;
|
||||
float oldlocx, oldlocy;
|
||||
float oldoffsetx, oldoffsety;
|
||||
float oldwidth, oldheight;
|
||||
int directions;
|
||||
} NodeSizeWidget;
|
||||
};
|
||||
|
||||
static void node_resize_init(
|
||||
bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir)
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data");
|
||||
NodeSizeWidget *nsw = (NodeSizeWidget *)MEM_callocN(sizeof(NodeSizeWidget),
|
||||
"size widget op data");
|
||||
|
||||
op->customdata = nsw;
|
||||
nsw->mxstart = snode->runtime->cursor[0] * UI_DPI_FAC;
|
||||
|
@ -926,7 +927,7 @@ static void node_resize_exit(bContext *C, wmOperator *op, bool cancel)
|
|||
if (cancel) {
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNode *node = nodeGetActive(snode->edittree);
|
||||
NodeSizeWidget *nsw = op->customdata;
|
||||
NodeSizeWidget *nsw = (NodeSizeWidget *)op->customdata;
|
||||
|
||||
node->locx = nsw->oldlocx;
|
||||
node->locy = nsw->oldlocy;
|
||||
|
@ -937,7 +938,7 @@ static void node_resize_exit(bContext *C, wmOperator *op, bool cancel)
|
|||
}
|
||||
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
op->customdata = nullptr;
|
||||
}
|
||||
|
||||
static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
@ -945,7 +946,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
bNode *node = nodeGetActive(snode->edittree);
|
||||
NodeSizeWidget *nsw = op->customdata;
|
||||
NodeSizeWidget *nsw = (NodeSizeWidget *)op->customdata;
|
||||
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE: {
|
||||
|
@ -1112,7 +1113,7 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
|
|||
else {
|
||||
/* hide unused sockets */
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
|
||||
if (sock->link == NULL) {
|
||||
if (sock->link == nullptr) {
|
||||
sock->flag |= SOCK_HIDDEN;
|
||||
}
|
||||
}
|
||||
|
@ -1128,17 +1129,17 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
|
|||
static bool cursor_isect_multi_input_socket(const float cursor[2], const bNodeSocket *socket)
|
||||
{
|
||||
const float node_socket_height = node_socket_calculate_height(socket);
|
||||
const rctf multi_socket_rect = {
|
||||
.xmin = socket->locx - NODE_SOCKSIZE * 4.0f,
|
||||
.xmax = socket->locx + NODE_SOCKSIZE * 2.0f,
|
||||
/*.xmax = socket->locx + NODE_SOCKSIZE * 5.5f
|
||||
* would be the same behavior as for regular sockets.
|
||||
* But keep it smaller because for multi-input socket you
|
||||
* sometimes want to drag the link to the other side, if you may
|
||||
* accidentally pick the wrong link otherwise. */
|
||||
.ymin = socket->locy - node_socket_height,
|
||||
.ymax = socket->locy + node_socket_height,
|
||||
};
|
||||
rctf multi_socket_rect;
|
||||
/*.xmax = socket->locx + NODE_SOCKSIZE * 5.5f
|
||||
* would be the same behavior as for regular sockets.
|
||||
* But keep it smaller because for multi-input socket you
|
||||
* sometimes want to drag the link to the other side, if you may
|
||||
* accidentally pick the wrong link otherwise. */
|
||||
BLI_rctf_init(&multi_socket_rect,
|
||||
socket->locx - NODE_SOCKSIZE * 4.0f,
|
||||
socket->locx + NODE_SOCKSIZE * 2.0f,
|
||||
socket->locy - node_socket_height,
|
||||
socket->locy + node_socket_height);
|
||||
if (BLI_rctf_isect_pt(&multi_socket_rect, cursor[0], cursor[1])) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1151,8 +1152,8 @@ int node_find_indicated_socket(
|
|||
{
|
||||
rctf rect;
|
||||
|
||||
*nodep = NULL;
|
||||
*sockp = NULL;
|
||||
*nodep = nullptr;
|
||||
*sockp = nullptr;
|
||||
|
||||
/* check if we click in a socket */
|
||||
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
|
||||
|
@ -1244,7 +1245,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
|
|||
|
||||
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
||||
|
||||
bNode *lastnode = ntree->nodes.last;
|
||||
bNode *lastnode = (bNode *)ntree->nodes.last;
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->flag & SELECT) {
|
||||
BKE_node_copy_store_new_pointers(ntree, node, LIB_ID_COPY_DEFAULT);
|
||||
|
@ -1262,14 +1263,14 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
|
|||
/* copy links between selected nodes
|
||||
* NB: this depends on correct node->new_node and sock->new_sock pointers from above copy!
|
||||
*/
|
||||
bNodeLink *lastlink = ntree->links.last;
|
||||
bNodeLink *lastlink = (bNodeLink *)ntree->links.last;
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
|
||||
/* This creates new links between copied nodes.
|
||||
* If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)!
|
||||
* If keep_inputs is set, also copies input links from unselected (when fromnode==nullptr)!
|
||||
*/
|
||||
if (link->tonode && (link->tonode->flag & NODE_SELECT) &&
|
||||
(keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) {
|
||||
bNodeLink *newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
|
||||
bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "bNodeLink");
|
||||
newlink->flag = link->flag;
|
||||
newlink->tonode = link->tonode->new_node;
|
||||
newlink->tosock = link->tosock->new_sock;
|
||||
|
@ -1353,7 +1354,7 @@ void NODE_OT_duplicate(wmOperatorType *ot)
|
|||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(
|
||||
ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes");
|
||||
ot->srna, "keep_inputs", false, "Keep Inputs", "Keep the input links to duplicated nodes");
|
||||
}
|
||||
|
||||
bool ED_node_select_check(ListBase *lb)
|
||||
|
@ -1414,7 +1415,7 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
if ((node->type == CMP_NODE_R_LAYERS) ||
|
||||
(node->type == CMP_NODE_CRYPTOMATTE && node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER)) {
|
||||
ID *id = node->id;
|
||||
if (id == NULL) {
|
||||
if (id == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (id->tag & LIB_TAG_DOIT) {
|
||||
|
@ -1453,7 +1454,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
/* This is actually a test whether scene is used by the compositor or not.
|
||||
* All the nodes are using same render result, so there is no need to do
|
||||
* anything smart about check how exactly scene is used. */
|
||||
bNode *node = NULL;
|
||||
bNode *node = nullptr;
|
||||
LISTBASE_FOREACH (bNode *, node_iter, &sce->nodetree->nodes) {
|
||||
if (node_iter->id == (ID *)sce) {
|
||||
node = node_iter;
|
||||
|
@ -1462,7 +1463,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
if (node) {
|
||||
ViewLayer *view_layer = BLI_findlink(&sce->view_layers, node->custom1);
|
||||
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, node->custom1);
|
||||
|
||||
if (view_layer) {
|
||||
PointerRNA op_ptr;
|
||||
|
@ -1554,13 +1555,13 @@ static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* sanity checking (poll callback checks this already) */
|
||||
if ((snode == NULL) || (snode->edittree == NULL)) {
|
||||
if ((snode == nullptr) || (snode->edittree == nullptr)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
node_flag_toggle_exec(snode, NODE_HIDDEN);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1585,7 +1586,7 @@ static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* sanity checking (poll callback checks this already) */
|
||||
if ((snode == NULL) || (snode->edittree == NULL)) {
|
||||
if ((snode == nullptr) || (snode->edittree == nullptr)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -1618,13 +1619,13 @@ static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* sanity checking (poll callback checks this already) */
|
||||
if ((snode == NULL) || (snode->edittree == NULL)) {
|
||||
if ((snode == nullptr) || (snode->edittree == nullptr)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
node_flag_toggle_exec(snode, NODE_OPTIONS);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1649,7 +1650,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* sanity checking (poll callback checks this already) */
|
||||
if ((snode == NULL) || (snode->edittree == NULL)) {
|
||||
if ((snode == nullptr) || (snode->edittree == nullptr)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -1674,7 +1675,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1870,12 +1871,12 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op)
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
||||
bNodeTree *ntree = NULL;
|
||||
bNode *node = NULL;
|
||||
bNodeTree *ntree = nullptr;
|
||||
bNode *node = nullptr;
|
||||
char file_path[MAX_NAME];
|
||||
|
||||
if (ptr.data) {
|
||||
node = ptr.data;
|
||||
node = (bNode *)ptr.data;
|
||||
ntree = (bNodeTree *)ptr.owner_id;
|
||||
}
|
||||
else if (snode && snode->edittree) {
|
||||
|
@ -1919,11 +1920,11 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U
|
|||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
||||
bNodeTree *ntree = NULL;
|
||||
bNode *node = NULL;
|
||||
bNodeTree *ntree = nullptr;
|
||||
bNode *node = nullptr;
|
||||
|
||||
if (ptr.data) {
|
||||
node = ptr.data;
|
||||
node = (bNode *)ptr.data;
|
||||
ntree = (bNodeTree *)ptr.owner_id;
|
||||
}
|
||||
else if (snode && snode->edittree) {
|
||||
|
@ -1965,10 +1966,10 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
||||
bNode *node = NULL;
|
||||
bNode *node = nullptr;
|
||||
|
||||
if (ptr.data) {
|
||||
node = ptr.data;
|
||||
node = (bNode *)ptr.data;
|
||||
}
|
||||
else if (snode && snode->edittree) {
|
||||
node = nodeGetActive(snode->edittree);
|
||||
|
@ -1978,9 +1979,9 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
NodeImageMultiFile *nimf = node->storage;
|
||||
NodeImageMultiFile *nimf = (NodeImageMultiFile *)node->storage;
|
||||
|
||||
bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input);
|
||||
bNodeSocket *sock = (bNodeSocket *)BLI_findlink(&node->inputs, nimf->active_input);
|
||||
if (!sock) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
@ -2014,7 +2015,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op)
|
|||
void NODE_OT_output_file_move_active_socket(wmOperatorType *ot)
|
||||
{
|
||||
static const EnumPropertyItem direction_items[] = {
|
||||
{1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL}};
|
||||
{1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, {0, nullptr, 0, nullptr, nullptr}};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Move File Node Socket";
|
||||
|
@ -2059,7 +2060,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
ED_node_sort(ntree);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -2097,7 +2098,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
/* No ID refcounting, this node is virtual,
|
||||
* detached from any actual Blender data currently. */
|
||||
bNode *new_node = BKE_node_copy_store_new_pointers(
|
||||
NULL, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN);
|
||||
nullptr, node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN);
|
||||
BKE_node_clipboard_add_node(new_node);
|
||||
}
|
||||
}
|
||||
|
@ -2127,7 +2128,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
/* This creates new links between copied nodes. */
|
||||
if (link->tonode && (link->tonode->flag & NODE_SELECT) && link->fromnode &&
|
||||
(link->fromnode->flag & NODE_SELECT)) {
|
||||
bNodeLink *newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink");
|
||||
bNodeLink *newlink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "bNodeLink");
|
||||
newlink->flag = link->flag;
|
||||
newlink->tonode = link->tonode->new_node;
|
||||
newlink->tosock = link->tosock->new_sock;
|
||||
|
@ -2188,7 +2189,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
|
|||
/* make sure all clipboard nodes would be valid in the target tree */
|
||||
bool all_nodes_valid = true;
|
||||
LISTBASE_FOREACH (bNode *, node, clipboard_nodes_lb) {
|
||||
const char *disabled_hint = NULL;
|
||||
const char *disabled_hint = nullptr;
|
||||
if (!node->typeinfo->poll_instance ||
|
||||
!node->typeinfo->poll_instance(node, ntree, &disabled_hint)) {
|
||||
all_nodes_valid = false;
|
||||
|
@ -2286,7 +2287,7 @@ static bNodeSocket *ntree_get_active_interface_socket(ListBase *lb)
|
|||
return socket;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int ntree_socket_add_exec(bContext *C, wmOperator *op)
|
||||
|
@ -2297,7 +2298,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
|
|||
PointerRNA ntree_ptr;
|
||||
RNA_id_pointer_create((ID *)ntree, &ntree_ptr);
|
||||
|
||||
const eNodeSocketInOut in_out = RNA_enum_get(op->ptr, "in_out");
|
||||
const eNodeSocketInOut in_out = (eNodeSocketInOut)RNA_enum_get(op->ptr, "in_out");
|
||||
ListBase *sockets = (in_out == SOCK_IN) ? &ntree->inputs : &ntree->outputs;
|
||||
|
||||
const char *default_name = (in_out == SOCK_IN) ? "Input" : "Output";
|
||||
|
@ -2328,7 +2329,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
|
|||
snode_notify(C, snode);
|
||||
snode_dag_update(C, snode);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -2356,11 +2357,11 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNodeTree *ntree = snode->edittree;
|
||||
const eNodeSocketInOut in_out = RNA_enum_get(op->ptr, "in_out");
|
||||
const eNodeSocketInOut in_out = (eNodeSocketInOut)RNA_enum_get(op->ptr, "in_out");
|
||||
|
||||
bNodeSocket *iosock = ntree_get_active_interface_socket(in_out == SOCK_IN ? &ntree->inputs :
|
||||
&ntree->outputs);
|
||||
if (iosock == NULL) {
|
||||
if (iosock == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -2378,7 +2379,7 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *op)
|
|||
snode_notify(C, snode);
|
||||
snode_dag_update(C, snode);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -2404,7 +2405,7 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot)
|
|||
static const EnumPropertyItem move_direction_items[] = {
|
||||
{1, "UP", 0, "Up", ""},
|
||||
{2, "DOWN", 0, "Down", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int ntree_socket_move_exec(bContext *C, wmOperator *op)
|
||||
|
@ -2413,12 +2414,12 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
|
|||
bNodeTree *ntree = snode->edittree;
|
||||
int direction = RNA_enum_get(op->ptr, "direction");
|
||||
|
||||
const eNodeSocketInOut in_out = RNA_enum_get(op->ptr, "in_out");
|
||||
const eNodeSocketInOut in_out = (eNodeSocketInOut)RNA_enum_get(op->ptr, "in_out");
|
||||
ListBase *sockets = in_out == SOCK_IN ? &ntree->inputs : &ntree->outputs;
|
||||
|
||||
bNodeSocket *iosock = ntree_get_active_interface_socket(sockets);
|
||||
|
||||
if (iosock == NULL) {
|
||||
if (iosock == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -2453,7 +2454,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op)
|
|||
snode_notify(C, snode);
|
||||
snode_dag_update(C, snode);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -2486,18 +2487,18 @@ static bool node_shader_script_update_poll(bContext *C)
|
|||
|
||||
/* test if we have a render engine that supports shaders scripts */
|
||||
if (!(type && type->update_script_node)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* see if we have a shader script node in context */
|
||||
bNode *node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
|
||||
bNode *node = (bNode *)CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data;
|
||||
|
||||
if (!node && snode && snode->edittree) {
|
||||
node = nodeGetActive(snode->edittree);
|
||||
}
|
||||
|
||||
if (node && node->type == SH_NODE_SCRIPT) {
|
||||
NodeShaderScript *nss = node->storage;
|
||||
NodeShaderScript *nss = (NodeShaderScript *)node->storage;
|
||||
|
||||
if (node->id || nss->filepath[0]) {
|
||||
return ED_operator_node_editable(C);
|
||||
|
@ -2505,14 +2506,14 @@ static bool node_shader_script_update_poll(bContext *C)
|
|||
}
|
||||
|
||||
/* see if we have a text datablock in context */
|
||||
Text *text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
|
||||
Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
|
||||
if (text) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* we don't check if text datablock is actually in use, too slow for poll */
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* recursively check for script nodes in groups using this text and update */
|
||||
|
@ -2556,11 +2557,11 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
|
|||
engine->reports = op->reports;
|
||||
|
||||
/* get node */
|
||||
bNodeTree *ntree_base = NULL;
|
||||
bNode *node = NULL;
|
||||
bNodeTree *ntree_base = nullptr;
|
||||
bNode *node = nullptr;
|
||||
if (nodeptr.data) {
|
||||
ntree_base = (bNodeTree *)nodeptr.owner_id;
|
||||
node = nodeptr.data;
|
||||
node = (bNode *)nodeptr.data;
|
||||
}
|
||||
else if (snode && snode->edittree) {
|
||||
ntree_base = snode->edittree;
|
||||
|
@ -2575,7 +2576,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
else {
|
||||
/* update all nodes using text datablock */
|
||||
Text *text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
|
||||
Text *text = (Text *)CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data;
|
||||
|
||||
if (text) {
|
||||
/* clear flags for recursion check */
|
||||
|
@ -2647,7 +2648,7 @@ static int viewer_border_exec(bContext *C, wmOperator *op)
|
|||
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
||||
|
||||
Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
|
||||
|
||||
if (ibuf) {
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
@ -2683,7 +2684,7 @@ static int viewer_border_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
snode_notify(C, snode);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
}
|
||||
else {
|
||||
btree->flag &= ~NTREE_VIEWER_BORDER;
|
||||
|
@ -2723,7 +2724,7 @@ static int clear_viewer_border_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
btree->flag &= ~NTREE_VIEWER_BORDER;
|
||||
snode_notify(C, snode);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -2749,11 +2750,11 @@ static int node_cryptomatte_add_socket_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
||||
bNodeTree *ntree = NULL;
|
||||
bNode *node = NULL;
|
||||
bNodeTree *ntree = nullptr;
|
||||
bNode *node = nullptr;
|
||||
|
||||
if (ptr.data) {
|
||||
node = ptr.data;
|
||||
node = (bNode *)ptr.data;
|
||||
ntree = (bNodeTree *)ptr.owner_id;
|
||||
}
|
||||
else if (snode && snode->edittree) {
|
||||
|
@ -2793,11 +2794,11 @@ static int node_cryptomatte_remove_socket_exec(bContext *C, wmOperator *UNUSED(o
|
|||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
PointerRNA ptr = CTX_data_pointer_get(C, "node");
|
||||
bNodeTree *ntree = NULL;
|
||||
bNode *node = NULL;
|
||||
bNodeTree *ntree = nullptr;
|
||||
bNode *node = nullptr;
|
||||
|
||||
if (ptr.data) {
|
||||
node = ptr.data;
|
||||
node = (bNode *)ptr.data;
|
||||
ntree = (bNodeTree *)ptr.owner_id;
|
||||
}
|
||||
else if (snode && snode->edittree) {
|
|
@ -21,7 +21,7 @@
|
|||
* \ingroup spnode
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -135,7 +135,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
|
|||
if (node && STREQ(node->idname, node_idname)) {
|
||||
return node;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -165,7 +165,7 @@ static int node_group_edit_exec(bContext *C, wmOperator *op)
|
|||
ED_node_tree_pop(snode);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_NODES, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -200,7 +200,8 @@ void NODE_OT_group_edit(wmOperatorType *ot)
|
|||
static AnimationBasePathChange *animation_basepath_change_new(const char *src_basepath,
|
||||
const char *dst_basepath)
|
||||
{
|
||||
AnimationBasePathChange *basepath_change = MEM_callocN(sizeof(*basepath_change), AT);
|
||||
AnimationBasePathChange *basepath_change = (AnimationBasePathChange *)MEM_callocN(
|
||||
sizeof(*basepath_change), AT);
|
||||
basepath_change->src_basepath = src_basepath;
|
||||
basepath_change->dst_basepath = dst_basepath;
|
||||
return basepath_change;
|
||||
|
@ -220,11 +221,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
{
|
||||
/* clear new pointers, set in copytree */
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
node->new_node = NULL;
|
||||
node->new_node = nullptr;
|
||||
}
|
||||
|
||||
ListBase anim_basepaths = {NULL, NULL};
|
||||
LinkNode *nodes_delayed_free = NULL;
|
||||
ListBase anim_basepaths = {nullptr, nullptr};
|
||||
LinkNode *nodes_delayed_free = nullptr;
|
||||
bNodeTree *ngroup = (bNodeTree *)gnode->id;
|
||||
|
||||
/* wgroup is a temporary copy of the NodeTree we're merging in
|
||||
|
@ -247,7 +248,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
/* keep track of this node's RNA "base" path (the part of the path identifying the node)
|
||||
* if the old nodetree has animation data which potentially covers this node
|
||||
*/
|
||||
const char *old_animation_basepath = NULL;
|
||||
const char *old_animation_basepath = nullptr;
|
||||
if (wgroup->adt) {
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
|
||||
|
@ -277,7 +278,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
node->flag |= NODE_SELECT;
|
||||
}
|
||||
|
||||
bNodeLink *glinks_first = ntree->links.last;
|
||||
bNodeLink *glinks_first = (bNodeLink *)ntree->links.last;
|
||||
|
||||
/* Add internal links to the ntree */
|
||||
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &wgroup->links) {
|
||||
|
@ -285,10 +286,10 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
BLI_addtail(&ntree->links, link);
|
||||
}
|
||||
|
||||
bNodeLink *glinks_last = ntree->links.last;
|
||||
bNodeLink *glinks_last = (bNodeLink *)ntree->links.last;
|
||||
|
||||
/* and copy across the animation,
|
||||
* note that the animation data's action can be NULL here */
|
||||
* note that the animation data's action can be nullptr here */
|
||||
if (wgroup->adt) {
|
||||
bAction *waction;
|
||||
|
||||
|
@ -307,7 +308,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
/* free temp action too */
|
||||
if (waction) {
|
||||
BKE_id_free(bmain, waction);
|
||||
wgroup->adt->action = NULL;
|
||||
wgroup->adt->action = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,14 +318,14 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
/* restore external links to and from the gnode */
|
||||
|
||||
/* input links */
|
||||
if (glinks_first != NULL) {
|
||||
if (glinks_first != nullptr) {
|
||||
for (bNodeLink *link = glinks_first->next; link != glinks_last->next; link = link->next) {
|
||||
if (link->fromnode->type == NODE_GROUP_INPUT) {
|
||||
const char *identifier = link->fromsock->identifier;
|
||||
int num_external_links = 0;
|
||||
|
||||
/* find external links to this input */
|
||||
for (bNodeLink *tlink = ntree->links.first; tlink != glinks_first->next;
|
||||
for (bNodeLink *tlink = (bNodeLink *)ntree->links.first; tlink != glinks_first->next;
|
||||
tlink = tlink->next) {
|
||||
if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) {
|
||||
nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock);
|
||||
|
@ -348,10 +349,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
}
|
||||
|
||||
/* Also iterate over new links to cover passthrough links. */
|
||||
glinks_last = ntree->links.last;
|
||||
glinks_last = (bNodeLink *)ntree->links.last;
|
||||
|
||||
/* output links */
|
||||
for (bNodeLink *link = ntree->links.first; link != glinks_first->next; link = link->next) {
|
||||
for (bNodeLink *link = (bNodeLink *)ntree->links.first; link != glinks_first->next;
|
||||
link = link->next) {
|
||||
if (link->fromnode == gnode) {
|
||||
const char *identifier = link->fromsock->identifier;
|
||||
int num_internal_links = 0;
|
||||
|
@ -384,7 +386,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
|
|||
}
|
||||
|
||||
while (nodes_delayed_free) {
|
||||
bNode *node = BLI_linklist_pop(&nodes_delayed_free);
|
||||
bNode *node = (bNode *)BLI_linklist_pop(&nodes_delayed_free);
|
||||
nodeRemoveNode(bmain, ntree, node, false);
|
||||
}
|
||||
|
||||
|
@ -455,10 +457,10 @@ static int node_group_separate_selected(
|
|||
|
||||
/* clear new pointers, set in BKE_node_copy_ex(). */
|
||||
LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
|
||||
node->new_node = NULL;
|
||||
node->new_node = nullptr;
|
||||
}
|
||||
|
||||
ListBase anim_basepaths = {NULL, NULL};
|
||||
ListBase anim_basepaths = {nullptr, nullptr};
|
||||
|
||||
/* add selected nodes into the ntree */
|
||||
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ngroup->nodes) {
|
||||
|
@ -543,7 +545,7 @@ static int node_group_separate_selected(
|
|||
}
|
||||
|
||||
/* and copy across the animation,
|
||||
* note that the animation data's action can be NULL here */
|
||||
* note that the animation data's action can be nullptr here */
|
||||
if (ngroup->adt) {
|
||||
/* now perform the moving */
|
||||
BKE_animdata_transfer_by_basepath(bmain, &ngroup->id, &ntree->id, &anim_basepaths);
|
||||
|
@ -562,16 +564,16 @@ static int node_group_separate_selected(
|
|||
return 1;
|
||||
}
|
||||
|
||||
typedef enum eNodeGroupSeparateType {
|
||||
enum eNodeGroupSeparateType {
|
||||
NODE_GS_COPY,
|
||||
NODE_GS_MOVE,
|
||||
} eNodeGroupSeparateType;
|
||||
};
|
||||
|
||||
/* Operator Property */
|
||||
static const EnumPropertyItem node_group_separate_types[] = {
|
||||
{NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"},
|
||||
{NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static int node_group_separate_exec(bContext *C, wmOperator *op)
|
||||
|
@ -628,8 +630,8 @@ static int node_group_separate_invoke(bContext *C,
|
|||
uiLayout *layout = UI_popup_menu_layout(pup);
|
||||
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
|
||||
uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY);
|
||||
uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE);
|
||||
uiItemEnumO(layout, "NODE_OT_group_separate", nullptr, 0, "type", NODE_GS_COPY);
|
||||
uiItemEnumO(layout, "NODE_OT_group_separate", nullptr, 0, "type", NODE_GS_MOVE);
|
||||
|
||||
UI_popup_menu_end(C, pup);
|
||||
|
||||
|
@ -674,12 +676,12 @@ static bool node_group_make_test_selected(bNodeTree *ntree,
|
|||
int ok = true;
|
||||
|
||||
/* make a local pseudo node tree to pass to the node poll functions */
|
||||
bNodeTree *ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname);
|
||||
bNodeTree *ngroup = ntreeAddTree(nullptr, "Pseudo Node Group", ntree_idname);
|
||||
|
||||
/* check poll functions for selected nodes */
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node_group_make_use_node(node, gnode)) {
|
||||
const char *disabled_hint = NULL;
|
||||
const char *disabled_hint = nullptr;
|
||||
if (node->typeinfo->poll_instance &&
|
||||
!node->typeinfo->poll_instance(node, ngroup, &disabled_hint)) {
|
||||
if (disabled_hint) {
|
||||
|
@ -781,7 +783,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree,
|
|||
expose_visible = true;
|
||||
}
|
||||
|
||||
ListBase anim_basepaths = {NULL, NULL};
|
||||
ListBase anim_basepaths = {nullptr, nullptr};
|
||||
|
||||
/* move nodes over */
|
||||
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
|
||||
|
@ -995,10 +997,10 @@ static bNode *node_group_make_from_selected(const bContext *C,
|
|||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
float min[2], max[2];
|
||||
const int totselect = node_get_selected_minmax(ntree, NULL, min, max, false);
|
||||
const int totselect = node_get_selected_minmax(ntree, nullptr, min, max, false);
|
||||
/* don't make empty group */
|
||||
if (totselect == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* new nodetree */
|
||||
|
@ -1029,7 +1031,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
|
|||
|
||||
ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
|
||||
|
||||
if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) {
|
||||
if (!node_group_make_test_selected(ntree, nullptr, ntree_idname, op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1044,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
|
|||
if (ngroup) {
|
||||
ED_node_tree_push(snode, ngroup, gnode);
|
||||
LISTBASE_FOREACH (bNode *, node, &ngroup->nodes) {
|
||||
sort_multi_input_socket_links(snode, node, NULL, NULL);
|
||||
sort_multi_input_socket_links(snode, node, nullptr, nullptr);
|
||||
}
|
||||
ntreeUpdateTree(bmain, ngroup);
|
||||
}
|
|
@ -60,7 +60,7 @@
|
|||
static bool ntree_has_drivers(bNodeTree *ntree)
|
||||
{
|
||||
const AnimData *adt = BKE_animdata_from_id(&ntree->id);
|
||||
if (adt == NULL) {
|
||||
if (adt == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return !BLI_listbase_is_empty(&adt->drivers);
|
||||
|
@ -102,7 +102,7 @@ static bool node_group_has_output_dfs(bNode *node)
|
|||
return false;
|
||||
}
|
||||
ntree->id.tag |= LIB_TAG_DOIT;
|
||||
for (bNode *current_node = ntree->nodes.first; current_node != NULL;
|
||||
for (bNode *current_node = (bNode *)ntree->nodes.first; current_node != nullptr;
|
||||
current_node = current_node->next) {
|
||||
if (current_node->type == NODE_GROUP) {
|
||||
if (current_node->id && node_group_has_output_dfs(current_node)) {
|
||||
|
@ -120,7 +120,7 @@ static bool node_group_has_output(Main *bmain, bNode *node)
|
|||
{
|
||||
BLI_assert(ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP));
|
||||
bNodeTree *ntree = (bNodeTree *)node->id;
|
||||
if (ntree == NULL) {
|
||||
if (ntree == nullptr) {
|
||||
return false;
|
||||
}
|
||||
BKE_main_id_tag_listbase(&bmain->nodetrees, LIB_TAG_DOIT, false);
|
||||
|
@ -145,7 +145,7 @@ bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
|
|||
* is connected to and so eventually.
|
||||
*/
|
||||
if (ELEM(current_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
|
||||
if (current_node->id != NULL && ntree_has_drivers((bNodeTree *)current_node->id)) {
|
||||
if (current_node->id != nullptr && ntree_has_drivers((bNodeTree *)current_node->id)) {
|
||||
return true;
|
||||
}
|
||||
if (ntree_check_nodes_connected(ntree, node, current_node) &&
|
||||
|
@ -164,12 +164,12 @@ bool node_connected_to_output(Main *bmain, bNodeTree *ntree, bNode *node)
|
|||
|
||||
/* ****************** Add *********************** */
|
||||
|
||||
typedef struct bNodeListItem {
|
||||
struct bNodeListItem {
|
||||
struct bNodeListItem *next, *prev;
|
||||
struct bNode *node;
|
||||
} bNodeListItem;
|
||||
};
|
||||
|
||||
typedef struct NodeInsertOfsData {
|
||||
struct NodeInsertOfsData {
|
||||
bNodeTree *ntree;
|
||||
bNode *insert; /* inserted node */
|
||||
bNode *prev, *next; /* prev/next node in the chain */
|
||||
|
@ -178,7 +178,7 @@ typedef struct NodeInsertOfsData {
|
|||
wmTimer *anim_timer;
|
||||
|
||||
float offset_x; /* offset to apply to node chain */
|
||||
} NodeInsertOfsData;
|
||||
};
|
||||
|
||||
static void clear_picking_highlight(ListBase *links)
|
||||
{
|
||||
|
@ -189,8 +189,8 @@ static void clear_picking_highlight(ListBase *links)
|
|||
|
||||
static LinkData *create_drag_link(Main *bmain, SpaceNode *snode, bNode *node, bNodeSocket *sock)
|
||||
{
|
||||
LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
|
||||
bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
|
||||
LinkData *linkdata = (LinkData *)MEM_callocN(sizeof(LinkData), "drag link op link data");
|
||||
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link");
|
||||
linkdata->data = oplink;
|
||||
if (sock->in_out == SOCK_OUT) {
|
||||
oplink->fromnode = node;
|
||||
|
@ -225,10 +225,10 @@ static void pick_link(const bContext *C,
|
|||
BLI_addtail(&nldrag->links, linkdata);
|
||||
nodeRemLink(snode->edittree, link_to_pick);
|
||||
|
||||
BLI_assert(nldrag->last_node_hovered_while_dragging_a_link != NULL);
|
||||
BLI_assert(nldrag->last_node_hovered_while_dragging_a_link != nullptr);
|
||||
|
||||
sort_multi_input_socket_links(
|
||||
snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, NULL);
|
||||
snode, nldrag->last_node_hovered_while_dragging_a_link, nullptr, nullptr);
|
||||
|
||||
/* Send changed event to original link->tonode. */
|
||||
if (node) {
|
||||
|
@ -256,7 +256,7 @@ static void pick_input_link_by_link_intersect(const bContext *C,
|
|||
|
||||
const int resolution = NODE_LINK_RESOL;
|
||||
|
||||
bNodeLink *link_to_pick = NULL;
|
||||
bNodeLink *link_to_pick = nullptr;
|
||||
clear_picking_highlight(&snode->edittree->links);
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (link->tosock == socket) {
|
||||
|
@ -305,8 +305,8 @@ static void pick_input_link_by_link_intersect(const bContext *C,
|
|||
|
||||
static int sort_nodes_locx(const void *a, const void *b)
|
||||
{
|
||||
const bNodeListItem *nli1 = a;
|
||||
const bNodeListItem *nli2 = b;
|
||||
const bNodeListItem *nli1 = (const bNodeListItem *)a;
|
||||
const bNodeListItem *nli2 = (const bNodeListItem *)b;
|
||||
const bNode *node1 = nli1->node;
|
||||
const bNode *node2 = nli2->node;
|
||||
|
||||
|
@ -319,14 +319,14 @@ static int sort_nodes_locx(const void *a, const void *b)
|
|||
static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
|
||||
{
|
||||
if (nodeSocketIsHidden(sock)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!allow_used && (sock->flag & SOCK_IN_USE)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bNodeSocket *best_socket_output(bNodeTree *ntree,
|
||||
|
@ -374,10 +374,10 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree,
|
|||
/* Always allow linking to an reroute node. The socket type of the reroute sockets might change
|
||||
* after the link has been created. */
|
||||
if (node->type == NODE_REROUTE) {
|
||||
return node->outputs.first;
|
||||
return (bNodeSocket *)node->outputs.first;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* this is a bit complicated, but designed to prioritize finding
|
||||
|
@ -409,7 +409,7 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool snode_autoconnect_input(SpaceNode *snode,
|
||||
|
@ -430,10 +430,10 @@ static bool snode_autoconnect_input(SpaceNode *snode,
|
|||
return true;
|
||||
}
|
||||
|
||||
typedef struct LinkAndPosition {
|
||||
struct LinkAndPosition {
|
||||
struct bNodeLink *link;
|
||||
float multi_socket_position[2];
|
||||
} LinkAndPosition;
|
||||
};
|
||||
|
||||
static int compare_link_by_y_position(const void *a, const void *b)
|
||||
{
|
||||
|
@ -457,14 +457,14 @@ void sort_multi_input_socket_links(SpaceNode *snode,
|
|||
}
|
||||
/* The total is calculated in #node_update_nodetree, which runs before this draw step. */
|
||||
int total_inputs = socket->total_inputs + 1;
|
||||
struct LinkAndPosition **input_links = MEM_malloc_arrayN(
|
||||
struct LinkAndPosition **input_links = (LinkAndPosition **)MEM_malloc_arrayN(
|
||||
total_inputs, sizeof(LinkAndPosition *), __func__);
|
||||
|
||||
int index = 0;
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (link->tosock == socket) {
|
||||
struct LinkAndPosition *link_and_position = MEM_callocN(sizeof(struct LinkAndPosition),
|
||||
__func__);
|
||||
struct LinkAndPosition *link_and_position = (LinkAndPosition *)MEM_callocN(
|
||||
sizeof(struct LinkAndPosition), __func__);
|
||||
link_and_position->link = link;
|
||||
node_link_calculate_multi_input_position(link->tosock->locx,
|
||||
link->tosock->locy,
|
||||
|
@ -477,7 +477,8 @@ void sort_multi_input_socket_links(SpaceNode *snode,
|
|||
}
|
||||
|
||||
if (drag_link) {
|
||||
LinkAndPosition *link_and_position = MEM_callocN(sizeof(LinkAndPosition), __func__);
|
||||
LinkAndPosition *link_and_position = (LinkAndPosition *)MEM_callocN(sizeof(LinkAndPosition),
|
||||
__func__);
|
||||
link_and_position->link = drag_link;
|
||||
copy_v2_v2(link_and_position->multi_socket_position, cursor);
|
||||
input_links[index] = link_and_position;
|
||||
|
@ -505,11 +506,12 @@ static void snode_autoconnect(Main *bmain,
|
|||
const bool replace)
|
||||
{
|
||||
bNodeTree *ntree = snode->edittree;
|
||||
ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list");
|
||||
ListBase *nodelist = (ListBase *)MEM_callocN(sizeof(ListBase), "items_list");
|
||||
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->flag & NODE_SELECT) {
|
||||
bNodeListItem *nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item");
|
||||
bNodeListItem *nli = (bNodeListItem *)MEM_mallocN(sizeof(bNodeListItem),
|
||||
"temporary node list item");
|
||||
nli->node = node;
|
||||
BLI_addtail(nodelist, nli);
|
||||
}
|
||||
|
@ -522,7 +524,7 @@ static void snode_autoconnect(Main *bmain,
|
|||
LISTBASE_FOREACH (bNodeListItem *, nli, nodelist) {
|
||||
bool has_selected_inputs = false;
|
||||
|
||||
if (nli->next == NULL) {
|
||||
if (nli->next == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -536,7 +538,7 @@ static void snode_autoconnect(Main *bmain,
|
|||
/* if there are selected sockets, connect those */
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock_to, &node_to->inputs) {
|
||||
if (sock_to->flag & SELECT) {
|
||||
has_selected_inputs = 1;
|
||||
has_selected_inputs = true;
|
||||
|
||||
if (!socket_is_available(ntree, sock_to, replace)) {
|
||||
continue;
|
||||
|
@ -595,7 +597,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
|
||||
/* context check */
|
||||
if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) {
|
||||
if (tonode == nullptr || BLI_listbase_is_empty(&tonode->outputs)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
|
@ -603,7 +605,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
|
|||
}
|
||||
|
||||
/* get viewer */
|
||||
bNode *viewer_node = NULL;
|
||||
bNode *viewer_node = nullptr;
|
||||
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
|
||||
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
if (node->flag & NODE_DO_OUTPUT) {
|
||||
|
@ -613,7 +615,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
|
|||
}
|
||||
}
|
||||
/* no viewer, we make one active */
|
||||
if (viewer_node == NULL) {
|
||||
if (viewer_node == nullptr) {
|
||||
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
|
||||
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
node->flag |= NODE_DO_OUTPUT;
|
||||
|
@ -623,14 +625,14 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
|
|||
}
|
||||
}
|
||||
|
||||
bNodeSocket *sock = NULL;
|
||||
bNodeLink *link = NULL;
|
||||
bNodeSocket *sock = nullptr;
|
||||
bNodeLink *link = nullptr;
|
||||
|
||||
/* try to find an already connected socket to cycle to the next */
|
||||
if (viewer_node) {
|
||||
link = NULL;
|
||||
link = nullptr;
|
||||
|
||||
for (link = snode->edittree->links.first; link; link = link->next) {
|
||||
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
||||
if (link->tonode == viewer_node && link->fromnode == tonode) {
|
||||
if (link->tosock == viewer_node->inputs.first) {
|
||||
break;
|
||||
|
@ -663,7 +665,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
|
|||
|
||||
/* find a socket starting from the first socket */
|
||||
if (!sock) {
|
||||
for (sock = tonode->outputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)tonode->outputs.first; sock; sock = sock->next) {
|
||||
if (!nodeSocketIsHidden(sock)) {
|
||||
break;
|
||||
}
|
||||
|
@ -674,24 +676,25 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
|
|||
/* add a new viewer if none exists yet */
|
||||
if (!viewer_node) {
|
||||
/* XXX location is a quick hack, just place it next to the linked socket */
|
||||
viewer_node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
|
||||
viewer_node = node_add_node(C, nullptr, CMP_NODE_VIEWER, sock->locx + 100, sock->locy);
|
||||
if (!viewer_node) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
link = NULL;
|
||||
link = nullptr;
|
||||
}
|
||||
else {
|
||||
/* get link to viewer */
|
||||
for (link = snode->edittree->links.first; link; link = link->next) {
|
||||
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
||||
if (link->tonode == viewer_node && link->tosock == viewer_node->inputs.first) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (link == NULL) {
|
||||
nodeAddLink(snode->edittree, tonode, sock, viewer_node, viewer_node->inputs.first);
|
||||
if (link == nullptr) {
|
||||
nodeAddLink(
|
||||
snode->edittree, tonode, sock, viewer_node, (bNodeSocket *)viewer_node->inputs.first);
|
||||
}
|
||||
else {
|
||||
link->fromnode = tonode;
|
||||
|
@ -779,7 +782,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
|
|||
if (tlink && tlink->fromsock == from) {
|
||||
if (from_count > from_link_limit) {
|
||||
nodeRemLink(ntree, tlink);
|
||||
tlink = NULL;
|
||||
tlink = nullptr;
|
||||
from_count--;
|
||||
}
|
||||
}
|
||||
|
@ -787,13 +790,13 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link)
|
|||
if (tlink && tlink->tosock == to) {
|
||||
if (to_count > to_link_limit) {
|
||||
nodeRemLink(ntree, tlink);
|
||||
tlink = NULL;
|
||||
tlink = nullptr;
|
||||
to_count--;
|
||||
}
|
||||
else if (tlink->fromsock == from) {
|
||||
/* Also remove link if it comes from the same output. */
|
||||
nodeRemLink(ntree, tlink);
|
||||
tlink = NULL;
|
||||
tlink = nullptr;
|
||||
to_count--;
|
||||
from_count--;
|
||||
}
|
||||
|
@ -806,13 +809,13 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
|
|||
Main *bmain = CTX_data_main(C);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNodeTree *ntree = snode->edittree;
|
||||
bNodeLinkDrag *nldrag = op->customdata;
|
||||
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
|
||||
bool do_tag_update = false;
|
||||
|
||||
/* avoid updates while applying links */
|
||||
ntree->is_updating = true;
|
||||
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
|
||||
bNodeLink *link = linkdata->data;
|
||||
bNodeLink *link = (bNodeLink *)linkdata->data;
|
||||
|
||||
/* See note below, but basically TEST flag means that the link
|
||||
* was connected to output (or to a node which affects the
|
||||
|
@ -867,14 +870,14 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
|
|||
static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNodeLinkDrag *nldrag = op->customdata;
|
||||
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
|
||||
|
||||
if (nldrag->in_out == SOCK_OUT) {
|
||||
bNode *tnode;
|
||||
bNodeSocket *tsock = NULL;
|
||||
bNodeSocket *tsock = nullptr;
|
||||
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) {
|
||||
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
|
||||
bNodeLink *link = linkdata->data;
|
||||
bNodeLink *link = (bNodeLink *)linkdata->data;
|
||||
|
||||
/* skip if socket is on the same node as the fromsock */
|
||||
if (tnode && link->fromnode == tnode) {
|
||||
|
@ -882,7 +885,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
|
|||
}
|
||||
|
||||
/* Skip if tsock is already linked with this output. */
|
||||
bNodeLink *existing_link_connected_to_fromsock = NULL;
|
||||
bNodeLink *existing_link_connected_to_fromsock = nullptr;
|
||||
LISTBASE_FOREACH (bNodeLink *, existing_link, &snode->edittree->links) {
|
||||
if (existing_link->fromsock == link->fromsock && existing_link->tosock == tsock) {
|
||||
existing_link_connected_to_fromsock = existing_link;
|
||||
|
@ -906,22 +909,22 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
|
|||
}
|
||||
else {
|
||||
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
|
||||
bNodeLink *link = linkdata->data;
|
||||
bNodeLink *link = (bNodeLink *)linkdata->data;
|
||||
if (nldrag->last_node_hovered_while_dragging_a_link) {
|
||||
sort_multi_input_socket_links(
|
||||
snode, nldrag->last_node_hovered_while_dragging_a_link, NULL, cursor);
|
||||
snode, nldrag->last_node_hovered_while_dragging_a_link, nullptr, cursor);
|
||||
}
|
||||
link->tonode = NULL;
|
||||
link->tosock = NULL;
|
||||
link->tonode = nullptr;
|
||||
link->tosock = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
bNode *tnode;
|
||||
bNodeSocket *tsock = NULL;
|
||||
bNodeSocket *tsock = nullptr;
|
||||
if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) {
|
||||
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
|
||||
bNodeLink *link = linkdata->data;
|
||||
bNodeLink *link = (bNodeLink *)linkdata->data;
|
||||
|
||||
/* skip if this is already the target socket */
|
||||
if (link->fromsock == tsock) {
|
||||
|
@ -939,10 +942,10 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
|
|||
}
|
||||
else {
|
||||
LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
|
||||
bNodeLink *link = linkdata->data;
|
||||
bNodeLink *link = (bNodeLink *)linkdata->data;
|
||||
|
||||
link->fromnode = NULL;
|
||||
link->fromsock = NULL;
|
||||
link->fromnode = nullptr;
|
||||
link->fromsock = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -952,7 +955,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2])
|
|||
/* in_out = starting socket */
|
||||
static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
bNodeLinkDrag *nldrag = op->customdata;
|
||||
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
float cursor[2];
|
||||
|
||||
|
@ -977,7 +980,7 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
if (event->val == KM_RELEASE) {
|
||||
node_link_exit(C, op, true);
|
||||
|
||||
ED_workspace_status_text(C, NULL);
|
||||
ED_workspace_status_text(C, nullptr);
|
||||
ED_region_tag_redraw(region);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
clear_picking_highlight(&snode->edittree->links);
|
||||
|
@ -993,13 +996,13 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
/* return 1 when socket clicked */
|
||||
static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor[2], bool detach)
|
||||
{
|
||||
bNodeLinkDrag *nldrag = NULL;
|
||||
bNodeLinkDrag *nldrag = nullptr;
|
||||
|
||||
/* output indicated? */
|
||||
bNode *node;
|
||||
bNodeSocket *sock;
|
||||
if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_OUT)) {
|
||||
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
|
||||
nldrag = (bNodeLinkDrag *)MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
|
||||
|
||||
const int num_links = nodeCountSocketLinks(snode->edittree, sock);
|
||||
int link_limit = nodeSocketLinkLimit(sock);
|
||||
|
@ -1009,11 +1012,11 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
|
|||
/* detach current links and store them in the operator data */
|
||||
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (link->fromsock == sock) {
|
||||
LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
|
||||
bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
|
||||
LinkData *linkdata = (LinkData *)MEM_callocN(sizeof(LinkData), "drag link op link data");
|
||||
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link");
|
||||
linkdata->data = oplink;
|
||||
*oplink = *link;
|
||||
oplink->next = oplink->prev = NULL;
|
||||
oplink->next = oplink->prev = nullptr;
|
||||
oplink->flag |= NODE_LINK_VALID;
|
||||
|
||||
/* The link could be disconnected and in that case we
|
||||
|
@ -1043,7 +1046,7 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
|
|||
}
|
||||
/* or an input? */
|
||||
else if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN)) {
|
||||
nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
|
||||
nldrag = (bNodeLinkDrag *)MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata");
|
||||
nldrag->last_node_hovered_while_dragging_a_link = node;
|
||||
|
||||
const int num_links = nodeCountSocketLinks(snode->edittree, sock);
|
||||
|
@ -1061,12 +1064,12 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor
|
|||
}
|
||||
}
|
||||
|
||||
if (link_to_pick != NULL && !nldrag->from_multi_input_socket) {
|
||||
LinkData *linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data");
|
||||
bNodeLink *oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link");
|
||||
if (link_to_pick != nullptr && !nldrag->from_multi_input_socket) {
|
||||
LinkData *linkdata = (LinkData *)MEM_callocN(sizeof(LinkData), "drag link op link data");
|
||||
bNodeLink *oplink = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "drag link op link");
|
||||
linkdata->data = oplink;
|
||||
*oplink = *link_to_pick;
|
||||
oplink->next = oplink->prev = NULL;
|
||||
oplink->next = oplink->prev = nullptr;
|
||||
oplink->flag |= NODE_LINK_VALID;
|
||||
oplink->flag &= ~NODE_LINK_TEST;
|
||||
if (node_connected_to_output(bmain, snode->edittree, link_to_pick->tonode)) {
|
||||
|
@ -1127,7 +1130,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
static void node_link_cancel(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNodeLinkDrag *nldrag = op->customdata;
|
||||
bNodeLinkDrag *nldrag = (bNodeLinkDrag *)op->customdata;
|
||||
|
||||
BLI_remlink(&snode->runtime->linkdrag, nldrag);
|
||||
|
||||
|
@ -1167,7 +1170,7 @@ void NODE_OT_link(wmOperatorType *ot)
|
|||
RNA_def_float_array(ot->srna,
|
||||
"drag_start",
|
||||
2,
|
||||
0,
|
||||
nullptr,
|
||||
-UI_PRECISION_FLOAT_MAX,
|
||||
UI_PRECISION_FLOAT_MAX,
|
||||
"Drag Start",
|
||||
|
@ -1189,11 +1192,11 @@ static int node_make_link_exec(bContext *C, wmOperator *op)
|
|||
|
||||
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
||||
|
||||
snode_autoconnect(bmain, snode, 1, replace);
|
||||
snode_autoconnect(bmain, snode, true, replace);
|
||||
|
||||
/* deselect sockets after linking */
|
||||
node_deselect_all_input_sockets(snode, 0);
|
||||
node_deselect_all_output_sockets(snode, 0);
|
||||
node_deselect_all_input_sockets(snode, false);
|
||||
node_deselect_all_output_sockets(snode, false);
|
||||
|
||||
ntreeUpdateTree(CTX_data_main(C), snode->edittree);
|
||||
snode_notify(C, snode);
|
||||
|
@ -1218,7 +1221,7 @@ void NODE_OT_link_make(wmOperatorType *ot)
|
|||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(
|
||||
ot->srna, "replace", 0, "Replace", "Replace socket connections with the new links");
|
||||
ot->srna, "replace", false, "Replace", "Replace socket connections with the new links");
|
||||
}
|
||||
|
||||
/* ********************** Node Link Intersect ***************** */
|
||||
|
@ -1226,16 +1229,16 @@ static bool node_links_intersect(bNodeLink *link, const float mcoords[][2], int
|
|||
{
|
||||
float coord_array[NODE_LINK_RESOL + 1][2];
|
||||
|
||||
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
|
||||
if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
|
||||
for (int i = 0; i < tot - 1; i++) {
|
||||
for (int b = 0; b < NODE_LINK_RESOL; b++) {
|
||||
if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ********************** Cut Link operator ***************** */
|
||||
|
@ -1285,7 +1288,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
|
|||
snode_update(snode, link->tonode);
|
||||
bNode *to_node = link->tonode;
|
||||
nodeRemLink(snode->edittree, link);
|
||||
sort_multi_input_socket_links(snode, to_node, NULL, NULL);
|
||||
sort_multi_input_socket_links(snode, to_node, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1324,7 +1327,7 @@ void NODE_OT_links_cut(wmOperatorType *ot)
|
|||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
|
||||
/* internal */
|
||||
RNA_def_int(ot->srna, "cursor", WM_CURSOR_KNIFE, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
|
||||
|
@ -1426,7 +1429,7 @@ void NODE_OT_links_mute(wmOperatorType *ot)
|
|||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||
|
||||
/* internal */
|
||||
RNA_def_int(ot->srna, "cursor", WM_CURSOR_MUTE, 0, INT_MAX, "Cursor", "", 0, INT_MAX);
|
||||
|
@ -1491,7 +1494,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
ED_node_sort(ntree);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1563,7 +1566,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
}
|
||||
|
||||
bNode *frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f);
|
||||
bNode *frame = node_add_node(C, nullptr, NODE_FRAME, 0.0f, 0.0f);
|
||||
|
||||
/* reset tags */
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
|
@ -1584,7 +1587,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
ED_node_sort(ntree);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1624,7 +1627,7 @@ static bNode *node_find_frame_to_attach(ARegion *region,
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||
|
@ -1637,7 +1640,7 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
|
|||
if (frame) {
|
||||
LISTBASE_FOREACH_BACKWARD (bNode *, node, &ntree->nodes) {
|
||||
if (node->flag & NODE_SELECT) {
|
||||
if (node->parent == NULL) {
|
||||
if (node->parent == nullptr) {
|
||||
/* disallow moving a parent into its child */
|
||||
if (nodeAttachNodeCheck(frame, node) == false) {
|
||||
/* attach all unparented nodes */
|
||||
|
@ -1666,7 +1669,7 @@ static int node_attach_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
|
|||
}
|
||||
|
||||
ED_node_sort(ntree);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1738,7 +1741,7 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
|
||||
ED_node_sort(ntree);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1766,13 +1769,13 @@ static bool ed_node_link_conditions(ScrArea *area,
|
|||
SpaceNode **r_snode,
|
||||
bNode **r_select)
|
||||
{
|
||||
SpaceNode *snode = area ? area->spacedata.first : NULL;
|
||||
SpaceNode *snode = area ? (SpaceNode *)area->spacedata.first : nullptr;
|
||||
|
||||
*r_snode = snode;
|
||||
*r_select = NULL;
|
||||
*r_select = nullptr;
|
||||
|
||||
/* no unlucky accidents */
|
||||
if (area == NULL || area->spacetype != SPACE_NODE) {
|
||||
if (area == nullptr || area->spacetype != SPACE_NODE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1782,8 +1785,8 @@ static bool ed_node_link_conditions(ScrArea *area,
|
|||
}
|
||||
|
||||
bNode *node;
|
||||
bNode *select = NULL;
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
bNode *select = nullptr;
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if (node->flag & SELECT) {
|
||||
if (select) {
|
||||
break;
|
||||
|
@ -1792,7 +1795,7 @@ static bool ed_node_link_conditions(ScrArea *area,
|
|||
}
|
||||
}
|
||||
/* only one selected */
|
||||
if (node || select == NULL) {
|
||||
if (node || select == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1835,7 +1838,7 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
|
|||
}
|
||||
|
||||
/* find link to select/highlight */
|
||||
bNodeLink *selink = NULL;
|
||||
bNodeLink *selink = nullptr;
|
||||
float dist_best = FLT_MAX;
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
float coord_array[NODE_LINK_RESOL + 1][2];
|
||||
|
@ -1844,7 +1847,7 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) {
|
||||
if (node_link_bezier_points(nullptr, nullptr, link, coord_array, NODE_LINK_RESOL)) {
|
||||
float dist = FLT_MAX;
|
||||
|
||||
/* loop over link coords to find shortest dist to
|
||||
|
@ -1939,7 +1942,7 @@ static bNodeSocket *get_main_socket(ListBase *sockets)
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool node_parents_offset_flag_enable_cb(bNode *parent, void *UNUSED(userdata))
|
||||
|
@ -1985,7 +1988,7 @@ static bool node_link_insert_offset_frame_chain_cb(bNode *fromnode,
|
|||
void *userdata,
|
||||
const bool reversed)
|
||||
{
|
||||
NodeInsertOfsData *data = userdata;
|
||||
NodeInsertOfsData *data = (NodeInsertOfsData *)userdata;
|
||||
bNode *ofs_node = reversed ? fromnode : tonode;
|
||||
|
||||
if (ofs_node->parent && ofs_node->parent != data->insert_parent) {
|
||||
|
@ -2022,7 +2025,7 @@ static bool node_link_insert_offset_chain_cb(bNode *fromnode,
|
|||
void *userdata,
|
||||
const bool reversed)
|
||||
{
|
||||
NodeInsertOfsData *data = userdata;
|
||||
NodeInsertOfsData *data = (NodeInsertOfsData *)userdata;
|
||||
bNode *ofs_node = reversed ? fromnode : tonode;
|
||||
|
||||
if (data->insert_parent) {
|
||||
|
@ -2035,7 +2038,7 @@ static bool node_link_insert_offset_chain_cb(bNode *fromnode,
|
|||
}
|
||||
|
||||
if (nodeIsChildOf(data->insert_parent, ofs_node) == false) {
|
||||
data->insert_parent = NULL;
|
||||
data->insert_parent = nullptr;
|
||||
}
|
||||
}
|
||||
else if (ofs_node->parent) {
|
||||
|
@ -2086,7 +2089,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
|
|||
rctf totr_frame;
|
||||
|
||||
/* check nodes front to back */
|
||||
for (frame = ntree->nodes.last; frame; frame = frame->prev) {
|
||||
for (frame = (bNode *)ntree->nodes.last; frame; frame = frame->prev) {
|
||||
/* skip selected, those are the nodes we want to attach */
|
||||
if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) {
|
||||
continue;
|
||||
|
@ -2152,7 +2155,7 @@ static void node_link_insert_offset_ntree(NodeInsertOfsData *iofsd,
|
|||
iofsd->offset_x = margin;
|
||||
|
||||
/* flag all parents of insert as offset to prevent them from being offset */
|
||||
nodeParentsIter(insert, node_parents_offset_flag_enable_cb, NULL);
|
||||
nodeParentsIter(insert, node_parents_offset_flag_enable_cb, nullptr);
|
||||
/* iterate over entire chain and apply offsets */
|
||||
nodeChainIter(ntree,
|
||||
right_alignment ? next : prev,
|
||||
|
@ -2173,7 +2176,8 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
|
|||
NodeInsertOfsData *iofsd = snode->runtime->iofsd;
|
||||
bool redraw = false;
|
||||
|
||||
if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) {
|
||||
if (!snode || event->type != TIMER || iofsd == nullptr ||
|
||||
iofsd->anim_timer != event->customdata) {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
|
@ -2203,13 +2207,13 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w
|
|||
|
||||
/* end timer + free insert offset data */
|
||||
if (duration > NODE_INSOFS_ANIM_DURATION) {
|
||||
WM_event_remove_timer(CTX_wm_manager(C), NULL, iofsd->anim_timer);
|
||||
WM_event_remove_timer(CTX_wm_manager(C), nullptr, iofsd->anim_timer);
|
||||
|
||||
LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
|
||||
node->anim_init_locx = node->anim_ofsx = 0.0f;
|
||||
}
|
||||
|
||||
snode->runtime->iofsd = NULL;
|
||||
snode->runtime->iofsd = nullptr;
|
||||
MEM_freeN(iofsd);
|
||||
|
||||
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
|
||||
|
@ -2270,7 +2274,7 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
|
|||
|
||||
/* get the link */
|
||||
bNodeLink *link;
|
||||
for (link = snode->edittree->links.first; link; link = link->next) {
|
||||
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
||||
if (link->flag & NODE_LINKFLAG_HILITE) {
|
||||
break;
|
||||
}
|
||||
|
@ -2298,7 +2302,8 @@ void ED_node_link_insert(Main *bmain, ScrArea *area)
|
|||
|
||||
/* set up insert offset data, it needs stuff from here */
|
||||
if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) {
|
||||
NodeInsertOfsData *iofsd = MEM_callocN(sizeof(NodeInsertOfsData), __func__);
|
||||
NodeInsertOfsData *iofsd = (NodeInsertOfsData *)MEM_callocN(sizeof(NodeInsertOfsData),
|
||||
__func__);
|
||||
|
||||
iofsd->insert = select;
|
||||
iofsd->prev = link->fromnode;
|
|
@ -21,7 +21,8 @@
|
|||
* \ingroup spnode
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
@ -81,7 +82,7 @@ static bool has_workbench_in_texture_color(const wmWindowManager *wm,
|
|||
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
if (area->spacetype == SPACE_VIEW3D) {
|
||||
const View3D *v3d = area->spacedata.first;
|
||||
const View3D *v3d = (const View3D *)area->spacedata.first;
|
||||
|
||||
if (ED_view3d_has_workbench_in_texture_color(scene, ob, v3d)) {
|
||||
return true;
|
||||
|
@ -100,28 +101,28 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my)
|
|||
{
|
||||
bNode *node;
|
||||
|
||||
for (node = ntree->nodes.last; node; node = node->prev) {
|
||||
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
|
||||
if (node->typeinfo->select_area_func) {
|
||||
if (node->typeinfo->select_area_func(node, mx, my)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
for (node = ntree->nodes.last; node; node = node->prev) {
|
||||
for (node = (bNode *)ntree->nodes.last; node; node = node->prev) {
|
||||
if (node->typeinfo->tweak_area_func) {
|
||||
if (node->typeinfo->tweak_area_func(node, mx, my)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool is_position_over_node_or_socket(SpaceNode *snode, float mouse[2])
|
||||
|
@ -168,18 +169,18 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no
|
|||
sock->flag &= ~SELECT;
|
||||
|
||||
if (node && deselect_node) {
|
||||
bool sel = 0;
|
||||
bool sel = false;
|
||||
|
||||
/* if no selected sockets remain, also deselect the node */
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
||||
if (sock->flag & SELECT) {
|
||||
sel = 1;
|
||||
sel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
|
||||
if (sock->flag & SELECT) {
|
||||
sel = 1;
|
||||
sel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +206,7 @@ void node_deselect_all(SpaceNode *snode)
|
|||
{
|
||||
bNode *node;
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
nodeSetSelected(node, false);
|
||||
}
|
||||
}
|
||||
|
@ -220,16 +221,16 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes
|
|||
* We can do that more efficiently here.
|
||||
*/
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
int sel = 0;
|
||||
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
||||
sock->flag &= ~SELECT;
|
||||
}
|
||||
|
||||
/* if no selected sockets remain, also deselect the node */
|
||||
if (deselect_nodes) {
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
|
||||
if (sock->flag & SELECT) {
|
||||
sel = 1;
|
||||
break;
|
||||
|
@ -253,18 +254,18 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node
|
|||
* We can do that more efficiently here.
|
||||
*/
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
bool sel = false;
|
||||
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->outputs.first; sock; sock = sock->next) {
|
||||
sock->flag &= ~SELECT;
|
||||
}
|
||||
|
||||
/* if no selected sockets remain, also deselect the node */
|
||||
if (deselect_nodes) {
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
||||
if (sock->flag & SELECT) {
|
||||
sel = 1;
|
||||
sel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +290,7 @@ static bool node_select_grouped_type(SpaceNode *snode, bNode *node_act)
|
|||
bNode *node;
|
||||
bool changed = false;
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if ((node->flag & SELECT) == 0) {
|
||||
if (node->type == node_act->type) {
|
||||
nodeSetSelected(node, true);
|
||||
|
@ -306,7 +307,7 @@ static bool node_select_grouped_color(SpaceNode *snode, bNode *node_act)
|
|||
bNode *node;
|
||||
bool changed = false;
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if ((node->flag & SELECT) == 0) {
|
||||
if (compare_v3v3(node->color, node_act->color, 0.005f)) {
|
||||
nodeSetSelected(node, true);
|
||||
|
@ -327,7 +328,7 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo
|
|||
const char *sep, *suf_act, *suf_curr;
|
||||
|
||||
pref_len_act = BLI_str_partition_ex_utf8(
|
||||
node_act->name, NULL, delims, &sep, &suf_act, from_right);
|
||||
node_act->name, nullptr, delims, &sep, &suf_act, from_right);
|
||||
|
||||
/* Note: in case we are searching for suffix, and found none, use whole name as suffix. */
|
||||
if (from_right && !(sep && suf_act)) {
|
||||
|
@ -335,12 +336,12 @@ static bool node_select_grouped_name(SpaceNode *snode, bNode *node_act, const bo
|
|||
suf_act = node_act->name;
|
||||
}
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if (node->flag & SELECT) {
|
||||
continue;
|
||||
}
|
||||
pref_len_curr = BLI_str_partition_ex_utf8(
|
||||
node->name, NULL, delims, &sep, &suf_curr, from_right);
|
||||
node->name, nullptr, delims, &sep, &suf_curr, from_right);
|
||||
|
||||
/* Same as with active node name! */
|
||||
if (from_right && !(sep && suf_curr)) {
|
||||
|
@ -371,7 +372,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNode *node_act = nodeGetActive(snode->edittree);
|
||||
|
||||
if (node_act == NULL) {
|
||||
if (node_act == nullptr) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -381,7 +382,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
|
|||
const int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
if (!extend) {
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
nodeSetSelected(node, false);
|
||||
}
|
||||
}
|
||||
|
@ -406,7 +407,7 @@ static int node_select_grouped_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (changed) {
|
||||
ED_node_sort(snode->edittree);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -420,7 +421,7 @@ void NODE_OT_select_grouped(wmOperatorType *ot)
|
|||
{NODE_SELECT_GROUPED_COLOR, "COLOR", 0, "Color", ""},
|
||||
{NODE_SELECT_GROUPED_PREFIX, "PREFIX", 0, "Prefix", ""},
|
||||
{NODE_SELECT_GROUPED_SUFIX, "SUFFIX", 0, "Suffix", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
|
@ -461,7 +462,7 @@ void node_select_single(bContext *C, bNode *node)
|
|||
bool active_texture_changed = false;
|
||||
bNode *tnode;
|
||||
|
||||
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
if (tnode != node) {
|
||||
nodeSetSelected(tnode, false);
|
||||
}
|
||||
|
@ -476,7 +477,7 @@ void node_select_single(bContext *C, bNode *node)
|
|||
DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
}
|
||||
|
||||
static int node_mouse_select(bContext *C,
|
||||
|
@ -491,7 +492,7 @@ static int node_mouse_select(bContext *C,
|
|||
const Scene *scene = CTX_data_scene(C);
|
||||
const wmWindowManager *wm = CTX_wm_manager(C);
|
||||
bNode *node, *tnode;
|
||||
bNodeSocket *sock = NULL;
|
||||
bNodeSocket *sock = nullptr;
|
||||
bNodeSocket *tsock;
|
||||
float cursor[2];
|
||||
int ret_value = OPERATOR_CANCELLED;
|
||||
|
@ -530,7 +531,7 @@ static int node_mouse_select(bContext *C,
|
|||
/* Only allow one selected output per node, for sensible linking.
|
||||
* Allow selecting outputs from different nodes though, if extend is true. */
|
||||
if (node) {
|
||||
for (tsock = node->outputs.first; tsock; tsock = tsock->next) {
|
||||
for (tsock = (bNodeSocket *)node->outputs.first; tsock; tsock = tsock->next) {
|
||||
if (tsock == sock) {
|
||||
continue;
|
||||
}
|
||||
|
@ -538,11 +539,11 @@ static int node_mouse_select(bContext *C,
|
|||
}
|
||||
}
|
||||
if (!extend) {
|
||||
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
if (tnode == node) {
|
||||
continue;
|
||||
}
|
||||
for (tsock = tnode->outputs.first; tsock; tsock = tsock->next) {
|
||||
for (tsock = (bNodeSocket *)tnode->outputs.first; tsock; tsock = tsock->next) {
|
||||
node_socket_deselect(tnode, tsock, true);
|
||||
}
|
||||
}
|
||||
|
@ -558,7 +559,7 @@ static int node_mouse_select(bContext *C,
|
|||
node = node_under_mouse_select(snode->edittree, (int)cursor[0], (int)cursor[1]);
|
||||
|
||||
if (extend) {
|
||||
if (node != NULL) {
|
||||
if (node != nullptr) {
|
||||
/* If node is selected but not active, we want to make it active,
|
||||
* but not toggle (deselect) it. */
|
||||
if (!((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0)) {
|
||||
|
@ -567,7 +568,7 @@ static int node_mouse_select(bContext *C,
|
|||
ret_value = OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
else if (deselect_all && node == NULL) {
|
||||
else if (deselect_all && node == nullptr) {
|
||||
/* Rather than deselecting others, users may want to drag to box-select (drag from empty
|
||||
* space) or tweak-translate an already selected item. If these cases may apply, delay
|
||||
* deselection. */
|
||||
|
@ -576,13 +577,13 @@ static int node_mouse_select(bContext *C,
|
|||
}
|
||||
else {
|
||||
/* Deselect in empty space. */
|
||||
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
nodeSetSelected(tnode, false);
|
||||
}
|
||||
ret_value = OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
else if (node != NULL) {
|
||||
else if (node != nullptr) {
|
||||
/* When clicking on an already selected node, we want to wait to deselect
|
||||
* others and allow the user to start moving the node without that. */
|
||||
if (wait_to_deselect_others && (node->flag & SELECT)) {
|
||||
|
@ -591,7 +592,7 @@ static int node_mouse_select(bContext *C,
|
|||
else {
|
||||
nodeSetSelected(node, true);
|
||||
|
||||
for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
for (tnode = (bNode *)snode->edittree->nodes.first; tnode; tnode = tnode->next) {
|
||||
if (tnode != node) {
|
||||
nodeSetSelected(tnode, false);
|
||||
}
|
||||
|
@ -605,7 +606,7 @@ static int node_mouse_select(bContext *C,
|
|||
/* update node order */
|
||||
if (ret_value != OPERATOR_CANCELLED) {
|
||||
bool active_texture_changed = false;
|
||||
if (node != NULL && ret_value != OPERATOR_RUNNING_MODAL) {
|
||||
if (node != nullptr && ret_value != OPERATOR_RUNNING_MODAL) {
|
||||
ED_node_set_active(bmain, snode->edittree, node, &active_texture_changed);
|
||||
}
|
||||
ED_node_set_active_viewer_key(snode);
|
||||
|
@ -614,7 +615,7 @@ static int node_mouse_select(bContext *C,
|
|||
DEG_id_tag_update(&snode->edittree->id, ID_RECALC_COPY_ON_WRITE);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
|
@ -681,7 +682,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
|
|||
WM_operator_properties_border_to_rctf(op, &rectf);
|
||||
UI_view2d_region_to_view_rctf(®ion->v2d, &rectf, &rectf);
|
||||
|
||||
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
|
||||
const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode");
|
||||
const bool select = (sel_op != SEL_OP_SUB);
|
||||
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
||||
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
|
||||
|
@ -693,7 +694,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
|
|||
is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr);
|
||||
}
|
||||
else {
|
||||
is_inside = BLI_rctf_isect(&rectf, &node->totr, NULL);
|
||||
is_inside = BLI_rctf_isect(&rectf, &node->totr, nullptr);
|
||||
}
|
||||
|
||||
if (is_inside) {
|
||||
|
@ -703,7 +704,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
|
|||
|
||||
ED_node_sort(snode->edittree);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -740,7 +741,7 @@ void NODE_OT_select_box(wmOperatorType *ot)
|
|||
/* properties */
|
||||
RNA_def_boolean(ot->srna,
|
||||
"tweak",
|
||||
0,
|
||||
false,
|
||||
"Tweak",
|
||||
"Only activate when mouse is not over a node (useful for tweak gesture)");
|
||||
|
||||
|
@ -766,8 +767,9 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
|
|||
float zoom = (float)(BLI_rcti_size_x(®ion->winrct)) /
|
||||
(float)(BLI_rctf_size_x(®ion->v2d.cur));
|
||||
|
||||
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
|
||||
WM_gesture_is_modal_first(op->customdata));
|
||||
const eSelectOp sel_op = ED_select_op_modal(
|
||||
(eSelectOp)RNA_enum_get(op->ptr, "mode"),
|
||||
WM_gesture_is_modal_first((const wmGesture *)op->customdata));
|
||||
const bool select = (sel_op != SEL_OP_SUB);
|
||||
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
||||
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
|
||||
|
@ -780,13 +782,13 @@ static int node_circleselect_exec(bContext *C, wmOperator *op)
|
|||
|
||||
UI_view2d_region_to_view(®ion->v2d, x, y, &offset[0], &offset[1]);
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if (BLI_rctf_isect_circle(&node->totr, offset, radius / zoom)) {
|
||||
nodeSetSelected(node, select);
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -853,7 +855,7 @@ static bool do_lasso_select_node(bContext *C,
|
|||
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
|
||||
|
||||
/* do actual selection */
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
|
||||
if (select && (node->flag & NODE_SELECT)) {
|
||||
continue;
|
||||
|
@ -873,7 +875,7 @@ static bool do_lasso_select_node(bContext *C,
|
|||
}
|
||||
|
||||
if (changed) {
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
@ -885,7 +887,7 @@ static int node_lasso_select_exec(bContext *C, wmOperator *op)
|
|||
const int(*mcoords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcoords_len);
|
||||
|
||||
if (mcoords) {
|
||||
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
|
||||
const eSelectOp sel_op = (eSelectOp)RNA_enum_get(op->ptr, "mode");
|
||||
|
||||
do_lasso_select_node(C, mcoords, mcoords_len, sel_op);
|
||||
|
||||
|
@ -916,7 +918,7 @@ void NODE_OT_select_lasso(wmOperatorType *ot)
|
|||
/* properties */
|
||||
RNA_def_boolean(ot->srna,
|
||||
"tweak",
|
||||
0,
|
||||
false,
|
||||
"Tweak",
|
||||
"Only activate when mouse is not over a node (useful for tweak gesture)");
|
||||
|
||||
|
@ -940,7 +942,7 @@ static int node_select_all_exec(bContext *C, wmOperator *op)
|
|||
|
||||
ED_node_sort(snode->edittree);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -973,11 +975,11 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
bNodeLink *link;
|
||||
bNode *node;
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
node->flag &= ~NODE_TEST;
|
||||
}
|
||||
|
||||
for (link = snode->edittree->links.first; link; link = link->next) {
|
||||
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -986,7 +988,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
}
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if (node->flag & NODE_TEST) {
|
||||
nodeSetSelected(node, true);
|
||||
}
|
||||
|
@ -994,7 +996,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
ED_node_sort(snode->edittree);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -1025,11 +1027,11 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
bNodeLink *link;
|
||||
bNode *node;
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
node->flag &= ~NODE_TEST;
|
||||
}
|
||||
|
||||
for (link = snode->edittree->links.first; link; link = link->next) {
|
||||
for (link = (bNodeLink *)snode->edittree->links.first; link; link = link->next) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1038,7 +1040,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
}
|
||||
}
|
||||
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if (node->flag & NODE_TEST) {
|
||||
nodeSetSelected(node, true);
|
||||
}
|
||||
|
@ -1046,7 +1048,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
ED_node_sort(snode->edittree);
|
||||
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_NODE | NA_SELECTED, nullptr);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -1079,7 +1081,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
|
|||
bNode *active = nodeGetActive(snode->edittree);
|
||||
int totnodes;
|
||||
const bool revert = RNA_boolean_get(op->ptr, "prev");
|
||||
const bool same_type = 1;
|
||||
const bool same_type = true;
|
||||
|
||||
ntreeGetDependencyList(snode->edittree, &node_array, &totnodes);
|
||||
|
||||
|
@ -1093,9 +1095,9 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
if (same_type) {
|
||||
bNode *node = NULL;
|
||||
bNode *node = nullptr;
|
||||
|
||||
while (node == NULL) {
|
||||
while (node == nullptr) {
|
||||
if (revert) {
|
||||
a--;
|
||||
}
|
||||
|
@ -1112,7 +1114,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
|
|||
if (node->type == active->type) {
|
||||
break;
|
||||
}
|
||||
node = NULL;
|
||||
node = nullptr;
|
||||
}
|
||||
if (node) {
|
||||
active = node;
|
||||
|
@ -1168,7 +1170,7 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot)
|
|||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
|
||||
RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -1223,7 +1225,7 @@ static void node_find_update_fn(const struct bContext *C,
|
|||
static void node_find_exec_fn(struct bContext *C, void *UNUSED(arg1), void *arg2)
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
bNode *active = arg2;
|
||||
bNode *active = (bNode *)arg2;
|
||||
|
||||
if (active) {
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
@ -1261,7 +1263,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *region, void *arg_op)
|
|||
0,
|
||||
"");
|
||||
UI_but_func_search_set(
|
||||
but, NULL, node_find_update_fn, op->type, false, NULL, node_find_exec_fn, NULL);
|
||||
but, nullptr, node_find_update_fn, op->type, false, nullptr, node_find_exec_fn, nullptr);
|
||||
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
|
||||
|
||||
/* fake button, it holds space for search items */
|
||||
|
@ -1273,22 +1275,23 @@ static uiBlock *node_find_menu(bContext *C, ARegion *region, void *arg_op)
|
|||
10 - UI_searchbox_size_y(),
|
||||
UI_searchbox_size_x(),
|
||||
UI_searchbox_size_y(),
|
||||
NULL,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
/* Move it downwards, mouse over button. */
|
||||
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, (const int[2]){0, -UI_UNIT_Y});
|
||||
std::array<int, 2> bounds_offset = {0, -UI_UNIT_Y};
|
||||
UI_block_bounds_set_popup(block, 0.3f * U.widget_unit, bounds_offset.data());
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static int node_find_node_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
{
|
||||
UI_popup_block_invoke(C, node_find_menu, op, NULL);
|
||||
UI_popup_block_invoke(C, node_find_menu, op, nullptr);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
@ -1306,7 +1309,7 @@ void NODE_OT_find_node(wmOperatorType *ot)
|
|||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_boolean(ot->srna, "prev", 0, "Previous", "");
|
||||
RNA_def_boolean(ot->srna, "prev", false, "Previous", "");
|
||||
}
|
||||
|
||||
/** \} */
|
|
@ -18,8 +18,8 @@
|
|||
* \ingroup edinterface
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
|||
#include "BLI_array.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
|
@ -51,7 +52,7 @@
|
|||
/************************* Node Socket Manipulation **************************/
|
||||
|
||||
/* describes an instance of a node type and a specific socket to link */
|
||||
typedef struct NodeLinkItem {
|
||||
struct NodeLinkItem {
|
||||
int socket_index; /* index for linking */
|
||||
int socket_type; /* socket type for compatibility check */
|
||||
const char *socket_name; /* ui label of the socket */
|
||||
|
@ -59,7 +60,7 @@ typedef struct NodeLinkItem {
|
|||
|
||||
/* extra settings */
|
||||
bNodeTree *ngroup; /* group node tree */
|
||||
} NodeLinkItem;
|
||||
};
|
||||
|
||||
/* Compare an existing node to a link item to see if it can be reused.
|
||||
* item must be for the same node type!
|
||||
|
@ -98,7 +99,7 @@ static void node_tag_recursive(bNode *node)
|
|||
|
||||
node->flag |= NODE_TEST;
|
||||
|
||||
for (input = node->inputs.first; input; input = input->next) {
|
||||
for (input = (bNodeSocket *)node->inputs.first; input; input = input->next) {
|
||||
if (input->link) {
|
||||
node_tag_recursive(input->link->fromnode);
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ static void node_clear_recursive(bNode *node)
|
|||
|
||||
node->flag &= ~NODE_TEST;
|
||||
|
||||
for (input = node->inputs.first; input; input = input->next) {
|
||||
for (input = (bNodeSocket *)node->inputs.first; input; input = input->next) {
|
||||
if (input->link) {
|
||||
node_clear_recursive(input->link->fromnode);
|
||||
}
|
||||
|
@ -132,16 +133,16 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
|
|||
}
|
||||
|
||||
/* tag linked nodes to be removed */
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)ntree->nodes.first; node; node = node->next) {
|
||||
node->flag &= ~NODE_TEST;
|
||||
}
|
||||
|
||||
node_tag_recursive(rem_node);
|
||||
|
||||
/* clear tags on nodes that are still used by other nodes */
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)ntree->nodes.first; node; node = node->next) {
|
||||
if (!(node->flag & NODE_TEST)) {
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
for (sock = (bNodeSocket *)node->inputs.first; sock; sock = sock->next) {
|
||||
if (sock->link && sock->link->fromnode != rem_node) {
|
||||
node_clear_recursive(sock->link->fromnode);
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node)
|
|||
}
|
||||
|
||||
/* remove nodes */
|
||||
for (node = ntree->nodes.first; node; node = next) {
|
||||
for (node = (bNode *)ntree->nodes.first; node; node = next) {
|
||||
next = node->next;
|
||||
|
||||
if (node->flag & NODE_TEST) {
|
||||
|
@ -205,7 +206,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
Main *bmain = CTX_data_main(C);
|
||||
bNode *node_from;
|
||||
bNodeSocket *sock_from_tmp;
|
||||
bNode *node_prev = NULL;
|
||||
bNode *node_prev = nullptr;
|
||||
|
||||
/* unlink existing node */
|
||||
if (sock_to->link) {
|
||||
|
@ -214,7 +215,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
}
|
||||
|
||||
/* find existing node that we can use */
|
||||
for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) {
|
||||
for (node_from = (bNode *)ntree->nodes.first; node_from; node_from = node_from->next) {
|
||||
if (node_from->type == type) {
|
||||
break;
|
||||
}
|
||||
|
@ -223,7 +224,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
if (node_from) {
|
||||
if (node_from->inputs.first || node_from->typeinfo->draw_buttons ||
|
||||
node_from->typeinfo->draw_buttons_ex) {
|
||||
node_from = NULL;
|
||||
node_from = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +234,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
}
|
||||
else if (!node_from) {
|
||||
node_from = nodeAddStaticNode(C, ntree, type);
|
||||
if (node_prev != NULL) {
|
||||
if (node_prev != nullptr) {
|
||||
/* If we're replacing existing node, use its location. */
|
||||
node_from->locx = node_prev->locx;
|
||||
node_from->locy = node_prev->locy;
|
||||
|
@ -241,7 +242,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
node_from->offsety = node_prev->offsety;
|
||||
}
|
||||
else {
|
||||
sock_from_tmp = BLI_findlink(&node_from->outputs, item->socket_index);
|
||||
sock_from_tmp = (bNodeSocket *)BLI_findlink(&node_from->outputs, item->socket_index);
|
||||
nodePositionRelative(node_from, node_to, sock_from_tmp, sock_to);
|
||||
}
|
||||
|
||||
|
@ -251,7 +252,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
nodeSetActive(ntree, node_from);
|
||||
|
||||
/* add link */
|
||||
sock_from_tmp = BLI_findlink(&node_from->outputs, item->socket_index);
|
||||
sock_from_tmp = (bNodeSocket *)BLI_findlink(&node_from->outputs, item->socket_index);
|
||||
nodeAddLink(ntree, node_from, sock_from_tmp, node_to, sock_to);
|
||||
sock_to->flag &= ~SOCK_COLLAPSED;
|
||||
|
||||
|
@ -259,8 +260,10 @@ static void node_socket_add_replace(const bContext *C,
|
|||
if (node_prev && node_from != node_prev) {
|
||||
bNodeSocket *sock_prev, *sock_from;
|
||||
|
||||
for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) {
|
||||
for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) {
|
||||
for (sock_prev = (bNodeSocket *)node_prev->inputs.first; sock_prev;
|
||||
sock_prev = sock_prev->next) {
|
||||
for (sock_from = (bNodeSocket *)node_from->inputs.first; sock_from;
|
||||
sock_from = sock_from->next) {
|
||||
if (nodeCountSocketLinks(ntree, sock_from) >= nodeSocketLinkLimit(sock_from)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -282,7 +285,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
if (node_from->typeinfo->nclass == NODE_CLASS_TEXTURE &&
|
||||
node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE &&
|
||||
/* White noise texture node does not have NodeTexBase. */
|
||||
node_from->storage != NULL && node_prev->storage != NULL) {
|
||||
node_from->storage != nullptr && node_prev->storage != nullptr) {
|
||||
memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase));
|
||||
}
|
||||
|
||||
|
@ -303,7 +306,7 @@ static void node_socket_add_replace(const bContext *C,
|
|||
#define UI_NODE_LINK_DISCONNECT -1
|
||||
#define UI_NODE_LINK_REMOVE -2
|
||||
|
||||
typedef struct NodeLinkArg {
|
||||
struct NodeLinkArg {
|
||||
Main *bmain;
|
||||
Scene *scene;
|
||||
bNodeTree *ntree;
|
||||
|
@ -314,7 +317,7 @@ typedef struct NodeLinkArg {
|
|||
NodeLinkItem item;
|
||||
|
||||
uiLayout *layout;
|
||||
} NodeLinkArg;
|
||||
};
|
||||
|
||||
static void ui_node_link_items(NodeLinkArg *arg,
|
||||
int in_out,
|
||||
|
@ -322,14 +325,15 @@ static void ui_node_link_items(NodeLinkArg *arg,
|
|||
int *r_totitems)
|
||||
{
|
||||
/* XXX this should become a callback for node types! */
|
||||
NodeLinkItem *items = NULL;
|
||||
NodeLinkItem *items = nullptr;
|
||||
int totitems = 0;
|
||||
|
||||
if (arg->node_type->type == NODE_GROUP) {
|
||||
bNodeTree *ngroup;
|
||||
int i;
|
||||
|
||||
for (ngroup = arg->bmain->nodetrees.first; ngroup; ngroup = ngroup->id.next) {
|
||||
for (ngroup = (bNodeTree *)arg->bmain->nodetrees.first; ngroup;
|
||||
ngroup = (bNodeTree *)ngroup->id.next) {
|
||||
const char *disabled_hint;
|
||||
if ((ngroup->type != arg->ntree->type) ||
|
||||
!nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) {
|
||||
|
@ -341,10 +345,11 @@ static void ui_node_link_items(NodeLinkArg *arg,
|
|||
}
|
||||
|
||||
if (totitems > 0) {
|
||||
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
|
||||
items = (NodeLinkItem *)MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
|
||||
|
||||
i = 0;
|
||||
for (ngroup = arg->bmain->nodetrees.first; ngroup; ngroup = ngroup->id.next) {
|
||||
for (ngroup = (bNodeTree *)arg->bmain->nodetrees.first; ngroup;
|
||||
ngroup = (bNodeTree *)ngroup->id.next) {
|
||||
const char *disabled_hint;
|
||||
if ((ngroup->type != arg->ntree->type) ||
|
||||
!nodeGroupPoll(arg->ntree, ngroup, &disabled_hint)) {
|
||||
|
@ -354,7 +359,8 @@ static void ui_node_link_items(NodeLinkArg *arg,
|
|||
ListBase *lb = (in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs);
|
||||
bNodeSocket *stemp;
|
||||
int index;
|
||||
for (stemp = lb->first, index = 0; stemp; stemp = stemp->next, index++, i++) {
|
||||
for (stemp = (bNodeSocket *)lb->first, index = 0; stemp;
|
||||
stemp = stemp->next, index++, i++) {
|
||||
NodeLinkItem *item = &items[i];
|
||||
|
||||
item->socket_index = index;
|
||||
|
@ -380,7 +386,7 @@ static void ui_node_link_items(NodeLinkArg *arg,
|
|||
}
|
||||
|
||||
if (totitems > 0) {
|
||||
items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
|
||||
items = (NodeLinkItem *)MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items");
|
||||
|
||||
i = 0;
|
||||
for (stemp = socket_templates; stemp && stemp->type != -1; stemp++, i++) {
|
||||
|
@ -474,15 +480,14 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
|
|||
bNodeTree *ntree = arg->ntree;
|
||||
bNodeSocket *sock = arg->sock;
|
||||
uiLayout *layout = arg->layout;
|
||||
uiLayout *column = NULL;
|
||||
uiLayout *column = nullptr;
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
uiBut *but;
|
||||
NodeLinkArg *argN;
|
||||
int first = 1;
|
||||
|
||||
/* generate array of node types sorted by UI name */
|
||||
bNodeType **sorted_ntypes = NULL;
|
||||
BLI_array_declare(sorted_ntypes);
|
||||
blender::Vector<bNodeType *> sorted_ntypes;
|
||||
|
||||
NODE_TYPES_BEGIN (ntype) {
|
||||
const char *disabled_hint;
|
||||
|
@ -498,20 +503,20 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
|
|||
continue;
|
||||
}
|
||||
|
||||
BLI_array_append(sorted_ntypes, ntype);
|
||||
sorted_ntypes.append(ntype);
|
||||
}
|
||||
NODE_TYPES_END;
|
||||
|
||||
qsort(
|
||||
sorted_ntypes, BLI_array_len(sorted_ntypes), sizeof(bNodeType *), ui_node_item_name_compare);
|
||||
sorted_ntypes.data(), sorted_ntypes.size(), sizeof(bNodeType *), ui_node_item_name_compare);
|
||||
|
||||
/* generate UI */
|
||||
for (int j = 0; j < BLI_array_len(sorted_ntypes); j++) {
|
||||
for (int j = 0; j < sorted_ntypes.size(); j++) {
|
||||
bNodeType *ntype = sorted_ntypes[j];
|
||||
NodeLinkItem *items;
|
||||
int totitems;
|
||||
char name[UI_MAX_NAME_STR];
|
||||
const char *cur_node_name = NULL;
|
||||
const char *cur_node_name = nullptr;
|
||||
int num = 0;
|
||||
int icon = ICON_NONE;
|
||||
|
||||
|
@ -531,11 +536,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
|
|||
}
|
||||
|
||||
if (first) {
|
||||
column = uiLayoutColumn(layout, 0);
|
||||
column = uiLayoutColumn(layout, false);
|
||||
UI_block_layout_set_current(block, column);
|
||||
|
||||
uiItemL(column, IFACE_(cname), ICON_NODE);
|
||||
but = block->buttons.last;
|
||||
but = (uiBut *)block->buttons.last;
|
||||
|
||||
first = 0;
|
||||
}
|
||||
|
@ -553,7 +558,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
|
|||
0,
|
||||
UI_UNIT_X * 4,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
|
@ -578,24 +583,22 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
|
|||
0,
|
||||
UI_UNIT_X * 4,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
TIP_("Add node to input"));
|
||||
|
||||
argN = MEM_dupallocN(arg);
|
||||
argN = (NodeLinkArg *)MEM_dupallocN(arg);
|
||||
argN->item = items[i];
|
||||
UI_but_funcN_set(but, ui_node_link, argN, NULL);
|
||||
UI_but_funcN_set(but, ui_node_link, argN, nullptr);
|
||||
}
|
||||
|
||||
if (items) {
|
||||
MEM_freeN(items);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_array_free(sorted_ntypes);
|
||||
}
|
||||
|
||||
static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *name)
|
||||
|
@ -635,7 +638,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
|
|||
|
||||
if (sock->link) {
|
||||
uiItemL(column, IFACE_("Link"), ICON_NONE);
|
||||
but = block->buttons.last;
|
||||
but = (uiBut *)block->buttons.last;
|
||||
but->drawflag = UI_BUT_TEXT_LEFT;
|
||||
|
||||
but = uiDefBut(block,
|
||||
|
@ -646,7 +649,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
|
|||
0,
|
||||
UI_UNIT_X * 4,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
|
@ -662,7 +665,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
|
|||
0,
|
||||
UI_UNIT_X * 4,
|
||||
UI_UNIT_Y,
|
||||
NULL,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
|
@ -683,7 +686,7 @@ void uiTemplateNodeLink(
|
|||
uiBut *but;
|
||||
float socket_col[4];
|
||||
|
||||
arg = MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg");
|
||||
arg = (NodeLinkArg *)MEM_callocN(sizeof(NodeLinkArg), "NodeLinkArg");
|
||||
arg->ntree = ntree;
|
||||
arg->node = node;
|
||||
arg->sock = input;
|
||||
|
@ -698,11 +701,11 @@ void uiTemplateNodeLink(
|
|||
char name[UI_MAX_NAME_STR];
|
||||
ui_node_sock_name(ntree, input, name);
|
||||
but = uiDefMenuBut(
|
||||
block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, "");
|
||||
block, ui_template_node_link_menu, nullptr, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, "");
|
||||
}
|
||||
else {
|
||||
but = uiDefIconMenuBut(
|
||||
block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
|
||||
block, ui_template_node_link_menu, nullptr, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
|
||||
}
|
||||
|
||||
UI_but_type_set_menu_from_pulldown(but);
|
||||
|
@ -739,7 +742,7 @@ static void ui_node_draw_node(
|
|||
}
|
||||
}
|
||||
|
||||
for (input = node->inputs.first; input; input = input->next) {
|
||||
for (input = (bNodeSocket *)node->inputs.first; input; input = input->next) {
|
||||
ui_node_draw_input(layout, C, ntree, node, input, depth + 1);
|
||||
}
|
||||
}
|
||||
|
@ -749,7 +752,7 @@ static void ui_node_draw_input(
|
|||
{
|
||||
PointerRNA inputptr, nodeptr;
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
uiLayout *row = NULL;
|
||||
uiLayout *row = nullptr;
|
||||
bNode *lnode;
|
||||
bool dependency_loop;
|
||||
|
||||
|
@ -759,11 +762,11 @@ static void ui_node_draw_input(
|
|||
|
||||
/* to avoid eternal loops on cyclic dependencies */
|
||||
node->flag |= NODE_TEST;
|
||||
lnode = (input->link) ? input->link->fromnode : NULL;
|
||||
lnode = (input->link) ? input->link->fromnode : nullptr;
|
||||
|
||||
dependency_loop = (lnode && (lnode->flag & NODE_TEST));
|
||||
if (dependency_loop) {
|
||||
lnode = NULL;
|
||||
lnode = nullptr;
|
||||
}
|
||||
|
||||
/* socket RNA pointer */
|
||||
|
@ -862,7 +865,7 @@ static void ui_node_draw_input(
|
|||
}
|
||||
|
||||
if (add_dummy_decorator) {
|
||||
uiItemDecoratorR(split_wrapper.decorate_column, NULL, NULL, 0);
|
||||
uiItemDecoratorR(split_wrapper.decorate_column, nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
/* clear */
|
||||
|
@ -879,7 +882,7 @@ void uiTemplateNodeView(
|
|||
}
|
||||
|
||||
/* clear for cycle check */
|
||||
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
|
||||
for (tnode = (bNode *)ntree->nodes.first; tnode; tnode = tnode->next) {
|
||||
tnode->flag &= ~NODE_TEST;
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ int space_node_view_flag(
|
|||
BLI_rctf_init_minmax(&cur_new);
|
||||
|
||||
if (snode->edittree) {
|
||||
for (node = snode->edittree->nodes.first; node; node = node->next) {
|
||||
for (node = (bNode *)snode->edittree->nodes.first; node; node = node->next) {
|
||||
if ((node->flag & node_flag) == node_flag) {
|
||||
BLI_rctf_union(&cur_new, &node->totr);
|
||||
tot++;
|
||||
|
@ -191,16 +191,16 @@ void NODE_OT_view_selected(wmOperatorType *ot)
|
|||
/** \name Background Image Operators
|
||||
* \{ */
|
||||
|
||||
typedef struct NodeViewMove {
|
||||
struct NodeViewMove {
|
||||
int mvalo[2];
|
||||
int xmin, ymin, xmax, ymax;
|
||||
} NodeViewMove;
|
||||
};
|
||||
|
||||
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
NodeViewMove *nvm = op->customdata;
|
||||
NodeViewMove *nvm = (NodeViewMove *)op->customdata;
|
||||
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE:
|
||||
|
@ -215,8 +215,8 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
|
|||
CLAMP(snode->yof, nvm->ymin, nvm->ymax);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -225,7 +225,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
|
|||
case RIGHTMOUSE:
|
||||
if (event->val == KM_RELEASE) {
|
||||
MEM_freeN(nvm);
|
||||
op->customdata = NULL;
|
||||
op->customdata = nullptr;
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
break;
|
||||
|
@ -247,14 +247,14 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
|
|||
void *lock;
|
||||
|
||||
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
|
||||
|
||||
if (ibuf == NULL) {
|
||||
if (ibuf == nullptr) {
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
nvm = MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct");
|
||||
nvm = (NodeViewMove *)MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct");
|
||||
op->customdata = nvm;
|
||||
nvm->mvalo[0] = event->mval[0];
|
||||
nvm->mvalo[1] = event->mval[1];
|
||||
|
@ -275,7 +275,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
|
|||
static void snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
op->customdata = nullptr;
|
||||
}
|
||||
|
||||
void NODE_OT_backimage_move(wmOperatorType *ot)
|
||||
|
@ -309,8 +309,8 @@ static int backimage_zoom_exec(bContext *C, wmOperator *op)
|
|||
|
||||
snode->zoom *= fac;
|
||||
ED_region_tag_redraw(region);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -356,9 +356,9 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
float facx, facy;
|
||||
|
||||
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
|
||||
|
||||
if ((ibuf == NULL) || (ibuf->x == 0) || (ibuf->y == 0)) {
|
||||
if ((ibuf == nullptr) || (ibuf->x == 0) || (ibuf->y == 0)) {
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
@ -374,8 +374,8 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
snode->yof = 0;
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ void NODE_OT_backimage_fit(wmOperatorType *ot)
|
|||
/** \name Sample Backdrop Operator
|
||||
* \{ */
|
||||
|
||||
typedef struct ImageSampleInfo {
|
||||
struct ImageSampleInfo {
|
||||
ARegionType *art;
|
||||
void *draw_handle;
|
||||
int x, y;
|
||||
|
@ -420,12 +420,12 @@ typedef struct ImageSampleInfo {
|
|||
|
||||
int draw;
|
||||
int color_manage;
|
||||
} ImageSampleInfo;
|
||||
};
|
||||
|
||||
static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ImageSampleInfo *info = arg_info;
|
||||
ImageSampleInfo *info = (ImageSampleInfo *)arg_info;
|
||||
|
||||
if (info->draw) {
|
||||
ED_image_draw_info(scene,
|
||||
|
@ -445,7 +445,7 @@ static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
|
|||
|
||||
/* Returns mouse position in image space. */
|
||||
bool ED_space_node_get_position(
|
||||
Main *bmain, SpaceNode *snode, struct ARegion *ar, const int mval[2], float fpos[2])
|
||||
Main *bmain, SpaceNode *snode, struct ARegion *region, const int mval[2], float fpos[2])
|
||||
{
|
||||
if (!ED_node_is_compositor(snode) || (snode->flag & SNODE_BACKDRAW) == 0) {
|
||||
return false;
|
||||
|
@ -453,7 +453,7 @@ bool ED_space_node_get_position(
|
|||
|
||||
void *lock;
|
||||
Image *ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
|
||||
if (!ibuf) {
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
return false;
|
||||
|
@ -462,8 +462,10 @@ bool ED_space_node_get_position(
|
|||
/* map the mouse coords to the backdrop image space */
|
||||
float bufx = ibuf->x * snode->zoom;
|
||||
float bufy = ibuf->y * snode->zoom;
|
||||
fpos[0] = (bufx > 0.0f ? ((float)mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
|
||||
fpos[1] = (bufy > 0.0f ? ((float)mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
|
||||
fpos[0] = (bufx > 0.0f ? ((float)mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f :
|
||||
0.0f);
|
||||
fpos[1] = (bufy > 0.0f ? ((float)mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f :
|
||||
0.0f);
|
||||
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
return true;
|
||||
|
@ -489,7 +491,7 @@ bool ED_space_node_color_sample(
|
|||
}
|
||||
|
||||
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
|
||||
if (!ibuf) {
|
||||
return false;
|
||||
}
|
||||
|
@ -532,14 +534,14 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
Main *bmain = CTX_data_main(C);
|
||||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
ImageSampleInfo *info = op->customdata;
|
||||
ImageSampleInfo *info = (ImageSampleInfo *)op->customdata;
|
||||
void *lock;
|
||||
Image *ima;
|
||||
ImBuf *ibuf;
|
||||
float fx, fy, bufx, bufy;
|
||||
|
||||
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, nullptr, &lock);
|
||||
if (!ibuf) {
|
||||
info->draw = 0;
|
||||
return;
|
||||
|
@ -570,8 +572,8 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
info->draw = 1;
|
||||
info->channels = ibuf->channels;
|
||||
|
||||
info->zp = NULL;
|
||||
info->zfp = NULL;
|
||||
info->zp = nullptr;
|
||||
info->zfp = nullptr;
|
||||
|
||||
if (ibuf->rect) {
|
||||
cp = (uchar *)(ibuf->rect + y * ibuf->x + x);
|
||||
|
@ -616,7 +618,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
}
|
||||
else {
|
||||
info->draw = 0;
|
||||
ED_node_sample_set(NULL);
|
||||
ED_node_sample_set(nullptr);
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
|
@ -626,9 +628,9 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
|
||||
static void sample_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
ImageSampleInfo *info = op->customdata;
|
||||
ImageSampleInfo *info = (ImageSampleInfo *)op->customdata;
|
||||
|
||||
ED_node_sample_set(NULL);
|
||||
ED_node_sample_set(nullptr);
|
||||
ED_region_draw_cb_exit(info->art, info->draw_handle);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
MEM_freeN(info);
|
||||
|
@ -644,7 +646,7 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
|
||||
info = (ImageSampleInfo *)MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
|
||||
info->art = region->type;
|
||||
info->draw_handle = ED_region_draw_cb_activate(
|
||||
region->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
|
Loading…
Reference in New Issue