Fix #144359: Scrolled down Asset Shelf prevents drag & drop in viewport.

The issue is in the `ED_region_overlap_isect_` family of functions I
believe. Their purpose is to check if a coordinate is in the
"non-transparent" or opaque parts of the overlapping region.

These are getting event coordinates (in window space), converted to
region relative space (substracting region->winrct).

Comparison is in view space (through `UI_view2d_region_to_view_y`)
to account for scrolling and zooming.

The thing where it goes wrong is that we are actually comparing to
`region->v2d.tot` (this can be huge, most of it not visible), where I
think we should be comparing to `region->v2d.cur` (that is the part that
is actually visible...)

Swapping `region->v2d.tot` with `region->v2d.cur` is what this PR does.

Pull Request: https://projects.blender.org/blender/blender/pulls/146032
This commit is contained in:
Philipp Oeser
2025-10-17 10:19:15 +02:00
committed by Philipp Oeser
parent 77819d77d2
commit 6536fd80fc

View File

@@ -24,7 +24,7 @@ bool ED_region_overlap_isect_x(const ARegion *region, const int event_x)
if (region->v2d.mask.xmin == region->v2d.mask.xmax) {
return false;
}
return BLI_rctf_isect_x(&region->v2d.tot,
return BLI_rctf_isect_x(&region->v2d.cur,
UI_view2d_region_to_view_x(&region->v2d, event_x - region->winrct.xmin));
}
@@ -35,7 +35,7 @@ bool ED_region_overlap_isect_y(const ARegion *region, const int event_y)
if (region->v2d.mask.ymin == region->v2d.mask.ymax) {
return false;
}
return BLI_rctf_isect_y(&region->v2d.tot,
return BLI_rctf_isect_y(&region->v2d.cur,
UI_view2d_region_to_view_y(&region->v2d, event_y - region->winrct.ymin));
}
@@ -98,8 +98,8 @@ bool ED_region_overlap_isect_x_with_margin(const ARegion *region,
return false;
}
int region_x = event_x - region->winrct.xmin;
return ((region->v2d.tot.xmin <= UI_view2d_region_to_view_x(&region->v2d, region_x + margin)) &&
(region->v2d.tot.xmax >= UI_view2d_region_to_view_x(&region->v2d, region_x - margin)));
return ((region->v2d.cur.xmin <= UI_view2d_region_to_view_x(&region->v2d, region_x + margin)) &&
(region->v2d.cur.xmax >= UI_view2d_region_to_view_x(&region->v2d, region_x - margin)));
}
bool ED_region_overlap_isect_y_with_margin(const ARegion *region,
@@ -112,8 +112,8 @@ bool ED_region_overlap_isect_y_with_margin(const ARegion *region,
return false;
}
int region_y = event_y - region->winrct.ymin;
return ((region->v2d.tot.ymin <= UI_view2d_region_to_view_y(&region->v2d, region_y + margin)) &&
(region->v2d.tot.ymax >= UI_view2d_region_to_view_y(&region->v2d, region_y - margin)));
return ((region->v2d.cur.ymin <= UI_view2d_region_to_view_y(&region->v2d, region_y + margin)) &&
(region->v2d.cur.ymax >= UI_view2d_region_to_view_y(&region->v2d, region_y - margin)));
}
bool ED_region_overlap_isect_xy_with_margin(const ARegion *region,