Gizmo: use simple unclipped win_to_ray function
When projecting the cursor onto a plane, clipping isn't important.
This commit is contained in:
parent
8377febcb7
commit
6672019484
|
@ -186,7 +186,6 @@ bool gizmo_window_project_2d(
|
|||
/* rotate mouse in relation to the center and relocate it */
|
||||
if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
|
||||
/* For 3d views, transform 2D mouse pos onto plane. */
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
float plane[4];
|
||||
|
@ -194,19 +193,18 @@ bool gizmo_window_project_2d(
|
|||
plane_from_point_normal_v3(plane, mat[3], mat[2]);
|
||||
|
||||
float ray_origin[3], ray_direction[3];
|
||||
float lambda;
|
||||
|
||||
if (ED_view3d_win_to_ray_clipped(CTX_data_depsgraph(C), ar, v3d, mval, ray_origin, ray_direction, false)) {
|
||||
float lambda;
|
||||
if (isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, true)) {
|
||||
float co[3];
|
||||
madd_v3_v3v3fl(co, ray_origin, ray_direction, lambda);
|
||||
float imat[4][4];
|
||||
invert_m4_m4(imat, mat);
|
||||
mul_m4_v3(imat, co);
|
||||
r_co[0] = co[(axis + 1) % 3];
|
||||
r_co[1] = co[(axis + 2) % 3];
|
||||
return true;
|
||||
}
|
||||
ED_view3d_win_to_ray(ar, mval, ray_origin, ray_direction);
|
||||
if (isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, true)) {
|
||||
float co[3];
|
||||
madd_v3_v3v3fl(co, ray_origin, ray_direction, lambda);
|
||||
float imat[4][4];
|
||||
invert_m4_m4(imat, mat);
|
||||
mul_m4_v3(imat, co);
|
||||
r_co[0] = co[(axis + 1) % 3];
|
||||
r_co[1] = co[(axis + 2) % 3];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -239,7 +239,6 @@ static int gizmo_arrow_modal(
|
|||
}
|
||||
ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
|
||||
GizmoInteraction *inter = gz->interaction_data;
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
|
@ -264,31 +263,28 @@ static int gizmo_arrow_modal(
|
|||
int ok = 0;
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
if (ED_view3d_win_to_ray_clipped(
|
||||
CTX_data_depsgraph(C),
|
||||
ar, v3d, proj[j].mval,
|
||||
proj[j].ray_origin, proj[j].ray_direction, false))
|
||||
{
|
||||
/* Force Y axis if we're view aligned */
|
||||
if (j == 0) {
|
||||
if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
|
||||
normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
|
||||
}
|
||||
ED_view3d_win_to_ray(
|
||||
ar, proj[j].mval,
|
||||
proj[j].ray_origin, proj[j].ray_direction);
|
||||
/* Force Y axis if we're view aligned */
|
||||
if (j == 0) {
|
||||
if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
|
||||
normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
float arrow_no_proj[3];
|
||||
project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
|
||||
float arrow_no_proj[3];
|
||||
project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
|
||||
|
||||
normalize_v3(arrow_no_proj);
|
||||
normalize_v3(arrow_no_proj);
|
||||
|
||||
float plane[4];
|
||||
plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj);
|
||||
float plane[4];
|
||||
plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj);
|
||||
|
||||
float lambda;
|
||||
if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) {
|
||||
madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
|
||||
ok++;
|
||||
}
|
||||
float lambda;
|
||||
if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) {
|
||||
madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
|
||||
ok++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,19 +100,16 @@ static void calc_initial_placement_point_from_view(
|
|||
|
||||
if (use_mouse_project) {
|
||||
float ray_co[3], ray_no[3];
|
||||
if (ED_view3d_win_to_ray_clipped(
|
||||
CTX_data_depsgraph(C),
|
||||
ar, v3d, mval,
|
||||
ray_co, ray_no, false))
|
||||
{
|
||||
float plane[4];
|
||||
plane_from_point_normal_v3(plane, cursor_matrix[3], orient_matrix[2]);
|
||||
float lambda;
|
||||
if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, true)) {
|
||||
madd_v3_v3v3fl(r_location, ray_co, ray_no, lambda);
|
||||
copy_m3_m3(r_rotation, orient_matrix);
|
||||
return;
|
||||
}
|
||||
ED_view3d_win_to_ray(
|
||||
ar, mval,
|
||||
ray_co, ray_no);
|
||||
float plane[4];
|
||||
plane_from_point_normal_v3(plane, cursor_matrix[3], orient_matrix[2]);
|
||||
float lambda;
|
||||
if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, true)) {
|
||||
madd_v3_v3v3fl(r_location, ray_co, ray_no, lambda);
|
||||
copy_m3_m3(r_rotation, orient_matrix);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue