]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-collision.cc
Release: bump Welcome versions.
[lilypond.git] / lily / note-collision.cc
index 18e8e00dbaf6ba1831d23d57d45c128dceea786b..664ce234a7ea92fc1aa06ae3d2800cac70c74932 100644 (file)
@@ -33,8 +33,6 @@
 #include "stem.hh"
 #include "warn.hh"
 
-using std::vector;
-
 Real
 check_meshing_chords (Grob *me,
                       Grob *clash_up, Grob *clash_down)
@@ -57,8 +55,10 @@ check_meshing_chords (Grob *me,
   vector<int> ups = Stem::note_head_positions (stems[UP]);
   vector<int> dps = Stem::note_head_positions (stems[DOWN]);
 
+  int threshold = robust_scm2int (me->get_property ("note-collision-threshold"), 1);
+
   /* Too far apart to collide. */
-  if (ups[0] > dps.back () + 1)
+  if (ups[0] > dps.back () + threshold)
     return 0.0;
 
   /* If the chords just 'touch' their extreme noteheads,
@@ -66,8 +66,8 @@ check_meshing_chords (Grob *me,
   */
   bool touch = false;
   if (ups[0] >= dps.back ()
-      && (dps.size () < 2 || ups[0] >= dps[dps.size () - 2] + 2)
-      && (ups.size () < 2 || ups[1] >= dps.back () + 2))
+      && (dps.size () < 2 || ups[0] >= dps[dps.size () - 2] + threshold + 1)
+      && (ups.size () < 2 || ups[1] >= dps.back () + threshold + 1))
     touch = true;
 
   /* Filter out the 'o's in this configuration, since they're no
@@ -143,7 +143,9 @@ check_meshing_chords (Grob *me,
 
   for (vsize i = 0, j = 0; i < ups.size () && j < dps.size ();)
     {
-      if (abs (ups[i] - dps[j]) == 1)
+      if (ups[i] == dps[j])
+        full_collide = true;
+      else if (abs (ups[i] - dps[j]) <= threshold)
         {
           merge_possible = false;
           if (ups[i] > dps[j])
@@ -151,8 +153,6 @@ check_meshing_chords (Grob *me,
           else
             distant_half_collide = true;
         }
-      else if (ups[i] == dps[j])
-        full_collide = true;
       else if (ups[i] > dps[0] && ups[i] < dps.back ())
         merge_possible = false;
       else if (dps[j] > ups[0] && dps[j] < ups.back ())
@@ -524,11 +524,11 @@ Note_collision_interface::automatic_shift (Grob *me,
 
               // check if we cross the opposite-stemmed voices
               if (d * extents[d][i][-d] < d * extent_union[-d][d])
-                offset = std::max (offset, 0.5);
+                offset = max (offset, 0.5);
               if (extents[-d].size ()
                   && extents[d][i][UP] > extents[-d][0][DOWN]
                   && extents[d][i][DOWN] < extents[-d][0][UP])
-                offset = std::max (offset, 1.0);
+                offset = max (offset, 1.0);
             }
           offsets[d].push_back (d * offset);
         }
@@ -595,7 +595,7 @@ Note_collision_interface::note_head_positions (Grob *me)
         out.insert (out.end (), nhp.begin (), nhp.end ());
       }
 
-  vector_sort (out, std::less<int> ());
+  vector_sort (out, less<int> ());
   return out;
 }
 
@@ -609,6 +609,7 @@ ADD_INTERFACE (Note_collision_interface,
                /* properties */
                "merge-differently-dotted "
                "merge-differently-headed "
+               "note-collision-threshold "
                "positioning-done "
                "prefer-dotted-right "
               );