3D View: use float for ED_view3d_project_base & minor changes
Using 'short' was historic (as the value was stored in the Base). Prefer floats which allow sub-pixel distances to be differentiated. Also remove IS_CLIPPED assignment as this only made sense when the values were stored in the Base, without any other ways to check if projection failed.
This commit is contained in:
parent
87d737cd79
commit
86352364a6
|
@ -459,7 +459,7 @@ void ED_view3d_project_float_v3_m4(const struct ARegion *region,
|
|||
|
||||
eV3DProjStatus ED_view3d_project_base(const struct ARegion *region,
|
||||
struct Base *base,
|
||||
short r_co[2]);
|
||||
float r_co[2]);
|
||||
|
||||
/* *** short *** */
|
||||
eV3DProjStatus ED_view3d_project_short_ex(const struct ARegion *region,
|
||||
|
|
|
@ -77,14 +77,16 @@ void ED_view3d_project_float_v3_m4(const ARegion *region,
|
|||
|
||||
eV3DProjStatus ED_view3d_project_base(const struct ARegion *region,
|
||||
struct Base *base,
|
||||
short r_co[2])
|
||||
float r_co[2])
|
||||
{
|
||||
eV3DProjStatus ret = ED_view3d_project_short_global(
|
||||
eV3DProjStatus ret = ED_view3d_project_float_global(
|
||||
region, base->object->obmat[3], r_co, V3D_PROJ_TEST_CLIP_DEFAULT);
|
||||
|
||||
/* Prevent uninitialized values when projection fails,
|
||||
* although the callers should check the return value. */
|
||||
if (ret != V3D_PROJ_RET_OK) {
|
||||
r_co[0] = IS_CLIPPED;
|
||||
r_co[1] = 0;
|
||||
r_co[0] = -1.0;
|
||||
r_co[1] = -1.0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -574,11 +574,16 @@ static bool do_lasso_select_objects(ViewContext *vc,
|
|||
BKE_view_layer_synced_ensure(vc->scene, vc->view_layer);
|
||||
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(vc->view_layer)) {
|
||||
if (BASE_SELECTABLE(v3d, base)) { /* Use this to avoid unnecessary lasso look-ups. */
|
||||
short region_co[2];
|
||||
float region_co[2];
|
||||
const bool is_select = base->flag & BASE_SELECTED;
|
||||
const bool is_inside =
|
||||
(ED_view3d_project_base(vc->region, base, region_co) == V3D_PROJ_RET_OK) &&
|
||||
BLI_lasso_is_point_inside(mcoords, mcoords_len, region_co[0], region_co[1], IS_CLIPPED);
|
||||
const bool is_inside = (ED_view3d_project_base(vc->region, base, region_co) ==
|
||||
V3D_PROJ_RET_OK) &&
|
||||
BLI_lasso_is_point_inside(mcoords,
|
||||
mcoords_len,
|
||||
int(region_co[0]),
|
||||
int(region_co[1]),
|
||||
/* Dummy value. */
|
||||
INT_MAX);
|
||||
const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
|
||||
if (sel_op_result != -1) {
|
||||
ED_object_base_select(base, sel_op_result ? BA_SELECT : BA_DESELECT);
|
||||
|
@ -1589,6 +1594,10 @@ static bool object_mouse_select_menu(bContext *C,
|
|||
const SelectPick_Params *params,
|
||||
Base **r_basact)
|
||||
{
|
||||
|
||||
const float mval_fl[2] = {float(mval[0]), float(mval[1])};
|
||||
/* Distance from object center to use for selection. */
|
||||
const float dist_threshold = 15 * U.pixelsize;
|
||||
int base_count = 0;
|
||||
bool ok;
|
||||
LinkNodePair linklist = {nullptr, nullptr};
|
||||
|
@ -1608,11 +1617,9 @@ static bool object_mouse_select_menu(bContext *C,
|
|||
}
|
||||
}
|
||||
else {
|
||||
const int dist = 15 * U.pixelsize;
|
||||
short region_co[2];
|
||||
float region_co[2];
|
||||
if (ED_view3d_project_base(vc->region, base, region_co) == V3D_PROJ_RET_OK) {
|
||||
const int delta_px[2] = {region_co[0] - mval[0], region_co[1] - mval[1]};
|
||||
if (len_manhattan_v2_int(delta_px) < dist) {
|
||||
if (len_manhattan_v2v2(mval_fl, region_co) < dist_threshold) {
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue