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:
authorMartin Poirier <theeth@yahoo.com>2005-08-25 22:03:19 +0400
committerMartin Poirier <theeth@yahoo.com>2005-08-25 22:03:19 +0400
commit6c9d743ef42053c189a466b76640ab40e94b71ee (patch)
tree6d9a197c11dcacb2ffed3c73c0682b14fc7b5498 /source/blender/src/transform_constraints.c
parent8d940dfafe577ea92c279cc41e791b0012c78d2b (diff)
Based on a suggestion from Zr, using line line intersection for single axis projection.
This makes perspective handling a bit better.
Diffstat (limited to 'source/blender/src/transform_constraints.c')
-rwxr-xr-xsource/blender/src/transform_constraints.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c
index 7efe4a5cd55..fcebab5412d 100755
--- a/source/blender/src/transform_constraints.c
+++ b/source/blender/src/transform_constraints.c
@@ -166,6 +166,9 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) {
float norm[3], n[3], n2[3], vec[3], factor;
+
+ if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f)
+ return;
/* For when view is parallel to constraint... will cause NaNs otherwise
So we take vertical motion in 3D space and apply it to the
@@ -182,32 +185,26 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
VecMulf(out, -factor); /* -factor makes move down going backwards */
}
else {
- // prevent division by zero, happens on constrainting without initial delta transform */
- if(in[0]!=0.0f || in[1]!=0.0f || in[2]!=0.0f) {
- /* project axis on viewplane */
- Projf(vec, axis, t->viewinv[2]);
- VecSubf(vec, axis, vec);
- /* project input on the new axis */
- Projf(vec, in, vec);
- /* get view vector on that point (account for perspective) */
- VecAddf(vec, vec, t->con.center);
- getViewVector(vec, norm);
-
- /* cross product twice to get a full space definition */
- Crossf(n, axis, norm);
- Crossf(n2, norm, n);
-
- /* Project input on plane perpendicular to the axis (as drawn on screen) */
- Projf(vec, in, n2);
-
- /* Adjust output */
- factor = Inpf(axis, vec);
- if (factor == 0.0f) return; /* prevent divide by zero */
- factor = Inpf(vec, vec) / factor;
-
- VecMulf(axis, factor);
- VECCOPY(out, axis);
- }
+ float cb[3], ab[3];
+
+ VECCOPY(out, axis);
+
+ /* Get view vector on axis to define a plane */
+ getViewVector(t->con.center, norm);
+ Crossf(vec, norm, axis);
+
+ /* Project input vector on the plane passing on axis */
+ Projf(vec, in, vec);
+ VecSubf(vec, in, vec);
+
+ /* Get the view vector there */
+ getViewVector(vec, norm);
+
+ /* intersect the two lines: axis and norm */
+ Crossf(cb, vec, norm);
+ Crossf(ab, axis, norm);
+
+ VecMulf(out, Inpf(cb, ab) / Inpf(ab, ab));
}
}