diff options
-rw-r--r-- | source/blender/editors/curve/editcurve_paint.c | 3 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_project.c | 18 |
3 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 7f3015193ba..b249af1c8b6 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -194,7 +194,6 @@ static bool stroke_elem_project( float surface_offset, const float radius, float r_location_world[3], float r_normal_world[3]) { - View3D *v3d = cdd->vc.v3d; ARegion *ar = cdd->vc.ar; RegionView3D *rv3d = cdd->vc.rv3d; @@ -204,7 +203,7 @@ static bool stroke_elem_project( if (cdd->project.use_plane) { /* get the view vector to 'location' */ float ray_origin[3], ray_direction[3]; - ED_view3d_win_to_ray_clipped(cdd->depsgraph, cdd->vc.ar, v3d, mval_fl, ray_origin, ray_direction, false); + ED_view3d_win_to_ray(ar, mval_fl, ray_origin, ray_direction); float lambda; if (isect_ray_plane_v3(ray_origin, ray_direction, cdd->project.plane, &lambda, true)) { diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index bb272873aec..8e9c1736122 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -260,6 +260,9 @@ bool ED_view3d_win_to_ray_clipped_ex( struct Depsgraph *depsgraph, const struct ARegion *ar, const struct View3D *v3d, const float mval[2], float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip); +void ED_view3d_win_to_ray( + const struct ARegion *ar, const float mval[2], + float r_ray_start[3], float r_ray_normal[3]); void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3]); void ED_view3d_win_to_3d( const struct View3D *v3d, const struct ARegion *ar, diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 719530c7293..6e8b7c281ce 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -409,6 +409,24 @@ bool ED_view3d_win_to_ray_clipped( } /** + * Calculate a 3d viewpoint and direction vector from 2d window coordinates. + * This ray_start is located at the viewpoint, ray_normal is the direction towards mval. + * \param ar The region (used for the window width and height). + * \param mval The area relative 2d location (such as event->mval, converted into float[2]). + * \param r_ray_start The world-space point where the ray intersects the window plane. + * \param r_ray_normal The normalized world-space direction of towards mval. + * + * \note Ignores view near/far clipping, to take this into account use #ED_view3d_win_to_ray_clipped. + */ +void ED_view3d_win_to_ray( + const ARegion *ar, const float mval[2], + float r_ray_start[3], float r_ray_normal[3]) +{ + ED_view3d_win_to_origin(ar, mval, r_ray_start); + ED_view3d_win_to_vector(ar, mval, r_ray_normal); +} + +/** * Calculate a normalized 3d direction vector from the viewpoint towards a global location. * In orthographic view the resulting vector will match the view vector. * \param rv3d The region (used for the window width and height). |