]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/beam.cc
Improvements in vertical skyline approximations (issue 2148).
[lilypond.git] / lily / beam.cc
index d73169a917181d046e8dfc50f9bd9cbc40b9d112..e5ea57d53b0089233e3897e88d276b840dc0be35 100644 (file)
@@ -848,9 +848,7 @@ Beam::consider_auto_knees (Grob *me)
   if (!scm_is_number (scm))
     return;
 
-  Interval_set gaps;
-
-  gaps.set_full ();
+  vector<Interval> forbidden_intervals;
 
   extract_grob_set (me, "normal-stems", stems);
 
@@ -884,15 +882,17 @@ Beam::consider_auto_knees (Grob *me)
         }
       head_extents_array.push_back (head_extents);
 
-      gaps.remove_interval (head_extents);
+      forbidden_intervals.push_back (head_extents);
     }
 
   Interval max_gap;
   Real max_gap_len = 0.0;
 
-  for (vsize i = gaps.allowed_regions_.size () - 1; i != VPOS; i--)
+  vector<Interval> allowed_regions
+    = Interval_set::interval_union (forbidden_intervals).complement ().intervals ();
+  for (vsize i = allowed_regions.size () - 1; i != VPOS; i--)
     {
-      Interval gap = gaps.allowed_regions_[i];
+      Interval gap = allowed_regions[i];
 
       /*
         the outer gaps are not knees.
@@ -1361,6 +1361,12 @@ Beam::pure_rest_collision_callback (SCM smob,
                     rest_max_pos[UP]
                    ) * ss / 2.0
                - previous;
+
+  // So that ceil below kicks in for rests that would otherwise brush
+  // up against a beam quanted to a ledger line, add a bit of space
+  // between the beam and the rest.
+  shift += (0.01 * beamdir);
+
   /* Always move by a whole number of staff spaces */
   shift = ceil (fabs (shift / ss)) * ss * sign (shift);