[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56220] trunk/blender/source/blender/ editors: fix [#35007] clipping border error
Campbell Barton
ideasman42 at gmail.com
Mon Apr 22 22:00:40 CEST 2013
Revision: 56220
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56220
Author: campbellbarton
Date: 2013-04-22 20:00:37 +0000 (Mon, 22 Apr 2013)
Log Message:
-----------
fix [#35007] clipping border error
add clip option to ED_view3d_win_to_ray(), ED_view3d_win_to_segment()
Modified Paths:
--------------
trunk/blender/source/blender/editors/armature/editarmature_sketch.c
trunk/blender/source/blender/editors/include/ED_view3d.h
trunk/blender/source/blender/editors/mesh/editmesh_knife.c
trunk/blender/source/blender/editors/mesh/editmesh_utils.c
trunk/blender/source/blender/editors/physics/particle_edit.c
trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
trunk/blender/source/blender/editors/space_view3d/view3d_project.c
trunk/blender/source/blender/editors/transform/transform_snap.c
Modified: trunk/blender/source/blender/editors/armature/editarmature_sketch.c
===================================================================
--- trunk/blender/source/blender/editors/armature/editarmature_sketch.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/armature/editarmature_sketch.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -904,7 +904,7 @@
float pval[2] = {0, 0};
ED_view3d_project_float_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP);
- ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal);
+ ED_view3d_win_to_ray(ar, v3d, pval, ray_start, ray_normal, false);
mul_v3_fl(ray_normal, distance * progress / length);
add_v3_v3(stk->points[i].p, ray_normal);
@@ -1557,7 +1557,7 @@
mval[0] = vi[0];
mval[1] = vi[1];
- ED_view3d_win_to_segment_clip(ar, v3d, mval, ray_start, ray_end);
+ ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end, true);
isect_line_line_v3(stk->points[s_i].p,
stk->points[s_i + 1].p,
Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h 2013-04-22 20:00:37 UTC (rev 56220)
@@ -196,16 +196,15 @@
eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag);
float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip);
-void ED_view3d_win_to_ray(const struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]);
+bool ED_view3d_win_to_ray(const struct ARegion *ar, struct View3D *v3d, const float mval[2],
+ float ray_start[3], float ray_normal[3], const bool do_clip);
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 ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]);
void ED_view3d_win_to_3d_int(const struct ARegion *ar, const float depth_pt[3], const int mval[2], float out[3]);
void ED_view3d_win_to_delta(const struct ARegion *ar, const float mval[2], float out[3], const float zfac);
void ED_view3d_win_to_vector(const struct ARegion *ar, const float mval[2], float out[3]);
-void ED_view3d_win_to_segment(const struct ARegion *ar, struct View3D *v3d, const float mval[2],
- float ray_start[3], float ray_end[3]);
-bool ED_view3d_win_to_segment_clip(const struct ARegion *ar, struct View3D *v3d, const float mval[2],
- float ray_start[3], float ray_end[3]);
+bool ED_view3d_win_to_segment(const struct ARegion *ar, struct View3D *v3d, const float mval[2],
+ float r_ray_start[3], float r_ray_end[3], const bool do_clip);
void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]);
void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z);
Modified: trunk/blender/source/blender/editors/mesh/editmesh_knife.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_knife.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/mesh/editmesh_knife.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -1394,8 +1394,8 @@
return;
/* unproject screen line */
- ED_view3d_win_to_segment_clip(kcd->ar, kcd->vc.v3d, s1, v1, v3);
- ED_view3d_win_to_segment_clip(kcd->ar, kcd->vc.v3d, s2, v2, v4);
+ ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s1, v1, v3, true);
+ ED_view3d_win_to_segment(kcd->ar, kcd->vc.v3d, s2, v2, v4, true);
mul_m4_v3(kcd->ob->imat, v1);
mul_m4_v3(kcd->ob->imat, v2);
Modified: trunk/blender/source/blender/editors/mesh/editmesh_utils.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_utils.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/mesh/editmesh_utils.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -1418,7 +1418,7 @@
const float mval_f[2] = {ar->winx / 2.0f,
ar->winy / 2.0f};
- ED_view3d_win_to_segment(ar, v3d, mval_f, origin, end);
+ ED_view3d_win_to_segment(ar, v3d, mval_f, origin, end, false);
invert_m4_m4(invmat, obedit->obmat);
mul_m4_v3(invmat, origin);
Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -3293,7 +3293,7 @@
mco[0] = data->mval[0] + dmx;
mco[1] = data->mval[1] + dmy;
- ED_view3d_win_to_segment_clip(data->vc.ar, data->vc.v3d, mco, co1, co2);
+ ED_view3d_win_to_segment(data->vc.ar, data->vc.v3d, mco, co1, co2, true);
mul_m4_v3(imat, co1);
mul_m4_v3(imat, co2);
Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -4102,7 +4102,7 @@
sculpt_stroke_modifiers_check(C, ob);
/* TODO: what if the segment is totally clipped? (return == 0) */
- ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mouse, ray_start, ray_end);
+ ED_view3d_win_to_segment(vc.ar, vc.v3d, mouse, ray_start, ray_end, true);
invert_m4_m4(obimat, ob->obmat);
mul_m4_v3(obimat, ray_start);
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_project.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_project.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_project.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -307,14 +307,18 @@
* \param mval The area relative 2d location (such as event->mval, converted into float[2]).
* \param ray_start The world-space starting point of the segment.
* \param ray_normal The normalized world-space direction of towards mval.
+ * \return success, false if the segment is totally clipped.
*/
-void ED_view3d_win_to_ray(const ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
+bool ED_view3d_win_to_ray(const ARegion *ar, View3D *v3d, const float mval[2],
+ float r_ray_start[3], float r_ray_normal[3], const bool do_clip)
{
float ray_end[3];
+ bool is_clip;
- ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end);
- sub_v3_v3v3(ray_normal, ray_end, ray_start);
- normalize_v3(ray_normal);
+ is_clip = ED_view3d_win_to_segment(ar, v3d, mval, r_ray_start, ray_end, do_clip);
+ sub_v3_v3v3(r_ray_normal, ray_end, r_ray_start);
+ normalize_v3(r_ray_normal);
+ return is_clip;
}
/**
@@ -474,8 +478,22 @@
normalize_v3(out);
}
-void ED_view3d_win_to_segment(const ARegion *ar, View3D *v3d, const float mval[2],
- float ray_start[3], float ray_end[3])
+/**
+ * Calculate a 3d segment from 2d window coordinates.
+ * This ray_start is located at the viewpoint, ray_end is a far point.
+ * ray_start and ray_end are clipped by the view near and far limits
+ * so points along this line are always in view.
+ * In orthographic view all resulting segments will be parallel.
+ * \param ar The region (used for the window width and height).
+ * \param v3d The 3d viewport (used for near and far clipping range).
+ * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
+ * \param r_ray_start The world-space starting point of the segment.
+ * \param r_ray_end The world-space end point of the segment.
+ * \param do_clip Optionally clip the ray by the view clipping planes.
+ * \return success, false if the segment is totally clipped.
+ */
+bool ED_view3d_win_to_segment(const ARegion *ar, View3D *v3d, const float mval[2],
+ float ray_start[3], float ray_end[3], const bool do_clip)
{
RegionView3D *rv3d = ar->regiondata;
@@ -499,29 +517,9 @@
madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f);
madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f);
}
-}
-/**
- * Calculate a 3d segment from 2d window coordinates.
- * This ray_start is located at the viewpoint, ray_end is a far point.
- * ray_start and ray_end are clipped by the view near and far limits
- * so points along this line are always in view.
- * In orthographic view all resulting segments will be parallel.
- * \param ar The region (used for the window width and height).
- * \param v3d The 3d viewport (used for near and far clipping range).
- * \param mval The area relative 2d location (such as event->mval, converted into float[2]).
- * \param ray_start The world-space starting point of the segment.
- * \param ray_end The world-space end point of the segment.
- * \return success, false if the segment is totally clipped.
- */
-bool ED_view3d_win_to_segment_clip(const ARegion *ar, View3D *v3d, const float mval[2],
- float ray_start[3], float ray_end[3])
-{
- RegionView3D *rv3d = ar->regiondata;
- ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end);
-
- /* clipping */
- if (rv3d->rflag & RV3D_CLIPPING) {
+ /* bounds clipping */
+ if (do_clip && (rv3d->rflag & RV3D_CLIPPING)) {
if (clip_segment_v3_plane_n(ray_start, ray_end, rv3d->clip, 6) == false) {
return false;
}
@@ -530,7 +528,6 @@
return true;
}
-
/* Utility functions for projection
* ******************************** */
Modified: trunk/blender/source/blender/editors/transform/transform_snap.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_snap.c 2013-04-22 19:39:10 UTC (rev 56219)
+++ trunk/blender/source/blender/editors/transform/transform_snap.c 2013-04-22 20:00:37 UTC (rev 56220)
@@ -1606,7 +1606,9 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list