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:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-09-20 20:29:16 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-09-20 20:29:37 +0300
commited6c8d82b804c8c197a5ebeed5cf17a586320d95 (patch)
tree9daea9f2e03de43eadf010b1d601dab088772a20 /source/blender/editors
parent1b4cf3af4b177ae97b04b025e6b9a73267e59310 (diff)
Fix T101196: constraint plane failing in side orthographic views
Caused due to an inaccuracy when the values of `in` and `out` are too close. The solution is to project the value of `in` directly onto the plane.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/transform/transform_constraints.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 2e12611a7c9..d09bd99ef57 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -337,25 +337,20 @@ static bool isPlaneProjectionViewAligned(const TransInfo *t, const float plane[4
return fabsf(factor) < eps;
}
-static void planeProjection(const TransInfo *t, const float in[3], float out[3])
+static void planeProjection(const TransInfo *t,
+ const float plane[3],
+ const float in[3],
+ float out[3])
{
- float vec[3], factor, norm[3];
- add_v3_v3v3(vec, in, t->center_global);
- view_vector_calc(t, vec, norm);
+ float pos[3], view_vec[3], factor;
- sub_v3_v3v3(vec, out, in);
+ add_v3_v3v3(pos, in, t->center_global);
+ view_vector_calc(t, pos, view_vec);
- factor = dot_v3v3(vec, norm);
- if (factor == 0.0f) {
- return; /* prevent divide by zero */
+ if (isect_ray_plane_v3(pos, view_vec, plane, &factor, false)) {
+ madd_v3_v3v3fl(out, in, view_vec, factor);
}
- factor = dot_v3v3(vec, vec) / factor;
-
- copy_v3_v3(vec, norm);
- mul_v3_fl(vec, factor);
-
- add_v3_v3v3(out, in, vec);
}
static short transform_orientation_or_default(const TransInfo *t)
@@ -397,7 +392,6 @@ static void applyAxisConstraintVec(const TransInfo *t,
copy_v3_v3(out, in);
if (!td && t->con.mode & CON_APPLY) {
bool is_snap_to_point = false, is_snap_to_edge = false, is_snap_to_face = false;
- mul_m3_v3(t->con.pmtx, out);
if (activeSnap(t)) {
if (validSnap(t)) {
@@ -410,8 +404,11 @@ static void applyAxisConstraintVec(const TransInfo *t,
}
}
- /* With snap points, a projection is alright, no adjustments needed. */
- if (!is_snap_to_point || is_snap_to_edge || is_snap_to_face) {
+ if (is_snap_to_point) {
+ /* With snap points, a projection is alright, no adjustments needed. */
+ mul_m3_v3(t->con.pmtx, out);
+ }
+ else {
const int dims = getConstraintSpaceDimension(t);
if (dims == 2) {
if (!is_zero_v3(out)) {
@@ -428,7 +425,10 @@ static void applyAxisConstraintVec(const TransInfo *t,
else {
/* View alignment correction. */
if (!isPlaneProjectionViewAligned(t, plane)) {
- planeProjection(t, in, out);
+ planeProjection(t, plane, in, out);
+ }
+ else {
+ mul_m3_v3(t->con.pmtx, out);
}
}
}