Cleanup: float2 in nodeToView & nodeFromView in BKE_node.hh #108956

Merged
Hans Goudey merged 7 commits from mod_moder/blender:tmp_cleanup_2dvector_for_node_space into main 2023-06-15 16:04:30 +02:00
2 changed files with 12 additions and 14 deletions
Showing only changes of commit aa2604f236 - Show all commits

View File

@ -314,8 +314,8 @@ static Array<uiBlock *> node_uiblocks_init(const bContext &C, const Span<bNode *
float2 node_to_view(const bNode &node, const float2 &co)
{
const float2 result = bke::nodeToView(&node, co);
return result * UI_SCALE_FAC;
const float2 node_location = bke::nodeToView(&node, co);
return node_location * UI_SCALE_FAC;
}
void node_to_updated_rect(const bNode &node, rctf &r_rect)
@ -331,9 +331,9 @@ void node_to_updated_rect(const bNode &node, rctf &r_rect)
float2 node_from_view(const bNode &node, const float2 &co)
{
const float2 co_scaled = co / UI_SCALE_FAC;
const float2 result = bke::nodeFromView(&node, co_scaled);
return result;
const float2 node_location = co / UI_SCALE_FAC;
return bke::nodeFromView(&node, node_location);
;
}
/**

View File

@ -47,11 +47,9 @@ static void create_transform_data_for_node(TransData &td,
bNode &node,
const float dpi_fac)
{
blender::float2 loc;
const blender::float2 node_offset = {node.offsetx, node.offsety};
/* account for parents (nested nodes) */
loc = blender::bke::nodeToView(node.parent, blender::math::round(node_offset));
const blender::float2 node_offset = {node.offsetx, node.offsety};
blender::float2 loc = blender::bke::nodeToView(&node, blender::math::round(node_offset));
loc *= dpi_fac;
/* use top-left corner as the transform origin for nodes */
@ -242,11 +240,11 @@ static void flushTransNodes(TransInfo *t)
loc /= dpi_fac;
/* account for parents (nested nodes) */
blender::float2 offset = blender::bke::nodeFromView(node, {});
offset = blender::math::round(offset);
offset += loc;
node->locx = offset.x;
node->locy = offset.y;
const blender::float2 node_offset = {node->offsetx, node->offsety};
const blender::float2 new_node_location = loc - blender::math::round(node_offset);
const blender::float2 location = blender::bke::nodeFromView(node->parent, new_node_location);
node->locx = location.x;
node->locy = location.y;
}
/* handle intersection with noodles */