]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-collision.cc
Merge remote branch 'origin/release/unstable' into HEAD
[lilypond.git] / lily / note-collision.cc
index 3d14a3649bef67db281fdf53475171e59561aa5f..7c43dddd4860bac3e2a608659ee92f0610d4e592 100644 (file)
@@ -56,13 +56,35 @@ check_meshing_chords (Grob *me,
   Grob *head_up = Note_column::first_head (clash_up);
   Grob *head_down = Note_column::first_head (clash_down);
 
-  vector<int> ups = Stem::note_head_positions (Note_column::get_stem (clash_up));
-  vector<int> dps = Stem::note_head_positions (Note_column::get_stem (clash_down));
+  /* Staff-positions of all noteheads on each stem */
+  vector<int> ups = Stem::note_head_positions (stems[UP]);
+  vector<int> dps = Stem::note_head_positions (stems[DOWN]);
 
   /* Too far apart to collide. */
   if (ups[0] > dps.back () + 1)
     return;
 
+  /* If the chords just 'touch' their extreme noteheads,
+     then we can align their stems.
+  */
+  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))
+    touch = true;
+
+  /* Filter out the 'o's in this configuration, since they're no
+   * part in the collision.
+   *
+   *  |
+   * x|o
+   * x|o
+   * x
+   *
+   */
+  ups = Stem::note_head_positions (stems[UP], true);
+  dps = Stem::note_head_positions (stems[DOWN], true);
+
   /* Merge heads if the notes lie the same line, or if the "stem-up-note" is
      above the "stem-down-note". */
   bool merge_possible = (ups[0] >= dps[0]) && (ups.back () >= dps.back ());
@@ -118,16 +140,6 @@ check_meshing_chords (Grob *me,
    *
    */
 
-  /* TODO: filter out the 'o's in this configuration, since they're no
-   * part in the collision.
-   *
-   *  |
-   * x|o
-   * x|o
-   * x
-   *
-   */
-
   bool close_half_collide = false;
   bool distant_half_collide = false;
   bool full_collide = false;
@@ -163,16 +175,6 @@ check_meshing_chords (Grob *me,
   full_collide = full_collide || (close_half_collide
                                   && distant_half_collide);
 
-  /* If the only collision is in the extreme noteheads,
-     then their stems can line up and the chords just 'touch'.
-     A half collision with the next note along the chord prevents touching.
-  */
-  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))
-    touch = true;
-
   /* Determine which chord goes on the left, and which goes right.
      Up-stem usually goes on the right, but if chords just 'touch' we can put
      both stems on a common vertical line.  In the presense of collisions,
@@ -354,7 +356,7 @@ check_meshing_chords (Grob *me,
           extract_grob_set (stem, "note-heads", heads);
           for (vsize i = 0; i < heads.size (); i++)
             unsmob_grob (heads[i]->get_object ("dot"))
-              ->set_property ("direction", scm_from_int (dir));
+            ->set_property ("direction", scm_from_int (dir));
         }
     }
 
@@ -525,12 +527,12 @@ Note_collision_interface::automatic_shift (Grob *me,
   while ((flip (&d)) != UP);
 
   /*
-    do horizontal shifts of each direction
-
-    |
-    x||
-    x||
-    x|
+   * do horizontal shifts of each direction
+   *
+    |
+   * x||
+    x||
+   *   x|
   */
 
   do