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>2016-04-04 11:01:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-04-04 11:36:37 +0300
commit3de9b2ca74deb3aef077bf6f0ecc5bf8fb22fa8a (patch)
tree4701b61e9015eba7c134230efcc5738180b49c49 /source/blender/editors/curve/editcurve.c
parent8f1223b6362a42b406367d9693166854538a5dc4 (diff)
Fix curve add-vertex w/ 2D curves
Project the point onto the 2d place where possible.
Diffstat (limited to 'source/blender/editors/curve/editcurve.c')
-rw-r--r--source/blender/editors/curve/editcurve.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 22cb479e77d..5c439dc2776 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4980,6 +4980,37 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
location, no_dummy, &dist_px_dummy);
}
+ if ((cu->flag & CU_3D) == 0) {
+ const float eps = 1e-6f;
+
+ /* get the view vector to 'location' */
+ float view_dir[3];
+ ED_view3d_global_to_vector(vc.rv3d, location, view_dir);
+
+ /* get the plane */
+ float plane[4];
+ /* only normalize to avoid precision errors */
+ normalize_v3_v3(plane, vc.obedit->obmat[2]);
+ plane[3] = -dot_v3v3(plane, vc.obedit->obmat[3]);
+
+ if (fabsf(dot_v3v3(view_dir, plane)) < eps) {
+ /* can't project on an aligned plane. */
+ }
+ else {
+ float lambda;
+ if (isect_ray_plane_v3(location, view_dir, plane, &lambda, false)) {
+ /* check if we're behind the viewport */
+ float location_test[3];
+ madd_v3_v3v3fl(location_test, location, view_dir, lambda);
+ if ((vc.rv3d->is_persp == false) ||
+ (mul_project_m4_v3_zfac(vc.rv3d->persmat, location_test) > 0.0f))
+ {
+ copy_v3_v3(location, location_test);
+ }
+ }
+ }
+ }
+
RNA_float_set_array(op->ptr, "location", location);
}