diff options
author | Hans Goudey <h.goudey@me.com> | 2021-01-15 19:48:22 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-01-15 19:48:22 +0300 |
commit | 237e27e161c9ac3c6b9d74dae1cafb5ea55c0458 (patch) | |
tree | b1f2193e6269befc4bf365573b15a89c5c76aedd /source/blender/editors | |
parent | 20a54347eec65d687c8d87bb16e1e7df9cad1a8b (diff) |
Cleanup: Add const in various places in node code
Also includes some various other minor cleanups, like using bool
instead of int in a couple places.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_view2d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 45 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 27 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_relationships.c | 2 |
6 files changed, 54 insertions, 49 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 8df29e5b520..64f881052a1 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -231,7 +231,7 @@ struct View2D *UI_view2d_fromcontext(const struct bContext *C); struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C); void UI_view2d_scroller_size_get(const struct View2D *v2d, float *r_x, float *r_y); -void UI_view2d_scale_get(struct View2D *v2d, float *r_x, float *r_y); +void UI_view2d_scale_get(const struct View2D *v2d, float *r_x, float *r_y); float UI_view2d_scale_get_x(const struct View2D *v2d); float UI_view2d_scale_get_y(const struct View2D *v2d); void UI_view2d_scale_get_inverse(const struct View2D *v2d, float *r_x, float *r_y); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index f115618c13b..59aee0fde29 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1895,7 +1895,7 @@ void UI_view2d_scroller_size_get(const View2D *v2d, float *r_x, float *r_y) * * \param r_x, r_y: scale on each axis */ -void UI_view2d_scale_get(View2D *v2d, float *r_x, float *r_y) +void UI_view2d_scale_get(const View2D *v2d, float *r_x, float *r_y) { if (r_x) { *r_x = UI_view2d_scale_get_x(v2d); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ad975196981..bf4bc6d37eb 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3817,9 +3817,9 @@ void draw_nodespace_back_pix(const bContext *C, } /* return quadratic beziers points for a given nodelink and clip if v2d is not NULL. */ -static bool node_link_bezier_handles(View2D *v2d, - SpaceNode *snode, - bNodeLink *link, +static bool node_link_bezier_handles(const View2D *v2d, + const SpaceNode *snode, + const bNodeLink *link, float vec[4][2]) { float cursor[2] = {0.0f, 0.0f}; @@ -3912,8 +3912,11 @@ static bool node_link_bezier_handles(View2D *v2d, } /* if v2d not NULL, it clips and returns 0 if not visible */ -bool node_link_bezier_points( - View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol) +bool node_link_bezier_points(const View2D *v2d, + const SpaceNode *snode, + const bNodeLink *link, + float coord_array[][2], + const int resol) { float vec[4][2]; @@ -4076,7 +4079,7 @@ static char nodelink_get_color_id(int th_col) return 0; } -static void nodelink_batch_draw(SpaceNode *snode) +static void nodelink_batch_draw(const SpaceNode *snode) { if (g_batch_link.count == 0) { return; @@ -4116,7 +4119,7 @@ void nodelink_batch_end(SpaceNode *snode) g_batch_link.enabled = false; } -static void nodelink_batch_add_link(SpaceNode *snode, +static void nodelink_batch_add_link(const SpaceNode *snode, const float p0[2], const float p1[2], const float p2[2], @@ -4148,8 +4151,12 @@ static void nodelink_batch_add_link(SpaceNode *snode, } /* don't do shadows if th_col3 is -1. */ -void node_draw_link_bezier( - View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int th_col2, int th_col3) +void node_draw_link_bezier(const View2D *v2d, + const SpaceNode *snode, + const bNodeLink *link, + int th_col1, + int th_col2, + int th_col3) { float vec[4][2]; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index d3fec7257f5..04d6934cc47 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -317,14 +317,14 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) } } -void node_to_view(struct bNode *node, float x, float y, float *rx, float *ry) +void node_to_view(const bNode *node, float x, float y, float *rx, float *ry) { nodeToView(node, x, y, rx, ry); *rx *= UI_DPI_FAC; *ry *= UI_DPI_FAC; } -void node_to_updated_rect(struct bNode *node, rctf *r_rect) +void node_to_updated_rect(const bNode *node, rctf *r_rect) { node_to_view(node, node->offsetx, node->offsety, &r_rect->xmin, &r_rect->ymax); node_to_view(node, @@ -334,7 +334,7 @@ void node_to_updated_rect(struct bNode *node, rctf *r_rect) &r_rect->ymin); } -void node_from_view(struct bNode *node, float x, float y, float *rx, float *ry) +void node_from_view(const bNode *node, float x, float y, float *rx, float *ry) { x /= UI_DPI_FAC; y /= UI_DPI_FAC; @@ -689,11 +689,11 @@ int node_get_colorid(bNode *node) /* note: in cmp_util.c is similar code, for node_compo_pass_on() * the same goes for shader and texture nodes. */ /* note: in node_edit.c is similar code, for untangle node */ -static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) +static void node_draw_mute_line(const View2D *v2d, const SpaceNode *snode, const bNode *node) { GPU_blend(GPU_BLEND_ALPHA); - LISTBASE_FOREACH (bNodeLink *, link, &node->internal_links) { + LISTBASE_FOREACH (const bNodeLink *, link, &node->internal_links) { node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1); } @@ -947,14 +947,14 @@ static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_ WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL); } -void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) +void node_draw_shadow(const SpaceNode *snode, const bNode *node, float radius, float alpha) { - rctf *rct = &node->totr; + const rctf *rct = &node->totr; UI_draw_roundbox_corner_set(UI_CNR_ALL); ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); } -void node_draw_sockets(View2D *v2d, +void node_draw_sockets(const View2D *v2d, const bContext *C, bNodeTree *ntree, bNode *node, @@ -1118,8 +1118,8 @@ void node_draw_sockets(View2D *v2d, } static void node_draw_basis(const bContext *C, - ARegion *region, - SpaceNode *snode, + const View2D *v2d, + const SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) @@ -1127,8 +1127,6 @@ static void node_draw_basis(const bContext *C, /* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */ float iconbutw = 0.8f * UI_UNIT_X; - View2D *v2d = ®ion->v2d; - /* skip if out of view */ if (BLI_rctf_isect(&node->totr, &v2d->cur, NULL) == false) { UI_block_end(C, node->block); @@ -1343,8 +1341,8 @@ static void node_draw_basis(const bContext *C, } static void node_draw_hidden(const bContext *C, - ARegion *region, - SpaceNode *snode, + const View2D *v2d, + const SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key)) @@ -1353,8 +1351,6 @@ static void node_draw_hidden(const bContext *C, float centy = BLI_rctf_cent_y(rct); float hiddenrad = BLI_rctf_size_y(rct) / 2.0f; - View2D *v2d = ®ion->v2d; - float scale; UI_view2d_scale_get(v2d, &scale, NULL); @@ -1438,7 +1434,7 @@ static void node_draw_hidden(const bContext *C, /* disable lines */ if (node->flag & NODE_MUTED) { - node_draw_mute_line(®ion->v2d, snode, node); + node_draw_mute_line(v2d, snode, node); } char showname[128]; /* 128 is used below */ @@ -1550,11 +1546,12 @@ void node_draw_default(const bContext *C, bNode *node, bNodeInstanceKey key) { + const View2D *v2d = ®ion->v2d; if (node->flag & NODE_HIDDEN) { - node_draw_hidden(C, region, snode, ntree, node, key); + node_draw_hidden(C, v2d, snode, ntree, node, key); } else { - node_draw_basis(C, region, snode, ntree, node, key); + node_draw_basis(C, v2d, snode, ntree, node, key); } } @@ -1607,8 +1604,7 @@ void node_draw_nodetree(const bContext *C, #endif /* draw background nodes, last nodes in front */ - int a = 0; - LISTBASE_FOREACH_INDEX (bNode *, node, &ntree->nodes, a) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { #ifdef USE_DRAW_TOT_UPDATE /* unrelated to background nodes, update the v2d->tot, * can be anywhere before we draw the scroll bars */ @@ -1635,8 +1631,7 @@ void node_draw_nodetree(const bContext *C, GPU_blend(GPU_BLEND_NONE); /* draw foreground nodes, last nodes in front */ - a = 0; - LISTBASE_FOREACH_INDEX (bNode *, node, &ntree->nodes, a) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->flag & NODE_BACKGROUND) { continue; } @@ -1686,8 +1681,8 @@ static void draw_nodetree(const bContext *C, /* shade the parent node group and add a uiBlock to clip mouse events */ static void draw_group_overlay(const bContext *C, ARegion *region) { - View2D *v2d = ®ion->v2d; - rctf rect = v2d->cur; + const View2D *v2d = ®ion->v2d; + const rctf rect = v2d->cur; float color[4]; /* shade node groups to separate them visually */ diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index aa59b7293a3..16c166ef5b1 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -61,14 +61,17 @@ void space_node_group_offset(struct SpaceNode *snode, float *x, float *y); /* node_draw.c */ int node_get_colorid(struct bNode *node); int node_get_resize_cursor(int directions); -void node_draw_shadow(struct SpaceNode *snode, struct bNode *node, float radius, float alpha); +void node_draw_shadow(const struct SpaceNode *snode, + const struct bNode *node, + float radius, + float alpha); void node_draw_default(const struct bContext *C, struct ARegion *region, struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *node, bNodeInstanceKey key); -void node_draw_sockets(struct View2D *v2d, +void node_draw_sockets(const struct View2D *v2d, const struct bContext *C, struct bNodeTree *ntree, struct bNode *node, @@ -92,9 +95,9 @@ void node_draw_space(const bContext *C, ARegion *region); void node_set_cursor(struct wmWindow *win, struct SpaceNode *snode, float cursor[2]); /* DPI scaled coords */ -void node_to_view(struct bNode *node, float x, float y, float *rx, float *ry); -void node_to_updated_rect(struct bNode *node, rctf *r_rect); -void node_from_view(struct bNode *node, float x, float y, float *rx, float *ry); +void node_to_view(const struct bNode *node, float x, float y, float *rx, float *ry); +void node_to_updated_rect(const struct bNode *node, rctf *r_rect); +void node_from_view(const struct bNode *node, float x, float y, float *rx, float *ry); /* node_buttons.c */ void node_buttons_register(struct ARegionType *art); @@ -145,17 +148,17 @@ void nodelink_batch_start(struct SpaceNode *snode); void nodelink_batch_end(struct SpaceNode *snode); void node_draw_link(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link); -void node_draw_link_bezier(struct View2D *v2d, - struct SpaceNode *snode, - struct bNodeLink *link, +void node_draw_link_bezier(const struct View2D *v2d, + const struct SpaceNode *snode, + const struct bNodeLink *link, int th_col1, int th_col2, int th_col3); -bool node_link_bezier_points(struct View2D *v2d, - struct SpaceNode *snode, - struct bNodeLink *link, +bool node_link_bezier_points(const struct View2D *v2d, + const struct SpaceNode *snode, + const struct bNodeLink *link, float coord_array[][2], - int resol); + const int resol); void draw_nodespace_back_pix(const struct bContext *C, struct ARegion *region, struct SpaceNode *snode, diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index ba1e752e276..ee3cc16080d 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -58,7 +58,7 @@ static bool ntree_has_drivers(bNodeTree *ntree) { - AnimData *adt = BKE_animdata_from_id(&ntree->id); + const AnimData *adt = BKE_animdata_from_id(&ntree->id); if (adt == NULL) { return false; } |