]> git.donarmstrong.com Git - lilypond.git/commitdiff
Use distance to original point rather than size of allowed region for
authorHan-Wen Nienhuys <hanwen@lilypond.org>
Fri, 15 Apr 2011 02:45:51 +0000 (23:45 -0300)
committerHan-Wen Nienhuys <hanwen@lilypond.org>
Fri, 15 Apr 2011 02:47:26 +0000 (23:47 -0300)
tie-breaking.

Add regression test.

input/regression/beam-collision-large-object.ly [new file with mode: 0644]
lily/beam.cc

diff --git a/input/regression/beam-collision-large-object.ly b/input/regression/beam-collision-large-object.ly
new file mode 100644 (file)
index 0000000..a3dd1dc
--- /dev/null
@@ -0,0 +1,15 @@
+\header {
+  texidoc = "Behave sensibly in the presence of large collisions."
+}
+
+\version "2.13.59"
+\new Staff {
+  <<
+    { \voiceOne s2 }
+    \\
+    { \voiceTwo e4 e }
+    \\
+    { \voiceFour
+      f''8[ e'' a'' g''] }
+  >>
+}
index f39bf9f62c06e55f0914bf5e83004ad775b96bde..6845b1346be59a2eefe2b3499965057993ee1b69 100644 (file)
@@ -1303,9 +1303,10 @@ Beam::shift_region_to_valid (SCM grob, SCM posns)
            || !collision_free[UP].is_empty ())
     {
       // We have space above or below collisions (or, no collisions at
-      // all).
+      // all).  Should we factor in the size of the collision_free
+      // interval as well?
       Interval best =  
-        (collision_free[DOWN].length () > collision_free[UP].length ()) ?
+        (collision_free[DOWN].distance(beam_left_y) < collision_free[UP].distance (beam_left_y)) ?
         collision_free[DOWN] : collision_free[UP];
 
       beam_left_y = point_in_interval (best, 2.0);