[Bf-blender-cvs] [d6d06432654] blender-v3.3-release: Fix T101196: constraint plane failing in side orthographic views
Germano Cavalcante
noreply at git.blender.org
Thu Jan 12 22:48:22 CET 2023
Commit: d6d064326549bf89a4d25b3e90a0671b10bbd5af
Author: Germano Cavalcante
Date: Tue Sep 20 14:29:16 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBd6d064326549bf89a4d25b3e90a0671b10bbd5af
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.
===================================================================
M source/blender/editors/transform/transform_constraints.c
===================================================================
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 658901a6991..d5274d3ae7d 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);
}
}
}
More information about the Bf-blender-cvs
mailing list