You cannot optimize integral division like this. You end up multiplying by 0, 1 or 2 instead of whole spectre of ratios.
authorunc0rr
Sat, 03 Nov 2018 10:57:47 +0100
changeset 14114 9eca6f2cac6d
parent 14113 be4419243735
child 14115 1dcd7e5e0aee
You cannot optimize integral division like this. You end up multiplying by 0, 1 or 2 instead of whole spectre of ratios.
rust/landgen/src/outline.rs
--- a/rust/landgen/src/outline.rs	Sat Nov 03 09:08:13 2018 +0300
+++ b/rust/landgen/src/outline.rs	Sat Nov 03 10:57:47 2018 +0100
@@ -210,10 +210,9 @@
                 + random_numbers.next().unwrap() as i32
                     % (dist_right as i32 + dist_left as i32 - min_distance * 2);
 
-            let offset = d / p.integral_norm() as i32;
             Some(Point::new(
-                mid_point.x + p.x * offset as i32,
-                mid_point.y + p.y * offset as i32,
+                mid_point.x + p.x * d / p.integral_norm() as i32,
+                mid_point.y + p.y * d / p.integral_norm() as i32,
             ))
         }
     }