Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Picard <dam.pic@free.fr>2022-10-14 02:40:01 +0300
committerDamien Picard <dam.pic@free.fr>2022-10-20 14:15:36 +0300
commit56d33099435dec98478997e5540f46dcfa17046d (patch)
tree2f82d40d57bde856102d5303dd33f7ab52813b9c
parentdc90910e8d8f6fedb8b23a74ad6fc808b02c809b (diff)
Fix T101708: Bug when joining nodes with thick lines
Caused by D15961, which changed the behavior of `dpi` and `pixel_size`. Instead of using a single value for `dpifac` (renamed to `dpi_fac`), use a value depending on whether we want pixel density or line width. This patch has the side-effect that the line width from the user preferences is now respected. It seems more logical that way, but I can't test with a hi-dpi display to see how that looks. If we want to get the old behavior back, we can just get rid of `prefs_line_width()` and replace its calls with `dpi_fac()`. A similar issue was also fixed for Icon Viewer.
-rw-r--r--development_icon_get.py6
-rw-r--r--node_wrangler.py29
2 files changed, 20 insertions, 15 deletions
diff --git a/development_icon_get.py b/development_icon_get.py
index f4bb7989..1f22a4d8 100644
--- a/development_icon_get.py
+++ b/development_icon_get.py
@@ -5,8 +5,8 @@ bl_info = {
"name": "Icon Viewer",
"description": "Click an icon to copy its name to the clipboard",
"author": "roaoao",
- "version": (1, 4, 0),
- "blender": (2, 80, 0),
+ "version": (1, 4, 1),
+ "blender": (3, 4, 0),
"location": "Text Editor > Dev Tab > Icon Viewer",
"doc_url": "{BLENDER_MANUAL_URL}/addons/development/icon_viewer.html",
"category": "Development",
@@ -30,7 +30,7 @@ HISTORY = []
def ui_scale():
prefs = bpy.context.preferences.system
- return prefs.dpi * prefs.pixel_size / DPI
+ return prefs.dpi / DPI
def prefs():
diff --git a/node_wrangler.py b/node_wrangler.py
index aa3b6bc2..5932388f 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -3,7 +3,7 @@
bl_info = {
"name": "Node Wrangler",
"author": "Bartek Skorupa, Greg Zaal, Sebastian Koenig, Christian Brinkmann, Florian Meyer",
- "version": (3, 42),
+ "version": (3, 43),
"blender": (3, 4, 0),
"location": "Node Editor Toolbar or Shift-W",
"description": "Various tools to enhance and speed up node-based workflow",
@@ -264,9 +264,14 @@ def force_update(context):
context.space_data.node_tree.update_tag()
-def dpifac():
+def dpi_fac():
prefs = bpy.context.preferences.system
- return prefs.dpi * prefs.pixel_size / 72
+ return prefs.dpi / 72
+
+
+def prefs_line_width():
+ prefs = bpy.context.preferences.system
+ return prefs.pixel_size
def node_mid_pt(node, axis):
@@ -342,8 +347,8 @@ def node_at_pos(nodes, context, event):
for node in nodes:
skipnode = False
if node.type != 'FRAME': # no point trying to link to a frame node
- dimx = node.dimensions.x/dpifac()
- dimy = node.dimensions.y/dpifac()
+ dimx = node.dimensions.x / dpi_fac()
+ dimy = node.dimensions.y / dpi_fac()
locx, locy = abs_node_location(node)
if not skipnode:
@@ -362,8 +367,8 @@ def node_at_pos(nodes, context, event):
for node in nodes:
if node.type != 'FRAME' and skipnode == False:
locx, locy = abs_node_location(node)
- dimx = node.dimensions.x/dpifac()
- dimy = node.dimensions.y/dpifac()
+ dimx = node.dimensions.x / dpi_fac()
+ dimy = node.dimensions.y / dpi_fac()
if (locx <= x <= locx + dimx) and \
(locy - dimy <= y <= locy):
nodes_under_mouse.append(node)
@@ -392,7 +397,7 @@ def store_mouse_cursor(context, event):
def draw_line(x1, y1, x2, y2, size, colour=(1.0, 1.0, 1.0, 0.7)):
shader = gpu.shader.from_builtin('POLYLINE_SMOOTH_COLOR')
shader.uniform_float("viewportSize", gpu.state.viewport_get()[2:])
- shader.uniform_float("lineWidth", size * dpifac())
+ shader.uniform_float("lineWidth", size * prefs_line_width())
vertices = ((x1, y1), (x2, y2))
vertex_colors = ((colour[0]+(1.0-colour[0])/4,
@@ -406,7 +411,7 @@ def draw_line(x1, y1, x2, y2, size, colour=(1.0, 1.0, 1.0, 0.7)):
def draw_circle_2d_filled(mx, my, radius, colour=(1.0, 1.0, 1.0, 0.7)):
- radius = radius * dpifac()
+ radius = radius * prefs_line_width()
sides = 12
vertices = [(radius * cos(i * 2 * pi / sides) + mx,
radius * sin(i * 2 * pi / sides) + my)
@@ -421,12 +426,12 @@ def draw_circle_2d_filled(mx, my, radius, colour=(1.0, 1.0, 1.0, 0.7)):
def draw_rounded_node_border(node, radius=8, colour=(1.0, 1.0, 1.0, 0.7)):
area_width = bpy.context.area.width
sides = 16
- radius = radius*dpifac()
+ radius *= prefs_line_width()
nlocx, nlocy = abs_node_location(node)
- nlocx = (nlocx+1)*dpifac()
- nlocy = (nlocy+1)*dpifac()
+ nlocx = (nlocx+1) * dpi_fac()
+ nlocy = (nlocy+1) * dpi_fac()
ndimx = node.dimensions.x
ndimy = node.dimensions.y