Node Editor: Skip socket drawing on low zoom

Socket drawing can be heavy with many nodes.
This patch skips drawing them on scale < 0.2
when they are barely visible anyway.

Differential Revision: https://developer.blender.org/D13255
This commit is contained in:
Erik Abrahamsson 2021-11-18 21:21:10 +01:00
parent 167ee8f2c7
commit b2d37c35d0
1 changed files with 7 additions and 1 deletions

View File

@ -1842,7 +1842,13 @@ static void node_draw_basis(const bContext *C,
UI_draw_roundbox_4fv(&rect, false, BASIS_RAD, color_outline);
}
node_draw_sockets(v2d, C, ntree, node, true, false);
float scale;
UI_view2d_scale_get(v2d, &scale, nullptr);
/* Skip slow socket drawing if zoom is small. */
if (scale > 0.2f) {
node_draw_sockets(v2d, C, ntree, node, true, false);
}
/* Preview. */
bNodeInstanceHash *previews = (bNodeInstanceHash *)CTX_data_pointer_get(C, "node_previews").data;