simplify normal direction check for bounds distances
authoralfadur
Sat, 03 Nov 2018 07:31:35 +0300
changeset 14132 269f13ac670d
parent 14131 21642eb0ff29
child 14133 f04bc39f0c05
simplify normal direction check for bounds distances
rust/landgen/src/outline.rs
--- a/rust/landgen/src/outline.rs	Sat Nov 03 06:45:05 2018 +0300
+++ b/rust/landgen/src/outline.rs	Sat Nov 03 07:31:35 2018 +0300
@@ -129,7 +129,7 @@
                 (map_box.right() - mid_point.x) * p.y / p.x + mid_point.y);
             dist_right = (mid_point - right_intersection).integral_norm();
 
-            if p.dot(mid_point - left_intersection) < 0 {
+            if p.x > 0 {
                 std::mem::swap(&mut dist_left, &mut dist_right);
             }
         }
@@ -147,7 +147,7 @@
                 map_box.bottom());
             let dr = (mid_point - bottom_intersection).integral_norm();
 
-            if p.dot(mid_point - top_intersection) > 0 {
+            if p.y < 0 {
                 dist_left = min(dist_left, dl);
                 dist_right = min(dist_right, dr);
             } else {