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:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-01-10 11:55:09 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-01-10 12:15:20 +0300
commit80ffa73b3f87caef9511c073e6ff2e004de7f5b3 (patch)
tree638bb3ad5ac646ed292b6b2b045bff911dedcc34 /source/blender/blenkernel/intern/shrinkwrap.c
parent0f99845d2f153cf5fce42264bd9217e9f2eb2759 (diff)
Fix T60285: allow negative offsets in shrinkwrap (worked in 2.79).
Diffstat (limited to 'source/blender/blenkernel/intern/shrinkwrap.c')
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index a411422003d..73b2d9aa336 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -1182,17 +1182,22 @@ static void shrinkwrap_snap_with_side(float r_point_co[3], const float point_co[
/* If exactly on the surface, push out along normal */
if (dist < FLT_EPSILON) {
- madd_v3_v3v3fl(r_point_co, hit_co, hit_no, goal_dist * forcesign);
+ if (forcesnap || goal_dist > 0) {
+ madd_v3_v3v3fl(r_point_co, hit_co, hit_no, goal_dist * forcesign);
+ }
+ else {
+ copy_v3_v3(r_point_co, hit_co);
+ }
}
/* Move to the correct side if needed */
else {
float delta[3];
sub_v3_v3v3(delta, point_co, hit_co);
- float dsign = signf(dot_v3v3(delta, hit_no));
+ float dsign = signf(dot_v3v3(delta, hit_no) * forcesign);
/* If on the wrong side or too close, move to correct */
- if (forcesnap || dsign * forcesign < 0 || dist < goal_dist) {
- interp_v3_v3v3(r_point_co, point_co, hit_co, (dist - goal_dist * dsign * forcesign) / dist);
+ if (forcesnap || dsign * dist < goal_dist) {
+ interp_v3_v3v3(r_point_co, point_co, hit_co, (dist - goal_dist * dsign) / dist);
}
else {
copy_v3_v3(r_point_co, point_co);
@@ -1217,7 +1222,7 @@ void BKE_shrinkwrap_snap_point_to_surface(
switch (mode) {
/* Offsets along the line between point_co and hit_co. */
case MOD_SHRINKWRAP_ON_SURFACE:
- if (goal_dist > 0 && (dist = len_v3v3(point_co, hit_co)) > FLT_EPSILON) {
+ if (goal_dist != 0 && (dist = len_v3v3(point_co, hit_co)) > FLT_EPSILON) {
interp_v3_v3v3(r_point_co, point_co, hit_co, (dist - goal_dist) / dist);
}
else {
@@ -1234,7 +1239,7 @@ void BKE_shrinkwrap_snap_point_to_surface(
break;
case MOD_SHRINKWRAP_OUTSIDE_SURFACE:
- if (goal_dist > 0) {
+ if (goal_dist != 0) {
shrinkwrap_snap_with_side(r_point_co, point_co, hit_co, hit_no, goal_dist, +1, true);
}
else {
@@ -1244,7 +1249,7 @@ void BKE_shrinkwrap_snap_point_to_surface(
/* Offsets along the normal */
case MOD_SHRINKWRAP_ABOVE_SURFACE:
- if (goal_dist > 0) {
+ if (goal_dist != 0) {
BKE_shrinkwrap_compute_smooth_normal(tree, transform, hit_idx, hit_co, hit_no, tmp);
madd_v3_v3v3fl(r_point_co, hit_co, tmp, goal_dist);
}