Fix T100767: Geometry nodes viewer node placed incorrectly

See explanation in comment.

Differential Revision: https://developer.blender.org/D15864
This commit is contained in:
Hans Goudey
2022-09-02 15:48:41 -05:00
parent 28d8076a2e
commit 831ed297d0

View File

@@ -639,8 +639,13 @@ static int link_socket_to_viewer(const bContext &C,
if (viewer_bnode == nullptr) {
/* Create a new viewer node if none exists. */
const int viewer_type = get_default_viewer_type(&C);
viewer_bnode = node_add_node(
C, nullptr, viewer_type, bsocket_to_view.locx + 100, bsocket_to_view.locy);
/* The socket location is in view space, so dividing by #UI_DPI_FAC
* brings it into the coordinate space of the node editor. */
viewer_bnode = node_add_node(C,
nullptr,
viewer_type,
bsocket_to_view.locx / UI_DPI_FAC + 100,
bsocket_to_view.locy / UI_DPI_FAC);
if (viewer_bnode == nullptr) {
return OPERATOR_CANCELLED;
}