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-02-02 04:03:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-02-02 04:40:07 +0300
commit7c04c3c960bc1351433f43aa7e83ff041a2c2cc3 (patch)
treeba1674a54674220b269cb94a17dd0160a33e444b /source/blender/editors/transform/transform_constraints.c
parentc0d2de25d15c255b5a772acc5b32b8e722e3e635 (diff)
Use simpler method to check the planes view aligned
Diffstat (limited to 'source/blender/editors/transform/transform_constraints.c')
-rw-r--r--source/blender/editors/transform/transform_constraints.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 17adff9b609..beeba7cf10f 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -280,9 +280,7 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
*/
static bool isPlaneProjectionViewAligned(TransInfo *t)
{
- RegionView3D *rv3d = t->ar->regiondata;
const float eps = 0.001f;
-
const float *constraint_vector[2];
int n = 0;
for (int i = 0; i < 3; i++) {
@@ -295,28 +293,15 @@ static bool isPlaneProjectionViewAligned(TransInfo *t)
}
BLI_assert(n == 2);
- float points[2][3];
- add_v3_v3v3(points[0], constraint_vector[0], t->center_global);
- add_v3_v3v3(points[1], constraint_vector[1], t->center_global);
-
- float coords[3][2];
- projectFloatView(t, points[0], coords[0]);
- projectFloatView(t, t->center_global, coords[1]);
- projectFloatView(t, points[1], coords[2]);
-
- float dir[2][2];
-
- sub_v2_v2v2(dir[0], coords[0], coords[1]);
- sub_v2_v2v2(dir[1], coords[2], coords[1]);
+ float view_to_plane[3], plane_normal[3];
- /* remove pixel scaling */
- float scale = mul_project_m4_v3_zfac((float(*)[4])rv3d->persmat, t->center_global) * rv3d->pixsize;
- mul_v2_fl(dir[0], scale);
- mul_v2_fl(dir[1], scale);
+ getViewVector(t, t->center_global, view_to_plane);
- float area = fabsf(cross_v2v2(dir[0], dir[1]));
+ cross_v3_v3v3(plane_normal, constraint_vector[0], constraint_vector[1]);
+ normalize_v3(plane_normal);
- return (area < eps);
+ float factor = dot_v3v3(plane_normal, view_to_plane);
+ return fabsf(factor) < eps;
}
static void planeProjection(TransInfo *t, const float in[3], float out[3])