forked from bartvdbraak/blender
View2d: check UI_view2d_view_to_region_clip succeeds before using the result
This commit is contained in:
parent
9ae0e585b0
commit
e4a2df9fec
@ -193,10 +193,10 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
|
||||
if (userdata.marker) {
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
UI_view2d_view_to_region_clip(v2d, co[0], co[1], &x1, &y1);
|
||||
UI_view2d_view_to_region_clip(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2);
|
||||
|
||||
if (abs(x2 - x1) <= delta && abs(y2 - y1) <= delta) {
|
||||
if (UI_view2d_view_to_region_clip(v2d, co[0], co[1], &x1, &y1) &&
|
||||
UI_view2d_view_to_region_clip(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2) &&
|
||||
(abs(x2 - x1) <= delta && abs(y2 - y1) <= delta))
|
||||
{
|
||||
if (!extend) {
|
||||
SelectUserData selectdata = {SEL_DESELECT};
|
||||
|
||||
|
@ -1048,16 +1048,14 @@ static void nearest_fcurve_vert_store(
|
||||
* needed to access the relevant vertex coordinates in the 3x3
|
||||
* 'vec' matrix
|
||||
*/
|
||||
UI_view2d_view_to_region_clip(v2d,
|
||||
bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale,
|
||||
&screen_co[0], &screen_co[1]);
|
||||
|
||||
/* check if distance from mouse cursor to vert in screen space is within tolerance */
|
||||
dist = len_v2v2_int(mval, screen_co);
|
||||
|
||||
if (dist <= GVERTSEL_TOL) {
|
||||
if (UI_view2d_view_to_region_clip(v2d,
|
||||
bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1] * unit_scale,
|
||||
&screen_co[0], &screen_co[1]) &&
|
||||
/* check if distance from mouse cursor to vert in screen space is within tolerance */
|
||||
((dist = len_v2v2_int(mval, screen_co)) <= GVERTSEL_TOL))
|
||||
{
|
||||
tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last;
|
||||
short replace = 0;
|
||||
bool replace = false;
|
||||
|
||||
/* if there is already a point for the F-Curve, check if this point is closer than that was */
|
||||
if ((nvi) && (nvi->fcu == fcu)) {
|
||||
|
@ -590,9 +590,8 @@ static bool do_lasso_select_node(bContext *C, const int mcords[][2], short moves
|
||||
BLI_rctf_cent_y(&node->totr)};
|
||||
|
||||
/* marker in screen coords */
|
||||
UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]);
|
||||
|
||||
if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
|
||||
if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_co[0], &screen_co[1]) &&
|
||||
BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
|
||||
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX))
|
||||
{
|
||||
nodeSetSelected(node, select);
|
||||
|
@ -3068,8 +3068,9 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo
|
||||
if (select != uvedit_face_select_test(scene, efa, cd_loop_uv_offset)) {
|
||||
float cent[2];
|
||||
uv_poly_center(efa, cent, cd_loop_uv_offset);
|
||||
UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]);
|
||||
if (BLI_rcti_isect_pt_v(&rect, screen_uv) &&
|
||||
|
||||
if (UI_view2d_view_to_region_clip(&ar->v2d, cent[0], cent[1], &screen_uv[0], &screen_uv[1]) &&
|
||||
BLI_rcti_isect_pt_v(&rect, screen_uv) &&
|
||||
BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
|
||||
{
|
||||
BM_elem_flag_enable(efa, BM_ELEM_TAG);
|
||||
@ -3090,8 +3091,10 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo
|
||||
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
|
||||
if ((select) != (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))) {
|
||||
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
|
||||
UI_view2d_view_to_region_clip(&ar->v2d, luv->uv[0], luv->uv[1], &screen_uv[0], &screen_uv[1]);
|
||||
if (BLI_rcti_isect_pt_v(&rect, screen_uv) &&
|
||||
if (UI_view2d_view_to_region_clip(&ar->v2d,
|
||||
luv->uv[0], luv->uv[1],
|
||||
&screen_uv[0], &screen_uv[1]) &&
|
||||
BLI_rcti_isect_pt_v(&rect, screen_uv) &&
|
||||
BLI_lasso_is_point_inside(mcords, moves, screen_uv[0], screen_uv[1], V2D_IS_CLIPPED))
|
||||
{
|
||||
uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
|
||||
|
Loading…
Reference in New Issue
Block a user