Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-09-20 05:13:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-20 05:13:11 +0300
commit66720194840b11bdfb0f26e4191d1f214cdc2e8e (patch)
treef6c54888610c462ce5fb28cbe835a73d8b7ce759 /source/blender/editors/gizmo_library
parent8377febcb710d339a683ab78de0eb795659553bc (diff)
Gizmo: use simple unclipped win_to_ray function
When projecting the cursor onto a plane, clipping isn't important.
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_utils.c26
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c38
2 files changed, 29 insertions, 35 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c
index 0995a73ebfc..e3b93e671df 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c
@@ -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];
-
- 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;
- }
+ float lambda;
+
+ 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;
}
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
index 8b504befa16..4e41f95a063 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
@@ -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++;
}
}