From bb93a912ae352ffbce4f32186a5e6cfc7762877b Mon Sep 17 00:00:00 2001
From: Mike Solomon <mike@apollinemike.com>
Date: Tue, 4 Jan 2011 10:34:36 -0500
Subject: [PATCH] Potential fix for issue 39

---
 lily/note-collision.cc |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/lily/note-collision.cc b/lily/note-collision.cc
index cc2ddb7..c7a095f 100644
--- a/lily/note-collision.cc
+++ b/lily/note-collision.cc
@@ -266,8 +266,24 @@ check_meshing_chords (Grob *me,
     shift_amount *= 0.52;
   else if (distant_half_collide && !touch)
     shift_amount *= 0.4;
-  else if (distant_half_collide || close_half_collide || full_collide)
+  else if (distant_half_collide || close_half_collide || full_collide) {
+    Real flagshift = 0.0;
+    /* kludge alert: lifted w/ slight modification from Stem::width.
+       If it is better in this instance to use Stem::width, then by
+       all means change it! */
+    if (!unsmob_grob (Note_column::get_stem (clash_up)->get_object ("beam")))
+    {
+       Interval r = Interval (-1, 1) * Stem::thickness (Note_column::get_stem (clash_up)) * 0.5;
+       r.unite (Stem::flag (Note_column::get_stem (clash_up)).extent (X_AXIS));
+       flagshift = r[RIGHT] - r[LEFT];
+    }
     shift_amount *= 0.5;
+    /* TODO: these shift factors are also magic and should be tuneable */
+    if (distant_half_collide || close_half_collide)
+      shift_amount -= (flagshift / 8);
+    else
+      shift_amount -= (flagshift / 3);
+  }
 
   /* we're meshing. */
   else if (Rhythmic_head::dot_count (head_up) || Rhythmic_head::dot_count (head_down))
-- 
1.7.3.2

